summaryrefslogtreecommitdiff
path: root/src/app/api/stock-opname
diff options
context:
space:
mode:
authorRafi Zadanly <zadanlyr@gmail.com>2023-12-09 12:26:26 +0700
committerRafi Zadanly <zadanlyr@gmail.com>2023-12-09 12:26:26 +0700
commite01af38369c04be36bc71473a46c73aca655f046 (patch)
tree04288773fa08c0d9714c0a5b18f4b6b2e652a2b2 /src/app/api/stock-opname
parentc977921f02308af769af37f6b7d37b21869797f2 (diff)
Fix compute different product stock opname
Diffstat (limited to 'src/app/api/stock-opname')
-rw-r--r--src/app/api/stock-opname/route.tsx34
1 files changed, 16 insertions, 18 deletions
diff --git a/src/app/api/stock-opname/route.tsx b/src/app/api/stock-opname/route.tsx
index cba16e2..4c2dee4 100644
--- a/src/app/api/stock-opname/route.tsx
+++ b/src/app/api/stock-opname/route.tsx
@@ -183,26 +183,24 @@ const computeIsDifferent = async ({
const differenceQty = product.differenceQty
const allQty = onhandQty + differenceQty
- if (!isDifferent) {
- const conditional = {
- verificationCheckAll: verificationCounter > 0 && verificationCounter === stockOpnames.length,
- anyCountEqWithOnhand: [totalQty['COUNT1'], totalQty['COUNT2'], totalQty['COUNT3']].includes(onhandQty),
- anyCountEqWithAllQty: [totalQty['COUNT1'], totalQty['COUNT2'], totalQty['COUNT3']].includes(allQty),
- count1EqWithCount2: totalQty['COUNT1'] !== null && totalQty['COUNT2'] !== null && totalQty['COUNT1'] === totalQty['COUNT2'],
- count1EqWithCount3: totalQty['COUNT1'] !== null && totalQty['COUNT3'] !== null && totalQty['COUNT1'] === totalQty['COUNT3'],
- count2EqWithCount3: totalQty['COUNT2'] !== null && totalQty['COUNT3'] !== null && totalQty['COUNT2'] === totalQty['COUNT3'],
- }
-
- isDifferent = !(
- conditional.verificationCheckAll ||
- conditional.anyCountEqWithOnhand ||
- conditional.anyCountEqWithAllQty ||
- conditional.count1EqWithCount2 ||
- conditional.count1EqWithCount3 ||
- conditional.count2EqWithCount3
- )
+ const conditional = {
+ verificationCheckAll: verificationCounter > 0 && verificationCounter === stockOpnames.length,
+ anyCountEqWithOnhand: [totalQty['COUNT1'], totalQty['COUNT2'], totalQty['COUNT3']].includes(onhandQty),
+ anyCountEqWithAllQty: [totalQty['COUNT1'], totalQty['COUNT2'], totalQty['COUNT3']].includes(allQty),
+ count1EqWithCount2: totalQty['COUNT1'] !== null && totalQty['COUNT2'] !== null && totalQty['COUNT1'] === totalQty['COUNT2'],
+ count1EqWithCount3: totalQty['COUNT1'] !== null && totalQty['COUNT3'] !== null && totalQty['COUNT1'] === totalQty['COUNT3'],
+ count2EqWithCount3: totalQty['COUNT2'] !== null && totalQty['COUNT3'] !== null && totalQty['COUNT2'] === totalQty['COUNT3'],
}
+ isDifferent = !(
+ conditional.verificationCheckAll ||
+ conditional.anyCountEqWithOnhand ||
+ conditional.anyCountEqWithAllQty ||
+ conditional.count1EqWithCount2 ||
+ conditional.count1EqWithCount3 ||
+ conditional.count2EqWithCount3
+ )
+
await prisma.product.update({
where: { id: product.id },
data: { isDifferent }