Browse Source

Bug 27796: Centralise payment/transaction type handling

This patch centralises the payment/transaction type select options
handling so the SIP types are properly in all cases.

Test plan
1) Check that SIP payment types are properly hidden on the following
   modals.
1a) Refund modal on the borrower account page (The 'Account credit'
option should appear here)
1b) Payout modal on borrower account page
1c) Payment via paycollect
1d) Payment via point of sale
1e) Refund via point of sale, register details page (The 'Account
credit' option should only appear for debts associated to a patron and
not for payments accepted via point of sale)
2) Signoff

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
21.05.x
Martin Renvoize 2 years ago
committed by Jonathan Druart
parent
commit
89cea3d7a7
  1. 29
      koha-tmpl/intranet-tmpl/prog/en/includes/payments.inc
  2. 33
      koha-tmpl/intranet-tmpl/prog/en/includes/transaction_types.inc
  3. 42
      koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt
  4. 5
      koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt
  5. 3
      koha-tmpl/intranet-tmpl/prog/en/modules/pos/pay.tt
  6. 36
      koha-tmpl/intranet-tmpl/prog/en/modules/pos/register.tt
  7. 10
      members/boraccount.pl
  8. 4
      pos/register.pl

29
koha-tmpl/intranet-tmpl/prog/en/includes/payments.inc

@ -1,29 +0,0 @@
[% USE AuthorisedValues %]
[%- BLOCK account_payment_types -%]
[% SET payment_types = [] %]
[% FOR pt IN AuthorisedValues.GetAuthValueDropbox('PAYMENT_TYPE') %]
[% NEXT IF pt.authorised_value.grep("^SIP[[:digit:]]{2}$").size() %]
[% payment_types.push(pt) %]
[% END %]
[% IF payment_types.size > 0 %]
<li>
[% IF Koha.Preference('UseCashRegisters') %]
<label for="payment_type" class="required">Payment type: </label>
<select name="payment_type" id="payment_type" class="required" required="required">
[% FOREACH pt IN payment_types %]
<option value="[% pt.authorised_value | html %]">[% pt.lib | html %]</option>
[% END %]
</select>
<span class="required">Required</span>
[%- ELSE -%]
<label for="payment_type">Payment type: </label>
<select name="payment_type" id="payment_type">
<option value=""></option>
[% FOREACH pt IN payment_types %]
<option value="[% pt.authorised_value | html %]">[% pt.lib | html %]</option>
[% END %]
</select>
[%- END -%]
</li>
[% END %]
[%- END -%]

33
koha-tmpl/intranet-tmpl/prog/en/includes/transaction_types.inc

@ -0,0 +1,33 @@
[% USE AuthorisedValues %]
[% SET payment_types = [] %]
[% FOR pt IN AuthorisedValues.GetAuthValueDropbox('PAYMENT_TYPE') %]
[% NEXT IF pt.authorised_value.grep("^SIP[[:digit:]]{2}$").size() %]
[% payment_types.push(pt) %]
[% END %]
[% IF payment_types.size > 0 %]
<li>
[% IF Koha.Preference('UseCashRegisters') %]
<label for="[% type %]_type" class="required">[% IF type == 'payment' %]Payment[% ELSE %]Transaction[% END %] type: </label>
<select name="[% type %]_type" id="[% type %]_type" class="required" required="required">
[% IF type == 'refund' %]
<option value="AC">Account credit</option>
[% END %]
[% FOREACH pt IN payment_types %]
<option value="[% pt.authorised_value | html %]">[% pt.lib | html %]</option>
[% END %]
</select>
<span class="required">Required</span>
[%- ELSE -%]
<label for="[% type %]_type">[% IF type == 'payment' %]Payment[% ELSE %]Transaction[% END %] type: </label>
<select name="[% type %]_type" id="[% type %]_type">
<option value=""></option>
[% IF type == 'refund' %]
<option value="AC">Account credit</option>
[% END %]
[% FOREACH pt IN payment_types %]
<option value="[% pt.authorised_value | html %]">[% pt.lib | html %]</option>
[% END %]
</select>
[%- END -%]
</li>
[% END %]

42
koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt

