Bugzilla – Attachment 96417 Details for
Bug 23442
Add a 'refund' process to accounts
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23442: Add refund option to patron account page
Bug-23442-Add-refund-option-to-patron-account-page.patch (text/plain), 9.50 KB, created by
Martin Renvoize (ashimema)
on 2019-12-18 12:40:37 UTC
(
hide
)
Description:
Bug 23442: Add refund option to patron account page
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2019-12-18 12:40:37 UTC
Size:
9.50 KB
patch
obsolete
>From ff4fea506c93a04b9fadb2b49fd895b37cf7b655 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Thu, 21 Nov 2019 13:09:47 +0000 >Subject: [PATCH] Bug 23442: Add refund option to patron account page > >This enhancement adds a refined workflow to allow librarians >to refund payments to patrons and record these refunds on the >patrons account. > >The use case is that a patron has paid for something before >then performing an action that may require some level of refund >to be actioned. Perhaps they are returning a lost and paid for >book. > >Test plan: >1) Undertake a series of transactions that result in a debit > accountline being partially or fully paid off. >2) Note that a new 'Issue refund' button appears next to a > debit (but only if your user has the refund permission or > is a superlibrarian) >3) Click the 'Issue refund' button and a modal should appear > pre-populated with the amount - amountoutstanding. >4) You should be able to edit the amount you wish to refund, > record the refund or cancel. >5) Signoff >--- > .../prog/en/modules/members/boraccount.tt | 85 +++++++++++++++++++ > members/boraccount.pl | 33 +++++++ > 2 files changed, 118 insertions(+) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt >index 8e2039edaa..e0ac0ea8a2 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt >+++ b/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 ) %] > <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' ) %] >+ <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> >+ [% END %] > </td> > </tr> > >@@ -183,6 +186,74 @@ > </form> <!-- /#payout_form --> > </div> <!-- /#issuePayoutModal --> > >+ <!-- Issue refund modal --> >+ <div class="modal" id="issueRefundModal" tabindex="-1" role="dialog" aria-labelledby="issueRefundLabel"> >+ <form id="refund_form" action="/cgi-bin/koha/members/boraccount.pl" method="get" enctype="multipart/form-data" class="validated"> >+ <input type="hidden" name="accountlines_id" value="" id="refundline"> >+ <input type="hidden" name="action" value="refund"> >+ <input type="hidden" name="borrowernumber" value="[% account.borrowernumber | html %]"> >+ <div class="modal-dialog" role="document"> >+ <div class="modal-content"> >+ <div class="modal-header"> >+ <button type="button" class="closebtn" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> >+ <h4 class="modal-title" id="issueRefundLabel">Issue refund</h4> >+ </div> >+ <div class="modal-body"> >+ <fieldset class="rows"> >+ <ol> >+ <li> >+ <span id="item" class="label">Account: </span><span></span> >+ </li> >+ <li> >+ <span id="paid" class="label">Amount paid: </span><span></span> >+ </li> >+ <li> >+ <label class="required" for="amount">Returned to patron: </label> >+ <input type="number" step="0.01" id="returned" name="amount" min="0.00" required="required"> >+ <span class="required">Required</span> >+ </li> >+ [% SET payment_types = AuthorisedValues.GetAuthValueDropbox('PAYMENT_TYPE') %] >+ [% IF payment_types %] >+ <li> >+ <label for="transaction_type">Transaction type: </label> >+ <select name="transaction_type" id="transaction_type"> >+ <option value="AC">Account credit</option> >+ [% FOREACH pt IN payment_types %] >+ <option value="[% pt.authorised_value | html %]">[% pt.lib | html %]</option> >+ [% END %] >+ </select> >+ </li> >+ [% END %] >+ >+ [% IF Koha.Preference('UseCashRegisters') %] >+ <li> >+ <label for="cash_register">Cash register: </label> >+ <select name="cash_register" id="cash_register"> >+ [% FOREACH register IN registers %] >+ [% IF register.id == registerid %] >+ <option value="[% register.id %]" selected="selected">[% register.name | html %]</option> >+ [% ELSE %] >+ <option value="[% register.id %]">[% register.name | html %]</option> >+ [% END %] >+ [% END %] >+ </select> >+ </li> >+ [% END %] >+ >+ </ol> >+ </fieldset> <!-- /.rows --> >+ </div> <!-- /.modal-body --> >+ <div class="modal-footer"> >+ <input type="hidden" name="registerid" value="[% register.id | html %]"> >+ <input type="hidden" name="op" value="refund"> >+ <button type="submit" class="btn btn-default">Confirm</button> >+ <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button> >+ </div> <!-- /.modal-footer --> >+ </div> <!-- /.modal-content --> >+ </div> <!-- /.modal-dialog --> >+ </form> <!-- /#refund_form --> >+ </div> <!-- /#issueRefundModal --> >+ > [% 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(); >+ }); > }); > </script> > [% END %] >diff --git a/members/boraccount.pl b/members/boraccount.pl >index df2ad35815..f5d7256499 100755 >--- a/members/boraccount.pl >+++ b/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; > >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 23442
:
92954
|
92955
|
92956
|
95674
|
95675
|
95676
|
95677
|
96400
|
96401
|
96402
|
96403
|
96414
|
96415
|
96416
|
96417
|
97008
|
97009
|
97010
|
97011
|
97012
|
97062
|
97063
|
97064
|
97065
|
97066
|
97067
|
97151
|
97152
|
97153
|
97154
|
97155
|
97156