Bug 39369 - Button "generate discharge" should not validate again a validated discharge
Summary: Button "generate discharge" should not validate again a validated discharge
Status: BLOCKED
Alias: None
Product: Koha
Classification: Unclassified
Component: Patrons (show other bugs)
Version: unspecified
Hardware: All All
: P5 - low minor
Assignee: Baptiste Wojtkowski (bwoj)
QA Contact: Testopia
URL:
Keywords:
Depends on: 37344
Blocks:
  Show dependency treegraph
 
Reported: 2025-03-18 16:05 UTC by Baptiste Wojtkowski (bwoj)
Modified: 2025-04-03 14:06 UTC (History)
5 users (show)

See Also:
GIT URL:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments
Bug 39369: Generating a discharge should not validate again a generated discharge (1.62 KB, patch)
2025-03-18 16:16 UTC, Baptiste Wojtkowski (bwoj)
Details | Diff | Splinter Review
Bug 39369: Generating a discharge should not validate again a generated discharge (1.62 KB, patch)
2025-03-18 16:18 UTC, Baptiste Wojtkowski (bwoj)
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Baptiste Wojtkowski (bwoj) 2025-03-18 16:05:26 UTC
The button generate discharge fetches all the discharges and puts a validation date to the most recent, regardless its state.
This makes no sense in particular if there are more than one discharges.
Comment 1 Baptiste Wojtkowski (bwoj) 2025-03-18 16:16:06 UTC
Created attachment 179462 [details] [review]
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
    5 - Notice you create a new discharge
    3 - If your tolerance to caffein is low, drink something else than
      coffee
Comment 2 Baptiste Wojtkowski (bwoj) 2025-03-18 16:18:49 UTC
Created attachment 179463 [details] [review]
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
Comment 3 Emmanuel Bétemps 2025-03-31 13:45:31 UTC
Hi,

7th step did'nt go well


Using index info to reconstruct a base tree...
M	Koha/Patron/Discharge.pm
M	installer/data/mysql/kohastructure.sql
M	koha-tmpl/intranet-tmpl/prog/en/modules/admin/authorised_values.tt
M	koha-tmpl/intranet-tmpl/prog/en/modules/members/discharge.tt
M	members/discharge.pl
M	opac/opac-reserve.pl
Falling back to patching base and 3-way merge...
Auto-merging koha-tmpl/intranet-tmpl/prog/en/modules/members/discharge.tt
CONFLICT (content): Merge conflict in koha-tmpl/intranet-tmpl/prog/en/modules/members/discharge.tt
Auto-merging installer/data/mysql/kohastructure.sql
CONFLICT (content): Merge conflict in installer/data/mysql/kohastructure.sql
CONFLICT (add/add): Merge conflict in installer/data/mysql/atomicupdate/bug_37344.pl
Auto-merging installer/data/mysql/atomicupdate/bug_37344.pl
error: Failed to merge in the changes.
Patch failed at 0001 Bug 37344: Add a real solution for discharge cancellation
[33mhint: Use 'git am --show-current-patch=diff' to see the failed patch[m
When you have resolved this problem run "git bz apply --continue".
If you would prefer to skip this patch, instead run "git bz apply --skip".
To restore the original branch and stop patching run "git bz apply --abort".
Patch left in /tmp/Bug-37344-Add-a-real-solution-for-discharge-cancel-i1tqnky4.patch

Cannot apply cleanly patches from bug 37344. Everything will be left dirty.
git bz apply --continue will not continue the process if patches from other bug reports need to be applied.

DEV atomic update /kohadevbox/koha/installer/data/mysql/atomicupdate/bug_37344.pl  [13:43:43]
	[31mERROR: {UNKNOWN}: Can't use an undefined value as a subroutine reference at /kohadevbox/koha/C4/Installer.pm line 769. at /kohadevbox/koha/C4/Installer.pm line 771
	[0m
Comment 4 Magnus Enger 2025-04-03 13:22:06 UTC
I can apply the patches fine, on top of 37344. But after applying the patch, when I try to do a discharge, I get a 500 error, and I see this in the logs:

==> /var/log/koha/kohadev/plack-error.log <==
DBIx::Class::Storage::DBI::_dbh_execute(): DBI Exception: DBD::mysql::st execute failed: Unknown column 'cancelled' in 'where clause' at /kohadevbox/koha/Koha/Patron/Discharge.pm line 73

The error does not happen without the patch.
Comment 5 Magnus Enger 2025-04-03 14:06:54 UTC
Looks like I didn't run the database update, sorry for that! But it also looks like bug 37344 should be signed off before proceeding with this one.