@things-factory/sales-base 4.0.38 → 4.0.39
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 +2 -2
- package/dist-server/service/arrival-notice/arrival-notice-mutation.js.map +1 -1
- package/dist-server/service/arrival-notice/arrival-notice-query.js +4 -4
- package/dist-server/service/arrival-notice/arrival-notice-query.js.map +1 -1
- package/dist-server/service/order-inventory/order-inventory.js +3 -3
- package/dist-server/service/order-inventory/order-inventory.js.map +1 -1
- package/dist-server/service/others/other-query.js +4 -2
- package/dist-server/service/others/other-query.js.map +1 -1
- package/dist-server/service/others/other-types.js +42 -0
- package/dist-server/service/others/other-types.js.map +1 -1
- package/dist-server/service/release-good/release-good-mutation.js +22 -10
- package/dist-server/service/release-good/release-good-mutation.js.map +1 -1
- package/dist-server/service/release-good/release-good-query.js +2 -4
- package/dist-server/service/release-good/release-good-query.js.map +1 -1
- package/package.json +12 -12
- package/server/service/arrival-notice/arrival-notice-mutation.ts +2 -2
- package/server/service/arrival-notice/arrival-notice-query.ts +3 -3
- package/server/service/order-inventory/order-inventory.ts +4 -4
- package/server/service/others/other-query.ts +9 -15
- package/server/service/others/other-types.ts +31 -0
- package/server/service/release-good/release-good-mutation.ts +38 -15
- package/server/service/release-good/release-good-query.ts +10 -10
|
@@ -76,7 +76,7 @@ export class ReleaseGoodMutation {
|
|
|
76
76
|
|
|
77
77
|
let releaseGoods: Partial<ReleaseGood[]> = extractRawReleaseGoods(rawReleaseGoods)
|
|
78
78
|
|
|
79
|
-
let
|
|
79
|
+
let errorsCaught: any[] = []
|
|
80
80
|
for (let i = 0, l = releaseGoods.length; i < l; i++) {
|
|
81
81
|
// generate release good by group to avoid duplication
|
|
82
82
|
// if this function is called simultaneously by different users
|
|
@@ -119,25 +119,31 @@ export class ReleaseGoodMutation {
|
|
|
119
119
|
|
|
120
120
|
createdReleaseGoods.push(createdReleaseGood)
|
|
121
121
|
})
|
|
122
|
-
} catch (
|
|
123
|
-
|
|
122
|
+
} catch (error) {
|
|
123
|
+
let rawReleaseGoods = formRawReleaseGoods(releaseGoods[i], error.message)
|
|
124
|
+
errorsCaught.push(...rawReleaseGoods)
|
|
124
125
|
}
|
|
125
126
|
}
|
|
126
127
|
|
|
127
128
|
let confirmedReleaseGoods: ReleaseGood[] = []
|
|
128
|
-
try {
|
|
129
|
-
confirmedReleaseGoods = await bulkConfirmReleaseGoods(
|
|
130
|
-
createdReleaseGoods.map(rg => rg.name),
|
|
131
|
-
domain,
|
|
132
|
-
user,
|
|
133
|
-
context,
|
|
134
|
-
tx
|
|
135
|
-
)
|
|
136
|
-
} catch (e) {
|
|
137
|
-
errorsFound.push(e)
|
|
138
|
-
}
|
|
139
129
|
|
|
140
|
-
|
|
130
|
+
if (createdReleaseGoods.length)
|
|
131
|
+
try {
|
|
132
|
+
confirmedReleaseGoods = await bulkConfirmReleaseGoods(
|
|
133
|
+
createdReleaseGoods.map(rg => rg.name),
|
|
134
|
+
domain,
|
|
135
|
+
user,
|
|
136
|
+
context,
|
|
137
|
+
tx
|
|
138
|
+
)
|
|
139
|
+
} catch (error) {
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
if (errorsCaught.length)
|
|
143
|
+
throw new ValidationError({
|
|
144
|
+
...ValidationError.ERROR_CODES.INVALID_DATA_FOUND,
|
|
145
|
+
detail: { data: JSON.stringify(errorsCaught) }
|
|
146
|
+
})
|
|
141
147
|
|
|
142
148
|
return confirmedReleaseGoods
|
|
143
149
|
}
|
|
@@ -1413,3 +1419,20 @@ function extractRawReleaseGoods(rawReleaseGoods): Partial<ReleaseGood[]> {
|
|
|
1413
1419
|
return releaseGoods
|
|
1414
1420
|
}, [])
|
|
1415
1421
|
}
|
|
1422
|
+
|
|
1423
|
+
function formRawReleaseGoods(releaseGood, errorMsg) {
|
|
1424
|
+
let rawReleaseGoods = []
|
|
1425
|
+
for (let i = 0, l = releaseGood.orderInventories.length; i < l; i++) {
|
|
1426
|
+
let rawReleaseGood = {
|
|
1427
|
+
...releaseGood,
|
|
1428
|
+
...releaseGood.orderInventories[i],
|
|
1429
|
+
errorMsg
|
|
1430
|
+
}
|
|
1431
|
+
|
|
1432
|
+
delete rawReleaseGood.orderInventories
|
|
1433
|
+
delete rawReleaseGood.product
|
|
1434
|
+
|
|
1435
|
+
rawReleaseGoods.push(rawReleaseGood)
|
|
1436
|
+
}
|
|
1437
|
+
return rawReleaseGoods
|
|
1438
|
+
}
|
|
@@ -371,9 +371,13 @@ export class ReleaseGoodQuery {
|
|
|
371
371
|
const PROD_ALIAS = 'PROD'
|
|
372
372
|
const GAN_ALIAS = 'GAN'
|
|
373
373
|
const conditions = filters
|
|
374
|
-
let {
|
|
375
|
-
|
|
376
|
-
|
|
374
|
+
let {
|
|
375
|
+
batchId = null,
|
|
376
|
+
containerNo = null,
|
|
377
|
+
product = [],
|
|
378
|
+
packingType = null,
|
|
379
|
+
inventory = []
|
|
380
|
+
} = getConditionValues(conditions)
|
|
377
381
|
|
|
378
382
|
const SELECT: string = `
|
|
379
383
|
SELECT
|
|
@@ -648,7 +652,7 @@ export async function bulkReleaseGoodsAvailableItemsFunction(
|
|
|
648
652
|
let availableItems = await tx.query(
|
|
649
653
|
`
|
|
650
654
|
WITH inv AS (
|
|
651
|
-
SELECT i.product_id, foo.product_detail_id, foo.sku, foo.product_info, i.
|
|
655
|
+
SELECT i.product_id, foo.product_detail_id, foo.sku, foo.product_info, i.packing_type, i.packing_size, i.uom,
|
|
652
656
|
SUM(i.qty - COALESCE(i.locked_qty, 0)) - COALESCE(
|
|
653
657
|
(
|
|
654
658
|
SELECT SUM(oi.release_qty) FROM order_inventories oi
|
|
@@ -686,7 +690,7 @@ export async function bulkReleaseGoodsAvailableItemsFunction(
|
|
|
686
690
|
AND i.domain_id = $1
|
|
687
691
|
AND i.bizplace_id = $2
|
|
688
692
|
WHERE l.type NOT IN ($3, $4)
|
|
689
|
-
GROUP BY i.product_id, foo.product_detail_id, foo.sku,foo.product_info, i.
|
|
693
|
+
GROUP BY i.product_id, foo.product_detail_id, foo.sku,foo.product_info, i.packing_type, i.packing_size, i.uom
|
|
690
694
|
ORDER BY foo.sku, remain_qty
|
|
691
695
|
) SELECT * FROM inv WHERE remain_qty > 0
|
|
692
696
|
`,
|
|
@@ -701,7 +705,6 @@ export async function bulkReleaseGoodsAvailableItemsFunction(
|
|
|
701
705
|
productDetailId: item.product_detail_id,
|
|
702
706
|
productInfo: item.product_info,
|
|
703
707
|
sku: item.sku,
|
|
704
|
-
batchId: item.batch_id,
|
|
705
708
|
packingType: item.packing_type,
|
|
706
709
|
packingSize: Number(item.packing_size || 0),
|
|
707
710
|
uom: item.uom,
|
|
@@ -766,7 +769,6 @@ function _extractData(rawData, validatedData) {
|
|
|
766
769
|
raw.packingType = validatedData[idx].packingType
|
|
767
770
|
raw.packingSize = validatedData[idx].packingSize
|
|
768
771
|
raw.uom = validatedData[idx].uom
|
|
769
|
-
raw.batchId = validatedData[idx].batchId
|
|
770
772
|
} else {
|
|
771
773
|
raw.assignedQty = 0
|
|
772
774
|
raw.assignedUomValue = 0
|
|
@@ -796,9 +798,7 @@ function _extractData(rawData, validatedData) {
|
|
|
796
798
|
})
|
|
797
799
|
}
|
|
798
800
|
|
|
799
|
-
function getConditionValues(
|
|
800
|
-
conditions: Filter[]
|
|
801
|
-
): {
|
|
801
|
+
function getConditionValues(conditions: Filter[]): {
|
|
802
802
|
batchId?: string
|
|
803
803
|
containerNo?: string
|
|
804
804
|
product?: string[]
|