@@ -, +, @@
---
.../prog/en/modules/pos/register.tt | 72 ++++++++++++++++++-
pos/register.pl | 34 +++++++++
2 files changed, 105 insertions(+), 1 deletion(-)
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/pos/register.tt
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/pos/register.tt
@@ -2,6 +2,7 @@
[% USE Asset %]
[% USE Koha %]
[% USE KohaDates %]
+[% USE AuthorisedValues %]
[% USE Price %]
[% SET footerjs = 1 %]
[% PROCESS 'accounts.inc' %]
@@ -97,7 +98,13 @@
[% credit.debit.amount | $Price %]
|
- |
+
+ [% IF CAN_user_cash_management_anonymous_refund && !(credit.debit.status == 'REFUNDED' ) %]
+
+ [% ELSIF CAN_user_updatecharges_refund && !(credit.debit.status == 'REFUNDED') && credit.debit.borrowernumber %]
+
+ [% END %]
+ |
[% END %]
[% END %]
@@ -147,6 +154,57 @@
+
+
+
[% MACRO jsinclude BLOCK %]
[% INCLUDE 'datatables.inc' %]
[% Asset.js("lib/jquery/plugins/rowGroup/dataTables.rowGroup.min.js") | $raw %]
@@ -171,6 +229,18 @@
}
}));
+ $("#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');
+ $("#paid + span").replaceWith(amount);
+ $("#returned").attr({ "value": amount, "max": amount });
+ $("#returned, #transaction_type").focus();
+ });
+
$(".printReceipt").click(function() {
var accountlines_id = $(this).data('accountline');
var win = window.open('/cgi-bin/koha/pos/printreceipt.pl?action=print&accountlines_id=' + accountlines_id, '_blank');
--- a/pos/register.pl
+++ a/pos/register.pl
@@ -39,6 +39,7 @@ my ( $template, $loggedinuser, $cookie, $user_flags ) = get_template_and_user(
}
);
my $logged_in_user = Koha::Patrons->find($loggedinuser) or die "Not logged in";
+my $schema = Koha::Database->new->schema;
my $library_id = C4::Context->userenv->{'branch'};
my $registerid = $input->param('registerid');
@@ -79,6 +80,39 @@ else {
}
);
}
+ elsif ( $op eq 'refund' ) {
+ my $amount = $input->param('amount');
+ my $quantity = $input->param('quantity');
+ my $accountline_id = $input->param('accountline');
+ my $transaction_type = $input->param('transaction_type');
+
+ my $accountline = Koha::Account::Lines->find($accountline_id);
+ $schema->txn_do(
+ sub {
+
+ my $refund = $accountline->reduce(
+ {
+ reduction_type => 'Refund',
+ branch => $library_id,
+ staff_id => $logged_in_user->id,
+ interface => 'intranet',
+ amount => $amount
+ }
+ );
+ my $payout = $refund->payout(
+ {
+ payout_type => $transaction_type,
+ branch => $library_id,
+ staff_id => $logged_in_user->id,
+ cash_register => $cash_register->id,
+ interface => 'intranet',
+ amount => $amount
+ }
+ );
+
+ }
+ );
+ }
}
output_html_with_http_headers( $input, $cookie, $template->output );
--