@@ -, +, @@ --- .../prog/en/modules/members/boraccount.tt | 62 +++++++++++++++++-- members/boraccount.pl | 20 ++++++ 2 files changed, 78 insertions(+), 4 deletions(-) --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt @@ -90,6 +90,9 @@ [% IF CAN_user_updatecharges_refund && account.is_debit && ( account.amountoutstanding != account.amount ) && !(account.status == 'REFUNDED') && !(account.debit_type_code == 'PAYOUT') %] [% END %] + [% IF CAN_user_updatecharges_discount && account.is_debit && ( account.amountoutstanding == account.amount ) && !(account.debit_type_code == 'PAYOUT') %] + + [% END %] @@ -147,7 +150,7 @@ [% IF payment_types > 3 %]
  • - [% FOREACH pt IN payment_types %] [% UNLESS excluded.grep("^$pt.authorised_value\$").size %] @@ -214,7 +217,7 @@ [% SET payment_types = AuthorisedValues.GetAuthValueDropbox('PAYMENT_TYPE') %]
  • - [% IF payment_types %] [% FOREACH pt IN payment_types %] @@ -252,6 +255,45 @@ + + + [% MACRO jsinclude BLOCK %] [% INCLUDE 'datatables.inc' %] [% INCLUDE 'columns_settings.inc' %] @@ -304,7 +346,7 @@ var amount = button.data('amount') * -1; $("#paid + span").replaceWith(amount); $("#amount").attr({ "value": amount, "max": amount }); - $("#amount, #transaction_type").focus(); + $("#amount, #payout_transaction_type").focus(); }); $("#issueRefundModal").on("shown.bs.modal", function(e){ @@ -318,7 +360,19 @@ var paid = amount - amountoutstanding; $("#paid + span").replaceWith(paid); $("#returned").attr({ "value": paid, "max": paid }); - $("#returned, #transaction_type").focus(); + $("#returned, #refund_transaction_type").focus(); + }); + + $("#applyDiscountModal").on("shown.bs.modal", function(e){ + var button = $(e.relatedTarget); + var item = button.data('item'); + $("#item + span").replaceWith(item); + var accountline = button.data('accountline'); + $('#discountline').val(accountline); + var amount = button.data('amount'); + $("#charged + span").replaceWith(amount); + $("#discount").attr({ "max": amount }); + $("#discount").focus(); }); }); --- a/members/boraccount.pl +++ a/members/boraccount.pl @@ -151,6 +151,26 @@ if ( $action eq 'refund' ) { ); } +if ( $action eq 'discount' ) { + my $charge_id = scalar $input->param('accountlines_id'); + my $charge = Koha::Account::Lines->find($charge_id); + my $amount = scalar $input->param('amount'); + $schema->txn_do( + sub { + + my $discount = $charge->reduce( + { + reduction_type => 'DISCOUNT', + branch => $library_id, + staff_id => $logged_in_user->id, + interface => 'intranet', + amount => $amount + } + ); + } + ); +} + #get account details my $total = $patron->account->balance; --