@things-factory/worksheet-base 4.0.0-y.0 → 4.0.4
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/controllers/ecommerce/ecommerce-controller.js +23 -9
- package/dist-server/controllers/ecommerce/ecommerce-controller.js.map +1 -1
- package/dist-server/controllers/ecommerce/index.js +1 -0
- package/dist-server/controllers/ecommerce/index.js.map +1 -1
- package/dist-server/controllers/ecommerce/sellercraft-controller.js +168 -0
- package/dist-server/controllers/ecommerce/sellercraft-controller.js.map +1 -0
- package/dist-server/controllers/inbound/unloading-worksheet-controller.js +6 -5
- 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/inspect/cycle-count-worksheet-controller.js +43 -8
- package/dist-server/controllers/inspect/cycle-count-worksheet-controller.js.map +1 -1
- package/dist-server/controllers/outbound/packing-worksheet-controller.js +16 -1
- package/dist-server/controllers/outbound/packing-worksheet-controller.js.map +1 -1
- package/dist-server/controllers/outbound/picking-worksheet-controller.js +17 -9
- package/dist-server/controllers/outbound/picking-worksheet-controller.js.map +1 -1
- package/dist-server/controllers/render-grn.js +192 -0
- package/dist-server/controllers/render-grn.js.map +1 -0
- package/dist-server/controllers/render-job-sheet.js +51 -35
- package/dist-server/controllers/render-job-sheet.js.map +1 -1
- package/dist-server/controllers/render-kimeda-grn.js +12 -5
- package/dist-server/controllers/render-kimeda-grn.js.map +1 -1
- package/dist-server/controllers/render-ro-do.js +19 -5
- package/dist-server/controllers/render-ro-do.js.map +1 -1
- package/dist-server/controllers/render-seebuu-grn.js +9 -3
- package/dist-server/controllers/render-seebuu-grn.js.map +1 -1
- package/dist-server/controllers/vas/vas-worksheet-controller.js +75 -14
- package/dist-server/controllers/vas/vas-worksheet-controller.js.map +1 -1
- package/dist-server/controllers/worksheet-controller.js +61 -8
- package/dist-server/controllers/worksheet-controller.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/cycle-count-adjustment.js +23 -1
- package/dist-server/graphql/resolvers/worksheet/cycle-count-adjustment.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/cycle-count-worksheet.js +4 -2
- package/dist-server/graphql/resolvers/worksheet/cycle-count-worksheet.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/fetch-sellercraft-airway-bill.js +25 -0
- package/dist-server/graphql/resolvers/worksheet/fetch-sellercraft-airway-bill.js.map +1 -0
- package/dist-server/graphql/resolvers/worksheet/generate-worksheet/generate-cycle-count-worksheet.js +4 -4
- package/dist-server/graphql/resolvers/worksheet/generate-worksheet/generate-cycle-count-worksheet.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/index.js +5 -4
- package/dist-server/graphql/resolvers/worksheet/index.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/not-tally-target-inventories.js +2 -2
- package/dist-server/graphql/resolvers/worksheet/not-tally-target-inventories.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/packing/activate-packing.js +13 -1
- package/dist-server/graphql/resolvers/worksheet/packing/activate-packing.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/packing/complete-packing.js +24 -38
- package/dist-server/graphql/resolvers/worksheet/packing/complete-packing.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/packing/packing.js +13 -1
- package/dist-server/graphql/resolvers/worksheet/packing/packing.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/packing/scan-product-packing.js +13 -1
- package/dist-server/graphql/resolvers/worksheet/packing/scan-product-packing.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/packing-worksheet.js +60 -19
- package/dist-server/graphql/resolvers/worksheet/packing-worksheet.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/picking/activate-batch-picking.js +20 -1
- package/dist-server/graphql/resolvers/worksheet/picking/activate-batch-picking.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/picking/activate-picking.js +24 -14
- package/dist-server/graphql/resolvers/worksheet/picking/activate-picking.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/picking/assign-picking-inventories.js +4 -4
- package/dist-server/graphql/resolvers/worksheet/picking/assign-picking-inventories.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/picking/complete-batch-picking.js +19 -0
- package/dist-server/graphql/resolvers/worksheet/picking/complete-batch-picking.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/picking/complete-picking.js +124 -149
- package/dist-server/graphql/resolvers/worksheet/picking/complete-picking.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/picking/undo-picking-assignment.js +4 -4
- package/dist-server/graphql/resolvers/worksheet/picking/undo-picking-assignment.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/picking-worksheet.js +2 -1
- package/dist-server/graphql/resolvers/worksheet/picking-worksheet.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/recommend-putway-location.js +1 -1
- package/dist-server/graphql/resolvers/worksheet/recommend-putway-location.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/replace-picking-pallets.js +13 -4
- package/dist-server/graphql/resolvers/worksheet/replace-picking-pallets.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/unloading/complete-unloading.js +21 -2
- package/dist-server/graphql/resolvers/worksheet/unloading/complete-unloading.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/unloading-return/complete-unload-returning.js +18 -1
- package/dist-server/graphql/resolvers/worksheet/unloading-return/complete-unload-returning.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/vas-transactions/common-utils.js +302 -11
- package/dist-server/graphql/resolvers/worksheet/vas-transactions/common-utils.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/vas-transactions/interfaces/index.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/vas-transactions/interfaces/repackaging.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/vas-transactions/repackaging/complete-repackaging.js +137 -31
- package/dist-server/graphql/resolvers/worksheet/vas-transactions/repackaging/complete-repackaging.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/vas-transactions/repackaging/repackaging.js +157 -42
- package/dist-server/graphql/resolvers/worksheet/vas-transactions/repackaging/repackaging.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/vas-transactions/repackaging/undo-repackaging.js +35 -21
- package/dist-server/graphql/resolvers/worksheet/vas-transactions/repackaging/undo-repackaging.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/worksheet.js +33 -27
- package/dist-server/graphql/resolvers/worksheet/worksheet.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/worksheets.js +39 -10
- package/dist-server/graphql/resolvers/worksheet/worksheets.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet-detail/generate-batch-picking-worksheet-details-by-bulk.js +1 -1
- package/dist-server/graphql/resolvers/worksheet-detail/generate-batch-picking-worksheet-details-by-bulk.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet-detail/generate-release-good-worksheet-details.js +3 -2
- package/dist-server/graphql/resolvers/worksheet-detail/generate-release-good-worksheet-details.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet-detail/worksheet-details-by-product-group.js +3 -2
- package/dist-server/graphql/resolvers/worksheet-detail/worksheet-details-by-product-group.js.map +1 -1
- package/dist-server/graphql/types/index.js +2 -1
- package/dist-server/graphql/types/index.js.map +1 -1
- package/dist-server/graphql/types/pallet/index.js +10 -0
- package/dist-server/graphql/types/pallet/index.js.map +1 -0
- package/dist-server/graphql/types/worksheet/airwaybill.js +10 -0
- package/dist-server/graphql/types/worksheet/airwaybill.js.map +1 -0
- package/dist-server/graphql/types/worksheet/index.js +10 -2
- package/dist-server/graphql/types/worksheet/index.js.map +1 -1
- package/dist-server/graphql/types/worksheet/worksheet-info.js +2 -0
- package/dist-server/graphql/types/worksheet/worksheet-info.js.map +1 -1
- package/dist-server/graphql/types/worksheet-detail/index.js +2 -1
- package/dist-server/graphql/types/worksheet-detail/index.js.map +1 -1
- package/dist-server/graphql/types/worksheet-detail/inventory-detail.js +1 -0
- package/dist-server/graphql/types/worksheet-detail/inventory-detail.js.map +1 -1
- package/dist-server/routes.js +10 -6
- package/dist-server/routes.js.map +1 -1
- package/dist-server/utils/inventory-util.js +7 -3
- package/dist-server/utils/inventory-util.js.map +1 -1
- package/package.json +16 -15
- package/server/controllers/ecommerce/ecommerce-controller.ts +37 -10
- package/server/controllers/ecommerce/index.ts +1 -0
- package/server/controllers/ecommerce/sellercraft-controller.ts +223 -0
- package/server/controllers/inbound/unloading-worksheet-controller.ts +16 -13
- package/server/controllers/index.ts +1 -0
- package/server/controllers/inspect/cycle-count-worksheet-controller.ts +108 -43
- package/server/controllers/outbound/packing-worksheet-controller.ts +21 -4
- package/server/controllers/outbound/picking-worksheet-controller.ts +26 -11
- package/server/controllers/render-grn.ts +218 -0
- package/server/controllers/render-job-sheet.ts +51 -39
- package/server/controllers/render-kimeda-grn.ts +16 -12
- package/server/controllers/render-ro-do.ts +22 -6
- package/server/controllers/render-seebuu-grn.ts +12 -12
- package/server/controllers/vas/vas-worksheet-controller.ts +104 -23
- package/server/controllers/worksheet-controller.ts +87 -22
- package/server/graphql/resolvers/pallet/pallet-outbound.ts +2 -1
- package/server/graphql/resolvers/worksheet/cycle-count-adjustment.ts +30 -2
- package/server/graphql/resolvers/worksheet/cycle-count-worksheet.ts +7 -4
- package/server/graphql/resolvers/worksheet/fetch-sellercraft-airway-bill.ts +30 -0
- package/server/graphql/resolvers/worksheet/generate-worksheet/generate-cycle-count-worksheet.ts +18 -3
- package/server/graphql/resolvers/worksheet/index.ts +6 -4
- package/server/graphql/resolvers/worksheet/not-tally-target-inventories.ts +4 -2
- package/server/graphql/resolvers/worksheet/packing/activate-packing.ts +20 -3
- package/server/graphql/resolvers/worksheet/packing/complete-packing.ts +30 -49
- package/server/graphql/resolvers/worksheet/packing/packing.ts +22 -3
- package/server/graphql/resolvers/worksheet/packing/scan-product-packing.ts +22 -3
- package/server/graphql/resolvers/worksheet/packing-worksheet.ts +71 -20
- package/server/graphql/resolvers/worksheet/picking/activate-batch-picking.ts +32 -3
- package/server/graphql/resolvers/worksheet/picking/activate-picking.ts +31 -17
- package/server/graphql/resolvers/worksheet/picking/assign-picking-inventories.ts +4 -3
- package/server/graphql/resolvers/worksheet/picking/complete-batch-picking.ts +31 -3
- package/server/graphql/resolvers/worksheet/picking/complete-picking.ts +143 -175
- package/server/graphql/resolvers/worksheet/picking/undo-picking-assignment.ts +5 -4
- package/server/graphql/resolvers/worksheet/picking-worksheet.ts +5 -2
- package/server/graphql/resolvers/worksheet/recommend-putway-location.ts +1 -1
- package/server/graphql/resolvers/worksheet/replace-picking-pallets.ts +22 -9
- package/server/graphql/resolvers/worksheet/unloading/complete-unloading.ts +27 -4
- package/server/graphql/resolvers/worksheet/unloading-return/complete-unload-returning.ts +23 -2
- package/server/graphql/resolvers/worksheet/vas-transactions/common-utils.ts +452 -14
- package/server/graphql/resolvers/worksheet/vas-transactions/interfaces/index.ts +36 -1
- package/server/graphql/resolvers/worksheet/vas-transactions/interfaces/repackaging.ts +8 -2
- package/server/graphql/resolvers/worksheet/vas-transactions/repackaging/complete-repackaging.ts +185 -56
- package/server/graphql/resolvers/worksheet/vas-transactions/repackaging/repackaging.ts +210 -54
- package/server/graphql/resolvers/worksheet/vas-transactions/repackaging/undo-repackaging.ts +64 -32
- package/server/graphql/resolvers/worksheet/worksheet.ts +67 -62
- package/server/graphql/resolvers/worksheet/worksheets.ts +51 -13
- package/server/graphql/resolvers/worksheet-detail/generate-batch-picking-worksheet-details-by-bulk.ts +1 -0
- package/server/graphql/resolvers/worksheet-detail/generate-release-good-worksheet-details.ts +2 -1
- package/server/graphql/resolvers/worksheet-detail/worksheet-details-by-product-group.ts +2 -1
- package/server/graphql/types/index.ts +2 -1
- package/server/graphql/types/pallet/index.ts +6 -0
- package/server/graphql/types/worksheet/airwaybill.ts +7 -0
- package/server/graphql/types/worksheet/index.ts +10 -2
- package/server/graphql/types/worksheet/worksheet-info.ts +2 -0
- package/server/graphql/types/worksheet-detail/index.ts +2 -1
- package/server/graphql/types/worksheet-detail/inventory-detail.ts +1 -0
- package/server/routes.ts +11 -6
- package/server/utils/inventory-util.ts +14 -5
|
@@ -1,28 +1,30 @@
|
|
|
1
|
+
import { EntityManager, Equal, In, Not } from 'typeorm'
|
|
2
|
+
|
|
1
3
|
import { User } from '@things-factory/auth-base'
|
|
2
4
|
import { Bizplace } from '@things-factory/biz-base'
|
|
5
|
+
import { Product } from '@things-factory/product-base'
|
|
3
6
|
import {
|
|
4
7
|
ArrivalNotice,
|
|
5
|
-
OrderNoGenerator,
|
|
6
|
-
OrderVas,
|
|
7
8
|
ORDER_STATUS,
|
|
8
9
|
ORDER_TYPES,
|
|
9
10
|
ORDER_VAS_STATUS,
|
|
11
|
+
OrderNoGenerator,
|
|
12
|
+
OrderVas,
|
|
10
13
|
ReleaseGood,
|
|
11
|
-
|
|
12
|
-
|
|
14
|
+
VAS,
|
|
15
|
+
VasOrder
|
|
13
16
|
} from '@things-factory/sales-base'
|
|
14
|
-
import { Product } from '@things-factory/product-base'
|
|
15
17
|
import {
|
|
16
18
|
Inventory,
|
|
17
|
-
InventoryHistory,
|
|
18
|
-
InventoryNoGenerator,
|
|
19
19
|
INVENTORY_STATUS,
|
|
20
20
|
INVENTORY_TRANSACTION_TYPE,
|
|
21
|
+
InventoryHistory,
|
|
22
|
+
InventoryNoGenerator,
|
|
21
23
|
Location,
|
|
22
24
|
LOCATION_TYPE,
|
|
23
25
|
Warehouse
|
|
24
26
|
} from '@things-factory/warehouse-base'
|
|
25
|
-
|
|
27
|
+
|
|
26
28
|
import { WORKSHEET_STATUS, WORKSHEET_TYPE } from '../../constants'
|
|
27
29
|
import { Worksheet, WorksheetDetail } from '../../entities'
|
|
28
30
|
import {
|
|
@@ -30,10 +32,12 @@ import {
|
|
|
30
32
|
completeRepackaging,
|
|
31
33
|
completeRepalletizing,
|
|
32
34
|
completeUnpacking,
|
|
35
|
+
FeaturedInventoryInterface,
|
|
33
36
|
RefOrderType
|
|
34
37
|
} from '../../graphql/resolvers/worksheet/vas-transactions'
|
|
35
|
-
import {
|
|
38
|
+
import { PackingUnits } from '../../graphql/resolvers/worksheet/vas-transactions/interfaces/repackaging'
|
|
36
39
|
import { generateInventoryHistory } from '../../utils'
|
|
40
|
+
import { ReferenceOrderType, WorksheetController } from '../worksheet-controller'
|
|
37
41
|
|
|
38
42
|
type CompleteTransactionType = (trxMgr: EntityManager, orderVas: OrderVas, user: User) => Promise<void>
|
|
39
43
|
|
|
@@ -41,6 +45,7 @@ export class VasWorksheetController extends WorksheetController {
|
|
|
41
45
|
private readonly COMPLETE_TRX_MAP: Record<string, CompleteTransactionType> = {
|
|
42
46
|
'vas-repalletizing': completeRepalletizing,
|
|
43
47
|
'vas-repack': completeRepackaging,
|
|
48
|
+
'vas-repack-relabel': completeRepackaging,
|
|
44
49
|
'vas-relabel': completeRelabeling,
|
|
45
50
|
'vas-unpack': completeUnpacking
|
|
46
51
|
}
|
|
@@ -102,20 +107,88 @@ export class VasWorksheetController extends WorksheetController {
|
|
|
102
107
|
return acc + inv.qty
|
|
103
108
|
}, 0)
|
|
104
109
|
|
|
110
|
+
let operationGuide = JSON.parse(targetVas.operationGuide)
|
|
111
|
+
let vasOperationGuide = targetVas.vas?.operationGuide
|
|
112
|
+
|
|
113
|
+
if (vasOperationGuide === 'vas-repack' || vasOperationGuide === 'vas-repack-relabel') {
|
|
114
|
+
const mainInventory: Inventory = inventories[0]
|
|
115
|
+
const featuredInvs: FeaturedInventoryInterface[] = []
|
|
116
|
+
const foundInvs: Inventory[] = await this.trxMgr
|
|
117
|
+
.getRepository(Inventory)
|
|
118
|
+
.findByIds(inventories.filter(inv => inv.id !== mainInventory.id).map(inv => inv.id))
|
|
119
|
+
|
|
120
|
+
/* Update lockedQty of featuredInvs */
|
|
121
|
+
for (let inventory of foundInvs) {
|
|
122
|
+
const transferQty: number = inventories.find(inv => inv.id === inventory.id).qty
|
|
123
|
+
const transferUomValue: number = Math.round((inventory.uomValue / inventory.qty) * transferQty * 100) / 100
|
|
124
|
+
|
|
125
|
+
inventory.lockedQty += transferQty
|
|
126
|
+
inventory.lockedUomValue += transferUomValue
|
|
127
|
+
|
|
128
|
+
await this.trxMgr.getRepository(Inventory).save(inventory)
|
|
129
|
+
|
|
130
|
+
let featuredInv: FeaturedInventoryInterface = {
|
|
131
|
+
palletId: inventory.palletId,
|
|
132
|
+
originalQty: transferQty,
|
|
133
|
+
originalUomValue: transferUomValue,
|
|
134
|
+
packingSize: inventory.packingSize,
|
|
135
|
+
uomValuePerQty: inventory.uomValue / (inventory.qty * inventory.packingSize)
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
switch (operationGuide.data?.packingUnit) {
|
|
139
|
+
case PackingUnits.QTY:
|
|
140
|
+
featuredInv.currentUnitQty = transferQty * inventory.packingSize
|
|
141
|
+
break
|
|
142
|
+
|
|
143
|
+
case PackingUnits.UOM:
|
|
144
|
+
featuredInv.currentUomValue = transferUomValue
|
|
145
|
+
break
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
featuredInvs.push(featuredInv)
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/* assign featuredInvs inside operationGuide.data */
|
|
152
|
+
operationGuide.data = {
|
|
153
|
+
...operationGuide.data,
|
|
154
|
+
featuredInvs
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/* assign main inventory as the only inventories */
|
|
158
|
+
inventories = [mainInventory]
|
|
159
|
+
}
|
|
160
|
+
|
|
105
161
|
for (let inventory of inventories) {
|
|
106
162
|
let newTargetVas: OrderVas = new OrderVas()
|
|
107
163
|
|
|
108
164
|
const foundInventory: Inventory = await this.trxMgr.getRepository(Inventory).findOne(inventory.id)
|
|
109
|
-
|
|
110
|
-
const assignedQty = inventory.qty // assigned inventory qty that was passed from client side
|
|
165
|
+
if (!foundInventory) throw new Error(this.ERROR_MSG.FIND.NO_RESULT(inventory.id))
|
|
111
166
|
|
|
112
|
-
|
|
167
|
+
// assigned inventory qty that was passed from client side
|
|
168
|
+
const assignedQty = inventory.qty
|
|
169
|
+
const unitUomValue: number = foundInventory.uomValue / foundInventory.qty
|
|
113
170
|
|
|
114
171
|
// update unpack qty for unpacking vas
|
|
115
|
-
if (
|
|
172
|
+
if (vasOperationGuide === 'vas-unpack') {
|
|
116
173
|
operationGuide.data.unpackQty = Math.round(operationGuide.data.unpackQty / accInventoriesQty) * assignedQty
|
|
117
174
|
}
|
|
118
175
|
|
|
176
|
+
if (vasOperationGuide === 'vas-repack' || vasOperationGuide === 'vas-repack-relabel') {
|
|
177
|
+
switch (operationGuide.data?.packingUnit) {
|
|
178
|
+
case PackingUnits.UOM:
|
|
179
|
+
newTargetVas.qty = 1
|
|
180
|
+
newTargetVas.uomValue = targetVas.uomValue
|
|
181
|
+
break
|
|
182
|
+
|
|
183
|
+
default:
|
|
184
|
+
newTargetVas.qty = accInventoriesQty
|
|
185
|
+
newTargetVas.uomValue = accInventoriesQty * unitUomValue
|
|
186
|
+
}
|
|
187
|
+
} else {
|
|
188
|
+
newTargetVas.qty = assignedQty
|
|
189
|
+
newTargetVas.uomValue = assignedQty * unitUomValue
|
|
190
|
+
}
|
|
191
|
+
|
|
119
192
|
newTargetVas.set = targetVas.set
|
|
120
193
|
newTargetVas.targetType = targetVas.targetType
|
|
121
194
|
newTargetVas.targetBatchId = targetVas.targetBatchId
|
|
@@ -129,8 +202,6 @@ export class VasWorksheetController extends WorksheetController {
|
|
|
129
202
|
newTargetVas.vas = targetVas.vas
|
|
130
203
|
newTargetVas.domain = this.domain
|
|
131
204
|
newTargetVas.name = OrderNoGenerator.orderVas()
|
|
132
|
-
newTargetVas.qty = assignedQty
|
|
133
|
-
newTargetVas.uomValue = assignedQty * unitUomValue
|
|
134
205
|
newTargetVas.inventory = foundInventory
|
|
135
206
|
newTargetVas.bizplace = bizplace
|
|
136
207
|
newTargetVas.creator = this.user
|
|
@@ -141,15 +212,13 @@ export class VasWorksheetController extends WorksheetController {
|
|
|
141
212
|
seq++
|
|
142
213
|
|
|
143
214
|
// update inventory locked qty & uom value
|
|
144
|
-
const currentLockedQty:
|
|
145
|
-
const currentLockedUomValue:
|
|
215
|
+
const currentLockedQty: number = foundInventory.lockedQty || 0
|
|
216
|
+
const currentLockedUomValue: number = foundInventory.lockedUomValue || 0
|
|
146
217
|
|
|
147
218
|
await this.trxMgr.getRepository(Inventory).save({
|
|
148
219
|
...foundInventory,
|
|
149
|
-
lockedQty:
|
|
150
|
-
lockedUomValue:
|
|
151
|
-
? targetVas.qty * unitUomValue + currentLockedUomValue
|
|
152
|
-
: targetVas.qty * unitUomValue,
|
|
220
|
+
lockedQty: inventory.qty + currentLockedQty,
|
|
221
|
+
lockedUomValue: inventory.qty * unitUomValue + currentLockedUomValue,
|
|
153
222
|
updater: this.user
|
|
154
223
|
})
|
|
155
224
|
}
|
|
@@ -360,13 +429,19 @@ export class VasWorksheetController extends WorksheetController {
|
|
|
360
429
|
}
|
|
361
430
|
}
|
|
362
431
|
|
|
363
|
-
const targetVas:
|
|
432
|
+
const targetVas: VasOrder = foundWorksheetDetail.targetVas
|
|
364
433
|
if (!targetVas) throw new Error(`VAS doesn't exists`)
|
|
365
434
|
|
|
366
435
|
const inventory: Inventory = foundWorksheetDetail.targetVas.inventory
|
|
367
436
|
|
|
368
437
|
// reset lockedQty if there's inventory found
|
|
369
|
-
if (
|
|
438
|
+
if (
|
|
439
|
+
inventory &&
|
|
440
|
+
inventory.lockedQty >= targetVas.qty &&
|
|
441
|
+
targetVas.vas.operationGuide &&
|
|
442
|
+
targetVas.vas.operationGuide !== 'vas-repack' &&
|
|
443
|
+
targetVas.vas.operationGuide !== 'vas-repack-relabel'
|
|
444
|
+
) {
|
|
370
445
|
await this.trxMgr.getRepository(Inventory).save({
|
|
371
446
|
...inventory,
|
|
372
447
|
lockedQty: inventory.lockedQty - targetVas.qty,
|
|
@@ -664,6 +739,12 @@ export class VasWorksheetController extends WorksheetController {
|
|
|
664
739
|
(wsd: WorksheetDetail) => wsd.targetVas.id === targetVas.id
|
|
665
740
|
)
|
|
666
741
|
|
|
742
|
+
// if (targetVas.operationGuide && (!issue || (targetVas.vas.name.toUpperCase() == VAS.REPACKAGING && issue))) {
|
|
743
|
+
// await this.doOperationTransaction(targetVas)
|
|
744
|
+
// } /*else if (targetVas.operationGuide && targetVas.vas.name.toUpperCase() === VAS.REPACKAGING && issue) {
|
|
745
|
+
// await this.doOperationTransaction(targetVas)
|
|
746
|
+
// }*/
|
|
747
|
+
|
|
667
748
|
if (targetVas.operationGuide && !issue) {
|
|
668
749
|
await this.doOperationTransaction(targetVas)
|
|
669
750
|
}
|
|
@@ -1,24 +1,26 @@
|
|
|
1
|
+
import { EntityManager, EntitySchema, Equal, FindOneOptions, In, Not } from 'typeorm'
|
|
2
|
+
|
|
1
3
|
import { Role, User } from '@things-factory/auth-base'
|
|
2
4
|
import { Bizplace, getDomainUsers } from '@things-factory/biz-base'
|
|
5
|
+
import { sendNotification } from '@things-factory/notification'
|
|
6
|
+
import { ProductDetail } from '@things-factory/product-base'
|
|
3
7
|
import {
|
|
4
8
|
ArrivalNotice,
|
|
5
9
|
DeliveryOrder,
|
|
6
10
|
InventoryCheck,
|
|
7
|
-
OrderInventory,
|
|
8
|
-
OrderProduct,
|
|
9
|
-
OrderVas,
|
|
10
11
|
ORDER_INVENTORY_STATUS,
|
|
11
12
|
ORDER_PRODUCT_STATUS,
|
|
12
13
|
ORDER_VAS_STATUS,
|
|
14
|
+
OrderInventory,
|
|
15
|
+
OrderProduct,
|
|
16
|
+
OrderVas,
|
|
13
17
|
ReleaseGood,
|
|
14
|
-
|
|
15
|
-
|
|
18
|
+
ReturnOrder,
|
|
19
|
+
VasOrder
|
|
16
20
|
} from '@things-factory/sales-base'
|
|
17
|
-
import { ProductDetail } from '@things-factory/product-base'
|
|
18
21
|
import { Domain } from '@things-factory/shell'
|
|
19
|
-
import {
|
|
20
|
-
|
|
21
|
-
import { EntityManager, EntitySchema, Equal, FindOneOptions, Not, In } from 'typeorm'
|
|
22
|
+
import { Inventory, INVENTORY_STATUS, Pallet } from '@things-factory/warehouse-base'
|
|
23
|
+
|
|
22
24
|
import { WORKSHEET_STATUS, WORKSHEET_TYPE } from '../constants'
|
|
23
25
|
import { Worksheet, WorksheetDetail } from '../entities'
|
|
24
26
|
import { generateInventoryHistory, WorksheetNoGenerator } from '../utils'
|
|
@@ -56,6 +58,7 @@ export class WorksheetController {
|
|
|
56
58
|
public readonly ERROR_MSG = {
|
|
57
59
|
FIND: {
|
|
58
60
|
NO_RESULT: (condition: any) => `There's no results matched with condition ${condition}`,
|
|
61
|
+
NO_CHILD_RESULT: (condition: any) => `There's no child result matched with condition ${condition}`,
|
|
59
62
|
NOT_MATCH: (source: any, target: any) => `Unable to find matching ${target} using ${source}`
|
|
60
63
|
},
|
|
61
64
|
ORDER_ITEM: {
|
|
@@ -637,10 +640,12 @@ export class WorksheetController {
|
|
|
637
640
|
|
|
638
641
|
const worksheetDetails: WorksheetDetail[] = worksheet.worksheetDetails
|
|
639
642
|
|
|
640
|
-
worksheetDetails
|
|
641
|
-
wsd.status
|
|
642
|
-
wsd
|
|
643
|
-
|
|
643
|
+
worksheetDetails
|
|
644
|
+
.filter((wsd: WorksheetDetail) => wsd.status !== ORDER_INVENTORY_STATUS.REPLACED)
|
|
645
|
+
.forEach((wsd: WorksheetDetail) => {
|
|
646
|
+
wsd.status = WORKSHEET_STATUS.DONE
|
|
647
|
+
wsd.updater = this.user
|
|
648
|
+
})
|
|
644
649
|
await this.trxMgr.getRepository(WorksheetDetail).save(worksheetDetails)
|
|
645
650
|
|
|
646
651
|
if (worksheetType === WORKSHEET_TYPE.UNLOADING) {
|
|
@@ -668,12 +673,14 @@ export class WorksheetController {
|
|
|
668
673
|
worksheetType === WORKSHEET_TYPE.WAREHOUSE_RETURN ||
|
|
669
674
|
worksheetType === WORKSHEET_TYPE.UNLOADING_RETURN
|
|
670
675
|
) {
|
|
671
|
-
const targetInventories: OrderInventory[] = worksheet.worksheetDetails
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
676
|
+
const targetInventories: OrderInventory[] = worksheet.worksheetDetails
|
|
677
|
+
.filter((wsd: WorksheetDetail) => wsd.status !== ORDER_INVENTORY_STATUS.REPLACED)
|
|
678
|
+
.map((wsd: WorksheetDetail) => {
|
|
679
|
+
let targetInventory: OrderInventory = wsd.targetInventory
|
|
680
|
+
targetInventory.status = ORDER_INVENTORY_STATUS.TERMINATED
|
|
681
|
+
targetInventory.updater = this.user
|
|
682
|
+
return targetInventory
|
|
683
|
+
})
|
|
677
684
|
|
|
678
685
|
await this.updateOrderTargets(targetInventories)
|
|
679
686
|
}
|
|
@@ -951,6 +958,60 @@ export class WorksheetController {
|
|
|
951
958
|
return childQty
|
|
952
959
|
}
|
|
953
960
|
|
|
961
|
+
/**
|
|
962
|
+
* @summary Check for product child qty at any scanned level
|
|
963
|
+
* @description It will check every level of product detail by comparing scanned level and GAN registered level.
|
|
964
|
+
* By getting the level that has relation, child qty will be retrieved
|
|
965
|
+
* 1st level: PALLET -> 2 CARTONS (scan), 2nd level: CARTON -> 6 BAGS, 3rd level: BAG -> 10 UNITS, lowest: UNIT (order registered packing type)
|
|
966
|
+
*/
|
|
967
|
+
async getChildPackingSize(
|
|
968
|
+
productDetails: ProductDetail[],
|
|
969
|
+
defaultProductDetail: ProductDetail,
|
|
970
|
+
unmatchingProductDetail: ProductDetail
|
|
971
|
+
): Promise<number> {
|
|
972
|
+
let hasChildRelation: boolean = Boolean(unmatchingProductDetail?.childProductDetail)
|
|
973
|
+
let hasMatchingChild: boolean
|
|
974
|
+
let packingSize: number = 1
|
|
975
|
+
let currentChildProductDetail: ProductDetail
|
|
976
|
+
|
|
977
|
+
if (hasChildRelation) {
|
|
978
|
+
currentChildProductDetail = productDetails.find(
|
|
979
|
+
(productDetail: ProductDetail) => productDetail.id === unmatchingProductDetail.childProductDetail.id
|
|
980
|
+
)
|
|
981
|
+
|
|
982
|
+
if (!currentChildProductDetail) {
|
|
983
|
+
throw new Error(this.ERROR_MSG.FIND.NOT_MATCH('packing type', `GTIN (${unmatchingProductDetail.gtin})`))
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
hasMatchingChild = Boolean(defaultProductDetail.id === currentChildProductDetail.id)
|
|
987
|
+
if (hasMatchingChild) {
|
|
988
|
+
packingSize = unmatchingProductDetail.packingSize
|
|
989
|
+
} else {
|
|
990
|
+
packingSize = unmatchingProductDetail.packingSize * packingSize
|
|
991
|
+
}
|
|
992
|
+
} else {
|
|
993
|
+
throw new Error(this.ERROR_MSG.FIND.NO_CHILD_RESULT(`${unmatchingProductDetail.gtin}`))
|
|
994
|
+
}
|
|
995
|
+
|
|
996
|
+
while (hasChildRelation && !hasMatchingChild) {
|
|
997
|
+
if (hasMatchingChild) {
|
|
998
|
+
packingSize = currentChildProductDetail.packingSize * packingSize // 12 x 10
|
|
999
|
+
} else if (!hasMatchingChild && hasChildRelation) {
|
|
1000
|
+
packingSize = currentChildProductDetail.packingSize * packingSize // 12 x 10
|
|
1001
|
+
currentChildProductDetail = productDetails.find(
|
|
1002
|
+
(productDetail: ProductDetail) => productDetail.id === currentChildProductDetail.childProductDetail.id
|
|
1003
|
+
)
|
|
1004
|
+
|
|
1005
|
+
hasChildRelation = Boolean(currentChildProductDetail?.childProductDetail)
|
|
1006
|
+
hasMatchingChild = Boolean(defaultProductDetail.id === currentChildProductDetail.id)
|
|
1007
|
+
} else if (!hasChildRelation && !hasMatchingChild) {
|
|
1008
|
+
throw new Error(this.ERROR_MSG.FIND.NO_RESULT(unmatchingProductDetail.gtin))
|
|
1009
|
+
}
|
|
1010
|
+
}
|
|
1011
|
+
|
|
1012
|
+
return packingSize
|
|
1013
|
+
}
|
|
1014
|
+
|
|
954
1015
|
async createInventory(inventory: Partial<Inventory> | Partial<Inventory>[]): Promise<Inventory | Inventory[]> {
|
|
955
1016
|
inventory = this.setStamp(inventory)
|
|
956
1017
|
return await this.trxMgr.getRepository(Inventory).save(inventory)
|
|
@@ -1037,9 +1098,13 @@ export class WorksheetController {
|
|
|
1037
1098
|
}
|
|
1038
1099
|
|
|
1039
1100
|
tidyConditions(record: Record<string, any>): Record<string, any> {
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
}
|
|
1101
|
+
if ('id' in record) {
|
|
1102
|
+
return { id: record.id }
|
|
1103
|
+
} else {
|
|
1104
|
+
Object.keys(record).forEach((key: string) => {
|
|
1105
|
+
if (record[key] === null || record[key] instanceof Date || Array.isArray(record[key])) delete record[key]
|
|
1106
|
+
})
|
|
1107
|
+
}
|
|
1043
1108
|
|
|
1044
1109
|
return record
|
|
1045
1110
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { EntityManager, In } from 'typeorm'
|
|
2
|
+
|
|
1
3
|
import { User } from '@things-factory/auth-base'
|
|
2
4
|
import { Bizplace } from '@things-factory/biz-base'
|
|
3
5
|
import { ReleaseGood } from '@things-factory/sales-base'
|
|
4
6
|
import { Domain } from '@things-factory/shell'
|
|
5
7
|
import { Pallet, PalletHistory } from '@things-factory/warehouse-base'
|
|
6
|
-
import { EntityManager, getRepository, In } from 'typeorm'
|
|
7
8
|
|
|
8
9
|
export const palletOutbound = {
|
|
9
10
|
async palletOutbound(_: any, { refOrderNo, patches }, context: any) {
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
+
import { EntityManager, In } from 'typeorm'
|
|
2
|
+
|
|
1
3
|
import { User } from '@things-factory/auth-base'
|
|
2
|
-
import {
|
|
4
|
+
import { Sellercraft, SellercraftStatus } from '@things-factory/integration-sellercraft'
|
|
5
|
+
import { InventoryCheck, ORDER_INVENTORY_STATUS, ORDER_STATUS, OrderInventory } from '@things-factory/sales-base'
|
|
3
6
|
import { Domain } from '@things-factory/shell'
|
|
4
7
|
import { Inventory, INVENTORY_STATUS, INVENTORY_TRANSACTION_TYPE, Location } from '@things-factory/warehouse-base'
|
|
5
|
-
|
|
8
|
+
|
|
6
9
|
import { WORKSHEET_STATUS, WORKSHEET_TYPE } from '../../../constants'
|
|
10
|
+
import { SellercraftController } from '../../../controllers'
|
|
7
11
|
import { Worksheet, WorksheetDetail } from '../../../entities'
|
|
8
12
|
import { generateInventoryHistory, switchLocationStatus } from '../../../utils'
|
|
9
13
|
|
|
@@ -48,6 +52,11 @@ export async function cycleCountAdjustment(
|
|
|
48
52
|
relations: [
|
|
49
53
|
'targetInventory',
|
|
50
54
|
'targetInventory.inventory',
|
|
55
|
+
'targetInventory.inventory.product',
|
|
56
|
+
'targetInventory.inventory.product.productDetails',
|
|
57
|
+
'targetInventory.inventory.product.productDetails.childProductDetail',
|
|
58
|
+
'targetInventory.inventory.bizplace',
|
|
59
|
+
'targetInventory.inventory.bizplace.domain',
|
|
51
60
|
'targetInventory.inventory.location',
|
|
52
61
|
'targetInventory.inspectedLocation',
|
|
53
62
|
'targetInventory.inspectedLocation.warehouse'
|
|
@@ -61,6 +70,10 @@ export async function cycleCountAdjustment(
|
|
|
61
70
|
const transactQty: number = targetInventory.inspectedQty - inventory.qty
|
|
62
71
|
const transactUomValue: number = targetInventory.inspectedUomValue - inventory.uomValue
|
|
63
72
|
|
|
73
|
+
const sellercraft: Sellercraft = await tx.getRepository(Sellercraft).findOne({
|
|
74
|
+
where: { domain: inventory.bizplace.domain, status: SellercraftStatus.ACTIVE }
|
|
75
|
+
})
|
|
76
|
+
|
|
64
77
|
if (targetInventory.status === ORDER_INVENTORY_STATUS.MISSING) {
|
|
65
78
|
// create STORED, CC_ADJUSTMENT history
|
|
66
79
|
await generateInventoryHistory(
|
|
@@ -83,6 +96,11 @@ export async function cycleCountAdjustment(
|
|
|
83
96
|
|
|
84
97
|
// create TERMINATED, TERMINATED history
|
|
85
98
|
await generateInventoryHistory(inventory, cycleCount, INVENTORY_TRANSACTION_TYPE.TERMINATED, 0, 0, user, tx)
|
|
99
|
+
|
|
100
|
+
if (sellercraft) {
|
|
101
|
+
const sellercraftCtrl: SellercraftController = new SellercraftController(tx, domain, user)
|
|
102
|
+
await sellercraftCtrl.updateSellercraftStock(sellercraft, inventory)
|
|
103
|
+
}
|
|
86
104
|
} else if (targetInventory.inspectedQty == 0) {
|
|
87
105
|
// create STORED, CC_ADJUSTMENT history
|
|
88
106
|
await generateInventoryHistory(
|
|
@@ -109,6 +127,11 @@ export async function cycleCountAdjustment(
|
|
|
109
127
|
|
|
110
128
|
// create TERMINATED, TERMINATED history
|
|
111
129
|
await generateInventoryHistory(inventory, cycleCount, INVENTORY_TRANSACTION_TYPE.TERMINATED, 0, 0, user, tx)
|
|
130
|
+
|
|
131
|
+
if (sellercraft) {
|
|
132
|
+
const sellercraftCtrl: SellercraftController = new SellercraftController(tx, domain, user)
|
|
133
|
+
await sellercraftCtrl.updateSellercraftStock(sellercraft, inventory)
|
|
134
|
+
}
|
|
112
135
|
} else {
|
|
113
136
|
const prevLocationId: string = inventory.location.id
|
|
114
137
|
|
|
@@ -153,6 +176,11 @@ export async function cycleCountAdjustment(
|
|
|
153
176
|
)
|
|
154
177
|
}
|
|
155
178
|
|
|
179
|
+
if (sellercraft) {
|
|
180
|
+
const sellercraftCtrl: SellercraftController = new SellercraftController(tx, domain, user)
|
|
181
|
+
await sellercraftCtrl.updateSellercraftStock(sellercraft, inventory)
|
|
182
|
+
}
|
|
183
|
+
|
|
156
184
|
targetInventory.status = ORDER_INVENTORY_STATUS.TERMINATED
|
|
157
185
|
targetInventory.updater = user
|
|
158
186
|
await tx.getRepository(OrderInventory).save(targetInventory)
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { createQueryBuilder, getRepository, In, SelectQueryBuilder } from 'typeorm'
|
|
2
|
+
|
|
3
|
+
import { InventoryCheck, ORDER_STATUS, OrderInventory } from '@things-factory/sales-base'
|
|
1
4
|
import { Domain } from '@things-factory/shell'
|
|
2
|
-
import { getRepository, createQueryBuilder, SelectQueryBuilder, In } from 'typeorm'
|
|
3
5
|
import { Inventory } from '@things-factory/warehouse-base'
|
|
4
|
-
|
|
6
|
+
|
|
5
7
|
import { WORKSHEET_STATUS, WORKSHEET_TYPE } from '../../../constants'
|
|
6
8
|
import { Worksheet, WorksheetDetail } from '../../../entities'
|
|
7
9
|
|
|
@@ -21,7 +23,7 @@ export const cycleCountWorksheetResolver = {
|
|
|
21
23
|
type: In([WORKSHEET_TYPE.CYCLE_COUNT, WORKSHEET_TYPE.CYCLE_COUNT_RECHECK]),
|
|
22
24
|
status: WORKSHEET_STATUS.EXECUTING
|
|
23
25
|
},
|
|
24
|
-
relations: ['bizplace']
|
|
26
|
+
relations: ['bizplace', 'bizplace.domain']
|
|
25
27
|
})
|
|
26
28
|
|
|
27
29
|
const qb: SelectQueryBuilder<WorksheetDetail> = createQueryBuilder(WorksheetDetail, 'WSD')
|
|
@@ -46,7 +48,8 @@ export const cycleCountWorksheetResolver = {
|
|
|
46
48
|
return {
|
|
47
49
|
worksheetInfo: {
|
|
48
50
|
startedAt: worksheet.startedAt,
|
|
49
|
-
bizplace: worksheet.bizplace
|
|
51
|
+
bizplace: worksheet.bizplace,
|
|
52
|
+
partnerDomainId: worksheet.bizplace?.domain.id
|
|
50
53
|
},
|
|
51
54
|
worksheetDetailInfos: worksheetDetails.map(async (cycleCountWSD: WorksheetDetail) => {
|
|
52
55
|
const targetInventory: OrderInventory = cycleCountWSD.targetInventory
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { EntityManager } from 'typeorm'
|
|
2
|
+
|
|
3
|
+
import { User } from '@things-factory/auth-base'
|
|
4
|
+
import { Sellercraft, SellercraftStatus } from '@things-factory/integration-sellercraft'
|
|
5
|
+
import { ReleaseGood } from '@things-factory/sales-base'
|
|
6
|
+
import { Domain } from '@things-factory/shell'
|
|
7
|
+
|
|
8
|
+
import { SellercraftController } from '../../../controllers'
|
|
9
|
+
|
|
10
|
+
export const fetchSellercraftAirwayBillResolver = {
|
|
11
|
+
async fetchSellercraftAirwayBill(_: any, { releaseGoodNo }, context: any) {
|
|
12
|
+
const { tx, domain, user }: { tx: EntityManager; domain: Domain; user: User } = context.state
|
|
13
|
+
let releaseGood: ReleaseGood = await tx
|
|
14
|
+
.getRepository(ReleaseGood)
|
|
15
|
+
.findOne({ where: { domain, name: releaseGoodNo }, relations: ['bizplace', 'bizplace.domain'] })
|
|
16
|
+
|
|
17
|
+
const sellercraft: Sellercraft = await tx.getRepository(Sellercraft).findOne({
|
|
18
|
+
domain: releaseGood.bizplace.domain,
|
|
19
|
+
status: SellercraftStatus.ACTIVE
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
if (sellercraft && !releaseGood?.airwayBill) {
|
|
23
|
+
const sellercraftCtrl: SellercraftController = new SellercraftController(tx, domain, user)
|
|
24
|
+
await sellercraftCtrl.fetchOrderDocument(sellercraft, releaseGood)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const airwayBill: string = releaseGood?.airwayBill
|
|
28
|
+
return { airwayBill }
|
|
29
|
+
}
|
|
30
|
+
}
|
package/server/graphql/resolvers/worksheet/generate-worksheet/generate-cycle-count-worksheet.ts
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
|
+
import { EntityManager } from 'typeorm'
|
|
2
|
+
|
|
1
3
|
import { User } from '@things-factory/auth-base'
|
|
4
|
+
import { OrderInventory } from '@things-factory/sales-base'
|
|
2
5
|
import { Domain } from '@things-factory/shell'
|
|
3
|
-
|
|
6
|
+
|
|
4
7
|
import { CycleCountWorksheetController } from '../../../../controllers'
|
|
5
8
|
import { Worksheet } from '../../../../entities'
|
|
6
9
|
|
|
7
10
|
export const generateCycleCountWorksheetResolver = {
|
|
8
|
-
async generateCycleCountWorksheet(
|
|
11
|
+
async generateCycleCountWorksheet(
|
|
12
|
+
_: any,
|
|
13
|
+
{ executionDate, customerId, orderInventoryIds, orderInventories, limit },
|
|
14
|
+
context: any
|
|
15
|
+
) {
|
|
9
16
|
const { tx, domain, user }: { tx: EntityManager; domain: Domain; user: User } = context.state
|
|
10
17
|
|
|
11
18
|
const cycleCountWorksheet: Worksheet = await generateCycleCountWorksheet(
|
|
@@ -15,6 +22,7 @@ export const generateCycleCountWorksheetResolver = {
|
|
|
15
22
|
executionDate,
|
|
16
23
|
customerId,
|
|
17
24
|
orderInventoryIds,
|
|
25
|
+
orderInventories,
|
|
18
26
|
limit
|
|
19
27
|
)
|
|
20
28
|
|
|
@@ -29,8 +37,15 @@ export async function generateCycleCountWorksheet(
|
|
|
29
37
|
executionDate: string,
|
|
30
38
|
customerId: string,
|
|
31
39
|
orderInventoryIds: string[] = [],
|
|
40
|
+
orderInventories: OrderInventory[],
|
|
32
41
|
limit: number
|
|
33
42
|
): Promise<Worksheet> {
|
|
34
43
|
const worksheetController: CycleCountWorksheetController = new CycleCountWorksheetController(tx, domain, user)
|
|
35
|
-
return await worksheetController.generateCycleCountWorksheet(
|
|
44
|
+
return await worksheetController.generateCycleCountWorksheet(
|
|
45
|
+
executionDate,
|
|
46
|
+
customerId,
|
|
47
|
+
orderInventoryIds,
|
|
48
|
+
orderInventories,
|
|
49
|
+
limit
|
|
50
|
+
)
|
|
36
51
|
}
|
|
@@ -8,6 +8,8 @@ import { cycleCountAdjustmentResolver } from './cycle-count-adjustment'
|
|
|
8
8
|
import { cycleCountWorksheetResolver } from './cycle-count-worksheet'
|
|
9
9
|
import { deleteWorksheet } from './delete-worksheet'
|
|
10
10
|
import { deliveryOrderByWorksheetResolver } from './delivery-order-by-worksheet'
|
|
11
|
+
import { fetchSellercraftAirwayBillResolver } from './fetch-sellercraft-airway-bill'
|
|
12
|
+
import { findReleaseOrdersByTaskNoResolver } from './find-release-orders-by-task-no'
|
|
11
13
|
import { Mutations as GenerateWorksheetMutations } from './generate-worksheet'
|
|
12
14
|
import { havingVasResolver } from './having-vas'
|
|
13
15
|
import { Mutations as InspectMutations } from './inspecting'
|
|
@@ -33,13 +35,13 @@ import { recommendPutawayLocationResolver } from './recommend-putway-location'
|
|
|
33
35
|
import { rejectCancellationReleaseOrder } from './reject-cancellation-release-order'
|
|
34
36
|
import { replacePickingPalletsResolver } from './replace-picking-pallets'
|
|
35
37
|
import { returnWorksheetResolver } from './return-worksheet'
|
|
36
|
-
import { sortingWorksheetResolver } from './sorting-worksheet'
|
|
37
38
|
import { Mutations as ReturningMutations } from './returning'
|
|
39
|
+
import { Mutations as SortingMutations } from './sorting'
|
|
40
|
+
import { sortingWorksheetResolver } from './sorting-worksheet'
|
|
38
41
|
import { transfer } from './transfer'
|
|
39
42
|
import { unloadedInventories } from './unloaded-inventories'
|
|
40
43
|
import { unloadedInventoriesByReusablePallet } from './unloaded-inventories-by-reusable-pallet'
|
|
41
44
|
import { Mutations as UnloadingMutations } from './unloading'
|
|
42
|
-
import { Mutations as SortingMutations } from './sorting'
|
|
43
45
|
import { Mutations as UnloadingReturnMutations } from './unloading-return'
|
|
44
46
|
import { unloadingReturnWorksheetResolver } from './unloading-return-worksheet'
|
|
45
47
|
import { unloadingWorksheetResolver } from './unloading-worksheet'
|
|
@@ -62,7 +64,6 @@ import { worksheetResolver } from './worksheet'
|
|
|
62
64
|
import { worksheetByOrderNoResolver } from './worksheet-by-order-no'
|
|
63
65
|
import { worksheetWithPaginationResolver } from './worksheet-with-pagination'
|
|
64
66
|
import { worksheetsResolver } from './worksheets'
|
|
65
|
-
import { findReleaseOrdersByTaskNoResolver } from './find-release-orders-by-task-no'
|
|
66
67
|
|
|
67
68
|
export const Query = {
|
|
68
69
|
...worksheetsResolver,
|
|
@@ -130,5 +131,6 @@ export const Mutation = {
|
|
|
130
131
|
...undoRelabelingResolver,
|
|
131
132
|
...crossDockPickingResolver,
|
|
132
133
|
...unpackingResolver,
|
|
133
|
-
...palletizingPallets
|
|
134
|
+
...palletizingPallets,
|
|
135
|
+
...fetchSellercraftAirwayBillResolver
|
|
134
136
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { createQueryBuilder, getRepository, SelectQueryBuilder } from 'typeorm'
|
|
2
|
+
|
|
1
3
|
import { InventoryCheck, ORDER_INVENTORY_STATUS } from '@things-factory/sales-base'
|
|
2
4
|
import { Domain } from '@things-factory/shell'
|
|
3
|
-
|
|
5
|
+
|
|
4
6
|
import { Worksheet, WorksheetDetail } from '../../../entities'
|
|
5
7
|
|
|
6
8
|
export const notTallyTargetInventoriesResolver = {
|
|
@@ -24,7 +26,7 @@ export const notTallyTargetInventoriesResolver = {
|
|
|
24
26
|
.leftJoinAndSelect('INV.product', 'PROD')
|
|
25
27
|
.where('WSD.domain = :domainId', { domainId: domain.id })
|
|
26
28
|
.andWhere('WSD.worksheet = :worksheetId', { worksheetId: worksheet.id })
|
|
27
|
-
.andWhere('
|
|
29
|
+
.andWhere('WSD.status = :status', { status: ORDER_INVENTORY_STATUS.NOT_TALLY })
|
|
28
30
|
.getMany()
|
|
29
31
|
|
|
30
32
|
return worksheetDetails.map((wsd: WorksheetDetail) => wsd.targetInventory)
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
import { EntityManager } from 'typeorm'
|
|
2
|
+
|
|
1
3
|
import { User } from '@things-factory/auth-base'
|
|
4
|
+
import { Sellercraft, SellercraftStatus } from '@things-factory/integration-sellercraft'
|
|
5
|
+
import { ReleaseGood } from '@things-factory/sales-base'
|
|
2
6
|
import { Domain } from '@things-factory/shell'
|
|
3
|
-
|
|
4
|
-
import { PackingWorksheetController } from '../../../../controllers'
|
|
7
|
+
|
|
8
|
+
import { PackingWorksheetController, SellercraftController } from '../../../../controllers'
|
|
5
9
|
import { Worksheet } from '../../../../entities'
|
|
6
10
|
|
|
7
11
|
export const activatePackingResolver = {
|
|
@@ -18,5 +22,18 @@ export async function activatePacking(
|
|
|
18
22
|
worksheetNo: string
|
|
19
23
|
): Promise<Worksheet> {
|
|
20
24
|
const worksheetController: PackingWorksheetController = new PackingWorksheetController(tx, domain, user)
|
|
21
|
-
|
|
25
|
+
const worksheet = await worksheetController.activatePacking(worksheetNo)
|
|
26
|
+
let releaseGood: ReleaseGood = worksheet.releaseGood
|
|
27
|
+
|
|
28
|
+
if (releaseGood.type == 'b2c') {
|
|
29
|
+
const sellercraft: Sellercraft = await tx
|
|
30
|
+
.getRepository(Sellercraft)
|
|
31
|
+
.findOne({ domain: releaseGood.bizplace.domain, status: SellercraftStatus.ACTIVE })
|
|
32
|
+
|
|
33
|
+
if (sellercraft) {
|
|
34
|
+
const sellercraftCtrl: SellercraftController = new SellercraftController(tx, domain, user)
|
|
35
|
+
await sellercraftCtrl.fetchOrderDocument(sellercraft, releaseGood)
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return worksheet
|
|
22
39
|
}
|