@things-factory/worksheet-base 4.3.356 → 4.3.358
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/worksheet.js +2 -1
- package/dist-server/constants/worksheet.js.map +1 -1
- package/dist-server/controllers/inspect/cycle-count-worksheet-controller.js +691 -257
- package/dist-server/controllers/inspect/cycle-count-worksheet-controller.js.map +1 -1
- package/dist-server/controllers/outbound/picking-worksheet-controller.js +76 -0
- package/dist-server/controllers/outbound/picking-worksheet-controller.js.map +1 -1
- package/dist-server/controllers/worksheet-controller.js +9 -2
- package/dist-server/controllers/worksheet-controller.js.map +1 -1
- package/dist-server/entities/worksheet-detail.js +9 -4
- package/dist-server/entities/worksheet-detail.js.map +1 -1
- package/dist-server/entities/worksheet.js +4 -0
- package/dist-server/entities/worksheet.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/check-stock-take-current-location.js +18 -11
- package/dist-server/graphql/resolvers/worksheet/check-stock-take-current-location.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/cycle-count-adjustment.js +75 -48
- package/dist-server/graphql/resolvers/worksheet/cycle-count-adjustment.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/cycle-count-worksheet-for-carton.js +82 -0
- package/dist-server/graphql/resolvers/worksheet/cycle-count-worksheet-for-carton.js.map +1 -0
- package/dist-server/graphql/resolvers/worksheet/cycle-count-worksheet-for-pallet.js +82 -0
- package/dist-server/graphql/resolvers/worksheet/cycle-count-worksheet-for-pallet.js.map +1 -0
- package/dist-server/graphql/resolvers/worksheet/generate-worksheet/generate-cycle-count-worksheet-carton.js +17 -0
- package/dist-server/graphql/resolvers/worksheet/generate-worksheet/generate-cycle-count-worksheet-carton.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/generate-worksheet/index.js +2 -1
- package/dist-server/graphql/resolvers/worksheet/generate-worksheet/index.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/index.js +3 -2
- package/dist-server/graphql/resolvers/worksheet/index.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/inspecting/add-extra-inventory.js +16 -0
- package/dist-server/graphql/resolvers/worksheet/inspecting/add-extra-inventory.js.map +1 -0
- package/dist-server/graphql/resolvers/worksheet/inspecting/check-missing-inventory-carton.js +16 -0
- package/dist-server/graphql/resolvers/worksheet/inspecting/check-missing-inventory-carton.js.map +1 -0
- package/dist-server/graphql/resolvers/worksheet/inspecting/check-missing-inventory.js +16 -0
- package/dist-server/graphql/resolvers/worksheet/inspecting/check-missing-inventory.js.map +1 -0
- package/dist-server/graphql/resolvers/worksheet/inspecting/index.js +9 -5
- package/dist-server/graphql/resolvers/worksheet/inspecting/index.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/inspecting/inspecting-carton.js +16 -0
- package/dist-server/graphql/resolvers/worksheet/inspecting/inspecting-carton.js.map +1 -0
- package/dist-server/graphql/resolvers/worksheet/inspecting/inspecting-pallet.js +16 -0
- package/dist-server/graphql/resolvers/worksheet/inspecting/inspecting-pallet.js.map +1 -0
- package/dist-server/graphql/resolvers/worksheet/inspecting/relocate-inventory-carton.js +16 -0
- package/dist-server/graphql/resolvers/worksheet/inspecting/relocate-inventory-carton.js.map +1 -0
- package/dist-server/graphql/resolvers/worksheet/inspecting/relocate-inventory.js +16 -0
- package/dist-server/graphql/resolvers/worksheet/inspecting/relocate-inventory.js.map +1 -0
- package/dist-server/graphql/resolvers/worksheet/inspecting/undo-inspection-carton.js +16 -0
- package/dist-server/graphql/resolvers/worksheet/inspecting/undo-inspection-carton.js.map +1 -0
- package/dist-server/graphql/resolvers/worksheet/not-tally-target-inventories.js +9 -5
- package/dist-server/graphql/resolvers/worksheet/not-tally-target-inventories.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/worksheet-with-pagination.js +9 -7
- package/dist-server/graphql/resolvers/worksheet/worksheet-with-pagination.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/worksheets.js +23 -9
- package/dist-server/graphql/resolvers/worksheet/worksheets.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet-detail/create-worksheet-detail.js +8 -1
- package/dist-server/graphql/resolvers/worksheet-detail/create-worksheet-detail.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet-detail/worksheet-detail.js +12 -1
- package/dist-server/graphql/resolvers/worksheet-detail/worksheet-detail.js.map +1 -1
- package/dist-server/graphql/types/worksheet/index.js +65 -9
- package/dist-server/graphql/types/worksheet/index.js.map +1 -1
- package/dist-server/graphql/types/worksheet/inventory-check-worksheet.js +2 -1
- package/dist-server/graphql/types/worksheet/inventory-check-worksheet.js.map +1 -1
- package/dist-server/graphql/types/worksheet/worksheet-detail-info.js +3 -0
- package/dist-server/graphql/types/worksheet/worksheet-detail-info.js.map +1 -1
- package/dist-server/graphql/types/worksheet/worksheet.js +2 -0
- package/dist-server/graphql/types/worksheet/worksheet.js.map +1 -1
- package/dist-server/graphql/types/worksheet-detail/new-worksheet-detail.js +1 -0
- package/dist-server/graphql/types/worksheet-detail/new-worksheet-detail.js.map +1 -1
- package/dist-server/graphql/types/worksheet-detail/worksheet-detail-patch.js +1 -0
- package/dist-server/graphql/types/worksheet-detail/worksheet-detail-patch.js.map +1 -1
- package/dist-server/graphql/types/worksheet-detail/worksheet-detail.js +1 -0
- package/dist-server/graphql/types/worksheet-detail/worksheet-detail.js.map +1 -1
- package/dist-server/utils/lmd-util.js +9 -8
- package/dist-server/utils/lmd-util.js.map +1 -1
- package/package.json +10 -10
- package/server/constants/worksheet.ts +2 -1
- package/server/controllers/inspect/cycle-count-worksheet-controller.ts +904 -296
- package/server/controllers/outbound/picking-worksheet-controller.ts +95 -1
- package/server/controllers/worksheet-controller.ts +10 -4
- package/server/entities/worksheet-detail.ts +7 -10
- package/server/entities/worksheet.ts +3 -0
- package/server/graphql/resolvers/worksheet/check-stock-take-current-location.ts +21 -14
- package/server/graphql/resolvers/worksheet/cycle-count-adjustment.ts +114 -51
- package/server/graphql/resolvers/worksheet/cycle-count-worksheet-for-carton.ts +90 -0
- package/server/graphql/resolvers/worksheet/cycle-count-worksheet-for-pallet.ts +91 -0
- package/server/graphql/resolvers/worksheet/generate-worksheet/generate-cycle-count-worksheet-carton.ts +57 -0
- package/server/graphql/resolvers/worksheet/generate-worksheet/generate-cycle-count-worksheet.ts +17 -11
- package/server/graphql/resolvers/worksheet/generate-worksheet/index.ts +2 -0
- package/server/graphql/resolvers/worksheet/index.ts +4 -2
- package/server/graphql/resolvers/worksheet/inspecting/{add-extra-pallet.ts → add-extra-inventory.ts} +27 -12
- package/server/graphql/resolvers/worksheet/inspecting/check-missing-inventory-carton.ts +24 -0
- package/server/graphql/resolvers/worksheet/inspecting/{check-missing-pallet.ts → check-missing-inventory.ts} +10 -5
- package/server/graphql/resolvers/worksheet/inspecting/index.ts +17 -9
- package/server/graphql/resolvers/worksheet/inspecting/inspecting-carton.ts +51 -0
- package/server/graphql/resolvers/worksheet/inspecting/{inspecting.ts → inspecting-pallet.ts} +5 -5
- package/server/graphql/resolvers/worksheet/inspecting/relocate-inventory-carton.ts +62 -0
- package/server/graphql/resolvers/worksheet/inspecting/{relocate-pallet.ts → relocate-inventory.ts} +15 -5
- package/server/graphql/resolvers/worksheet/inspecting/undo-inspection-carton.ts +24 -0
- package/server/graphql/resolvers/worksheet/not-tally-target-inventories.ts +11 -7
- package/server/graphql/resolvers/worksheet/worksheet-with-pagination.ts +9 -7
- package/server/graphql/resolvers/worksheet/worksheets.ts +57 -38
- package/server/graphql/resolvers/worksheet-detail/create-worksheet-detail.ts +10 -2
- package/server/graphql/resolvers/worksheet-detail/worksheet-detail.ts +12 -1
- package/server/graphql/types/worksheet/index.ts +65 -9
- package/server/graphql/types/worksheet/inventory-check-worksheet.ts +2 -1
- package/server/graphql/types/worksheet/worksheet-detail-info.ts +3 -0
- package/server/graphql/types/worksheet/worksheet.ts +2 -0
- package/server/graphql/types/worksheet-detail/new-worksheet-detail.ts +1 -0
- package/server/graphql/types/worksheet-detail/worksheet-detail-patch.ts +1 -0
- package/server/graphql/types/worksheet-detail/worksheet-detail.ts +1 -0
- package/server/utils/lmd-util.ts +25 -6
- package/tsconfig.json +1 -1
- package/dist-server/graphql/resolvers/worksheet/cycle-count-worksheet.js +0 -74
- package/dist-server/graphql/resolvers/worksheet/cycle-count-worksheet.js.map +0 -1
- package/dist-server/graphql/resolvers/worksheet/inspecting/add-extra-pallet.js +0 -16
- package/dist-server/graphql/resolvers/worksheet/inspecting/add-extra-pallet.js.map +0 -1
- package/dist-server/graphql/resolvers/worksheet/inspecting/check-missing-pallet.js +0 -16
- package/dist-server/graphql/resolvers/worksheet/inspecting/check-missing-pallet.js.map +0 -1
- package/dist-server/graphql/resolvers/worksheet/inspecting/inspecting.js +0 -16
- package/dist-server/graphql/resolvers/worksheet/inspecting/inspecting.js.map +0 -1
- package/dist-server/graphql/resolvers/worksheet/inspecting/relocate-pallet.js +0 -16
- package/dist-server/graphql/resolvers/worksheet/inspecting/relocate-pallet.js.map +0 -1
- package/server/graphql/resolvers/worksheet/cycle-count-worksheet.ts +0 -80
|
@@ -28,6 +28,7 @@ import {
|
|
|
28
28
|
ORDER_INVENTORY_STATUS,
|
|
29
29
|
ORDER_PRODUCT_STATUS,
|
|
30
30
|
ORDER_STATUS,
|
|
31
|
+
INVENTORY_CHECK_ITEM_STATUS,
|
|
31
32
|
ORDER_TYPES,
|
|
32
33
|
OrderInventory,
|
|
33
34
|
OrderNoGenerator,
|
|
@@ -37,7 +38,8 @@ import {
|
|
|
37
38
|
OrderToteSeal,
|
|
38
39
|
OrderVas,
|
|
39
40
|
PowrupController,
|
|
40
|
-
ReleaseGood
|
|
41
|
+
ReleaseGood,
|
|
42
|
+
InventoryCheckItem
|
|
41
43
|
} from '@things-factory/sales-base'
|
|
42
44
|
import { Setting } from '@things-factory/setting-base'
|
|
43
45
|
import { Domain } from '@things-factory/shell'
|
|
@@ -750,6 +752,29 @@ export class PickingWorksheetController extends VasWorksheetController {
|
|
|
750
752
|
let pickedUomValue = pickedQty * productDetail.uomValue
|
|
751
753
|
let matchingProduct
|
|
752
754
|
|
|
755
|
+
// validation to prevent picking if the inventory is involved in cycle count
|
|
756
|
+
let inventoryCheckItem: InventoryCheckItem = await this.trxMgr.getRepository(InventoryCheckItem).findOne({
|
|
757
|
+
where: {
|
|
758
|
+
domain: this.domain,
|
|
759
|
+
inventory: inventory.id,
|
|
760
|
+
status: In([
|
|
761
|
+
INVENTORY_CHECK_ITEM_STATUS.PENDING,
|
|
762
|
+
INVENTORY_CHECK_ITEM_STATUS.INSPECTING,
|
|
763
|
+
INVENTORY_CHECK_ITEM_STATUS.INSPECTED,
|
|
764
|
+
INVENTORY_CHECK_ITEM_STATUS.NOT_TALLY,
|
|
765
|
+
INVENTORY_CHECK_ITEM_STATUS.GROUP_NOT_TALLY,
|
|
766
|
+
INVENTORY_CHECK_ITEM_STATUS.MISSING,
|
|
767
|
+
INVENTORY_CHECK_ITEM_STATUS.ADDED
|
|
768
|
+
])
|
|
769
|
+
}
|
|
770
|
+
})
|
|
771
|
+
|
|
772
|
+
if (inventoryCheckItem) {
|
|
773
|
+
throw new Error(
|
|
774
|
+
`Inventory currently involved in an ongoing cycle count. Please complete the cycle count to proceed with picking.`
|
|
775
|
+
)
|
|
776
|
+
}
|
|
777
|
+
|
|
753
778
|
//validation to prevent duplicated picking
|
|
754
779
|
if (targetInventory?.status != ORDER_INVENTORY_STATUS.PICKING)
|
|
755
780
|
throw new Error(this.ERROR_MSG.VALIDITY.CANT_PROCEED_STEP_BY('picking', `is done`))
|
|
@@ -1018,6 +1043,29 @@ export class PickingWorksheetController extends VasWorksheetController {
|
|
|
1018
1043
|
let targetProduct: OrderProduct = targetInventory.orderProduct
|
|
1019
1044
|
let bizplace: Bizplace = worksheetDetail.worksheet.bizplace
|
|
1020
1045
|
|
|
1046
|
+
// validation to prevent picking if the inventory is involved in cycle count
|
|
1047
|
+
let inventoryCheckItem: InventoryCheckItem = await this.trxMgr.getRepository(InventoryCheckItem).findOne({
|
|
1048
|
+
where: {
|
|
1049
|
+
domain: this.domain,
|
|
1050
|
+
inventory: inventory.id,
|
|
1051
|
+
status: In([
|
|
1052
|
+
INVENTORY_CHECK_ITEM_STATUS.PENDING,
|
|
1053
|
+
INVENTORY_CHECK_ITEM_STATUS.INSPECTING,
|
|
1054
|
+
INVENTORY_CHECK_ITEM_STATUS.INSPECTED,
|
|
1055
|
+
INVENTORY_CHECK_ITEM_STATUS.NOT_TALLY,
|
|
1056
|
+
INVENTORY_CHECK_ITEM_STATUS.GROUP_NOT_TALLY,
|
|
1057
|
+
INVENTORY_CHECK_ITEM_STATUS.MISSING,
|
|
1058
|
+
INVENTORY_CHECK_ITEM_STATUS.ADDED
|
|
1059
|
+
])
|
|
1060
|
+
}
|
|
1061
|
+
})
|
|
1062
|
+
|
|
1063
|
+
if (inventoryCheckItem) {
|
|
1064
|
+
throw new Error(
|
|
1065
|
+
`Inventory currently involved in an ongoing cycle count. Please complete the cycle count to proceed with picking.`
|
|
1066
|
+
)
|
|
1067
|
+
}
|
|
1068
|
+
|
|
1021
1069
|
//validation to prevent duplicated picking
|
|
1022
1070
|
let oiValidate: OrderInventory = await this.trxMgr.getRepository(OrderInventory).findOne({
|
|
1023
1071
|
where: { domain: this.domain, id: targetInventory.id, status: ORDER_INVENTORY_STATUS.PICKING }
|
|
@@ -1202,6 +1250,29 @@ export class PickingWorksheetController extends VasWorksheetController {
|
|
|
1202
1250
|
where: { domain: this.domain, id: targetInventory.inventory.id }
|
|
1203
1251
|
})
|
|
1204
1252
|
|
|
1253
|
+
// validation to prevent picking if the inventory is involved in cycle count
|
|
1254
|
+
let inventoryCheckItem: InventoryCheckItem = await this.trxMgr.getRepository(InventoryCheckItem).findOne({
|
|
1255
|
+
where: {
|
|
1256
|
+
domain: this.domain,
|
|
1257
|
+
inventory: inventory.id,
|
|
1258
|
+
status: In([
|
|
1259
|
+
INVENTORY_CHECK_ITEM_STATUS.PENDING,
|
|
1260
|
+
INVENTORY_CHECK_ITEM_STATUS.INSPECTING,
|
|
1261
|
+
INVENTORY_CHECK_ITEM_STATUS.INSPECTED,
|
|
1262
|
+
INVENTORY_CHECK_ITEM_STATUS.NOT_TALLY,
|
|
1263
|
+
INVENTORY_CHECK_ITEM_STATUS.GROUP_NOT_TALLY,
|
|
1264
|
+
INVENTORY_CHECK_ITEM_STATUS.MISSING,
|
|
1265
|
+
INVENTORY_CHECK_ITEM_STATUS.ADDED
|
|
1266
|
+
])
|
|
1267
|
+
}
|
|
1268
|
+
})
|
|
1269
|
+
|
|
1270
|
+
if (inventoryCheckItem) {
|
|
1271
|
+
throw new Error(
|
|
1272
|
+
`Inventory currently involved in an ongoing cycle count. Please complete the cycle count to proceed with picking.`
|
|
1273
|
+
)
|
|
1274
|
+
}
|
|
1275
|
+
|
|
1205
1276
|
const releaseGood: ReleaseGood = targetInventory.releaseGood
|
|
1206
1277
|
|
|
1207
1278
|
if (inventory.palletId !== palletId)
|
|
@@ -1365,6 +1436,29 @@ export class PickingWorksheetController extends VasWorksheetController {
|
|
|
1365
1436
|
const releaseGood: ReleaseGood = targetInventory.releaseGood
|
|
1366
1437
|
if (pickedQty <= 0) break
|
|
1367
1438
|
|
|
1439
|
+
// validation to prevent picking if the inventory is involved in cycle count
|
|
1440
|
+
let inventoryCheckItem: InventoryCheckItem = await this.trxMgr.getRepository(InventoryCheckItem).findOne({
|
|
1441
|
+
where: {
|
|
1442
|
+
domain: this.domain,
|
|
1443
|
+
inventory: inventory.id,
|
|
1444
|
+
status: In([
|
|
1445
|
+
INVENTORY_CHECK_ITEM_STATUS.PENDING,
|
|
1446
|
+
INVENTORY_CHECK_ITEM_STATUS.INSPECTING,
|
|
1447
|
+
INVENTORY_CHECK_ITEM_STATUS.INSPECTED,
|
|
1448
|
+
INVENTORY_CHECK_ITEM_STATUS.NOT_TALLY,
|
|
1449
|
+
INVENTORY_CHECK_ITEM_STATUS.GROUP_NOT_TALLY,
|
|
1450
|
+
INVENTORY_CHECK_ITEM_STATUS.MISSING,
|
|
1451
|
+
INVENTORY_CHECK_ITEM_STATUS.ADDED
|
|
1452
|
+
])
|
|
1453
|
+
}
|
|
1454
|
+
})
|
|
1455
|
+
|
|
1456
|
+
if (inventoryCheckItem) {
|
|
1457
|
+
throw new Error(
|
|
1458
|
+
`Inventory currently involved in an ongoing cycle count. Please complete the cycle count to proceed with picking.`
|
|
1459
|
+
)
|
|
1460
|
+
}
|
|
1461
|
+
|
|
1368
1462
|
if (
|
|
1369
1463
|
targetInventory.status === ORDER_INVENTORY_STATUS.PICKING &&
|
|
1370
1464
|
targetReleaseQty > targetPickedQty &&
|
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
ArrivalNotice,
|
|
25
25
|
DeliveryOrder,
|
|
26
26
|
InventoryCheck,
|
|
27
|
+
InventoryCheckItem,
|
|
27
28
|
ORDER_INVENTORY_STATUS,
|
|
28
29
|
ORDER_PRODUCT_STATUS,
|
|
29
30
|
ORDER_VAS_STATUS,
|
|
@@ -62,7 +63,7 @@ export type ReferenceOrderType =
|
|
|
62
63
|
| DeliveryOrder
|
|
63
64
|
| ReturnOrder
|
|
64
65
|
| Replenishment
|
|
65
|
-
export type OrderTargetTypes = OrderProduct | OrderInventory | OrderVas
|
|
66
|
+
export type OrderTargetTypes = OrderProduct | OrderInventory | OrderVas | InventoryCheckItem
|
|
66
67
|
|
|
67
68
|
export enum ReferenceOrderFields {
|
|
68
69
|
ArrivalNotice = 'arrivalNotice',
|
|
@@ -76,7 +77,8 @@ export enum ReferenceOrderFields {
|
|
|
76
77
|
export enum OrderTargetFields {
|
|
77
78
|
OrderProduct = 'targetProduct',
|
|
78
79
|
OrderInventory = 'targetInventory',
|
|
79
|
-
OrderVas = 'targetVas'
|
|
80
|
+
OrderVas = 'targetVas',
|
|
81
|
+
InventoryCheckItem = 'targetInventoryCheckItem'
|
|
80
82
|
}
|
|
81
83
|
|
|
82
84
|
export interface BasicInterface {
|
|
@@ -168,6 +170,8 @@ export class WorksheetController {
|
|
|
168
170
|
return OrderTargetFields.OrderInventory
|
|
169
171
|
} else if (orderTarget instanceof OrderVas) {
|
|
170
172
|
return OrderTargetFields.OrderVas
|
|
173
|
+
} else if (orderTarget instanceof InventoryCheckItem) {
|
|
174
|
+
return OrderTargetFields.InventoryCheckItem
|
|
171
175
|
} else {
|
|
172
176
|
this.ERROR_MSG.VALIDITY.UNEXPECTED_FIELD_VALUE('orderTarget', 'One of order target type', orderTarget)
|
|
173
177
|
}
|
|
@@ -591,9 +595,9 @@ export class WorksheetController {
|
|
|
591
595
|
}
|
|
592
596
|
|
|
593
597
|
/**
|
|
594
|
-
* @summary Update order targets (OrderProduct, OrderInventory, OrderVas)
|
|
598
|
+
* @summary Update order targets (OrderProduct, OrderInventory, OrderVas, InventoryCheckItem)
|
|
595
599
|
* @description
|
|
596
|
-
* Update order targets like (OrderProduct, OrderInventory, OrderVas)
|
|
600
|
+
* Update order targets like (OrderProduct, OrderInventory, OrderVas, InventoryCheckItem)
|
|
597
601
|
*/
|
|
598
602
|
async updateOrderTargets(orderTargets: OrderTargetTypes[], entitySchema?: EntitySchema): Promise<any> {
|
|
599
603
|
if (orderTargets.some((orderTarget: any) => !orderTarget.id)) throw new Error(this.ERROR_MSG.UPDATE.ID_NOT_EXISTS)
|
|
@@ -609,6 +613,8 @@ export class WorksheetController {
|
|
|
609
613
|
entitySchema = OrderInventory
|
|
610
614
|
} else if (orderTargets[0] instanceof OrderVas) {
|
|
611
615
|
entitySchema = OrderVas
|
|
616
|
+
} else if (orderTargets[0] instanceof InventoryCheckItem) {
|
|
617
|
+
entitySchema = InventoryCheckItem
|
|
612
618
|
}
|
|
613
619
|
}
|
|
614
620
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { User } from '@things-factory/auth-base'
|
|
2
2
|
import { Bizplace, Worker } from '@things-factory/biz-base'
|
|
3
|
-
import { OrderInventory, OrderProduct, OrderVas } from '@things-factory/sales-base'
|
|
3
|
+
import { OrderInventory, OrderProduct, OrderVas, InventoryCheckItem } from '@things-factory/sales-base'
|
|
4
4
|
import { Domain } from '@things-factory/shell'
|
|
5
5
|
import { Location } from '@things-factory/warehouse-base'
|
|
6
6
|
import { Column, CreateDateColumn, Entity, Index, ManyToOne, PrimaryGeneratedColumn, UpdateDateColumn } from 'typeorm'
|
|
@@ -12,15 +12,9 @@ import { Worksheet } from './worksheet'
|
|
|
12
12
|
(worksheetDetail: WorksheetDetail) => [worksheetDetail.domain, worksheetDetail.bizplace, worksheetDetail.name],
|
|
13
13
|
{ unique: true }
|
|
14
14
|
)
|
|
15
|
-
@Index(
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
)
|
|
19
|
-
@Index(
|
|
20
|
-
'ix_worksheet-detail_2',
|
|
21
|
-
(worksheetDetail: WorksheetDetail) => [worksheetDetail.id],
|
|
22
|
-
{ unique: true }
|
|
23
|
-
)
|
|
15
|
+
@Index('ix_worksheet-detail_1', (worksheetDetail: WorksheetDetail) => [worksheetDetail.targetInventory])
|
|
16
|
+
@Index('ix_worksheet-detail_2', (worksheetDetail: WorksheetDetail) => [worksheetDetail.id], { unique: true })
|
|
17
|
+
@Index('ix_worksheet-detail_3', (worksheetDetail: WorksheetDetail) => [worksheetDetail.targetInventoryCheckItem])
|
|
24
18
|
export class WorksheetDetail {
|
|
25
19
|
@PrimaryGeneratedColumn('uuid')
|
|
26
20
|
id: string
|
|
@@ -78,6 +72,9 @@ export class WorksheetDetail {
|
|
|
78
72
|
@ManyToOne(type => Location)
|
|
79
73
|
toLocation: Location
|
|
80
74
|
|
|
75
|
+
@ManyToOne(type => InventoryCheckItem)
|
|
76
|
+
targetInventoryCheckItem: InventoryCheckItem
|
|
77
|
+
|
|
81
78
|
@Column({
|
|
82
79
|
nullable: true
|
|
83
80
|
})
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Domain } from '@things-factory/shell'
|
|
2
2
|
import { getRepository, Repository } from 'typeorm'
|
|
3
3
|
import { Inventory } from '@things-factory/warehouse-base'
|
|
4
|
-
import { InventoryCheck,
|
|
4
|
+
import { InventoryCheck, InventoryCheckItem } from '@things-factory/sales-base'
|
|
5
5
|
import { WorksheetDetail } from '../../../entities'
|
|
6
6
|
|
|
7
7
|
export const checkStockTakeCurrentLocationResolver = {
|
|
@@ -16,29 +16,33 @@ export const checkStockTakeCurrentLocationResolver = {
|
|
|
16
16
|
where: { domain, palletId },
|
|
17
17
|
relations: ['bizplace']
|
|
18
18
|
})
|
|
19
|
-
|
|
19
|
+
// need to change InventoryCheckItem
|
|
20
20
|
const cycleCount: InventoryCheck = await inventoryCheckRepo.findOne({
|
|
21
21
|
where: { domain, name: cycleCountNo },
|
|
22
22
|
relations: [
|
|
23
|
-
'
|
|
24
|
-
'
|
|
25
|
-
'
|
|
26
|
-
'
|
|
23
|
+
'inventoryCheckItems',
|
|
24
|
+
'inventoryCheckItems.inventory',
|
|
25
|
+
'inventoryCheckItems.inventory.location',
|
|
26
|
+
'inventoryCheckItems.inventory.product'
|
|
27
27
|
]
|
|
28
28
|
})
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
if (!cycleCount) {
|
|
31
|
+
throw new Error('Cycle count not found')
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const inventoryCheckItems: InventoryCheckItem[] = cycleCount.inventoryCheckItems
|
|
31
35
|
|
|
32
|
-
const foundInventory: Inventory =
|
|
33
|
-
(
|
|
36
|
+
const foundInventory: Inventory = inventoryCheckItems.find(
|
|
37
|
+
(ici: InventoryCheckItem) => ici.inventory.palletId === inventory.palletId
|
|
34
38
|
)?.inventory
|
|
35
39
|
|
|
36
40
|
const foundWSD: any[] = await Promise.all(
|
|
37
|
-
|
|
38
|
-
.filter((
|
|
39
|
-
.map(async (
|
|
41
|
+
inventoryCheckItems
|
|
42
|
+
.filter((ici: InventoryCheckItem) => ici.inventory.palletId === inventory.palletId)
|
|
43
|
+
.map(async (ici: InventoryCheckItem) => {
|
|
40
44
|
const matchingWSD = await worksheetDetailRepo.findOne({
|
|
41
|
-
where: { domain,
|
|
45
|
+
where: { domain, targetInventoryCheckItem: ici }
|
|
42
46
|
})
|
|
43
47
|
|
|
44
48
|
return matchingWSD
|
|
@@ -50,6 +54,7 @@ export const checkStockTakeCurrentLocationResolver = {
|
|
|
50
54
|
return {
|
|
51
55
|
worksheetDetailName: foundWSD[0].name,
|
|
52
56
|
currentLocation: foundInventory.location.name,
|
|
57
|
+
cartonId: foundInventory.cartonId,
|
|
53
58
|
palletId: foundInventory.palletId,
|
|
54
59
|
batchId: foundInventory.batchId,
|
|
55
60
|
qty: foundInventory.qty,
|
|
@@ -58,6 +63,8 @@ export const checkStockTakeCurrentLocationResolver = {
|
|
|
58
63
|
productName: foundInventory.product.name,
|
|
59
64
|
productDescription: foundInventory.product.description
|
|
60
65
|
}
|
|
61
|
-
} catch (e) {
|
|
66
|
+
} catch (e) {
|
|
67
|
+
console.error(e)
|
|
68
|
+
}
|
|
62
69
|
}
|
|
63
70
|
}
|
|
@@ -4,10 +4,11 @@ import { Application, ApplicationType, User } from '@things-factory/auth-base'
|
|
|
4
4
|
import { Sellercraft, SellercraftStatus } from '@things-factory/integration-sellercraft'
|
|
5
5
|
import {
|
|
6
6
|
InventoryCheck,
|
|
7
|
+
InventoryCheckItem,
|
|
7
8
|
ORDER_INVENTORY_STATUS,
|
|
8
9
|
ORDER_STATUS,
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
PowrupController,
|
|
11
|
+
INVENTORY_CHECK_ITEM_STATUS
|
|
11
12
|
} from '@things-factory/sales-base'
|
|
12
13
|
|
|
13
14
|
import { Domain } from '@things-factory/shell'
|
|
@@ -16,19 +17,23 @@ import {
|
|
|
16
17
|
INVENTORY_STATUS,
|
|
17
18
|
INVENTORY_TRANSACTION_TYPE,
|
|
18
19
|
Location,
|
|
19
|
-
generateInventoryHistory
|
|
20
|
+
generateInventoryHistory,
|
|
21
|
+
InventoryNoGenerator,
|
|
22
|
+
InventoryHistory
|
|
20
23
|
} from '@things-factory/warehouse-base'
|
|
21
24
|
import { Bizplace, getCompanyBizplace } from '@things-factory/biz-base'
|
|
25
|
+
import { PartnerSetting, Setting } from '@things-factory/setting-base'
|
|
26
|
+
import { generateId } from '@things-factory/id-rule-base'
|
|
22
27
|
|
|
23
28
|
import { WORKSHEET_STATUS, WORKSHEET_TYPE } from '../../../constants'
|
|
24
|
-
import { SellercraftController } from '../../../controllers'
|
|
29
|
+
import { SellercraftController, WorksheetController } from '../../../controllers'
|
|
25
30
|
import { Worksheet, WorksheetDetail } from '../../../entities'
|
|
26
31
|
import { switchLocationStatus } from '../../../utils'
|
|
27
32
|
|
|
28
33
|
export const cycleCountAdjustmentResolver = {
|
|
29
|
-
async cycleCountAdjustment(_: any, { cycleCountNo }, context: any) {
|
|
34
|
+
async cycleCountAdjustment(_: any, { worksheetNo, cycleCountNo }, context: any) {
|
|
30
35
|
const { tx, domain, user }: { tx: EntityManager; domain: Domain; user: User } = context.state
|
|
31
|
-
await cycleCountAdjustment(tx, domain, user, cycleCountNo)
|
|
36
|
+
await cycleCountAdjustment(tx, domain, user, worksheetNo, cycleCountNo)
|
|
32
37
|
}
|
|
33
38
|
}
|
|
34
39
|
|
|
@@ -36,20 +41,21 @@ export async function cycleCountAdjustment(
|
|
|
36
41
|
tx: EntityManager,
|
|
37
42
|
domain: Domain,
|
|
38
43
|
user: User,
|
|
44
|
+
worksheetNo: string,
|
|
39
45
|
cycleCountNo: string
|
|
40
46
|
): Promise<void> {
|
|
41
47
|
// get cycle count no
|
|
42
48
|
const cycleCount: InventoryCheck = await tx.getRepository(InventoryCheck).findOne({
|
|
43
49
|
where: {
|
|
44
50
|
domain,
|
|
45
|
-
name: cycleCountNo
|
|
46
|
-
status: ORDER_STATUS.PENDING_REVIEW
|
|
51
|
+
name: cycleCountNo
|
|
47
52
|
}
|
|
48
53
|
})
|
|
49
54
|
|
|
50
55
|
let worksheet: Worksheet = await tx.getRepository(Worksheet).findOne({
|
|
51
56
|
where: {
|
|
52
57
|
domain,
|
|
58
|
+
name: worksheetNo,
|
|
53
59
|
type: In([WORKSHEET_TYPE.CYCLE_COUNT, WORKSHEET_TYPE.CYCLE_COUNT_RECHECK]),
|
|
54
60
|
inventoryCheck: cycleCount
|
|
55
61
|
}
|
|
@@ -64,36 +70,37 @@ export async function cycleCountAdjustment(
|
|
|
64
70
|
status: WORKSHEET_STATUS.NOT_TALLY
|
|
65
71
|
},
|
|
66
72
|
relations: [
|
|
67
|
-
'
|
|
68
|
-
'
|
|
69
|
-
'
|
|
70
|
-
'
|
|
71
|
-
'
|
|
72
|
-
'
|
|
73
|
-
'
|
|
74
|
-
'
|
|
75
|
-
'
|
|
76
|
-
'
|
|
77
|
-
'
|
|
78
|
-
'
|
|
79
|
-
'
|
|
73
|
+
'targetInventoryCheckItem',
|
|
74
|
+
'targetInventoryCheckItem.inventoryCheck',
|
|
75
|
+
'targetInventoryCheckItem.inventory',
|
|
76
|
+
'targetInventoryCheckItem.inventory.product',
|
|
77
|
+
'targetInventoryCheckItem.inventory.productDetail',
|
|
78
|
+
'targetInventoryCheckItem.inventory.product.productDetails',
|
|
79
|
+
'targetInventoryCheckItem.inventory.product.productDetails.childProductDetail',
|
|
80
|
+
'targetInventoryCheckItem.inventory.bizplace',
|
|
81
|
+
'targetInventoryCheckItem.inventory.domain',
|
|
82
|
+
'targetInventoryCheckItem.inventory.bizplace.domain',
|
|
83
|
+
'targetInventoryCheckItem.inventory.warehouse',
|
|
84
|
+
'targetInventoryCheckItem.inventory.location',
|
|
85
|
+
'targetInventoryCheckItem.inspectedLocation',
|
|
86
|
+
'targetInventoryCheckItem.inspectedLocation.warehouse'
|
|
80
87
|
]
|
|
81
88
|
})
|
|
82
89
|
|
|
83
90
|
for (let worksheetDetail of worksheetDetails) {
|
|
84
|
-
const
|
|
85
|
-
let inventory: Inventory =
|
|
91
|
+
const targetInventoryCheckItem: InventoryCheckItem = worksheetDetail.targetInventoryCheckItem
|
|
92
|
+
let inventory: Inventory = targetInventoryCheckItem.inventory
|
|
86
93
|
|
|
87
|
-
let transactQty: number =
|
|
88
|
-
let transactUomValue: number =
|
|
94
|
+
let transactQty: number = targetInventoryCheckItem.inspectedQty - inventory.qty
|
|
95
|
+
let transactUomValue: number = targetInventoryCheckItem.inspectedUomValue - inventory.uomValue
|
|
89
96
|
|
|
90
97
|
const sellercraft: Sellercraft = await tx.getRepository(Sellercraft).findOne({
|
|
91
98
|
where: { domain: inventory.bizplace.domain, status: SellercraftStatus.ACTIVE },
|
|
92
99
|
relations: ['domain']
|
|
93
100
|
})
|
|
94
101
|
|
|
95
|
-
const customerDomain: Domain =
|
|
96
|
-
const customerBizplaceId: string =
|
|
102
|
+
const customerDomain: Domain = targetInventoryCheckItem.inventory.bizplace.domain
|
|
103
|
+
const customerBizplaceId: string = targetInventoryCheckItem.inventory.bizplace.id
|
|
97
104
|
const companyBizplace: Bizplace = await getCompanyBizplace(domain, null, customerBizplaceId, tx)
|
|
98
105
|
const application: Application = await tx.getRepository(Application).findOne({
|
|
99
106
|
domain: companyBizplace.domain,
|
|
@@ -101,7 +108,7 @@ export async function cycleCountAdjustment(
|
|
|
101
108
|
type: ApplicationType.POWRUP
|
|
102
109
|
})
|
|
103
110
|
|
|
104
|
-
if (
|
|
111
|
+
if (targetInventoryCheckItem.status === ORDER_INVENTORY_STATUS.MISSING) {
|
|
105
112
|
// create STORED, CC_ADJUSTMENT history
|
|
106
113
|
await generateInventoryHistory(
|
|
107
114
|
inventory,
|
|
@@ -133,7 +140,7 @@ export async function cycleCountAdjustment(
|
|
|
133
140
|
const powrupController: PowrupController = new PowrupController()
|
|
134
141
|
powrupController.updateStock([inventory], customerDomain, user, tx)
|
|
135
142
|
}
|
|
136
|
-
} else if (
|
|
143
|
+
} else if (targetInventoryCheckItem.inspectedQty == 0) {
|
|
137
144
|
// create STORED, CC_ADJUSTMENT history
|
|
138
145
|
await generateInventoryHistory(
|
|
139
146
|
inventory,
|
|
@@ -146,13 +153,13 @@ export async function cycleCountAdjustment(
|
|
|
146
153
|
)
|
|
147
154
|
|
|
148
155
|
// change inventory qty to 0 and terminate it
|
|
149
|
-
inventory.batchId =
|
|
150
|
-
inventory.qty =
|
|
156
|
+
inventory.batchId = targetInventoryCheckItem.inspectedBatchNo
|
|
157
|
+
inventory.qty = targetInventoryCheckItem.inspectedQty
|
|
151
158
|
inventory.lockedQty = 0
|
|
152
|
-
inventory.uomValue =
|
|
159
|
+
inventory.uomValue = targetInventoryCheckItem.inspectedUomValue
|
|
153
160
|
inventory.lockedUomValue = 0
|
|
154
|
-
inventory.location =
|
|
155
|
-
inventory.warehouse =
|
|
161
|
+
inventory.location = targetInventoryCheckItem.inspectedLocation
|
|
162
|
+
inventory.warehouse = targetInventoryCheckItem.inspectedLocation.warehouse
|
|
156
163
|
inventory.status = INVENTORY_STATUS.TERMINATED
|
|
157
164
|
inventory.updater = user
|
|
158
165
|
inventory = await tx.getRepository(Inventory).save(inventory)
|
|
@@ -169,10 +176,52 @@ export async function cycleCountAdjustment(
|
|
|
169
176
|
const powrupController: PowrupController = new PowrupController()
|
|
170
177
|
powrupController.updateStock([inventory], customerDomain, user, tx)
|
|
171
178
|
}
|
|
179
|
+
} else if (targetInventoryCheckItem.status === INVENTORY_CHECK_ITEM_STATUS.ADDED) {
|
|
180
|
+
const inventories: Inventory[] = await tx.getRepository(Inventory).find({
|
|
181
|
+
where: { id: targetInventoryCheckItem.inventory.id, domain, status: INVENTORY_STATUS.CC_ADDED }
|
|
182
|
+
})
|
|
183
|
+
|
|
184
|
+
for (let inventory of inventories) {
|
|
185
|
+
inventory.status = INVENTORY_STATUS.STORED
|
|
186
|
+
inventory.creator = user
|
|
187
|
+
inventory.updater = user
|
|
188
|
+
await tx.getRepository(Inventory).save(inventory)
|
|
189
|
+
|
|
190
|
+
await tx.getRepository(InventoryHistory).save({
|
|
191
|
+
...targetInventoryCheckItem,
|
|
192
|
+
seq: inventory.lastSeq,
|
|
193
|
+
refOrderId: targetInventoryCheckItem.inventoryCheckId,
|
|
194
|
+
orderNo: targetInventoryCheckItem.inventoryCheck.name,
|
|
195
|
+
name: InventoryNoGenerator.inventoryHistoryName(),
|
|
196
|
+
palletId: inventory.palletId,
|
|
197
|
+
batchId: inventory.batchId,
|
|
198
|
+
zone: inventory.zone,
|
|
199
|
+
packingType: inventory.packingType,
|
|
200
|
+
qty: inventory.qty || 0,
|
|
201
|
+
openingQty: 0,
|
|
202
|
+
uomValue: inventory.uomValue || 0,
|
|
203
|
+
openingUomValue: 0,
|
|
204
|
+
status: inventory.status,
|
|
205
|
+
transactionType: INVENTORY_TRANSACTION_TYPE.CC_ADJUSTMENT,
|
|
206
|
+
createdAt: inventory.createdAt,
|
|
207
|
+
updatedAt: inventory.updatedAt,
|
|
208
|
+
domain: domain,
|
|
209
|
+
bizplace: targetInventoryCheckItem.inventory.bizplace,
|
|
210
|
+
inventory: inventory.id,
|
|
211
|
+
cartonId: inventory.cartonId,
|
|
212
|
+
creator: user,
|
|
213
|
+
updater: user,
|
|
214
|
+
product: targetInventoryCheckItem.inventory.product,
|
|
215
|
+
productDetail: targetInventoryCheckItem.inventory.productDetail,
|
|
216
|
+
packingSize: inventory.packingSize,
|
|
217
|
+
warehouse: targetInventoryCheckItem.inventory.warehouse,
|
|
218
|
+
location: targetInventoryCheckItem.inventory.location
|
|
219
|
+
})
|
|
220
|
+
}
|
|
172
221
|
} else {
|
|
173
222
|
const prevLocationId: string = inventory.location.id
|
|
174
223
|
|
|
175
|
-
if (
|
|
224
|
+
if (targetInventoryCheckItem.inspectedBatchNo !== inventory.batchId) {
|
|
176
225
|
// generate TERMINATED, ADJUSTMENT history
|
|
177
226
|
const { qty, uomValue }: { qty: number; uomValue: number } = inventory
|
|
178
227
|
inventory.status = INVENTORY_STATUS.TERMINATED
|
|
@@ -189,22 +238,20 @@ export async function cycleCountAdjustment(
|
|
|
189
238
|
tx
|
|
190
239
|
)
|
|
191
240
|
|
|
192
|
-
transactQty =
|
|
193
|
-
transactUomValue =
|
|
241
|
+
transactQty = targetInventoryCheckItem.inspectedQty
|
|
242
|
+
transactUomValue = targetInventoryCheckItem.inspectedUomValue
|
|
194
243
|
}
|
|
195
244
|
|
|
196
|
-
inventory.batchId =
|
|
197
|
-
inventory.qty =
|
|
198
|
-
inventory.
|
|
199
|
-
inventory.
|
|
200
|
-
inventory.
|
|
201
|
-
inventory.location = targetInventory.inspectedLocation
|
|
202
|
-
inventory.warehouse = targetInventory.inspectedLocation.warehouse
|
|
245
|
+
inventory.batchId = targetInventoryCheckItem.inspectedBatchNo
|
|
246
|
+
inventory.qty = targetInventoryCheckItem.inspectedQty
|
|
247
|
+
inventory.uomValue = targetInventoryCheckItem.inspectedUomValue
|
|
248
|
+
inventory.location = targetInventoryCheckItem.inspectedLocation || inventory.location
|
|
249
|
+
inventory.warehouse = targetInventoryCheckItem.inspectedLocation.warehouse || inventory.warehouse
|
|
203
250
|
inventory.status = INVENTORY_STATUS.STORED
|
|
204
251
|
inventory.updater = user
|
|
205
252
|
inventory = await tx.getRepository(Inventory).save(inventory)
|
|
206
253
|
|
|
207
|
-
if (prevLocationId !==
|
|
254
|
+
if (prevLocationId !== targetInventoryCheckItem.inspectedLocation.id) {
|
|
208
255
|
const prevLocation: Location = await tx.getRepository(Location).findOne(prevLocationId)
|
|
209
256
|
await switchLocationStatus(domain, prevLocation, user, tx)
|
|
210
257
|
}
|
|
@@ -230,9 +277,9 @@ export async function cycleCountAdjustment(
|
|
|
230
277
|
powrupController.updateStock([inventory], customerDomain, user, tx)
|
|
231
278
|
}
|
|
232
279
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
await tx.getRepository(
|
|
280
|
+
targetInventoryCheckItem.status = ORDER_INVENTORY_STATUS.TERMINATED
|
|
281
|
+
targetInventoryCheckItem.updater = user
|
|
282
|
+
await tx.getRepository(InventoryCheckItem).save(targetInventoryCheckItem)
|
|
236
283
|
|
|
237
284
|
worksheetDetail.status = WORKSHEET_STATUS.ADJUSTED
|
|
238
285
|
worksheetDetail.updater = user
|
|
@@ -242,8 +289,24 @@ export async function cycleCountAdjustment(
|
|
|
242
289
|
worksheet.status = WORKSHEET_STATUS.DONE
|
|
243
290
|
await tx.getRepository(Worksheet).save(worksheet)
|
|
244
291
|
|
|
245
|
-
//
|
|
246
|
-
|
|
247
|
-
|
|
292
|
+
// Search for any worksheets in EXECUTING
|
|
293
|
+
let worksheets: Worksheet[] = await tx.getRepository(Worksheet).find({
|
|
294
|
+
where: {
|
|
295
|
+
domain,
|
|
296
|
+
type: In([WORKSHEET_TYPE.CYCLE_COUNT, WORKSHEET_TYPE.CYCLE_COUNT_RECHECK]),
|
|
297
|
+
inventoryCheck: cycleCount,
|
|
298
|
+
status: WORKSHEET_STATUS.EXECUTING
|
|
299
|
+
}
|
|
300
|
+
})
|
|
301
|
+
|
|
302
|
+
// Check if there is worksheets in executing, cycle count status change to INSPECTING
|
|
303
|
+
if (worksheets.length > 0 && cycleCount.status !== 'INSPECTING') {
|
|
304
|
+
cycleCount.status = ORDER_STATUS.INSPECTING
|
|
305
|
+
cycleCount.updater = user
|
|
306
|
+
} else if ((worksheets.length == 0 && cycleCount.status !== 'DONE') || cycleCount.status == 'PENDING_REVIEW') {
|
|
307
|
+
// change cycle count status to DONE
|
|
308
|
+
cycleCount.status = ORDER_STATUS.DONE
|
|
309
|
+
cycleCount.updater = user
|
|
310
|
+
}
|
|
248
311
|
await tx.getRepository(InventoryCheck).save(cycleCount)
|
|
249
312
|
}
|