Martin Renvoize
7878aa0012
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> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
52 lines
1.9 KiB
JavaScript
52 lines
1.9 KiB
JavaScript
$('#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();
|
|
});
|