From 94710144cd4c6d83c0948faa2850019aaaa346ec Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Fri, 13 Feb 2026 17:14:17 +0000 Subject: [PATCH] Bug 40445: (follow-up) Set amountoutstanding for CASHUP_SURPLUS and CASHUP_DEFICIT accountlines CASHUP_SURPLUS and CASHUP_DEFICIT accountlines represent immediate reconciliation adjustments that should be considered settled at the time of creation. These records should have amountoutstanding set to 0 to indicate they are fully reconciled. This patch adds amountoutstanding => 0 when creating both types of reconciliation accountlines and updates the tests to verify this behavior. Test plan: 1. prove t/db_dependent/Koha/Cash/Register.t 2. Verify all tests pass, specifically the new tests for amountoutstanding Signed-off-by: Jackie Usher --- Koha/Cash/Register.pm | 38 +++++++++++++++-------------- t/db_dependent/Koha/Cash/Register.t | 14 ++++++----- 2 files changed, 28 insertions(+), 24 deletions(-) diff --git a/Koha/Cash/Register.pm b/Koha/Cash/Register.pm index db37537196a..611347e8568 100644 --- a/Koha/Cash/Register.pm +++ b/Koha/Cash/Register.pm @@ -448,15 +448,16 @@ sub add_cashup { # Surplus: more cash found than expected (credits are negative amounts) my $surplus = Koha::Account::Line->new( { - date => $reconciliation_date, - amount => -abs($difference), # Credits are negative - credit_type_code => 'CASHUP_SURPLUS', - manager_id => $manager_id, - interface => 'intranet', - branchcode => $self->branch, - register_id => $self->id, - payment_type => 'CASH', - note => $reconciliation_note + date => $reconciliation_date, + amount => -abs($difference), # Credits are negative + amountoutstanding => 0, + credit_type_code => 'CASHUP_SURPLUS', + manager_id => $manager_id, + interface => 'intranet', + branchcode => $self->branch, + register_id => $self->id, + payment_type => 'CASH', + note => $reconciliation_note } )->store(); @@ -474,15 +475,16 @@ sub add_cashup { # Deficit: less cash found than expected my $deficit = Koha::Account::Line->new( { - date => $reconciliation_date, - amount => abs($difference), - debit_type_code => 'CASHUP_DEFICIT', - manager_id => $manager_id, - interface => 'intranet', - branchcode => $self->branch, - register_id => $self->id, - payment_type => 'CASH', - note => $reconciliation_note + date => $reconciliation_date, + amount => abs($difference), + amountoutstanding => 0, + debit_type_code => 'CASHUP_DEFICIT', + manager_id => $manager_id, + interface => 'intranet', + branchcode => $self->branch, + register_id => $self->id, + payment_type => 'CASH', + note => $reconciliation_note } )->store(); my $account_offset = Koha::Account::Offset->new( diff --git a/t/db_dependent/Koha/Cash/Register.t b/t/db_dependent/Koha/Cash/Register.t index 43c23a682a2..6157b1791f5 100755 --- a/t/db_dependent/Koha/Cash/Register.t +++ b/t/db_dependent/Koha/Cash/Register.t @@ -423,7 +423,7 @@ subtest 'cashup_reconciliation' => sub { }; subtest 'surplus_cashup' => sub { - plan tests => 9; + plan tests => 10; $schema->storage->txn_begin; @@ -472,8 +472,9 @@ subtest 'cashup_reconciliation' => sub { sprintf( '%.0f', $surplus_line->amount ), sprintf( '%.0f', -$surplus ), 'Surplus amount is correct (negative for credit)' ); - is( $surplus_line->branchcode, $register2->branch, 'Surplus branchcode matches register branch' ); - is( $surplus_line->payment_type, 'CASH', 'Surplus payment_type is set to CASH' ); + is( $surplus_line->branchcode, $register2->branch, 'Surplus branchcode matches register branch' ); + is( $surplus_line->payment_type, 'CASH', 'Surplus payment_type is set to CASH' ); + is( sprintf( '%.0f', $surplus_line->amountoutstanding ), '0', 'Surplus amountoutstanding is set to 0' ); # Note should be undef for surplus without user note is( $surplus_line->note, undef, 'No note for surplus without user reconciliation note' ); @@ -522,7 +523,7 @@ subtest 'cashup_reconciliation' => sub { }; subtest 'deficit_cashup' => sub { - plan tests => 9; + plan tests => 10; $schema->storage->txn_begin; @@ -571,8 +572,9 @@ subtest 'cashup_reconciliation' => sub { sprintf( '%.0f', $deficit_line->amount ), sprintf( '%.0f', $deficit ), 'Deficit amount is correct (positive for debit)' ); - is( $deficit_line->branchcode, $register3->branch, 'Deficit branchcode matches register branch' ); - is( $deficit_line->payment_type, 'CASH', 'Deficit payment_type is set to CASH' ); + is( $deficit_line->branchcode, $register3->branch, 'Deficit branchcode matches register branch' ); + is( $deficit_line->payment_type, 'CASH', 'Deficit payment_type is set to CASH' ); + is( sprintf( '%.0f', $deficit_line->amountoutstanding ), '0', 'Deficit amountoutstanding is set to 0' ); # Note should be undef for deficit without user note is( $deficit_line->note, undef, 'No note for deficit without user reconciliation note' ); -- 2.53.0