Koha/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt
Katrin Fischer 6d6f763182
Bug 33056: Terminology: change 'fine' to 'charge'when making a payment or writeoff
In the development meeting of Feb 22, 2023, we decided to change 'fine' to 'charge' when referring to various types of fees ('fine' should be limited to overdue fines).

To test:
0. Go to patron's account accounting tab, Make a payment section
   --> It will read: X has no outstanding fines.
   0.1 Create a manual invoice
   --> Use "Write off all" button, verify confirmation message says 'fines'
1. Add a manual fee to a patron's account
   1.1. Go to a patron's account > Accounting tab
   1.2. Click 'Create manual invoice'
   1.3. Enter an amount
   1.4. Click 'Save'
2. Pay an individual charge
   2.1. Click 'Make a payment'
   2.2. Click the 'Pay' button next to an individual charge
   --> In the browser tab title, it says 'Collect fine payment for ...'
   --> In the breadcrumbs, the last section is 'Pay an individual fine'
   --> The heading of the page is 'Pay an individual fine'
   --> The heading inside the payment tab is 'Pay an individual fine'
   2.3. Click 'Cancel' and go back to the 'Make a payment' tab
3. Pay an amount toward all charges
   3.1. Click 'Pay amount'
   --> In the browser tab title, it says 'Collect fine payment for ...'
   --> In the breadcrumbs, the last section is 'Pay an amount toward all fines'
   --> The heading of the page is 'Pay an amount toward all fines'
   --> The heading inside the payment tab is 'Pay an amount toward all fines'
   3.2. Click 'Cancel' and go back to the 'Make a payment' tab
4. Pay an amount toward selected charges
   4.1. Click 'Pay selected'
   --> In the browser tab title, it says 'Collect fine payment for ...'
   --> In the breadcrumbs, the last section is 'Pay an amount toward selected fines'
   --> The heading of the page is 'Pay an amount toward selected fines'
   --> The heading inside the payment tab is 'Pay an amount toward selected fines'
   4.2. Click 'Cancel' and go back to the 'Make a payment' tab
5. Write off an individual charge
   5.1. Click the 'Write off' button next to an individual charge
   --> In the browser tab title, it says 'Collect fine payment for ...'
   --> In the breadcrumbs, the last section is 'Write off an individual fine'
   --> The heading of the page is 'Write off an individual fine'
   --> The heading inside the payment tab is 'Write off an individual fine'
   5.2. Click 'Cancel' and go back to the 'Make a payment' tab
6. Write off selected charges
   6.1. Click 'Writeoff selected'
   --> In the browser tab title, it says 'Write off an amount for ...'
   --> In the breadcrumbs, the last section is 'Write off an amount toward selected fines'
   --> The heading of the page is 'Write off an amount toward selected fines'
   --> The heading inside the payment tab is 'Write off an amount toward selected fines'
   6.2. Click 'Cancel' and go back to the 'Make a payment' tab
7. Apply patch and repeat
   --> All fines should now be charges.

Signed-off-by: Caroline Cyr La Rose <caroline.cyr-la-rose@inlibro.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2023-03-16 16:24:35 -03:00

565 lines
24 KiB
Text

