1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-08-05 05:25:24 +02:00

Scaffold out basic transactions model and UI (#478)

* Transaction scaffold

* Rough in transaction views

* Fix sort order

* Fix mass assignment issue

* Fix test

* Simplify CI workflow

* Don't seed db before test
This commit is contained in:
Zach Gollwitzer 2024-02-23 21:34:33 -05:00 committed by GitHub
parent e767aca37f
commit 87b97b3c41
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
26 changed files with 430 additions and 44 deletions

View file

@ -40,6 +40,15 @@ valuations = [
{ date: Date.today - 3, value: 301900 }
]
transactions = [
{ date: Date.today - 27, amount: 7.56, currency: "USD", name: "Starbucks" },
{ date: Date.today - 18, amount: -2000, currency: "USD", name: "Paycheck" },
{ date: Date.today - 18, amount: 18.20, currency: "USD", name: "Walgreens" },
{ date: Date.today - 13, amount: 34.20, currency: "USD", name: "Chipotle" },
{ date: Date.today - 9, amount: -200, currency: "USD", name: "Birthday check" },
{ date: Date.today - 5, amount: 85.00, currency: "USD", name: "Amazon stuff" }
]
# Represent system-generated "Balances" at various dates, based on valuations
balances = [
{ date: Date.today - 30, balance: 300000 },
@ -75,6 +84,8 @@ balances = [
{ date: Date.today, balance: current_balance }
]
valuations.each do |valuation|
Valuation.find_or_create_by(
account_id: account.id,
@ -93,3 +104,14 @@ balances.each do |balance|
balance_record.balance = balance[:balance]
end
end
transactions.each do |transaction|
Transaction.find_or_create_by(
account_id: account.id,
date: transaction[:date],
amount: transaction[:amount]
) do |transaction_record|
transaction_record.currency = transaction[:currency]
transaction_record.name = transaction[:name]
end
end