mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-21 14:19:39 +02:00
Change default valuation currency to that of the related account, not family (#728)
This commit is contained in:
parent
9ede14d23b
commit
1108e45596
2 changed files with 7 additions and 1 deletions
|
@ -4,7 +4,7 @@ class ValuationsController < ApplicationController
|
||||||
@account = Current.family.accounts.find(params[:account_id])
|
@account = Current.family.accounts.find(params[:account_id])
|
||||||
|
|
||||||
# TODO: placeholder logic until we have a better abstraction for trends
|
# TODO: placeholder logic until we have a better abstraction for trends
|
||||||
@valuation = @account.valuations.new(valuation_params.merge(currency: Current.family.currency))
|
@valuation = @account.valuations.new(valuation_params.merge(currency: @account.currency))
|
||||||
if @valuation.save
|
if @valuation.save
|
||||||
@valuation.account.sync_later(@valuation.date)
|
@valuation.account.sync_later(@valuation.date)
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,12 @@ class ValuationsControllerTest < ActionDispatch::IntegrationTest
|
||||||
assert_redirected_to account_path(@valuation.account)
|
assert_redirected_to account_path(@valuation.account)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "should create valuation with account's currency" do
|
||||||
|
foreign_account = accounts(:eur_checking)
|
||||||
|
post account_valuations_url(foreign_account), params: { valuation: { value: 1, date: Date.current, type: "Appraisal" } }
|
||||||
|
assert_equal foreign_account.currency, Valuation.order(created_at: :desc).first.currency
|
||||||
|
end
|
||||||
|
|
||||||
test "create should sync account with correct start date" do
|
test "create should sync account with correct start date" do
|
||||||
date = Date.current - 1.day
|
date = Date.current - 1.day
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue