@things-factory/sales-base 4.3.25 → 4.3.26
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@things-factory/sales-base",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.26",
|
|
4
4
|
"main": "dist-server/index.js",
|
|
5
5
|
"browser": "client/index.js",
|
|
6
6
|
"things-factory": true,
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"@things-factory/setting-base": "^4.3.24",
|
|
35
35
|
"@things-factory/shell": "^4.3.23",
|
|
36
36
|
"@things-factory/transport-base": "^4.3.24",
|
|
37
|
-
"@things-factory/warehouse-base": "^4.3.
|
|
37
|
+
"@things-factory/warehouse-base": "^4.3.26"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "dbb4dc519a8a7bd8fd295ec91f2f80ba6b1b3250"
|
|
40
40
|
}
|
|
@@ -60,45 +60,54 @@ export class ReleaseGoodQuery {
|
|
|
60
60
|
|
|
61
61
|
const qb: SelectQueryBuilder<ReleaseGood> = getRepository(ReleaseGood).createQueryBuilder('rg')
|
|
62
62
|
buildQuery(qb, params, context)
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
(acc, sort) => ({
|
|
90
|
-
...acc,
|
|
91
|
-
[arrChildSortData.indexOf(sort.name) >= 0 ? sort.name + '.name' : 'rg.' + sort.name]: sort.desc
|
|
92
|
-
? 'DESC'
|
|
93
|
-
: 'ASC'
|
|
94
|
-
}),
|
|
95
|
-
!params.sortings.some(e => e.name === 'status') ? { rank: 'ASC' } : {}
|
|
96
|
-
)
|
|
63
|
+
let items: any
|
|
64
|
+
let total: number
|
|
65
|
+
if (!params.filters.find((filter: any) => filter.name === 'releaseGoodOnly')) {
|
|
66
|
+
qb.addSelect('COALESCE("cc".rank, 99999)', 'rank')
|
|
67
|
+
qb.leftJoinAndSelect('rg.domain', 'domain')
|
|
68
|
+
qb.leftJoinAndSelect('rg.bizplace', 'bizplace')
|
|
69
|
+
qb.leftJoinAndSelect('rg.orderInventories', 'oi')
|
|
70
|
+
qb.leftJoinAndSelect('rg.orderProducts', 'op')
|
|
71
|
+
qb.leftJoinAndSelect('oi.inventory', 'inv')
|
|
72
|
+
qb.leftJoinAndSelect('oi.product', 'prod')
|
|
73
|
+
qb.leftJoinAndSelect('rg.arrivalNotice', 'an')
|
|
74
|
+
qb.leftJoinAndSelect('rg.creator', 'creator')
|
|
75
|
+
qb.leftJoinAndSelect('rg.updater', 'updater')
|
|
76
|
+
qb.leftJoin(
|
|
77
|
+
subQuery => {
|
|
78
|
+
return subQuery
|
|
79
|
+
.select(`ccd.rank`, 'rank')
|
|
80
|
+
.addSelect(`ccd.name`, 'status')
|
|
81
|
+
.from(`common_code_details`, 'ccd')
|
|
82
|
+
.innerJoin(`ccd.commonCode`, 'cc')
|
|
83
|
+
.where(`ccd.domain_id = :domainId`, { domainId: domain.id })
|
|
84
|
+
.andWhere(`cc.name = 'RO_LIST_STATUS'`)
|
|
85
|
+
},
|
|
86
|
+
'cc',
|
|
87
|
+
'cc.status = rg.status'
|
|
88
|
+
)
|
|
97
89
|
|
|
98
|
-
|
|
90
|
+
const arrChildSortData = ['bizplace']
|
|
91
|
+
const sort = (params.sortings || []).reduce(
|
|
92
|
+
(acc, sort) => ({
|
|
93
|
+
...acc,
|
|
94
|
+
[arrChildSortData.indexOf(sort.name) >= 0 ? sort.name + '.name' : 'rg.' + sort.name]: sort.desc
|
|
95
|
+
? 'DESC'
|
|
96
|
+
: 'ASC'
|
|
97
|
+
}),
|
|
98
|
+
!params.sortings.some(e => e.name === 'status') ? { rank: 'ASC' } : {}
|
|
99
|
+
)
|
|
99
100
|
|
|
100
|
-
|
|
101
|
+
qb.orderBy(sort)
|
|
101
102
|
|
|
103
|
+
let [itemsRes, totalRes] = await qb.getManyAndCount()
|
|
104
|
+
items = itemsRes
|
|
105
|
+
total = totalRes
|
|
106
|
+
} else {
|
|
107
|
+
let itemsRes = await qb.getOne()
|
|
108
|
+
items = itemsRes ? [itemsRes] : []
|
|
109
|
+
total = items.length
|
|
110
|
+
}
|
|
102
111
|
return { items, total }
|
|
103
112
|
} catch (error) {
|
|
104
113
|
throw error
|
|
@@ -468,24 +477,27 @@ export class ReleaseGoodQuery {
|
|
|
468
477
|
${batchId ? `AND LOWER(${INV_ALIAS}.batch_id) LIKE '%${batchId.toLowerCase()}%'` : ''}
|
|
469
478
|
${packingType ? `AND LOWER(${INV_ALIAS}.packing_type) LIKE '%${packingType.toLowerCase()}%'` : ''}
|
|
470
479
|
${containerNo ? `AND LOWER(${GAN_ALIAS}.container_no) LIKE '%${containerNo.toLowerCase()}%'` : ''}
|
|
471
|
-
${
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
480
|
+
${
|
|
481
|
+
product?.length > 0 && product[0]
|
|
482
|
+
? `AND ${PROD_ALIAS}.id IN (${product.map((id: string) => `'${id}'`).join(', ')})`
|
|
483
|
+
: product[0] === null
|
|
484
|
+
? `AND ${PROD_ALIAS}.id isnull`
|
|
485
|
+
: ''
|
|
486
|
+
}
|
|
487
|
+
${
|
|
488
|
+
inventory?.length > 0
|
|
489
|
+
? `
|
|
490
|
+
AND (${INV_ALIAS}.batch_id, ${PROD_ALIAS}.id) ${
|
|
491
|
+
filters.find((filter: { name: string; operator: string; value: any }) => filter.name === 'inventory')
|
|
492
|
+
.operator
|
|
493
|
+
} (
|
|
482
494
|
${inventory
|
|
483
|
-
|
|
484
|
-
|
|
495
|
+
.map((inv: { batchId: string; productId: string }) => `('${inv.batchId}', '${inv.productId}')`)
|
|
496
|
+
.join(', ')}
|
|
485
497
|
)
|
|
486
498
|
`
|
|
487
|
-
|
|
488
|
-
|
|
499
|
+
: ''
|
|
500
|
+
}
|
|
489
501
|
`
|
|
490
502
|
|
|
491
503
|
// ${product?.length > 0 ? `AND ${PROD_ALIAS}.id IN (${product.map((id: string) => id ? `'${id}'` : null).join(', ')})` : ''}
|
|
@@ -660,7 +672,7 @@ export async function bulkReleaseGoodsAvailableItemsFunction(
|
|
|
660
672
|
packing_size: raw.packingSize,
|
|
661
673
|
uom: raw.uom,
|
|
662
674
|
releaseQty: raw.releaseQty,
|
|
663
|
-
release_qty: raw.releaseQty
|
|
675
|
+
release_qty: raw.releaseQty
|
|
664
676
|
}
|
|
665
677
|
})
|
|
666
678
|
)
|
|
@@ -840,16 +852,16 @@ function _extractData(rawData, validatedData) {
|
|
|
840
852
|
!raw.productId || !raw.productDetailId
|
|
841
853
|
? 'inventory or product not found'
|
|
842
854
|
: raw.releaseQty <= 0
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
855
|
+
? 'invalid release qty'
|
|
856
|
+
: raw.assignedQty < raw.releaseQty
|
|
857
|
+
? 'insufficient stock'
|
|
858
|
+
: raw.releaseDate == ''
|
|
859
|
+
? 'release date is empty'
|
|
860
|
+
: releaseDate < _getStdDateStr(new Date())
|
|
861
|
+
? 'backdate is not allowed'
|
|
862
|
+
: !raw.refNo
|
|
863
|
+
? 'ref no is empty'
|
|
864
|
+
: ''
|
|
853
865
|
}
|
|
854
866
|
})
|
|
855
867
|
}
|