From 5b59e22afc6de1d75382e3519299fdd009640d8d Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Fri, 8 Aug 2025 17:14:27 +0100 Subject: [PATCH] Bug 40445: (follow-up) Exclude reconciliation accountlines from outstanding_accountlines The outstanding_accountlines method should exclude CASHUP_SURPLUS and CASHUP_DEFICIT accountlines that are created during cashup reconciliation. These reconciliation entries represent discrepancies found during cashup and should not be counted as outstanding amounts for subsequent cashups. This prevents surplus/deficit accountlines from being included in the total when calculating expected amounts for future cashups. Test plan: 1. Perform a cashup with surplus or deficit 2. Verify that reconciliation accountlines are created 3. Check that subsequent calls to outstanding_accountlines() exclude these reconciliation entries 4. Run prove t/db_dependent/Koha/Cash/Register.t --- Koha/Cash/Register.pm | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Koha/Cash/Register.pm b/Koha/Cash/Register.pm index 0ca8f714ad0..b67d91ad6af 100644 --- a/Koha/Cash/Register.pm +++ b/Koha/Cash/Register.pm @@ -126,6 +126,22 @@ sub outstanding_accountlines { $since->count ? { 'date' => { '>' => $since->get_column('timestamp')->as_query } } : {}; + + # Exclude reconciliation accountlines from outstanding accountlines + $local_conditions->{'-and'} = [ + { + '-or' => [ + { 'credit_type_code' => { '!=' => 'CASHUP_SURPLUS' } }, + { 'credit_type_code' => undef } + ] + }, + { + '-or' => [ + { 'debit_type_code' => { '!=' => 'CASHUP_DEFICIT' } }, + { 'debit_type_code' => undef } + ] + } + ]; my $merged_conditions = $conditions ? { %{$conditions}, %{$local_conditions} } -- 2.50.1