@ -129,7 +129,7 @@
<button type="button" data-toggle="modal" data-target="#issuePayoutModal" data-account="[%- PROCESS account_type_description account=account -%]" data-accountline="[% account.accountlines_id | html %]" data-amount="[% account.amountoutstanding | $Price %]" class="btn btn-default btn-xs"><i class="fa fa-money"></i> Issue payout</button>
[% END %]
[% IF CAN_user_updatecharges_refund && account.is_debit && ( account.amountoutstanding != account.amount ) && !(account.status == 'REFUNDED') && !(account.debit_type_code == 'PAYOUT') %]
<button type="button" data-toggle="modal" data-target="#issueRefundModal" data-item="[%- PROCESS account_type_description account=account -%]" data-accountline="[% account.accountlines_id | html %]" data-amount="[% account.amount | $Price %]" data-amountoutstanding="[% account.amountoutstanding | $Price %]" class="btn btn-default btn-xs"><i class="fa fa-money"></i> Issue refund</button>
<button type="button" class="btn btn-default btn-xs" data-toggle="modal" data-target="#issueRefundModal" data-item="[%- PROCESS account_type_description account=account -%]" data-accountline="[% account.accountlines_id | html %]" data-amount="[% account.amount | $Price %]" data-amountoutstanding="[% account.amountoutstanding | $Price %]" data-member="[% credit.debit.borrowernumber %]"><i class="fa fa-money"></i> Issue refund</button>
[% END %]
[% IF CAN_user_updatecharges_discount && account.is_debit && ( account.amountoutstanding == account.amount ) && !(account.debit_type_code == 'PAYOUT') %]
<button type="button" data-toggle="modal" data-target="#applyDiscountModal" data-item="[%- PROCESS account_type_description account=account -%]" data-accountline="[% account.accountlines_id | html %]" data-amount="[% account.amount | $Price %]" data-amountoutstanding="[% account.amountoutstanding | $Price %]" class="btn btn-default btn-xs">Apply discount</button>
@ -191,20 +191,8 @@
<input type="text" inputmode="numeric" pattern="[0-9]*" id="amount" name="amount" required="required">
<span class="required">Required</span>
</li>
[% SET payment_types = AuthorisedValues.GetAuthValueDropbox('PAYMENT_TYPE') %]
[% SET excluded = ['SIP00', 'SIP01', 'SIP02'] %]
[% IF payment_types > 3 %]
<li>
<label for="transaction_type">Transaction type: </label>
<select name="transaction_type" id="payout_transaction_type">
[% FOREACH pt IN payment_types %]
[% UNLESS excluded.grep("^$pt.authorised_value\$").size %]
<option value="[% pt.authorised_value | html %]">[% pt.lib | html %]</option>
[% END %]
[% END %]
</select>
</li>
[% END %]
[% INCLUDE 'transaction_types.inc' type="payout" %]
[% IF Koha.Preference('UseCashRegisters') %]
<li>
@ -260,18 +248,8 @@
<input type="text" inputmode="numeric" pattern="[0-9]*" id="returned" name="amount" required="required">
<span class="required">Required</span>
</li>
[% SET payment_types = AuthorisedValues.GetAuthValueDropbox('PAYMENT_TYPE') %]
<li>
<label for="transaction_type">Transaction type: </label>
<select name="transaction_type" id="refund_transaction_type">
<option value="AC">Account credit</option>
[% IF payment_types %]
[% FOREACH pt IN payment_types %]
<option value="[% pt.authorised_value | html %]">[% pt.lib | html %]</option>
[% END %]
[% END %]
</select>
</li>
[% INCLUDE 'transaction_types.inc' type="refund" %]
[% IF Koha.Preference('UseCashRegisters') %]
<li>
@ -393,11 +371,17 @@
var accountline = button.data('accountline');
$('#refundline').val(accountline);
var amount = button.data('amount');
var amountoutstanding = button.data('amountoutstanding');
var amountoutstanding = button.data('amountoutstanding') || 0;
var paid = amount - amountoutstanding;
$("#paid + span").replaceWith(paid);
$("#returned").attr({ "value": paid, "max": paid, "min": 0 });
$("#returned, #refund_transaction_type").focus();
var member = button.data('member');
if ( member === '' ) {
$("#refund_type option[value='AC']").remove();
} else if ( $("#refund_type option[value='AC']").length == 0 ) {
$("#refund_type").prepend('<option value="AC" selected="selected">Account credit</option>');
}
$("#returned, #refund_type").focus();
});
$("#applyDiscountModal").on("shown.bs.modal", function(e){

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

@ -5,7 +5,6 @@
[% USE Registers %]
[% USE Price %]
[% SET footerjs = 1 %]
[% PROCESS 'payments.inc' %]
[% PROCESS 'accounts.inc' %]
[% INCLUDE 'doc-head-open.inc' %]
[% BLOCK cash_register_required %]
@ -167,7 +166,7 @@
<span id="change">0.00</span>
</li>
[% PROCESS account_payment_types %]
[% INCLUDE 'transaction_types.inc' type="payment" %]
[% IF Koha.Preference('UseCashRegisters') %]
<li>
@ -298,7 +297,7 @@
<span id="change">0.00</span>
</li>
[% PROCESS account_payment_types %]
[% INCLUDE 'transaction_types.inc' type="payment" %]
[% IF Koha.Preference('UseCashRegisters') %]
<li>

3
koha-tmpl/intranet-tmpl/prog/en/modules/pos/pay.tt

@ -6,7 +6,6 @@
[% USE TablesSettings %]
[% USE Registers %]
[% SET footerjs = 1 %]
[% PROCESS 'payments.inc' %]
[% INCLUDE 'doc-head-open.inc' %]
[% SET registers = Registers.all( filters => { current_branch => 1 } ) %]
<title>Koha &rsaquo; Payments</title>
@ -136,7 +135,7 @@
<input type="hidden" name="change" value="[% 0 | $Price %]"/>
</li>
[% PROCESS account_payment_types %]
[% INCLUDE 'transaction_types.inc' type="payment" %]
<li>
<label for="registerid" class="required">Cash register: </label>

36
koha-tmpl/intranet-tmpl/prog/en/modules/pos/register.tt

@ -114,9 +114,9 @@
<td></td>
<td>
[% IF CAN_user_cash_management_anonymous_refund && !(credit.debit.status == 'REFUNDED' ) %]
<button type="button" class="btn btn-default btn-xs" data-toggle="modal" data-target="#issueRefundModal" data-item="[%- PROCESS account_type_description account=credit.debit -%]" data-accountline="[% credit.debit.accountlines_id | html %]" data-amount="[% credit.debit.amount | $Price %]" data-quantity="[% credit.debit.note | html %]"><i class="fa fa-money"></i> Issue refund</button>
<button type="button" class="btn btn-default btn-xs" data-toggle="modal" data-target="#issueRefundModal" data-item="[%- PROCESS account_type_description account=credit.debit -%]" data-accountline="[% credit.debit.accountlines_id | html %]" data-amount="[% credit.debit.amount | $Price %]" data-amountoutstanding="[% credit.debit.amountoutstanding | $Price %]" data-member="[% credit.debit.borrowernumber %]"><i class="fa fa-money"></i> Issue refund</button>
[% ELSIF CAN_user_updatecharges_refund && !(credit.debit.status == 'REFUNDED') && credit.debit.borrowernumber %]
<button type="button" class="btn btn-default btn-xs" data-toggle="modal" data-target="#issueRefundModal" data-item="[%- PROCESS account_type_description account=credit.debit -%]" data-accountline="[% credit.debit.accountlines_id | html %]" data-amount="[% credit.debit.amount | $Price %]" data-quantity="[% credit.debit.note | html %]"><i class="fa fa-money"></i> Issue refund</button>
<button type="button" class="btn btn-default btn-xs" data-toggle="modal" data-target="#issueRefundModal" data-item="[%- PROCESS account_type_description account=credit.debit -%]" data-accountline="[% credit.debit.accountlines_id | html %]" data-amount="[% credit.debit.amount | $Price %]" data-amountoutstanding="[% credit.debit.amountoutstanding | $Price %]" data-member="[% credit.debit.borrowernumber %]"><i class="fa fa-money"></i> Issue refund</button>
[% END %]
</td>
</tr>
@ -202,8 +202,8 @@
<td>[% credit.debit.amount | $Price %]</td>
<td></td>
<td>
[% IF CAN_user_cash_management_refund_cash_registers && !(credit.debit.status == 'REFUNDED' ) %]
<button type="button" class="btn btn-default btn-xs pos_refund" data-toggle="modal" data-target="#issueRefundModal" data-item="[%- PROCESS account_type_description account=credit.debit -%]" data-accountline="[% credit.debit.accountlines_id | html %]" data-amount="[% credit.debit.amount | $Price %]" data-quantity="[% credit.debit.note | html %]"><i class="fa fa-money"></i> Issue refund</button>
[% IF CAN_user_cash_management_refund_cash_registers && !(credit.debit.status == 'REFUNDED') && !(credit.debit.debit_type_code == 'PAYOUT') %]
<button type="button" class="btn btn-default btn-xs pos_refund" data-toggle="modal" data-target="#issueRefundModal" data-item="[%- PROCESS account_type_description account=credit.debit -%]" data-accountline="[% credit.debit.accountlines_id | html %]" data-amount="[% credit.debit.amount | $Price %]" data-amountoutstanding="[% credit.debit.amountoutstanding | $Price %]" data-member="[% credit.debit.borrowernumber %]"><i class="fa fa-money"></i> Issue refund</button>
[% END %]
</td>
</tr>
@ -302,19 +302,7 @@
<input type="text" inputmode="decimal" pattern="^\d+(\.\d{2})?$" id="returned" name="amount" required="required">
<span class="required">Required</span>
</li>
[% SET payment_types = [] %]
[% FOR pt IN AuthorisedValues.GetAuthValueDropbox('PAYMENT_TYPE') %]
[% NEXT IF pt.authorised_value.grep("^SIP[[:digit:]]{2}$").size() %]
[% payment_types.push(pt) %]
[% END %]
<li>
<label for="transaction_type">Transaction type: </label>
<select name="transaction_type" id="transaction_type">
[% FOREACH pt IN payment_types %]
<option value="[% pt.authorised_value | html %]">[% pt.lib | html %]</option>
[% END %]
</select>
</li>
[% INCLUDE 'transaction_types.inc' type="refund" %]
</ol>
</fieldset> <!-- /.rows -->
</div> <!-- /.modal-body -->
@ -390,9 +378,17 @@
var accountline = button.data('accountline');
$('#refundline').val(accountline);
var amount = button.data('amount');
$("#paid + span").replaceWith(amount);
$("#returned").attr({ "value": amount, "max": amount });
$("#returned, #transaction_type").focus();
var amountoutstanding = button.data('amountoutstanding') || 0;
var paid = amount - amountoutstanding;
$("#paid + span").replaceWith(paid);
$("#returned").attr({ "value": paid, "max": paid });
var member = button.data('member');
if ( member === '' ) {
$("#refund_type option[value='AC']").remove();
} else if ( $("#refund_type option[value='AC']").length == 0 ) {
$("#refund_type").prepend('<option value="AC" selected="selected">Account credit</option>');
}
$("#returned, #refund_type").focus();
});
$(".printReceipt").click(function() {

10
members/boraccount.pl

@ -79,12 +79,12 @@ if ( $action eq 'payout' ) {
my $payment_id = scalar $input->param('accountlines_id');
my $payment = Koha::Account::Lines->find($payment_id);
my $amount = scalar $input->param('amount');
my $transaction_type = scalar $input->param('transaction_type');
my $payout_type = scalar $input->param('payout_type');
$schema->txn_do(
sub {
my $payout = $payment->payout(
{
payout_type => $transaction_type,
payout_type => $payout_type,
branch => $library_id,
staff_id => $logged_in_user->id,
cash_register => $registerid,
@ -100,7 +100,7 @@ if ( $action eq 'refund' ) {
my $charge_id = scalar $input->param('accountlines_id');
my $charge = Koha::Account::Lines->find($charge_id);
my $amount = scalar $input->param('amount');
my $transaction_type = scalar $input->param('transaction_type');
my $refund_type = scalar $input->param('refund_type');
$schema->txn_do(
sub {
@ -113,10 +113,10 @@ if ( $action eq 'refund' ) {
amount => $amount
}
);
unless ( $transaction_type eq 'AC' ) {
unless ( $refund_type eq 'AC' ) {
my $payout = $refund->payout(
{
payout_type => $transaction_type,
payout_type => $refund_type,
branch => $library_id,
staff_id => $logged_in_user->id,
cash_register => $registerid,

4
pos/register.pl

@ -119,7 +119,7 @@ else {
my $amount = $input->param('amount');
my $quantity = $input->param('quantity');
my $accountline_id = $input->param('accountline');
my $transaction_type = $input->param('transaction_type');
my $refund_type = $input->param('refund_type');
my $accountline = Koha::Account::Lines->find($accountline_id);
$schema->txn_do(
@ -136,7 +136,7 @@ else {
);
my $payout = $refund->payout(
{
payout_type => $transaction_type,
payout_type => $refund_type,
branch => $library_id,
staff_id => $logged_in_user->id,
cash_register => $cash_register->id,

Loading…
Cancel
Save