@@ -, +, @@
accountline being partially or fully paid off.
debit (but only if your user has the refund permission or
is a superlibrarian)
pre-populated with the amount - amountoutstanding.
record the refund or cancel.
---
.../prog/en/modules/members/boraccount.tt | 85 +++++++++++++++++++
members/boraccount.pl | 33 +++++++
2 files changed, 118 insertions(+)
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt
@@ -87,6 +87,9 @@
[% IF CAN_user_updatecharges_payout && account.is_credit && ( account.amountoutstanding < 0 ) %]
[% END %]
+ [% IF CAN_user_updatecharges_refund && account.is_debit && ( account.amountoutstanding != account.amount ) && !(account.status == 'REFUNDED' ) %]
+
+ [% END %]
@@ -183,6 +186,74 @@
+
+
+
[% MACRO jsinclude BLOCK %]
[% INCLUDE 'datatables.inc' %]
[% INCLUDE 'columns_settings.inc' %]
@@ -239,6 +310,20 @@
$("#amount").attr({ "value": amount, "max": amount });
$("#amount, #transaction_type").focus();
});
+
+ $("#issueRefundModal").on("shown.bs.modal", function(e){
+ var button = $(e.relatedTarget);
+ var item = button.data('item');
+ $("#item + span").replaceWith(item);
+ var accountline = button.data('accountline');
+ $('#refundline').val(accountline);
+ var amount = button.data('amount');
+ var amountoutstanding = button.data('amountoutstanding');
+ var paid = amount - amountoutstanding;
+ $("#paid + span").replaceWith(paid);
+ $("#returned").attr({ "value": paid, "max": paid });
+ $("#returned, #transaction_type").focus();
+ });
});
[% END %]
--- a/members/boraccount.pl
+++ a/members/boraccount.pl
@@ -118,6 +118,39 @@ if ( $action eq 'payout' ) {
);
}
+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');
+ $schema->txn_do(
+ sub {
+
+ my $refund = $charge->reduce(
+ {
+ reduction_type => 'REFUND',
+ branch => $library_id,
+ staff_id => $logged_in_user->id,
+ interface => 'intranet',
+ amount => $amount
+ }
+ );
+ unless ( $transaction_type eq 'AC' ) {
+ my $payout = $refund->payout(
+ {
+ payout_type => $transaction_type,
+ branch => $library_id,
+ staff_id => $logged_in_user->id,
+ cash_register => $registerid,
+ interface => 'intranet',
+ amount => $amount
+ }
+ );
+ }
+ }
+ );
+}
+
#get account details
my $total = $patron->account->balance;
--