@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
|
@@ -268,7 +268,7 @@ export class DraftReleaseGoodMutation {
|
|
|
268
268
|
i.uom == itm.uom &&
|
|
269
269
|
itm.releaseQty <= i.remainQty
|
|
270
270
|
)
|
|
271
|
-
return { ...itm, status: foundProductInv ? 'suffice' : 'insufficient' }
|
|
271
|
+
return { ...itm, releaseUomValue: (foundProductInv.remainUomValue / foundProductInv.remainQty) * itm.releaseQty, status: foundProductInv ? 'suffice' : 'insufficient' }
|
|
272
272
|
})
|
|
273
273
|
|
|
274
274
|
let insufficient = draftOrder.orderProducts.find(op => op.status == 'insufficient')
|
|
@@ -285,7 +285,7 @@ export class DraftReleaseGoodMutation {
|
|
|
285
285
|
let orderInventories = []
|
|
286
286
|
|
|
287
287
|
for (let index = 0; index < draftOrder.orderProducts.length; index++) {
|
|
288
|
-
const itm = draftOrder.orderProducts[index]
|
|
288
|
+
const itm: Partial<OrderProduct> = draftOrder.orderProducts[index]
|
|
289
289
|
let data = []
|
|
290
290
|
if (itm.productBundle) {
|
|
291
291
|
let bundle: ProductBundle = await parentTx.getRepository(ProductBundle).findOne({
|
|
@@ -301,26 +301,26 @@ export class DraftReleaseGoodMutation {
|
|
|
301
301
|
const objProductBundleSetting = bundle.productBundleSettings[index2]
|
|
302
302
|
data.push({
|
|
303
303
|
sku: objProductBundleSetting.product.sku,
|
|
304
|
-
|
|
305
|
-
|
|
304
|
+
packingType: objProductBundleSetting.productDetail.packingType,
|
|
305
|
+
packingSize: objProductBundleSetting.productDetail.packingSize,
|
|
306
306
|
uom: objProductBundleSetting.productDetail.uom,
|
|
307
|
-
|
|
307
|
+
releaseQty: objProductBundleSetting.bundleQty * itm.releaseQty,
|
|
308
308
|
assignedQty: undefined,
|
|
309
309
|
assignedUomValue: undefined,
|
|
310
|
-
releaseUomValue:
|
|
310
|
+
releaseUomValue: objProductBundleSetting.bundleQty * itm.releaseQty * itm.releaseUomValue
|
|
311
311
|
})
|
|
312
312
|
}
|
|
313
313
|
} else {
|
|
314
314
|
data = [
|
|
315
315
|
{
|
|
316
316
|
sku: itm.product.sku,
|
|
317
|
-
|
|
318
|
-
|
|
317
|
+
packingType: itm.packingType,
|
|
318
|
+
packingSize: itm.packingSize,
|
|
319
319
|
uom: itm.uom,
|
|
320
|
-
|
|
320
|
+
releaseQty: itm.releaseQty,
|
|
321
321
|
assignedQty: undefined,
|
|
322
322
|
assignedUomValue: undefined,
|
|
323
|
-
releaseUomValue:
|
|
323
|
+
releaseUomValue: itm.releaseUomValue
|
|
324
324
|
}
|
|
325
325
|
]
|
|
326
326
|
}
|
|
@@ -329,15 +329,17 @@ export class DraftReleaseGoodMutation {
|
|
|
329
329
|
let existingOI = orderInventories.find(
|
|
330
330
|
itm =>
|
|
331
331
|
itm.sku == data.sku &&
|
|
332
|
-
itm.
|
|
333
|
-
itm.
|
|
332
|
+
itm.packingType == data.packingType &&
|
|
333
|
+
itm.packingSize == data.packingSize &&
|
|
334
334
|
itm.uom == data.uom
|
|
335
335
|
)
|
|
336
336
|
|
|
337
337
|
if (existingOI) {
|
|
338
|
-
existingOI.
|
|
338
|
+
existingOI.releaseQty = existingOI.releaseQty + data.releaseQty
|
|
339
|
+
existingOI.releaseUomValue = existingOI.releaseUomValue + data.uomValue
|
|
340
|
+
existingOI.uomValue = existingOI.uomValue + data.uomValue
|
|
339
341
|
} else {
|
|
340
|
-
orderInventories.push(data)
|
|
342
|
+
orderInventories.push({ ...data, orderProduct: itm })
|
|
341
343
|
}
|
|
342
344
|
})
|
|
343
345
|
}
|
|
@@ -349,7 +351,7 @@ export class DraftReleaseGoodMutation {
|
|
|
349
351
|
context,
|
|
350
352
|
childTx
|
|
351
353
|
)
|
|
352
|
-
if (availableItems.some(item => !item.
|
|
354
|
+
if (availableItems.some(item => !item.releaseQty || item.releaseQty > item.assignedQty))
|
|
353
355
|
throw new ValidationError({
|
|
354
356
|
...ValidationError.ERROR_CODES.INSUFFICIENT_STOCK,
|
|
355
357
|
detail: { data: JSON.stringify(availableItems) }
|
|
@@ -358,7 +360,9 @@ export class DraftReleaseGoodMutation {
|
|
|
358
360
|
releaseGood.orderInventories = availableItems.map(itm => {
|
|
359
361
|
return {
|
|
360
362
|
...itm,
|
|
361
|
-
releaseQty: itm.
|
|
363
|
+
releaseQty: itm.releaseQty,
|
|
364
|
+
releaseUomValue: itm.releaseUomValue,
|
|
365
|
+
uomValue: itm.uomValue
|
|
362
366
|
}
|
|
363
367
|
})
|
|
364
368
|
let createdReleaseGood: ReleaseGood = await bulkGenerateReleaseGood(
|
|
@@ -469,7 +473,21 @@ export async function createDraftReleaseGoodFunction(
|
|
|
469
473
|
orderNo = OrderNoGenerator.draftReleaseGood()
|
|
470
474
|
}
|
|
471
475
|
|
|
472
|
-
// // 1. Create
|
|
476
|
+
// // 1. Create shipping order if found
|
|
477
|
+
if (shippingOrder) {
|
|
478
|
+
let newShippingOrder: ShippingOrder = await tx.getRepository(ShippingOrder).save({
|
|
479
|
+
...shippingOrder,
|
|
480
|
+
name: OrderNoGenerator.shippingOrder(),
|
|
481
|
+
domain,
|
|
482
|
+
bizplace: draftReleaseGood.bizplace,
|
|
483
|
+
status: ORDER_STATUS.PENDING,
|
|
484
|
+
creator: user,
|
|
485
|
+
updater: user
|
|
486
|
+
})
|
|
487
|
+
draftReleaseGood.shippingOrder = newShippingOrder
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
// // 2. Create draft release good
|
|
473
491
|
const createdDraftReleaseGood: DraftReleaseGood = await tx.getRepository(DraftReleaseGood).save({
|
|
474
492
|
...draftReleaseGood,
|
|
475
493
|
name: orderNo,
|
|
@@ -479,7 +497,8 @@ export async function createDraftReleaseGoodFunction(
|
|
|
479
497
|
updater: user
|
|
480
498
|
})
|
|
481
499
|
|
|
482
|
-
|
|
500
|
+
|
|
501
|
+
// // 3. Create draft release good product
|
|
483
502
|
await upsertDraftReleaseGoodProducts(
|
|
484
503
|
domain,
|
|
485
504
|
draftReleaseGood.bizplace,
|
|
@@ -489,7 +508,7 @@ export async function createDraftReleaseGoodFunction(
|
|
|
489
508
|
tx
|
|
490
509
|
)
|
|
491
510
|
|
|
492
|
-
// //
|
|
511
|
+
// // 4. Create Attachments
|
|
493
512
|
if (files?.length) {
|
|
494
513
|
const attachments: Attachment[] = files.map(attachment => {
|
|
495
514
|
return {
|
|
@@ -554,7 +573,7 @@ export async function updateDraftReleaseGoodFunction(
|
|
|
554
573
|
...existingDraftReleaseGood,
|
|
555
574
|
...draftReleaseGood,
|
|
556
575
|
domain,
|
|
557
|
-
creator:
|
|
576
|
+
creator: existingDraftReleaseGood.creator,
|
|
558
577
|
updater: user
|
|
559
578
|
})
|
|
560
579
|
|
|
@@ -714,8 +733,8 @@ export async function upsertDraftReleaseGoodProducts(
|
|
|
714
733
|
updatePatch['packingType'] = op?.packingType
|
|
715
734
|
? op.packingType
|
|
716
735
|
: product?.packingType
|
|
717
|
-
|
|
718
|
-
|
|
736
|
+
? product.packingType
|
|
737
|
+
: productBundle.packingType
|
|
719
738
|
updatePatch['uom'] = op?.uom ? op.uom : product?.primaryUnit ? product.primaryUnit : 'UNIT'
|
|
720
739
|
updatePatch['uomValue'] = op?.uomValue ? op.uomValue : product?.primaryValue ? product.primaryValue : 0
|
|
721
740
|
|
|
@@ -44,7 +44,9 @@ export class ManifestMutation {
|
|
|
44
44
|
if (removeOrders?.length > 0) {
|
|
45
45
|
//check if user removing all tracking no, if yes then delete
|
|
46
46
|
let totalTrackingNo = await tx.getRepository(ReleaseGood).count({ where: { manifest: manifestId } })
|
|
47
|
-
await tx
|
|
47
|
+
await tx
|
|
48
|
+
.getRepository(ReleaseGood)
|
|
49
|
+
.update({ domain, refNo: In(removeOrders) }, { manifest: null, manifestedBy: null, manifestedAt: null })
|
|
48
50
|
if (removeOrders.length == totalTrackingNo) {
|
|
49
51
|
await tx.getRepository(Manifest).delete(manifestId)
|
|
50
52
|
return false
|
|
@@ -101,6 +103,8 @@ export class ManifestMutation {
|
|
|
101
103
|
.findOne({ domain, refNo: item.refNo, trackingNo: item.trackingNo })
|
|
102
104
|
releaseOrder.manifest = manifest
|
|
103
105
|
releaseOrder.updater = user
|
|
106
|
+
releaseOrder.manifestedBy = user.id
|
|
107
|
+
releaseOrder.manifestedAt = new Date()
|
|
104
108
|
await tx.getRepository(ReleaseGood).save(releaseOrder)
|
|
105
109
|
})
|
|
106
110
|
)
|
|
@@ -117,7 +121,7 @@ export class ManifestMutation {
|
|
|
117
121
|
@Arg('shippingProvider', { nullable: true }) shippingProvider: string,
|
|
118
122
|
@Ctx() context: any
|
|
119
123
|
): Promise<boolean> {
|
|
120
|
-
const { domain, tx } = context.state
|
|
124
|
+
const { domain, user, tx } = context.state
|
|
121
125
|
const releaseGoodRepo = tx.getRepository(ReleaseGood)
|
|
122
126
|
//check if order belongs to same shipping provider
|
|
123
127
|
let foundReleaseOrder = await releaseGoodRepo.findOne({ where: { trackingNo }, relations: ['manifest'] })
|
|
@@ -134,7 +138,10 @@ export class ManifestMutation {
|
|
|
134
138
|
throw new Error(i18next.t('error.tracking_no_belongs_to_x', { x: foundReleaseOrder.transporter }))
|
|
135
139
|
}
|
|
136
140
|
|
|
137
|
-
await releaseGoodRepo.update(
|
|
141
|
+
await releaseGoodRepo.update(
|
|
142
|
+
{ id: foundReleaseOrder.id },
|
|
143
|
+
{ manifest: manifestId, manifestedAt: new Date(), manifestedBy: user }
|
|
144
|
+
)
|
|
138
145
|
|
|
139
146
|
return true
|
|
140
147
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { Arg, Args, Ctx, FieldResolver, Query, Resolver, Root
|
|
1
|
+
import { Arg, Args, Ctx, Directive, FieldResolver, Query, Resolver, Root } from 'type-graphql'
|
|
2
2
|
import { Brackets, EntityManager, getRepository, Like, SelectQueryBuilder } from 'typeorm'
|
|
3
3
|
|
|
4
4
|
import { User } from '@things-factory/auth-base'
|
|
5
5
|
import { getPermittedBizplaceIds } from '@things-factory/biz-base'
|
|
6
6
|
import { Product } from '@things-factory/product-base'
|
|
7
7
|
import { buildQuery, convertListParams, Domain, Filter, ListParam, Pagination, Sorting } from '@things-factory/shell'
|
|
8
|
-
import { Inventory, InventoryPatch
|
|
8
|
+
import { Inventory, InventoryPatch } from '@things-factory/warehouse-base'
|
|
9
9
|
|
|
10
10
|
import { ORDER_INVENTORY_STATUS, ORDER_STATUS } from '../../constants'
|
|
11
11
|
import { ArrivalNotice } from '../arrival-notice/arrival-notice'
|
|
@@ -23,58 +23,90 @@ export class OrderInventoryQuery {
|
|
|
23
23
|
@Query(returns => OrderInventoryList)
|
|
24
24
|
async orderInventories(@Ctx() context: any, @Args() params: ListParam): Promise<OrderInventoryList> {
|
|
25
25
|
const { domain }: { domain: Domain } = context.state
|
|
26
|
-
|
|
26
|
+
const arrivalNoticeNoParam: any = params.filters.find((param: any) => param.name === 'arrivalNoticeNo')
|
|
27
|
+
const releaseGoodNoParam: any = params.filters.find((param: any) => param.name === 'releaseGoodNo')
|
|
27
28
|
|
|
28
|
-
|
|
29
|
-
const anParam = filters.find(
|
|
30
|
-
(filter: filterInterface) => filter.name === 'arrivalNoticeNo' && filter.operator === 'eq'
|
|
31
|
-
)
|
|
32
|
-
const rgParam = filters.find(
|
|
33
|
-
(filter: filterInterface) => filter.name === 'releaseGoodNo' && filter.operator === 'eq'
|
|
34
|
-
)
|
|
35
|
-
|
|
36
|
-
if (anParam && !filters.some((filter: filterInterface) => filter.name === 'arrivalNotice')) {
|
|
29
|
+
if (arrivalNoticeNoParam && arrivalNoticeNoParam?.value) {
|
|
37
30
|
const foundArrivalNotice: ArrivalNotice = await getRepository(ArrivalNotice).findOne({
|
|
38
31
|
where: {
|
|
39
|
-
name:
|
|
32
|
+
name: arrivalNoticeNoParam.value,
|
|
40
33
|
domain
|
|
41
34
|
}
|
|
42
35
|
})
|
|
43
36
|
|
|
44
37
|
if (foundArrivalNotice) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
38
|
+
params.filters.splice(
|
|
39
|
+
params.filters.findIndex(item => item.name == 'arrivalNoticeNo'),
|
|
40
|
+
1
|
|
41
|
+
)
|
|
42
|
+
params.filters.push({ name: 'arrivalNoticeId', operator: 'eq', value: foundArrivalNotice.id })
|
|
43
|
+
} else {
|
|
44
|
+
throw new Error(`Cannot find result for order "${arrivalNoticeNoParam.value}"`)
|
|
45
|
+
}
|
|
48
46
|
}
|
|
49
47
|
|
|
50
|
-
if (
|
|
48
|
+
if (releaseGoodNoParam && releaseGoodNoParam?.value) {
|
|
51
49
|
const foundReleaseGood: ReleaseGood = await getRepository(ReleaseGood).findOne({
|
|
52
50
|
where: {
|
|
53
|
-
name:
|
|
51
|
+
name: releaseGoodNoParam.value,
|
|
54
52
|
domain
|
|
55
53
|
}
|
|
56
54
|
})
|
|
57
55
|
|
|
58
56
|
if (foundReleaseGood) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
57
|
+
params.filters.splice(
|
|
58
|
+
params.filters.findIndex(item => item.name == 'releaseGoodNo'),
|
|
59
|
+
1
|
|
60
|
+
)
|
|
61
|
+
params.filters.push({ name: 'releaseGoodId', operator: 'eq', value: foundReleaseGood.id })
|
|
62
|
+
} else {
|
|
63
|
+
throw new Error(`Cannot find result for order "${releaseGoodNoParam.value}"`)
|
|
64
|
+
}
|
|
62
65
|
}
|
|
63
66
|
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
67
|
+
const qb: SelectQueryBuilder<OrderInventory> = getRepository(OrderInventory).createQueryBuilder('oi')
|
|
68
|
+
buildQuery(qb, params, context)
|
|
69
|
+
|
|
70
|
+
qb.leftJoinAndSelect('oi.domain', 'domain')
|
|
71
|
+
qb.leftJoinAndSelect('oi.arrivalNotice', 'arrivalNotice')
|
|
72
|
+
qb.leftJoinAndSelect('oi.orderProduct', 'orderProduct')
|
|
73
|
+
qb.leftJoinAndSelect('oi.inventory', 'inventory')
|
|
74
|
+
qb.leftJoinAndSelect('inventory.product', 'product')
|
|
75
|
+
qb.leftJoinAndSelect('inventory.location', 'location')
|
|
76
|
+
qb.leftJoinAndSelect('oi.releaseGood', 'releaseGood')
|
|
77
|
+
qb.leftJoinAndSelect('oi.deliveryOrder', 'deliveryOrder')
|
|
78
|
+
qb.leftJoinAndSelect('oi.creator', 'creator')
|
|
79
|
+
qb.leftJoinAndSelect('oi.updater', 'updater')
|
|
80
|
+
|
|
81
|
+
let sort = {}
|
|
82
|
+
if (params?.sortings) {
|
|
83
|
+
if (params.sortings.some(e => e.name === 'inventoryPalletId')) {
|
|
84
|
+
// overwrite the worksheet status sorting since inventory check status is needed
|
|
85
|
+
sort = {
|
|
86
|
+
'inventory.palletId': params.sortings[params.sortings.findIndex(item => item.name == 'inventoryPalletId')]
|
|
87
|
+
.desc
|
|
88
|
+
? 'DESC'
|
|
89
|
+
: 'ASC',
|
|
90
|
+
'oi.createdAt': params.sortings[params.sortings.findIndex(item => item.name == 'createdAt')]?.desc
|
|
91
|
+
? 'DESC'
|
|
92
|
+
: 'ASC'
|
|
93
|
+
}
|
|
94
|
+
} else if (params.sortings.some(e => e.name === 'createdAt')) {
|
|
95
|
+
sort = {
|
|
96
|
+
...sort,
|
|
97
|
+
'oi.createdAt': params.sortings[params.sortings.findIndex(item => item.name == 'createdAt')]?.desc
|
|
98
|
+
? 'DESC'
|
|
99
|
+
: 'ASC'
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
} else {
|
|
103
|
+
sort = { 'oi.createdAt': 'ASC' }
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
qb.orderBy(sort)
|
|
107
|
+
|
|
108
|
+
let [items, total] = await qb.getManyAndCount()
|
|
109
|
+
|
|
78
110
|
return { items, total }
|
|
79
111
|
}
|
|
80
112
|
|
|
@@ -457,7 +489,7 @@ export class OrderInventoryQuery {
|
|
|
457
489
|
let sort = ''
|
|
458
490
|
let prioritySort = ''
|
|
459
491
|
let releaseOrderIdQuery = ''
|
|
460
|
-
|
|
492
|
+
|
|
461
493
|
// Require further evaluation. Potential performance issue.
|
|
462
494
|
if (mergedPageParam) {
|
|
463
495
|
releaseOrderIdQuery = `
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
Entity,
|
|
6
6
|
Index,
|
|
7
7
|
ManyToOne,
|
|
8
|
+
OneToMany,
|
|
8
9
|
PrimaryGeneratedColumn,
|
|
9
10
|
RelationId,
|
|
10
11
|
UpdateDateColumn
|
|
@@ -20,6 +21,7 @@ import { ArrivalNotice } from '../arrival-notice/arrival-notice'
|
|
|
20
21
|
import { DeliveryOrder } from '../delivery-order/delivery-order'
|
|
21
22
|
import { InventoryCheck } from '../inventory-check/inventory-check'
|
|
22
23
|
import { OrderProduct } from '../order-product/order-product'
|
|
24
|
+
import { OrderToteItem } from '../order-tote-item/order-tote-item'
|
|
23
25
|
import { ReleaseGood } from '../release-good/release-good'
|
|
24
26
|
import { ReturnOrder } from '../return-order/return-order'
|
|
25
27
|
import { TransferOrder } from '../transfer-order/transfer-order'
|
|
@@ -62,6 +64,7 @@ import { TransferOrder } from '../transfer-order/transfer-order'
|
|
|
62
64
|
orderInventory.releaseQty,
|
|
63
65
|
orderInventory.uom
|
|
64
66
|
])
|
|
67
|
+
@Index('ix_order-inventory_5', (orderInventory: OrderInventory) => [orderInventory.releaseGood])
|
|
65
68
|
@ObjectType()
|
|
66
69
|
export class OrderInventory {
|
|
67
70
|
@PrimaryGeneratedColumn('uuid')
|
|
@@ -182,6 +185,10 @@ export class OrderInventory {
|
|
|
182
185
|
@RelationId((orderInventory: OrderInventory) => orderInventory.orderProduct)
|
|
183
186
|
orderProductId: string
|
|
184
187
|
|
|
188
|
+
@OneToMany(type => OrderToteItem, orderToteItem => orderToteItem.orderInventory, { nullable: true })
|
|
189
|
+
@Field(type => [OrderToteItem], { nullable: true })
|
|
190
|
+
orderToteItems: OrderToteItem[]
|
|
191
|
+
|
|
185
192
|
@Column({ type: 'uuid', nullable: true })
|
|
186
193
|
@Field({ nullable: true })
|
|
187
194
|
refWorksheetId: string
|
|
@@ -334,9 +341,8 @@ export class OrderInventory {
|
|
|
334
341
|
@Field({ nullable: true })
|
|
335
342
|
loadedAt: Date
|
|
336
343
|
|
|
337
|
-
@Column({ nullable: true })
|
|
338
344
|
@Field({ nullable: true })
|
|
339
|
-
|
|
345
|
+
dispatchedAt: Date
|
|
340
346
|
|
|
341
347
|
@CreateDateColumn()
|
|
342
348
|
@Field()
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { User } from '@things-factory/auth-base'
|
|
2
|
-
import { convertListParams, Domain, Filter, Pagination, Sorting } from '@things-factory/shell'
|
|
3
1
|
import { Arg, Ctx, FieldResolver, Query, Resolver, Root } from 'type-graphql'
|
|
4
|
-
import { getRepository } from 'typeorm'
|
|
2
|
+
import { Brackets, getRepository, SelectQueryBuilder } from 'typeorm'
|
|
3
|
+
|
|
4
|
+
import { User } from '@things-factory/auth-base'
|
|
5
|
+
import { Domain, Filter, Pagination, Sorting } from '@things-factory/shell'
|
|
6
|
+
|
|
5
7
|
import { OrderProductList } from '../'
|
|
6
8
|
import { OrderProduct } from './order-product'
|
|
7
9
|
|
|
@@ -14,11 +16,46 @@ export class OrderProductQuery {
|
|
|
14
16
|
@Arg('pagination', type => Pagination, { nullable: true }) pagination?: Pagination,
|
|
15
17
|
@Arg('sortings', type => [Sorting], { nullable: true }) sortings?: Sorting[]
|
|
16
18
|
): Promise<OrderProductList> {
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
const { domain, user }: { domain: Domain; user: User } = context.state
|
|
20
|
+
const params = { filters, pagination }
|
|
21
|
+
|
|
22
|
+
const releaseGoodFilters = params.filters.filter(x => x.name == 'releaseGood')
|
|
23
|
+
const productFilters = params.filters.filter(x => x.name == 'productInfo')
|
|
24
|
+
const productFilterColumns = ['sku', 'brand_sku', 'name', 'description', 'brand', 'sub_brand']
|
|
25
|
+
params.filters = params.filters.filter(x => x.name != 'productInfo')
|
|
26
|
+
|
|
27
|
+
let qb: SelectQueryBuilder<OrderProduct> = await getRepository(OrderProduct).createQueryBuilder('op')
|
|
28
|
+
qb.leftJoinAndSelect('op.product', 'product')
|
|
29
|
+
.leftJoinAndSelect('op.domain', 'domain')
|
|
30
|
+
.leftJoinAndSelect('op.bizplace', 'bizplace')
|
|
31
|
+
.leftJoinAndSelect('bizplace.company', 'company')
|
|
32
|
+
.leftJoinAndSelect('op.arrivalNotice', 'an')
|
|
33
|
+
.leftJoinAndSelect('op.releaseGood', 'rg')
|
|
34
|
+
.leftJoinAndSelect('op.creator', 'creator')
|
|
35
|
+
.leftJoinAndSelect('op.updater', 'updater')
|
|
36
|
+
.andWhere('op.domain_id = :domainId', { domainId: domain.id })
|
|
37
|
+
.andWhere('op.release_good_id IN (:...releaseGoodId)', { releaseGoodId: releaseGoodFilters[0].value })
|
|
38
|
+
|
|
39
|
+
if (productFilters && productFilters.length > 0) {
|
|
40
|
+
let productInfo = productFilters[0]
|
|
41
|
+
let productValue = productInfo.value
|
|
42
|
+
.toLowerCase()
|
|
43
|
+
.split(',')
|
|
44
|
+
.map(prod => {
|
|
45
|
+
return "'%" + prod.trim().replace(/'/g, "''") + "%'"
|
|
46
|
+
})
|
|
47
|
+
.join(',')
|
|
48
|
+
qb.andWhere(
|
|
49
|
+
new Brackets(qb2 => {
|
|
50
|
+
productFilterColumns.forEach(filter => {
|
|
51
|
+
qb2.orWhere(`Lower("product"."${filter}") LIKE ANY(ARRAY[${productValue}])`)
|
|
52
|
+
})
|
|
53
|
+
})
|
|
54
|
+
)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
let [items, total] = await qb.getManyAndCount()
|
|
58
|
+
|
|
22
59
|
return { items, total }
|
|
23
60
|
}
|
|
24
61
|
|
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
import { Field, ObjectType } from 'type-graphql'
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
Column,
|
|
4
|
+
Entity,
|
|
5
|
+
Index,
|
|
6
|
+
ManyToOne,
|
|
7
|
+
OneToMany,
|
|
8
|
+
PrimaryGeneratedColumn,
|
|
9
|
+
RelationId,
|
|
10
|
+
UpdateDateColumn
|
|
11
|
+
} from 'typeorm'
|
|
3
12
|
|
|
4
13
|
import { User } from '@things-factory/auth-base'
|
|
5
14
|
import { Domain } from '@things-factory/shell'
|
|
6
15
|
import { Tote } from '@things-factory/warehouse-base'
|
|
7
|
-
|
|
16
|
+
|
|
8
17
|
import { OrderToteSeal } from '../order-tote-seal/order-tote-seal'
|
|
18
|
+
import { ReleaseGood } from '../release-good/release-good'
|
|
9
19
|
|
|
10
20
|
@Entity()
|
|
11
21
|
@Index('ix_order_tote_0', (orderTote: OrderTote) => [orderTote.id], { unique: true })
|
|
@@ -57,6 +67,7 @@ export class OrderTote {
|
|
|
57
67
|
@RelationId((orderTote: OrderTote) => orderTote.updater)
|
|
58
68
|
updaterId: string
|
|
59
69
|
|
|
70
|
+
@OneToMany(type => OrderToteSeal, orderToteSeal => orderToteSeal.orderTote, { nullable: true })
|
|
60
71
|
@Field(type => [OrderToteSeal], { nullable: true })
|
|
61
72
|
orderToteSeals?: OrderToteSeal[]
|
|
62
73
|
}
|