@things-factory/worksheet-base 4.0.11 → 4.0.16
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/dist-server/constants/template.js +1 -0
- package/dist-server/constants/template.js.map +1 -1
- package/dist-server/controllers/ecommerce/sellercraft-controller.js +3 -3
- package/dist-server/controllers/ecommerce/sellercraft-controller.js.map +1 -1
- package/dist-server/controllers/inbound/putaway-worksheet-controller.js +24 -5
- package/dist-server/controllers/inbound/putaway-worksheet-controller.js.map +1 -1
- package/dist-server/controllers/inbound/unloading-worksheet-controller.js +67 -28
- package/dist-server/controllers/inbound/unloading-worksheet-controller.js.map +1 -1
- package/dist-server/controllers/index.js +1 -0
- package/dist-server/controllers/index.js.map +1 -1
- package/dist-server/controllers/outbound/loading-worksheet-controller.js +4 -0
- package/dist-server/controllers/outbound/loading-worksheet-controller.js.map +1 -1
- package/dist-server/controllers/outbound/packing-worksheet-controller.js +1 -3
- package/dist-server/controllers/outbound/packing-worksheet-controller.js.map +1 -1
- package/dist-server/controllers/outbound/picking-worksheet-controller.js +159 -116
- package/dist-server/controllers/outbound/picking-worksheet-controller.js.map +1 -1
- package/dist-server/controllers/render-elccl-grn.js +6 -6
- package/dist-server/controllers/render-elccl-grn.js.map +1 -1
- package/dist-server/controllers/render-manifest.js +64 -0
- package/dist-server/controllers/render-manifest.js.map +1 -0
- package/dist-server/controllers/worksheet-controller.js +28 -2
- package/dist-server/controllers/worksheet-controller.js.map +1 -1
- package/dist-server/graphql/resolvers/pallet/index.js +2 -1
- package/dist-server/graphql/resolvers/pallet/index.js.map +1 -1
- package/dist-server/graphql/resolvers/pallet/pallet-outbound.js +1 -1
- package/dist-server/graphql/resolvers/pallet/pallet-outbound.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/inventories-by-pallet.js +6 -5
- package/dist-server/graphql/resolvers/worksheet/inventories-by-pallet.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/loading-worksheet.js +23 -2
- package/dist-server/graphql/resolvers/worksheet/loading-worksheet.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/packing-worksheet.js +22 -0
- package/dist-server/graphql/resolvers/worksheet/packing-worksheet.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/pending-cancellation-release-order.js +6 -3
- package/dist-server/graphql/resolvers/worksheet/pending-cancellation-release-order.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/picking/activate-picking.js +0 -4
- package/dist-server/graphql/resolvers/worksheet/picking/activate-picking.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/picking/complete-picking.js +30 -5
- package/dist-server/graphql/resolvers/worksheet/picking/complete-picking.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/picking/fetch-and-assign-picking-task.js +72 -0
- package/dist-server/graphql/resolvers/worksheet/picking/fetch-and-assign-picking-task.js.map +1 -0
- package/dist-server/graphql/resolvers/worksheet/picking/index.js +2 -1
- package/dist-server/graphql/resolvers/worksheet/picking/index.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/picking/picking.js +4 -4
- package/dist-server/graphql/resolvers/worksheet/picking/picking.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/picking/scan-product-picking.js +4 -4
- package/dist-server/graphql/resolvers/worksheet/picking/scan-product-picking.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/picking-worksheet.js +86 -57
- package/dist-server/graphql/resolvers/worksheet/picking-worksheet.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/recommend-putway-location.js +40 -7
- package/dist-server/graphql/resolvers/worksheet/recommend-putway-location.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/unloaded-inventories.js +6 -1
- package/dist-server/graphql/resolvers/worksheet/unloaded-inventories.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/unloading-return-worksheet.js +2 -2
- package/dist-server/graphql/resolvers/worksheet/unloading-return-worksheet.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet-detail/generate-release-good-worksheet-details.js +48 -44
- package/dist-server/graphql/resolvers/worksheet-detail/generate-release-good-worksheet-details.js.map +1 -1
- package/dist-server/graphql/types/index.js +9 -4
- package/dist-server/graphql/types/index.js.map +1 -1
- package/dist-server/graphql/types/pallet/index.js +6 -3
- package/dist-server/graphql/types/pallet/index.js.map +1 -1
- package/dist-server/graphql/types/pallet/pallet.js +10 -0
- package/dist-server/graphql/types/pallet/pallet.js.map +1 -0
- package/dist-server/graphql/types/worksheet/index.js +7 -1
- package/dist-server/graphql/types/worksheet/index.js.map +1 -1
- package/dist-server/index.js +1 -0
- package/dist-server/index.js.map +1 -1
- package/dist-server/routes.js +4 -0
- package/dist-server/routes.js.map +1 -1
- package/dist-server/utils/inventory-util.js +50 -5
- package/dist-server/utils/inventory-util.js.map +1 -1
- package/package.json +16 -16
- package/server/constants/template.ts +1 -0
- package/server/controllers/ecommerce/sellercraft-controller.ts +3 -3
- package/server/controllers/inbound/putaway-worksheet-controller.ts +29 -8
- package/server/controllers/inbound/unloading-worksheet-controller.ts +83 -29
- package/server/controllers/index.ts +1 -0
- package/server/controllers/outbound/loading-worksheet-controller.ts +20 -0
- package/server/controllers/outbound/packing-worksheet-controller.ts +3 -5
- package/server/controllers/outbound/picking-worksheet-controller.ts +206 -154
- package/server/controllers/render-elccl-grn.ts +8 -6
- package/server/controllers/render-manifest.ts +68 -0
- package/server/controllers/worksheet-controller.ts +41 -2
- package/server/graphql/resolvers/pallet/index.ts +2 -0
- package/server/graphql/resolvers/pallet/pallet-outbound.ts +1 -2
- package/server/graphql/resolvers/worksheet/inventories-by-pallet.ts +10 -8
- package/server/graphql/resolvers/worksheet/loading-worksheet.ts +30 -4
- package/server/graphql/resolvers/worksheet/packing-worksheet.ts +28 -3
- package/server/graphql/resolvers/worksheet/pending-cancellation-release-order.ts +13 -7
- package/server/graphql/resolvers/worksheet/picking/activate-picking.ts +1 -6
- package/server/graphql/resolvers/worksheet/picking/complete-picking.ts +35 -4
- package/server/graphql/resolvers/worksheet/picking/fetch-and-assign-picking-task.ts +78 -0
- package/server/graphql/resolvers/worksheet/picking/index.ts +3 -1
- package/server/graphql/resolvers/worksheet/picking/picking.ts +6 -4
- package/server/graphql/resolvers/worksheet/picking/scan-product-picking.ts +7 -4
- package/server/graphql/resolvers/worksheet/picking-worksheet.ts +102 -62
- package/server/graphql/resolvers/worksheet/recommend-putway-location.ts +56 -6
- package/server/graphql/resolvers/worksheet/unloaded-inventories.ts +10 -1
- package/server/graphql/resolvers/worksheet/unloading-return-worksheet.ts +6 -4
- package/server/graphql/resolvers/worksheet-detail/generate-release-good-worksheet-details.ts +102 -76
- package/server/graphql/types/index.ts +9 -4
- package/server/graphql/types/pallet/index.ts +8 -2
- package/server/graphql/types/pallet/pallet.ts +7 -0
- package/server/graphql/types/worksheet/index.ts +8 -2
- package/server/index.ts +1 -0
- package/server/routes.ts +5 -0
- package/server/utils/inventory-util.ts +53 -9
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
import { getRepository, In } from 'typeorm'
|
|
2
|
+
|
|
1
3
|
import { ArrivalNotice, ReturnOrder } from '@things-factory/sales-base'
|
|
2
4
|
import { Setting } from '@things-factory/setting-base'
|
|
3
5
|
import { Domain } from '@things-factory/shell'
|
|
4
|
-
import { Location, LOCATION_STATUS, LOCATION_TYPE, Warehouse } from '@things-factory/warehouse-base'
|
|
5
|
-
|
|
6
|
+
import { Inventory, Location, LOCATION_STATUS, LOCATION_TYPE, Warehouse } from '@things-factory/warehouse-base'
|
|
7
|
+
|
|
6
8
|
import { WORKSHEET_STATUS, WORKSHEET_TYPE } from '../../../constants'
|
|
7
9
|
import { Worksheet, WorksheetDetail } from '../../../entities'
|
|
10
|
+
import { isInventoryExpiring } from '../../../utils/inventory-util'
|
|
8
11
|
|
|
9
12
|
export const recommendPutawayLocationResolver = {
|
|
10
13
|
async recommendPutawayLocation(
|
|
@@ -17,14 +20,22 @@ export const recommendPutawayLocationResolver = {
|
|
|
17
20
|
const worksheetDetail: WorksheetDetail = await getRepository(WorksheetDetail).findOne(
|
|
18
21
|
{ domain, name: worksheetDetailName },
|
|
19
22
|
{
|
|
20
|
-
relations: [
|
|
23
|
+
relations: [
|
|
24
|
+
'worksheet',
|
|
25
|
+
'worksheet.arrivalNotice',
|
|
26
|
+
'worksheet.returnOrder',
|
|
27
|
+
'targetInventory',
|
|
28
|
+
'targetInventory.inventory'
|
|
29
|
+
]
|
|
21
30
|
}
|
|
22
31
|
)
|
|
23
32
|
|
|
33
|
+
const inventory: Inventory = worksheetDetail.targetInventory.inventory
|
|
24
34
|
if (worksheetDetail.status !== WORKSHEET_STATUS.EXECUTING) throw new Error('Current target is not processing')
|
|
25
35
|
|
|
26
36
|
const arrivalNotice: ArrivalNotice = worksheetDetail.worksheet.arrivalNotice
|
|
27
37
|
const returnOrder: ReturnOrder = worksheetDetail.worksheet.returnOrder
|
|
38
|
+
|
|
28
39
|
let unloadingWS: Worksheet
|
|
29
40
|
if (arrivalNotice) {
|
|
30
41
|
unloadingWS = await getRepository(Worksheet).findOne({
|
|
@@ -37,19 +48,41 @@ export const recommendPutawayLocationResolver = {
|
|
|
37
48
|
relations: ['bufferLocation', 'bufferLocation.warehouse']
|
|
38
49
|
})
|
|
39
50
|
}
|
|
51
|
+
|
|
40
52
|
const targetWarehouse: Warehouse = unloadingWS.bufferLocation.warehouse
|
|
41
53
|
const sortingLevelSetting: Setting = await getRepository(Setting).findOne({
|
|
42
54
|
where: { domain, name: 'location-recommendation-level' }
|
|
43
55
|
})
|
|
44
56
|
const sortingLevel = sortingLevelSetting?.value
|
|
45
57
|
|
|
58
|
+
const isExpiring: boolean = await isInventoryExpiring(inventory)
|
|
59
|
+
|
|
60
|
+
let recommendedLocations: Location[] = []
|
|
61
|
+
if (isExpiring) {
|
|
62
|
+
switch (sortingLevel) {
|
|
63
|
+
case 'level 1':
|
|
64
|
+
recommendedLocations = await recommendQuarantineLocationLevel1(domain, targetWarehouse, optCnt)
|
|
65
|
+
break
|
|
66
|
+
|
|
67
|
+
default:
|
|
68
|
+
recommendedLocations = await recommendQuarantineLocationLevel1(domain, targetWarehouse, optCnt)
|
|
69
|
+
break
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (recommendedLocations.length > 0) return recommendedLocations
|
|
74
|
+
|
|
46
75
|
switch (sortingLevel) {
|
|
47
76
|
case 'level 1':
|
|
48
|
-
|
|
77
|
+
recommendedLocations = await recommendLocationLevel1(domain, targetWarehouse, optCnt)
|
|
78
|
+
break
|
|
49
79
|
|
|
50
80
|
default:
|
|
51
|
-
|
|
81
|
+
recommendedLocations = await recommendLocationLevel1(domain, targetWarehouse, optCnt)
|
|
82
|
+
break
|
|
52
83
|
}
|
|
84
|
+
|
|
85
|
+
return recommendedLocations
|
|
53
86
|
}
|
|
54
87
|
}
|
|
55
88
|
|
|
@@ -57,6 +90,23 @@ export async function recommendLocationLevel1(
|
|
|
57
90
|
domain: Domain,
|
|
58
91
|
warehouse: Warehouse,
|
|
59
92
|
optCnt: number
|
|
93
|
+
): Promise<Location[]> {
|
|
94
|
+
return await getEmptyLocations(domain, warehouse, optCnt, [LOCATION_TYPE.SHELF, LOCATION_TYPE.FLOOR])
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export async function recommendQuarantineLocationLevel1(
|
|
98
|
+
domain: Domain,
|
|
99
|
+
warehouse: Warehouse,
|
|
100
|
+
optCnt: number
|
|
101
|
+
): Promise<Location[]> {
|
|
102
|
+
return await getEmptyLocations(domain, warehouse, optCnt, [LOCATION_TYPE.QUARANTINE])
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export async function getEmptyLocations(
|
|
106
|
+
domain: Domain,
|
|
107
|
+
warehouse: Warehouse,
|
|
108
|
+
optCnt: number,
|
|
109
|
+
allowedTypes: LOCATION_TYPE[]
|
|
60
110
|
): Promise<Location[]> {
|
|
61
111
|
const orderSetting: Setting = await getRepository(Setting).findOne({
|
|
62
112
|
where: { domain, name: 'rule-for-storing-product' }
|
|
@@ -69,7 +119,7 @@ export async function recommendLocationLevel1(
|
|
|
69
119
|
domain,
|
|
70
120
|
warehouse,
|
|
71
121
|
status: LOCATION_STATUS.EMPTY,
|
|
72
|
-
type:
|
|
122
|
+
type: In(allowedTypes)
|
|
73
123
|
},
|
|
74
124
|
order,
|
|
75
125
|
take: optCnt
|
|
@@ -32,7 +32,7 @@ export const unloadedInventories = {
|
|
|
32
32
|
const returnOrder: ReturnOrder = foundWorksheetDetails[0].worksheet.returnOrder
|
|
33
33
|
const customerBizplace: Bizplace = foundWorksheetDetails[0].bizplace
|
|
34
34
|
if (arrivalNotice) {
|
|
35
|
-
|
|
35
|
+
let foundInv = await getRepository(Inventory).find({
|
|
36
36
|
where: {
|
|
37
37
|
domain,
|
|
38
38
|
bizplace: customerBizplace,
|
|
@@ -44,6 +44,15 @@ export const unloadedInventories = {
|
|
|
44
44
|
},
|
|
45
45
|
relations: ['reusablePallet', 'product', 'bizplace']
|
|
46
46
|
})
|
|
47
|
+
const items = foundInv.map((inv: Inventory) => {
|
|
48
|
+
const expirationDate: Date = inv.expirationDate ? new Date(inv.expirationDate) : null
|
|
49
|
+
return {
|
|
50
|
+
...inv,
|
|
51
|
+
expirationDate: expirationDate
|
|
52
|
+
}
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
return items
|
|
47
56
|
}
|
|
48
57
|
|
|
49
58
|
if (returnOrder) {
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
import { getRepository } from 'typeorm'
|
|
2
|
+
|
|
1
3
|
import { Bizplace } from '@things-factory/biz-base'
|
|
4
|
+
import { OrderInventory, ReturnOrder } from '@things-factory/sales-base'
|
|
2
5
|
import { Domain } from '@things-factory/shell'
|
|
3
|
-
|
|
4
|
-
import { fetchExecutingWorksheet } from '../../../utils'
|
|
5
|
-
import { ReturnOrder, OrderInventory } from '@things-factory/sales-base'
|
|
6
|
+
|
|
6
7
|
import { WORKSHEET_TYPE } from '../../../constants'
|
|
7
8
|
import { Worksheet, WorksheetDetail } from '../../../entities'
|
|
9
|
+
import { fetchExecutingWorksheet } from '../../../utils'
|
|
8
10
|
|
|
9
11
|
export const unloadingReturnWorksheetResolver = {
|
|
10
12
|
async unloadingReturnWorksheet(_: any, { returnOrderNo }, context: any) {
|
|
@@ -59,7 +61,7 @@ export const unloadingReturnWorksheetResolver = {
|
|
|
59
61
|
description: productWSD.description,
|
|
60
62
|
targetName: targetInventory.name,
|
|
61
63
|
packingType: targetInventory.packingType,
|
|
62
|
-
packingSize: targetInventory.packingSize,
|
|
64
|
+
packingSize: targetInventory.inventory.packingSize,
|
|
63
65
|
palletQty: targetInventory.palletQty,
|
|
64
66
|
actualPalletQty: targetInventory.actualPalletQty,
|
|
65
67
|
packQty: targetInventory.returnQty,
|
package/server/graphql/resolvers/worksheet-detail/generate-release-good-worksheet-details.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { Domain } from '@things-factory/shell'
|
|
2
1
|
import { EntityManager } from 'typeorm'
|
|
3
|
-
|
|
4
|
-
import { OrderInventory, OrderNoGenerator, ORDER_INVENTORY_STATUS } from '@things-factory/sales-base'
|
|
5
|
-
import { Product } from '@things-factory/product-base'
|
|
2
|
+
|
|
6
3
|
import { User } from '@things-factory/auth-base'
|
|
4
|
+
import { Product } from '@things-factory/product-base'
|
|
5
|
+
import { ORDER_INVENTORY_STATUS, OrderInventory, OrderNoGenerator } from '@things-factory/sales-base'
|
|
6
|
+
import { Domain } from '@things-factory/shell'
|
|
7
|
+
import { Inventory } from '@things-factory/warehouse-base'
|
|
8
|
+
|
|
7
9
|
import { WORKSHEET_STATUS, WORKSHEET_TYPE } from '../../../constants'
|
|
8
10
|
import { Worksheet, WorksheetDetail } from '../../../entities'
|
|
9
11
|
import { WorksheetNoGenerator } from '../../../utils'
|
|
@@ -14,84 +16,108 @@ export const generateReleaseGoodWorksheetDetailsResolver = {
|
|
|
14
16
|
{ worksheetNo, batchId, productId, packingType, packingSize, worksheetDetails },
|
|
15
17
|
context: any
|
|
16
18
|
): Promise<void> {
|
|
17
|
-
const { tx,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
19
|
+
const { tx, domain, user }: { tx: EntityManager; domain: Domain; user: User } = context.state
|
|
20
|
+
return await generateReleaseGoodWorksheetDetails(
|
|
21
|
+
tx,
|
|
22
|
+
domain,
|
|
23
|
+
user,
|
|
24
|
+
worksheetNo,
|
|
25
|
+
batchId,
|
|
26
|
+
productId,
|
|
27
|
+
packingType,
|
|
28
|
+
packingSize,
|
|
29
|
+
worksheetDetails
|
|
30
|
+
)
|
|
31
|
+
}
|
|
32
|
+
}
|
|
29
33
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
export async function generateReleaseGoodWorksheetDetails(
|
|
35
|
+
tx: EntityManager,
|
|
36
|
+
domain: Domain,
|
|
37
|
+
user: User,
|
|
38
|
+
worksheetNo: string,
|
|
39
|
+
batchId: string,
|
|
40
|
+
productId: string,
|
|
41
|
+
packingType: string,
|
|
42
|
+
packingSize: number,
|
|
43
|
+
worksheetDetails: Partial<WorksheetDetail>[]
|
|
44
|
+
): Promise<void> {
|
|
45
|
+
// 1. Remove prev worksheet details if it's exists
|
|
46
|
+
const worksheet: Worksheet = await tx.getRepository(Worksheet).findOne({
|
|
47
|
+
where: { name: worksheetNo, domain },
|
|
48
|
+
relations: [
|
|
49
|
+
'bizplace',
|
|
50
|
+
'releaseGood',
|
|
51
|
+
'worksheetDetails',
|
|
52
|
+
'worksheetDetails.targetInventory',
|
|
53
|
+
'worksheetDetails.targetInventory.product'
|
|
54
|
+
]
|
|
55
|
+
})
|
|
35
56
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
57
|
+
const prevWSDs: WorksheetDetail[] = worksheet.worksheetDetails.filter((wsd: WorksheetDetail) => {
|
|
58
|
+
const targetInv: OrderInventory = wsd.targetInventory
|
|
59
|
+
if (targetInv.batchId === batchId && targetInv.product.id === productId && targetInv.packingType === packingType)
|
|
60
|
+
return wsd.id
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
// TODO: Delete order inventories
|
|
64
|
+
if (prevWSDs?.length) {
|
|
65
|
+
const wsdIds: string[] = prevWSDs.map((wsd: WorksheetDetail) => wsd.id)
|
|
66
|
+
const prevOrderInvIds: string[] = prevWSDs.map((wsd: WorksheetDetail) => wsd.targetInventory.id)
|
|
67
|
+
await tx.getRepository(WorksheetDetail).delete(wsdIds)
|
|
68
|
+
await tx.getRepository(OrderInventory).delete(prevOrderInvIds)
|
|
69
|
+
}
|
|
43
70
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
71
|
+
await Promise.all(
|
|
72
|
+
worksheetDetails.map(async (wsd: WorksheetDetail) => {
|
|
73
|
+
// 2. Create order inventory
|
|
74
|
+
let targetInventory: OrderInventory = wsd.targetInventory
|
|
75
|
+
const inventory: Inventory = await tx.getRepository(Inventory).findOne(targetInventory.inventory.id)
|
|
49
76
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
77
|
+
targetInventory = await tx.getRepository(OrderInventory).save({
|
|
78
|
+
...targetInventory,
|
|
79
|
+
domain,
|
|
80
|
+
bizplace: worksheet.bizplace,
|
|
81
|
+
name: OrderNoGenerator.orderInventory(),
|
|
82
|
+
releaseGood: worksheet.releaseGood,
|
|
83
|
+
inventory,
|
|
84
|
+
batchId,
|
|
85
|
+
batchIdRef: inventory.batchIdRef,
|
|
86
|
+
status: ORDER_INVENTORY_STATUS.READY_TO_PICK,
|
|
87
|
+
product: await tx.getRepository(Product).findOne(productId),
|
|
88
|
+
packingType,
|
|
89
|
+
packingSize,
|
|
90
|
+
creator: user,
|
|
91
|
+
updater: user
|
|
92
|
+
})
|
|
66
93
|
|
|
67
|
-
|
|
68
|
-
|
|
94
|
+
const currentLockedQty: any = inventory.lockedQty
|
|
95
|
+
const currentLockedUomValue: any = inventory.lockedUomValue
|
|
69
96
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
97
|
+
await tx.getRepository(Inventory).save({
|
|
98
|
+
...targetInventory.inventory,
|
|
99
|
+
lockedQty: Boolean(currentLockedQty)
|
|
100
|
+
? targetInventory.releaseQty + currentLockedQty
|
|
101
|
+
: targetInventory.releaseQty,
|
|
102
|
+
lockedUomValue: Boolean(currentLockedUomValue)
|
|
103
|
+
? targetInventory.releaseUomValue + currentLockedUomValue
|
|
104
|
+
: targetInventory.releaseUomValue,
|
|
105
|
+
updater: user
|
|
106
|
+
})
|
|
80
107
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
})
|
|
108
|
+
// 3. Create worksheet details
|
|
109
|
+
await tx.getRepository(WorksheetDetail).save({
|
|
110
|
+
...wsd,
|
|
111
|
+
domain,
|
|
112
|
+
bizplace: worksheet.bizplace,
|
|
113
|
+
worksheet,
|
|
114
|
+
name: WorksheetNoGenerator.pickingDetail(),
|
|
115
|
+
targetInventory,
|
|
116
|
+
type: WORKSHEET_TYPE.PICKING,
|
|
117
|
+
status: WORKSHEET_STATUS.DEACTIVATED,
|
|
118
|
+
creator: user,
|
|
119
|
+
updater: user
|
|
94
120
|
})
|
|
95
|
-
)
|
|
96
|
-
|
|
121
|
+
})
|
|
122
|
+
)
|
|
97
123
|
}
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
import * as Pallet from './pallet'
|
|
2
1
|
import * as Worksheet from './worksheet'
|
|
3
2
|
import * as WorksheetDetail from './worksheet-detail'
|
|
4
3
|
import * as WorksheetMovement from './worksheet-movement'
|
|
4
|
+
import * as PalletOutbound from './pallet'
|
|
5
5
|
|
|
6
|
-
export const queries = [Worksheet.Query, WorksheetDetail.Query, WorksheetMovement.Query]
|
|
6
|
+
export const queries = [Worksheet.Query, WorksheetDetail.Query, WorksheetMovement.Query, PalletOutbound.Query]
|
|
7
7
|
|
|
8
|
-
export const mutations = [
|
|
8
|
+
export const mutations = [
|
|
9
|
+
Worksheet.Mutation,
|
|
10
|
+
WorksheetDetail.Mutation,
|
|
11
|
+
WorksheetMovement.Mutation,
|
|
12
|
+
PalletOutbound.Mutation
|
|
13
|
+
]
|
|
9
14
|
|
|
10
|
-
export const types = [...Worksheet.Types, ...WorksheetDetail.Types, ...WorksheetMovement.Types]
|
|
15
|
+
export const types = [...Worksheet.Types, ...WorksheetDetail.Types, ...WorksheetMovement.Types, ...PalletOutbound.Types]
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
+
import { PalletPatch } from './pallet'
|
|
2
|
+
|
|
1
3
|
export const Mutation = /* GraphQL */ `
|
|
2
|
-
palletOutbound(
|
|
4
|
+
palletOutbound (
|
|
3
5
|
refOrderNo: String!
|
|
4
|
-
patches: [PalletPatch]
|
|
6
|
+
patches: [PalletPatch]
|
|
5
7
|
): Boolean @transaction
|
|
6
8
|
`
|
|
9
|
+
|
|
10
|
+
export const Types = /* GraphQL */ [PalletPatch]
|
|
11
|
+
|
|
12
|
+
export const Query = /* GraphQL */ ``
|
|
@@ -290,6 +290,8 @@ export const Mutation = /* GraphQL */ `
|
|
|
290
290
|
cartonId: String
|
|
291
291
|
locationName: String!
|
|
292
292
|
releaseQty: Int!
|
|
293
|
+
binLocation: String
|
|
294
|
+
serialNumber: String
|
|
293
295
|
): Boolean @privilege(category: "worksheet_execute", privilege: "mutation") @transaction
|
|
294
296
|
|
|
295
297
|
scanProductPicking (
|
|
@@ -298,6 +300,7 @@ export const Mutation = /* GraphQL */ `
|
|
|
298
300
|
productBarcode: String!
|
|
299
301
|
cartonId: String!
|
|
300
302
|
binLocation: String
|
|
303
|
+
serialNumber: String
|
|
301
304
|
): Boolean @privilege(category: "worksheet_execute", privilege: "mutation") @transaction
|
|
302
305
|
|
|
303
306
|
sortingProduct (
|
|
@@ -515,6 +518,9 @@ export const Mutation = /* GraphQL */ `
|
|
|
515
518
|
worksheetId: String!
|
|
516
519
|
userId: String!
|
|
517
520
|
): Boolean @privilege(category: "worksheet_control", privilege: "mutation") @transaction
|
|
521
|
+
|
|
522
|
+
fetchAndAssignPickingTask
|
|
523
|
+
: ExecutingWorksheet @privilege(category: "worksheet_control", privilege: "mutation") @transaction
|
|
518
524
|
|
|
519
525
|
palletizingPallets (
|
|
520
526
|
refOrderNo: String!
|
|
@@ -588,7 +594,7 @@ export const Query = /* GraphQL */ `
|
|
|
588
594
|
|
|
589
595
|
pickingWorksheet (
|
|
590
596
|
releaseGoodNo: String!, locationSortingRules: [Sorting]
|
|
591
|
-
): ExecutingWorksheet @privilege(category: "worksheet", privilege: "query")
|
|
597
|
+
): ExecutingWorksheet @privilege(category: "worksheet", privilege: "query") @transaction
|
|
592
598
|
|
|
593
599
|
sortingWorksheet (
|
|
594
600
|
releaseGoodNo: String!
|
|
@@ -662,7 +668,7 @@ export const Query = /* GraphQL */ `
|
|
|
662
668
|
findReleaseOrdersByTaskNo(taskNo: String!): [ReleaseGood] @privilege(category: "worksheet", privilege: "query") @transaction
|
|
663
669
|
`
|
|
664
670
|
|
|
665
|
-
export const Types = /* GraphQL */
|
|
671
|
+
export const Types = /* GraphQL */[
|
|
666
672
|
Worksheet,
|
|
667
673
|
AirwayBill,
|
|
668
674
|
NewWorksheet,
|
package/server/index.ts
CHANGED
|
@@ -4,4 +4,5 @@ export * from './constants'
|
|
|
4
4
|
export * from './entities'
|
|
5
5
|
export * from './graphql'
|
|
6
6
|
export * from './graphql/resolvers/worksheet/generate-worksheet/generate-release-good-worksheet'
|
|
7
|
+
export * from './graphql/resolvers/worksheet-detail/generate-release-good-worksheet-details'
|
|
7
8
|
export * from './migrations'
|
package/server/routes.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { renderElcclGRN } from './controllers/render-elccl-grn'
|
|
|
2
2
|
import { renderGRN } from './controllers/render-grn'
|
|
3
3
|
import { renderJobSheet } from './controllers/render-job-sheet'
|
|
4
4
|
import { renderKimedaGRN } from './controllers/render-kimeda-grn'
|
|
5
|
+
import { renderManifest } from './controllers/render-manifest'
|
|
5
6
|
import { renderManualDO } from './controllers/render-manual-do'
|
|
6
7
|
import { renderOrientageDO } from './controllers/render-orientage-do'
|
|
7
8
|
import { renderOrientageGRN } from './controllers/render-orientage-grn'
|
|
@@ -44,4 +45,8 @@ process.on('bootstrap-module-domain-private-route' as any, (app, routes) => {
|
|
|
44
45
|
routes.get('/view_job_sheet/:ganNo/:timezoneOffSet', async (context, next) => {
|
|
45
46
|
context.body = await renderJobSheet(context.params, context)
|
|
46
47
|
})
|
|
48
|
+
|
|
49
|
+
routes.get('/view_manifest/:manifestNo', async (context, next) => {
|
|
50
|
+
context.body = await renderManifest(context.params, context)
|
|
51
|
+
})
|
|
47
52
|
})
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
EntityManager,
|
|
3
|
-
getRepository,
|
|
4
|
-
Repository
|
|
5
|
-
} from 'typeorm'
|
|
1
|
+
import { EntityManager, getRepository, Repository } from 'typeorm'
|
|
6
2
|
|
|
7
3
|
import { User } from '@things-factory/auth-base'
|
|
8
4
|
import { Bizplace } from '@things-factory/biz-base'
|
|
@@ -63,10 +59,36 @@ export async function generateInventoryHistory(
|
|
|
63
59
|
palletId: inventory.palletId,
|
|
64
60
|
seq: seq - 1
|
|
65
61
|
})
|
|
62
|
+
|
|
66
63
|
openingQty = lastInvHistory.openingQty + lastInvHistory.qty
|
|
67
64
|
openingUomValue = lastInvHistory.openingUomValue + lastInvHistory.uomValue
|
|
68
65
|
}
|
|
69
66
|
|
|
67
|
+
if (transactionType == 'PICKING' || transactionType == 'UNLOADING') {
|
|
68
|
+
const [findSameOrderHistory, total]: InventoryHistory = await invHistoryRepo.findAndCount({
|
|
69
|
+
domain: inventory.domain,
|
|
70
|
+
palletId: inventory.palletId,
|
|
71
|
+
refOrderId: refOrder.id
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
if (findSameOrderHistory) {
|
|
75
|
+
let prevTotalQty = 0
|
|
76
|
+
let prevTotalUomValue = 0
|
|
77
|
+
for (let oh of findSameOrderHistory) {
|
|
78
|
+
prevTotalQty += oh.qty
|
|
79
|
+
prevTotalUomValue += oh.uomValue
|
|
80
|
+
}
|
|
81
|
+
qty -= prevTotalQty
|
|
82
|
+
uomValue -= prevTotalUomValue
|
|
83
|
+
}
|
|
84
|
+
} else if (transactionType == 'UNDO_UNLOADING' || transactionType == 'RETURN') {
|
|
85
|
+
qty = qty
|
|
86
|
+
uomValue = uomValue
|
|
87
|
+
} else {
|
|
88
|
+
qty = 0
|
|
89
|
+
uomValue = 0
|
|
90
|
+
}
|
|
91
|
+
|
|
70
92
|
let inventoryHistory: InventoryHistory = new InventoryHistory()
|
|
71
93
|
inventoryHistory.name = InventoryNoGenerator.inventoryHistoryName()
|
|
72
94
|
inventoryHistory.description = inventory.description
|
|
@@ -93,8 +115,6 @@ export async function generateInventoryHistory(
|
|
|
93
115
|
inventoryHistory.uom = inventory.uom
|
|
94
116
|
inventoryHistory.qty = qty
|
|
95
117
|
inventoryHistory.openingQty = openingQty
|
|
96
|
-
inventoryHistory.weight = 0
|
|
97
|
-
inventoryHistory.openingWeight = 0
|
|
98
118
|
inventoryHistory.uomValue = uomValue
|
|
99
119
|
inventoryHistory.openingUomValue = openingUomValue
|
|
100
120
|
inventoryHistory.unitCost = inventory.unitCost
|
|
@@ -221,7 +241,7 @@ export async function checkPalletIdenticallity(
|
|
|
221
241
|
* @param trxMgr
|
|
222
242
|
*/
|
|
223
243
|
export async function inventoriesByStrategy(
|
|
224
|
-
{ worksheetId, batchId, bizplaceId, productId, packingType, packingSize, pickingStrategy, locationSortingRules },
|
|
244
|
+
{ worksheetId, batchId, bizplaceId, productId, packingType, packingSize, uom, pickingStrategy, locationSortingRules },
|
|
225
245
|
domain: Domain,
|
|
226
246
|
trxMgr: EntityManager
|
|
227
247
|
) {
|
|
@@ -248,12 +268,14 @@ export async function inventoriesByStrategy(
|
|
|
248
268
|
.andWhere('"PROD"."id" = :productId')
|
|
249
269
|
.andWhere('"INV"."packing_type" = :packingType')
|
|
250
270
|
.andWhere('"INV"."packing_size" = :packingSize')
|
|
271
|
+
.andWhere('"INV"."uom" = :uom')
|
|
251
272
|
.andWhere('"INV"."status" = :status', { status: 'STORED' })
|
|
252
273
|
.setParameters({
|
|
253
274
|
domainId: domain.id,
|
|
254
275
|
productId,
|
|
255
276
|
packingType,
|
|
256
|
-
packingSize
|
|
277
|
+
packingSize,
|
|
278
|
+
uom
|
|
257
279
|
})
|
|
258
280
|
|
|
259
281
|
if (batchId !== '') {
|
|
@@ -348,3 +370,25 @@ export async function inventoriesByStrategy(
|
|
|
348
370
|
const total: number = await qb.getCount()
|
|
349
371
|
return { items, total }
|
|
350
372
|
}
|
|
373
|
+
|
|
374
|
+
export async function isInventoryExpiring(inventory: Inventory): Promise<boolean> {
|
|
375
|
+
if (!inventory.id) throw new Error('No inventory id provided')
|
|
376
|
+
let product: Product | undefined = inventory.product
|
|
377
|
+
if (!product) {
|
|
378
|
+
inventory = await getRepository(Inventory).findOne(inventory.id, {
|
|
379
|
+
relations: ['product']
|
|
380
|
+
})
|
|
381
|
+
product = inventory.product
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
const { expirationDate } = inventory
|
|
385
|
+
const { isRequiredCheckExpiry, expirationPeriod } = product
|
|
386
|
+
|
|
387
|
+
if (!isRequiredCheckExpiry || !expirationPeriod || expirationDate <= 0) return false
|
|
388
|
+
|
|
389
|
+
let date: Date = new Date()
|
|
390
|
+
const acceptBefore: Date = new Date(date.setDate(date.getDate() + expirationPeriod))
|
|
391
|
+
const expiryDate: Date = new Date(expirationDate)
|
|
392
|
+
|
|
393
|
+
return expiryDate < acceptBefore
|
|
394
|
+
}
|