Fix item counts, PR/QT conversions, validation and department loss
This commit is contained in:
@@ -88,6 +88,7 @@ foreach ($convert_items as $ci) {
|
||||
'unit_price' => $unit_price,
|
||||
'total_price' => $total_price,
|
||||
'tax_amount' => $tax_amount,
|
||||
'tax_rate' => (float)($qi['tax_rate'] ?? 0),
|
||||
'stock_out_id' => 0,
|
||||
];
|
||||
$validated[] = ['item_id' => $item_id, 'quantity' => $qty];
|
||||
|
||||
@@ -235,7 +235,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 align-middle">
|
||||
|
||||
@@ -515,7 +515,7 @@
|
||||
// ── Boot ──────────────────────────────────────────────────────────────────
|
||||
$(async function() {
|
||||
try {
|
||||
load_departments('department_id');
|
||||
await Promise.resolve(load_departments('department_id')).catch(function() {});
|
||||
if (quotation_id) {
|
||||
await retrieve_quotation();
|
||||
} else {
|
||||
|
||||
@@ -165,12 +165,6 @@
|
||||
return map[String(status)] || '<span class="badge bg-light text-dark">—</span>';
|
||||
}
|
||||
|
||||
function order_items_count(items) {
|
||||
if (Array.isArray(items)) return items.length;
|
||||
try { return JSON.parse(items || '[]').length; }
|
||||
catch(e) { return 0; }
|
||||
}
|
||||
|
||||
function retrieve_orders() {
|
||||
return ajax_request({
|
||||
url: '<?php echo $server_url?>order/api/engine/retrieve_order.php',
|
||||
@@ -226,7 +220,7 @@
|
||||
}
|
||||
|
||||
$.each(rows, function(i, o) {
|
||||
var item_count = order_items_count(o.items);
|
||||
var item_count = parseInt(o.item_count) || 0;
|
||||
var source = String(o.source || '');
|
||||
var source_display = source === 'quotation' && parseInt(o.source_id) > 0
|
||||
? `<a href="<?php echo $server_url?>revenue/manage_quotation.php?id=${o.source_id}">Quotation #${o.source_id}</a>`
|
||||
|
||||
@@ -212,14 +212,14 @@
|
||||
var body = '';
|
||||
|
||||
$.each(page_data, function(i, q) {
|
||||
var items = typeof q.items === 'string' ? JSON.parse(q.items || '[]') : (q.items || []);
|
||||
var item_count = parseInt(q.item_count) || 0;
|
||||
body += `<tr>
|
||||
<td class="py-3 fw-semibold">${escape_html(q.quotation_number)}</td>
|
||||
<td class="py-3">${format_date(q.quotation_date)}</td>
|
||||
<td class="py-3">${q.valid_until ? format_date(q.valid_until) : '<span class="text-muted">—</span>'}</td>
|
||||
<td class="py-3">${escape_html(q.contact_name || '—')}</td>
|
||||
<td class="py-3">${get_dept_label(q.department_id)}</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(q.grand_total, 2)}</td>
|
||||
<td class="py-3">${status_badge[String(q.status)] || q.status}</td>
|
||||
<td class="py-3">
|
||||
|
||||
Reference in New Issue
Block a user