diff options
Diffstat (limited to 'src/app/api/company')
| -rw-r--r-- | src/app/api/company/[companyId]/product/[productId]/compute-different/route.tsx | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/src/app/api/company/[companyId]/product/[productId]/compute-different/route.tsx b/src/app/api/company/[companyId]/product/[productId]/compute-different/route.tsx index 2141c27..33cd55d 100644 --- a/src/app/api/company/[companyId]/product/[productId]/compute-different/route.tsx +++ b/src/app/api/company/[companyId]/product/[productId]/compute-different/route.tsx @@ -40,10 +40,6 @@ export async function POST(request: NextRequest, { params }: PostParams) { 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++ } @@ -72,6 +68,26 @@ export async function POST(request: NextRequest, { params }: PostParams) { 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 + } + const payload = { where: { id: product.id }, data: { isDifferent } |
