@things-factory/operato-wms 5.0.13 → 6.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client/pages/bulk-operation/bulk-operation.js +96 -8
- package/client/pages/bulk-operation/validate-gan-popup.js +37 -27
- package/client/pages/bulk-operation/validate-ro-popup.js +40 -0
- package/client/pages/components/select-inventory-popup.js +633 -0
- package/client/pages/constants/order.js +2 -1
- package/client/pages/inbound/pallet-label-popup.js +2 -0
- package/client/pages/inbound/select-product-batch.js +7 -1
- package/client/pages/inbound/undo-unload-popup.js +37 -21
- package/client/pages/inbound/unload-product.js +147 -59
- package/client/pages/inbound/worksheet-putaway.js +1 -1
- package/client/pages/inbound/worksheet-unloading.js +11 -7
- package/client/pages/inventory/inventory-adjustment.js +261 -238
- package/client/pages/inventory/inventory-by-product-detail.js +99 -92
- package/client/pages/inventory/inventory-by-product.js +170 -68
- package/client/pages/inventory/onhand-inventory.js +10 -12
- package/client/pages/inventory/serial-number-list-popup.js +36 -5
- package/client/pages/inventory-check/inspecting-product.js +1 -1
- package/client/pages/manifest/create-loading-manifest.js +47 -22
- package/client/pages/manifest/dispatcher-verification-popup.js +24 -13
- package/client/pages/manifest/loading-manifest-detail.js +311 -46
- package/client/pages/manifest/loading-manifest-list.js +86 -13
- package/client/pages/order/arrival-notice/arrival-notice-detail.js +305 -52
- package/client/pages/order/arrival-notice/arrival-notice-list.js +20 -1
- package/client/pages/order/arrival-notice/create-arrival-notice.js +2 -2
- package/client/pages/order/goods-received-note/received-note-detail.js +187 -15
- package/client/pages/order/release-order/b2b/b2b-order-list.js +76 -80
- package/client/pages/order/release-order/b2c/b2c-order-requests.js +148 -123
- package/client/pages/order/release-order/batch-picking-popup.js +11 -0
- package/client/pages/order/release-order/create-release-order.js +762 -250
- package/client/pages/order/release-order/release-extra-product-popup.js +10 -3
- package/client/pages/order/release-order/release-order-detail.js +897 -215
- package/client/pages/order/transport-order/delivery-note-popup.js +1050 -107
- package/client/pages/order/transport-order/print-delivery-note.js +214 -33
- package/client/pages/order/transport-order/upload-delivery-note.js +6 -4
- package/client/pages/order/transport-order/view-delivery-note.js +0 -1
- package/client/pages/outbound/generate-worksheet-popup.js +374 -0
- package/client/pages/outbound/inventory-reassign-popup.js +1097 -0
- package/client/pages/outbound/loading-product.js +88 -78
- package/client/pages/outbound/merged-outbound-worksheet.js +1 -1
- package/client/pages/outbound/packing-product.js +193 -82
- package/client/pages/outbound/packing-worksheet-list.js +10 -9
- package/client/pages/outbound/picking-product.js +979 -905
- package/client/pages/outbound/route-label-popup.js +283 -191
- package/client/pages/outbound/serial-number-popup.js +1 -0
- package/client/pages/outbound/sorting-product.js +12 -12
- package/client/pages/outbound/worksheet-batch-picking.js +39 -5
- package/client/pages/outbound/worksheet-packing.js +17 -4
- package/client/pages/outbound/worksheet-picking.js +45 -6
- package/client/pages/report/inbound-serial-number-report.js +86 -9
- package/client/pages/report/inventory-report.js +10 -0
- package/client/pages/report/inventory-summary-report.js +28 -19
- package/client/pages/report/outbound-order-details-report.js +204 -43
- package/client/pages/report/outbound-serial-number-report.js +87 -9
- package/client/pages/report/release-inventory-report.js +503 -0
- package/client/route.js +5 -0
- package/client/util/index.js +2 -0
- package/client/util/page-settings.js +43 -0
- package/client/util/toast.js +10 -0
- package/dist-server/graphql/resolvers/board-setting/board-settings.js +3 -3
- package/dist-server/graphql/resolvers/board-setting/board-settings.js.map +1 -1
- package/dist-server/graphql/resolvers/custom/elccl/elccl-daily-collection-report.js +2 -2
- package/dist-server/graphql/resolvers/custom/elccl/elccl-daily-collection-report.js.map +1 -1
- package/dist-server/graphql/resolvers/custom/elccl/elccl-daily-order-inventory-report.js +1 -1
- package/dist-server/graphql/resolvers/custom/elccl/elccl-daily-order-inventory-report.js.map +1 -1
- package/dist-server/graphql/resolvers/custom/elccl/elccl-inventory-history-pallet-detail-report.js +2 -2
- package/dist-server/graphql/resolvers/custom/elccl/elccl-inventory-history-pallet-detail-report.js.map +1 -1
- package/dist-server/graphql/resolvers/custom/elccl/elccl-inventory-history-report.js +9 -10
- package/dist-server/graphql/resolvers/custom/elccl/elccl-inventory-history-report.js.map +1 -1
- package/dist-server/graphql/resolvers/custom/elccl/elccl-inventory-history-summary-report.js +2 -2
- package/dist-server/graphql/resolvers/custom/elccl/elccl-inventory-history-summary-report.js.map +1 -1
- package/dist-server/graphql/resolvers/custom/elccl/elccl-onhand-inventory-counter.js +6 -4
- package/dist-server/graphql/resolvers/custom/elccl/elccl-onhand-inventory-counter.js.map +1 -1
- package/dist-server/graphql/resolvers/custom/kimeda/kimeda-onhand-inventory-counter.js +6 -4
- package/dist-server/graphql/resolvers/custom/kimeda/kimeda-onhand-inventory-counter.js.map +1 -1
- package/dist-server/graphql/resolvers/dashboard/arrival-notices-by-status.js +21 -10
- package/dist-server/graphql/resolvers/dashboard/arrival-notices-by-status.js.map +1 -1
- package/dist-server/graphql/resolvers/dashboard/collection-orders-by-status.js +1 -2
- package/dist-server/graphql/resolvers/dashboard/collection-orders-by-status.js.map +1 -1
- package/dist-server/graphql/resolvers/dashboard/delivery-orders-by-status.js +1 -2
- package/dist-server/graphql/resolvers/dashboard/delivery-orders-by-status.js.map +1 -1
- package/dist-server/graphql/resolvers/dashboard/index.js +2 -1
- package/dist-server/graphql/resolvers/dashboard/index.js.map +1 -1
- package/dist-server/graphql/resolvers/dashboard/inventory-expiry-monitor.js +17 -1
- package/dist-server/graphql/resolvers/dashboard/inventory-expiry-monitor.js.map +1 -1
- package/dist-server/graphql/resolvers/dashboard/outbound-order-by-status.js +113 -75
- package/dist-server/graphql/resolvers/dashboard/outbound-order-by-status.js.map +1 -1
- package/dist-server/graphql/resolvers/dashboard/release-goods-by-status.js +21 -10
- package/dist-server/graphql/resolvers/dashboard/release-goods-by-status.js.map +1 -1
- package/dist-server/graphql/resolvers/dashboard/unit-inbounded-outbounded.js +56 -0
- package/dist-server/graphql/resolvers/dashboard/unit-inbounded-outbounded.js.map +1 -0
- package/dist-server/graphql/resolvers/index.js +5 -4
- package/dist-server/graphql/resolvers/index.js.map +1 -1
- package/dist-server/graphql/resolvers/inventory-comparison/inventory-comparison-list.js.map +1 -1
- package/dist-server/graphql/resolvers/opa-menu/opa-menus.js +8 -7
- package/dist-server/graphql/resolvers/opa-menu/opa-menus.js.map +1 -1
- package/dist-server/graphql/resolvers/{extra → other}/add-release-good-products.js +59 -8
- package/dist-server/graphql/resolvers/other/add-release-good-products.js.map +1 -0
- package/dist-server/graphql/resolvers/{extra → other}/index.js +3 -1
- package/dist-server/graphql/resolvers/other/index.js.map +1 -0
- package/dist-server/graphql/resolvers/other/page-settings.js +87 -0
- package/dist-server/graphql/resolvers/other/page-settings.js.map +1 -0
- package/dist-server/graphql/resolvers/reports/costing-report.js +4 -4
- package/dist-server/graphql/resolvers/reports/costing-report.js.map +1 -1
- package/dist-server/graphql/resolvers/reports/inbound-order-details-report.js +3 -3
- package/dist-server/graphql/resolvers/reports/inbound-order-details-report.js.map +1 -1
- package/dist-server/graphql/resolvers/reports/inbound-serial-number-report.js +36 -7
- package/dist-server/graphql/resolvers/reports/inbound-serial-number-report.js.map +1 -1
- package/dist-server/graphql/resolvers/reports/index.js +2 -1
- package/dist-server/graphql/resolvers/reports/index.js.map +1 -1
- package/dist-server/graphql/resolvers/reports/outbound-order-details-report.js +69 -30
- package/dist-server/graphql/resolvers/reports/outbound-order-details-report.js.map +1 -1
- package/dist-server/graphql/resolvers/reports/outbound-serial-number-report.js +36 -11
- package/dist-server/graphql/resolvers/reports/outbound-serial-number-report.js.map +1 -1
- package/dist-server/graphql/resolvers/reports/product-label-report.js +3 -3
- package/dist-server/graphql/resolvers/reports/product-label-report.js.map +1 -1
- package/dist-server/graphql/resolvers/reports/release-inventory-report.js +180 -0
- package/dist-server/graphql/resolvers/reports/release-inventory-report.js.map +1 -0
- package/dist-server/graphql/resolvers/shipping-provider/shipping-providers.js +2 -2
- package/dist-server/graphql/resolvers/shipping-provider/shipping-providers.js.map +1 -1
- package/dist-server/graphql/resolvers/warehouse-inventory-adjustment/warehouse-intentory-adjustment.js +1 -1
- package/dist-server/graphql/resolvers/warehouse-inventory-adjustment/warehouse-intentory-adjustment.js.map +1 -1
- package/dist-server/graphql/types/dashboard/index.js +1 -0
- package/dist-server/graphql/types/dashboard/index.js.map +1 -1
- package/dist-server/graphql/types/index.js +7 -2
- package/dist-server/graphql/types/index.js.map +1 -1
- package/dist-server/graphql/types/other/index.js +19 -0
- package/dist-server/graphql/types/other/index.js.map +1 -0
- package/dist-server/graphql/types/other/page-setting.js +34 -0
- package/dist-server/graphql/types/other/page-setting.js.map +1 -0
- package/dist-server/graphql/types/reports/index.js +6 -1
- package/dist-server/graphql/types/reports/index.js.map +1 -1
- package/dist-server/graphql/types/reports/outbound-order-details-report.js +17 -1
- package/dist-server/graphql/types/reports/outbound-order-details-report.js.map +1 -1
- package/dist-server/graphql/types/reports/release-inventory-report-list.js +12 -0
- package/dist-server/graphql/types/reports/release-inventory-report-list.js.map +1 -0
- package/dist-server/graphql/types/reports/release-inventory-report.js +27 -0
- package/dist-server/graphql/types/reports/release-inventory-report.js.map +1 -0
- package/dist-server/migrations/1568858861188-SeedSetting.js +5 -6
- package/dist-server/migrations/1568858861188-SeedSetting.js.map +1 -1
- package/dist-server/migrations/1623308919899-SeedLocationRecommendSetting.js +1 -1
- package/dist-server/migrations/1623308919899-SeedLocationRecommendSetting.js.map +1 -1
- package/dist-server/migrations/1623381200659-SeedStoringRule.js +1 -1
- package/dist-server/migrations/1623381200659-SeedStoringRule.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/dist-server/utils/report-query-util.js +5 -2
- package/dist-server/utils/report-query-util.js.map +1 -1
- package/helps/release-note.ko.md +8 -20
- package/helps/release-note.md +8 -20
- package/helps/release-note.ms.md +8 -20
- package/helps/release-note.zh.md +8 -20
- package/package.json +42 -42
- package/server/graphql/resolvers/board-setting/board-settings.ts +4 -6
- package/server/graphql/resolvers/custom/elccl/elccl-daily-collection-report.ts +4 -5
- package/server/graphql/resolvers/custom/elccl/elccl-daily-order-inventory-report.ts +9 -10
- package/server/graphql/resolvers/custom/elccl/elccl-inventory-history-pallet-detail-report.ts +4 -5
- package/server/graphql/resolvers/custom/elccl/elccl-inventory-history-report.ts +17 -19
- package/server/graphql/resolvers/custom/elccl/elccl-inventory-history-summary-report.ts +10 -8
- package/server/graphql/resolvers/custom/elccl/elccl-onhand-inventory-counter.ts +9 -9
- package/server/graphql/resolvers/custom/kimeda/kimeda-onhand-inventory-counter.ts +9 -9
- package/server/graphql/resolvers/dashboard/arrival-notices-by-status.ts +23 -14
- package/server/graphql/resolvers/dashboard/collection-orders-by-status.ts +4 -5
- package/server/graphql/resolvers/dashboard/delivery-orders-by-status.ts +4 -5
- package/server/graphql/resolvers/dashboard/index.ts +3 -1
- package/server/graphql/resolvers/dashboard/inventory-expiry-monitor.ts +18 -6
- package/server/graphql/resolvers/dashboard/outbound-order-by-status.ts +114 -81
- package/server/graphql/resolvers/dashboard/release-goods-by-status.ts +23 -14
- package/server/graphql/resolvers/dashboard/unit-inbounded-outbounded.ts +61 -0
- package/server/graphql/resolvers/index.ts +5 -4
- package/server/graphql/resolvers/inventory-comparison/inventory-comparison-list.ts +11 -9
- package/server/graphql/resolvers/opa-menu/opa-menus.ts +7 -6
- package/server/graphql/resolvers/{extra → other}/add-release-good-products.ts +73 -12
- package/server/graphql/resolvers/other/index.ts +10 -0
- package/server/graphql/resolvers/other/page-settings.ts +105 -0
- package/server/graphql/resolvers/reports/costing-report.ts +8 -10
- package/server/graphql/resolvers/reports/inbound-order-details-report.ts +7 -9
- package/server/graphql/resolvers/reports/inbound-serial-number-report.ts +41 -13
- package/server/graphql/resolvers/reports/index.ts +3 -1
- package/server/graphql/resolvers/reports/outbound-order-details-report.ts +76 -38
- package/server/graphql/resolvers/reports/outbound-serial-number-report.ts +42 -18
- package/server/graphql/resolvers/reports/product-label-report.ts +4 -6
- package/server/graphql/resolvers/reports/release-inventory-report.ts +201 -0
- package/server/graphql/resolvers/shipping-provider/shipping-providers.ts +3 -5
- package/server/graphql/resolvers/warehouse-inventory-adjustment/warehouse-intentory-adjustment.ts +10 -10
- package/server/graphql/types/dashboard/index.ts +1 -0
- package/server/graphql/types/index.ts +8 -2
- package/server/graphql/types/other/index.ts +19 -0
- package/server/graphql/types/other/page-setting.ts +33 -0
- package/server/graphql/types/reports/index.ts +6 -1
- package/server/graphql/types/reports/outbound-order-details-report.ts +17 -1
- package/server/graphql/types/reports/release-inventory-report-list.ts +8 -0
- package/server/graphql/types/reports/release-inventory-report.ts +23 -0
- package/server/migrations/1568858861188-SeedSetting.ts +4 -4
- package/server/migrations/1623308919899-SeedLocationRecommendSetting.ts +3 -2
- package/server/migrations/1623381200659-SeedStoringRule.ts +3 -2
- package/server/utils/report-query-util.ts +5 -2
- package/things-factory.config.js +4 -0
- package/translations/en.json +148 -27
- package/translations/ko.json +185 -105
- package/translations/ms.json +183 -98
- package/translations/zh.json +197 -112
- package/dist-server/graphql/resolvers/extra/add-release-good-products.js.map +0 -1
- package/dist-server/graphql/resolvers/extra/index.js.map +0 -1
- package/dist-server/graphql/types/extra/index.js +0 -11
- package/dist-server/graphql/types/extra/index.js.map +0 -1
- package/server/graphql/resolvers/extra/index.ts +0 -5
- package/server/graphql/types/extra/index.ts +0 -7
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { In, Not } from 'typeorm'
|
|
2
2
|
|
|
3
|
-
import { User } from '@things-factory/auth-base'
|
|
4
3
|
import { Bizplace } from '@things-factory/biz-base'
|
|
5
4
|
import { Product } from '@things-factory/product-base'
|
|
6
5
|
import {
|
|
@@ -11,7 +10,6 @@ import {
|
|
|
11
10
|
OrderProduct,
|
|
12
11
|
ReleaseGood
|
|
13
12
|
} from '@things-factory/sales-base'
|
|
14
|
-
import { Domain } from '@things-factory/shell'
|
|
15
13
|
import { Inventory } from '@things-factory/warehouse-base'
|
|
16
14
|
import {
|
|
17
15
|
generatePickingWorksheetDetail,
|
|
@@ -22,13 +20,13 @@ import {
|
|
|
22
20
|
} from '@things-factory/worksheet-base'
|
|
23
21
|
|
|
24
22
|
export const addReleaseGoodProducts = {
|
|
25
|
-
async addReleaseGoodProducts(_: any, { name, orderInventories, existingOrderInventories }, context:
|
|
23
|
+
async addReleaseGoodProducts(_: any, { name, orderInventories, existingOrderInventories }, context: ResolverContext) {
|
|
26
24
|
try {
|
|
27
|
-
const { tx, user, domain }
|
|
25
|
+
const { tx, user, domain } = context.state
|
|
28
26
|
|
|
29
27
|
let releaseGood: ReleaseGood = await tx.getRepository(ReleaseGood).findOne({
|
|
30
|
-
where: { domain, name: name },
|
|
31
|
-
relations: ['bizplace']
|
|
28
|
+
where: { domain: { id: domain.id }, name: name },
|
|
29
|
+
relations: ['bizplace', 'orderProducts']
|
|
32
30
|
})
|
|
33
31
|
|
|
34
32
|
const bizplace: Bizplace = releaseGood.bizplace
|
|
@@ -48,12 +46,12 @@ export const addReleaseGoodProducts = {
|
|
|
48
46
|
curOrderInv.domain = domain
|
|
49
47
|
curOrderInv.bizplace = bizplace
|
|
50
48
|
curOrderInv.releaseGood = releaseGood
|
|
51
|
-
curOrderInv.product = await tx.getRepository(Product).
|
|
49
|
+
curOrderInv.product = await tx.getRepository(Product).findOneBy({ id: oi.product.id })
|
|
52
50
|
|
|
53
51
|
let existingOrderInv: OrderInventory
|
|
54
52
|
|
|
55
53
|
if (curOrderInv?.inventory?.id) {
|
|
56
|
-
const foundInv: Inventory = await tx.getRepository(Inventory).
|
|
54
|
+
const foundInv: Inventory = await tx.getRepository(Inventory).findOneBy({ id: curOrderInv.inventory.id })
|
|
57
55
|
curOrderInv.inventory = foundInv
|
|
58
56
|
|
|
59
57
|
existingOrderInv = await tx.getRepository(OrderInventory).findOne({
|
|
@@ -204,17 +202,29 @@ export const addReleaseGoodProducts = {
|
|
|
204
202
|
newOrderInv.status = pickingWorksheet ? ORDER_INVENTORY_STATUS.PICKING : ORDER_INVENTORY_STATUS.PENDING
|
|
205
203
|
newOrderInv.name = OrderNoGenerator.orderInventory()
|
|
206
204
|
newOrderInv.releaseGood = releaseGood
|
|
207
|
-
newOrderInv.product = await tx.getRepository(Product).
|
|
205
|
+
newOrderInv.product = await tx.getRepository(Product).findOneBy({ id: oi.product.id })
|
|
208
206
|
newOrderInv.creator = user
|
|
209
207
|
newOrderInv.updater = user
|
|
210
208
|
|
|
211
209
|
let existingOrderInv: OrderInventory
|
|
212
210
|
|
|
211
|
+
let existingOrderProduct: OrderProduct = await tx.getRepository(OrderProduct).findOne({
|
|
212
|
+
where: {
|
|
213
|
+
domain: { id: domain.id },
|
|
214
|
+
releaseGood: { id: releaseGood.id },
|
|
215
|
+
batchId: oi.batchId,
|
|
216
|
+
packingType: oi.packingType,
|
|
217
|
+
product: { id: newOrderInv.product.id }
|
|
218
|
+
}
|
|
219
|
+
})
|
|
220
|
+
|
|
213
221
|
// check if it is release by inventory (has inventory value) or product
|
|
214
222
|
if (newOrderInv.inventory?.id) {
|
|
215
223
|
// if release by inventory, then quantity and uomValue values are updated
|
|
216
|
-
const foundInv: Inventory = await tx.getRepository(Inventory).
|
|
224
|
+
const foundInv: Inventory = await tx.getRepository(Inventory).findOneBy({ id: newOrderInv.inventory.id })
|
|
217
225
|
newOrderInv.inventory = foundInv
|
|
226
|
+
newOrderInv.uom = oi?.uom || foundInv.uom
|
|
227
|
+
newOrderInv.batchIdRef = oi?.batchIdRef || foundInv.batchIdRef
|
|
218
228
|
|
|
219
229
|
// check for existing released OrderInventory specifying product, batchId, packingType, and inventory
|
|
220
230
|
existingOrderInv = await tx.getRepository(OrderInventory).findOne({
|
|
@@ -241,7 +251,9 @@ export const addReleaseGoodProducts = {
|
|
|
241
251
|
status: ORDER_PRODUCT_STATUS.ASSIGNED
|
|
242
252
|
}
|
|
243
253
|
|
|
244
|
-
newOrderProduct = await tx.getRepository(OrderProduct).save(newOrderProduct)
|
|
254
|
+
if (!existingOrderProduct) newOrderProduct = await tx.getRepository(OrderProduct).save(newOrderProduct)
|
|
255
|
+
|
|
256
|
+
newOrderInv.orderProduct = existingOrderProduct ? existingOrderProduct : newOrderProduct
|
|
245
257
|
|
|
246
258
|
await tx.getRepository(Inventory).save(foundInv)
|
|
247
259
|
} else {
|
|
@@ -286,6 +298,7 @@ export const addReleaseGoodProducts = {
|
|
|
286
298
|
if (existingWorksheetDetail) {
|
|
287
299
|
existingWorksheetDetail = {
|
|
288
300
|
...existingWorksheetDetail,
|
|
301
|
+
targetProduct: newOrderInv.orderProduct,
|
|
289
302
|
status: WORKSHEET_STATUS.DEACTIVATED
|
|
290
303
|
}
|
|
291
304
|
|
|
@@ -306,11 +319,14 @@ export const addReleaseGoodProducts = {
|
|
|
306
319
|
savedOrderInv.releaseQty = newOrderInv.releaseQty
|
|
307
320
|
savedOrderInv.releaseUomValue = newOrderInv.releaseUomValue
|
|
308
321
|
savedOrderInv.batchId = newOrderInv.batchId
|
|
322
|
+
savedOrderInv.batchIdRef = newOrderInv.batchIdRef
|
|
309
323
|
savedOrderInv.packingType = newOrderInv.packingType
|
|
324
|
+
savedOrderInv.uom = newOrderInv.uom
|
|
310
325
|
savedOrderInv.product = newOrderInv.product
|
|
311
326
|
savedOrderInv.inventory = newOrderInv.inventory
|
|
312
327
|
savedOrderInv.status = newOrderInv.status
|
|
313
328
|
savedOrderInv.releaseGood = newOrderInv.releaseGood
|
|
329
|
+
savedOrderInv.orderProduct = newOrderInv.orderProduct
|
|
314
330
|
savedOrderInv.bizplace = newOrderInv.bizplace
|
|
315
331
|
savedOrderInv.domain = domain
|
|
316
332
|
savedOrderInv.creator = user
|
|
@@ -345,6 +361,51 @@ export const addReleaseGoodProducts = {
|
|
|
345
361
|
|
|
346
362
|
await tx.getRepository(Worksheet).save(loadingWorksheet)
|
|
347
363
|
}
|
|
364
|
+
|
|
365
|
+
// Update Order Product Release Qty
|
|
366
|
+
let rgOrderProducts: OrderProduct[] = await tx
|
|
367
|
+
.getRepository(OrderProduct)
|
|
368
|
+
.find({ where: { domain: { id: domain.id }, releaseGood } })
|
|
369
|
+
|
|
370
|
+
await Promise.all(
|
|
371
|
+
rgOrderProducts.map(async op => {
|
|
372
|
+
const orderInventories: OrderInventory[] = await tx.getRepository(OrderInventory).find({
|
|
373
|
+
where: {
|
|
374
|
+
domain: { id: domain.id },
|
|
375
|
+
releaseGood: { id: releaseGood.id },
|
|
376
|
+
orderProduct: { id: op.id },
|
|
377
|
+
status: Not(
|
|
378
|
+
In([
|
|
379
|
+
ORDER_INVENTORY_STATUS.TERMINATED,
|
|
380
|
+
ORDER_INVENTORY_STATUS.CANCELLED,
|
|
381
|
+
ORDER_INVENTORY_STATUS.PENDING_CANCEL
|
|
382
|
+
])
|
|
383
|
+
)
|
|
384
|
+
}
|
|
385
|
+
})
|
|
386
|
+
|
|
387
|
+
let totalReleaseQty: number = orderInventories.reduce((total, currentValue) => {
|
|
388
|
+
total += currentValue.releaseQty
|
|
389
|
+
return total
|
|
390
|
+
}, 0)
|
|
391
|
+
|
|
392
|
+
let totalReleaseUomValue: number = orderInventories.reduce((total, currentValue) => {
|
|
393
|
+
total += currentValue.releaseUomValue
|
|
394
|
+
return total
|
|
395
|
+
}, 0)
|
|
396
|
+
|
|
397
|
+
let updateOPInfo: any = {
|
|
398
|
+
releaseQty: totalReleaseQty,
|
|
399
|
+
releaseUomValue: totalReleaseUomValue
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
if (totalReleaseQty <= 0) {
|
|
403
|
+
updateOPInfo.status = ORDER_PRODUCT_STATUS.TERMINATED
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
await tx.getRepository(OrderProduct).update({ id: op.id }, updateOPInfo)
|
|
407
|
+
})
|
|
408
|
+
)
|
|
348
409
|
} catch (error) {
|
|
349
410
|
throw error
|
|
350
411
|
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { getRepository, EntityManager, In } from 'typeorm'
|
|
2
|
+
|
|
3
|
+
import { Sequence, SEQUENCE_TYPE } from '@things-factory/id-rule-base'
|
|
4
|
+
import { buildQuery, Domain, ListParam, convertListParams } from '@things-factory/shell'
|
|
5
|
+
import { User } from '@things-factory/auth-base'
|
|
6
|
+
import {
|
|
7
|
+
getMyBizplace,
|
|
8
|
+
getPartnerBizplaceIds,
|
|
9
|
+
getPartnersBizplaces,
|
|
10
|
+
getPartnersCompanyBizplaces,
|
|
11
|
+
getPermittedBizplaceIds,
|
|
12
|
+
Bizplace
|
|
13
|
+
} from '@things-factory/biz-base'
|
|
14
|
+
|
|
15
|
+
import { CommonCode as CommonCodeEntity, CommonCodeDetail as CommonCodeDetailEntity } from '@things-factory/code-base'
|
|
16
|
+
|
|
17
|
+
export const pageSettings = {
|
|
18
|
+
async pageSettings(_: any, { codes, partners }, context: any) {
|
|
19
|
+
const { domain, user, tx }: { domain: Domain; user: User; tx: EntityManager } = context.state
|
|
20
|
+
try {
|
|
21
|
+
let promiseTask = []
|
|
22
|
+
if (codes) {
|
|
23
|
+
promiseTask.push(queryCommonCode(codes, domain, tx, context))
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (partners) {
|
|
27
|
+
promiseTask.push(queryPartners(partners, domain, tx, context))
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return await Promise.all(promiseTask)
|
|
31
|
+
} catch (error) {
|
|
32
|
+
throw error
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async function queryCommonCode(codes, domain, tx, context) {
|
|
38
|
+
const codeQb = tx.getRepository(CommonCodeEntity).createQueryBuilder('cc')
|
|
39
|
+
buildQuery(codeQb, { filters: codes }, context)
|
|
40
|
+
|
|
41
|
+
codes = (await codeQb
|
|
42
|
+
.leftJoinAndSelect('cc.details', 'ccdet')
|
|
43
|
+
.orderBy('cc.name')
|
|
44
|
+
.addOrderBy('ccdet.rank')
|
|
45
|
+
.addOrderBy('ccdet.name')
|
|
46
|
+
.getMany()).map((cc: CommonCodeEntity) => {
|
|
47
|
+
return {
|
|
48
|
+
id: cc.id,
|
|
49
|
+
name: cc.name,
|
|
50
|
+
description: cc.description,
|
|
51
|
+
settingDetails: cc.details.map(det => {
|
|
52
|
+
return {
|
|
53
|
+
id: det.id,
|
|
54
|
+
name: det.name,
|
|
55
|
+
description: det.description,
|
|
56
|
+
rank: det.rank
|
|
57
|
+
}
|
|
58
|
+
})
|
|
59
|
+
}
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
return {
|
|
63
|
+
type: 'code',
|
|
64
|
+
details: codes
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
async function queryPartners(partners, domain, tx, context) {
|
|
69
|
+
let partnersBizplaceIds = []
|
|
70
|
+
let bizplaceIndex: any = partners.filters?.findIndex(x => x.name === 'bizplace')
|
|
71
|
+
if (bizplaceIndex && bizplaceIndex > -1) {
|
|
72
|
+
partnersBizplaceIds = partners.filters
|
|
73
|
+
.filter(x => x.name === 'bizplace')
|
|
74
|
+
.map(item => {
|
|
75
|
+
return item.value
|
|
76
|
+
})
|
|
77
|
+
partners.filters.splice(bizplaceIndex, 1)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const convertedParams = convertListParams({ filters: partners })
|
|
81
|
+
|
|
82
|
+
if (!(partnersBizplaceIds.length > 0)) {
|
|
83
|
+
const partnersBizplaces: Bizplace[] = await getPartnersBizplaces(context.state.domain, context.state.user)
|
|
84
|
+
partnersBizplaceIds = partnersBizplaces.map((bizplace: Bizplace) => bizplace.id || null)
|
|
85
|
+
convertedParams.where.id = In(partnersBizplaceIds)
|
|
86
|
+
} else {
|
|
87
|
+
convertedParams.where.id = In(partnersBizplaceIds)
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
partners = ((await tx.getRepository(Bizplace).find({
|
|
91
|
+
...convertedParams,
|
|
92
|
+
relations: ['domain', 'company', 'users', 'creator', 'updater']
|
|
93
|
+
})).map((biz: Bizplace) => {
|
|
94
|
+
return {
|
|
95
|
+
id: biz.id,
|
|
96
|
+
name: biz.name,
|
|
97
|
+
description: biz.description,
|
|
98
|
+
}
|
|
99
|
+
}))
|
|
100
|
+
|
|
101
|
+
return {
|
|
102
|
+
type: 'partner',
|
|
103
|
+
details: partners
|
|
104
|
+
}
|
|
105
|
+
}
|
|
@@ -1,25 +1,23 @@
|
|
|
1
|
-
import { EntityManager } from 'typeorm'
|
|
2
|
-
|
|
3
1
|
import { User } from '@things-factory/auth-base'
|
|
4
2
|
import { Bizplace } from '@things-factory/biz-base'
|
|
5
|
-
import { ListParam } from '@things-factory/shell'
|
|
3
|
+
import { Filter, ListParam } from '@things-factory/shell'
|
|
6
4
|
|
|
7
5
|
import { rawProductsQuery } from '../../../utils'
|
|
8
6
|
|
|
9
7
|
export const costingReport = {
|
|
10
|
-
async costingReport(_: any, params: ListParam, context:
|
|
8
|
+
async costingReport(_: any, params: ListParam, context: ResolverContext) {
|
|
11
9
|
try {
|
|
12
|
-
const { tx }
|
|
13
|
-
let bizplaceFilter = { name: '', operator: '', value: '' }
|
|
10
|
+
const { tx } = context.state
|
|
11
|
+
let bizplaceFilter: Filter = { name: '', operator: '', value: '' }
|
|
14
12
|
let userFilter = params.filters.find(data => data.name === 'user')
|
|
15
13
|
let fromDate = params.filters.find(data => data.name === 'fromDate')
|
|
16
14
|
let toDate = params.filters.find(data => data.name === 'toDate')
|
|
17
15
|
|
|
18
16
|
if (userFilter) {
|
|
19
|
-
const user
|
|
17
|
+
const user = (await tx.getRepository(User).findOne({
|
|
20
18
|
where: { id: userFilter.value },
|
|
21
19
|
relations: ['bizplaces']
|
|
22
|
-
})
|
|
20
|
+
})) as User & { bizplaces: Bizplace[] }
|
|
23
21
|
|
|
24
22
|
const bizplace: Bizplace = user.bizplaces[0]
|
|
25
23
|
|
|
@@ -32,7 +30,7 @@ export const costingReport = {
|
|
|
32
30
|
|
|
33
31
|
if (!bizplaceFilter || !fromDate || !toDate) throw 'Invalid input'
|
|
34
32
|
|
|
35
|
-
const bizplace: Bizplace = await tx.getRepository(Bizplace).
|
|
33
|
+
const bizplace: Bizplace = await tx.getRepository(Bizplace).findOneBy({
|
|
36
34
|
id: bizplaceFilter.value
|
|
37
35
|
})
|
|
38
36
|
|
|
@@ -97,7 +95,7 @@ export const costingReport = {
|
|
|
97
95
|
WITH RECURSIVE cte_forwarded_cost as (
|
|
98
96
|
select src.domain_id, src.bizplace_id, src.product_id, src.packing_type, src.packing_size, src.uom, TO_DATE(src.created_year_month,'YYYY-MM')::timestamp as running_year_month,
|
|
99
97
|
sum(src.qty) as qty, sum(src.total_cost)/ sum(src.qty) as monthly_avg_cost,
|
|
100
|
-
coalesce(
|
|
98
|
+
coalesce(sum(src.qty)) as closing_qty from (
|
|
101
99
|
select distinct on (pallet_id)
|
|
102
100
|
ih.domain_id, ih.bizplace_id, ih.pallet_id, ih.unit_cost, (ih.unit_cost * (ih.opening_qty + ih.qty)) as total_cost, ih.status, ih.transaction_type, ih.product_id, ih.packing_type, ih.packing_size, coalesce(ih.uom, pd.uom) as uom,
|
|
103
101
|
ih.created_at, to_char(ih.created_at, 'YYYY-MM') as created_year_month,
|
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
import { EntityManager } from 'typeorm'
|
|
2
|
-
|
|
3
1
|
import { User } from '@things-factory/auth-base'
|
|
4
2
|
import { Bizplace } from '@things-factory/biz-base'
|
|
5
|
-
import { ListParam } from '@things-factory/shell'
|
|
3
|
+
import { Filter, ListParam } from '@things-factory/shell'
|
|
6
4
|
|
|
7
5
|
import { rawProductsQuery } from '../../../utils'
|
|
8
6
|
|
|
9
7
|
export const inboundOrderDetailsReport = {
|
|
10
|
-
async inboundOrderDetailsReport(_: any, params: ListParam, context:
|
|
8
|
+
async inboundOrderDetailsReport(_: any, params: ListParam, context: ResolverContext) {
|
|
11
9
|
try {
|
|
12
|
-
const { tx }
|
|
13
|
-
let bizplaceFilter = { name: '', operator: '', value: '' }
|
|
10
|
+
const { tx } = context.state
|
|
11
|
+
let bizplaceFilter: Filter = { name: '', operator: '', value: '' }
|
|
14
12
|
let userFilter = params.filters.find(data => data.name === 'user')
|
|
15
13
|
let fromDate = params.filters.find(data => data.name === 'fromDate')
|
|
16
14
|
let toDate = params.filters.find(data => data.name === 'toDate')
|
|
@@ -20,10 +18,10 @@ export const inboundOrderDetailsReport = {
|
|
|
20
18
|
let doNo = params.filters.find(data => data.name === 'doNo')
|
|
21
19
|
|
|
22
20
|
if (userFilter) {
|
|
23
|
-
const user
|
|
21
|
+
const user = (await tx.getRepository(User).findOne({
|
|
24
22
|
where: { id: userFilter.value },
|
|
25
23
|
relations: ['bizplaces']
|
|
26
|
-
})
|
|
24
|
+
})) as User & { bizplaces: Bizplace[] }
|
|
27
25
|
|
|
28
26
|
const bizplace: Bizplace = user.bizplaces[0]
|
|
29
27
|
|
|
@@ -36,7 +34,7 @@ export const inboundOrderDetailsReport = {
|
|
|
36
34
|
|
|
37
35
|
if (!bizplaceFilter || !fromDate || !toDate) throw 'Invalid input'
|
|
38
36
|
|
|
39
|
-
const bizplace: Bizplace = await tx.getRepository(Bizplace).
|
|
37
|
+
const bizplace: Bizplace = await tx.getRepository(Bizplace).findOneBy({
|
|
40
38
|
id: bizplaceFilter.value
|
|
41
39
|
})
|
|
42
40
|
|
|
@@ -1,26 +1,28 @@
|
|
|
1
|
-
import { EntityManager } from 'typeorm'
|
|
2
|
-
|
|
3
1
|
import { User } from '@things-factory/auth-base'
|
|
4
2
|
import { Bizplace } from '@things-factory/biz-base'
|
|
5
|
-
import { ListParam } from '@things-factory/shell'
|
|
3
|
+
import { Filter, ListParam } from '@things-factory/shell'
|
|
6
4
|
|
|
7
5
|
import { rawProductsQuery } from '../../../utils'
|
|
8
6
|
|
|
9
7
|
export const inboundSerialNumberReport = {
|
|
10
|
-
async inboundSerialNumberReport(_: any, params: ListParam, context:
|
|
8
|
+
async inboundSerialNumberReport(_: any, params: ListParam, context: ResolverContext) {
|
|
11
9
|
try {
|
|
12
|
-
const { tx }
|
|
13
|
-
let bizplaceFilter = { name: '', operator: '', value: '' }
|
|
10
|
+
const { tx } = context.state
|
|
11
|
+
let bizplaceFilter: Filter = { name: '', operator: '', value: '' }
|
|
14
12
|
let userFilter = params.filters.find(data => data.name === 'user')
|
|
15
13
|
let fromDate = params.filters.find(data => data.name === 'fromDate')
|
|
16
14
|
let toDate = params.filters.find(data => data.name === 'toDate')
|
|
17
|
-
let
|
|
15
|
+
let orderNo = params.filters.find(data => data.name === 'orderNo')
|
|
16
|
+
let ref = params.filters.find(data => data.name === 'ref')
|
|
17
|
+
let palletId = params.filters.find(data => data.name === 'palletId')
|
|
18
|
+
let cartonId = params.filters.find(data => data.name === 'cartonId')
|
|
19
|
+
let serialNumber = params.filters.find(data => data.name === 'serialNumber')
|
|
18
20
|
|
|
19
21
|
if (userFilter) {
|
|
20
|
-
const user
|
|
22
|
+
const user = (await tx.getRepository(User).findOne({
|
|
21
23
|
where: { id: userFilter.value },
|
|
22
24
|
relations: ['bizplaces']
|
|
23
|
-
})
|
|
25
|
+
})) as User & { bizplaces: Bizplace[] }
|
|
24
26
|
|
|
25
27
|
const bizplace: Bizplace = user.bizplaces[0]
|
|
26
28
|
|
|
@@ -33,15 +35,40 @@ export const inboundSerialNumberReport = {
|
|
|
33
35
|
|
|
34
36
|
if (!bizplaceFilter || !fromDate || !toDate) throw 'Invalid input'
|
|
35
37
|
|
|
36
|
-
const bizplace: Bizplace = await tx.getRepository(Bizplace).
|
|
38
|
+
const bizplace: Bizplace = await tx.getRepository(Bizplace).findOneBy({
|
|
37
39
|
id: bizplaceFilter.value
|
|
38
40
|
})
|
|
39
41
|
|
|
40
42
|
await rawProductsQuery(tx, params, bizplace)
|
|
41
43
|
|
|
42
44
|
let extraQueryFilters = ''
|
|
43
|
-
if (
|
|
44
|
-
extraQueryFilters = `${extraQueryFilters} and order_no like '%${
|
|
45
|
+
if (orderNo) {
|
|
46
|
+
extraQueryFilters = `${extraQueryFilters} and order_no like '%${orderNo.value}%' `
|
|
47
|
+
}
|
|
48
|
+
if (palletId) {
|
|
49
|
+
extraQueryFilters = `${extraQueryFilters} and pallet_id like '%${palletId.value}%' `
|
|
50
|
+
}
|
|
51
|
+
if (cartonId) {
|
|
52
|
+
extraQueryFilters = `${extraQueryFilters} and carton_id like '%${cartonId.value}%' `
|
|
53
|
+
}
|
|
54
|
+
if (serialNumber) {
|
|
55
|
+
extraQueryFilters = `${extraQueryFilters} and serial_number like '%${serialNumber.value}%' `
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
let refNoQueryFilter = ''
|
|
59
|
+
if (ref) {
|
|
60
|
+
let refValue = ref.value
|
|
61
|
+
.toLowerCase()
|
|
62
|
+
.split(',')
|
|
63
|
+
.map(ref => {
|
|
64
|
+
return "'%" + ref.trim().replace(/'/g, "''") + "%'"
|
|
65
|
+
})
|
|
66
|
+
.join(',')
|
|
67
|
+
refNoQueryFilter = `AND (
|
|
68
|
+
Lower(an.ref_no) LIKE ANY(ARRAY[${refValue}])
|
|
69
|
+
OR Lower(an.ref_no_2) LIKE ANY(ARRAY[${refValue}])
|
|
70
|
+
OR Lower(an.ref_no_3) LIKE ANY(ARRAY[${refValue}])
|
|
71
|
+
)`
|
|
45
72
|
}
|
|
46
73
|
|
|
47
74
|
await tx.query(
|
|
@@ -59,13 +86,14 @@ export const inboundSerialNumberReport = {
|
|
|
59
86
|
coalesce(w.started_at,ii.created_at) as "etd"
|
|
60
87
|
from inventory_items ii
|
|
61
88
|
inner join inventories i on i.id = ii.inventory_id
|
|
62
|
-
inner join
|
|
89
|
+
inner join temp_products p on p.id = i.product_id
|
|
63
90
|
left join product_details pd on pd.product_id = p.id and pd.packing_type = i.packing_type and pd.packing_size = i.packing_size
|
|
64
91
|
left join arrival_notices an on an.id = ii.inbound_order_id::uuid
|
|
65
92
|
left join worksheets w on w.arrival_notice_id = an.id and w.type = 'UNLOADING'
|
|
66
93
|
where
|
|
67
94
|
i.domain_id = $1 and i.bizplace_id = $2
|
|
68
95
|
and coalesce(w.started_at, ii.created_at) between $3 and $4
|
|
96
|
+
${refNoQueryFilter}
|
|
69
97
|
order by coalesce(w.started_at, ii.created_at), p.sku
|
|
70
98
|
) src
|
|
71
99
|
where 1=1
|
|
@@ -5,6 +5,7 @@ import { costingReport } from './costing-report'
|
|
|
5
5
|
import { inboundOrderDetailsReport } from './inbound-order-details-report'
|
|
6
6
|
import { outboundOrderDetailsReport } from './outbound-order-details-report'
|
|
7
7
|
import { productLabelReport } from './product-label-report'
|
|
8
|
+
import { releaseInventoryReport } from './release-inventory-report'
|
|
8
9
|
|
|
9
10
|
export const Query = {
|
|
10
11
|
...inboundSerialNumberReport,
|
|
@@ -12,5 +13,6 @@ export const Query = {
|
|
|
12
13
|
...costingReport,
|
|
13
14
|
...inboundOrderDetailsReport,
|
|
14
15
|
...outboundOrderDetailsReport,
|
|
15
|
-
...productLabelReport
|
|
16
|
+
...productLabelReport,
|
|
17
|
+
...releaseInventoryReport
|
|
16
18
|
}
|