diff options
| author | Imanuel Marinao <imanuel.mariano.5@gmail.com> | 2024-07-04 14:33:23 +0700 |
|---|---|---|
| committer | Imanuel Marinao <imanuel.mariano.5@gmail.com> | 2024-07-04 14:33:23 +0700 |
| commit | a50bc458c9f9dfff8fa9902afa51769e8a282c0c (patch) | |
| tree | b505030d21053fd2c91bc8958361b293853adad4 | |
| parent | d0c00e30f3f850f8452397db05f41e0c0ecef3f9 (diff) | |
<iman> update stock opname
| -rw-r--r-- | src/app/api/company/[companyId]/product/[productId]/compute-different/route.tsx | 26 | ||||
| -rw-r--r-- | src/app/api/stock-opname/route.tsx | 20 |
2 files changed, 40 insertions, 6 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 c533392..7bf44cf 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 @@ -60,14 +60,21 @@ export async function POST(request: NextRequest, { params }: PostParams) { const conditional = { verificationCheckAll: verificationCounter > 0 && verificationCounter === stockOpnames.length, // anyCountEqWithOnhand: [totalQty['COUNT1'], totalQty['COUNT2'], totalQty['COUNT3']].includes(onhandQty), - // anyCountEqWithOnhand: (totalQty["COUNT1"] === onhandQty && zeroCount2 && zeroCount3) || (totalQty["COUNT2"] === onhandQty && zeroCount3) || totalQty["COUNT3"] === onhandQty, - anyCountEqWithOnhand: totalQty["COUNT1"] === onhandQty || totalQty["COUNT2"] === onhandQty || totalQty["COUNT1"] === onhandQty, + anyCountEqWithOnhand: (totalQty["COUNT1"] === onhandQty && zeroCount2 && zeroCount3) || (totalQty["COUNT2"] === onhandQty && zeroCount3) || totalQty["COUNT3"] === onhandQty, anyCountEqWithAllQty: [totalQty["COUNT1"], totalQty["COUNT2"], totalQty["COUNT3"]].includes(allQty), count1EqWithCount2: totalQty["COUNT1"] !== 0 && totalQty["COUNT2"] !== 0 && totalQty["COUNT1"] === totalQty["COUNT2"] && totalQty["COUNT3"] === null && totalQty["COUNT1"] !== onhandQty, count1EqWithCount3: totalQty["COUNT1"] !== 0 && totalQty["COUNT3"] !== 0 && totalQty["COUNT1"] === totalQty["COUNT3"], count2EqWithCount3: totalQty["COUNT2"] !== 0 && totalQty["COUNT3"] !== 0 && totalQty["COUNT2"] === totalQty["COUNT3"], }; + // isDifferent = !( + // conditional.verificationCheckAll || + // conditional.anyCountEqWithOnhand || + // conditional.anyCountEqWithAllQty || + // conditional.count1EqWithCount2 || + // conditional.count1EqWithCount3 || + // conditional.count2EqWithCount3 + // ); if (conditional.verificationCheckAll || conditional.anyCountEqWithOnhand || conditional.count1EqWithCount2 || conditional.count1EqWithCount3 || conditional.count2EqWithCount3) { isDifferent = false; } else { @@ -79,11 +86,10 @@ export async function POST(request: NextRequest, { params }: PostParams) { const detailCondition = { verificationCheckAll: _.isNumber(VERIFICATION.quantity), - // anyCountEqWithOnhand: (totalQty["COUNT1"] === onhandQty && zeroCount2 && zeroCount3) || (totalQty["COUNT2"] === onhandQty && zeroCount3) || totalQty["COUNT3"] === onhandQty, - anyCountEqWithOnhand: totalQty["COUNT1"] === onhandQty || totalQty["COUNT2"] === onhandQty || totalQty["COUNT1"] === onhandQty, + anyCountEqWithOnhand: (totalQty["COUNT1"] === onhandQty && zeroCount2 && zeroCount3) || (totalQty["COUNT2"] === onhandQty && zeroCount3) || totalQty["COUNT3"] === onhandQty, count1EqWithCount2: totalQty["COUNT3"] === 0 && COUNT1.quantity === COUNT2.quantity && totalQty["COUNT1"] !== onhandQty, count1EqWithCount3: COUNT1.quantity === COUNT3.quantity, - count2EqWithCount3: COUNT2.quantity === COUNT3.quantity && COUNT2.quantity !== 0 && COUNT3.quantity !== 0, + count2EqWithCount3: totalQty["COUNT2"] !== null && totalQty["COUNT3"] !== null && totalQty["COUNT2"] === totalQty["COUNT3"], // count3EqWithCount1_2: (COUNT3.quantity !== COUNT1.quantity) && (COUNT3.quantity !== COUNT2.quantity) && (COUNT1.quantity === COUNT2.quantity) && (COUNT3.quantity !== onhandQty) }; @@ -93,7 +99,17 @@ export async function POST(request: NextRequest, { params }: PostParams) { isDifferent = true; break; } + console.log("----------------------------------BATAS SUCI ATAS RECOMPUTE------------------------------"); + console.log("opname:", opname); + console.log("Is Different2222:", isDifferent); + console.log("Conditions:", detailCondition); } + console.log("Total Quantity:", totalQty); + console.log("Onhand Quantity:", onhandQty); + console.log("Difference Quantity:", differenceQty); + console.log("Conditions:", conditional); + console.log("Is Different:", isDifferent); + console.log("----------------------------------BATAS SUCI BAWAH RECOMPUTE------------------------------"); const payload = { where: { id: product.id }, diff --git a/src/app/api/stock-opname/route.tsx b/src/app/api/stock-opname/route.tsx index 1ec79d1..e0a5ee7 100644 --- a/src/app/api/stock-opname/route.tsx +++ b/src/app/api/stock-opname/route.tsx @@ -180,6 +180,14 @@ const computeIsDifferent = async ({ companyId, productId }: { companyId: number; count2EqWithCount3: totalQty["COUNT2"] !== null && totalQty["COUNT3"] !== null && totalQty["COUNT2"] === totalQty["COUNT3"], }; + // isDifferent = !( + // conditional.verificationCheckAll || + // conditional.anyCountEqWithOnhand || + // conditional.anyCountEqWithAllQty || + // conditional.count1EqWithCount2 || + // conditional.count1EqWithCount3 || + // conditional.count2EqWithCount3 + // ) if (conditional.verificationCheckAll || conditional.anyCountEqWithOnhand || conditional.count1EqWithCount2 || conditional.count1EqWithCount3 || conditional.count2EqWithCount3) { isDifferent = false; } else { @@ -194,7 +202,7 @@ const computeIsDifferent = async ({ companyId, productId }: { companyId: number; anyCountEqWithOnhand: totalQty["COUNT1"] === onhandQty || totalQty["COUNT2"] === onhandQty || totalQty["COUNT3"] === onhandQty, count1EqWithCount2: totalQty["COUNT3"] === 0 && COUNT1.quantity === COUNT2.quantity, count1EqWithCount3: COUNT1.quantity === COUNT3.quantity, - count2EqWithCount3: COUNT2.quantity === COUNT3.quantity && COUNT2.quantity !== 0 && COUNT3.quantity !== 0, + count2EqWithCount3: totalQty["COUNT2"] !== null && totalQty["COUNT3"] !== null && totalQty["COUNT2"] === totalQty["COUNT3"], // count3EqWithCount1_2: (COUNT3.quantity !== COUNT1.quantity) && (COUNT3.quantity !== COUNT2.quantity) && (COUNT1.quantity === COUNT2.quantity) && (COUNT3.quantity !== onhandQty) }; @@ -204,8 +212,18 @@ const computeIsDifferent = async ({ companyId, productId }: { companyId: number; isDifferent = true; break; } + console.log("----------------------------------BATAS SUCI ATAS NEW STOCK ------------------------------"); + console.log("Is Different2222:", isDifferent); + console.log("Conditions:", detailCondition); } + console.log("Total Quantity:", totalQty); + console.log("Onhand Quantity:", onhandQty); + console.log("Difference Quantity:", differenceQty); + console.log("Conditions:", conditional); + console.log("Is Different tambah data:", isDifferent); + console.log("----------------------------------BATAS SUCI BAWAH NEW STOCK------------------------------"); + await prisma.product.update({ where: { id: product.id }, data: { isDifferent }, |
