@things-factory/worksheet-base 4.3.247 → 4.3.249
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/inbound/putaway-worksheet-controller.js +2 -1
- package/dist-server/controllers/inbound/putaway-worksheet-controller.js.map +1 -1
- package/dist-server/controllers/outbound/picking-worksheet-controller.js +239 -27
- package/dist-server/controllers/outbound/picking-worksheet-controller.js.map +1 -1
- package/dist-server/entities/warehouse-bizplace-onhand-inventory.js +6 -4
- package/dist-server/entities/warehouse-bizplace-onhand-inventory.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/inventories-by-pallet.js +2 -1
- package/dist-server/graphql/resolvers/worksheet/inventories-by-pallet.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/worksheet.js +15 -8
- package/dist-server/graphql/resolvers/worksheet/worksheet.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet-detail/regenerate-release-good-worksheet-details.js +1 -0
- package/dist-server/graphql/resolvers/worksheet-detail/regenerate-release-good-worksheet-details.js.map +1 -1
- package/dist-server/utils/inventory-util.js +6 -6
- package/dist-server/utils/inventory-util.js.map +1 -1
- package/package.json +18 -18
- package/server/controllers/inbound/putaway-worksheet-controller.ts +2 -1
- package/server/controllers/outbound/picking-worksheet-controller.ts +326 -36
- package/server/entities/warehouse-bizplace-onhand-inventory.ts +6 -4
- package/server/graphql/resolvers/worksheet/inventories-by-pallet.ts +46 -62
- package/server/graphql/resolvers/worksheet/worksheet.ts +11 -4
- package/server/graphql/resolvers/worksheet-detail/regenerate-release-good-worksheet-details.ts +1 -0
- package/server/utils/inventory-util.ts +6 -6
|
@@ -1,28 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Brackets,
|
|
3
|
-
getRepository,
|
|
4
|
-
SelectQueryBuilder
|
|
5
|
-
} from 'typeorm'
|
|
1
|
+
import { Brackets, getRepository, SelectQueryBuilder } from 'typeorm'
|
|
6
2
|
|
|
7
3
|
import { User } from '@things-factory/auth-base'
|
|
8
4
|
import { getPermittedBizplaceIds } from '@things-factory/biz-base'
|
|
9
5
|
import { ORDER_INVENTORY_STATUS } from '@things-factory/sales-base'
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
buildQuery,
|
|
13
|
-
Domain
|
|
14
|
-
} from '@things-factory/shell'
|
|
15
|
-
import {
|
|
16
|
-
Inventory,
|
|
17
|
-
LOCATION_TYPE
|
|
18
|
-
} from '@things-factory/warehouse-base'
|
|
6
|
+
import { buildCondition, buildQuery, Domain } from '@things-factory/shell'
|
|
7
|
+
import { Inventory, LOCATION_TYPE } from '@things-factory/warehouse-base'
|
|
19
8
|
|
|
20
9
|
export const inventoriesByPalletResolver = {
|
|
21
10
|
async inventoriesByPallet(_: any, { filters, pagination, sortings, locationSortingRules }, context: any) {
|
|
22
11
|
const { domain, user }: { domain: Domain; user: User } = context.state
|
|
23
12
|
const params = { filters, pagination }
|
|
24
13
|
let permittedBizplaceIds: string[] = await getPermittedBizplaceIds(domain, user)
|
|
25
|
-
const bizplaceId =
|
|
14
|
+
const bizplaceId = params.filters.find(x => x.name == 'bizplace_id')
|
|
26
15
|
const productFilters = params.filters.filter(x => x.name == 'productName')
|
|
27
16
|
const recallFilters = params.filters.find(x => x.name === 'recall')
|
|
28
17
|
const skipLockCheckFilters = params.filters.find(x => x.name === 'skipLockCheck')
|
|
@@ -46,6 +35,7 @@ export const inventoriesByPalletResolver = {
|
|
|
46
35
|
.leftJoinAndSelect('iv.bizplace', 'bizplace')
|
|
47
36
|
.leftJoinAndSelect('iv.product', 'product')
|
|
48
37
|
.leftJoinAndSelect('iv.productDetail', 'productDetail')
|
|
38
|
+
.leftJoin('product_detail_stocks', 'pds', 'pds.product_detail_id = iv.product_detail_id')
|
|
49
39
|
.leftJoinAndSelect('iv.warehouse', 'warehouse')
|
|
50
40
|
.leftJoinAndSelect('iv.location', 'location')
|
|
51
41
|
.leftJoinAndSelect('iv.creator', 'creator')
|
|
@@ -56,7 +46,7 @@ export const inventoriesByPalletResolver = {
|
|
|
56
46
|
.andWhere(
|
|
57
47
|
`location.type ${recallFilters?.value === true ? '' : 'NOT'} IN ('${LOCATION_TYPE.QUARANTINE}', '${
|
|
58
48
|
LOCATION_TYPE.RESERVE
|
|
59
|
-
}')`
|
|
49
|
+
}', '${LOCATION_TYPE.DAMAGE}')`
|
|
60
50
|
)
|
|
61
51
|
.andWhere(
|
|
62
52
|
`(iv.batch_id, product.name, iv.packing_type, product.brand) NOT IN (
|
|
@@ -73,14 +63,43 @@ export const inventoriesByPalletResolver = {
|
|
|
73
63
|
AND oi.domain_id = (:domainId)
|
|
74
64
|
AND oi.bizplace_id = (:bizplaceId)
|
|
75
65
|
)`,
|
|
76
|
-
{ bizplaceId: bizplaceId.value
|
|
66
|
+
{ bizplaceId: bizplaceId.value, domainId: domain.id }
|
|
77
67
|
)
|
|
78
68
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
69
|
+
if (locationFilters) {
|
|
70
|
+
qb.andWhere(`location.name ilike '${locationFilters.value}'`)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (productFilters && productFilters.length > 0) {
|
|
74
|
+
let productInfo = productFilters[0]
|
|
75
|
+
qb.andWhere(
|
|
76
|
+
new Brackets(qb2 => {
|
|
77
|
+
productFilterColumns.forEach(filter => {
|
|
78
|
+
const condition = buildCondition(
|
|
79
|
+
'product',
|
|
80
|
+
filter,
|
|
81
|
+
'i_like',
|
|
82
|
+
productInfo.value,
|
|
83
|
+
false,
|
|
84
|
+
Object.keys(qb.getParameters()).length
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
qb2.orWhere(condition.clause, condition.parameters)
|
|
88
|
+
})
|
|
89
|
+
})
|
|
90
|
+
)
|
|
91
|
+
}
|
|
83
92
|
|
|
93
|
+
if (!skipLockCheck) {
|
|
94
|
+
qb.andWhere('CASE WHEN iv.lockedQty IS NULL THEN 0 ELSE iv.lockedQty END >= 0')
|
|
95
|
+
qb.andWhere('iv.qty - CASE WHEN iv.lockedQty IS NULL THEN 0 ELSE iv.lockedQty END > 0')
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (recallFilters?.value === true) {
|
|
99
|
+
qb.orWhere('(iv.domain_id = (:domainId) and iv.bizplace_id = (:bizplaceId)')
|
|
100
|
+
if (locationFilters) {
|
|
101
|
+
qb.andWhere(`location.name ilike '${locationFilters.value}'`)
|
|
102
|
+
}
|
|
84
103
|
if (productFilters && productFilters.length > 0) {
|
|
85
104
|
let productInfo = productFilters[0]
|
|
86
105
|
qb.andWhere(
|
|
@@ -94,53 +113,18 @@ export const inventoriesByPalletResolver = {
|
|
|
94
113
|
false,
|
|
95
114
|
Object.keys(qb.getParameters()).length
|
|
96
115
|
)
|
|
97
|
-
|
|
116
|
+
|
|
98
117
|
qb2.orWhere(condition.clause, condition.parameters)
|
|
99
118
|
})
|
|
100
119
|
})
|
|
101
120
|
)
|
|
102
121
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
qb.andWhere('iv.qty - CASE WHEN iv.lockedQty IS NULL THEN 0 ELSE iv.lockedQty END > 0')
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
if (recallFilters?.value === true) {
|
|
110
|
-
qb.orWhere(
|
|
111
|
-
'(iv.domain_id = (:domainId) and iv.bizplace_id = (:bizplaceId)'
|
|
112
|
-
)
|
|
113
|
-
if (locationFilters){
|
|
114
|
-
qb.andWhere
|
|
115
|
-
(`location.name ilike '${locationFilters.value}'`)
|
|
116
|
-
}
|
|
117
|
-
if (productFilters && productFilters.length > 0) {
|
|
118
|
-
let productInfo = productFilters[0]
|
|
119
|
-
qb.andWhere(
|
|
120
|
-
new Brackets(qb2 => {
|
|
121
|
-
productFilterColumns.forEach(filter => {
|
|
122
|
-
const condition = buildCondition(
|
|
123
|
-
'product',
|
|
124
|
-
filter,
|
|
125
|
-
'i_like',
|
|
126
|
-
productInfo.value,
|
|
127
|
-
false,
|
|
128
|
-
Object.keys(qb.getParameters()).length
|
|
129
|
-
)
|
|
130
|
-
|
|
131
|
-
qb2.orWhere(condition.clause, condition.parameters)
|
|
132
|
-
})
|
|
133
|
-
})
|
|
134
|
-
)
|
|
135
|
-
}
|
|
136
|
-
if (batchIdFilters) {
|
|
137
|
-
qb.andWhere(
|
|
138
|
-
`iv.batch_id ilike '${batchIdFilters.value}'`
|
|
139
|
-
)
|
|
140
|
-
}
|
|
122
|
+
if (batchIdFilters) {
|
|
123
|
+
qb.andWhere(`iv.batch_id ilike '${batchIdFilters.value}'`)
|
|
124
|
+
}
|
|
141
125
|
qb.andWhere(
|
|
142
126
|
'iv.obsolete = true and case when iv.expiration_date is not null and product.shelf_life is not null then CURRENT_DATE > iv.expiration_date - product.shelf_life else true end)'
|
|
143
|
-
|
|
127
|
+
)
|
|
144
128
|
} else {
|
|
145
129
|
qb.andWhere('iv.obsolete = false')
|
|
146
130
|
qb.andWhere(
|
|
@@ -201,4 +185,4 @@ async function getRemainAmount(inventory: Inventory): Promise<{ remainQty: numbe
|
|
|
201
185
|
remainQty: inventory.qty - (inventory.lockedQty || 0),
|
|
202
186
|
remainUomValue: inventory.uomValue - (inventory.lockedUomValue || 0)
|
|
203
187
|
}
|
|
204
|
-
}
|
|
188
|
+
}
|
|
@@ -38,6 +38,8 @@ export const worksheetResolver = {
|
|
|
38
38
|
'releaseGood.arrivalNotice',
|
|
39
39
|
'releaseGood.shippingOrder',
|
|
40
40
|
'releaseGood.orderPackages',
|
|
41
|
+
'releaseGood.orderProducts',
|
|
42
|
+
'releaseGood.orderProducts.product',
|
|
41
43
|
'replenishment',
|
|
42
44
|
'returnOrder',
|
|
43
45
|
'inventoryCheck',
|
|
@@ -47,6 +49,7 @@ export const worksheetResolver = {
|
|
|
47
49
|
'worksheetDetails.toLocation',
|
|
48
50
|
'worksheetDetails.targetProduct',
|
|
49
51
|
'worksheetDetails.targetProduct.product',
|
|
52
|
+
'worksheetDetails.targetProduct.releaseGood',
|
|
50
53
|
'worksheetDetails.targetVas',
|
|
51
54
|
'worksheetDetails.targetVas.product',
|
|
52
55
|
'worksheetDetails.targetVas.newProduct',
|
|
@@ -187,7 +190,7 @@ export const worksheetResolver = {
|
|
|
187
190
|
worksheet.orderInventories = orderInventories
|
|
188
191
|
}
|
|
189
192
|
|
|
190
|
-
if (worksheet?.releaseGood?.id) {
|
|
193
|
+
if (worksheet?.releaseGood?.id && worksheet?.releaseGood?.assignedInventory) {
|
|
191
194
|
let qbOrderInventories = getRepository(OrderInventory)
|
|
192
195
|
.createQueryBuilder('oi')
|
|
193
196
|
.leftJoinAndSelect('oi.releaseGood', 'releaseGood')
|
|
@@ -258,11 +261,15 @@ export const worksheetResolver = {
|
|
|
258
261
|
}
|
|
259
262
|
|
|
260
263
|
// before VAS
|
|
261
|
-
if (worksheet
|
|
264
|
+
if (worksheet?.orderInventories?.length > 0) {
|
|
262
265
|
worksheet.worksheetDetails.sort(function (a, b) {
|
|
263
266
|
return (
|
|
264
|
-
worksheet.orderInventories
|
|
265
|
-
|
|
267
|
+
worksheet.orderInventories
|
|
268
|
+
.map(oi => oi.id)
|
|
269
|
+
.indexOf(worksheet.type == 'VAS' ? a.targetVas.id : a.targetInventory.id) -
|
|
270
|
+
worksheet.orderInventories
|
|
271
|
+
.map(oi => oi.id)
|
|
272
|
+
.indexOf(worksheet.type == 'VAS' ? b.targetVas.id : b.targetInventory.id)
|
|
266
273
|
)
|
|
267
274
|
})
|
|
268
275
|
}
|
|
@@ -254,12 +254,12 @@ export async function isInventoryExpiring(inventory: Inventory): Promise<boolean
|
|
|
254
254
|
}
|
|
255
255
|
|
|
256
256
|
const { expirationDate } = inventory
|
|
257
|
-
const { isRequiredCheckExpiry,
|
|
257
|
+
const { isRequiredCheckExpiry, minInboundShelfLife } = product
|
|
258
258
|
|
|
259
|
-
if (!isRequiredCheckExpiry || !
|
|
259
|
+
if (!isRequiredCheckExpiry || !minInboundShelfLife || expirationDate <= 0) return false
|
|
260
260
|
|
|
261
261
|
let date: Date = new Date()
|
|
262
|
-
const acceptBefore: Date = new Date(date.setDate(date.getDate() +
|
|
262
|
+
const acceptBefore: Date = new Date(date.setDate(date.getDate() + minInboundShelfLife))
|
|
263
263
|
const expiryDate: Date = new Date(expirationDate)
|
|
264
264
|
|
|
265
265
|
return expiryDate < acceptBefore
|
|
@@ -280,13 +280,13 @@ export async function isInventoryObsolete(inventories: Inventory[]): Promise<any
|
|
|
280
280
|
}
|
|
281
281
|
|
|
282
282
|
let { expirationDate } = inventories[i]
|
|
283
|
-
const {
|
|
283
|
+
const { minOutboundShelfLife } = product
|
|
284
284
|
|
|
285
|
-
if (
|
|
285
|
+
if (minOutboundShelfLife && expirationDate) {
|
|
286
286
|
let date: Date = new Date()
|
|
287
287
|
expirationDate = new Date(expirationDate)
|
|
288
288
|
|
|
289
|
-
const releaseBefore: Date = new Date(expirationDate.setDate(expirationDate.getDate() -
|
|
289
|
+
const releaseBefore: Date = new Date(expirationDate.setDate(expirationDate.getDate() - minOutboundShelfLife))
|
|
290
290
|
|
|
291
291
|
if (date > releaseBefore) {
|
|
292
292
|
obsoleteInventories.push(inventories[i].id)
|