From 2e89fba61df29de1c4b44e0390028d93b0971edd 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 linked to a new record/order. 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 +++ .../en/modules/acqui/newordersubscription.tt | 2 +- .../prog/en/modules/acqui/newordersuggestion.tt | 4 ++-- .../prog/en/modules/acqui/z3950_search.tt | 2 +- .../modules/admin/preferences/acquisitions.pref | 7 +++++++ .../prog/en/modules/catalogue/results.tt | 2 +- 9 files changed, 33 insertions(+), 5 deletions(-) create mode 100755 installer/data/mysql/atomicupdate/bug_27063_-_KeepInvoiceOnOrderRelink_syspref.pl diff --git a/acqui/neworderempty.pl b/acqui/neworderempty.pl index 9c93addacca..221cc0d0b11 100755 --- a/acqui/neworderempty.pl +++ b/acqui/neworderempty.pl @@ -539,6 +539,7 @@ $template->param( users => \@order_users, ( uc( C4::Context->preference("marcflavour") ) ) => 1, estimated_delivery_date => $data->{estimated_delivery_date}, + relink_invoiceid => ( C4::Context->preference('KeepInvoiceOnOrderRelink') and $input->param("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 f49557be9c7..a5542b0e8d9 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -363,6 +363,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('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'), ('JobsNotificationMethod','STOMP','polling|STOMP','Define the preferred job worker notification method','Choice'), +('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 72433c41ef6..8fe52acf47d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt @@ -357,6 +357,9 @@ + [% IF relink_invoiceid %] + + [% END %] [% FOREACH c IN currencies %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/newordersubscription.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/newordersubscription.tt index e367c99492f..f21b6d60bce 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/newordersubscription.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/newordersubscription.tt @@ -92,7 +92,7 @@ [% END %] [% IF not sub.aqbooksellerid || booksellerid == sub.aqbooksellerid %] [% IF ordernumber %] - + [% ELSE %] [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/newordersuggestion.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/newordersuggestion.tt index 5e05be5a2bf..dad39b69a6c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/newordersuggestion.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/newordersuggestion.tt @@ -102,13 +102,13 @@ [% IF ( suggestion.biblionumber ) %] [% IF ordernumber %] - [% tp('verb', 'Order') | html %] + [% tp('verb', 'Order') | html %] [% ELSE %] [% tp('verb', 'Order') | html %] [% END %] [% ELSE %] [% IF ordernumber %] - [% tp('verb', 'Order') | html %] + [% tp('verb', 'Order') | html %] [% ELSE %] [% tp('verb', 'Order') | html %] [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/z3950_search.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/z3950_search.tt index cc8d996fc43..a6f95c0bc48 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/z3950_search.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/z3950_search.tt @@ -225,7 +225,7 @@ tr.selected td {
  • MARC
  • Card
  • [% IF ordernumber %] -
  • [% tp('verb', 'Order') | html %]
  • +
  • [% tp('verb', 'Order') | html %]
  • [% ELSE %]
  • [% tp('verb', 'Order') | html %]
  • [% END %] 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 b172a03da9b..f69df436f0e 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 @@ -145,6 +145,13 @@ Acquisitions: 1: Enable 0: Disable - automatic order line creation from MARC records. + - + - pref: KeepInvoiceOnOrderRelink + default: no + choices: + 1: "Keep" + 0: "Do not keep" + - " a link to the invoice when an order is relinked." Printing: - - Use the diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt index 299fb6c178b..86d1d3fa012 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt @@ -594,7 +594,7 @@ [% IF ( CAN_user_acquisition_order_manage ) %] [% IF ( searchtoorder_basketno && searchtoorder_vendorid ) %] [% IF searchtoorder_ordernumber %] - | Relink to order + | Relink to order [% ELSE %] | Add order [% END %] -- 2.39.5