mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-23 15:19:38 +02:00
Scaffold out the UI for individual account page (#461)
* Add `AccountBalance` table for account views * Scaffold out account UI * Add D3 line chart scaffolding * Style fixes
This commit is contained in:
parent
0490fda465
commit
3ec9c9b56b
47 changed files with 724 additions and 12 deletions
|
@ -9,7 +9,9 @@ class AccountsController < ApplicationController
|
|||
end
|
||||
|
||||
def show
|
||||
@account = Current.family.accounts.find(params[:id])
|
||||
# Temporary while dummy data is being used
|
||||
# @account = Current.family.accounts.find(params[:id])
|
||||
@account = sample_account
|
||||
end
|
||||
|
||||
def create
|
||||
|
@ -23,9 +25,40 @@ class AccountsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
private
|
||||
|
||||
def account_params
|
||||
params.require(:account).permit(:name, :accountable_type, :original_balance, :original_currency, :subtype)
|
||||
end
|
||||
|
||||
def sample_account
|
||||
OpenStruct.new(
|
||||
id: 1,
|
||||
name: "Sample Account",
|
||||
original_balance: BigDecimal("1115181"),
|
||||
original_currency: "USD",
|
||||
converted_balance: BigDecimal("1115181"), # Assuming conversion rate is 1 for simplicity
|
||||
converted_currency: "USD",
|
||||
dollar_change: BigDecimal("1553.43"), # Added dollar change
|
||||
percent_change: BigDecimal("0.9"), # Added percent change
|
||||
subtype: "Checking",
|
||||
accountable_type: "Depository",
|
||||
balances: sample_balances
|
||||
)
|
||||
end
|
||||
|
||||
def sample_balances
|
||||
4.times.map do |i|
|
||||
OpenStruct.new(
|
||||
date: "Feb #{12 + i} 2024",
|
||||
description: "Manually entered",
|
||||
amount: BigDecimal("1000") + (i * BigDecimal("100")),
|
||||
change: i == 3 ? -50 : (i == 2 ? 0 : 100 + (i * 10)),
|
||||
percentage_change: i == 3 ? -5 : (i == 2 ? 0 : 10 + i),
|
||||
icon: i == 3 ? "arrow-down" : (i == 2 ? "minus" : (i.even? ? "arrow-down" : "arrow-up"))
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue