@things-factory/sales-base 4.3.60 → 4.3.64
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/constants/release-good.js +5 -1
- package/dist-server/constants/release-good.js.map +1 -1
- package/dist-server/service/delivery-order/delivery-order-mutation.js +6 -15
- package/dist-server/service/delivery-order/delivery-order-mutation.js.map +1 -1
- package/dist-server/service/delivery-order/delivery-order-query.js +3 -0
- package/dist-server/service/delivery-order/delivery-order-query.js.map +1 -1
- package/dist-server/service/draft-release-good/draft-release-good-mutation.js +26 -19
- package/dist-server/service/draft-release-good/draft-release-good-mutation.js.map +1 -1
- package/dist-server/service/manifest/manifest-mutation.js +7 -3
- package/dist-server/service/manifest/manifest-mutation.js.map +1 -1
- package/dist-server/service/order-inventory/order-inventory-query.js +54 -27
- package/dist-server/service/order-inventory/order-inventory-query.js.map +1 -1
- package/dist-server/service/order-inventory/order-inventory.js +8 -2
- package/dist-server/service/order-inventory/order-inventory.js.map +1 -1
- package/dist-server/service/order-product/order-product-query.js +35 -4
- package/dist-server/service/order-product/order-product-query.js.map +1 -1
- package/dist-server/service/order-tote/order-tote.js +2 -1
- package/dist-server/service/order-tote/order-tote.js.map +1 -1
- package/dist-server/service/release-good/release-good-mutation.js +102 -37
- package/dist-server/service/release-good/release-good-mutation.js.map +1 -1
- package/dist-server/service/release-good/release-good-query.js +80 -7
- package/dist-server/service/release-good/release-good-query.js.map +1 -1
- package/dist-server/service/release-good/release-good-types.js +41 -20
- package/dist-server/service/release-good/release-good-types.js.map +1 -1
- package/dist-server/service/release-good/release-good.js +25 -6
- package/dist-server/service/release-good/release-good.js.map +1 -1
- package/dist-server/service/shipping-order/shipping-order-types.js +21 -1
- package/dist-server/service/shipping-order/shipping-order-types.js.map +1 -1
- package/dist-server/service/shipping-order/shipping-order.js +22 -2
- package/dist-server/service/shipping-order/shipping-order.js.map +1 -1
- package/dist-server/utils/inventory-util.js +69 -30
- package/dist-server/utils/inventory-util.js.map +1 -1
- package/package.json +6 -6
- package/server/constants/release-good.ts +6 -3
- package/server/service/delivery-order/delivery-order-mutation.ts +5 -11
- package/server/service/delivery-order/delivery-order-query.ts +19 -18
- package/server/service/draft-release-good/draft-release-good-mutation.ts +41 -22
- package/server/service/manifest/manifest-mutation.ts +10 -3
- package/server/service/order-inventory/order-inventory-query.ts +68 -36
- package/server/service/order-inventory/order-inventory.ts +8 -2
- package/server/service/order-product/order-product-query.ts +45 -8
- package/server/service/order-tote/order-tote.ts +13 -2
- package/server/service/release-good/release-good-mutation.ts +165 -50
- package/server/service/release-good/release-good-query.ts +126 -41
- package/server/service/release-good/release-good-types.ts +25 -6
- package/server/service/release-good/release-good.ts +24 -8
- package/server/service/shipping-order/shipping-order-types.ts +16 -1
- package/server/service/shipping-order/shipping-order.ts +18 -2
- package/server/utils/inventory-util.ts +107 -54
|
@@ -30,7 +30,6 @@ import {
|
|
|
30
30
|
ShippingOrder,
|
|
31
31
|
ShippingOrderInfo
|
|
32
32
|
} from '../'
|
|
33
|
-
|
|
34
33
|
import { ReleaseOrderType } from '../../constants'
|
|
35
34
|
|
|
36
35
|
const ORMCONFIG = config.get('ormconfig', {})
|
|
@@ -96,8 +95,8 @@ export class ReleaseGood {
|
|
|
96
95
|
DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb'
|
|
97
96
|
? 'enum'
|
|
98
97
|
: DATABASE_TYPE == 'oracle'
|
|
99
|
-
|
|
100
|
-
|
|
98
|
+
? 'varchar2'
|
|
99
|
+
: 'smallint',
|
|
101
100
|
enum: ReleaseOrderType,
|
|
102
101
|
default: ReleaseOrderType.B2B
|
|
103
102
|
})
|
|
@@ -124,6 +123,10 @@ export class ReleaseGood {
|
|
|
124
123
|
@Field()
|
|
125
124
|
crossDocking: Boolean
|
|
126
125
|
|
|
126
|
+
@Column({ nullable: true })
|
|
127
|
+
@Field({ nullable: true })
|
|
128
|
+
orderMethod: string
|
|
129
|
+
|
|
127
130
|
@ManyToOne(type => ArrivalNotice)
|
|
128
131
|
@Field(type => ArrivalNotice, { nullable: true })
|
|
129
132
|
arrivalNotice: ArrivalNotice
|
|
@@ -164,16 +167,14 @@ export class ReleaseGood {
|
|
|
164
167
|
DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb'
|
|
165
168
|
? 'enum'
|
|
166
169
|
: DATABASE_TYPE == 'oracle'
|
|
167
|
-
|
|
168
|
-
|
|
170
|
+
? 'varchar2'
|
|
171
|
+
: 'smallint',
|
|
169
172
|
enum: DispatchmentStatus,
|
|
170
173
|
default: DispatchmentStatus.READY_TO_DISPATCH
|
|
171
174
|
})
|
|
172
175
|
dispatchmentStatus: DispatchmentStatus
|
|
173
176
|
|
|
174
|
-
|
|
175
|
-
@Field({ nullable: true })
|
|
176
|
-
releaseDateTime: Date
|
|
177
|
+
|
|
177
178
|
|
|
178
179
|
@Column({ nullable: true })
|
|
179
180
|
@Field({ nullable: true })
|
|
@@ -311,6 +312,10 @@ export class ReleaseGood {
|
|
|
311
312
|
@Field({ nullable: true })
|
|
312
313
|
invoice: string
|
|
313
314
|
|
|
315
|
+
@Column({ nullable: true })
|
|
316
|
+
@Field({ nullable: true })
|
|
317
|
+
recall: boolean
|
|
318
|
+
|
|
314
319
|
@Column({ nullable: true })
|
|
315
320
|
bundleInfo: string
|
|
316
321
|
|
|
@@ -438,6 +443,17 @@ export class ReleaseGood {
|
|
|
438
443
|
@Field({ nullable: true })
|
|
439
444
|
stopId: string
|
|
440
445
|
|
|
446
|
+
@Column({ nullable: true })
|
|
447
|
+
@Field({ nullable: true })
|
|
448
|
+
manifestedAt: Date
|
|
449
|
+
|
|
450
|
+
@ManyToOne(type => User)
|
|
451
|
+
@Field(type => User, { nullable: true })
|
|
452
|
+
manifestedBy: User
|
|
453
|
+
|
|
454
|
+
@RelationId((releaseGood: ReleaseGood) => releaseGood.manifestedBy)
|
|
455
|
+
manifestedById: string
|
|
456
|
+
|
|
441
457
|
@Field({ nullable: true })
|
|
442
458
|
orderRemark: Boolean
|
|
443
459
|
|
|
@@ -54,21 +54,36 @@ export class ShippingOrderPatch {
|
|
|
54
54
|
@Field({ nullable: true })
|
|
55
55
|
containerNo: string
|
|
56
56
|
|
|
57
|
+
@Field({ nullable: true })
|
|
58
|
+
containerSize: string
|
|
59
|
+
|
|
57
60
|
@Field({ nullable: true })
|
|
58
61
|
containerArrivalDate: string
|
|
59
62
|
|
|
60
63
|
@Field({ nullable: true })
|
|
61
64
|
containerLeavingDate: string
|
|
62
65
|
|
|
66
|
+
@Field({ nullable: true })
|
|
67
|
+
containerClosureDate: string
|
|
68
|
+
|
|
63
69
|
@Field({ nullable: true })
|
|
64
70
|
containerArrivalDateTime: string
|
|
65
71
|
|
|
66
72
|
@Field({ nullable: true })
|
|
67
|
-
containerLeavingDateTime:
|
|
73
|
+
containerLeavingDateTime: Date
|
|
74
|
+
|
|
75
|
+
@Field({ nullable: true })
|
|
76
|
+
containerClosureDateTime: Date
|
|
68
77
|
|
|
69
78
|
@Field({ nullable: true })
|
|
70
79
|
remark: string
|
|
71
80
|
|
|
81
|
+
@Field({ nullable: true })
|
|
82
|
+
exportRemark: string
|
|
83
|
+
|
|
72
84
|
@Field({ nullable: true })
|
|
73
85
|
status: string
|
|
86
|
+
|
|
87
|
+
@Field({ nullable: true })
|
|
88
|
+
remindContainerDeparture: boolean
|
|
74
89
|
}
|
|
@@ -41,14 +41,18 @@ export class ShippingOrder {
|
|
|
41
41
|
@Field()
|
|
42
42
|
name: string
|
|
43
43
|
|
|
44
|
-
@Column()
|
|
45
|
-
@Field()
|
|
44
|
+
@Column({ nullable: true })
|
|
45
|
+
@Field({ nullable: true })
|
|
46
46
|
shipName: string
|
|
47
47
|
|
|
48
48
|
@Column()
|
|
49
49
|
@Field()
|
|
50
50
|
containerNo: string
|
|
51
51
|
|
|
52
|
+
@Column({ nullable: true })
|
|
53
|
+
@Field()
|
|
54
|
+
containerSize: string
|
|
55
|
+
|
|
52
56
|
@Column({ nullable: true })
|
|
53
57
|
@Field({ nullable: true })
|
|
54
58
|
containerArrivalDate: string
|
|
@@ -65,6 +69,18 @@ export class ShippingOrder {
|
|
|
65
69
|
@Field({ nullable: true })
|
|
66
70
|
containerLeavingDateTime: Date
|
|
67
71
|
|
|
72
|
+
@Column({ nullable: true })
|
|
73
|
+
@Field({ nullable: true })
|
|
74
|
+
containerClosureDate: string
|
|
75
|
+
|
|
76
|
+
@Column({ nullable: true })
|
|
77
|
+
@Field({ nullable: true })
|
|
78
|
+
containerClosureDateTime: Date
|
|
79
|
+
|
|
80
|
+
@Column({ nullable: true })
|
|
81
|
+
@Field({ nullable: true })
|
|
82
|
+
remindContainerDeparture: boolean
|
|
83
|
+
|
|
68
84
|
@Column({ nullable: true })
|
|
69
85
|
@Field({ nullable: true })
|
|
70
86
|
from: string
|
|
@@ -127,16 +127,15 @@ export const InventoryUtil = {
|
|
|
127
127
|
) bp on i.product_id = bp.product_id
|
|
128
128
|
WHERE p.bizplace_id IN (${bizplaceIds})
|
|
129
129
|
${productDetailWhereClause}
|
|
130
|
-
${
|
|
131
|
-
|
|
132
|
-
? `AND (
|
|
130
|
+
${productFilter
|
|
131
|
+
? `AND (
|
|
133
132
|
lower(p.sku) ilike '${productFilter.value}'
|
|
134
133
|
OR lower(p.name) ilike '${productFilter.value}'
|
|
135
134
|
OR lower(p.description) ilike '${productFilter.value}'
|
|
136
135
|
)
|
|
137
136
|
`
|
|
138
|
-
|
|
139
|
-
|
|
137
|
+
: ``
|
|
138
|
+
}
|
|
140
139
|
GROUP BY
|
|
141
140
|
p.id,
|
|
142
141
|
pd.packing_type,
|
|
@@ -165,16 +164,15 @@ export const InventoryUtil = {
|
|
|
165
164
|
) pbs ON pbs.product_bundle_id = pb.id
|
|
166
165
|
${bundleWhereClause}
|
|
167
166
|
AND pb.bizplace_id IN (${bizplaceIds})
|
|
168
|
-
${
|
|
169
|
-
|
|
170
|
-
? `AND (
|
|
167
|
+
${productFilter
|
|
168
|
+
? `AND (
|
|
171
169
|
lower(pb.sku) ilike '${productFilter.value}'
|
|
172
170
|
OR lower(pb.name) ilike '${productFilter.value}'
|
|
173
171
|
OR lower(pb.description) ilike '${productFilter.value}'
|
|
174
172
|
)
|
|
175
173
|
`
|
|
176
|
-
|
|
177
|
-
|
|
174
|
+
: ``
|
|
175
|
+
}
|
|
178
176
|
GROUP BY
|
|
179
177
|
pb.packing_type,
|
|
180
178
|
pb.packing_size,
|
|
@@ -227,6 +225,8 @@ export const InventoryUtil = {
|
|
|
227
225
|
trxMgr
|
|
228
226
|
)
|
|
229
227
|
|
|
228
|
+
const _groupType = filters.find(res => res.name == 'groupType')
|
|
229
|
+
|
|
230
230
|
let queryStrings = `
|
|
231
231
|
CREATE TEMP TABLE temp_inventory_product_group AS (
|
|
232
232
|
SELECT * FROM (
|
|
@@ -324,18 +324,48 @@ export const InventoryUtil = {
|
|
|
324
324
|
)
|
|
325
325
|
`
|
|
326
326
|
|
|
327
|
+
let filterGroupTypeQuery
|
|
328
|
+
|
|
329
|
+
if (_groupType) {
|
|
330
|
+
if (_groupType.value === 'SINGLE') {
|
|
331
|
+
filterGroupTypeQuery = `where "groupType"= 'SINGLE' `
|
|
332
|
+
} else {
|
|
333
|
+
filterGroupTypeQuery = `where "groupType"= 'BUNDLE' `
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
let sortingArr = params.sortings || []
|
|
338
|
+
|
|
339
|
+
let sortedBy = []
|
|
340
|
+
|
|
341
|
+
if (sortingArr.length > 0) {
|
|
342
|
+
sortingArr.forEach(element => {
|
|
343
|
+
if (element.desc) {
|
|
344
|
+
sortedBy.push(`"${element.name}" DESC `)
|
|
345
|
+
} else {
|
|
346
|
+
sortedBy.push(`"${element.name}" `)
|
|
347
|
+
}
|
|
348
|
+
})
|
|
349
|
+
}
|
|
350
|
+
|
|
327
351
|
await trxMgr.query(queryStrings, [domain.id])
|
|
328
352
|
|
|
329
|
-
const [{ total }]: any = await trxMgr.query(
|
|
353
|
+
const [{ total }]: any = await trxMgr.query(
|
|
354
|
+
`select count(*) as total from temp_inventory_product_group ${filterGroupTypeQuery ? filterGroupTypeQuery : ''}`
|
|
355
|
+
)
|
|
330
356
|
let items: any[] = []
|
|
331
357
|
|
|
332
358
|
if (params?.pagination) {
|
|
333
|
-
items = await trxMgr.query(
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
359
|
+
items = await trxMgr.query(
|
|
360
|
+
`select * from temp_inventory_product_group ${filterGroupTypeQuery ? filterGroupTypeQuery : ''} ${sortingArr.length > 0 ? ' Order by ' + sortedBy.toString() : ''
|
|
361
|
+
} OFFSET $1 LIMIT $2`,
|
|
362
|
+
[(params.pagination.page - 1) * params.pagination.limit, params.pagination.limit]
|
|
363
|
+
)
|
|
337
364
|
} else {
|
|
338
|
-
items = await trxMgr.query(
|
|
365
|
+
items = await trxMgr.query(
|
|
366
|
+
`select * from temp_inventory_product_group ${filterGroupTypeQuery ? filterGroupTypeQuery : ''} ${sortingArr.length > 0 ? ' Order by ' + sortedBy.toString() : ''
|
|
367
|
+
}`
|
|
368
|
+
)
|
|
339
369
|
}
|
|
340
370
|
|
|
341
371
|
await trxMgr.query(`drop table temp_inventory_product_group`)
|
|
@@ -551,7 +581,8 @@ export const InventoryUtil = {
|
|
|
551
581
|
locationSortingRules: any = [],
|
|
552
582
|
customerBizplace: Bizplace,
|
|
553
583
|
domain: Domain,
|
|
554
|
-
trxMgr: EntityManager
|
|
584
|
+
trxMgr: EntityManager,
|
|
585
|
+
batchId?: string
|
|
555
586
|
): Promise<OrderInventory[]> {
|
|
556
587
|
let qb: SelectQueryBuilder<Inventory> = trxMgr.getRepository(Inventory).createQueryBuilder('iv')
|
|
557
588
|
qb.leftJoinAndSelect('iv.location', 'loc')
|
|
@@ -571,30 +602,50 @@ export const InventoryUtil = {
|
|
|
571
602
|
locationTypes: [LOCATION_TYPE.QUARANTINE, LOCATION_TYPE.RESERVE]
|
|
572
603
|
})
|
|
573
604
|
|
|
574
|
-
if (
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
case 'LIFO':
|
|
589
|
-
qb.addOrderBy('"iv"."created_at"', 'DESC')
|
|
590
|
-
break
|
|
591
|
-
case 'FMFO':
|
|
592
|
-
qb.addOrderBy('"iv"."manufacture_date"', 'ASC')
|
|
593
|
-
break
|
|
594
|
-
default:
|
|
595
|
-
qb.addOrderBy('"iv"."created_at"', 'ASC')
|
|
596
|
-
break
|
|
605
|
+
if (batchId) {
|
|
606
|
+
qb.andWhere('"iv"."batch_id" = :batchId', { batchId: batchId })
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
let locationSorting = function (qb: SelectQueryBuilder<Inventory>, locationSortingRules) {
|
|
610
|
+
if (locationSortingRules?.length) {
|
|
611
|
+
locationSortingRules.forEach((rule: { name: string; desc: boolean }, idx: number) => {
|
|
612
|
+
idx === 0
|
|
613
|
+
? qb.addOrderBy(`loc.${rule.name}`, rule.desc ? 'DESC' : 'ASC')
|
|
614
|
+
: qb.addOrderBy(`loc.${rule.name}`, rule.desc ? 'DESC' : 'ASC')
|
|
615
|
+
})
|
|
616
|
+
} else {
|
|
617
|
+
qb.addOrderBy('"loc"."name"', 'ASC')
|
|
618
|
+
qb.addOrderBy('"iv"."created_at"', 'ASC')
|
|
597
619
|
}
|
|
620
|
+
return qb
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
switch (product?.pickingStrategy) {
|
|
624
|
+
case 'FIFO':
|
|
625
|
+
qb.addOrderBy('"iv"."created_at"', 'ASC')
|
|
626
|
+
qb = locationSorting(qb, locationSortingRules)
|
|
627
|
+
break
|
|
628
|
+
case 'LIFO':
|
|
629
|
+
qb.addOrderBy('"iv"."created_at"', 'DESC')
|
|
630
|
+
qb = locationSorting(qb, locationSortingRules)
|
|
631
|
+
break
|
|
632
|
+
case 'FEFO':
|
|
633
|
+
qb.addOrderBy('"iv"."expiration_date"', 'ASC')
|
|
634
|
+
qb.addOrderBy('"iv"."created_at"', 'ASC')
|
|
635
|
+
qb = locationSorting(qb, locationSortingRules)
|
|
636
|
+
break
|
|
637
|
+
case 'FMFO':
|
|
638
|
+
qb.addOrderBy('"iv"."manufacture_date"', 'ASC')
|
|
639
|
+
qb.addOrderBy('"iv"."created_at"', 'ASC')
|
|
640
|
+
qb = locationSorting(qb, locationSortingRules)
|
|
641
|
+
break
|
|
642
|
+
case 'LOCATION':
|
|
643
|
+
qb = locationSorting(qb, locationSortingRules)
|
|
644
|
+
break
|
|
645
|
+
default:
|
|
646
|
+
qb.addOrderBy('"iv"."created_at"', 'ASC')
|
|
647
|
+
qb = locationSorting(qb, locationSortingRules)
|
|
648
|
+
break
|
|
598
649
|
}
|
|
599
650
|
|
|
600
651
|
let inventories: Inventory[] = await qb.getMany()
|
|
@@ -709,6 +760,9 @@ async function getConditions(
|
|
|
709
760
|
whereClause += `AND LOWER("productBrand") LIKE '${value.toLowerCase()}'`
|
|
710
761
|
break
|
|
711
762
|
|
|
763
|
+
case 'productSKU':
|
|
764
|
+
whereClause += `AND LOWER("productSKU") LIKE '${value.toLowerCase()}'`
|
|
765
|
+
|
|
712
766
|
case 'productName':
|
|
713
767
|
const products: Product[] = await trxMgr.getRepository(Product).find({
|
|
714
768
|
select: ['id'],
|
|
@@ -797,32 +851,31 @@ async function getConditions(
|
|
|
797
851
|
case 'batch_product':
|
|
798
852
|
productWhereClause += `
|
|
799
853
|
AND (i.batch_id, p.id, i.packing_type, i.packing_size) ${operator === 'in' ? 'IN' : 'NOT IN'} (${value
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
854
|
+
.map(
|
|
855
|
+
(v: { batchId: string; productId: string; packingType: string; packingSize: string }) =>
|
|
856
|
+
`('${v.batchId}', '${v.productId}', '${v.packingType}', '${v.packingSize}')`
|
|
857
|
+
)
|
|
858
|
+
.join()})
|
|
805
859
|
`
|
|
806
860
|
break
|
|
807
861
|
|
|
808
862
|
case 'batch_bundle':
|
|
809
863
|
bundleWhereClause += `
|
|
810
864
|
${bundleWhereClause == '' ? 'WHERE' : 'AND'} pb.id ${operator === 'in' ? 'IN' : 'NOT IN'} (${value
|
|
811
|
-
|
|
812
|
-
|
|
865
|
+
.map((v: { productId: string }) => `('${v.productId}')`)
|
|
866
|
+
.join()})
|
|
813
867
|
`
|
|
814
868
|
break
|
|
815
869
|
|
|
816
870
|
case 'product':
|
|
817
871
|
productDetailWhereClause += `
|
|
818
|
-
AND (pd.product_id, pd.packing_type, pd.packing_size, pd.uom) ${
|
|
819
|
-
operator === 'in' ? 'IN' : 'NOT IN'
|
|
872
|
+
AND (pd.product_id, pd.packing_type, pd.packing_size, pd.uom) ${operator === 'in' ? 'IN' : 'NOT IN'
|
|
820
873
|
} (${value
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
874
|
+
.map(
|
|
875
|
+
(v: { productId: string; packingType: string; packingSize: string; uom: string }) =>
|
|
876
|
+
`('${v.productId}', '${v.packingType}', '${v.packingSize}', '${v.uom}')`
|
|
877
|
+
)
|
|
878
|
+
.join()})
|
|
826
879
|
`
|
|
827
880
|
break
|
|
828
881
|
}
|