Bugzilla – Attachment 116175 Details for
Bug 26274
Expose cash register cashup summaries via an API route.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 26274: Update register.tt to use the API
Bug-26274-Update-registertt-to-use-the-API.patch (text/plain), 10.09 KB, created by
Martin Renvoize (ashimema)
on 2021-02-01 16:44:21 UTC
(
hide
)
Description:
Bug 26274: Update register.tt to use the API
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2021-02-01 16:44:21 UTC
Size:
10.09 KB
patch
obsolete
>From e47c77f05104cad3687c0ab2710b2d0ff3a9cd29 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Thu, 28 Jan 2021 17:20:29 +0000 >Subject: [PATCH] Bug 26274: Update register.tt to use the API > >This patch updates the existing register details page to utilise the new >api routes to gather the summary details on demand. > >Test plan >1/ Enable cash registers >2/ Add some transactions >3/ Perform a cashup >4/ Click 'Summary' next to the last cashup date >5/ Note the modal appears as it did prior to the patch being applied. >6/ Check the print option still works >7/ Signoff > >Signed-off-by: David Nind <david@davidnind.com> >--- > .../en/includes/modals/cashup_summary.inc | 33 ++++++++++ > .../prog/en/modules/pos/register.tt | 65 ++----------------- > .../intranet-tmpl/prog/js/cashup_modal.js | 52 +++++++++++++++ > 3 files changed, 89 insertions(+), 61 deletions(-) > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/modals/cashup_summary.inc > create mode 100644 koha-tmpl/intranet-tmpl/prog/js/cashup_modal.js > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/modals/cashup_summary.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/modals/cashup_summary.inc >new file mode 100644 >index 0000000000..7e9e246918 >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/modals/cashup_summary.inc >@@ -0,0 +1,33 @@ >+<!-- Cashup summary modal --> >+<div class="modal printable" id="cashupSummaryModal" tabindex="-1" role="dialog" aria-labelledby="cashupSummaryLabel"> >+ <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="cashupSummaryLabel">Cashup summary</h4> >+ </div> >+ <div class="modal-body"> >+ <ul> >+ <li>Cash register: <span id="register_description"></span></li> >+ <li>Period: <span id="from_date"></span> to <span id="to_date"></span></li> >+ </ul> >+ <table> >+ <thead> >+ <tr> >+ <th>Type</th> >+ <th>Total</th> >+ </tr> >+ </thead> >+ <tbody> >+ </tbody> >+ <tfoot> >+ </tfoot> >+ </table> >+ </div> <!-- /.modal-body --> >+ <div class="modal-footer"> >+ <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> >+ <button type="button" class="printModal btn btn-primary"><i class="fa fa-print"></i> Print</button> >+ </div> <!-- /.modal-footer --> >+ </div> <!-- /.modal-content --> >+ </div> <!-- /.modal-dialog --> >+</div> <!-- /#cashupSummaryModal --> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/pos/register.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/pos/register.tt >index 55c23fcdde..caaea05ed3 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/pos/register.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/pos/register.tt >@@ -59,8 +59,7 @@ > <h2>Summary</h2> > <ul> > [% IF register.last_cashup %] >- <li>Last cashup: [% register.last_cashup.timestamp | $KohaDates with_hours => 1 %] (<a data-toggle="modal" href="#cashupSummaryModal" class="button">Summary</a>)</li> >- >+ <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> > [% END %] > <li>Float: [% register.starting_float | $Price %]</li> > <li>Total income (cash): [% accountlines.credits_total * -1 | $Price %] ([% accountlines.credits_total(payment_type => 'CASH') * -1 | $Price %])</li> >@@ -304,68 +303,12 @@ > </form> <!-- /#refund_form --> > </div> <!-- /#issueRefundModal --> > >- <!-- Cashup summary modal --> >- [% IF register.last_cashup %] >- <div class="modal printable" id="cashupSummaryModal" tabindex="-1" role="dialog" aria-labelledby="cashupSummaryLabel"> >- <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="cashupSummaryLabel">Cashup summary</h4> >- </div> >- <div class="modal-body"> >- <ul> >- <li>Cash register: [% register.description | html %]</li> >- <li>Period: [% register.last_cashup.cashup_summary.from_date | $KohaDates with_hours => 1 %] to [% register.last_cashup.cashup_summary.to_date | $KohaDates with_hours => 1 %]</li> >- </ul> >- <table> >- <thead> >- <tr> >- <th>Type</th> >- <th>Total</th> >- </tr> >- </thead> >- <tbody> >- [%- FOREACH out IN register.last_cashup.cashup_summary.outgoing -%] >- <tr> >- <td>[%- PROCESS account_type_description account=out -%]</td> >- <td>[% out.total * -1 | $Price %]</td> >- </tr> >- [%- END -%] >- [%- FOREACH in IN register.last_cashup.cashup_summary.income -%] >- <tr> >- <td>[%- PROCESS account_type_description account=in -%]</td> >- <td>[% in.total * -1 | $Price %]</td> >- </tr> >- [%- END -%] >- </tbody> >- <tfoot> >- <tr> >- <td>Total</td> >- <td>[% ( register.last_cashup.cashup_summary.outgoing_transactions.total + register.last_cashup.cashup_summary.income_transactions.total) * -1 | $Price %]</td> >- </tr> >- [% FOREACH pt IN payment_types %] >- <tr> >- <td>[% pt.lib | html %]</td> >- <td>[% ( register.last_cashup.cashup_summary.outgoing_transactions.total( payment_type => pt.authorised_value ) + register.last_cashup.cashup_summary.income_transactions.total( payment_type => pt.authorised_value )) * -1 | $Price %]</td> >- </tr> >- [% END %] >- >- </tfoot> >- </table> >- </div> <!-- /.modal-body --> >- <div class="modal-footer"> >- <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> >- <button type="button" class="printModal btn btn-primary"><i class="fa fa-print"></i> Print</button> >- </div> <!-- /.modal-footer --> >- </div> <!-- /.modal-content --> >- </div> <!-- /.modal-dialog --> >- </div> <!-- /#cashupSummaryModal --> >- [% END %] >+ [% INCLUDE 'modals/cashup_summary.inc' %] > >-[% MACRO jsinclude BLOCK %] >+ [% MACRO jsinclude BLOCK %] > [% INCLUDE 'datatables.inc' %] > [% Asset.js("lib/jquery/plugins/rowGroup/dataTables.rowGroup.min.js") | $raw %] >+ [% Asset.js("js/cashup_modal.js") | $raw %] > [% INCLUDE 'calendar.inc' %] > <script> > var sales_table = $("#sales").dataTable($.extend(true, {}, dataTablesDefaults, { >diff --git a/koha-tmpl/intranet-tmpl/prog/js/cashup_modal.js b/koha-tmpl/intranet-tmpl/prog/js/cashup_modal.js >new file mode 100644 >index 0000000000..01e8849e23 >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/js/cashup_modal.js >@@ -0,0 +1,52 @@ >+$('#cashupSummaryModal').on('show.bs.modal', function(e) { >+ var button = $(e.relatedTarget); >+ var cashup = button.data('cashup'); >+ var description = button.data('register'); >+ var summary_modal = $(this); >+ summary_modal.find('#register_description').text(description); >+ $.ajax({ >+ url: '/api/v1/cashups/' + cashup, >+ headers: { >+ 'x-koha-embed': 'summary' >+ }, >+ async: false, >+ success: function(data) { >+ summary_modal.find('#from_date').text(data.summary.from_date); >+ summary_modal.find('#to_date').text(data.summary.to_date); >+ var tbody = summary_modal.find('tbody') >+ tbody.empty(); >+ for (out of data.summary.payout_grouped) { >+ tbody.append('<tr><td>' + out.credit_type.description + '</td><td>- ' + out.total + '</td></tr>'); >+ } >+ >+ for (income of data.summary.income_grouped) { >+ tbody.append('<tr><td>' + income.debit_type.description + '</td><td>' + income.total + '</td></tr>'); >+ } >+ >+ var tfoot = summary_modal.find('tfoot'); >+ tfoot.empty(); >+ tfoot.append('<tr><td>Total</td><td>' + data.summary.total + '</td></tr>'); >+ for (type of data.summary.total_grouped) { >+ if (type.total !== 0) { >+ tfoot.append('<tr><td>' + type.payment_type + '</td><td>' + type.total + '</td></tr>'); >+ } >+ } >+ } >+ }); >+}); >+ >+$('.modal.printable').on('shown.bs.modal', function() { >+ $('.modal-dialog', this).addClass('focused'); >+ $('body').addClass('modalprinter'); >+ >+ if ($(this).hasClass('autoprint')) { >+ window.print(); >+ } >+}).on('hidden.bs.modal', function() { >+ $('.modal-dialog', this).removeClass('focused'); >+ $('body').removeClass('modalprinter'); >+}); >+ >+$('.printModal').click(function() { >+ window.print(); >+}); >-- >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 26274
:
115803
|
115804
|
115991
|
115992
|
116136
|
116137
|
116142
|
116143
|
116145
|
116146
|
116174
|
116175
|
116324
|
116325
|
116326
|
116327
|
116939