Auto-categorize investment contributions across all transfer paths (#924)

* Ensure investment contributions are auto-categorized with proper kind and category creation.

* Retrigger CI
This commit is contained in:
LPW
2026-02-07 10:41:31 -05:00
committed by GitHub
parent fc3504abe0
commit 36661bdc9b
10 changed files with 193 additions and 5 deletions

View File

@@ -165,6 +165,30 @@ class Rule::ActionTest < ActiveSupport::TestCase
end
end
test "set_as_transfer_or_payment assigns investment_contribution kind and category for investment destination" do
investment = accounts(:investment)
action = Rule::Action.new(
rule: @transaction_rule,
action_type: "set_as_transfer_or_payment",
value: investment.id
)
# Only apply to txn1 (positive amount = outflow)
action.apply(Transaction.where(id: @txn1.id))
@txn1.reload
transfer = Transfer.find_by(outflow_transaction_id: @txn1.id) || Transfer.find_by(inflow_transaction_id: @txn1.id)
assert transfer.present?, "Transfer should be created"
assert_equal "investment_contribution", transfer.outflow_transaction.kind
assert_equal "funds_movement", transfer.inflow_transaction.kind
category = @family.investment_contributions_category
assert_equal category, transfer.outflow_transaction.category
end
test "set_investment_activity_label ignores invalid values" do
action = Rule::Action.new(
rule: @transaction_rule,