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

First sketch of budgeting module

This commit is contained in:
Zach Gollwitzer 2024-12-30 17:29:59 -05:00
parent 5d1a2937bb
commit 9a2a7b31d4
45 changed files with 342 additions and 84 deletions

View file

@ -28,28 +28,31 @@ class Account::TransferTest < ActiveSupport::TestCase
name: "Inflow",
amount: -100,
currency: "USD",
marked_as_transfer: true,
entryable: Account::Transaction.new
entryable: Account::Transaction.new(
category: account.family.default_transfer_category
)
outflow = account.entries.create! \
date: Date.current,
name: "Outflow",
amount: 100,
currency: "USD",
marked_as_transfer: true,
entryable: Account::Transaction.new
entryable: Account::Transaction.new(
category: account.family.default_transfer_category
)
assert_raise ActiveRecord::RecordInvalid do
Account::Transfer.create! entries: [ inflow, outflow ]
end
end
test "all transfer transactions must be marked as transfers" do
@inflow.update! marked_as_transfer: false
test "all transfer transactions must have transfer category" do
@inflow.entryable.update! category: nil
assert_raise ActiveRecord::RecordInvalid do
Account::Transfer.create! entries: [ @inflow, @outflow ]
end
transfer = Account::Transfer.new entries: [ @inflow, @outflow ]
assert_not transfer.valid?
assert_equal "Entries must have transfer category", transfer.errors.full_messages.first
end
test "single-currency transfer transactions must net to zero" do