From 57a93704c00dadb389defffdd64400fa00e1a283 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Fri, 19 Jul 2019 09:20:49 +0100 Subject: [PATCH] Bug 23321: (follow-up) Require cash registers for payments This follow-up catches the case where no cash registers have been defined for the current branch and as such payments cannot be processed. Test plan: 1) Ensure you have 'UseCashRegisters' set to 'Do' 2) Attempt to make a payment for a fee whilst logged into a branch that has not yet had cash registers configured. 3) Note that you are shown a warning and cannot proceed. 4) Signoff Sponsored-by: PTFS Europe Sponsored-by: Cheshire Libraries Shared Services Signed-off-by: Maryse Simard Signed-off-by: Tomas Cohen Arazi Signed-off-by: Martin Renvoize --- .../prog/en/modules/members/paycollect.tt | 15 ++++++++ members/paycollect.pl | 38 ++++++++++++------- 2 files changed, 40 insertions(+), 13 deletions(-) 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 535b66b6cc..2f71eb842f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt @@ -61,6 +61,12 @@ [% END %] [% IF ( pay_individual ) %] + [% IF ( error_registers ) %] +
+ You must have at least one cash register associated with this branch before you can record payments. +
+ [% ELSE %] +
@@ -144,6 +150,7 @@ Cancel
+ [% END %] [% ELSIF ( writeoff_individual ) %]
@@ -190,6 +197,11 @@
[% ELSE %] + [% IF ( error_registers && type != 'writeoff' ) %] +
+ You must have at least one cash register associated with this branch before you can record payments. +
+ [% ELSE %]
@@ -231,6 +243,7 @@ 0.00 + [% IF type != 'writeoff' %] [% SET payment_types = AuthorisedValues.GetAuthValueDropbox('PAYMENT_TYPE') %] [% IF payment_types %]
  • @@ -258,6 +271,7 @@
  • [% END %] + [% END %]
  • @@ -270,6 +284,7 @@ Cancel
  • + [% END %] [% END %] diff --git a/members/paycollect.pl b/members/paycollect.pl index 2a1aeb9b0b..0974997885 100755 --- a/members/paycollect.pl +++ b/members/paycollect.pl @@ -75,20 +75,32 @@ my $payment_note = uri_unescape scalar $input->param('payment_note'); my $payment_type = scalar $input->param('payment_type'); my $accountlines_id; -my $registerid = $input->param('registerid'); -if ( !$registerid ) { - $registerid = Koha::Cash::Registers->find( - { branch => $library_id, branch_default => 1 }, - )->id; +my $registerid; +if ( C4::Context->preference('UseCashRegisters') ) { + $registerid = $input->param('registerid'); + my $registers = Koha::Cash::Registers->search( + { branch => $library_id, archived => 0 }, + { order_by => { '-asc' => 'name' } } + ); + + if ( !$registers->count ) { + $template->param( error_registers => 1 ); + } + else { + + if ( !$registerid ) { + my $default_register = Koha::Cash::Registers->find( + { branch => $library_id, branch_default => 1 } ); + $registerid = $default_register->id if $default_register; + } + $registerid = $registers->next->id if !$registerid; + + $template->param( + registerid => $registerid, + registers => $registers, + ); + } } -my $registers = Koha::Cash::Registers->search( - { branch => $library_id, archived => 0 }, - { order_by => { '-asc' => 'name' } } -); -$template->param( - registerid => $registerid, - registers => $registers, -); if ( $pay_individual || $writeoff_individual ) { if ($pay_individual) { -- 2.39.5