From c8fc43ed2e4009df7291c598e96a40ab957e3b1b Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Fri, 27 Jul 2018 14:30:07 -0400 Subject: [PATCH] LP#978095 ACQ use last-canceled copy reason if best Only use an alternate keep-debits cancel reason if the currently canceled copy is not using a keep-debits reason. Also clarify in the docs that if another keep-debits reason is selected, it's essentially chosen at random, not necessarily the "last" copy. Signed-off-by: Bill Erickson Signed-off-by: Mike Rylander --- .../perlmods/lib/OpenILS/Application/Acq/Order.pm | 9 ++++----- ...ancel_lineitems_when_all_copies_are_canceled.adoc | 12 +++++++++++- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm index 7215e05f3b..42fbebb918 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm @@ -3272,16 +3272,15 @@ sub autocancel_lineitem { foreach my $lid ( @{ $all_lids } ) { if (! $lid->cancel_reason ) { $all_lids_are_canceled = 0; - } - if ($lid->cancel_reason) { - if ($U->is_true($lid->cancel_reason->keep_debits)) { + } elsif ( + !$U->is_true($candidate_cancel_reason->keep_debits) && + $U->is_true($lid->cancel_reason->keep_debits)) { $candidate_cancel_reason = $lid->cancel_reason; - } } } my $cancel_result; if ($all_lids_are_canceled) { - eval { $cancel_result = cancel_lineitem($mgr, $li_id, $candidate_cancel_reason); }; + $cancel_result = cancel_lineitem($mgr, $li_id, $candidate_cancel_reason); } return $cancel_result; } diff --git a/docs/RELEASE_NOTES_NEXT/Acquisitions/autocancel_lineitems_when_all_copies_are_canceled.adoc b/docs/RELEASE_NOTES_NEXT/Acquisitions/autocancel_lineitems_when_all_copies_are_canceled.adoc index e84e519cc0..806786716a 100644 --- a/docs/RELEASE_NOTES_NEXT/Acquisitions/autocancel_lineitems_when_all_copies_are_canceled.adoc +++ b/docs/RELEASE_NOTES_NEXT/Acquisitions/autocancel_lineitems_when_all_copies_are_canceled.adoc @@ -1,3 +1,13 @@ Auto-Cancel Lineitems When All Copies Are Canceled ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -When a copy (lineitem detail) is canceled through the Acquisitions interface, the parent lineitem is also canceled if all copies for that lineitem are also canceled. The cancel reason given will be taken from the last copy with a cancel reason where Keep Debits is true, or failing that, the cancel reason used for the copy just canceled. +When a copy (lineitem detail) is canceled through the Acquisitions interface, +the parent lineitem is also canceled if all copies for that lineitem are also +canceled. The cancel reason given will come from: + +1. The cancel reason for the just-canceled copy if it's a Keep Debits true + cancel reason. +2. The cancel reason from any other copy on the lineitem that has a Keep + Debits true cancel reason. +3. The cancel reason for the just-canceled copy if no copies have a Keep + Debits true cancel reason. + -- 2.43.2