diff options
| author | Rafi Zadanly <zadanlyr@gmail.com> | 2023-11-20 14:09:34 +0700 |
|---|---|---|
| committer | Rafi Zadanly <zadanlyr@gmail.com> | 2023-11-20 14:09:34 +0700 |
| commit | ab9732a86074917d8411e96ebed6d99eba21bbc0 (patch) | |
| tree | 30d8254b3413f7a1aff170caa07ba9e3b4929ef8 | |
| parent | 07819844d5ef7e323fd956eacfedecb2f4f4bb80 (diff) | |
Update logic compute is different
| -rw-r--r-- | package.json | 1 | ||||
| -rw-r--r-- | src/app/api/stock-opname/route.tsx | 8 | ||||
| -rw-r--r-- | src/common/constants/result.ts | 2 | ||||
| -rw-r--r-- | src/modules/result/components/Table.tsx | 4 |
4 files changed, 9 insertions, 6 deletions
diff --git a/package.json b/package.json index c45d698..1ab9e0e 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ "jsonwebtoken": "^9.0.2", "lodash": "^4.17.21", "lucide-react": "^0.291.0", + "moment": "^2.29.4", "next": "13.5.6", "prisma": "^5.5.2", "react": "^18", 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({ diff --git a/src/common/constants/result.ts b/src/common/constants/result.ts index 229bc87..e9c47df 100644 --- a/src/common/constants/result.ts +++ b/src/common/constants/result.ts @@ -1,5 +1,5 @@ export const SHOWING_SELECTIONS = [ { key: "1", value: "", label: "Semua" }, { key: "2", value: "diff", label: "Selisih" }, - { key: "3", value: "not-diff", label: "Tidak Selisih" }, + { key: "3", value: "not-diff", label: "Aman" }, ]; diff --git a/src/modules/result/components/Table.tsx b/src/modules/result/components/Table.tsx index 021dfef..8a29fd4 100644 --- a/src/modules/result/components/Table.tsx +++ b/src/modules/result/components/Table.tsx @@ -13,6 +13,7 @@ import getClientCredential from "@/common/libs/getClientCredential"; import { SHOWING_SELECTIONS } from "@/common/constants/result"; import Link from "next/link"; import { useState } from "react"; +import moment from "moment"; const Table = () => { const credential = getClientCredential() @@ -51,12 +52,13 @@ const Table = () => { setExportLoad(true) const response = await fetch(`/api/stock-opname/export?companyId=${filter.company}`) const buffer = await response.arrayBuffer() + console.log({ type: response.headers.get('type') }); const blob = new Blob([buffer], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' }) const url = window.URL.createObjectURL(blob) const a = document.createElement('a') a.href = url - a.download = 'export.xlsx' + a.download = `export_${moment().format('MM_DD_HH_ss')}.xlsx` document.body.appendChild(a) a.click() document.body.removeChild(a) |
