mirror of
https://github.com/we-promise/sure.git
synced 2026-04-19 12:04:08 +00:00
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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user