Bug 40445: (follow-up) Move TT values out of kohaTable script blocks
xt/tt_kohaTable_tidy.t forbids mixing Template::Toolkit tags with .kohaTable() calls inside the same <script> block, since such blocks are expected to be pure JS. The cashup modal init calls in pos/register.tt and pos/registers.tt embedded TT-derived values (bankable amount, register float, reconciliation note settings, cashup progress) directly alongside kohaTable() initialisation, tripping the check. This moves those TT expressions into the existing TT-tag-only <script> block that precedes the kohaTable block in each template, exposing them as a plain JS object (cashupModalData) that the kohaTable block then reads. Test plan: 1. Apply the patch. 2. prove xt/tt_kohaTable_tidy.t -- register.tt and registers.tt should no longer be listed among the failures. 3. Load the POS register and registers pages, confirm the trigger and confirm cashup modals still receive the correct bankable amount, register float, and reconciliation note settings. Sponsored-by: OpenFifth <https://openfifth.co.uk/> Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk>
This commit is contained in:
parent
fa6ef97625
commit
c7d13ee7a3
|
|
@ -494,6 +494,13 @@
|
|||
id: "[% register.id | html %]",
|
||||
description: "[% register.description | html %]",
|
||||
};
|
||||
const cashupModalData = {
|
||||
bankableAmount: [% accountlines.total( payment_type => [ 'CASH', 'SIP00' ]) * -1 | html %],
|
||||
registerFloat: [% register.starting_float | html %],
|
||||
hasAuthorisedValues: [% reconciliation_note_avs ? 'true' : 'false' | html %],
|
||||
noteRequired: [% reconciliation_note_required ? 'true' : 'false' | html %],
|
||||
isInProgress: [% cashup_in_progress ? 'true' : 'false' | html %],
|
||||
};
|
||||
</script>
|
||||
<script nonce="[% Koha.CSPNonce | $raw %]">
|
||||
var sales_table = $("#sales").kohaTable({
|
||||
|
|
@ -652,15 +659,15 @@
|
|||
});
|
||||
|
||||
// Initialize cashup modals
|
||||
initTriggerCashupModal('#triggerCashupModal', {
|
||||
bankableAmount: [% accountlines.total( payment_type => [ 'CASH', 'SIP00' ]) * -1 | html %],
|
||||
registerFloat: [% register.starting_float | html %]
|
||||
initTriggerCashupModal("#triggerCashupModal", {
|
||||
bankableAmount: cashupModalData.bankableAmount,
|
||||
registerFloat: cashupModalData.registerFloat,
|
||||
});
|
||||
|
||||
initConfirmCashupModal('#confirmCashupModal', {
|
||||
hasAuthorisedValues: [% reconciliation_note_avs ? 'true' : 'false' | html %],
|
||||
noteRequired: [% reconciliation_note_required ? 'true' : 'false' | html %],
|
||||
isInProgress: [% cashup_in_progress ? 'true' : 'false' | html %]
|
||||
initConfirmCashupModal("#confirmCashupModal", {
|
||||
hasAuthorisedValues: cashupModalData.hasAuthorisedValues,
|
||||
noteRequired: cashupModalData.noteRequired,
|
||||
isInProgress: cashupModalData.isInProgress,
|
||||
});
|
||||
</script>
|
||||
[% END %]
|
||||
|
|
|
|||
|
|
@ -407,32 +407,36 @@
|
|||
$("#income").text('[% ctotal | $Price %] ([% cctotal | $Price %])');
|
||||
$("#outgoing").text('[% dtotal | $Price %] ([% cdtotal | $Price %])');
|
||||
});
|
||||
const cashupModalData = {
|
||||
hasAuthorisedValues: [% reconciliation_note_avs ? 'true' : 'false' | html %],
|
||||
noteRequired: [% reconciliation_note_required ? 'true' : 'false' | html %],
|
||||
};
|
||||
</script>
|
||||
<script nonce="[% Koha.CSPNonce | $raw %]">
|
||||
$(document).ready(function () {
|
||||
var registers_table = $("#registers").kohaTable({
|
||||
columnDefs: [{ targets: [ -1, 0 ], orderable: false }],
|
||||
columnDefs: [{ targets: [-1, 0], orderable: false }],
|
||||
searching: false,
|
||||
paginationType: "full",
|
||||
});
|
||||
|
||||
// Initialize cashup modals
|
||||
initTriggerCashupModal('#triggerCashupModalRegister');
|
||||
initTriggerCashupModal("#triggerCashupModalRegister");
|
||||
|
||||
initConfirmCashupModal('#confirmCashupModal', {
|
||||
hasAuthorisedValues: [% reconciliation_note_avs ? 'true' : 'false' | html %],
|
||||
noteRequired: [% reconciliation_note_required ? 'true' : 'false' | html %]
|
||||
initConfirmCashupModal("#confirmCashupModal", {
|
||||
hasAuthorisedValues: cashupModalData.hasAuthorisedValues,
|
||||
noteRequired: cashupModalData.noteRequired,
|
||||
});
|
||||
|
||||
// Select all registers functionality
|
||||
$("#select_all_registers").on("change", function() {
|
||||
$("#select_all_registers").on("change", function () {
|
||||
var isChecked = $(this).is(":checked");
|
||||
$(".register_checkbox:not(:disabled)").prop("checked", isChecked);
|
||||
updateCashupSelectedButton();
|
||||
});
|
||||
|
||||
// Individual checkbox change handler
|
||||
$(".register_checkbox").on("change", function() {
|
||||
$(".register_checkbox").on("change", function () {
|
||||
updateCashupSelectedButton();
|
||||
|
||||
// Update select all checkbox state
|
||||
|
|
@ -461,13 +465,13 @@
|
|||
}
|
||||
|
||||
// Handle cashup selected modal
|
||||
$("#confirmCashupSelectedModal").on("shown.bs.modal", function(e) {
|
||||
$("#confirmCashupSelectedModal").on("shown.bs.modal", function (e) {
|
||||
var selectedCheckboxes = $(".register_checkbox:checked");
|
||||
var selectedCount = selectedCheckboxes.length;
|
||||
var selectedIds = [];
|
||||
var selectedNames = [];
|
||||
|
||||
selectedCheckboxes.each(function() {
|
||||
selectedCheckboxes.each(function () {
|
||||
var registerRow = $(this).closest("tr");
|
||||
var registerId = $(this).val();
|
||||
var registerName = registerRow.find("td:nth-child(2) a").text(); // Second column (after checkbox)
|
||||
|
|
@ -481,13 +485,13 @@
|
|||
|
||||
// Populate register list
|
||||
var list = $("#selected_registers_list").empty();
|
||||
selectedNames.forEach(function(name) {
|
||||
selectedNames.forEach(function (name) {
|
||||
$("<li>").text(name).appendTo(list);
|
||||
});
|
||||
});
|
||||
|
||||
// Handle start cashup for selected
|
||||
$("#start_selected_btn").on("click", function(e) {
|
||||
$("#start_selected_btn").on("click", function (e) {
|
||||
e.preventDefault();
|
||||
var form = $(this).closest("form");
|
||||
form.find("#selected_operation").val("cud-cashup_start");
|
||||
|
|
@ -495,7 +499,7 @@
|
|||
});
|
||||
|
||||
// Handle quick cashup for selected
|
||||
$("#quick_selected_btn").on("click", function(e) {
|
||||
$("#quick_selected_btn").on("click", function (e) {
|
||||
e.preventDefault();
|
||||
var form = $(this).closest("form");
|
||||
form.find("#selected_operation").val("cud-cashup");
|
||||
|
|
|
|||
Loading…
Reference in New Issue