From 45dfcc28c0d1bb9742d842cf50f554f906c44506 Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Sat, 6 Jul 2024 10:20:34 +0700
Subject: <iman> update zero onhand

---
 src/app/api/stock-opname/route.tsx | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

(limited to 'src/app/api/stock-opname/route.tsx')

diff --git a/src/app/api/stock-opname/route.tsx b/src/app/api/stock-opname/route.tsx
index 5ecdb89..384c834 100644
--- a/src/app/api/stock-opname/route.tsx
+++ b/src/app/api/stock-opname/route.tsx
@@ -170,10 +170,14 @@ const computeIsDifferent = async ({ companyId, productId }: { companyId: number;
   // const differenceQty = product.differenceQty
   // const allQty = onhandQty + differenceQty
 
+  const zeroCount1: boolean = totalQty["COUNT1"] === 0;
+  const zeroCount2: boolean = totalQty["COUNT2"] === 0;
+  const zeroCount3: boolean = totalQty["COUNT3"] === 0;
+
   const conditional = {
     verificationCheckAll: verificationCounter > 0 && verificationCounter === stockOpnames.length,
     // anyCountEqWithOnhand: [totalQty['COUNT1'], totalQty['COUNT2'], totalQty['COUNT3']].includes(onhandQty),
-    anyCountEqWithOnhand: totalQty["COUNT1"] === onhandQty || totalQty["COUNT2"] === onhandQty || totalQty["COUNT1"] === onhandQty,
+    anyCountEqWithOnhand: (totalQty["COUNT1"] === onhandQty && zeroCount2 && zeroCount3) || (totalQty["COUNT2"] === onhandQty && zeroCount3 && onhandQty!== 0) || (totalQty["COUNT3"] === onhandQty && onhandQty!== 0),
     anyCountEqWithAllQty: [totalQty["COUNT1"], totalQty["COUNT2"], totalQty["COUNT3"]].includes(allQty),
     count1EqWithCount2: totalQty["COUNT1"] !== null && totalQty["COUNT2"] !== null && totalQty["COUNT1"] === totalQty["COUNT2"] && totalQty["COUNT3"] === null,
     count1EqWithCount3: totalQty["COUNT1"] !== null && totalQty["COUNT3"] !== null && totalQty["COUNT1"] === totalQty["COUNT3"],
@@ -191,7 +195,7 @@ const computeIsDifferent = async ({ companyId, productId }: { companyId: number;
 
     const detailCondition = {
       verificationCheckAll: _.isNumber(VERIFICATION.quantity),
-      anyCountEqWithOnhand: totalQty["COUNT1"] === onhandQty || totalQty["COUNT2"] === onhandQty || totalQty["COUNT3"] === onhandQty,
+      anyCountEqWithOnhand: (totalQty["COUNT1"] === onhandQty && zeroCount2 && zeroCount3) || (totalQty["COUNT2"] === onhandQty && zeroCount3 && onhandQty!== 0) || (totalQty["COUNT3"] === onhandQty && onhandQty!== 0),
       count1EqWithCount2: totalQty["COUNT3"] === 0 && COUNT1.quantity === COUNT2.quantity,
       count1EqWithCount3: COUNT1.quantity === COUNT3.quantity,
       count2EqWithCount3: totalQty["COUNT2"] !== 0 && totalQty["COUNT3"] !== 0 && totalQty["COUNT2"] === totalQty["COUNT3"],
-- 
cgit v1.2.3

