From 4018ae38952fabc021d562f1a6baca3fb83ae752 Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Fri, 15 Apr 2022 10:01:00 +0200 Subject: [PATCH] Bug 30563: Add syspref to make the "cash register" field mandatory Test plan: 1. Apply patch and run updatedatabase 2. Enable 'UseCashRegisters' syspref and create at least one cash register for your library 3. Verify that you have several authorized values in the 'PAYMENT_TYPE' category. One of them should be 'CASH' 4. Go to a patron accounting tab, create a manual invoice and go to the payment form. Select payment type 'CASH' and verify that you cannot submit the form if no cash register is selected. Select another payment type and verify that you can submit the form even if no cash register is selected 5. Set syspref 'RequireCashRegister' to 'always require a cash register' 6. Repeat step 4 but this time you should not be able to submit the form if no cash register is selected, no matter which payment type is selected. --- .../add-syspref-RequireCashRegister.pl | 17 +++++++++++ installer/data/mysql/mandatory/sysprefs.sql | 1 + .../modules/admin/preferences/accounting.pref | 8 +++++ .../prog/en/modules/members/paycollect.tt | 29 +++++++++++++++---- 4 files changed, 50 insertions(+), 5 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/add-syspref-RequireCashRegister.pl diff --git a/installer/data/mysql/atomicupdate/add-syspref-RequireCashRegister.pl b/installer/data/mysql/atomicupdate/add-syspref-RequireCashRegister.pl new file mode 100644 index 0000000000..da878d4e82 --- /dev/null +++ b/installer/data/mysql/atomicupdate/add-syspref-RequireCashRegister.pl @@ -0,0 +1,17 @@ +use Modern::Perl; + +return { + bug_number => '30563', + description => 'Add system preference RequireCashRegister', + up => sub { + my ($args) = @_; + my ($dbh, $out) = @$args{qw(dbh out)}; + + $dbh->do(q{ + INSERT IGNORE INTO systempreferences (`variable`, `value`, `options`, `explanation`, `type`) + VALUES ('RequireCashRegister', '0', NULL, 'Require a cash register when collecting a payment', 'YesNo') + }); + + say $out 'System preference RequireCashRegister added'; + }, +}; diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index 34523550c0..03fcbaba10 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -567,6 +567,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('RentalsInNoissuesCharge','1',NULL,'Rental charges block checkouts (added to noissuescharge).','YesNo'), ('ReplyToDefault','',NULL,'Use this email address as the replyto in emails','Free'), ('ReportsLog','0',NULL,'If ON, log information about reports.','YesNo'), +('RequireCashRegister','0',NULL,'Require a cash register when collecting a payment','YesNo'), ('RequireStrongPassword','1','','Require a strong login password for staff and patrons','YesNo'), ('ReservesControlBranch','PatronLibrary','ItemHomeLibrary|PatronLibrary','Branch checked for members reservations rights','Choice'), ('ReservesMaxPickUpDelay','7','','Define the Maximum delay to pick up an item on hold','Integer'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/accounting.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/accounting.pref index b23880179b..0930801513 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/accounting.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/accounting.pref @@ -26,6 +26,14 @@ Accounting: 1: "Use" 0: "Don't use" - " cash registers with the accounting system to track payments." + - + - "When collecting a payment, " + - pref: RequireCashRegister + default: no + choices: + no: "require a cash register only when the CASH payment type is selected" + yes: "always require a cash register" + - " (Requires UseCashRegisters)" - - pref: EnablePointOfSale default: no diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt index cc6dc7bc5d..f8a97ac728 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt @@ -170,11 +170,26 @@ [% IF Koha.Preference('UseCashRegisters') %]
  • - - + [% ELSE %] + + + [% IF Koha.Preference('RequireCashRegister') %] + Required + [% END %]
  • [% END %] @@ -403,9 +418,13 @@ }, [% IF Koha.Preference('UseCashRegisters') %] cash_register: { - required: function() { - return $('#payment_type').val() == 'CASH' - } + [% IF Koha.Preference('RequireCashRegister') %] + required: true + [% ELSE %] + required: function() { + return $('#payment_type').val() == 'CASH' + } + [% END %] } [% END %] }, -- 2.30.2