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.

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
This commit is contained in:
Julian Maurice 2022-04-15 10:01:00 +02:00 committed by Fridolin Somers
parent 5d50e73652
commit d8163c0fc5
4 changed files with 50 additions and 5 deletions

View File

@ -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';
},
};

View File

@ -569,6 +569,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'),
('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'),

View File

@ -33,6 +33,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

View File

@ -187,11 +187,26 @@
[% IF Koha.Preference('UseCashRegisters') %]
<li>
<label for="cash_register">Cash register: </label>
<select name="cash_register" id="cash_register">
[% IF Koha.Preference('RequireCashRegister') %]
<label for="cash_register" class="required">
[% ELSE %]
<label for="cash_register">
[% END %]
Cash register:
</label>
[% IF Koha.Preference('RequireCashRegister') %]
<select name="cash_register" id="cash_register" required>
[% ELSE %]
<select name="cash_register" id="cash_register">
[% END %]
<option id="noregister" disabled selected="selected" value="">-- Select an option--</option>
[% PROCESS options_for_registers %]
</select>
[% IF Koha.Preference('RequireCashRegister') %]
<span class="required">Required</span>
[% END %]
</li>
[% END %]
</ol>
@ -420,9 +435,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 %]
},