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

Centralize entry naming (#2454)
Some checks failed
Publish Docker image / ci (push) Has been cancelled
Publish Docker image / Build docker image (push) Has been cancelled

* Centralize entry naming

* Lint fixes, code style
This commit is contained in:
Zach Gollwitzer 2025-07-10 18:40:38 -04:00 committed by GitHub
parent afbfb474c2
commit 9110ab27d2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 187 additions and 16 deletions

View file

@ -29,13 +29,11 @@ class Trade::CreateForm
end
def create_trade
prefix = type == "sell" ? "Sell " : "Buy "
trade_name = prefix + "#{qty.to_i.abs} shares of #{security.ticker}"
signed_qty = type == "sell" ? -qty.to_d : qty.to_d
signed_amount = signed_qty * price.to_d
trade_entry = account.entries.new(
name: trade_name,
name: Trade.build_name(type, qty, security.ticker),
date: date,
amount: signed_amount,
currency: currency,