From 11f99549fddb8687374da35ad497ccd1cc7bf1a9 Mon Sep 17 00:00:00 2001 From: Baptiste Wojtkowski Date: Tue, 18 Mar 2025 16:50:16 +0100 Subject: [PATCH] Bug 39369: Generating a discharge should not validate again a generated discharge Test plan: 1 - Apply Bug 37344 2 - Go on discharge.pl, click on "generate discharge" 3 - Drink a coffee (or do something during 1 min) 4 - Click again on the button - notice the date has changed 5 - Cancel the discharge 6 - Click again on the button - notice the cancelled discharge has been updated 7 - Apply patch 8 - Repeat 2 to 6 with following changes: 4 - Notice you simply print again the discharge 6 - Notice you create a new discharge 3 - If your tolerance to caffein is low, drink something else than coffee --- Koha/Patron/Discharge.pm | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Koha/Patron/Discharge.pm b/Koha/Patron/Discharge.pm index d1a256e3..2ab6cce8 100644 --- a/Koha/Patron/Discharge.pm +++ b/Koha/Patron/Discharge.pm @@ -142,7 +142,16 @@ sub discharge { # Generate the discharge my $rs = Koha::Database->new->schema->resultset('Discharge'); - my $discharge = $rs->search( { borrower => $borrowernumber }, { order_by => { -desc => 'needed' }, rows => 1 } ); + my $discharge = $rs->search( + { + borrower => $borrowernumber, + validated => undef, + }, + { + order_by => { -desc => 'needed' }, + rows => 1 + } + ); if ( $discharge->count > 0 ) { $discharge->update( { -- 2.30.2