$(document).ready(function() {
$('#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) {
let from_date = $datetime(data.summary.from_date);
summary_modal.find('#from_date').text(from_date);
let to_date = $datetime(data.summary.to_date);
summary_modal.find('#to_date').text(to_date);
var tbody = summary_modal.find('tbody')
tbody.empty();
for (out of data.summary.payout_grouped) {
if (out.credit_type_code == 'REFUND') {
tbody.append('
' + __x('{credit_type_description} against {debit_type_description}', { 'credit_type_description': escape_str(out.credit_type.description), 'debit_type_description': escape_str(out.related_debit.debit_type.description) }) + ' | - ' + out.total.format_price() + ' |
');
} else {
tbody.append('' + escape_str(out.credit_type.description) + ' | - ' + out.total.format_price() + ' |
');
}
}
for (income of data.summary.income_grouped) {
tbody.append('' + escape_str(income.debit_type.description) + ' | ' + income.total.format_price() + ' |
');
}
var tfoot = summary_modal.find('tfoot');
tfoot.empty();
tfoot.append('Total | ' + data.summary.total.format_price() + ' |
');
for (type of data.summary.total_grouped) {
if (type.total !== 0) {
tfoot.append('' + escape_str(type.payment_type) + ' | ' + type.total.format_price() + ' |
');
}
}
}
});
});
});