|
Lines 3-9
$(document).ready(function () {
Link Here
|
| 3 |
var button = $(e.relatedTarget); |
3 |
var button = $(e.relatedTarget); |
| 4 |
var cashup = button.data("cashup"); |
4 |
var cashup = button.data("cashup"); |
| 5 |
var description = button.data("register"); |
5 |
var description = button.data("register"); |
|
|
6 |
var inProgress = button.data("in-progress") || false; |
| 6 |
var summary_modal = $(this); |
7 |
var summary_modal = $(this); |
|
|
8 |
|
| 9 |
// Update title based on whether this is a preview |
| 10 |
if (inProgress) { |
| 11 |
summary_modal |
| 12 |
.find("#cashupSummaryLabel") |
| 13 |
.text(__("Cashup summary preview")); |
| 14 |
} else { |
| 15 |
summary_modal |
| 16 |
.find("#cashupSummaryLabel") |
| 17 |
.text(__("Cashup summary")); |
| 18 |
} |
| 19 |
|
| 7 |
summary_modal.find("#register_description").text(description); |
20 |
summary_modal.find("#register_description").text(description); |
| 8 |
$.ajax({ |
21 |
$.ajax({ |
| 9 |
url: "/api/v1/cashups/" + cashup, |
22 |
url: "/api/v1/cashups/" + cashup, |
|
Lines 17-22
$(document).ready(function () {
Link Here
|
| 17 |
let to_date = $datetime(data.summary.to_date); |
30 |
let to_date = $datetime(data.summary.to_date); |
| 18 |
summary_modal.find("#to_date").text(to_date); |
31 |
summary_modal.find("#to_date").text(to_date); |
| 19 |
|
32 |
|
|
|
33 |
// Add preview notice if this is an in-progress cashup |
| 34 |
if (inProgress) { |
| 35 |
var previewNotice = summary_modal.find(".preview-notice"); |
| 36 |
if (previewNotice.length === 0) { |
| 37 |
summary_modal |
| 38 |
.find(".modal-body > ul") |
| 39 |
.before( |
| 40 |
'<div class="alert alert-info preview-notice">' + |
| 41 |
'<i class="fa-solid fa-info-circle"></i> ' + |
| 42 |
"<strong>" + |
| 43 |
__("Preview:") + |
| 44 |
"</strong> " + |
| 45 |
__( |
| 46 |
"This summary shows the expected cashup amounts. A reconciliation record may be added when you complete the cashup." |
| 47 |
) + |
| 48 |
"</div>" |
| 49 |
); |
| 50 |
} |
| 51 |
} else { |
| 52 |
summary_modal.find(".preview-notice").remove(); |
| 53 |
} |
| 54 |
|
| 20 |
// Check for reconciliation (surplus or deficit) from dedicated fields |
55 |
// Check for reconciliation (surplus or deficit) from dedicated fields |
| 21 |
var surplus = data.summary.surplus_total; |
56 |
var surplus = data.summary.surplus_total; |
| 22 |
var deficit = data.summary.deficit_total; |
57 |
var deficit = data.summary.deficit_total; |
|
Lines 69-77
$(document).ready(function () {
Link Here
|
| 69 |
var tfoot = summary_modal.find("tfoot"); |
104 |
var tfoot = summary_modal.find("tfoot"); |
| 70 |
tfoot.empty(); |
105 |
tfoot.empty(); |
| 71 |
|
106 |
|
|
|
107 |
// Determine if this is a negative cashup (float deficit scenario) |
| 108 |
var isNegativeCashup = data.summary.total < 0; |
| 109 |
|
| 110 |
// Add informational notice for negative cashups |
| 111 |
if (isNegativeCashup) { |
| 112 |
var noticeText = __( |
| 113 |
"This cashup shows a negative amount because refunds exceeded collections during this session. " + |
| 114 |
"The register float was topped up to restore the expected balance." |
| 115 |
); |
| 116 |
tbody.prepend( |
| 117 |
"<tr class='reconciliation-info'><td colspan='2'>" + |
| 118 |
"<i class='fa-solid fa-info-circle'></i> " + |
| 119 |
"<strong>" + |
| 120 |
__("Float deficit:") + |
| 121 |
"</strong> " + |
| 122 |
noticeText + |
| 123 |
"</td></tr>" |
| 124 |
); |
| 125 |
} |
| 126 |
|
| 72 |
// 1. Total (sum of all transactions) |
127 |
// 1. Total (sum of all transactions) |
|
|
128 |
var totalLabel = isNegativeCashup |
| 129 |
? __("Total float deficit") |
| 130 |
: __("Total"); |
| 131 |
|
| 73 |
tfoot.append( |
132 |
tfoot.append( |
| 74 |
"<tr class='total-row'><td><strong>Total</strong></td><td><strong>" + |
133 |
"<tr class='total-row'><td><strong>" + |
|
|
134 |
totalLabel + |
| 135 |
"</strong></td><td><strong>" + |
| 75 |
data.summary.total.format_price() + |
136 |
data.summary.total.format_price() + |
| 76 |
"</strong></td></tr>" |
137 |
"</strong></td></tr>" |
| 77 |
); |
138 |
); |
|
Lines 93-100
$(document).ready(function () {
Link Here
|
| 93 |
} |
154 |
} |
| 94 |
} |
155 |
} |
| 95 |
if (cashCollected !== null) { |
156 |
if (cashCollected !== null) { |
|
|
157 |
var cashLabel = |
| 158 |
cashCollected < 0 |
| 159 |
? __("Cash added to register") |
| 160 |
: __("Cash collected"); |
| 161 |
|
| 96 |
tfoot.append( |
162 |
tfoot.append( |
| 97 |
"<tr><td><strong>Cash collected</strong></td><td><strong>" + |
163 |
"<tr><td><strong>" + |
|
|
164 |
cashLabel + |
| 165 |
"</strong></td><td><strong>" + |
| 98 |
cashCollected.format_price() + |
166 |
cashCollected.format_price() + |
| 99 |
"</strong></td></tr>" |
167 |
"</strong></td></tr>" |
| 100 |
); |
168 |
); |
|
Lines 107-116
$(document).ready(function () {
Link Here
|
| 107 |
type.payment_type !== "Cash" && |
175 |
type.payment_type !== "Cash" && |
| 108 |
type.payment_type !== "CASH" |
176 |
type.payment_type !== "CASH" |
| 109 |
) { |
177 |
) { |
|
|
178 |
var paymentTypeLabel = |
| 179 |
type.total < 0 |
| 180 |
? __x("{payment_type} to add", { |
| 181 |
payment_type: escape_str( |
| 182 |
type.payment_type |
| 183 |
), |
| 184 |
}) |
| 185 |
: __x("{payment_type} collected", { |
| 186 |
payment_type: escape_str( |
| 187 |
type.payment_type |
| 188 |
), |
| 189 |
}); |
| 190 |
|
| 110 |
tfoot.append( |
191 |
tfoot.append( |
| 111 |
"<tr><td><strong>" + |
192 |
"<tr><td><strong>" + |
| 112 |
escape_str(type.payment_type) + |
193 |
paymentTypeLabel + |
| 113 |
" collected" + |
|
|
| 114 |
"</strong></td><td><strong>" + |
194 |
"</strong></td><td><strong>" + |
| 115 |
type.total.format_price() + |
195 |
type.total.format_price() + |
| 116 |
"</strong></td></tr>" |
196 |
"</strong></td></tr>" |
|
Lines 133-146
$(document).ready(function () {
Link Here
|
| 133 |
if (surplus) { |
213 |
if (surplus) { |
| 134 |
reconciliationClass = |
214 |
reconciliationClass = |
| 135 |
"reconciliation-result text-warning"; |
215 |
"reconciliation-result text-warning"; |
| 136 |
reconciliationLabel = "Cashup surplus"; |
216 |
reconciliationLabel = __("Cashup surplus"); |
| 137 |
reconciliationAmount = |
217 |
reconciliationAmount = |
| 138 |
"+" + Math.abs(surplus).format_price(); |
218 |
"+" + Math.abs(surplus).format_price(); |
| 139 |
reconciliationNote = data.summary.surplus_note; |
219 |
reconciliationNote = data.summary.surplus_note; |
| 140 |
} else if (deficit) { |
220 |
} else if (deficit) { |
| 141 |
reconciliationClass = |
221 |
reconciliationClass = |
| 142 |
"reconciliation-result text-danger"; |
222 |
"reconciliation-result text-danger"; |
| 143 |
reconciliationLabel = "Cashup deficit"; |
223 |
reconciliationLabel = __("Cashup deficit"); |
| 144 |
reconciliationAmount = |
224 |
reconciliationAmount = |
| 145 |
"-" + Math.abs(deficit).format_price(); |
225 |
"-" + Math.abs(deficit).format_price(); |
| 146 |
reconciliationNote = data.summary.deficit_note; |
226 |
reconciliationNote = data.summary.deficit_note; |
|
Lines 158-170
$(document).ready(function () {
Link Here
|
| 158 |
|
238 |
|
| 159 |
// Add note if present |
239 |
// Add note if present |
| 160 |
if (reconciliationNote) { |
240 |
if (reconciliationNote) { |
|
|
241 |
// Check if note is an authorized value code and use description if available |
| 242 |
var noteDisplay = reconciliationNote; |
| 243 |
if ( |
| 244 |
typeof reconciliation_note_avs !== "undefined" && |
| 245 |
reconciliation_note_avs[reconciliationNote] |
| 246 |
) { |
| 247 |
noteDisplay = |
| 248 |
reconciliation_note_avs[reconciliationNote]; |
| 249 |
} |
| 250 |
|
| 161 |
tfoot.append( |
251 |
tfoot.append( |
| 162 |
"<tr class='" + |
252 |
"<tr class='" + |
| 163 |
reconciliationClass + |
253 |
reconciliationClass + |
| 164 |
"'><td colspan='2'><em>" + |
254 |
"'><td colspan='2'><em>" + |
| 165 |
__("Note:") + |
255 |
__("Note:") + |
| 166 |
" " + |
256 |
" " + |
| 167 |
escape_str(reconciliationNote) + |
257 |
escape_str(noteDisplay) + |
| 168 |
"</em></td></tr>" |
258 |
"</em></td></tr>" |
| 169 |
); |
259 |
); |
| 170 |
} |
260 |
} |
| 171 |
- |
|
|