[% USE raw %]
[% USE Asset %]
[% USE Koha %]
[% USE Branches %]
[% USE Registers %]
[% USE Price %]
[% SET footerjs = 1 %]
[% PROCESS 'accounts.inc' %]
[% INCLUDE 'doc-head-open.inc' %]
[% BLOCK cash_register_required %]
<div id="error_message" class="dialog message">
<p>
You must have at least one cash register associated with the library before you can record payments.
</p>
[% IF ( CAN_user_parameters_manage_cash_registers ) %]
<form action="/cgi-bin/koha/admin/cash_registers.pl" method="get">
<input type="hidden" name="op" value="add_form" />
<button class="new" type="submit"><i class="fa fa-plus"></i> Create a new cash register</button>
</form>
[% END %]
</div>
[% END %]
[% SET registers = Registers.all( filters => { current_branch => 1 } ) %]
<title>
[% IF type == 'WRITEOFF' %]
Write off an amount for [% INCLUDE 'patron-title.inc' no_html = 1 %]
[% ELSE %]
Collect payment for [% INCLUDE 'patron-title.inc' no_html = 1 %]
[% END %] &rsaquo; Patrons &rsaquo; Koha
</title>
[% INCLUDE 'doc-head-close.inc' %]
</head>
<body id="pat_paycollect" class="pat">
[% WRAPPER 'header.inc' %]
[% INCLUDE 'patron-search-header.inc' %]
[% END %]
[% WRAPPER 'sub-header.inc' %]
<nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
<ol>
<li>
<a href="/cgi-bin/koha/mainpage.pl">Home</a>
</li>
<li>
<a href="/cgi-bin/koha/members/members-home.pl">Patrons</a>
</li>
<li>
<a href="/cgi-bin/koha/members/pay.pl?borrowernumber=[% patron.borrowernumber | uri %]">Pay charges for [% INCLUDE 'patron-title.inc' %]</a>
</li>
<li>
<a href="#" aria-current="page">
[% IF ( pay_individual ) %]
<span>Pay an individual charge</span>
[% ELSIF ( writeoff_individual ) %]
<span>Write off an individual charge</span>
[% ELSE %]
[% IF ( selected_accts ) %]
[% IF type == 'WRITEOFF' %]
<span>Write off an amount toward selected charges</span>
[% ELSE %]
<span>Pay an amount toward selected charges</span>
[% END %]
[% ELSE %]
<span>Pay an amount toward all charges</span>
[% END %]
[% END %]
</a>
</li>
</ol>
</nav>
[% END %]
<div class="main container-fluid">
<div class="row">
<div class="col-sm-10 col-sm-push-2">
<main>
<h1>
[% IF ( pay_individual ) %]
<span>Pay an individual charge</span>
[% ELSIF ( writeoff_individual ) %]
<span>Write off an individual charge</span>
[% ELSE %]
[% IF ( selected_accts ) %]
[% IF type == 'WRITEOFF' %]
<span>Write off an amount toward selected charges</span>
[% ELSE %]
<span>Pay an amount toward selected charges</span>
[% END %]
[% ELSE %]
<span>Pay an amount toward all charges</span>
[% END %]
[% END %]
</h1>
[% INCLUDE 'members-toolbar.inc' borrowernumber=patron.borrowernumber %]
<!-- The manual invoice and credit buttons -->
<div class="toptabs">
<ul class="nav nav-tabs" role="tablist">
<li role="presentation" class="transactions">
<a href="/cgi-bin/koha/members/boraccount.pl?borrowernumber=[% patron.borrowernumber | uri %]" role="tab">Transactions</a>
</li>
<li role="presentation" class="makepayment active">
<a href="/cgi-bin/koha/members/pay.pl?borrowernumber=[% patron.borrowernumber | uri %]" role="tab">Make a payment</a>
</li>
<li role="presentation">
<a href="/cgi-bin/koha/members/maninvoice.pl?borrowernumber=[% patron.borrowernumber | uri %]" role="tab">Create manual invoice</a>
</li>
<li role="presentation">
<a href="/cgi-bin/koha/members/mancredit.pl?borrowernumber=[% patron.borrowernumber | uri %]" role="tab">Create manual credit</a>
</li>
</ul> <!-- /.nav.nav-tabs -->
<div class="tab-content">
<div role="tabpanel" class="tab-pane active">
[% IF ( error_over ) %]
<div id="error_message" class="dialog alert">
You must pay a value less than or equal to [% total_due | $Price %].
</div>
[% END %]
[% IF ( error_under ) %]
<div id="error_message" class="dialog alert">
You must collect a value greater than or equal to [% total_paid | $Price %].
</div>
[% END %]
[% IF ( pay_individual ) %]
[% IF Koha.Preference('UseCashRegisters') && ( registers.size == 0 ) %]
[% PROCESS 'cash_register_required' %]
[% ELSE %]
<ul class="nav nav-pills">
<li role="presentation" class="active"><a href="#">Pay</a></li>
<li role="presentation"><a href="/cgi-bin/koha/members/paycollect.pl?writeoff_individual=1&borrowernumber=[% patron.borrowernumber | uri %]&debit_type_code=[% debit_type_code | uri %]&amount=[% amount | uri %]&amountoutstanding=[% amountoutstanding | uri %]&description=[% individual_description | uri %]&itemnumber=[% itemnumber | uri %]&accountlines_id=[% accountlines_id | uri %]&payment_note=[% payment_note | uri %]">Write off</a></li>
</ul>
<form name="payindivfine" id="payindivfine" method="post" action="/cgi-bin/koha/members/paycollect.pl">
<input type="hidden" name="csrf_token" value="[% csrf_token | html %]" />
<input type="hidden" name="borrowernumber" id="borrowernumber" value="[% patron.borrowernumber | html %]" />
<input type="hidden" name="pay_individual" id="pay_individual" value="[% pay_individual | html %]" />
<input type="hidden" name="itemnumber" id="itemnumber" value="[% itemnumber | html %]" />
<input type="hidden" name="description" id="description" value="[% individual_description | html %]" />
<input type="hidden" name="debit_type_code" id="debit_type_code" value="[% debit_type_code | html %]" />
<input type="hidden" name="amount" id="amount" value="[% amount | html %]" />
<input type="hidden" name="amountoutstanding" id="amountoutstanding" value="[% amountoutstanding | html %]" />
<input type="hidden" name="accountlines_id" id="accountlines_id" value="[% accountlines_id | html %]" />
<input type="hidden" name="change_given" id="change_given" />
<fieldset class="rows">
<legend>Pay an individual charge</legend>
<input type="hidden" name="payment_note" id="payment_note" value="[% payment_note | html %]" />
<table>
<thead><tr>
<th>Description</th>
<th>Account type</th>
<th>Amount</th>
<th>Amount outstanding</th>
</tr></thead>
<tfoot>
<tr><td colspan="3">Total amount payable:</td><td>[% amountoutstanding | $Price %]</td></tr>
</tfoot>
<tbody><tr>
<td>
[% individual_description | html %]
</td>
[% line.debit_type_code = debit_type_code %]
<td>[% PROCESS account_type_description account=line %]</td>
<td class="debit">[% amount | $Price %]</td>
<td class="debit">[% amountoutstanding | $Price %]</td>
</tr></tbody>
</table>
<ol>
<li>
<label for="paid">Amount being paid: </label>
<input name="paid" id="paid" type="text" step="0.01" min="0" value="[% amountoutstanding | $Price on_editing => 1 %]"/>
</li>
<li>
<label for="collected">Amount tendered: </label>
<input name="collected" id="collected" type="text" step="0.01" min="0" value="[% amountoutstanding | $Price on_editing => 1 %]"/>
</li>
<li>
<label>Change to give: </label>
<span id="change">0.00</span>
</li>
[% INCLUDE 'transaction_types.inc' type="payment" %]
[% IF Koha.Preference('UseCashRegisters') %]
<li>
[% IF Koha.Preference('RequireCashRegister') %]
<label for="cash_register" class="required">
[% ELSE %]
<label for="cash_register">
[% END %]
Cash register:
</label>
[% IF Koha.Preference('RequireCashRegister') %]
<select name="cash_register" id="cash_register" required>
[% ELSE %]
<select name="cash_register" id="cash_register">
[% END %]
<option id="noregister" disabled selected="selected" value="">-- Select an option--</option>
[% PROCESS options_for_registers %]
</select>
[% IF Koha.Preference('RequireCashRegister') %]
<span class="required">Required</span>
[% END %]
</li>
[% END %]
</ol>
</fieldset>
[% IF available_additional_fields %]
[% INCLUDE 'additional-fields-entry.inc' available=available_additional_fields values=additional_field_values %]
[% END %]
<div class="action">
<input type="submit" name="submitbutton" class="btn btn-primary" value="Confirm" />
<a class="cancel" href="/cgi-bin/koha/members/pay.pl?borrowernumber=[% patron.borrowernumber | html %]">Cancel</a>
</div>
</form>
[% END %]
[% ELSIF ( writeoff_individual ) %]
<ul class="nav nav-pills">
<li role="presentation"><a href="/cgi-bin/koha/members/paycollect.pl?pay_individual=1&borrowernumber=[% patron.borrowernumber | uri %]&debit_type_code=[% debit_type_code | uri %]&amount=[% amount | uri %]&amountoutstanding=[% amountoutstanding | uri %]&description=[% individual_description | uri %]&itemnumber=[% itemnumber | uri %]&accountlines_id=[% accountlines_id | uri %]&payment_note=[% payment_note | uri %]">Pay</a></li>
<li role="presentation" class="active"><a href="#">Write off</a></li>
</ul>
<form name="woindivfine" id="woindivfine" action="/cgi-bin/koha/members/pay.pl" method="post" >
<input type="hidden" name="csrf_token" value="[% csrf_token | html %]" />
<fieldset class="rows">
<legend>Write off an individual charge</legend>
<input type="hidden" name="borrowernumber" id="borrowernumber" value="[% patron.borrowernumber | html %]" />
<input type="hidden" name="pay_individual" id="pay_individual" value="[% pay_individual | html %]" />
<input type="hidden" name="itemnumber" id="itemnumber" value="[% itemnumber | html %]" />
<input type="hidden" name="description" id="description" value="[% individual_description | html %]" />
<input type="hidden" name="debit_type_code" id="debit_type_code" value="[% debit_type_code | html %]" />
<input type="hidden" name="amount" id="amount" value="[% amount | html %]" />
<input type="hidden" name="accountlines_id" id="accountlines_id" value="[% accountlines_id | html %]" />
<input type="hidden" name="payment_note" id="payment_note" value="[% payment_note | html %]" />
<input type="hidden" name="amountoutstanding" id="amountoutstanding" value="[% amountoutstanding | html %]" />
<input type="hidden" name="confirm_writeoff" id="confirm_writeoff" value="1" />
<input type="hidden" name="change_given" id="change_given" />
<table>
<thead><tr>
<th>Description</th>
<th>Account type</th>
<th>Amount</th>
<th>Amount outstanding</th>
</tr></thead>
<tfoot><tr><td colspan="3">Total amount outstanding:</td><td>[% amountoutstanding | $Price %]</td></tr></tfoot>
<tbody><tr>
<td>[% individual_description | html %]</td>
[% line.debit_type_code = debit_type_code %]
<td>[% PROCESS account_type_description account=line %]</td>
<td class="debit">[% amount | $Price %]</td>
<td class="debit">[% amountoutstanding | $Price %]</td>
</tr></tbody>
</table>
<ol>
<li>
<label for="amountwrittenoff">Writeoff amount: </label>
<!-- default to writing off all -->
<input name="amountwrittenoff" id="amountwrittenoff" value="[% amountoutstanding | $Price on_editing => 1 %]" type="text" />
</li>
</ol>
</fieldset>
[% IF available_additional_fields %]
[% INCLUDE 'additional-fields-entry.inc' available=available_additional_fields values=additional_field_values %]
[% END %]
<div class="action">
<input type="submit" class="btn btn-primary" value="Write off this charge" />
<a class="cancel" href="/cgi-bin/koha/members/pay.pl?borrowernumber=[% patron.borrowernumber | html %]">Cancel</a>
</div>
</form>
[% ELSE %]
[% IF Koha.Preference('UseCashRegisters') && ( registers.size == 0 ) && ( type != 'WRITEOFF' ) %]
[% PROCESS 'cash_register_required' %]
[% ELSE %]
[% IF selected_accts %]
<ul class="nav nav-pills">
[% IF type == 'WRITEOFF' %]
<li role="presentation"><a href="/cgi-bin/koha/members/paycollect.pl?borrowernumber=[% patron.borrowernumber | uri %]&type=PAYMENT&amt=[% amt | uri %]&selected=[% selected_accts | uri %]&notes=[% selected_accts_notes | uri %]">Pay</a></li>
<li role="presentation" class="active"><a>Write off</a></li>
[% ELSE %]
<li role="presentation" class="active"><a>Pay</a></li>
<li role="presentation"><a href="/cgi-bin/koha/members/paycollect.pl?borrowernumber=[% patron.borrowernumber | uri %]&type=WRITEOFF&amt=[% amt | uri %]&selected=[% selected_accts | uri %]&notes=[% selected_accts_notes | uri %]">Write off</a></li>
[% END %]
</ul>
[% END %]
<form name="payfine" id="payfine" method="post" action="/cgi-bin/koha/members/paycollect.pl">
<input type="hidden" name="csrf_token" value="[% csrf_token | html %]" />
<input type="hidden" name="borrowernumber" id="borrowernumber" value="[% patron.borrowernumber | html %]" />
<input type="hidden" name="selected_accts" id="selected_accts" value="[% selected_accts | html %]" />
<input type="hidden" name="total" id="total" value="[% total | html %]" />
<input type="hidden" name="type" value="[% type | html %]" />
<input type="hidden" name="change_given" id="change_given" />
<fieldset class="rows">
[% IF ( selected_accts ) %]
[% IF type == 'WRITEOFF' %]
<legend>Write off an amount toward selected charges</legend>
[% ELSE %]
<legend>Pay an amount toward selected charges</legend>
[% END %]
[% ELSE %]
<legend>Pay an amount toward all charges</legend>
[% END %]
<ol>
<li>
<span class="label">Total amount outstanding: </span>
<span class="debit">[% total | $Price %]</span>
</li>
<li>
[% IF type == 'WRITEOFF' %]
<label for="paid">Writeoff amount: </label>
[% ELSE %]
<label for="paid">Amount being paid: </label>
[% END %]
<input name="paid" id="paid" type="text" step="0.01" min="0" value="[% total | $Price on_editing => 1 %]"/>
</li>
[% IF type != 'WRITEOFF' %]
<li>
<label for="collected">Amount tendered: </label>
<input name="collected" id="collected" type="text" step="0.01" min="0" value="[% total | $Price on_editing => 1 %]"/>
</li>
<li>
<label>Change to give: </label>
<span id="change">0.00</span>
</li>
[% INCLUDE 'transaction_types.inc' type="payment" %]
[% IF Koha.Preference('UseCashRegisters') %]
<li>
<label for="cash_register">Cash register: </label>
<select name="cash_register" id="cash_register">
<option id="noregister" disabled selected="selected" value="">-- Select an option--</option>
[% PROCESS options_for_registers %]
</select>
</li>
[% END %]
[% END %]
<li>
<label for="selected_accts_notes">Note: </label>
<textarea name="selected_accts_notes" id="selected_accts_notes">[% selected_accts_notes | html %]</textarea>
</li>
</ol>
</fieldset>
[% IF available_additional_fields %]
[% INCLUDE 'additional-fields-entry.inc' available=available_additional_fields values=additional_field_values %]
[% END %]
<div class="action">
<input type="submit" name="submitbutton" class="btn btn-primary" value="Confirm" />
<a class="cancel" href="/cgi-bin/koha/members/pay.pl?borrowernumber=[% patron.borrowernumber | html %]">Cancel</a>
</div>
</form>
[% END %]
[% END %]
</div> <!-- /.tab-pane -->
</div> <!-- /.tab-content -->
</div> <!-- /.toptabs -->
</main>
</div> <!-- /.col-sm-10.col-sm-push-2 -->
<div class="col-sm-2 col-sm-pull-10">
<aside>
[% INCLUDE 'circ-menu.inc' %]
</aside>
</div> <!-- /.col-sm-2.col-sm-pull-10 -->
</div> <!-- /.row -->
<!-- Modal -->
<div id="confirm_change_form" class="modal" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h3>The amount collected is more than the outstanding charge</h3>
</div>
<div class="modal-body">
<p>The amount collected from the patron is higher than the amount to be paid.</p>
<p>The change to give is <strong><span id="modal_change">0.00</span></strong>.</p>
<p>Confirm this payment?</p>
</div>
<div class="modal-footer">
<button class="btn btn-default approve" id="modal_submit" type="button"><i class="fa fa-check"></i> Yes</button>
<button class="btn btn-default deny cancel" href="#" data-dismiss="modal" aria-hidden="true"><i class="fa fa-times"></i> No</button>
</div>
</div>
</div>
</div>
[% MACRO jsinclude BLOCK %]
[% INCLUDE 'str/members-menu.inc' %]
[% Asset.js("js/members-menu.js") | $raw %]
<script>
$(document).ready(function() {
[% IF payment_id && Koha.Preference('FinePaymentAutoPopup') %]
window.open('/cgi-bin/koha/members/printfeercpt.pl?action=print&accountlines_id=[% payment_id | html %]&change_given=[% change_given | html %]&borrowernumber=[% patron.borrowernumber | html %]', '_blank');
[% END %]
var forms = $('#payindivfine, #payfine');
var change = $('#change')[0];
$('#payindivfine, #payfine').preventDoubleFormSubmit();
$("#paid, #collected").on("change",function() {
moneyFormat( this );
if (change != undefined) {
updateChangeValues();
}
});
if (change != undefined) {
forms.on("submit", function(e) {
if (change.innerHTML > 0.00) {
e.preventDefault();
$("#confirm_change_form").modal("show");
} else {
return true;
}
});
}
$("#confirm_change_form").on("hidden.bs.modal", function(){
// remove class added by preventDoubleFormSubmit if necessary
$("body, form input[type='submit'], form button[type='submit'], form a").removeClass('waiting');
});
$('#modal_submit').click(function() {
forms[0].submit();
});
$( "#payindivfine, #payfine" ).validate({
rules: {
paid: { required: true },
collected: {
required: true
},
[% IF Koha.Preference('UseCashRegisters') %]
cash_register: {
[% IF Koha.Preference('RequireCashRegister') %]
required: true
[% ELSE %]
required: function() {
return $('#payment_type').val() == 'CASH'
}
[% END %]
}
[% END %]
},
invalidHandler: function(event, validator) {
// reset beenSubmitted for prevenDoubleFormSubmit
event.target.beenSubmitted = false;
// remove class added by preventDoubleFormSubmit
$("body, form input[type='submit'], form button[type='submit'], form a").removeClass('waiting');
}
});
});
prevent_default = 1;
$('#woindivfine').on('submit', function(e){
if ( prevent_default ) {
e.preventDefault();
let amount_outstanding = parseFloat( $('#amountoutstanding').attr('value') );
let amount_writeoff = parseFloat( $('#amountwrittenoff').attr('value') );
if ( amount_writeoff > amount_outstanding ) {
alert(_("You are attemping to writeoff more than the value of the fee."));
$('#woindivfine').beenSubmitted = false;
} else {
prevent_default = 0;
$('#woindivfine').preventDoubleFormSubmit();
$('#woindivfine').submit();
}
}
});
function moneyFormat(textObj) {
var newValue = textObj.value;
var decAmount = "";
var dolAmount = "";
var dolFlag = false;
var aChar = "";
for(var i = newValue.length; 0 < i; i--) {
aChar = newValue.substring(i-1, i);
if ("0" <= aChar && aChar <= "9") {
if(dolFlag) {
dolAmount = "" + aChar + dolAmount;
}
else {
decAmount = "" + aChar + decAmount;
}
}
if (aChar == "." || aChar == ",") {
dolFlag = true;
}
}
if (!dolFlag) {
dolAmount = decAmount;
decAmount = "";
}
if (dolAmount == "") {
dolAmount = "0";
}
// Strip leading 0s
if (dolAmount.length > 1) {
while(dolAmount.length > 1 && dolAmount.substring(0,1) == "0") {
dolAmount = dolAmount.substring(1,dolAmount.length);
}
}
if (decAmount.length > 2) {
decAmount = decAmount.substring(0,2);
}
// Pad right side
if (decAmount.length == 1) {
decAmount = decAmount + "0";
}
if (decAmount.length == 0) {
decAmount = decAmount + "00";
}
textObj.value = dolAmount + "." + decAmount;
}
function updateChangeValues() {
var change = $('#change')[0];
change.innerHTML = Math.round(($('#collected')[0].value - $('#paid')[0].value) * 100) / 100;
if (change.innerHTML <= 0) {
var paid = $('#paid')[0];
moneyFormat(paid);
$('#collected').rules( "add", { min: Number(paid.value) });
$( "#payindivfine, #payfine" ).valid();
change.innerHTML = "0.00";
$('input[name="change_given"]').val('0.00');
} else {
change.value = change.innerHTML;
moneyFormat(change);
change.innerHTML = change.value;
$('input[name="change_given"]').val(change.value);
}
$('#modal_change').html(change.innerHTML);
}
</script>
[% END %]
[% INCLUDE 'intranet-bottom.inc' %]