1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-08-02 20:15:22 +02:00

Account namespace updates: part 6 (transactions) (#904)

* Move Transaction to Account namespace

* Fix improper routes, improve separation of concerns

* Replace account transactions list partial with view

* Remove logs

* Consolidate transaction views

* Remove unused code

* Transfer style tweaks

* Remove more unused code

* Add back totals by currency helper
This commit is contained in:
Zach Gollwitzer 2024-06-24 11:58:39 -04:00 committed by GitHub
parent cb3fd34f90
commit da18c3d850
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
72 changed files with 575 additions and 522 deletions

View file

View file

@ -1,15 +1,15 @@
require "test_helper"
class TransactionTest < ActiveSupport::TestCase
class Account::TransactionTest < ActiveSupport::TestCase
setup do
@transaction = transactions(:checking_one)
@transaction = account_transactions(:checking_one)
@family = families(:dylan_family)
end
# See: https://github.com/maybe-finance/maybe/wiki/vision#signage-of-money
test "negative amounts are inflows, positive amounts are outflows to an account" do
inflow_transaction = transactions(:checking_four)
outflow_transaction = transactions(:checking_five)
inflow_transaction = account_transactions(:checking_four)
outflow_transaction = account_transactions(:checking_five)
assert inflow_transaction.amount < 0
assert inflow_transaction.inflow?
@ -35,8 +35,8 @@ class TransactionTest < ActiveSupport::TestCase
end
test "triggers sync with correct start date when transaction deleted" do
prior_transaction = transactions(:checking_two) # 12 days ago
current_transaction = transactions(:checking_one) # 5 days ago
prior_transaction = account_transactions(:checking_two) # 12 days ago
current_transaction = account_transactions(:checking_one) # 5 days ago
current_transaction.destroy!
current_transaction.account.expects(:sync_later).with(prior_transaction.date)

View file

@ -15,7 +15,7 @@ class Account::TransferTest < ActiveSupport::TestCase
test "transfer must have 2 transactions" do
invalid_transfer_1 = Account::Transfer.new transactions: [ @outflow ]
invalid_transfer_2 = Account::Transfer.new transactions: [ @inflow, @outflow, transactions(:savings_four) ]
invalid_transfer_2 = Account::Transfer.new transactions: [ @inflow, @outflow, account_transactions(:savings_four) ]
assert invalid_transfer_1.invalid?
assert invalid_transfer_2.invalid?

View file

@ -99,7 +99,7 @@ class AccountTest < ActiveSupport::TestCase
end
test "should destroy dependent transactions" do
assert_difference("Transaction.count", -@account.transactions.count) do
assert_difference("Account::Transaction.count", -@account.transactions.count) do
@account.destroy
end
end

View file

@ -34,7 +34,7 @@ class CategoryTest < ActiveSupport::TestCase
end
test "replacing and destroying" do
transctions = categories(:food_and_drink).transactions.to_a
transactions = categories(:food_and_drink).transactions.to_a
categories(:food_and_drink).replace_and_destroy!(categories(:income))

View file

@ -45,7 +45,7 @@ class ImportTest < ActiveSupport::TestCase
# Fixtures already define "Food & Drink" and "Income", so these should not be created
# "Shopping" is a new category, but should only be created 1x during import
assert_difference \
-> { Transaction.count } => 4,
-> { Account::Transaction.count } => 4,
-> { Category.count } => 1,
-> { Tagging.count } => 4,
-> { Tag.count } => 2 do
@ -59,11 +59,11 @@ class ImportTest < ActiveSupport::TestCase
test "publishes a valid import with missing data" do
@empty_import.update! raw_csv_str: valid_csv_with_missing_data
assert_difference -> { Category.count } => 1, -> { Transaction.count } => 2 do
assert_difference -> { Category.count } => 1, -> { Account::Transaction.count } => 2 do
@empty_import.publish
end
assert_not_nil Transaction.find_sole_by(name: Import::FALLBACK_TRANSACTION_NAME)
assert_not_nil Account::Transaction.find_sole_by(name: Import::FALLBACK_TRANSACTION_NAME)
@empty_import.reload
@ -73,7 +73,7 @@ class ImportTest < ActiveSupport::TestCase
test "failed publish results in error status" do
@empty_import.update! raw_csv_str: valid_csv_with_invalid_values
assert_difference "Transaction.count", 0 do
assert_difference "Account::Transaction.count", 0 do
@empty_import.publish
end