mirror of
https://github.com/we-promise/sure.git
synced 2026-04-19 03:54:08 +00:00
fix: Transfers should always total to zero (#1859)
This commit is contained in:
@@ -196,10 +196,22 @@ class TransactionsTest < ApplicationSystemTestCase
|
||||
end
|
||||
end
|
||||
|
||||
test "transfers should always sum to zero" do
|
||||
asset_account = accounts(:other_asset)
|
||||
investment_account = accounts(:investment)
|
||||
outflow_entry = create_transaction("outflow", Date.current, 500, account: asset_account)
|
||||
inflow_entry = create_transaction("inflow", 1.day.ago.to_date, -500, account: investment_account)
|
||||
asset_account.auto_match_transfers!
|
||||
visit transactions_url
|
||||
within "#entry-group-" + Date.current.to_s + "-totals" do
|
||||
assert_text "-$100.00" # transaction eleven from setup
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def create_transaction(name, date, amount, category: nil, merchant: nil, tags: [])
|
||||
account = accounts(:depository)
|
||||
def create_transaction(name, date, amount, category: nil, merchant: nil, tags: [], account: nil)
|
||||
account ||= accounts(:depository)
|
||||
|
||||
account.entries.create! \
|
||||
name: name,
|
||||
|
||||
Reference in New Issue
Block a user