@things-factory/sales-base 4.3.79-alpha.0 → 4.3.80-alpha.0

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.
Files changed (63) hide show
  1. package/dist-server/service/arrival-notice/arrival-notice-mutation.js +6 -5
  2. package/dist-server/service/arrival-notice/arrival-notice-mutation.js.map +1 -1
  3. package/dist-server/service/draft-release-good/draft-release-good-mutation.js +3 -4
  4. package/dist-server/service/draft-release-good/draft-release-good-mutation.js.map +1 -1
  5. package/dist-server/service/draft-release-good/draft-release-good-query.js +4 -7
  6. package/dist-server/service/draft-release-good/draft-release-good-query.js.map +1 -1
  7. package/dist-server/service/invoice-product/invoice-product.js +8 -3
  8. package/dist-server/service/invoice-product/invoice-product.js.map +1 -1
  9. package/dist-server/service/order-inventory/order-inventory-query.js +2 -1
  10. package/dist-server/service/order-inventory/order-inventory-query.js.map +1 -1
  11. package/dist-server/service/order-inventory/order-inventory-types.js +18 -10
  12. package/dist-server/service/order-inventory/order-inventory-types.js.map +1 -1
  13. package/dist-server/service/order-inventory/order-inventory.js +12 -3
  14. package/dist-server/service/order-inventory/order-inventory.js.map +1 -1
  15. package/dist-server/service/order-product/order-product-query.js +1 -0
  16. package/dist-server/service/order-product/order-product-query.js.map +1 -1
  17. package/dist-server/service/order-product/order-product-types.js +18 -10
  18. package/dist-server/service/order-product/order-product-types.js.map +1 -1
  19. package/dist-server/service/order-vas/order-vas.js +8 -3
  20. package/dist-server/service/order-vas/order-vas.js.map +1 -1
  21. package/dist-server/service/others/other-query.js +3 -1
  22. package/dist-server/service/others/other-query.js.map +1 -1
  23. package/dist-server/service/others/other-types.js +4 -0
  24. package/dist-server/service/others/other-types.js.map +1 -1
  25. package/dist-server/service/purchase-order/purchase-order-mutation.js +10 -2
  26. package/dist-server/service/purchase-order/purchase-order-mutation.js.map +1 -1
  27. package/dist-server/service/purchase-order/purchase-order-query.js +1 -0
  28. package/dist-server/service/purchase-order/purchase-order-query.js.map +1 -1
  29. package/dist-server/service/release-good/release-good-mutation.js +18 -8
  30. package/dist-server/service/release-good/release-good-mutation.js.map +1 -1
  31. package/dist-server/service/release-good/release-good-query.js +4 -6
  32. package/dist-server/service/release-good/release-good-query.js.map +1 -1
  33. package/dist-server/service/release-good/release-good-types.js +8 -4
  34. package/dist-server/service/release-good/release-good-types.js.map +1 -1
  35. package/dist-server/service/return-order/return-order-mutation.js +2 -0
  36. package/dist-server/service/return-order/return-order-mutation.js.map +1 -1
  37. package/dist-server/service/return-order/return-order-types.js.map +1 -1
  38. package/dist-server/service/reverse-kitting-order-inventory/reverse-kitting-order-inventory.js +8 -3
  39. package/dist-server/service/reverse-kitting-order-inventory/reverse-kitting-order-inventory.js.map +1 -1
  40. package/dist-server/utils/inventory-util.js +33 -102
  41. package/dist-server/utils/inventory-util.js.map +1 -1
  42. package/package.json +4 -4
  43. package/server/service/arrival-notice/arrival-notice-mutation.ts +6 -3
  44. package/server/service/draft-release-good/draft-release-good-mutation.ts +3 -4
  45. package/server/service/draft-release-good/draft-release-good-query.ts +5 -5
  46. package/server/service/invoice-product/invoice-product.ts +5 -1
  47. package/server/service/order-inventory/order-inventory-query.ts +2 -0
  48. package/server/service/order-inventory/order-inventory-types.ts +6 -0
  49. package/server/service/order-inventory/order-inventory.ts +8 -1
  50. package/server/service/order-product/order-product-query.ts +1 -0
  51. package/server/service/order-product/order-product-types.ts +6 -0
  52. package/server/service/order-vas/order-vas.ts +6 -1
  53. package/server/service/others/other-query.ts +6 -3
  54. package/server/service/others/other-types.ts +3 -0
  55. package/server/service/purchase-order/purchase-order-mutation.ts +10 -1
  56. package/server/service/purchase-order/purchase-order-query.ts +1 -0
  57. package/server/service/release-good/release-good-mutation.ts +21 -8
  58. package/server/service/release-good/release-good-query.ts +4 -7
  59. package/server/service/release-good/release-good-types.ts +4 -3
  60. package/server/service/return-order/return-order-mutation.ts +3 -1
  61. package/server/service/return-order/return-order-types.ts +1 -0
  62. package/server/service/reverse-kitting-order-inventory/reverse-kitting-order-inventory.ts +5 -1
  63. package/server/utils/inventory-util.ts +67 -147
