From f686ab1593b4241cb7c673ededbbfc6e7fe0c89e Mon Sep 17 00:00:00 2001 From: Aleisha Amohia Date: Wed, 7 Aug 2024 03:25:55 +0000 Subject: [PATCH] Bug 27063: Syspref KeepInvoiceOnOrderRelink and implement This follow-up patch adds a new system preference KeepInvoiceOnOrderRelink. When enabled, relinking a received order will keep the invoice ID of the original order. This is useful for standing orders where the record has been deleted and relinked. To test: 1. Enable the system preference KeepInvoiceOnOrderRelink 2. Add an order to a standing basket 3. Receive the order 4. Once received, go to the record and view the Acquisitions details tab. Notice the invoice is linked. 5. Go back to the basket 6. Relink the received order to a different record 7. Go to the record and view the Acquisitions details tab. Notice the invoice has been kept. 8. Repeat the test plan with the system preference KeepInvoiceOnOrderRelink disabled. Notice the invoice is nullified after the order is relinked. Sponsored-by: Auckland University of Technology --- acqui/neworderempty.pl | 1 + ...g_27063_-_KeepInvoiceOnOrderRelink_syspref.pl | 16 ++++++++++++++++ installer/data/mysql/mandatory/sysprefs.sql | 1 + .../prog/en/modules/acqui/neworderempty.tt | 3 +++ .../modules/admin/preferences/acquisitions.pref | 7 +++++++ 5 files changed, 28 insertions(+) create mode 100755 installer/data/mysql/atomicupdate/bug_27063_-_KeepInvoiceOnOrderRelink_syspref.pl diff --git a/acqui/neworderempty.pl b/acqui/neworderempty.pl index 29aa586a8bc..c03ea84b081 100755 --- a/acqui/neworderempty.pl +++ b/acqui/neworderempty.pl @@ -536,6 +536,7 @@ $template->param( users => \@order_users, ( uc( C4::Context->preference("marcflavour") ) ) => 1, estimated_delivery_date => $data->{estimated_delivery_date}, + invoiceid => ( C4::Context->preference('KeepInvoiceOnOrderRelink') and $relink ) ? $data->{invoiceid} : undef, ); output_html_with_http_headers $input, $cookie, $template->output; diff --git a/installer/data/mysql/atomicupdate/bug_27063_-_KeepInvoiceOnOrderRelink_syspref.pl b/installer/data/mysql/atomicupdate/bug_27063_-_KeepInvoiceOnOrderRelink_syspref.pl new file mode 100755 index 00000000000..0c8ee26ec83 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_27063_-_KeepInvoiceOnOrderRelink_syspref.pl @@ -0,0 +1,16 @@ +use Modern::Perl; + +return { + bug_number => "27063", + description => "Allow changing which record an order is linked to", + up => sub { + my ($args) = @_; + my ( $dbh, $out ) = @$args{qw(dbh out)}; + + $dbh->do( + q{ INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ('KeepInvoiceOnOrderRelink', '0', NULL, 'Keep or empty the invoice when an order is relinked in Acquisitions', 'YesNo') } + ); + + say $out "Added system preference 'KeepInvoiceOnOrderRelink'"; + }, +}; diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index 1a7cd033e90..c21d22819b6 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -358,6 +358,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('itemBarcodeInputFilter','','whitespace|T-prefix|cuecat|libsuite8|EAN13','If set, allows specification of a item barcode input filter','Choice'), ('itemcallnumber','',NULL,'The MARC field/subfield that is used to calculate the itemcallnumber (Dewey would be 082ab or 092ab; LOC would be 050ab or 090ab) could be 852hi from an item record','free'), ('ItemsDeniedRenewal','','','This syspref allows to define custom rules for denying renewal of specific items.','Textarea'), +('KeepInvoiceOnOrderRelink', '0', NULL, 'Keep or empty the invoice when an order is relinked in Acquisitions', 'YesNo') ('KohaAdminEmailAddress','root@localhost','','Define the email address where patron modification requests are sent','free'), ('KohaManualBaseURL','https://koha-community.org/manual/','','Where is the Koha manual/documentation located?','Free'), ('KohaManualLanguage','en','en|ar|cs|de|es|fr|it|pt_BR|tr|zh_TW','What is the language of the online manual you want to use?','Choice'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt index a8aa424cfe2..53b81fb9afa 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt @@ -356,6 +356,9 @@ + [% IF Koha.Preference('KeepInvoiceOnOrderRelink') %] + + [% END %] [% FOREACH c IN currencies %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/acquisitions.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/acquisitions.pref index 3584d9d59d5..29cfece8ada 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/acquisitions.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/acquisitions.pref @@ -138,6 +138,13 @@ Acquisitions: class: email - 'when sending acquisitions order and claim notices.' - '
If left empty, it will fall back to the first defined address in the following list: library reply-to, library email, ReplytoDefault, KohaAdminEmailAddress.' + - + - pref: KeepInvoiceOnOrderRelink + default: no + choices: + 1: "Keep" + 0: "Do not keep" + - " a link to the invoice when an order is relinked." Printing: - - Use the -- 2.39.2