1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-08-04 21:15:19 +02:00

Fix transfers and form currencies (#1477)
Some checks are pending
Publish Docker image / ci (push) Waiting to run
Publish Docker image / Build docker image (push) Blocked by required conditions

This commit is contained in:
Zach Gollwitzer 2024-11-18 15:50:47 -05:00 committed by GitHub
parent fcb95207d7
commit 81d604f3d4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 41 additions and 19 deletions

View file

@ -3,7 +3,7 @@ class Account::TransactionBuilder
TYPES = %w[income expense interest transfer_in transfer_out].freeze
attr_accessor :type, :amount, :date, :account, :transfer_account_id
attr_accessor :type, :amount, :date, :account, :currency, :transfer_account_id
validates :type, :amount, :date, presence: true
validates :type, inclusion: { in: TYPES }
@ -45,8 +45,9 @@ class Account::TransactionBuilder
def build_entry(account_id, amount, marked_as_transfer: false)
Account::Entry.new \
account_id: account_id,
name: marked_as_transfer ? (amount < 0 ? "Deposit" : "Withdrawal") : "Interest",
amount: amount,
currency: account.currency,
currency: currency,
date: date,
marked_as_transfer: marked_as_transfer,
entryable: Account::Transaction.new