Browse Source

Bug 24786: Update paycollect to use session register

This patch adds handling to allow for the use of the session cash
register by default if it has been set, otherwise it defaults to '--
None --' and requires the end user to select the register to proceed
with the payment.

Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
20.11.x
Martin Renvoize 1 year ago
committed by Jonathan Druart
parent
commit
24804aa4c6
  1. 8
      Koha/Template/Plugin/Registers.pm
  2. 5
      koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc
  3. 22
      koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt
  4. 28
      members/paycollect.pl

8
Koha/Template/Plugin/Registers.pm

@ -44,7 +44,7 @@ sub session_register_name {
=head2
[% SET registers = Registers.all() %]
[% SET registers = Registers.all( { branch => branchcode } );
[% SET registers = Registers.all( { filters => { current_branch => 1 } } );
Returns a list of all cash registers available that adhere to the passed filters.
@ -53,7 +53,11 @@ Returns a list of all cash registers available that adhere to the passed filters
sub all {
my ( $self, $params ) = @_;
my $registers = Koha::Cash::Registers->search()->unblessed();
my $filters = $params->{filters};
my $where;
$where->{branch} = C4::Context->userenv->{'branch'}
if $filters->{current_branch};
my $registers = Koha::Cash::Registers->search($where)->unblessed();
for my $register ( @{$registers} ) {
$register->{selected} = ( defined( $self->session_register_id )
&& $register->{id} == $self->session_register_id ) ? 1 : 0;

5
koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc

@ -24,10 +24,9 @@
[% END %]
[% BLOCK options_for_registers %]
<!-- <option hidden disabled selected value> -- select an option -- </option> -->
<option id="noregister"[% IF register_required %] disabled selected [% END %] value="">-- None --</option>
<option id="noregister"[% IF register_required %] disabled [% END %] selected="selected" value="">[% IF register_required %]-- Select an option--[% ELSE %]-- None --[% END %]</option>
[% FOREACH r IN registers %]
[% IF r.branch == branch %]
[% IF r.branch == Branches.GetLoggedInBranchcode %]
[% IF r.selected %]
<option class="[% r.branch | html %] [% IF r.branch_default %]default[% END %]" value="[% r.id | html %]" selected="selected">[% r.name | html %]</option>
[% ELSE %]

22
koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt

@ -2,6 +2,7 @@
[% USE Asset %]
[% USE Koha %]
[% USE Branches %]
[% USE Registers %]
[% USE Price %]
[% SET footerjs = 1 %]
[% PROCESS 'payments.inc' %]
@ -20,6 +21,7 @@
[% END %]
</div>
[% END %]
[% SET registers = Registers.all( filters => { current_branch => 1 } ) %]
<title>Koha &rsaquo; Patrons &rsaquo;
[% IF type == 'WRITEOFF' %]
Write off an amount for [% patron.firstname | html %] [% patron.surname | html %]
@ -86,7 +88,7 @@
[% END %]
[% IF ( pay_individual ) %]
[% IF ( error_registers ) %]
[% IF Koha.Preference('UseCashRegisters') && ( registers.size == 0 ) %]
[% PROCESS 'cash_register_required' %]
[% ELSE %]
@ -153,13 +155,7 @@
<li>
<label for="cash_register">Cash register: </label>
<select name="cash_register" id="cash_register">
[% FOREACH register IN registers %]
[% IF register.id == default_register %]
<option value="[% register.id | html %]" selected="selected">[% register.name | html %]</option>
[% ELSE %]
<option value="[% register.id | html %]">[% register.name | html %]</option>
[% END %]
[% END %]
[% PROCESS options_for_registers register_required => 1 %]
</select>
</li>
[% END %]
@ -225,7 +221,7 @@
</div>
</form>
[% ELSE %]
[% IF ( error_registers && type != 'WRITEOFF' ) %]
[% IF Koha.Preference('UseCashRegisters') && ( registers.size == 0 ) && ( type != 'WRITEOFF' ) %]
[% PROCESS 'cash_register_required' %]
[% ELSE %]
@ -289,13 +285,7 @@
<li>
<label for="cash_register">Cash register: </label>
<select name="cash_register" id="cash_register">
[% FOREACH register IN registers %]
[% IF register.id == default_register %]
<option value="[% register.id | html %]" selected="selected">[% register.name | html %]</option>
[% ELSE %]
<option value="[% register.id | html %]">[% register.name | html %]</option>
[% END %]
[% END %]
[% PROCESS options_for_registers register_required => 1 %]
</select>
</li>
[% END %]

28
members/paycollect.pl

@ -77,33 +77,7 @@ my $payment_note = uri_unescape scalar $input->param('payment_note');
my $payment_type = scalar $input->param('payment_type');
my $accountlines_id;
my $cash_register_id;
if ( C4::Context->preference('UseCashRegisters') ) {
$cash_register_id = $input->param('cash_register');
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 ( !$cash_register_id ) {
my $default_register = Koha::Cash::Registers->find(
{ branch => $library_id, branch_default => 1 } );
$cash_register_id = $default_register->id if $default_register;
}
$cash_register_id = $registers->next->id if !$cash_register_id;
$template->param(
default_register => $cash_register_id,
registers => $registers,
);
}
}
my $cash_register_id = $input->param('cash_register');
if ( $pay_individual || $writeoff_individual ) {
if ($pay_individual) {
$template->param( pay_individual => 1 );

Loading…
Cancel
Save