@things-factory/sales-base 4.3.79-alpha.1 → 4.3.79
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.js +0 -5
- package/dist-server/service/arrival-notice/arrival-notice.js.map +1 -1
- package/dist-server/service/draft-release-good/draft-release-good-mutation.js +8 -3
- 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 +7 -4
- package/dist-server/service/draft-release-good/draft-release-good-query.js.map +1 -1
- package/dist-server/service/draft-release-good/draft-release-good.js +0 -5
- package/dist-server/service/draft-release-good/draft-release-good.js.map +1 -1
- package/dist-server/service/invoice-product/invoice-product.js +3 -8
- package/dist-server/service/invoice-product/invoice-product.js.map +1 -1
- package/dist-server/service/order-inventory/order-inventory-types.js +10 -18
- package/dist-server/service/order-inventory/order-inventory-types.js.map +1 -1
- package/dist-server/service/order-inventory/order-inventory.js +3 -8
- package/dist-server/service/order-inventory/order-inventory.js.map +1 -1
- package/dist-server/service/order-product/order-product-query.js +0 -1
- package/dist-server/service/order-product/order-product-query.js.map +1 -1
- package/dist-server/service/order-product/order-product-types.js +10 -14
- package/dist-server/service/order-product/order-product-types.js.map +1 -1
- package/dist-server/service/order-vas/order-vas.js +3 -8
- package/dist-server/service/order-vas/order-vas.js.map +1 -1
- package/dist-server/service/others/other-query.js +32 -21
- package/dist-server/service/others/other-query.js.map +1 -1
- package/dist-server/service/others/other-types.js +0 -4
- package/dist-server/service/others/other-types.js.map +1 -1
- package/dist-server/service/purchase-order/purchase-order-mutation.js +2 -10
- package/dist-server/service/purchase-order/purchase-order-mutation.js.map +1 -1
- package/dist-server/service/purchase-order/purchase-order-query.js +0 -1
- package/dist-server/service/purchase-order/purchase-order-query.js.map +1 -1
- package/dist-server/service/release-good/release-good-mutation.js +49 -187
- package/dist-server/service/release-good/release-good-mutation.js.map +1 -1
- package/dist-server/service/release-good/release-good-query.js +6 -4
- package/dist-server/service/release-good/release-good-query.js.map +1 -1
- package/dist-server/service/release-good/release-good-types.js +4 -8
- package/dist-server/service/release-good/release-good-types.js.map +1 -1
- package/dist-server/service/release-good/release-good.js +0 -5
- package/dist-server/service/release-good/release-good.js.map +1 -1
- package/dist-server/service/reverse-kitting-order-inventory/reverse-kitting-order-inventory.js +3 -8
- package/dist-server/service/reverse-kitting-order-inventory/reverse-kitting-order-inventory.js.map +1 -1
- package/dist-server/utils/inventory-util.js +102 -33
- package/dist-server/utils/inventory-util.js.map +1 -1
- package/package.json +13 -13
- package/server/service/arrival-notice/arrival-notice.ts +0 -4
- package/server/service/draft-release-good/draft-release-good-mutation.ts +12 -10
- package/server/service/draft-release-good/draft-release-good-query.ts +5 -5
- package/server/service/draft-release-good/draft-release-good.ts +0 -4
- package/server/service/invoice-product/invoice-product.ts +1 -5
- package/server/service/order-inventory/order-inventory-types.ts +0 -6
- package/server/service/order-inventory/order-inventory.ts +1 -5
- package/server/service/order-product/order-product-query.ts +0 -1
- package/server/service/order-product/order-product-types.ts +0 -3
- package/server/service/order-vas/order-vas.ts +1 -6
- package/server/service/others/other-query.ts +43 -34
- package/server/service/others/other-types.ts +0 -3
- package/server/service/purchase-order/purchase-order-mutation.ts +1 -10
- package/server/service/purchase-order/purchase-order-query.ts +0 -1
- package/server/service/release-good/release-good-mutation.ts +50 -221
- package/server/service/release-good/release-good-query.ts +7 -4
- package/server/service/release-good/release-good-types.ts +3 -4
- package/server/service/release-good/release-good.ts +6 -8
- package/server/service/reverse-kitting-order-inventory/reverse-kitting-order-inventory.ts +1 -5
- package/server/utils/inventory-util.ts +147 -67
|
@@ -195,7 +195,6 @@ export class DraftReleaseGoodMutation {
|
|
|
195
195
|
relations: [
|
|
196
196
|
'orderProducts',
|
|
197
197
|
'orderProducts.product',
|
|
198
|
-
'orderProducts.productDetail',
|
|
199
198
|
'orderProducts.productBundle',
|
|
200
199
|
'shippingOrder',
|
|
201
200
|
'bizplace',
|
|
@@ -263,14 +262,13 @@ export class DraftReleaseGoodMutation {
|
|
|
263
262
|
draftOrder.orderProducts = draftOrder.orderProducts.map(itm => {
|
|
264
263
|
let foundProductInv = productInventory.items.find(
|
|
265
264
|
i =>
|
|
266
|
-
(i.
|
|
265
|
+
(i.productId == itm?.product?.id || i.productId == itm?.productBundle?.id) &&
|
|
266
|
+
i.packingType == itm.packingType &&
|
|
267
|
+
i.packingSize == itm.packingSize &&
|
|
268
|
+
i.uom == itm.uom &&
|
|
267
269
|
itm.releaseQty <= i.remainQty
|
|
268
270
|
)
|
|
269
|
-
return {
|
|
270
|
-
...itm,
|
|
271
|
-
releaseUomValue: (foundProductInv.remainUomValue / foundProductInv.remainQty) * itm.releaseQty,
|
|
272
|
-
status: foundProductInv ? 'suffice' : 'insufficient'
|
|
273
|
-
}
|
|
271
|
+
return { ...itm, releaseUomValue: (foundProductInv.remainUomValue / foundProductInv.remainQty) * itm.releaseQty, status: foundProductInv ? 'suffice' : 'insufficient' }
|
|
274
272
|
})
|
|
275
273
|
|
|
276
274
|
let insufficient = draftOrder.orderProducts.find(op => op.status == 'insufficient')
|
|
@@ -279,6 +277,10 @@ export class DraftReleaseGoodMutation {
|
|
|
279
277
|
let releaseGood = { ...draftOrder }
|
|
280
278
|
delete releaseGood.id
|
|
281
279
|
delete releaseGood.name
|
|
280
|
+
delete releaseGood.createdAt
|
|
281
|
+
delete releaseGood.createdBy
|
|
282
|
+
delete releaseGood.updatedAt
|
|
283
|
+
delete releaseGood.updatedBy
|
|
282
284
|
|
|
283
285
|
let orderInventories = []
|
|
284
286
|
|
|
@@ -495,6 +497,7 @@ export async function createDraftReleaseGoodFunction(
|
|
|
495
497
|
updater: user
|
|
496
498
|
})
|
|
497
499
|
|
|
500
|
+
|
|
498
501
|
// // 3. Create draft release good product
|
|
499
502
|
await upsertDraftReleaseGoodProducts(
|
|
500
503
|
domain,
|
|
@@ -629,7 +632,6 @@ export async function upsertDraftReleaseGoodProducts(
|
|
|
629
632
|
relations: [
|
|
630
633
|
'orderProducts',
|
|
631
634
|
'orderProducts.product',
|
|
632
|
-
'orderProducts.productDetail',
|
|
633
635
|
'orderProducts.productBundle',
|
|
634
636
|
'orderProducts.creator',
|
|
635
637
|
'orderProducts.updater'
|
|
@@ -731,8 +733,8 @@ export async function upsertDraftReleaseGoodProducts(
|
|
|
731
733
|
updatePatch['packingType'] = op?.packingType
|
|
732
734
|
? op.packingType
|
|
733
735
|
: product?.packingType
|
|
734
|
-
|
|
735
|
-
|
|
736
|
+
? product.packingType
|
|
737
|
+
: productBundle.packingType
|
|
736
738
|
updatePatch['uom'] = op?.uom ? op.uom : product?.primaryUnit ? product.primaryUnit : 'UNIT'
|
|
737
739
|
updatePatch['uomValue'] = op?.uomValue ? op.uomValue : product?.primaryValue ? product.primaryValue : 0
|
|
738
740
|
|
|
@@ -255,7 +255,6 @@ export async function getDraftReleaseGoodFunction(_: any, name: any, context: an
|
|
|
255
255
|
'releaseGood',
|
|
256
256
|
'orderProducts',
|
|
257
257
|
'orderProducts.product',
|
|
258
|
-
'orderProducts.productDetail',
|
|
259
258
|
'orderProducts.productBundle',
|
|
260
259
|
'shippingOrder',
|
|
261
260
|
'bizplace',
|
|
@@ -317,7 +316,11 @@ export async function getDraftReleaseGoodFunction(_: any, name: any, context: an
|
|
|
317
316
|
|
|
318
317
|
result.orderProducts = result.orderProducts.map(itm => {
|
|
319
318
|
let foundProductInv = productInventory?.items.find(
|
|
320
|
-
i =>
|
|
319
|
+
i =>
|
|
320
|
+
(i.productId == itm?.product?.id || i.productId == itm?.productBundle?.id) &&
|
|
321
|
+
i.packingType == itm.packingType &&
|
|
322
|
+
i.packingSize == itm.packingSize &&
|
|
323
|
+
i.uom == itm.uom
|
|
321
324
|
)
|
|
322
325
|
return {
|
|
323
326
|
...itm,
|
|
@@ -327,9 +330,6 @@ export async function getDraftReleaseGoodFunction(_: any, name: any, context: an
|
|
|
327
330
|
brand: foundProductInv.productBrand,
|
|
328
331
|
sku: foundProductInv.productSKU
|
|
329
332
|
},
|
|
330
|
-
productDetail: itm.productDetail || {
|
|
331
|
-
id: foundProductInv.productDetailId
|
|
332
|
-
},
|
|
333
333
|
groupType: foundProductInv ? foundProductInv.groupType : 'SINGLE',
|
|
334
334
|
remainQty: foundProductInv ? foundProductInv.remainQty : 0,
|
|
335
335
|
remainUomValue: foundProductInv ? foundProductInv.remainUomValue : 0,
|
|
@@ -237,10 +237,6 @@ export class DraftReleaseGood {
|
|
|
237
237
|
@Field({ nullable: true })
|
|
238
238
|
packageId: string
|
|
239
239
|
|
|
240
|
-
@Column({ nullable: true })
|
|
241
|
-
@Field({ nullable: true })
|
|
242
|
-
source: string
|
|
243
|
-
|
|
244
240
|
@ManyToOne(type => ContactPoint)
|
|
245
241
|
@Field(type => ContactPoint, { nullable: true })
|
|
246
242
|
deliverTo: ContactPoint
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
} from 'typeorm'
|
|
12
12
|
|
|
13
13
|
import { User } from '@things-factory/auth-base'
|
|
14
|
-
import { Product
|
|
14
|
+
import { Product } from '@things-factory/product-base'
|
|
15
15
|
import { Domain } from '@things-factory/shell'
|
|
16
16
|
|
|
17
17
|
import { Invoice } from '../invoice/invoice'
|
|
@@ -77,10 +77,6 @@ export class InvoiceProduct {
|
|
|
77
77
|
@Field({ nullable: true })
|
|
78
78
|
shippingFeePaidByCustomer: number
|
|
79
79
|
|
|
80
|
-
@ManyToOne(type => ProductDetail, { nullable: true })
|
|
81
|
-
@Field({ nullable: true })
|
|
82
|
-
productDetail: ProductDetail
|
|
83
|
-
|
|
84
80
|
@CreateDateColumn()
|
|
85
81
|
@Field()
|
|
86
82
|
createdAt: Date
|
|
@@ -41,9 +41,6 @@ export class NewOrderInventory {
|
|
|
41
41
|
@Field(type => NewProduct, { nullable: true })
|
|
42
42
|
product: NewProduct
|
|
43
43
|
|
|
44
|
-
@Field(type => ObjectRef, { nullable: true })
|
|
45
|
-
productDetail: ObjectRef
|
|
46
|
-
|
|
47
44
|
@Field({ nullable: true })
|
|
48
45
|
productSKU: string
|
|
49
46
|
|
|
@@ -203,9 +200,6 @@ export class OrderInventoryPatch {
|
|
|
203
200
|
@Field({ nullable: true })
|
|
204
201
|
productId: string
|
|
205
202
|
|
|
206
|
-
@Field({ nullable: true })
|
|
207
|
-
productDetailId: string
|
|
208
|
-
|
|
209
203
|
@Field({ nullable: true })
|
|
210
204
|
orderProductId: string
|
|
211
205
|
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
|
|
14
14
|
import { User } from '@things-factory/auth-base'
|
|
15
15
|
import { Bizplace } from '@things-factory/biz-base'
|
|
16
|
-
import { Product
|
|
16
|
+
import { Product } from '@things-factory/product-base'
|
|
17
17
|
import { Domain } from '@things-factory/shell'
|
|
18
18
|
import { Inventory, Location } from '@things-factory/warehouse-base'
|
|
19
19
|
|
|
@@ -341,10 +341,6 @@ export class OrderInventory {
|
|
|
341
341
|
@Field({ nullable: true })
|
|
342
342
|
loadedAt: Date
|
|
343
343
|
|
|
344
|
-
@ManyToOne(type => ProductDetail, { nullable: true })
|
|
345
|
-
@Field({ nullable: true })
|
|
346
|
-
productDetail: ProductDetail
|
|
347
|
-
|
|
348
344
|
@Field({ nullable: true })
|
|
349
345
|
dispatchedAt: Date
|
|
350
346
|
|
|
@@ -26,7 +26,6 @@ export class OrderProductQuery {
|
|
|
26
26
|
|
|
27
27
|
let qb: SelectQueryBuilder<OrderProduct> = await getRepository(OrderProduct).createQueryBuilder('op')
|
|
28
28
|
qb.leftJoinAndSelect('op.product', 'product')
|
|
29
|
-
.leftJoinAndSelect('op.productDetail', 'productDetail')
|
|
30
29
|
.leftJoinAndSelect('op.domain', 'domain')
|
|
31
30
|
.leftJoinAndSelect('op.bizplace', 'bizplace')
|
|
32
31
|
.leftJoinAndSelect('bizplace.company', 'company')
|
|
@@ -84,9 +84,6 @@ export class OrderProductPatch {
|
|
|
84
84
|
@Field(type => ObjectRef, { nullable: true })
|
|
85
85
|
toInventory: ObjectRef
|
|
86
86
|
|
|
87
|
-
@Field(type => ObjectRef, { nullable: true })
|
|
88
|
-
productDetail: ObjectRef
|
|
89
|
-
|
|
90
87
|
@Field(type => InboundProduct, { nullable: true })
|
|
91
88
|
product: InboundProduct
|
|
92
89
|
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
|
|
13
13
|
import { User } from '@things-factory/auth-base'
|
|
14
14
|
import { Bizplace } from '@things-factory/biz-base'
|
|
15
|
-
import { Product
|
|
15
|
+
import { Product } from '@things-factory/product-base'
|
|
16
16
|
import { Domain } from '@things-factory/shell'
|
|
17
17
|
import { Inventory } from '@things-factory/warehouse-base'
|
|
18
18
|
|
|
@@ -200,10 +200,6 @@ export class OrderVas {
|
|
|
200
200
|
@Field()
|
|
201
201
|
updatedAt: Date
|
|
202
202
|
|
|
203
|
-
@ManyToOne(type => ProductDetail, { nullable: true })
|
|
204
|
-
@Field({ nullable: true })
|
|
205
|
-
productDetail: ProductDetail
|
|
206
|
-
|
|
207
203
|
@ManyToOne(type => User)
|
|
208
204
|
@Field(type => User, { nullable: true })
|
|
209
205
|
creator: User
|
|
@@ -217,5 +213,4 @@ export class OrderVas {
|
|
|
217
213
|
|
|
218
214
|
@RelationId((orderVas: OrderVas) => orderVas.updater)
|
|
219
215
|
updaterId: string
|
|
220
|
-
|
|
221
216
|
}
|
|
@@ -195,49 +195,59 @@ export class OtherQuery {
|
|
|
195
195
|
|
|
196
196
|
const { items, total } = await InventoryUtil.bizplaceInventoryProductGroup(bizplaces, params, context, tx)
|
|
197
197
|
|
|
198
|
-
|
|
198
|
+
// Filter to find for item with enough remain qty
|
|
199
|
+
const availableItems = items.filter(item => item.remainQty >= orderInventory.releaseQty)
|
|
200
|
+
let availableItem
|
|
199
201
|
|
|
202
|
+
if (availableItems.length > 0) {
|
|
203
|
+
availableItem = availableItems[0]
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
let packageUomValue = availableItem ? availableItem.remainUomValue / availableItem.remainQty : null
|
|
200
207
|
const newOrderInventory: any = {
|
|
201
|
-
product:
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
208
|
+
product: availableItem
|
|
209
|
+
? {
|
|
210
|
+
id: availableItem.productId,
|
|
211
|
+
sku: availableItem.productSKU,
|
|
212
|
+
name: availableItem.productName
|
|
213
|
+
}
|
|
214
|
+
: { id: null },
|
|
215
|
+
inventory: availableItem
|
|
216
|
+
? {
|
|
217
|
+
...availableItem,
|
|
218
|
+
remainQty: availableItem ? availableItem.remainQty : null,
|
|
219
|
+
remainUomValue: availableItem ? availableItem.remainUomValue : null,
|
|
220
|
+
remainUomValueWithUom: availableItem ? availableItem.remainUomValueWithUom : ''
|
|
221
|
+
}
|
|
222
|
+
: null,
|
|
223
|
+
productId: availableItem ? availableItem.productId : null,
|
|
224
|
+
productSKU: availableItem ? availableItem.productSKU : orderInventory.productSKU,
|
|
225
|
+
productName: availableItem ? availableItem.productName : null,
|
|
226
|
+
uom: availableItem ? availableItem.uom : null,
|
|
227
|
+
remainQty: availableItem ? availableItem.remainQty : null,
|
|
228
|
+
remainUomValue: availableItem ? availableItem.remainUomValue : null,
|
|
229
|
+
remainUomValueWithUom: availableItem ? availableItem.remainUomValueWithUom : '',
|
|
230
|
+
batchId: availableItem ? availableItem.batchId : null,
|
|
231
|
+
batchIdRef: availableItem ? availableItem.batchIdRef : null,
|
|
232
|
+
packingType: availableItem ? availableItem.packingType : orderInventory.packingType,
|
|
233
|
+
packingSize: availableItem ? availableItem.packingSize : 1,
|
|
225
234
|
releaseQty: orderInventory.releaseQty
|
|
226
235
|
? Number.isInteger(orderInventory.releaseQty)
|
|
227
236
|
? orderInventory.releaseQty
|
|
228
237
|
: null
|
|
229
238
|
: null,
|
|
230
|
-
releaseUomValue:
|
|
231
|
-
|
|
232
|
-
?
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
isError: total <= 0 ? true : false
|
|
239
|
+
releaseUomValue: availableItem
|
|
240
|
+
? Number.isInteger(orderInventory.releaseQty)
|
|
241
|
+
? parseFloat((orderInventory.releaseQty * packageUomValue).toFixed(2))
|
|
242
|
+
: null
|
|
243
|
+
: null,
|
|
244
|
+
groupType: availableItem ? availableItem.groupType : null,
|
|
245
|
+
isError: !availableItem ? true : false
|
|
238
246
|
}
|
|
239
247
|
|
|
240
248
|
newOrderInventories.push(newOrderInventory)
|
|
249
|
+
|
|
250
|
+
// end loop
|
|
241
251
|
}
|
|
242
252
|
|
|
243
253
|
try {
|
|
@@ -518,7 +528,6 @@ export class OtherQuery {
|
|
|
518
528
|
primaryUnit: productDetail?.uom ? productDetail.uom : null,
|
|
519
529
|
primaryValue: productDetail?.uomValue ? productDetail.uomValue : null
|
|
520
530
|
},
|
|
521
|
-
productDetail,
|
|
522
531
|
totalUomValue:
|
|
523
532
|
orderProduct.packQty > 0
|
|
524
533
|
? uomValue
|
|
@@ -69,14 +69,7 @@ export class PurchaseOrderMutation {
|
|
|
69
69
|
|
|
70
70
|
const findPurchaseOrder: PurchaseOrder = await getRepository(PurchaseOrder).findOne({
|
|
71
71
|
where: { domain, id },
|
|
72
|
-
relations: [
|
|
73
|
-
'orderProducts',
|
|
74
|
-
'orderProducts.product',
|
|
75
|
-
'orderProducts.productDetail',
|
|
76
|
-
'bufferLocation',
|
|
77
|
-
'bizplace',
|
|
78
|
-
'domain'
|
|
79
|
-
]
|
|
72
|
+
relations: ['orderProducts', 'orderProducts.product', 'bufferLocation', 'bizplace', 'domain']
|
|
80
73
|
})
|
|
81
74
|
|
|
82
75
|
// const findPurchaseOrder: PurchaseOrder = await tx.getRepository(PurchaseOrder).findOne({id}, { relations:['bizplace']})
|
|
@@ -425,7 +418,6 @@ export async function upsertPurchaseOrderProducts(
|
|
|
425
418
|
const bizplaceRepo: Repository<Product> = tx?.getRepository(Bizplace) || getRepository(Bizplace)
|
|
426
419
|
const orderProductRepo: Repository<OrderProduct> = tx?.getRepository(OrderProduct) || getRepository(OrderProduct)
|
|
427
420
|
const productRepo: Repository<Product> = tx?.getRepository(Product) || getRepository(Product)
|
|
428
|
-
const productDetailRepo: Repository<Product> = tx?.getRepository(ProductDetail) || getRepository(ProductDetail)
|
|
429
421
|
|
|
430
422
|
// // Remove all existing order products that do not exist in current input
|
|
431
423
|
let removeOP = purchaseOrder.orderProducts.filter(
|
|
@@ -451,7 +443,6 @@ export async function upsertPurchaseOrderProducts(
|
|
|
451
443
|
bizplace: bizplace,
|
|
452
444
|
name: op?.id ? op.name : OrderNoGenerator.orderProduct(),
|
|
453
445
|
product: await productRepo.findOne(op.product.id),
|
|
454
|
-
productDetail: await productDetailRepo.findOne(op.productDetail.id),
|
|
455
446
|
packingSize: foundProductDetail?.packingSize || 1,
|
|
456
447
|
purchaseOrder: purchaseOrder,
|
|
457
448
|
status: purchaseOrder.status,
|