Bugzilla – Attachment 100089 Details for
Bug 24081
Add a 'discount' process to accounts
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24081: Add discount action to boraccount
Bug-24081-Add-discount-action-to-boraccount.patch (text/plain), 8.94 KB, created by
Martin Renvoize (ashimema)
on 2020-03-04 08:49:32 UTC
(
hide
)
Description:
Bug 24081: Add discount action to boraccount
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2020-03-04 08:49:32 UTC
Size:
8.94 KB
patch
obsolete
>From 54eb74b273df80deda3a2e7ce64a4273f0cc70f1 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Tue, 3 Mar 2020 19:22:49 +0000 >Subject: [PATCH] Bug 24081: Add discount action to boraccount > >This patch adds the ability to apply discounts to existing patron >charges from the boraccount page. > >Test plan >1/ Carry out some accounting actions that end up with debts on the >patron record. (Add a manual invoice for example) >2/ Note a new 'Apply discount' action button on the unpaid debt >3/ Paid debts do not display the action button >4/ Click the button >5/ Enter an amount into the resulting modal and click confirm >6/ Confirm that the outstanding debt has been reduced by the amount you >specified. >7/ Confirm that a new 'Discount' line appears on the patrons account >8/ Confirm that in the 'details' view of the debt that the discount line >was used against the debt to create the reduction. >9/ Signoff > >Signed-off-by: Michal Denar <black23@gmail.com> >--- > .../prog/en/modules/members/boraccount.tt | 62 +++++++++++++++++-- > members/boraccount.pl | 20 ++++++ > 2 files changed, 78 insertions(+), 4 deletions(-) > >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 c93eb6fa09..73010320e9 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt >+++ b/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') %] > <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 %] >+ [% 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"><i class="fa fa-percent"></i> Apply discount</button> >+ [% END %] > </td> > </tr> > >@@ -147,7 +150,7 @@ > [% IF payment_types > 3 %] > <li> > <label for="transaction_type">Transaction type: </label> >- <select name="transaction_type" id="transaction_type"> >+ <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> >@@ -214,7 +217,7 @@ > [% SET payment_types = AuthorisedValues.GetAuthValueDropbox('PAYMENT_TYPE') %] > <li> > <label for="transaction_type">Transaction type: </label> >- <select name="transaction_type" id="transaction_type"> >+ <select name="transaction_type" id="refund_transaction_type"> > <option value="AC">Account credit</option> > [% IF payment_types %] > [% FOREACH pt IN payment_types %] >@@ -252,6 +255,45 @@ > </form> <!-- /#refund_form --> > </div> <!-- /#issueRefundModal --> > >+ <!-- Apply discount modal --> >+ <div class="modal" id="applyDiscountModal" tabindex="-1" role="dialog" aria-labelledby="applyDiscountLabel"> >+ <form id="discount_form" action="/cgi-bin/koha/members/boraccount.pl" method="get" enctype="multipart/form-data" class="validated"> >+ <input type="hidden" name="accountlines_id" value="" id="discountline"> >+ <input type="hidden" name="action" value="discount"> >+ <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="applyDiscountLabel">Apply discount</h4> >+ </div> >+ <div class="modal-body"> >+ <fieldset class="rows"> >+ <ol> >+ <li> >+ <span id="item" class="label">Account type: </span><span></span> >+ </li> >+ <li> >+ <span id="charged" class="label">Amount charged: </span><span></span> >+ </li> >+ <li> >+ <label class="required" for="amount">Discount to apply: </label> >+ <input type="number" step="0.01" id="discount" name="amount" min="0.00" required="required"> >+ <span class="required">Required</span> >+ </li> >+ </ol> >+ </fieldset> <!-- /.rows --> >+ </div> <!-- /.modal-body --> >+ <div class="modal-footer"> >+ <input type="hidden" name="op" value="discount"> >+ <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> <!-- /#discount_form --> >+ </div> <!-- /#applyDiscountModal --> >+ > [% 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(); > }); > }); > </script> >diff --git a/members/boraccount.pl b/members/boraccount.pl >index 8dfe35d92e..dae6a5a484 100755 >--- a/members/boraccount.pl >+++ b/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; > >-- >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 24081
:
97090
|
97091
|
100044
|
100045
|
100046
|
100074
|
100075
|
100076
|
100084
|
100085
|
100086
|
100087
|
100088
|
100089
|
100111
|
100112
|
100113
|
100114