Fix item counts, PR/QT conversions, validation and department loss

This commit is contained in:
Thanakorn
2026-09-15 16:11:47 +07:00
parent 78d69d81df
commit c915379e2e
23 changed files with 100 additions and 45 deletions
+2 -2
View File
@@ -341,7 +341,7 @@
</td>
<td>
<input type="number" class="form-control form-control-sm item_tax_rate"
value="${parseFloat(item.tax_rate || 0).toFixed(2)}" min="0" max="100" step="0.01" oninput="recalc_totals()">
value="${line_tax_rate(item).toFixed(2)}" min="0" max="100" step="0.01" oninput="recalc_totals()">
<input type="hidden" class="item_tax_amount" value="${item.tax_amount || 0}">
</td>
<td class="item_total text-end">${format_number((item.quantity || 1) * (item.unit_price || item.price || 0), 2)}</td>
@@ -712,7 +712,7 @@
// ── Boot ─────────────────────────────────────────────────────────────────
$(async function() {
try {
load_departments('department_id');
await Promise.resolve(load_departments('department_id')).catch(function() {});
await retrieve_warehouses();
if (order_id) {
+1 -2
View File
@@ -241,8 +241,7 @@
var body = '';
$.each(page_data, function(i, o) {
var items = JSON.parse(o.items || '[]');
var item_count = items.length;
var item_count = parseInt(o.item_count) || 0;
var can_edit = parseInt(o.status) === 0;
var can_cancel = parseInt(o.status) >= 0 && parseInt(o.status) <= 1;
+2 -2
View File
@@ -158,7 +158,7 @@
var body = '';
$.each(page_data, function(i, r) {
var items = JSON.parse(r.items || '[]');
var item_count = parseInt(r.item_count) || 0;
var can_cancel = parseInt(r.status) >= 0 && parseInt(r.status) <= 1;
body += `<tr>
@@ -167,7 +167,7 @@
<td class="py-3">${r.contact_name || '<span class="text-muted">—</span>'}</td>
<td class="py-3">${get_dept_label(r.department_id)}</td>
<td class="py-3">${format_date(r.return_date)}</td>
<td class="py-3">${items.length} item${items.length !== 1 ? 's' : ''}</td>
<td class="py-3">${item_count} item${item_count !== 1 ? 's' : ''}</td>
<td class="py-3 fw-semibold">${format_number(r.refund_amount, 2)}</td>
<td class="py-3">${return_status_badge(r.status)}</td>
<td class="py-3">${receipt_status_badge(r.receipt_status)}</td>