mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-08-02 20:15:22 +02:00
Add currency validation to account, update demo data generator (#996)
* Add currency validation to account, update demo data generator * Fix tests
This commit is contained in:
parent
ef0f910b9b
commit
b200b71284
6 changed files with 44 additions and 27 deletions
|
@ -4,7 +4,7 @@ class Account < ApplicationRecord
|
|||
|
||||
broadcasts_refreshes
|
||||
|
||||
validates :family, presence: true
|
||||
validates :name, :balance, :currency, presence: true
|
||||
|
||||
belongs_to :family
|
||||
belongs_to :institution, optional: true
|
||||
|
|
|
@ -100,6 +100,7 @@ class Demo::Generator
|
|||
accountable: CreditCard.new,
|
||||
name: "Chase Credit Card",
|
||||
balance: 2300,
|
||||
currency: "USD",
|
||||
institution: family.institutions.find_or_create_by(name: "Chase")
|
||||
|
||||
50.times do
|
||||
|
@ -126,6 +127,7 @@ class Demo::Generator
|
|||
accountable: Depository.new,
|
||||
name: "Chase Checking",
|
||||
balance: 15000,
|
||||
currency: "USD",
|
||||
institution: family.institutions.find_or_create_by(name: "Chase")
|
||||
|
||||
10.times do
|
||||
|
@ -149,6 +151,7 @@ class Demo::Generator
|
|||
accountable: Depository.new,
|
||||
name: "Demo Savings",
|
||||
balance: 40000,
|
||||
currency: "USD",
|
||||
subtype: "savings",
|
||||
institution: family.institutions.find_or_create_by(name: "Chase")
|
||||
|
||||
|
@ -195,6 +198,7 @@ class Demo::Generator
|
|||
accountable: Investment.new,
|
||||
name: "Robinhood",
|
||||
balance: 100000,
|
||||
currency: "USD",
|
||||
institution: family.institutions.find_or_create_by(name: "Robinhood")
|
||||
|
||||
aapl = Security.find_by(symbol: "AAPL")
|
||||
|
@ -228,7 +232,8 @@ class Demo::Generator
|
|||
house = family.accounts.create! \
|
||||
accountable: Property.new,
|
||||
name: "123 Maybe Way",
|
||||
balance: 560000
|
||||
balance: 560000,
|
||||
currency: "USD"
|
||||
|
||||
create_valuation!(house, 3.years.ago.to_date, 520000)
|
||||
create_valuation!(house, 2.years.ago.to_date, 540000)
|
||||
|
@ -237,19 +242,22 @@ class Demo::Generator
|
|||
family.accounts.create! \
|
||||
accountable: Loan.new,
|
||||
name: "Mortgage",
|
||||
balance: 495000
|
||||
balance: 495000,
|
||||
currency: "USD"
|
||||
end
|
||||
|
||||
def create_car_and_loan!
|
||||
family.accounts.create! \
|
||||
accountable: Vehicle.new,
|
||||
name: "Honda Accord",
|
||||
balance: 18000
|
||||
balance: 18000,
|
||||
currency: "USD"
|
||||
|
||||
family.accounts.create! \
|
||||
accountable: Loan.new,
|
||||
name: "Car Loan",
|
||||
balance: 8000
|
||||
balance: 8000,
|
||||
currency: "USD"
|
||||
end
|
||||
|
||||
def create_transaction!(attributes = {})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue