@things-factory/sales-base 4.3.135 → 4.3.138
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/service/arrival-notice/arrival-notice-mutation.js +6 -5
- package/dist-server/service/arrival-notice/arrival-notice-mutation.js.map +1 -1
- package/dist-server/service/arrival-notice/arrival-notice-query.js +1 -0
- package/dist-server/service/arrival-notice/arrival-notice-query.js.map +1 -1
- package/dist-server/service/draft-release-good/draft-release-good-mutation.js +2 -4
- package/dist-server/service/draft-release-good/draft-release-good-mutation.js.map +1 -1
- package/dist-server/service/draft-release-good/draft-release-good-query.js +11 -15
- package/dist-server/service/draft-release-good/draft-release-good-query.js.map +1 -1
- package/dist-server/service/invoice-product/invoice-product.js +8 -3
- package/dist-server/service/invoice-product/invoice-product.js.map +1 -1
- package/dist-server/service/order-inventory/order-inventory-query.js +2 -1
- package/dist-server/service/order-inventory/order-inventory-query.js.map +1 -1
- package/dist-server/service/order-inventory/order-inventory-types.js +18 -10
- package/dist-server/service/order-inventory/order-inventory-types.js.map +1 -1
- package/dist-server/service/order-inventory/order-inventory.js +12 -3
- package/dist-server/service/order-inventory/order-inventory.js.map +1 -1
- package/dist-server/service/order-product/order-product-query.js +1 -0
- package/dist-server/service/order-product/order-product-query.js.map +1 -1
- package/dist-server/service/order-product/order-product-types.js +18 -10
- package/dist-server/service/order-product/order-product-types.js.map +1 -1
- package/dist-server/service/order-vas/order-vas.js +8 -3
- package/dist-server/service/order-vas/order-vas.js.map +1 -1
- package/dist-server/service/others/other-query.js +193 -177
- package/dist-server/service/others/other-query.js.map +1 -1
- package/dist-server/service/others/other-types.js +9 -1
- package/dist-server/service/others/other-types.js.map +1 -1
- package/dist-server/service/purchase-order/purchase-order-mutation.js +10 -2
- package/dist-server/service/purchase-order/purchase-order-mutation.js.map +1 -1
- package/dist-server/service/purchase-order/purchase-order-query.js +1 -0
- package/dist-server/service/purchase-order/purchase-order-query.js.map +1 -1
- package/dist-server/service/release-good/release-good-mutation.js +25 -11
- package/dist-server/service/release-good/release-good-mutation.js.map +1 -1
- package/dist-server/service/release-good/release-good-query.js +2 -0
- package/dist-server/service/release-good/release-good-query.js.map +1 -1
- package/dist-server/service/release-good/release-good-types.js +8 -4
- package/dist-server/service/release-good/release-good-types.js.map +1 -1
- package/dist-server/service/release-good/release-good.js +1 -0
- package/dist-server/service/release-good/release-good.js.map +1 -1
- package/dist-server/service/return-order/return-order-mutation.js +3 -0
- package/dist-server/service/return-order/return-order-mutation.js.map +1 -1
- package/dist-server/service/return-order/return-order-types.js.map +1 -1
- package/dist-server/service/reverse-kitting-order-inventory/reverse-kitting-order-inventory.js +8 -3
- package/dist-server/service/reverse-kitting-order-inventory/reverse-kitting-order-inventory.js.map +1 -1
- package/dist-server/utils/inventory-util.js +39 -104
- package/dist-server/utils/inventory-util.js.map +1 -1
- package/package.json +13 -13
- package/server/service/arrival-notice/arrival-notice-mutation.ts +6 -3
- package/server/service/arrival-notice/arrival-notice-query.ts +1 -0
- package/server/service/draft-release-good/draft-release-good-mutation.ts +4 -7
- package/server/service/draft-release-good/draft-release-good-query.ts +17 -21
- package/server/service/invoice-product/invoice-product.ts +5 -1
- package/server/service/order-inventory/order-inventory-query.ts +2 -0
- package/server/service/order-inventory/order-inventory-types.ts +6 -0
- package/server/service/order-inventory/order-inventory.ts +8 -1
- package/server/service/order-product/order-product-query.ts +1 -0
- package/server/service/order-product/order-product-types.ts +6 -0
- package/server/service/order-vas/order-vas.ts +6 -1
- package/server/service/others/other-query.ts +237 -220
- package/server/service/others/other-types.ts +7 -1
- package/server/service/purchase-order/purchase-order-mutation.ts +10 -1
- package/server/service/purchase-order/purchase-order-query.ts +1 -0
- package/server/service/release-good/release-good-mutation.ts +34 -19
- package/server/service/release-good/release-good-query.ts +2 -0
- package/server/service/release-good/release-good-types.ts +4 -3
- package/server/service/release-good/release-good.ts +1 -0
- package/server/service/return-order/return-order-mutation.ts +4 -1
- package/server/service/return-order/return-order-types.ts +1 -0
- package/server/service/reverse-kitting-order-inventory/reverse-kitting-order-inventory.ts +5 -1
- package/server/utils/inventory-util.ts +75 -149
- package/translations/en.json +1 -0
- package/translations/ko.json +2 -1
- package/translations/ms.json +2 -1
- package/translations/zh.json +25 -0
|
@@ -2,7 +2,7 @@ import { EntityManager, Equal, getRepository, In, Not, Raw, Repository, SelectQu
|
|
|
2
2
|
|
|
3
3
|
import { User } from '@things-factory/auth-base'
|
|
4
4
|
import { Bizplace } from '@things-factory/biz-base'
|
|
5
|
-
import { Product, ProductBundle } from '@things-factory/product-base'
|
|
5
|
+
import { Product, ProductBundle, ProductDetail } from '@things-factory/product-base'
|
|
6
6
|
import { Domain, ListParam } from '@things-factory/shell'
|
|
7
7
|
import {
|
|
8
8
|
Inventory,
|
|
@@ -12,7 +12,8 @@ import {
|
|
|
12
12
|
Location,
|
|
13
13
|
LOCATION_STATUS,
|
|
14
14
|
LOCATION_TYPE,
|
|
15
|
-
Pallet
|
|
15
|
+
Pallet,
|
|
16
|
+
generateInventoryHistory
|
|
16
17
|
} from '@things-factory/warehouse-base'
|
|
17
18
|
|
|
18
19
|
import { ORDER_TYPES } from '../constants'
|
|
@@ -102,6 +103,7 @@ export const InventoryUtil = {
|
|
|
102
103
|
coalesce(p.sku, '') AS "productSKU",
|
|
103
104
|
coalesce(p.brand, '') AS "productBrand",
|
|
104
105
|
p.id AS "productId",
|
|
106
|
+
pd.id AS "productDetailId",
|
|
105
107
|
COALESCE(SUM(COALESCE(i.qty, 0)) - SUM(COALESCE(i.locked_qty, 0)) - MAX(COALESCE(oi.release_qty, 0)) - MAX(COALESCE(bp.bundle_product_release_qty, 0)),0) AS "remainQty",
|
|
106
108
|
COALESCE(SUM(COALESCE(i.uom_value, 0)) - SUM(COALESCE(i.locked_uom_value, 0)) - MAX(COALESCE(oi.release_uom_value, 0)) - MAX(COALESCE(bp.bundle_product_release_uom_value, 0)),0) AS "remainUomValue",
|
|
107
109
|
concat(SUM(COALESCE(i.uom_value, 0)) - SUM(COALESCE(i.locked_uom_value, 0)) - MAX(COALESCE(oi.release_uom_value, 0)) - MAX(COALESCE(bp.bundle_product_release_uom_value, 0)), ' ', pd.uom) AS "remainUomValueWithUom",
|
|
@@ -114,10 +116,7 @@ export const InventoryUtil = {
|
|
|
114
116
|
WHERE l2.type NOT IN ('${LOCATION_TYPE.QUARANTINE}', '${LOCATION_TYPE.RESERVE}')
|
|
115
117
|
AND i.domain_id = $1 AND i.status = 'STORED'
|
|
116
118
|
${inventoryBizplaceFilter ? `AND i.bizplace_id = '${inventoryBizplaceFilter.value}'` : ``}
|
|
117
|
-
) i ON i.
|
|
118
|
-
AND i.packing_type = pd.packing_type
|
|
119
|
-
and i.packing_size = pd.packing_size
|
|
120
|
-
and i.uom = pd.uom
|
|
119
|
+
) i ON i.product_detail_id = pd.id
|
|
121
120
|
LEFT JOIN oi ON i.batch_id = oi.batch_id AND p.name = oi.product_name AND i.packing_type = oi.packing_type AND i.packing_size = oi.packing_size AND i.uom = oi.uom
|
|
122
121
|
LEFT JOIN (
|
|
123
122
|
SELECT pbs.product_id, SUM(pbs.bundle_qty * src.release_qty) AS bundle_product_release_qty, SUM(pbs.bundle_qty * src.release_uom_value) AS bundle_product_release_uom_value
|
|
@@ -125,24 +124,26 @@ export const InventoryUtil = {
|
|
|
125
124
|
INNER JOIN json_populate_recordset(NULL::order_inventories, '${batchBundle}') src ON src.product_id = pbs.product_bundle_id
|
|
126
125
|
GROUP BY pbs.product_id
|
|
127
126
|
) bp on i.product_id = bp.product_id
|
|
128
|
-
WHERE
|
|
127
|
+
WHERE i.bizplace_id IN (${bizplaceIds})
|
|
129
128
|
${productDetailWhereClause}
|
|
130
|
-
${
|
|
131
|
-
|
|
129
|
+
${
|
|
130
|
+
productFilter
|
|
131
|
+
? `AND (
|
|
132
132
|
lower(p.sku) ilike '${productFilter.value}'
|
|
133
133
|
OR lower(p.name) ilike '${productFilter.value}'
|
|
134
134
|
OR lower(p.description) ilike '${productFilter.value}'
|
|
135
135
|
)
|
|
136
136
|
`
|
|
137
|
-
|
|
138
|
-
|
|
137
|
+
: ``
|
|
138
|
+
}
|
|
139
139
|
GROUP BY
|
|
140
140
|
p.id,
|
|
141
|
+
pd.id,
|
|
141
142
|
pd.packing_type,
|
|
142
143
|
pd.packing_size,
|
|
143
144
|
pd.uom
|
|
144
145
|
UNION
|
|
145
|
-
SELECT packing_type, packing_size,'UNIT' AS "uom", name AS "productName", sku AS "productSKU", '-' AS "productBrand", id AS "productId",
|
|
146
|
+
SELECT packing_type, packing_size,'UNIT' AS "uom", name AS "productName", sku AS "productSKU", '-' AS "productBrand", id AS "productId", pbs.product_detail_id AS "productDetailId",
|
|
146
147
|
COALESCE(MIN(FLOOR(pbs."availableQty")),0) AS "remainQty",
|
|
147
148
|
COALESCE(MIN(FLOOR(pbs."availableUomValue")),0) AS "remainUomValue",
|
|
148
149
|
CONCAT(COALESCE(MIN(FLOOR(pbs."availableUomValue")),0),' UNIT') AS "remainUomValueWithUom",
|
|
@@ -151,7 +152,8 @@ export const InventoryUtil = {
|
|
|
151
152
|
LEFT JOIN (
|
|
152
153
|
SELECT pbs.product_id, pbs.product_bundle_id, min(pbs.bundle_qty),
|
|
153
154
|
(SUM(COALESCE(i2.qty, 0)) - SUM(COALESCE(i2.locked_qty, 0)) - MAX(COALESCE(oi.release_qty, 0))) / min(pbs.bundle_qty) AS "availableQty",
|
|
154
|
-
(SUM(COALESCE(i2.uom_value, 0)) - SUM(COALESCE(i2.locked_uom_value, 0)) - MAX(COALESCE(oi.release_uom_value, 0))) / min(pbs.bundle_qty) AS "availableUomValue"
|
|
155
|
+
(SUM(COALESCE(i2.uom_value, 0)) - SUM(COALESCE(i2.locked_uom_value, 0)) - MAX(COALESCE(oi.release_uom_value, 0))) / min(pbs.bundle_qty) AS "availableUomValue",
|
|
156
|
+
pbs.product_detail_id
|
|
155
157
|
FROM product_bundle_settings pbs
|
|
156
158
|
LEFT JOIN inventories i2 ON i2.product_id = pbs.product_id AND i2.domain_id = $1 AND i2.status = 'STORED'
|
|
157
159
|
INNER JOIN locations l2 ON i2.location_id = l2.id
|
|
@@ -160,25 +162,28 @@ export const InventoryUtil = {
|
|
|
160
162
|
${inventoryBizplaceFilter ? `AND i2.bizplace_id = '${inventoryBizplaceFilter.value}'` : ``}
|
|
161
163
|
GROUP BY
|
|
162
164
|
pbs.product_id,
|
|
163
|
-
pbs.product_bundle_id
|
|
165
|
+
pbs.product_bundle_id,
|
|
166
|
+
pbs.product_detail_id
|
|
164
167
|
) pbs ON pbs.product_bundle_id = pb.id
|
|
165
168
|
${bundleWhereClause}
|
|
166
169
|
AND pb.bizplace_id IN (${bizplaceIds})
|
|
167
|
-
${
|
|
168
|
-
|
|
170
|
+
${
|
|
171
|
+
productFilter
|
|
172
|
+
? `AND (
|
|
169
173
|
lower(pb.sku) ilike '${productFilter.value}'
|
|
170
174
|
OR lower(pb.name) ilike '${productFilter.value}'
|
|
171
175
|
OR lower(pb.description) ilike '${productFilter.value}'
|
|
172
176
|
)
|
|
173
177
|
`
|
|
174
|
-
|
|
175
|
-
|
|
178
|
+
: ``
|
|
179
|
+
}
|
|
176
180
|
GROUP BY
|
|
177
181
|
pb.packing_type,
|
|
178
182
|
pb.packing_size,
|
|
179
183
|
pb.name,
|
|
180
184
|
pb.sku,
|
|
181
|
-
pb.id
|
|
185
|
+
pb.id,
|
|
186
|
+
pbs.product_detail_id
|
|
182
187
|
)
|
|
183
188
|
AS inv_prod_grp
|
|
184
189
|
${whereClause}
|
|
@@ -273,6 +278,7 @@ export const InventoryUtil = {
|
|
|
273
278
|
coalesce(p.sku, '') AS "productSKU",
|
|
274
279
|
coalesce(p.brand, '') AS "productBrand",
|
|
275
280
|
p.id AS "productId",
|
|
281
|
+
i.product_detail_id AS "productDetailId",
|
|
276
282
|
SUM(COALESCE(i.qty, 0)) - SUM(COALESCE(i.locked_qty, 0)) - MAX(COALESCE(oi.release_qty, 0)) - MAX(COALESCE(bp.bundle_product_release_qty, 0)) AS "remainQty",
|
|
277
283
|
SUM(COALESCE(i.uom_value, 0)) - SUM(COALESCE(i.locked_uom_value, 0)) - MAX(COALESCE(oi.release_uom_value, 0)) - MAX(COALESCE(bp.bundle_product_release_uom_value, 0)) AS "remainUomValue",
|
|
278
284
|
concat(SUM(COALESCE(i.uom_value, 0)) - SUM(COALESCE(i.locked_uom_value, 0)) - MAX(COALESCE(oi.release_uom_value, 0)) - MAX(COALESCE(bp.bundle_product_release_uom_value, 0)), ' ', i.uom) AS "remainUomValueWithUom",
|
|
@@ -292,6 +298,7 @@ export const InventoryUtil = {
|
|
|
292
298
|
AND l2.type NOT IN ('${LOCATION_TYPE.QUARANTINE}', '${LOCATION_TYPE.RESERVE}')
|
|
293
299
|
${productWhereClause}
|
|
294
300
|
GROUP BY
|
|
301
|
+
i.product_detail_id,
|
|
295
302
|
i.batch_id,
|
|
296
303
|
i.batch_id_ref,
|
|
297
304
|
p.id,
|
|
@@ -299,7 +306,7 @@ export const InventoryUtil = {
|
|
|
299
306
|
i.packing_size,
|
|
300
307
|
i.uom
|
|
301
308
|
UNION
|
|
302
|
-
SELECT 'BUNDLE' AS "batchId", null as "batchIdRef", packing_type, packing_size,'UNIT' AS "uom", name AS "productName", sku AS "productSKU", 'brand' AS "productBrand", id AS "productId",
|
|
309
|
+
SELECT 'BUNDLE' AS "batchId", null as "batchIdRef", packing_type, packing_size,'UNIT' AS "uom", name AS "productName", sku AS "productSKU", 'brand' AS "productBrand", id AS "productId", pbs.product_detail_id AS "productDetailId",
|
|
303
310
|
MIN(FLOOR(pbs."availableQty")) AS "remainQty",
|
|
304
311
|
MIN(FLOOR(pbs."availableUomValue")) AS "remainUomValue",
|
|
305
312
|
CONCAT(MIN(FLOOR(pbs."availableUomValue")),' UNIT') AS "remainUomValueWithUom",
|
|
@@ -308,16 +315,17 @@ export const InventoryUtil = {
|
|
|
308
315
|
INNER JOIN (
|
|
309
316
|
SELECT pbs.product_id, pbs.product_bundle_id, min(pbs.bundle_qty),
|
|
310
317
|
(SUM(COALESCE(i2.qty, 0)) - SUM(COALESCE(i2.locked_qty, 0)) - MAX(COALESCE(oi.release_qty, 0))) / min(pbs.bundle_qty) AS "availableQty",
|
|
311
|
-
(SUM(COALESCE(i2.uom_value, 0)) - SUM(COALESCE(i2.locked_uom_value, 0)) - MAX(COALESCE(oi.release_uom_value, 0))) / min(pbs.bundle_qty) AS "availableUomValue"
|
|
318
|
+
(SUM(COALESCE(i2.uom_value, 0)) - SUM(COALESCE(i2.locked_uom_value, 0)) - MAX(COALESCE(oi.release_uom_value, 0))) / min(pbs.bundle_qty) AS "availableUomValue",
|
|
319
|
+
pbs.product_detail_id
|
|
312
320
|
FROM product_bundle_settings pbs
|
|
313
321
|
LEFT JOIN inventories i2 ON i2.product_id = pbs.product_id AND i2.domain_id = $1
|
|
314
322
|
AND i2.bizplace_id IN (${bizplaceIds})
|
|
315
323
|
AND i2.status = 'STORED'
|
|
316
324
|
LEFT JOIN oi ON oi.product_id = i2.product_id
|
|
317
|
-
GROUP BY pbs.product_id, pbs.product_bundle_id
|
|
325
|
+
GROUP BY pbs.product_id, pbs.product_bundle_id, pbs.product_detail_id
|
|
318
326
|
) pbs ON pbs.product_bundle_id = pb.id
|
|
319
327
|
${bundleWhereClause}
|
|
320
|
-
GROUP BY pb.packing_type, pb.packing_size, pb.name, pb.sku, pb.id
|
|
328
|
+
GROUP BY pb.packing_type, pb.packing_size, pb.name, pb.sku, pb.id, pbs.product_detail_id
|
|
321
329
|
)
|
|
322
330
|
AS inv_prod_grp
|
|
323
331
|
${whereClause}
|
|
@@ -357,13 +365,15 @@ export const InventoryUtil = {
|
|
|
357
365
|
|
|
358
366
|
if (params?.pagination) {
|
|
359
367
|
items = await trxMgr.query(
|
|
360
|
-
`select * from temp_inventory_product_group ${filterGroupTypeQuery ? filterGroupTypeQuery : ''} ${
|
|
368
|
+
`select * from temp_inventory_product_group ${filterGroupTypeQuery ? filterGroupTypeQuery : ''} ${
|
|
369
|
+
sortingArr.length > 0 ? ' Order by ' + sortedBy.toString() : ''
|
|
361
370
|
} OFFSET $1 LIMIT $2`,
|
|
362
371
|
[(params.pagination.page - 1) * params.pagination.limit, params.pagination.limit]
|
|
363
372
|
)
|
|
364
373
|
} else {
|
|
365
374
|
items = await trxMgr.query(
|
|
366
|
-
`select * from temp_inventory_product_group ${filterGroupTypeQuery ? filterGroupTypeQuery : ''} ${
|
|
375
|
+
`select * from temp_inventory_product_group ${filterGroupTypeQuery ? filterGroupTypeQuery : ''} ${
|
|
376
|
+
sortingArr.length > 0 ? ' Order by ' + sortedBy.toString() : ''
|
|
367
377
|
}`
|
|
368
378
|
)
|
|
369
379
|
}
|
|
@@ -483,12 +493,17 @@ export const InventoryUtil = {
|
|
|
483
493
|
context: any,
|
|
484
494
|
trxMgr?: EntityManager
|
|
485
495
|
): Promise<Inventory> {
|
|
496
|
+
let validOrderInventories = orderInventories.filter(oi => oi.isError == false)
|
|
497
|
+
|
|
498
|
+
if (!validOrderInventories.length) {
|
|
499
|
+
return
|
|
500
|
+
}
|
|
501
|
+
|
|
486
502
|
let json_oi = JSON.stringify(
|
|
487
|
-
|
|
503
|
+
validOrderInventories.map(x => {
|
|
488
504
|
return {
|
|
489
|
-
|
|
505
|
+
product_detail_id: x.productDetail.id,
|
|
490
506
|
batch_id: x.batchId,
|
|
491
|
-
packing_type: x.packingType,
|
|
492
507
|
release_qty: x.releaseQty,
|
|
493
508
|
uom: x.uom
|
|
494
509
|
}
|
|
@@ -497,15 +512,14 @@ export const InventoryUtil = {
|
|
|
497
512
|
|
|
498
513
|
let resultQb = await trxMgr.query(
|
|
499
514
|
`
|
|
500
|
-
select joi.
|
|
515
|
+
select joi.product_detail_id as "productDetailId", joi.batch_id as "batchId", joi.uom as "uom", joi.release_qty as "releaseQty",
|
|
501
516
|
sum(i.qty - coalesce(i.locked_qty,0)) - coalesce(
|
|
502
517
|
(
|
|
503
518
|
select sum(oi.release_qty) from order_inventories oi
|
|
504
519
|
where (oi.status = 'PENDING' or oi.status = 'PENDING_RECEIVE' or oi.status = 'PENDING_WORKSHEET' or oi.status = 'PENDING_SPLIT')
|
|
505
520
|
and oi.inventory_id IS null
|
|
506
|
-
and oi.
|
|
521
|
+
and oi.product_detail_id = joi.product_detail_id
|
|
507
522
|
and oi.batch_id = joi.batch_id
|
|
508
|
-
and oi.packing_type = joi.packing_type
|
|
509
523
|
and oi.uom = joi.uom
|
|
510
524
|
and oi.domain_id = $1
|
|
511
525
|
and oi.bizplace_id = $2
|
|
@@ -515,21 +529,20 @@ export const InventoryUtil = {
|
|
|
515
529
|
select sum(oi.release_uom_value) from order_inventories oi
|
|
516
530
|
where (oi.status = 'PENDING' or oi.status = 'PENDING_RECEIVE' or oi.status = 'PENDING_WORKSHEET' or oi.status = 'PENDING_SPLIT')
|
|
517
531
|
and oi.inventory_id IS null
|
|
518
|
-
and oi.
|
|
532
|
+
and oi.product_detail_id = joi.product_detail_id
|
|
519
533
|
and oi.batch_id = joi.batch_id
|
|
520
|
-
and oi.packing_type = joi.packing_type
|
|
521
534
|
and oi.uom = joi.uom
|
|
522
535
|
and oi.domain_id = $1
|
|
523
536
|
and oi.bizplace_id = $2
|
|
524
537
|
),0) as "availableUomValue"
|
|
525
538
|
from json_populate_recordset(NULL::order_inventories,'${json_oi}') joi
|
|
526
|
-
left join inventories i on joi.
|
|
539
|
+
left join inventories i on joi.product_detail_id = i.product_detail_id
|
|
527
540
|
and joi.batch_id = i.batch_id
|
|
528
|
-
and
|
|
541
|
+
and i.status ='STORED'
|
|
529
542
|
and joi.uom = i.uom
|
|
530
543
|
and i.domain_id = $1
|
|
531
544
|
and i.bizplace_id = $2
|
|
532
|
-
group by joi.
|
|
545
|
+
group by joi.product_detail_id, joi.batch_id, joi.packing_type, joi.release_qty, joi.uom
|
|
533
546
|
`,
|
|
534
547
|
[warehouseDomain.id, partnerBizplace.id]
|
|
535
548
|
)
|
|
@@ -575,9 +588,9 @@ export const InventoryUtil = {
|
|
|
575
588
|
* @returns orderInventories
|
|
576
589
|
*/
|
|
577
590
|
async autoAssignInventoryForRelease(
|
|
578
|
-
product: Product,
|
|
579
591
|
orderInventory: OrderInventory,
|
|
580
|
-
|
|
592
|
+
product: Product,
|
|
593
|
+
productDetail: ProductDetail,
|
|
581
594
|
locationSortingRules: any = [],
|
|
582
595
|
customerBizplace: Bizplace,
|
|
583
596
|
domain: Domain,
|
|
@@ -588,16 +601,14 @@ export const InventoryUtil = {
|
|
|
588
601
|
qb.leftJoinAndSelect('iv.location', 'loc')
|
|
589
602
|
.andWhere('"iv"."domain_id" = :domainId')
|
|
590
603
|
.andWhere('"iv"."bizplace_id" = :bizplaceId')
|
|
591
|
-
.andWhere('"iv"."
|
|
592
|
-
.andWhere('"iv"."product_id" = :productId')
|
|
604
|
+
.andWhere('"iv"."product_detail_id" = :productDetailId')
|
|
593
605
|
.andWhere('"iv"."status" = :status')
|
|
594
606
|
.andWhere('"iv"."qty" - COALESCE("iv"."locked_qty", 0) > 0')
|
|
595
607
|
.andWhere('"loc"."type" NOT IN (:...locationTypes)')
|
|
596
608
|
.setParameters({
|
|
597
609
|
domainId: domain.id,
|
|
598
610
|
bizplaceId: customerBizplace.id,
|
|
599
|
-
|
|
600
|
-
productId: product.id,
|
|
611
|
+
productDetailId: productDetail.id,
|
|
601
612
|
status: INVENTORY_STATUS.STORED,
|
|
602
613
|
locationTypes: [LOCATION_TYPE.QUARANTINE, LOCATION_TYPE.RESERVE]
|
|
603
614
|
})
|
|
@@ -659,7 +670,7 @@ export const InventoryUtil = {
|
|
|
659
670
|
}
|
|
660
671
|
})
|
|
661
672
|
|
|
662
|
-
return _composeTargetInventories(
|
|
673
|
+
return _composeTargetInventories(productDetail, orderInventory, inventories)
|
|
663
674
|
},
|
|
664
675
|
|
|
665
676
|
/**
|
|
@@ -851,31 +862,32 @@ async function getConditions(
|
|
|
851
862
|
case 'batch_product':
|
|
852
863
|
productWhereClause += `
|
|
853
864
|
AND (i.batch_id, p.id, i.packing_type, i.packing_size) ${operator === 'in' ? 'IN' : 'NOT IN'} (${value
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
865
|
+
.map(
|
|
866
|
+
(v: { batchId: string; productId: string; packingType: string; packingSize: string }) =>
|
|
867
|
+
`('${v.batchId}', '${v.productId}', '${v.packingType}', '${v.packingSize}')`
|
|
868
|
+
)
|
|
869
|
+
.join()})
|
|
859
870
|
`
|
|
860
871
|
break
|
|
861
872
|
|
|
862
873
|
case 'batch_bundle':
|
|
863
874
|
bundleWhereClause += `
|
|
864
875
|
${bundleWhereClause == '' ? 'WHERE' : 'AND'} pb.id ${operator === 'in' ? 'IN' : 'NOT IN'} (${value
|
|
865
|
-
|
|
866
|
-
|
|
876
|
+
.map((v: { productId: string }) => `('${v.productId}')`)
|
|
877
|
+
.join()})
|
|
867
878
|
`
|
|
868
879
|
break
|
|
869
880
|
|
|
870
881
|
case 'product':
|
|
871
882
|
productDetailWhereClause += `
|
|
872
|
-
AND (pd.product_id, pd.packing_type, pd.packing_size, pd.uom) ${
|
|
883
|
+
AND (pd.product_id, pd.packing_type, pd.packing_size, pd.uom) ${
|
|
884
|
+
operator === 'in' ? 'IN' : 'NOT IN'
|
|
873
885
|
} (${value
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
886
|
+
.map(
|
|
887
|
+
(v: { productId: string; packingType: string; packingSize: string; uom: string }) =>
|
|
888
|
+
`('${v.productId}', '${v.packingType}', '${v.packingSize}', '${v.uom}')`
|
|
889
|
+
)
|
|
890
|
+
.join()})
|
|
879
891
|
`
|
|
880
892
|
break
|
|
881
893
|
}
|
|
@@ -927,98 +939,6 @@ async function updateInventory(
|
|
|
927
939
|
return await trxMgr.getRepository(Inventory).save(inventory)
|
|
928
940
|
}
|
|
929
941
|
|
|
930
|
-
async function generateInventoryHistory(
|
|
931
|
-
inventory: Inventory,
|
|
932
|
-
refOrder: any,
|
|
933
|
-
transactionType: string,
|
|
934
|
-
qty: number,
|
|
935
|
-
uomValue: number,
|
|
936
|
-
user: User,
|
|
937
|
-
trxMgr?: EntityManager
|
|
938
|
-
): Promise<InventoryHistory> {
|
|
939
|
-
const invHistoryRepo: Repository<InventoryHistory> =
|
|
940
|
-
trxMgr?.getRepository(InventoryHistory) || getRepository(InventoryHistory)
|
|
941
|
-
const invRepo: Repository<Inventory> = trxMgr?.getRepository(Inventory) || getRepository(Inventory)
|
|
942
|
-
|
|
943
|
-
if (!inventory?.id) throw new Error(`Can't find out ID of inventory.`)
|
|
944
|
-
if (!refOrder?.id || !refOrder.name) throw new Error(`Can't find out ID or Name of Reference Order`)
|
|
945
|
-
if (
|
|
946
|
-
!inventory?.domain ||
|
|
947
|
-
!inventory?.bizplace ||
|
|
948
|
-
!inventory?.product?.id ||
|
|
949
|
-
!inventory?.warehouse?.id ||
|
|
950
|
-
!inventory?.location?.id
|
|
951
|
-
) {
|
|
952
|
-
inventory = await invRepo.findOne({
|
|
953
|
-
where: { id: inventory.id },
|
|
954
|
-
relations: ['domain', 'bizplace', 'product', 'warehouse', 'location']
|
|
955
|
-
})
|
|
956
|
-
}
|
|
957
|
-
|
|
958
|
-
const domain: Domain = inventory.domain
|
|
959
|
-
const location: Location = inventory.location
|
|
960
|
-
|
|
961
|
-
const seq: number = await invHistoryRepo.count({ domain: inventory.domain, palletId: inventory.palletId })
|
|
962
|
-
let openingQty: number = 0
|
|
963
|
-
let openingUomValue: number = 0
|
|
964
|
-
|
|
965
|
-
if (seq) {
|
|
966
|
-
const lastInvHistory: InventoryHistory = await invHistoryRepo.findOne({
|
|
967
|
-
domain: inventory.domain,
|
|
968
|
-
palletId: inventory.palletId,
|
|
969
|
-
seq: seq - 1
|
|
970
|
-
})
|
|
971
|
-
openingQty = lastInvHistory.openingQty + lastInvHistory.qty
|
|
972
|
-
openingUomValue = lastInvHistory.openingUomValue + lastInvHistory.uomValue
|
|
973
|
-
}
|
|
974
|
-
|
|
975
|
-
let inventoryHistory: InventoryHistory = new InventoryHistory()
|
|
976
|
-
inventoryHistory.name = InventoryNoGenerator.inventoryHistoryName()
|
|
977
|
-
inventoryHistory.description = inventory.description
|
|
978
|
-
inventoryHistory.seq = seq
|
|
979
|
-
inventoryHistory.palletId = inventory.palletId
|
|
980
|
-
inventoryHistory.cartonId = inventory.cartonId
|
|
981
|
-
inventoryHistory.batchId = inventory.batchId
|
|
982
|
-
inventoryHistory.batchIdRef = inventory.batchIdRef
|
|
983
|
-
inventoryHistory.status = inventory.status
|
|
984
|
-
inventoryHistory.transactionType = transactionType
|
|
985
|
-
inventoryHistory.refOrderId = refOrder?.id || null
|
|
986
|
-
inventoryHistory.orderNo = refOrder?.name || null
|
|
987
|
-
inventoryHistory.orderRefNo = refOrder?.refNo || null
|
|
988
|
-
inventoryHistory.inventory = inventory
|
|
989
|
-
inventoryHistory.product = inventory.product
|
|
990
|
-
inventoryHistory.reusablePallet = inventory.reusablePallet
|
|
991
|
-
inventoryHistory.zone = inventory.zone
|
|
992
|
-
inventoryHistory.warehouse = inventory.warehouse
|
|
993
|
-
inventoryHistory.location = inventory.location
|
|
994
|
-
inventoryHistory.expirationDate = inventory.expirationDate
|
|
995
|
-
inventoryHistory.packingType = inventory.packingType
|
|
996
|
-
inventoryHistory.packingSize = inventory.packingSize
|
|
997
|
-
inventoryHistory.uom = inventory.uom
|
|
998
|
-
inventoryHistory.qty = qty
|
|
999
|
-
inventoryHistory.openingQty = openingQty
|
|
1000
|
-
inventoryHistory.uomValue = uomValue
|
|
1001
|
-
inventoryHistory.openingUomValue = openingUomValue
|
|
1002
|
-
inventoryHistory.unitCost = inventory.unitCost
|
|
1003
|
-
inventoryHistory.domain = inventory.domain
|
|
1004
|
-
inventoryHistory.bizplace = inventory.bizplace
|
|
1005
|
-
inventoryHistory.creator = user
|
|
1006
|
-
inventoryHistory.updater = user
|
|
1007
|
-
|
|
1008
|
-
inventoryHistory = await invHistoryRepo.save(inventoryHistory)
|
|
1009
|
-
|
|
1010
|
-
if (inventory.lastSeq !== seq) {
|
|
1011
|
-
await invRepo.save({
|
|
1012
|
-
...inventory,
|
|
1013
|
-
lastSeq: inventoryHistory.seq,
|
|
1014
|
-
updater: user
|
|
1015
|
-
})
|
|
1016
|
-
}
|
|
1017
|
-
|
|
1018
|
-
await switchLocationStatus(domain, location, user, trxMgr)
|
|
1019
|
-
return inventoryHistory
|
|
1020
|
-
}
|
|
1021
|
-
|
|
1022
942
|
/**
|
|
1023
943
|
* @description: Check location emptiness and update status of location
|
|
1024
944
|
* @param domain
|
|
@@ -1057,12 +977,17 @@ export async function switchLocationStatus(
|
|
|
1057
977
|
return location
|
|
1058
978
|
}
|
|
1059
979
|
|
|
1060
|
-
export function _composeTargetInventories(
|
|
980
|
+
export function _composeTargetInventories(
|
|
981
|
+
productDetail: ProductDetail,
|
|
982
|
+
record: any,
|
|
983
|
+
inventories: Inventory[]
|
|
984
|
+
): OrderInventory[] {
|
|
1061
985
|
let leftReleaseQty: number = record.releaseQty
|
|
1062
986
|
let leftReleaseUomValue: number = record.releaseUomValue
|
|
1063
987
|
let compReleaseQty: number = 0
|
|
1064
988
|
let compReleaseUomValue: number = 0
|
|
1065
989
|
let totalInventoryQty: number = inventories.reduce((total, inventory) => total + inventory.remainQty, 0)
|
|
990
|
+
let product = productDetail.product
|
|
1066
991
|
|
|
1067
992
|
if (totalInventoryQty < record.releaseQty) {
|
|
1068
993
|
throw new Error(`invalid release qty for ${product?.sku}`)
|
|
@@ -1115,6 +1040,7 @@ export function _composeTargetInventories(product: Product, record: any, invento
|
|
|
1115
1040
|
batchIdRef,
|
|
1116
1041
|
uom,
|
|
1117
1042
|
product,
|
|
1043
|
+
productDetail,
|
|
1118
1044
|
type: ORDER_TYPES.RELEASE_OF_GOODS
|
|
1119
1045
|
})
|
|
1120
1046
|
|
package/translations/en.json
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"error.Manifest(s) (x) already in open status": "Manifest(s) ({x}) already in open status",
|
|
3
|
+
"error.product_not_found": "product not found",
|
|
3
4
|
"error.release_order_not_found": "release order not found",
|
|
4
5
|
"error.tracking_no_already_scanned_before": "tracking no already scanned before",
|
|
5
6
|
"error.tracking_no_belongs_to_x": "tracking no belongs to {x}",
|
package/translations/ko.json
CHANGED
|
@@ -20,5 +20,6 @@
|
|
|
20
20
|
"error.Manifest(s) (x) already in open status": "[ko] Manifest(s) ({x}) already in open status",
|
|
21
21
|
"error.release_order_not_found": "[ko] release order not found",
|
|
22
22
|
"error.tracking_no_belongs_to_x": "[ko] tracking no belongs to {x}",
|
|
23
|
-
"error.tracking_no_already_scanned_before": "[ko] tracking no already scanned before"
|
|
23
|
+
"error.tracking_no_already_scanned_before": "[ko] tracking no already scanned before",
|
|
24
|
+
"error.product_not_found": "[ko] product not found"
|
|
24
25
|
}
|
package/translations/ms.json
CHANGED
|
@@ -20,5 +20,6 @@
|
|
|
20
20
|
"error.Manifest(s) (x) already in open status": "[ms] Manifest(s) ({x}) already in open status",
|
|
21
21
|
"error.release_order_not_found": "[ms] release order not found",
|
|
22
22
|
"error.tracking_no_belongs_to_x": "[ms] tracking no belongs to {x}",
|
|
23
|
-
"error.tracking_no_already_scanned_before": "[ms] tracking no already scanned before"
|
|
23
|
+
"error.tracking_no_already_scanned_before": "[ms] tracking no already scanned before",
|
|
24
|
+
"error.product_not_found": "[ms] product not found"
|
|
24
25
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"error.Manifest(s) (x) already in open status": "[zh] Manifest(s) ({x}) already in open status",
|
|
3
|
+
"error.product_not_found": "[zh] product not found",
|
|
4
|
+
"error.release_order_not_found": "[zh] release order not found",
|
|
5
|
+
"error.tracking_no_already_scanned_before": "t[zh] racking no already scanned before",
|
|
6
|
+
"error.tracking_no_belongs_to_x": "[zh] tracking no belongs to {x}",
|
|
7
|
+
"field.customer": "[zh] customer",
|
|
8
|
+
"field.issued_on": "[zh] issued on",
|
|
9
|
+
"field.payment_due": "[zh] payment due",
|
|
10
|
+
"field.version": "[zh] version",
|
|
11
|
+
"field.purchase_order": "[zh] purchase order",
|
|
12
|
+
"field.revision_price_on": "[zh] revision_price_on",
|
|
13
|
+
"field.option_name": "[zh] option_name",
|
|
14
|
+
"field.option_value": "[zh] option_value",
|
|
15
|
+
"field.type": "[zh] type",
|
|
16
|
+
"field.price": "[zh] price",
|
|
17
|
+
"field.quotation": "[zh] quotation",
|
|
18
|
+
"field.value": "[zh] value",
|
|
19
|
+
"field.quotation_item": "[zh] quotation item",
|
|
20
|
+
"field.amount": "[zh] amount",
|
|
21
|
+
"field.options": "[zh] options",
|
|
22
|
+
"field.unit": "[zh] unit",
|
|
23
|
+
"field.start_at": "[zh] start at",
|
|
24
|
+
"field.end_at": "[zh] end at"
|
|
25
|
+
}
|