diff --git a/app/models/account.rb b/app/models/account.rb index 400e8beaa73..19d883ca094 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -151,6 +151,7 @@ def update_balance!(balance) else entries.create! \ date: Date.current, + name: "Balance update", amount: balance, currency: currency, entryable: Account::Valuation.new diff --git a/app/views/account/valuations/_form.html.erb b/app/views/account/valuations/_form.html.erb index b56e847bbbb..f3f0aa5fac1 100644 --- a/app/views/account/valuations/_form.html.erb +++ b/app/views/account/valuations/_form.html.erb @@ -8,6 +8,7 @@ <% end %>
+ <%= form.hidden_field :name, value: "Balance update" %> <%= form.date_field :date, label: true, required: true, value: Date.current, min: Account::Entry.min_supported_date, max: Date.current %> <%= form.money_field :amount, label: t(".amount"), required: true %>
diff --git a/config/brakeman.ignore b/config/brakeman.ignore index 6ebccac2e9b..ce280c4d1ce 100644 --- a/config/brakeman.ignore +++ b/config/brakeman.ignore @@ -23,6 +23,29 @@ ], "note": "" }, + { + "warning_type": "Mass Assignment", + "warning_code": 105, + "fingerprint": "5bfdb129316655dc4e02f3a599156660414a6562212a5f61057d376f6888f078", + "check_name": "PermitAttributes", + "message": "Potentially dangerous key allowed for mass assignment", + "file": "app/controllers/concerns/entryable_resource.rb", + "line": 122, + "link": "https://brakemanscanner.org/docs/warning_types/mass_assignment/", + "code": "params.require(:account_entry).permit(:account_id, :name, :enriched_name, :date, :amount, :currency, :excluded, :notes, :nature, :entryable_attributes => self.class.permitted_entryable_attributes)", + "render_path": null, + "location": { + "type": "method", + "class": "EntryableResource", + "method": "entry_params" + }, + "user_input": ":account_id", + "confidence": "High", + "cwe_id": [ + 915 + ], + "note": "" + }, { "warning_type": "Mass Assignment", "warning_code": 105, @@ -80,29 +103,6 @@ ], "note": "" }, - { - "warning_type": "Mass Assignment", - "warning_code": 105, - "fingerprint": "f158202dcc66f2273ddea5e5296bad7146a50ca6667f49c77372b5b234542334", - "check_name": "PermitAttributes", - "message": "Potentially dangerous key allowed for mass assignment", - "file": "app/controllers/concerns/entryable_resource.rb", - "line": 122, - "link": "https://brakemanscanner.org/docs/warning_types/mass_assignment/", - "code": "params.require(:account_entry).permit(:account_id, :name, :date, :amount, :currency, :excluded, :notes, :nature, :entryable_attributes => self.class.permitted_entryable_attributes)", - "render_path": null, - "location": { - "type": "method", - "class": "EntryableResource", - "method": "entry_params" - }, - "user_input": ":account_id", - "confidence": "High", - "cwe_id": [ - 915 - ], - "note": "" - }, { "warning_type": "Dynamic Render Path", "warning_code": 15, @@ -138,6 +138,6 @@ "note": "" } ], - "updated": "2024-11-27 15:33:53 -0500", + "updated": "2024-12-18 17:46:13 -0500", "brakeman_version": "6.2.2" } diff --git a/test/interfaces/accountable_resource_interface_test.rb b/test/interfaces/accountable_resource_interface_test.rb index c1fe92089b5..d44baf7e581 100644 --- a/test/interfaces/accountable_resource_interface_test.rb +++ b/test/interfaces/accountable_resource_interface_test.rb @@ -76,7 +76,7 @@ module AccountableResourceInterfaceTest end test "updates account balance by editing existing valuation for today" do - @account.entries.create! date: Date.current, amount: 6000, currency: "USD", entryable: Account::Valuation.new + @account.entries.create! date: Date.current, amount: 6000, currency: "USD", name: "Balance update", entryable: Account::Valuation.new assert_no_difference [ "Account::Entry.count", "Account::Valuation.count" ] do patch account_url(@account), params: { diff --git a/test/system/trades_test.rb b/test/system/trades_test.rb index 9e26b7083a4..9ca85c08875 100644 --- a/test/system/trades_test.rb +++ b/test/system/trades_test.rb @@ -23,7 +23,7 @@ class TradesTest < ApplicationSystemTestCase end test "can create buy transaction" do - shares_qty = 25.0 + shares_qty = 25 open_new_trade_modal @@ -38,7 +38,7 @@ class TradesTest < ApplicationSystemTestCase visit_account_trades within_trades do - assert_text "Buy 10.0 shares of AAPL" + assert_text "Purchase 10 shares of AAPL" assert_text "Buy #{shares_qty} shares of AAPL" end end @@ -60,7 +60,7 @@ class TradesTest < ApplicationSystemTestCase visit_account_trades within_trades do - assert_text "Sell #{aapl.qty} shares of AAPL" + assert_text "Sell #{aapl.qty.round} shares of AAPL" end end