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

Allow user to add buy and sell trade transactions for investment accounts (#1066)

* Consolidate modal form structure into partial + helper

* Scaffold out trade transaction form

* Normalize translations

* Add buy and sell trade form with tests

* Move entryable lists to dedicated controllers

* Delegate entry group contents rendering

* More cleanup

* Extract transaction and valuation update logic from entries controller

* Delegate edit and show actions to entryables

* Trade builder

* Update paths for transaction updates
This commit is contained in:
Zach Gollwitzer 2024-08-09 11:22:57 -04:00 committed by GitHub
parent 6bca35fa22
commit e05f03b314
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
75 changed files with 801 additions and 624 deletions

View file

@ -1,74 +1,6 @@
{
"ignored_warnings": [
{
"warning_type": "Dynamic Render Path",
"warning_code": 15,
"fingerprint": "6179565a9eb1786348e6bbaf5d838b77f9075551930a6ca8ba33fbbf6d2adf26",
"check_name": "Render",
"message": "Render path contains parameter value",
"file": "app/views/account/entries/show.html.erb",
"line": 1,
"link": "https://brakemanscanner.org/docs/warning_types/dynamic_render_path/",
"code": "render(partial => permitted_entryable_partial_path(Current.family.accounts.find(params[:account_id]).entries.find(params[:id]), \"show\"), { :locals => ({ :entry => Current.family.accounts.find(params[:account_id]).entries.find(params[:id]) }) })",
"render_path": [
{
"type": "controller",
"class": "Account::EntriesController",
"method": "show",
"line": 42,
"file": "app/controllers/account/entries_controller.rb",
"rendered": {
"name": "account/entries/show",
"file": "app/views/account/entries/show.html.erb"
}
}
],
"location": {
"type": "template",
"template": "account/entries/show"
},
"user_input": "params[:id]",
"confidence": "Weak",
"cwe_id": [
22
],
"note": ""
},
{
"warning_type": "Dynamic Render Path",
"warning_code": 15,
"fingerprint": "7a182d062523a7fe890fbe5945c0004aeec1044ac764430f1d464326e5fa2710",
"check_name": "Render",
"message": "Render path contains parameter value",
"file": "app/views/account/entries/edit.html.erb",
"line": 2,
"link": "https://brakemanscanner.org/docs/warning_types/dynamic_render_path/",
"code": "render(action => permitted_entryable_partial_path(Current.family.accounts.find(params[:account_id]).entries.find(params[:id]), \"edit\"), { :entry => Current.family.accounts.find(params[:account_id]).entries.find(params[:id]) })",
"render_path": [
{
"type": "controller",
"class": "Account::EntriesController",
"method": "edit",
"line": 29,
"file": "app/controllers/account/entries_controller.rb",
"rendered": {
"name": "account/entries/edit",
"file": "app/views/account/entries/edit.html.erb"
}
}
],
"location": {
"type": "template",
"template": "account/entries/edit"
},
"user_input": "params[:id]",
"confidence": "Weak",
"cwe_id": [
22
],
"note": ""
}
],
"updated": "2024-06-30 12:52:10 -0400",
"updated": "2024-08-09 10:16:00 -0400",
"brakeman_version": "6.1.2"
}

View file

@ -2,92 +2,12 @@
en:
account:
entries:
create:
success: "%{name} created"
destroy:
success: Entry deleted
empty:
description: Try adding an entry, editing filters or refining your search
title: No entries found
entryables:
trade:
show:
overview: Overview
trade:
buy: Buy
sell: Sell
transaction:
selection_bar:
mark_transfers: Mark as transfers?
mark_transfers_confirm: Mark as transfers
mark_transfers_message: By marking transactions as transfers, they will
no longer be included in income or spending calculations.
show:
account_label: Account
account_placeholder: Select an account
additional: Additional
amount: Amount
category_label: Category
category_placeholder: Select a category
date_label: Date
delete: Delete
delete_subtitle: This permanently deletes the transaction, affects your
historical balances, and cannot be undone.
delete_title: Delete transaction
exclude_subtitle: This excludes the transaction from any in-app features
or analytics.
exclude_title: Exclude transaction
merchant_label: Merchant
merchant_placeholder: Select a merchant
name_label: Name
nature: Transaction type
note_label: Notes
note_placeholder: Enter a note
overview: Overview
settings: Settings
tags_label: Select one or more tags
transaction:
deposit: Deposit
remove_transfer: Remove transfer
remove_transfer_body: This will remove the transfer from this transaction
remove_transfer_confirm: Confirm
withdrawal: Withdrawal
valuation:
form:
cancel: Cancel
valuation:
confirm_accept: Delete entry
confirm_body_html: "<p>Deleting this entry will remove it from the accounts
history which will impact different parts of your account. This includes
the net worth and account graphs.</p></br><p>The only way youll be
able to add this entry back is by re-entering it manually via a new
entry</p>"
confirm_title: Delete Entry?
delete_entry: Delete entry
edit_entry: Edit entry
no_change: No change
start_balance: Starting balance
value_update: Value update
loading:
loading: Loading entries...
trades:
amount: Amount
new: New transaction
no_trades: No transactions for this account yet.
trade: transaction
trades: Transactions
type: Type
transactions:
new: New transaction
no_transactions: No transactions for this account yet.
transaction: transaction
transactions: Transactions
update:
success: Entry updated
valuations:
change: change
date: date
new_entry: New entry
no_valuations: No valuations for this account yet
valuations: Value history
value: value

View file

@ -11,7 +11,7 @@ en:
name: name
needs_sync: Your account needs to sync the latest prices to calculate this
portfolio
new_holding: New holding
new_holding: New transaction
no_holdings: No holdings to show.
return: total return
weight: weight

View file

@ -0,0 +1,31 @@
---
en:
account:
trades:
create:
success: Transaction created successfully.
form:
holding: Ticker symbol
price: Price per share
qty: Quantity
submit: Add transaction
ticker_placeholder: AAPL
type: Type
index:
amount: Amount
new: New transaction
no_trades: No transactions for this account yet.
trade: transaction
trades: Transactions
type: Type
new:
title: New transaction
show:
overview: Overview
trade:
buy: Buy
deposit: Deposit
inflow: Inflow
outflow: Outflow
sell: Sell
withdrawal: Withdrawal

View file

@ -0,0 +1,44 @@
---
en:
account:
transactions:
index:
new: New transaction
no_transactions: No transactions for this account yet.
transaction: transaction
transactions: Transactions
selection_bar:
mark_transfers: Mark as transfers?
mark_transfers_confirm: Mark as transfers
mark_transfers_message: By marking transactions as transfers, they will no
longer be included in income or spending calculations.
show:
account_label: Account
account_placeholder: Select an account
additional: Additional
amount: Amount
category_label: Category
category_placeholder: Select a category
date_label: Date
delete: Delete
delete_subtitle: This permanently deletes the transaction, affects your historical
balances, and cannot be undone.
delete_title: Delete transaction
exclude_subtitle: This excludes the transaction from any in-app features or
analytics.
exclude_title: Exclude transaction
merchant_label: Merchant
merchant_placeholder: Select a merchant
name_label: Name
nature: Transaction type
note_label: Notes
note_placeholder: Enter a note
overview: Overview
settings: Settings
tags_label: Select one or more tags
transaction:
remove_transfer: Remove transfer
remove_transfer_body: This will remove the transfer from this transaction
remove_transfer_confirm: Confirm
update:
success: Transaction updated successfully.

View file

@ -0,0 +1,27 @@
---
en:
account:
valuations:
create:
success: Valuation created successfully.
form:
cancel: Cancel
index:
change: change
date: date
new_entry: New entry
no_valuations: No valuations for this account yet
valuations: Value history
value: value
valuation:
confirm_accept: Delete entry
confirm_body_html: "<p>Deleting this entry will remove it from the accounts
history which will impact different parts of your account. This includes
the net worth and account graphs.</p></br><p>The only way youll be able
to add this entry back is by re-entering it manually via a new entry</p>"
confirm_title: Delete Entry?
delete_entry: Delete entry
edit_entry: Edit entry
no_change: No change
start_balance: Starting balance
value_update: Value update

View file

@ -81,13 +81,11 @@ Rails.application.routes.draw do
resources :holdings, only: %i[ index new show ]
resources :cashes, only: :index
resources :entries, except: :index do
collection do
get "transactions", as: :transaction
get "valuations", as: :valuation
get "trades", as: :trade
end
end
resources :transactions, only: %i[ index update ]
resources :valuations, only: %i[ index new create ]
resources :trades, only: %i[ index new create ]
resources :entries, only: %i[ edit update show destroy ]
end
end