From f44f3c97d3b012407ba3b0ffc6aca7962041b6c8 Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Tue, 13 Apr 2021 10:06:24 +0200 Subject: [PATCH] Bug 28138: Add syspref to make the payment type required The payment type is already required when using the cash register feature, but some users want to force selecting a payment type even when cash registers are not used The new system preference name is RequirePaymentType Test plan: 1. Apply patch and run updatedatabase.pl 2. Disable UseCashRegisters and RequirePaymentType sysprefs 3. Create some authorised values in PAYMENT_TYPE category if needed 4. Create a manual invoice and pay it. Notice that the payment type is optional. 5. Enable RequirePaymentType 6. Create a manual invoice and pay it. Notice that the payment type is now required. 7. Enable UseCashRegisters and verify that the payment type is always required, even if RequirePaymentType is disabled Rebased by Thibaud Guillot on 21-12-02 Signed-off-by: shiyao Signed-off-by: Lucas Gass --- .../add-system-preference-RequirePaymentType.perl | 9 +++++++++ installer/data/mysql/mandatory/sysprefs.sql | 1 + .../intranet-tmpl/prog/en/includes/transaction_types.inc | 2 +- .../prog/en/modules/admin/preferences/accounting.pref | 7 +++++++ 4 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 installer/data/mysql/atomicupdate/add-system-preference-RequirePaymentType.perl diff --git a/installer/data/mysql/atomicupdate/add-system-preference-RequirePaymentType.perl b/installer/data/mysql/atomicupdate/add-system-preference-RequirePaymentType.perl new file mode 100644 index 0000000000..5ba51c1a38 --- /dev/null +++ b/installer/data/mysql/atomicupdate/add-system-preference-RequirePaymentType.perl @@ -0,0 +1,9 @@ +$DBversion = 'XXX'; +if ( CheckVersion($DBversion) ) { + $dbh->do(q{ + INSERT IGNORE INTO systempreferences (`variable`,`value`,`options`,`explanation`,`type`) + VALUES ('RequirePaymentType','0','','Require staff to select a payment type when a payment is made','YesNo') + }); + + NewVersion( $DBversion, '28138', 'Add system preference RequirePaymentType'); +} diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index 1b029aa5ee..251f1630b5 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -568,6 +568,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'), +('RequirePaymentType','0','','Require staff to select a payment type when a payment is made','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/includes/transaction_types.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/transaction_types.inc index 267e5b30ed..cc1ef8a0cb 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/transaction_types.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/transaction_types.inc @@ -6,7 +6,7 @@ [% END %] [% IF payment_types.size > 0 %]
  • - [% IF Koha.Preference('UseCashRegisters') %] + [% IF Koha.Preference('UseCashRegisters') || Koha.Preference('RequirePaymentType') %]