@@ -, +, @@
---
.../prog/en/modules/members/paycollect.tt | 15 ++++++++
members/paycollect.pl | 38 ++++++++++++-------
2 files changed, 40 insertions(+), 13 deletions(-)
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt
+++ a/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 %]
+
+ [% END %]
[% ELSIF ( writeoff_individual ) %]
[% ELSE %]
+ [% IF ( error_registers && type != 'writeoff' ) %]
+
+ You must have at least one cash register associated with this branch before you can record payments.
+
+ [% ELSE %]
+ [% END %]
[% END %]
--- a/members/paycollect.pl
+++ a/members/paycollect.pl
@@ -74,20 +74,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) {
--