5 [% USE AuthorisedValues %]
8 [% PROCESS 'accounts.inc' %]
9 [% INCLUDE 'doc-head-open.inc' %]
10 <title>Cashup › Koha</title>
11 [% INCLUDE 'doc-head-close.inc' %]
12 [% Asset.css("lib/jquery/plugins/rowGroup/stylesheets/rowGroup.dataTables.min.css") | $raw %]
15 <body id="register" class="pos">
16 [% WRAPPER 'header.inc' %]
17 [% INCLUDE 'circ-search.inc' %]
20 [% WRAPPER 'sub-header.inc' %]
21 <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
24 <a href="/cgi-bin/koha/mainpage.pl">Home</a>
27 <a href="/cgi-bin/koha/pos/pay.pl">Cash management</a>
30 <a href="#" aria-current="page">
31 Transaction history for [% register.name | html %]
38 <div class="main container-fluid">
40 <div class="col-sm-10 col-sm-push-2">
42 [% IF ( error_registers ) %]
43 <div id="error_message" class="dialog message">
45 You must have at least one cash register associated with the library before you can record payments.
47 [% IF ( CAN_user_parameters_manage_cash_registers ) %]
48 <form action="/cgi-bin/koha/admin/cash_registers.pl" method="get">
49 <input type="hidden" name="op" value="add_form" />
50 <button class="new" type="submit"><i class="fa fa-plus"></i> Create a new cash register</button>
56 [% IF ( error_cashup_permission ) %]
57 <div id="error_message" class="dialog alert">
58 You do not have permission to perform cashup actions.
62 [% IF ( error_refund_permission ) %]
63 <div id="error_message" class="dialog alert">
64 You do not have permission to perform refund actions.
68 [% IF ( CAN_user_cash_management_cashup ) %]
69 <div id="toolbar" class="btn-toolbar">
70 <button id="pos_cashup" type="button" class="btn btn-default" data-toggle="modal" data-target="#confirmCashupModal" ><i class="fa fa-money"></i> Record cashup</button>
74 <h1>Transaction history for [% register.name | html %]</h1>
78 [% IF register.last_cashup %]
79 <li>Last cashup: [% register.last_cashup.timestamp | $KohaDates with_hours => 1 %] (<a data-toggle="modal" data-cashup="[% register.last_cashup.id | html %]" data-register="[% register.description | html %]" href="#cashupSummaryModal" class="button">Summary</a>)</li>
81 <li>Float: [% register.starting_float | $Price %]</li>
82 <li>Total income (cash): [% accountlines.credits_total * -1 | $Price %] ([% accountlines.credits_total(payment_type => [ 'CASH', 'SIP00' ]) * -1 | $Price %])</li>
83 <li>Total outgoing (cash): [% accountlines.debits_total * -1 | $Price %] ([% accountlines.debits_total( payment_type => [ 'CASH', 'SIP00' ]) * -1 | $Price %])</li>
84 <li>Total bankable: [% accountlines.total( payment_type => [ 'CASH', 'SIP00' ]) * -1 | $Price %]</li>
87 [% IF register.last_cashup %]
88 <h2>Transactions since [% register.last_cashup.timestamp | $KohaDates with_hours => 1 %]</h2>
90 <h2>Transactions to date</h2>
92 <table id="sales" class="table_sales">
100 <th class="noExport">Actions</th>
103 [% FOREACH accountline IN accountlines %]
104 [% IF accountline.is_credit %]
105 [% IF accountline.credit_offsets.count == 1 %]
106 <tr class="credit dtrg-group dtrg-start dtrg-level-0">
109 <td>[% accountline.timestamp | $KohaDates with_hours => 1 %] ([% IF accountline.credit_number %][%- accountline.credit_number | html -%][% ELSE %][% accountline.accountlines_id | html %][% END %])</td>
110 <td>[%- PROCESS account_type_description account=accountline -%] ([% AuthorisedValues.GetByCode( 'PAYMENT_TYPE', accountline.payment_type ) | html %])</td>
112 <td>[% accountline.amount * -1 | $Price %]</td>
113 <td><button class="printReceipt btn btn-default btn-xs" data-accountline="[% accountline.accountlines_id | uri %]"><i class="fa fa-print"></i> Print receipt</button></td>
116 [% FOREACH credit IN accountline.credit_offsets %]
117 [% IF credit.debit %]
119 <td>[% accountline.accountlines_id | html %]</td>
120 <td>{ "type": "credit", "identifier": "[%- accountline.credit_number | html -%]", "description": "[%- PROCESS account_type_description account=accountline -%] ([% AuthorisedValues.GetByCode( 'PAYMENT_TYPE', accountline.payment_type ) | html %])", "amount": "[% accountline.amount * -1 | $Price %]", "timestamp": "[% accountline.timestamp | $KohaDates with_hours => 1 %]" }</td>
123 [%- PROCESS account_type_description account=credit.debit -%]
124 [%- IF credit.debit.description -%] ([% credit.debit.description | html %])[%- END -%]
125 [%- IF ( credit.debit.itemnumber ) -%] (<a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% credit.debit.item.biblionumber | uri %]&itemnumber=[% credit.debit.itemnumber | uri %]">[% credit.debit.item.biblio.title | html %]</a>)[%- END -%]
127 <td>[% credit.debit.amount | $Price %]</td>
130 [% IF CAN_user_cash_management_anonymous_refund && !(credit.debit.status == 'REFUNDED') && !(credit.debit.debit_type_code == 'PAYOUT') %]
131 <button type="button" class="btn btn-default btn-xs pos_refund" data-toggle="modal" data-target="#issueRefundModal" data-item="[%- PROCESS account_type_description account=credit.debit -%]" data-accountline="[% credit.debit.accountlines_id | html %]" data-amount="[% credit.debit.amount | $Price %]" data-amountoutstanding="[% credit.debit.amountoutstanding | $Price %]" data-member="[% credit.debit.borrowernumber | html %]"><i class="fa fa-money"></i> Issue refund</button>
132 [% ELSIF CAN_user_updatecharges_refund && !(credit.debit.status == 'REFUNDED') && credit.debit.borrowernumber && !(credit.debit.debit_type_code == 'PAYOUT') %]
133 <button type="button" class="btn btn-default btn-xs" data-toggle="modal" data-target="#issueRefundModal" data-item="[%- PROCESS account_type_description account=credit.debit -%]" data-accountline="[% credit.debit.accountlines_id | html %]" data-amount="[% credit.debit.amount | $Price %]" data-amountoutstanding="[% credit.debit.amountoutstanding | $Price %]" data-member="[% credit.debit.borrowernumber | html %]"><i class="fa fa-money"></i> Issue refund</button>
141 [% FOREACH debit IN accountline.debit_offsets %]
142 [% IF debit.credit %]
144 <td>[% accountline.accountlines_id | html %]</td>
145 <td>{ "type": "debit", "identifier": "[%- accountline.credit_number | html -%]", "description": "[%- PROCESS account_type_description account=accountline -%] ([% AuthorisedValues.GetByCode( 'PAYMENT_TYPE', accountline.payment_type ) | html %])", "amount": "[% accountline.amount * -1 | $Price %]", "timestamp": "[% accountline.timestamp | $KohaDates with_hours => 1 %]" }</td>
148 [%- PROCESS account_type_description account=debit.credit -%]
149 [%- IF debit.credit.description %][% debit.credit.description | html %][%- END -%]
150 [%- IF ( debit.credit.itemnumber ) -%] (<a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% debit.credit.item.biblionumber | uri %]&itemnumber=[% debit.credit.itemnumber | uri %]">[% debit.credit.item.biblio.title | html %]</a>)[%- END -%]
152 <td>[% debit.credit.amount | $Price %]</td>
155 [%- IF debit.credit.credit_type_code == 'REFUND' -%]<a href="/cgi-bin/koha/members/accountline-details.pl?accountlines_id=[% debit.credit.accountlines_id | uri %]" class="btn btn-default btn-xs"><i class="fa fa-list"></i> Details</a>[%- END -%]
165 <td colspan="5">Total income: </td>
166 <td>[% accountlines.total * -1 | $Price %]</td>
173 [% IF register.cashups %]
174 <h2>Older transactions</h2>
175 <form method="GET" action="/cgi-bin/koha/pos/register.pl">
176 <fieldset class="rows">
177 Please select a date range to display transactions for:
180 <label for="trange_f">From: </label>
181 <input type="text" size="10" id="from" class="flatpickr" data-date_to="to" name="trange_f" value="[% trange_f | html %]"/>
182 <label class="inline" for="trange_t">To: </label>
183 <input type="text" size="10" id="to" class="flatpickr" name="trange_t" value="[% trange_t | html %]" />
184 <span class="hint">[% INCLUDE 'date-format.inc' %]</span>
190 <input type="hidden" name="registerid" value="[% register.id | html %]">
191 <input type="submit" class="btn btn-primary" value="Display" />
196 <table id="past_sales" class="past_sales_table">
204 <th class="noExport">Actions</th>
207 [% FOREACH accountline IN past_accountlines %]
208 [% IF accountline.is_credit %]
209 [% FOREACH credit IN accountline.credit_offsets %]
210 [% IF credit.debit %]
212 <td>[% accountline.accountlines_id | html %]</td>
213 <td>{ "type": "credit", "identifier": "[%- accountline.credit_number | html -%]", "description": "[%- PROCESS account_type_description account=accountline -%] ([% AuthorisedValues.GetByCode( 'PAYMENT_TYPE', accountline.payment_type ) | html %])", "amount": "[% accountline.amount * -1 | $Price %]", "timestamp": "[% accountline.timestamp | $KohaDates with_hours => 1 %]" }</td>
216 [%- PROCESS account_type_description account=credit.debit -%]
217 [%- IF credit.debit.description -%] ([% credit.debit.description | html %])[%- END -%]
218 [%- IF ( credit.debit.itemnumber ) -%] (<a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% credit.debit.item.biblionumber | uri %]&itemnumber=[% credit.debit.itemnumber | uri %]">[% credit.debit.item.biblio.title | html %]</a>)[%- END -%]
220 <td>[% credit.debit.amount | $Price %]</td>
223 [% IF CAN_user_cash_management_anonymous_refund && !(credit.debit.status == 'REFUNDED') && !(credit.debit.debit_type_code == 'PAYOUT') %]
224 <button type="button" class="btn btn-default btn-xs pos_refund" data-toggle="modal" data-target="#issueRefundModal" data-item="[%- PROCESS account_type_description account=credit.debit -%]" data-accountline="[% credit.debit.accountlines_id | html %]" data-amount="[% credit.debit.amount | $Price %]" data-amountoutstanding="[% credit.debit.amountoutstanding | $Price %]" data-member="[% credit.debit.borrowernumber | html %]"><i class="fa fa-money"></i> Issue refund</button>
225 [% ELSIF CAN_user_updatecharges_refund && !(credit.debit.status == 'REFUNDED') && credit.debit.borrowernumber && !(credit.debit.debit_type_code == 'PAYOUT') %]
226 <button type="button" class="btn btn-default btn-xs" data-toggle="modal" data-target="#issueRefundModal" data-item="[%- PROCESS account_type_description account=credit.debit -%]" data-accountline="[% credit.debit.accountlines_id | html %]" data-amount="[% credit.debit.amount | $Price %]" data-amountoutstanding="[% credit.debit.amountoutstanding | $Price %]" data-member="[% credit.debit.borrowernumber | html %]"><i class="fa fa-money"></i> Issue refund</button>
233 [% FOREACH debit IN accountline.debit_offsets %]
234 [% IF debit.credit %]
236 <td>[% accountline.accountlines_id | html %]</td>
237 <td>{ "type": "debit", "identifier": "[%- accountline.credit_number | html -%]", "description": "[%- PROCESS account_type_description account=accountline -%] ([% AuthorisedValues.GetByCode( 'PAYMENT_TYPE', accountline.payment_type ) | html %])", "amount": "[% accountline.amount * -1 | $Price %]", "timestamp": "[% accountline.timestamp | $KohaDates with_hours => 1 %]" }</td>
240 [%- PROCESS account_type_description account=debit.credit -%]
241 [%- IF debit.credit.description %][% debit.credit.description | html %][%- END -%]
242 [%- IF ( debit.credit.itemnumber ) -%] (<a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% debit.credit.item.biblionumber | uri %]&itemnumber=[% debit.credit.itemnumber | uri %]">[% debit.credit.item.biblio.title | html %]</a>)[%- END -%]
244 <td>[% debit.credit.amount | $Price %]</td>
247 [%- IF debit.credit.credit_type_code == 'REFUND' -%]<a href="/cgi-bin/koha/members/accountline-details.pl?accountlines_id=[% debit.credit.accountlines_id | uri %]" class="btn btn-default btn-xs"><i class="fa fa-list"></i> Details</a>[%- END -%]
257 <td colspan="5">Total income: </td>
258 <td>[% past_accountlines.total * -1 | $Price %]</td>
266 <h2>Cashup history</h2>
267 <table id="table_cashups">
273 <th data-class-name="actions">Actions</th>
280 <div class="col-sm-2 col-sm-pull-10">
282 [% INCLUDE 'pos-menu.inc' %]
287 <!-- Confirm cashup modal -->
288 <div class="modal" id="confirmCashupModal" tabindex="-1" role="dialog" aria-labelledby="confirmCashupLabel">
289 <div class="modal-dialog" role="document">
290 <div class="modal-content">
291 <div class="modal-header">
292 <button type="button" class="closebtn" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
293 <h4 class="modal-title" id="confirmCashupLabel">Confirm cashup of <em>[% register.description | html %]</em></h4>
295 <div class="modal-body">
296 Please confirm that you have removed [% accountlines.total( payment_type => [ 'CASH', 'SIP00' ]) * -1 | $Price %] from the cash register and left a float of [% register.starting_float | $Price %].
297 </div> <!-- /.modal-body -->
298 <div class="modal-footer">
299 <a href="/cgi-bin/koha/pos/register.pl?op=cashup" class="btn btn-default" id="pos_cashup_confirm">Confirm</a>
300 <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
301 </div> <!-- /.modal-footer -->
302 </div> <!-- /.modal-content -->
303 </div> <!-- /.modal-dialog -->
304 </div> <!-- /#confirmCashupModal -->
306 <!-- Issue refund modal -->
307 <div class="modal" id="issueRefundModal" tabindex="-1" role="dialog" aria-labelledby="issueRefundLabel">
308 <form id="refund_form" method="post" enctype="multipart/form-data" class="validated">
309 <input type="hidden" name="accountline" value="" id="refundline">
310 <div class="modal-dialog" role="document">
311 <div class="modal-content">
312 <div class="modal-header">
313 <button type="button" class="closebtn" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
314 <h4 class="modal-title" id="issueRefundLabel">Issue refund from <em>[% register.description | html %]</em></h4>
316 <div class="modal-body">
317 <fieldset class="rows">
320 <span id="item" class="label">Item: </span><span></span>
323 <span id="paid" class="label">Amount paid: </span><span></span>
326 <label class="required" for="amount">Returned to patron: </label>
327 <input type="text" inputmode="decimal" pattern="^\d+(\.\d{2})?$" id="returned" name="amount" required="required">
328 <span class="required">Required</span>
330 [% INCLUDE 'transaction_types.inc' type="refund" %]
332 </fieldset> <!-- /.rows -->
333 </div> <!-- /.modal-body -->
334 <div class="modal-footer">
335 <input type="hidden" name="registerid" value="[% register.id | html %]">
336 <input type="hidden" name="op" value="refund">
337 <button type="submit" class="btn btn-default" id="pos_refund_confirm">Confirm</button>
338 <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
339 </div> <!-- /.modal-footer -->
340 </div> <!-- /.modal-content -->
341 </div> <!-- /.modal-dialog -->
342 </form> <!-- /#refund_form -->
343 </div> <!-- /#issueRefundModal -->
345 [% INCLUDE 'modals/cashup_summary.inc' %]
347 [% MACRO jsinclude BLOCK %]
348 [% INCLUDE 'datatables.inc' %]
349 [% Asset.js("lib/jquery/plugins/rowGroup/dataTables.rowGroup.min.js") | $raw %]
350 [% INCLUDE 'format_price.inc' %]
351 [% INCLUDE 'js-date-format.inc' %]
352 [% Asset.js("js/cashup_modal.js") | $raw %]
353 [% INCLUDE 'calendar.inc' %]
355 var sales_table = $("#sales").dataTable($.extend(true, {}, dataTablesDefaults, {
356 orderFixed: [ 0, 'asc'],
363 startRender: function ( rows, group ) {
365 var details = JSON.parse(rows.data().pluck(1).pop());
366 var identifier = details.identifier || group;
367 return $('<tr class="'+details.type+'"/>')
368 .append( '<td>'+details.timestamp+' ('+identifier+')</td>' )
369 .append( '<td colspan="2">'+details.description+'</td>' )
370 .append( '<td>'+details.amount+'</td>' )
371 .append( '<td><button class="printReceipt btn btn-default btn-xs" data-accountline="'+group+'"><i class="fa fa-print"></i> ' + _("Print receipt") + '</button></td>');
376 initComplete: function() {
381 var past_sales_table = $("#past_sales").dataTable($.extend(true, {}, dataTablesDefaults, {
382 orderFixed: [ 0, 'asc'],
389 startRender: function ( rows, group ) {
390 var details = JSON.parse(rows.data().pluck(1).pop());
391 var identifier = details.identifier || group;
392 return $('<tr class="'+details.type+'"/>')
393 .append( '<td>'+details.timestamp+' ('+identifier+')</td>' )
394 .append( '<td colspan="2">'+details.description+'</td>' )
395 .append( '<td>'+details.amount+'</td>' )
396 .append( '<td><button class="printReceipt btn btn-default btn-xs" data-accountline="'+group+'"><i class="fa fa-print"></i> Print receipt</button></td>');
402 $("#issueRefundModal").on("shown.bs.modal", function(e){
403 var button = $(e.relatedTarget);
404 var item = button.data('item');
405 $("#item + span").replaceWith(item);
406 var accountline = button.data('accountline');
407 $('#refundline').val(accountline);
408 var amount = button.data('amount');
409 var amountoutstanding = button.data('amountoutstanding') || 0;
410 var paid = amount - amountoutstanding;
411 $("#paid + span").replaceWith(paid);
412 $("#returned").attr({ "value": paid, "max": paid });
413 var member = button.data('member');
414 if ( member === '' ) {
415 $("#refund_type option[value='AC']").remove();
416 } else if ( $("#refund_type option[value='AC']").length == 0 ) {
417 $("#refund_type").prepend('<option value="AC" selected="selected">Account credit</option>');
419 $("#returned, #refund_type").focus();
422 $("body").on('click', ".printReceipt", function() {
423 var accountlines_id = $(this).data('accountline');
424 var win = window.open('/cgi-bin/koha/pos/printreceipt.pl?action=print&accountlines_id=' + accountlines_id, '_blank');
428 var cashups_table_url = "/api/v1/cash_registers/[% register.id | html %]/cashups?";
429 var cashups_table = $("#table_cashups").kohaTable({
431 "url": cashups_table_url
433 "header_filter": true,
437 "order": [[ 0, "desc" ]],
443 "render": function(data, type, row, meta) {
444 return $datetime(row.timestamp);
448 "data": "manager.firstname:manager.surname",
451 "render": function(data, type, row, meta) {
453 if ( row.manager.firstname == null ) {
454 fullname = row.manager.surname;
457 fullname = row.manager.firstname + " " + row.manager.surname;
459 return escape_str(fullname);
466 "render": function(data, type, row, meta) {
467 var amt = row.amount * -1;
468 return escape_price(amt);
472 "data": function( row, type, val, meta ) {
473 var result = '<a class="btn btn-default btn-xs" role="button" data-toggle="modal" data-cashup="'+encodeURIComponent(row.cashup_id)+'" data-register="[% register.description | html %]" href="#cashupSummaryModal"><i class="fa fa-pencil" aria-hidden="true"></i> '+_("Summary")+'</a>\n';
484 [% INCLUDE 'intranet-bottom.inc' %]