summaryrefslogtreecommitdiff
path: root/src/app/api/stock-opname/route.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/app/api/stock-opname/route.tsx')
-rw-r--r--src/app/api/stock-opname/route.tsx24
1 files changed, 20 insertions, 4 deletions
diff --git a/src/app/api/stock-opname/route.tsx b/src/app/api/stock-opname/route.tsx
index 4c2dee4..38284bf 100644
--- a/src/app/api/stock-opname/route.tsx
+++ b/src/app/api/stock-opname/route.tsx
@@ -169,10 +169,6 @@ const computeIsDifferent = async ({
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
-
if (_.isNumber(VERIFICATION.quantity)) verificationCounter++
}
@@ -201,6 +197,26 @@ const computeIsDifferent = async ({
conditional.count2EqWithCount3
)
+ for (const opname of stockOpnames) {
+ let { COUNT1, COUNT2, COUNT3, VERIFICATION } = opname
+
+ const detailCondition = {
+ verificationCheckAll: _.isNumber(VERIFICATION.quantity),
+ count1EqWithCount2: COUNT1.quantity !== null && COUNT2.quantity !== null && COUNT1.quantity === COUNT2.quantity,
+ count1EqWithCount3: COUNT1.quantity !== null && COUNT3.quantity !== null && COUNT1.quantity === COUNT3.quantity,
+ count2EqWithCount3: COUNT2.quantity !== null && COUNT3.quantity !== null && COUNT2.quantity === COUNT3.quantity,
+ }
+
+ isDifferent = !(
+ detailCondition.verificationCheckAll ||
+ detailCondition.count1EqWithCount2 ||
+ detailCondition.count1EqWithCount3 ||
+ detailCondition.count2EqWithCount3
+ )
+
+ if (isDifferent) break
+ }
+
await prisma.product.update({
where: { id: product.id },
data: { isDifferent }