From ab9732a86074917d8411e96ebed6d99eba21bbc0 Mon Sep 17 00:00:00 2001
From: Rafi Zadanly <zadanlyr@gmail.com>
Date: Mon, 20 Nov 2023 14:09:34 +0700
Subject: Update logic compute is different

---
 src/app/api/stock-opname/route.tsx | 8 ++++----
 1 file changed, 4 insertions(+), 4 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 406981b..3aa9d06 100644
--- a/src/app/api/stock-opname/route.tsx
+++ b/src/app/api/stock-opname/route.tsx
@@ -183,6 +183,10 @@ const computeIsDifferent = async ({
     if (_.isNumber(totalQty['COUNT2']) && _.isNumber(COUNT2.quantity)) totalQty['COUNT2'] += COUNT2.quantity
     if (_.isNumber(totalQty['COUNT3']) && _.isNumber(COUNT3.quantity)) totalQty['COUNT3'] += COUNT3.quantity
     if (_.isNumber(totalQty['VERIFICATION']) && _.isNumber(VERIFICATION.quantity)) totalQty['VERIFICATION'] += VERIFICATION.quantity
+
+    if (_.isNumber(COUNT1.quantity) && _.isNumber(COUNT2.quantity) && COUNT1.quantity !== COUNT2.quantity) isDifferent = true
+    if (_.isNumber(COUNT1.quantity) && _.isNumber(COUNT3.quantity) && COUNT1.quantity !== COUNT3.quantity) isDifferent = true
+    if (_.isNumber(COUNT2.quantity) && _.isNumber(COUNT3.quantity) && COUNT2.quantity !== COUNT3.quantity) isDifferent = true
   }
 
   const product = await prisma.product.findFirst({ where: { id: productId } })
@@ -206,10 +210,6 @@ const computeIsDifferent = async ({
       conditional.count1EqWithCount3 ||
       conditional.count2EqWithCount3
     )
-
-    // if (isCount2Counted && totalQty['COUNT1'] != onhandQty) {
-    //   isDifferent = true
-    // }
   }
 
   await prisma.product.update({
-- 
cgit v1.2.3

