u
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user