From b0014d662988240d14f3430a9941dbefa845bf1e Mon Sep 17 00:00:00 2001 From: seb Date: Wed, 21 Oct 2026 04:28:56 +0200 Subject: [PATCH] u --- src/store/order/syncSummary.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/store/order/syncSummary.js b/src/store/order/syncSummary.js index c3a7522..b53b222 100644 --- a/src/store/order/syncSummary.js +++ b/src/store/order/syncSummary.js @@ -201,7 +201,7 @@ export async function syncOrderSummary(runner, { companyId, manifestId, orderNum const paidTotal = Math.round(Number(payRes.rows[0]?.paid_total || 0) * 100) / 100; const shippedQuantity = Math.round(Number(shipRes.rows[0]?.shipped_quantity || 0) * 1000) / 1000; - const isPaid = grossTotal > 0 && Math.abs(paidTotal - grossTotal) < 0.01 ? 1 : 0; + const isPaid = Math.abs(grossTotal) < 0.01 || Math.abs(paidTotal - grossTotal) < 0.01 ? 1 : 0; const isShipped = orderedQuantity > 0 && Math.abs(shippedQuantity - orderedQuantity) < 0.001 ? 1 : 0; await runner.query(isSqlite ? SQL_UPSERT_SUMMARY_SQLITE : SQL_UPSERT_SUMMARY_MSSQL, { @@ -284,7 +284,7 @@ export async function rebuildOrderSummaries(runner, companyId) { ROUND(COALESCE(op.paid_total, 0), 2) AS paid_total, ROUND(COALESCE(oa.ordered_quantity, 0), 3) AS ordered_quantity, ROUND(COALESCE(st.shipped_quantity, 0), 3) AS shipped_quantity, - CASE WHEN COALESCE(oa.gross_total, 0) > 0 AND ABS(COALESCE(op.paid_total, 0) - oa.gross_total) < 0.01 THEN 1 ELSE 0 END AS is_paid, + CASE WHEN ABS(COALESCE(oa.gross_total, 0)) < 0.01 OR ABS(COALESCE(op.paid_total, 0) - oa.gross_total) < 0.01 THEN 1 ELSE 0 END AS is_paid, CASE WHEN COALESCE(oa.ordered_quantity, 0) > 0 AND ABS(COALESCE(st.shipped_quantity, 0) - oa.ordered_quantity) < 0.001 THEN 1 ELSE 0 END AS is_shipped FROM manifest m LEFT JOIN entity e ON e.id = m.entity_id @@ -358,7 +358,7 @@ export async function rebuildOrderSummaries(runner, companyId) { ROUND(COALESCE(op.paid_total, 0), 2) AS paid_total, ROUND(COALESCE(oa.ordered_quantity, 0), 3) AS ordered_quantity, ROUND(COALESCE(st.shipped_quantity, 0), 3) AS shipped_quantity, - CASE WHEN COALESCE(oa.gross_total, 0) > 0 AND ABS(COALESCE(op.paid_total, 0) - oa.gross_total) < 0.01 THEN 1 ELSE 0 END AS is_paid, + CASE WHEN ABS(COALESCE(oa.gross_total, 0)) < 0.01 OR ABS(COALESCE(op.paid_total, 0) - oa.gross_total) < 0.01 THEN 1 ELSE 0 END AS is_paid, CASE WHEN COALESCE(oa.ordered_quantity, 0) > 0 AND ABS(COALESCE(st.shipped_quantity, 0) - oa.ordered_quantity) < 0.001 THEN 1 ELSE 0 END AS is_shipped FROM manifest m LEFT JOIN entity e ON e.id = m.entity_id