@@ -84,6 +84,9 @@ 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
+
87
90
  @Field(type => InboundProduct, { nullable: true })
88
91
  product: InboundProduct
89
92
 
@@ -225,6 +228,9 @@ export class NewOrderProduct {
225
228
  @Field(type => ObjectRef, { nullable: true })
226
229
  toInventory: ObjectRef
227
230
 
231
+ @Field(type => ObjectRef, { nullable: true })
232
+ productDetail: ObjectRef
233
+
228
234
  @Field(type => InboundProduct, { nullable: true })
229
235
  product: InboundProduct
230
236
 
@@ -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 } from '@things-factory/product-base'
15
+ import { Product, ProductDetail } 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,6 +200,10 @@ 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
+
203
207
  @ManyToOne(type => User)
204
208
  @Field(type => User, { nullable: true })
205
209
  creator: User
@@ -213,4 +217,5 @@ export class OrderVas {
213
217
 
214
218
  @RelationId((orderVas: OrderVas) => orderVas.updater)
215
219
  updaterId: string
220
+
216
221
  }
@@ -200,6 +200,7 @@ export class OtherQuery {
200
200
  const newOrderInventory: any = {
201
201
  product:
202
202
  total > 0 ? { id: items[0].productId, sku: items[0].productSKU, name: items[0].productName } : { id: null },
203
+ productDetail: total > 0 ? { id: items[0].productDetailId } : { id: null },
203
204
  inventory:
204
205
  total > 0
205
206
  ? {
@@ -210,6 +211,7 @@ export class OtherQuery {
210
211
  }
211
212
  : null,
212
213
  productId: total > 0 ? items[0].productId : null,
214
+ productDetailID: total > 0 ? items[0].productDetailId : null,
213
215
  productSKU: total > 0 ? items[0].productSKU : orderInventory.productSKU,
214
216
  productName: total > 0 ? items[0].productName : null,
215
217
  uom: total > 0 ? items[0].uom : null,
@@ -472,7 +474,7 @@ export class OtherQuery {
472
474
  let productDetail: ProductDetail
473
475
  const hasConditions: boolean = Boolean(
474
476
  (orderProduct?.packingType && orderProduct?.packingType.trim() != '') ||
475
- (orderProduct?.uom && orderProduct?.uom.trim() != '')
477
+ (orderProduct?.uom && orderProduct?.uom.trim() != '')
476
478
  )
477
479
  let productDetailCondition: any = { product: foundProduct }
478
480
 
@@ -495,8 +497,8 @@ export class OtherQuery {
495
497
  ? productDetail.uomValue
496
498
  : null
497
499
  : orderProduct?.uomValue
498
- ? orderProduct.uomValue
499
- : productDetail.uomValue
500
+ ? orderProduct.uomValue
501
+ : productDetail.uomValue
500
502
 
501
503
  newOrderProduct = {
502
504
  ...orderProduct,
@@ -516,6 +518,7 @@ export class OtherQuery {
516
518
  primaryUnit: productDetail?.uom ? productDetail.uom : null,
517
519
  primaryValue: productDetail?.uomValue ? productDetail.uomValue : null
518
520
  },
521
+ productDetail,
519
522
  totalUomValue:
520
523
  orderProduct.packQty > 0
521
524
  ? uomValue
@@ -19,6 +19,9 @@ export class InventoryProductGroup {
19
19
  @Field({ nullable: true })
20
20
  productId: string
21
21
 
22
+ @Field({ nullable: true })
23
+ productDetailId: string
24
+
22
25
  @Field({ nullable: true })
23
26
  batchId: string
24
27
 
@@ -69,7 +69,14 @@ export class PurchaseOrderMutation {
69
69
 
70
70
  const findPurchaseOrder: PurchaseOrder = await getRepository(PurchaseOrder).findOne({
71
71
  where: { domain, id },
72
- relations: ['orderProducts', 'orderProducts.product', 'bufferLocation', 'bizplace', 'domain']
72
+ relations: [
73
+ 'orderProducts',
74
+ 'orderProducts.product',
75
+ 'orderProducts.productDetail',
76
+ 'bufferLocation',
77
+ 'bizplace',
78
+ 'domain'
79
+ ]
73
80
  })
74
81
 
75
82
  // const findPurchaseOrder: PurchaseOrder = await tx.getRepository(PurchaseOrder).findOne({id}, { relations:['bizplace']})
@@ -418,6 +425,7 @@ export async function upsertPurchaseOrderProducts(
418
425
  const bizplaceRepo: Repository<Product> = tx?.getRepository(Bizplace) || getRepository(Bizplace)
419
426
  const orderProductRepo: Repository<OrderProduct> = tx?.getRepository(OrderProduct) || getRepository(OrderProduct)
420
427
  const productRepo: Repository<Product> = tx?.getRepository(Product) || getRepository(Product)
428
+ const productDetailRepo: Repository<Product> = tx?.getRepository(ProductDetail) || getRepository(ProductDetail)
421
429
 
422
430
  // // Remove all existing order products that do not exist in current input
423
431
  let removeOP = purchaseOrder.orderProducts.filter(
@@ -443,6 +451,7 @@ export async function upsertPurchaseOrderProducts(
443
451
  bizplace: bizplace,
444
452
  name: op?.id ? op.name : OrderNoGenerator.orderProduct(),
445
453
  product: await productRepo.findOne(op.product.id),
454
+ productDetail: await productDetailRepo.findOne(op.productDetail.id),
446
455
  packingSize: foundProductDetail?.packingSize || 1,
447
456
  purchaseOrder: purchaseOrder,
448
457
  status: purchaseOrder.status,
@@ -62,6 +62,7 @@ export async function getPurchaseOrderFunction(_: any, name: any, context: any,
62
62
  'supplier',
63
63
  'orderProducts',
64
64
  'orderProducts.product',
65
+ 'orderProducts.productDetail',
65
66
  'otherCharges',
66
67
  'bufferLocation',
67
68
  'bizplace',
@@ -16,7 +16,7 @@ import { MarketplaceStore } from '@things-factory/integration-marketplace'
16
16
  import { Sellercraft, SellercraftStatus } from '@things-factory/integration-sellercraft'
17
17
  import { MarketplaceOrder, MarketplaceProductVariation } from '@things-factory/marketplace-base'
18
18
  // import { sendNotification } from '@things-factory/notification'
19
- import { Product, ProductBundleSetting } from '@things-factory/product-base'
19
+ import { Product, ProductBundleSetting, ProductDetail } from '@things-factory/product-base'
20
20
  import { PartnerSetting, Setting } from '@things-factory/setting-base'
21
21
  import { Domain } from '@things-factory/shell'
22
22
  import { Inventory } from '@things-factory/warehouse-base'
@@ -722,7 +722,7 @@ export async function generateReleaseGoodFunction(
722
722
 
723
723
  const pbSettings: ProductBundleSetting[] = await tx.getRepository(ProductBundleSetting).find({
724
724
  where: { productBundle: oi.product.id },
725
- relations: ['product', 'productBundle']
725
+ relations: ['product', 'productBundle', 'productDetail']
726
726
  })
727
727
 
728
728
  pbSettings.forEach(pbs => {
@@ -736,6 +736,9 @@ export async function generateReleaseGoodFunction(
736
736
  id: pbs.product.id,
737
737
  name: pbs.product.name,
738
738
  groupType: PRODUCT_GROUP_TYPE.SINGLE
739
+ },
740
+ productDetail: {
741
+ id: pbs.productDetail.id
739
742
  }
740
743
  }
741
744
  splitBundleOIs.push(splitOI)
@@ -750,6 +753,10 @@ export async function generateReleaseGoodFunction(
750
753
  newReleaseGood = await tx.getRepository(ReleaseGood).save(newReleaseGood)
751
754
 
752
755
  for (let oi of orderInventories) {
756
+ let productDetail: any = await tx
757
+ .getRepository(ProductDetail)
758
+ .findOne(oi.productDetail.id, { relations: ['product'] })
759
+
753
760
  let newOrderInv: OrderInventory = Object.assign({}, oi)
754
761
  newOrderInv = {
755
762
  ...newOrderInv,
@@ -758,7 +765,8 @@ export async function generateReleaseGoodFunction(
758
765
  status: ORDER_INVENTORY_STATUS.PENDING,
759
766
  name: OrderNoGenerator.orderInventory(),
760
767
  releaseGood: newReleaseGood,
761
- product: await tx.getRepository(Product).findOne(oi.product.id),
768
+ product: productDetail.product,
769
+ productDetail,
762
770
  creator: user,
763
771
  updater: user
764
772
  }
@@ -796,9 +804,9 @@ export async function generateReleaseGoodFunction(
796
804
  }
797
805
 
798
806
  let assignedOrderInventories: OrderInventory[] = await InventoryUtil.autoAssignInventoryForRelease(
799
- newOrderInv.product,
800
807
  oi,
801
- oi.packingType,
808
+ productDetail.product,
809
+ productDetail,
802
810
  locationSortingRules,
803
811
  bizplace,
804
812
  warehouseDomain,
@@ -1497,12 +1505,17 @@ export async function bulkGenerateReleaseGood(
1497
1505
  }
1498
1506
  }
1499
1507
 
1500
- const product: Product = await tx.getRepository(Product).findOne(oi.productId)
1508
+ let productDetail = oi.orderProduct?.productDetail
1509
+ let product = oi.orderProduct?.product
1510
+ if (!productDetail) {
1511
+ productDetail = await tx.getRepository(ProductDetail).findOne(oi.productDetailId, { relations: ['product'] })
1512
+ product = productDetail.product
1513
+ }
1501
1514
 
1502
1515
  let assignedResult = await InventoryUtil.autoAssignInventoryForRelease(
1503
- product,
1504
1516
  oi,
1505
- oi.packingType,
1517
+ product,
1518
+ productDetail,
1506
1519
  locationSortingRules,
1507
1520
  bizplace,
1508
1521
  warehouseDomain,
@@ -196,6 +196,7 @@ export class ReleaseGoodQuery {
196
196
  .createQueryBuilder('oi')
197
197
  .leftJoinAndSelect('oi.inventory', 'inventory')
198
198
  .leftJoinAndSelect('oi.product', 'product')
199
+ .leftJoinAndSelect('oi.productDetail', 'productDetail')
199
200
  .leftJoinAndSelect('inventory.location', 'location')
200
201
  .where('oi.domain_id = :domainId', { domainId: domain.id })
201
202
  .andWhere('oi.release_good_id = :releaseGoodId', { releaseGoodId: releaseGood.id })
@@ -226,6 +227,7 @@ export class ReleaseGoodQuery {
226
227
  batchIdRef: inventory.batchIdRef,
227
228
  palletId: inventory.palletId,
228
229
  product: orderInv.product,
230
+ productDetail: orderInv.productDetail,
229
231
  productIdRef: orderInv.product.id,
230
232
  productName: `${orderInv.product.name} (${orderInv.product.description})`,
231
233
  packingType: orderInv.packingType,
@@ -375,10 +377,7 @@ export class ReleaseGoodQuery {
375
377
  params.filters.push({
376
378
  name: typeFilter == 'b2c' ? 'releaseDate' : 'createdAt',
377
379
  operator: 'gte',
378
- value:
379
- typeFilter == 'b2c'
380
- ? releaseDateFrom
381
- : fromDateVal.toISOString(),
380
+ value: typeFilter == 'b2c' ? releaseDateFrom : fromDateVal.toISOString(),
382
381
  relation: false
383
382
  })
384
383
  }
@@ -393,9 +392,7 @@ export class ReleaseGoodQuery {
393
392
  name: typeFilter == 'b2c' ? 'releaseDate' : 'createdAt',
394
393
  operator: typeFilter == 'b2c' ? 'lte' : 'lt',
395
394
  value:
396
- typeFilter == 'b2c'
397
- ? releaseDateTo
398
- : new Date(toDateVal.setDate(toDateVal.getDate() + 1)).toISOString(),
395
+ typeFilter == 'b2c' ? releaseDateTo : new Date(toDateVal.setDate(toDateVal.getDate() + 1)).toISOString(),
399
396
  relation: false
400
397
  })
401
398
  }
@@ -1,6 +1,6 @@
1
1
  import { Field, Float, InputType, Int, ObjectType } from 'type-graphql'
2
2
 
3
- import { Product } from '@things-factory/product-base'
3
+ import { Product, ProductDetail } from '@things-factory/product-base'
4
4
  import { ObjectRef } from '@things-factory/shell'
5
5
  import { Location } from '@things-factory/warehouse-base'
6
6
 
@@ -77,6 +77,9 @@ export class InventoryInfos {
77
77
  @Field(type => Product, { nullable: true })
78
78
  product?: Product
79
79
 
80
+ @Field(type => ProductDetail, { nullable: true })
81
+ productDetail?: ProductDetail
82
+
80
83
  @Field({ nullable: true })
81
84
  packingType?: string
82
85
 
@@ -185,8 +188,6 @@ export class NewReleaseGood {
185
188
  @Field({ nullable: true })
186
189
  orderMethod: string
187
190
 
188
-
189
-
190
191
  @Field({ nullable: true })
191
192
  collectionOrderNo: string
192
193
 
@@ -6,7 +6,7 @@ import { Attachment, createAttachments } from '@things-factory/attachment-base'
6
6
  import { Role, User } from '@things-factory/auth-base'
7
7
  import { Bizplace, getDomainUsers } from '@things-factory/biz-base'
8
8
  import { sendNotification } from '@things-factory/notification'
9
- import { Product } from '@things-factory/product-base'
9
+ import { Product, ProductDetail } from '@things-factory/product-base'
10
10
  import { Domain } from '@things-factory/shell'
11
11
  import { Inventory } from '@things-factory/warehouse-base'
12
12
 
@@ -59,6 +59,7 @@ export class ReturnOrderMutation {
59
59
  itm =>
60
60
  itm.product.id === curr.product.id &&
61
61
  itm.packingType === curr.packingType &&
62
+ itm.productDetailId === curr.product.productDetailId &&
62
63
  itm.batchId === curr.batchId &&
63
64
  itm.packingSize === curr.packingSize
64
65
  )
@@ -99,6 +100,7 @@ export class ReturnOrderMutation {
99
100
  newOrderInv.name = OrderNoGenerator.orderInventory()
100
101
  newOrderInv.returnOrder = createdReturnOrder
101
102
  newOrderInv.product = await tx.getRepository(Product).findOne(moi.product.id)
103
+ newOrderInv.productDetail = await tx.getRepository(ProductDetail).findOne(moi.productDetail.id)
102
104
  newOrderInv.creator = user
103
105
  newOrderInv.updater = user
104
106
 
@@ -115,6 +115,7 @@ export class NewReturnOrder {
115
115
  @Field({ nullable: true })
116
116
  truckNo: string
117
117
 
118
+
118
119
  @Field({ nullable: true })
119
120
  deliveryOrderNo: string
120
121
 
@@ -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 } from '@things-factory/product-base'
15
+ import { Product, ProductDetail } from '@things-factory/product-base'
16
16
  import { Domain } from '@things-factory/shell'
17
17
  import { Inventory } from '@things-factory/warehouse-base'
18
18
 
@@ -127,6 +127,10 @@ export class ReverseKittingOrderInventory {
127
127
  @Field({ nullable: true })
128
128
  updatedAt?: Date
129
129
 
130
+ @ManyToOne(type => ProductDetail, { nullable: true })
131
+ @Field({ nullable: true })
132
+ productDetail: ProductDetail
133
+
130
134
  @ManyToOne(type => User, { nullable: true })
131
135
  @Field({ nullable: true })
132
136
  creator?: User