@things-factory/worksheet-base 4.3.80-alpha.1 → 4.3.81
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/sellercraft-controller.js +3 -0
- package/dist-server/controllers/ecommerce/sellercraft-controller.js.map +1 -1
- package/dist-server/controllers/inbound/unloading-worksheet-controller.js +49 -49
- package/dist-server/controllers/inbound/unloading-worksheet-controller.js.map +1 -1
- package/dist-server/controllers/inspect/cycle-count-worksheet-controller.js +4 -2
- package/dist-server/controllers/inspect/cycle-count-worksheet-controller.js.map +1 -1
- package/dist-server/controllers/outbound/loading-worksheet-controller.js +4 -10
- package/dist-server/controllers/outbound/loading-worksheet-controller.js.map +1 -1
- package/dist-server/controllers/outbound/packing-worksheet-controller.js +20 -22
- package/dist-server/controllers/outbound/packing-worksheet-controller.js.map +1 -1
- package/dist-server/controllers/outbound/picking-worksheet-controller.js +39 -34
- package/dist-server/controllers/outbound/picking-worksheet-controller.js.map +1 -1
- package/dist-server/controllers/outbound/sorting-worksheet-controller.js +14 -12
- package/dist-server/controllers/outbound/sorting-worksheet-controller.js.map +1 -1
- package/dist-server/controllers/vas/vas-worksheet-controller.js +2 -1
- package/dist-server/controllers/vas/vas-worksheet-controller.js.map +1 -1
- package/dist-server/controllers/worksheet-controller.js +3 -2
- package/dist-server/controllers/worksheet-controller.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/batch-picking-worksheet.js +0 -6
- package/dist-server/graphql/resolvers/worksheet/batch-picking-worksheet.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/confirm-cancellation-release-order.js +2 -1
- package/dist-server/graphql/resolvers/worksheet/confirm-cancellation-release-order.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/cycle-count-adjustment.js +6 -6
- package/dist-server/graphql/resolvers/worksheet/cycle-count-adjustment.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/inventories-by-pallet.js +1 -2
- package/dist-server/graphql/resolvers/worksheet/inventories-by-pallet.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/loading/complete-loading.js +28 -67
- package/dist-server/graphql/resolvers/worksheet/loading/complete-loading.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/packing/activate-packing.js +8 -23
- package/dist-server/graphql/resolvers/worksheet/packing/activate-packing.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/packing/complete-packing.js +7 -30
- package/dist-server/graphql/resolvers/worksheet/packing/complete-packing.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/packing/packing.js +8 -23
- package/dist-server/graphql/resolvers/worksheet/packing/packing.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/packing/scan-product-packing.js +8 -25
- package/dist-server/graphql/resolvers/worksheet/packing/scan-product-packing.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/packing-worksheet.js +12 -59
- package/dist-server/graphql/resolvers/worksheet/packing-worksheet.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/picking/activate-picking.js +25 -51
- package/dist-server/graphql/resolvers/worksheet/picking/activate-picking.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/picking/complete-batch-picking.js +2 -2
- package/dist-server/graphql/resolvers/worksheet/picking/complete-batch-picking.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/picking/complete-picking.js +118 -262
- package/dist-server/graphql/resolvers/worksheet/picking/complete-picking.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/picking-worksheet.js +2 -3
- package/dist-server/graphql/resolvers/worksheet/picking-worksheet.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/proceed-extra-products.js +4 -6
- package/dist-server/graphql/resolvers/worksheet/proceed-extra-products.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/putaway/complete-putaway.js +14 -39
- package/dist-server/graphql/resolvers/worksheet/putaway/complete-putaway.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/transfer.js +9 -9
- package/dist-server/graphql/resolvers/worksheet/transfer.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/vas-transactions/common-utils.js +17 -17
- package/dist-server/graphql/resolvers/worksheet/vas-transactions/common-utils.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/worksheet.js +6 -4
- package/dist-server/graphql/resolvers/worksheet/worksheet.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet-detail/regenerate-release-good-worksheet-details.js +4 -4
- package/dist-server/graphql/resolvers/worksheet-detail/regenerate-release-good-worksheet-details.js.map +1 -1
- package/dist-server/graphql/types/worksheet-detail/index.js +0 -1
- package/dist-server/graphql/types/worksheet-detail/index.js.map +1 -1
- package/dist-server/utils/inventory-util.js +98 -1
- package/dist-server/utils/inventory-util.js.map +1 -1
- package/package.json +17 -17
- package/server/controllers/ecommerce/sellercraft-controller.ts +3 -0
- package/server/controllers/inbound/unloading-worksheet-controller.ts +70 -49
- package/server/controllers/inspect/cycle-count-worksheet-controller.ts +4 -2
- package/server/controllers/outbound/loading-worksheet-controller.ts +3 -9
- package/server/controllers/outbound/packing-worksheet-controller.ts +31 -23
- package/server/controllers/outbound/picking-worksheet-controller.ts +51 -34
- package/server/controllers/outbound/sorting-worksheet-controller.ts +12 -12
- package/server/controllers/vas/vas-worksheet-controller.ts +2 -2
- package/server/controllers/worksheet-controller.ts +6 -4
- package/server/graphql/resolvers/worksheet/batch-picking-worksheet.ts +0 -6
- package/server/graphql/resolvers/worksheet/confirm-cancellation-release-order.ts +2 -1
- package/server/graphql/resolvers/worksheet/cycle-count-adjustment.ts +2 -2
- package/server/graphql/resolvers/worksheet/inventories-by-pallet.ts +1 -3
- package/server/graphql/resolvers/worksheet/loading/complete-loading.ts +33 -77
- package/server/graphql/resolvers/worksheet/packing/activate-packing.ts +9 -26
- package/server/graphql/resolvers/worksheet/packing/complete-packing.ts +9 -34
- package/server/graphql/resolvers/worksheet/packing/packing.ts +9 -26
- package/server/graphql/resolvers/worksheet/packing/scan-product-packing.ts +9 -28
- package/server/graphql/resolvers/worksheet/packing-worksheet.ts +13 -68
- package/server/graphql/resolvers/worksheet/picking/activate-picking.ts +30 -60
- package/server/graphql/resolvers/worksheet/picking/complete-batch-picking.ts +2 -2
- package/server/graphql/resolvers/worksheet/picking/complete-picking.ts +130 -288
- package/server/graphql/resolvers/worksheet/picking-worksheet.ts +2 -3
- package/server/graphql/resolvers/worksheet/proceed-extra-products.ts +4 -5
- package/server/graphql/resolvers/worksheet/putaway/complete-putaway.ts +15 -45
- package/server/graphql/resolvers/worksheet/transfer.ts +16 -18
- package/server/graphql/resolvers/worksheet/vas-transactions/common-utils.ts +2 -3
- package/server/graphql/resolvers/worksheet/worksheet.ts +15 -13
- package/server/graphql/resolvers/worksheet-detail/regenerate-release-good-worksheet-details.ts +1 -4
- package/server/graphql/types/worksheet-detail/index.ts +0 -1
- package/server/utils/inventory-util.ts +126 -1
|
@@ -1,36 +1,38 @@
|
|
|
1
|
-
import { EntityManager } from 'typeorm'
|
|
2
|
-
|
|
3
1
|
import { User } from '@things-factory/auth-base'
|
|
4
2
|
import { Bizplace } from '@things-factory/biz-base'
|
|
5
|
-
import { ORDER_PRODUCT_STATUS, OrderInventory } from '@things-factory/sales-base'
|
|
6
3
|
import { Domain } from '@things-factory/shell'
|
|
4
|
+
import { OrderInventory, ORDER_PRODUCT_STATUS } from '@things-factory/sales-base'
|
|
7
5
|
import {
|
|
8
6
|
Inventory,
|
|
9
|
-
INVENTORY_STATUS,
|
|
10
|
-
INVENTORY_TRANSACTION_TYPE,
|
|
11
7
|
InventoryHistory,
|
|
12
|
-
InventoryNoGenerator
|
|
8
|
+
InventoryNoGenerator,
|
|
9
|
+
INVENTORY_STATUS,
|
|
10
|
+
INVENTORY_TRANSACTION_TYPE
|
|
13
11
|
} from '@things-factory/warehouse-base'
|
|
14
|
-
|
|
12
|
+
import { EntityManager } from 'typeorm'
|
|
15
13
|
import { WORKSHEET_STATUS, WORKSHEET_TYPE } from '../../../constants'
|
|
16
14
|
import { Worksheet, WorksheetDetail } from '../../../entities'
|
|
17
15
|
|
|
18
16
|
export const transfer = {
|
|
19
17
|
async transfer(_: any, { palletId, toPalletId, qty }, context: any) {
|
|
20
|
-
const {
|
|
21
|
-
|
|
18
|
+
const {
|
|
19
|
+
tx,
|
|
20
|
+
domain,
|
|
21
|
+
bizplace,
|
|
22
|
+
user
|
|
23
|
+
}: { tx: EntityManager; domain: Domain; bizplace: Bizplace; user: User } = context.state
|
|
22
24
|
|
|
23
25
|
// 1. get to inventory
|
|
24
26
|
let toInventory: Inventory = await tx.getRepository(Inventory).findOne({
|
|
25
27
|
where: { domain: domain, palletId: toPalletId },
|
|
26
|
-
relations: ['bizplace', 'product', '
|
|
28
|
+
relations: ['bizplace', 'product', 'warehouse', 'location']
|
|
27
29
|
})
|
|
28
30
|
if (!toInventory) throw new Error(`to pallet doesn't exists`)
|
|
29
31
|
|
|
30
32
|
// 2. get from inventory
|
|
31
33
|
let fromInventory: Inventory = await tx.getRepository(Inventory).findOne({
|
|
32
34
|
where: { domain: domain, palletId },
|
|
33
|
-
relations: ['bizplace', 'product', '
|
|
35
|
+
relations: ['bizplace', 'product', 'warehouse', 'location']
|
|
34
36
|
})
|
|
35
37
|
if (!fromInventory) throw new Error(`from pallet doesn't exists`)
|
|
36
38
|
if (toInventory.batchId !== fromInventory.batchId) throw new Error(`Can't transfer to different batch`)
|
|
@@ -72,7 +74,6 @@ export const transfer = {
|
|
|
72
74
|
domain: domain,
|
|
73
75
|
name: InventoryNoGenerator.inventoryHistoryName(),
|
|
74
76
|
product: toInventory.product,
|
|
75
|
-
productDetail: toInventory.productDetail,
|
|
76
77
|
warehouse: toInventory.warehouse,
|
|
77
78
|
location: toInventory.location,
|
|
78
79
|
seq: toInventory.lastSeq,
|
|
@@ -96,7 +97,7 @@ export const transfer = {
|
|
|
96
97
|
|
|
97
98
|
fromInventory = await tx.getRepository(Inventory).findOne({
|
|
98
99
|
where: { id: fromInventory.id },
|
|
99
|
-
relations: ['bizplace', 'product', '
|
|
100
|
+
relations: ['bizplace', 'product', 'warehouse', 'location']
|
|
100
101
|
})
|
|
101
102
|
|
|
102
103
|
// - add inventory history
|
|
@@ -104,7 +105,6 @@ export const transfer = {
|
|
|
104
105
|
...fromInventory,
|
|
105
106
|
name: InventoryNoGenerator.inventoryHistoryName(),
|
|
106
107
|
product: fromInventory.product,
|
|
107
|
-
productDetail: fromInventory.productDetail,
|
|
108
108
|
warehouse: fromInventory.warehouse,
|
|
109
109
|
location: fromInventory.location,
|
|
110
110
|
seq: fromInventory.lastSeq,
|
|
@@ -131,7 +131,7 @@ export const transfer = {
|
|
|
131
131
|
|
|
132
132
|
toInventory = await tx.getRepository(Inventory).findOne({
|
|
133
133
|
where: { id: toInventory.id },
|
|
134
|
-
relations: ['bizplace', 'product', '
|
|
134
|
+
relations: ['bizplace', 'product', 'warehouse', 'location']
|
|
135
135
|
})
|
|
136
136
|
// - add inventory history
|
|
137
137
|
delete toInventory.id
|
|
@@ -140,7 +140,6 @@ export const transfer = {
|
|
|
140
140
|
domain,
|
|
141
141
|
name: InventoryNoGenerator.inventoryHistoryName(),
|
|
142
142
|
product: toInventory.product,
|
|
143
|
-
productDetail: toInventory.productDetail,
|
|
144
143
|
warehouse: toInventory.warehouse,
|
|
145
144
|
location: toInventory.location,
|
|
146
145
|
seq: toInventory.lastSeq,
|
|
@@ -158,7 +157,7 @@ export const transfer = {
|
|
|
158
157
|
|
|
159
158
|
fromInventory = await tx.getRepository(Inventory).findOne({
|
|
160
159
|
where: { id: fromInventory.id },
|
|
161
|
-
relations: ['bizplace', 'product', '
|
|
160
|
+
relations: ['bizplace', 'product', 'warehouse', 'location']
|
|
162
161
|
})
|
|
163
162
|
|
|
164
163
|
// - add inventory history
|
|
@@ -166,7 +165,6 @@ export const transfer = {
|
|
|
166
165
|
...fromInventory,
|
|
167
166
|
name: InventoryNoGenerator.inventoryHistoryName(),
|
|
168
167
|
product: fromInventory.product,
|
|
169
|
-
productDetail: fromInventory.productDetail,
|
|
170
168
|
warehouse: fromInventory.warehouse,
|
|
171
169
|
location: fromInventory.location,
|
|
172
170
|
seq: fromInventory.lastSeq,
|
|
@@ -19,13 +19,12 @@ import {
|
|
|
19
19
|
InventoryNoGenerator,
|
|
20
20
|
Location,
|
|
21
21
|
Pallet,
|
|
22
|
-
Warehouse
|
|
23
|
-
generateInventoryHistory
|
|
22
|
+
Warehouse
|
|
24
23
|
} from '@things-factory/warehouse-base'
|
|
25
24
|
|
|
26
25
|
import { WORKSHEET_STATUS, WORKSHEET_TYPE } from '../../../../constants'
|
|
27
26
|
import { Worksheet, WorksheetDetail } from '../../../../entities'
|
|
28
|
-
import { WorksheetNoGenerator } from '../../../../utils'
|
|
27
|
+
import { generateInventoryHistory, WorksheetNoGenerator } from '../../../../utils'
|
|
29
28
|
import {
|
|
30
29
|
OperationGuideInterface,
|
|
31
30
|
PackingUnits,
|
|
@@ -121,27 +121,29 @@ export const worksheetResolver = {
|
|
|
121
121
|
worksheet.worksheetDetails.map(async (wsd: WorksheetDetail) => {
|
|
122
122
|
let inventory: Inventory = wsd.targetInventory.inventory
|
|
123
123
|
|
|
124
|
-
let
|
|
124
|
+
let foundHistory: InventoryHistory = await getRepository(InventoryHistory).findOne({
|
|
125
125
|
where: [
|
|
126
126
|
{ inventory, refOrderId: worksheet.arrivalNotice.id, status: INVENTORY_STATUS.UNLOADED },
|
|
127
127
|
{ inventory, refOrderId: worksheet.arrivalNotice.id, status: INVENTORY_STATUS.PARTIALLY_UNLOADED },
|
|
128
|
-
{ inventory, refOrderId: worksheet.arrivalNotice.id, status: INVENTORY_STATUS.CHECKED }
|
|
128
|
+
{ inventory, refOrderId: worksheet.arrivalNotice.id, status: INVENTORY_STATUS.CHECKED },
|
|
129
|
+
{ inventory, refOrderId: worksheet.arrivalNotice.id, status: INVENTORY_STATUS.STORED }
|
|
129
130
|
],
|
|
130
|
-
relations: ['location', 'product']
|
|
131
|
+
relations: ['location', 'product'],
|
|
132
|
+
order: { seq: 'DESC' }
|
|
131
133
|
})
|
|
132
134
|
|
|
133
135
|
wsd.targetInventory.inventory = {
|
|
134
136
|
...inventory,
|
|
135
|
-
qty:
|
|
136
|
-
uomValue:
|
|
137
|
-
location:
|
|
138
|
-
product:
|
|
139
|
-
cartonId:
|
|
140
|
-
batchId:
|
|
141
|
-
batchIdRef:
|
|
142
|
-
packingType:
|
|
143
|
-
packingSize:
|
|
144
|
-
uom:
|
|
137
|
+
qty: foundHistory?.qty || foundHistory?.openingQty || 0,
|
|
138
|
+
uomValue: foundHistory?.uomValue || foundHistory?.openingUomValue || 0,
|
|
139
|
+
location: foundHistory?.location,
|
|
140
|
+
product: foundHistory?.product,
|
|
141
|
+
cartonId: foundHistory?.cartonId,
|
|
142
|
+
batchId: foundHistory?.batchId,
|
|
143
|
+
batchIdRef: foundHistory?.batchIdRef,
|
|
144
|
+
packingType: foundHistory?.packingType,
|
|
145
|
+
packingSize: foundHistory?.packingSize,
|
|
146
|
+
uom: foundHistory?.uom
|
|
145
147
|
}
|
|
146
148
|
|
|
147
149
|
return wsd
|
package/server/graphql/resolvers/worksheet-detail/regenerate-release-good-worksheet-details.ts
CHANGED
|
@@ -19,7 +19,7 @@ import { WorksheetNoGenerator } from '../../../utils'
|
|
|
19
19
|
export const regenerateReleaseGoodWorksheetDetailsResolver = {
|
|
20
20
|
async regenerateReleaseGoodWorksheetDetails(
|
|
21
21
|
_: any,
|
|
22
|
-
{ worksheetNo, batchId, productId,
|
|
22
|
+
{ worksheetNo, batchId, productId, packingType, packingSize, orderProductId, worksheetDetails },
|
|
23
23
|
context: any
|
|
24
24
|
): Promise<void> {
|
|
25
25
|
const { tx, domain, user }: { tx: EntityManager; domain: Domain; user: User } = context.state
|
|
@@ -30,7 +30,6 @@ export const regenerateReleaseGoodWorksheetDetailsResolver = {
|
|
|
30
30
|
worksheetNo,
|
|
31
31
|
batchId,
|
|
32
32
|
productId,
|
|
33
|
-
productDetailId,
|
|
34
33
|
packingType,
|
|
35
34
|
packingSize,
|
|
36
35
|
orderProductId,
|
|
@@ -46,7 +45,6 @@ export async function regenerateReleaseGoodWorksheetDetails(
|
|
|
46
45
|
worksheetNo: string,
|
|
47
46
|
batchId: string,
|
|
48
47
|
productId: string,
|
|
49
|
-
productDetailId: string,
|
|
50
48
|
packingType: string,
|
|
51
49
|
packingSize: number,
|
|
52
50
|
orderProductId: string,
|
|
@@ -117,7 +115,6 @@ export async function regenerateReleaseGoodWorksheetDetails(
|
|
|
117
115
|
batchIdRef: inventory.batchIdRef,
|
|
118
116
|
status: ORDER_INVENTORY_STATUS.READY_TO_PICK,
|
|
119
117
|
product: await tx.getRepository(Product).findOne(productId),
|
|
120
|
-
productDetail: productDetailId,
|
|
121
118
|
packingType,
|
|
122
119
|
packingSize,
|
|
123
120
|
orderProduct: targetProduct,
|
|
@@ -4,9 +4,134 @@ import { User } from '@things-factory/auth-base'
|
|
|
4
4
|
import { Bizplace } from '@things-factory/biz-base'
|
|
5
5
|
import { Product } from '@things-factory/product-base'
|
|
6
6
|
import { Domain } from '@things-factory/shell'
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
Inventory,
|
|
9
|
+
INVENTORY_STATUS,
|
|
10
|
+
InventoryHistory,
|
|
11
|
+
InventoryNoGenerator,
|
|
12
|
+
Location,
|
|
13
|
+
LOCATION_STATUS,
|
|
14
|
+
LOCATION_TYPE
|
|
15
|
+
} from '@things-factory/warehouse-base'
|
|
8
16
|
|
|
9
17
|
/**
|
|
18
|
+
* @description It will insert new record into inventory histories table.
|
|
19
|
+
* seq will be calculated based on number of records for one specific pallet id (provided by inventory object)
|
|
20
|
+
*/
|
|
21
|
+
export async function generateInventoryHistory(
|
|
22
|
+
inventory: Inventory,
|
|
23
|
+
refOrder: any,
|
|
24
|
+
transactionType: string,
|
|
25
|
+
qty: number = 0,
|
|
26
|
+
uomValue: number = 0,
|
|
27
|
+
user: User,
|
|
28
|
+
trxMgr?: EntityManager,
|
|
29
|
+
targetInventory: Inventory = {}
|
|
30
|
+
): Promise<InventoryHistory> {
|
|
31
|
+
const invHistoryRepo: Repository<InventoryHistory> =
|
|
32
|
+
trxMgr?.getRepository(InventoryHistory) || getRepository(InventoryHistory)
|
|
33
|
+
const invRepo: Repository<Inventory> = trxMgr?.getRepository(Inventory) || getRepository(Inventory)
|
|
34
|
+
|
|
35
|
+
if (!inventory?.id) throw new Error(`Can't find out ID of inventory.`)
|
|
36
|
+
if (!refOrder?.id || !refOrder.name) throw new Error(`Can't find out ID or Name of Reference Order`)
|
|
37
|
+
if (
|
|
38
|
+
!inventory?.domain ||
|
|
39
|
+
!inventory?.bizplace ||
|
|
40
|
+
!inventory?.product?.id ||
|
|
41
|
+
!inventory?.warehouse?.id ||
|
|
42
|
+
!inventory?.location?.id
|
|
43
|
+
) {
|
|
44
|
+
inventory = await invRepo.findOne({
|
|
45
|
+
where: { id: inventory.id },
|
|
46
|
+
relations: ['domain', 'bizplace', 'product', 'warehouse', 'location']
|
|
47
|
+
})
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const domain: Domain = inventory.domain
|
|
51
|
+
const location: Location = inventory.location
|
|
52
|
+
|
|
53
|
+
const seq: number = await invHistoryRepo.count({ domain: inventory.domain, palletId: inventory.palletId })
|
|
54
|
+
let openingQty: number = 0
|
|
55
|
+
let openingUomValue: number = 0
|
|
56
|
+
|
|
57
|
+
if (seq) {
|
|
58
|
+
const lastInvHistory: InventoryHistory = await invHistoryRepo.findOne({
|
|
59
|
+
domain: inventory.domain,
|
|
60
|
+
palletId: inventory.palletId,
|
|
61
|
+
seq: seq - 1
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
openingQty = lastInvHistory.openingQty + lastInvHistory.qty
|
|
65
|
+
openingUomValue = lastInvHistory.openingUomValue + lastInvHistory.uomValue
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (transactionType == 'PICKING' || transactionType == 'UNLOADING') {
|
|
69
|
+
const [findSameOrderHistory, total]: InventoryHistory = await invHistoryRepo.findAndCount({
|
|
70
|
+
domain: inventory.domain,
|
|
71
|
+
palletId: inventory.palletId,
|
|
72
|
+
refOrderId: refOrder.id
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
if (findSameOrderHistory) {
|
|
76
|
+
let prevTotalQty = 0
|
|
77
|
+
let prevTotalUomValue = 0
|
|
78
|
+
for (let oh of findSameOrderHistory) {
|
|
79
|
+
prevTotalQty += oh.qty
|
|
80
|
+
prevTotalUomValue += oh.uomValue
|
|
81
|
+
}
|
|
82
|
+
qty -= prevTotalQty
|
|
83
|
+
uomValue -= prevTotalUomValue
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
let inventoryHistory: InventoryHistory = new InventoryHistory()
|
|
88
|
+
inventoryHistory.name = InventoryNoGenerator.inventoryHistoryName()
|
|
89
|
+
inventoryHistory.description = inventory.description
|
|
90
|
+
inventoryHistory.seq = seq
|
|
91
|
+
inventoryHistory.palletId = inventory.palletId
|
|
92
|
+
inventoryHistory.cartonId = inventory.cartonId
|
|
93
|
+
inventoryHistory.batchId = inventory.batchId
|
|
94
|
+
inventoryHistory.batchIdRef = inventory.batchIdRef
|
|
95
|
+
inventoryHistory.status = inventory.status
|
|
96
|
+
inventoryHistory.transactionType = transactionType
|
|
97
|
+
inventoryHistory.refOrderId = refOrder?.id || null
|
|
98
|
+
inventoryHistory.orderNo = refOrder?.name || null
|
|
99
|
+
inventoryHistory.orderRefNo = refOrder?.refNo || null
|
|
100
|
+
inventoryHistory.inventory = inventory
|
|
101
|
+
inventoryHistory.targetInventory = targetInventory
|
|
102
|
+
inventoryHistory.product = inventory.product
|
|
103
|
+
inventoryHistory.reusablePallet = inventory.reusablePallet
|
|
104
|
+
inventoryHistory.zone = inventory.zone
|
|
105
|
+
inventoryHistory.warehouse = inventory.warehouse
|
|
106
|
+
inventoryHistory.location = inventory.location
|
|
107
|
+
inventoryHistory.expirationDate = inventory.expirationDate
|
|
108
|
+
inventoryHistory.packingType = inventory.packingType
|
|
109
|
+
inventoryHistory.packingSize = inventory.packingSize
|
|
110
|
+
inventoryHistory.uom = inventory.uom
|
|
111
|
+
inventoryHistory.qty = qty
|
|
112
|
+
inventoryHistory.openingQty = openingQty
|
|
113
|
+
inventoryHistory.uomValue = uomValue
|
|
114
|
+
inventoryHistory.openingUomValue = openingUomValue
|
|
115
|
+
inventoryHistory.unitCost = inventory.unitCost
|
|
116
|
+
inventoryHistory.domain = inventory.domain
|
|
117
|
+
inventoryHistory.bizplace = inventory.bizplace
|
|
118
|
+
inventoryHistory.creator = user
|
|
119
|
+
inventoryHistory.updater = user
|
|
120
|
+
|
|
121
|
+
inventoryHistory = await invHistoryRepo.save(inventoryHistory)
|
|
122
|
+
|
|
123
|
+
if (inventory.lastSeq !== seq) {
|
|
124
|
+
await invRepo.save({
|
|
125
|
+
id: inventory.id,
|
|
126
|
+
lastSeq: inventoryHistory.seq,
|
|
127
|
+
updater: user
|
|
128
|
+
})
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
await switchLocationStatus(domain, location, user, trxMgr)
|
|
132
|
+
return inventoryHistory
|
|
133
|
+
}
|
|
134
|
+
|
|
10
135
|
/**
|
|
11
136
|
* @description: Check location emptiness and update status of location
|
|
12
137
|
* @param domain
|