feat(sync): add delivery cost, discount tracking and import settings

Parse delivery.total and discounts[] from GoMag JSON into new
delivery_cost/discount_total fields. Add app_settings table for
configuring transport/discount CODMAT codes. When configured,
transport and discount are appended as extra articles in the
Oracle import JSON. Reorder Total column in dashboard/logs tables
and show transport/discount breakdown in order detail modals.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Claude Agent
2026-03-16 10:15:17 +00:00
parent 137c4a8b0b
commit 25aa9e544c
10 changed files with 302 additions and 22 deletions

View File

@@ -162,8 +162,8 @@ async function loadRunOrders(runId, statusFilter, page) {
<td><code>${esc(o.order_number)}</code></td>
<td>${esc(o.customer_name)}</td>
<td>${o.items_count || 0}</td>
<td class="text-end">${orderTotal}</td>
<td class="text-nowrap">${statusDot(o.status)} ${logStatusText(o.status)}</td>
<td>${orderTotal}</td>
</tr>`;
}).join('');
}
@@ -324,6 +324,10 @@ async function openOrderDetail(orderNumber) {
if (detailItemsTotal) detailItemsTotal.textContent = '-';
const detailOrderTotal = document.getElementById('detailOrderTotal');
if (detailOrderTotal) detailOrderTotal.textContent = '-';
const deliveryWrap = document.getElementById('detailDeliveryWrap');
if (deliveryWrap) deliveryWrap.style.display = 'none';
const discountWrap = document.getElementById('detailDiscountWrap');
if (discountWrap) discountWrap.style.display = 'none';
const mobileContainer = document.getElementById('detailItemsMobile');
if (mobileContainer) mobileContainer.innerHTML = '';
@@ -355,6 +359,22 @@ async function openOrderDetail(orderNumber) {
document.getElementById('detailError').style.display = '';
}
// Show delivery cost
const dlvWrap = document.getElementById('detailDeliveryWrap');
const dlvEl = document.getElementById('detailDeliveryCost');
if (order.delivery_cost && Number(order.delivery_cost) > 0) {
if (dlvEl) dlvEl.textContent = Number(order.delivery_cost).toFixed(2) + ' lei';
if (dlvWrap) dlvWrap.style.display = '';
}
// Show discount
const dscWrap = document.getElementById('detailDiscountWrap');
const dscEl = document.getElementById('detailDiscount');
if (order.discount_total && Number(order.discount_total) > 0) {
if (dscEl) dscEl.textContent = '-' + Number(order.discount_total).toFixed(2) + ' lei';
if (dscWrap) dscWrap.style.display = '';
}
const items = data.items || [];
if (items.length === 0) {
document.getElementById('detailItemsBody').innerHTML = '<tr><td colspan="8" class="text-center text-muted">Niciun articol</td></tr>';