@things-factory/sales-base 4.0.30 → 4.0.31

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 (40) hide show
  1. package/dist-server/service/arrival-notice/arrival-notice-mutation.js +2 -2
  2. package/dist-server/service/arrival-notice/arrival-notice-mutation.js.map +1 -1
  3. package/dist-server/service/arrival-notice/arrival-notice-query.js +13 -11
  4. package/dist-server/service/arrival-notice/arrival-notice-query.js.map +1 -1
  5. package/dist-server/service/arrival-notice/arrival-notice-types.js +5 -1
  6. package/dist-server/service/arrival-notice/arrival-notice-types.js.map +1 -1
  7. package/dist-server/service/arrival-notice/arrival-notice.js +1 -1
  8. package/dist-server/service/arrival-notice/arrival-notice.js.map +1 -1
  9. package/dist-server/service/order-inventory/order-inventory.js +24 -0
  10. package/dist-server/service/order-inventory/order-inventory.js.map +1 -1
  11. package/dist-server/service/purchase-order/purchase-order-mutation.js +1 -1
  12. package/dist-server/service/purchase-order/purchase-order-mutation.js.map +1 -1
  13. package/dist-server/service/release-good/release-good-query.js +7 -4
  14. package/dist-server/service/release-good/release-good-query.js.map +1 -1
  15. package/dist-server/service/reverse-kitting-order/reverse-kitting-order-mutation.js +5 -4
  16. package/dist-server/service/reverse-kitting-order/reverse-kitting-order-mutation.js.map +1 -1
  17. package/dist-server/service/reverse-kitting-order/reverse-kitting-order-query.js +1 -2
  18. package/dist-server/service/reverse-kitting-order/reverse-kitting-order-query.js.map +1 -1
  19. package/dist-server/service/reverse-kitting-order/reverse-kitting-order-type.js +1 -1
  20. package/dist-server/service/reverse-kitting-order/reverse-kitting-order-type.js.map +1 -1
  21. package/dist-server/service/reverse-kitting-order/reverse-kitting-order.js +51 -4
  22. package/dist-server/service/reverse-kitting-order/reverse-kitting-order.js.map +1 -1
  23. package/dist-server/service/reverse-kitting-order-inventory/reverse-kitting-order-inventory-type.js +9 -1
  24. package/dist-server/service/reverse-kitting-order-inventory/reverse-kitting-order-inventory-type.js.map +1 -1
  25. package/dist-server/service/reverse-kitting-order-inventory/reverse-kitting-order-inventory.js +35 -3
  26. package/dist-server/service/reverse-kitting-order-inventory/reverse-kitting-order-inventory.js.map +1 -1
  27. package/package.json +12 -12
  28. package/server/service/arrival-notice/arrival-notice-mutation.ts +1 -1
  29. package/server/service/arrival-notice/arrival-notice-query.ts +12 -10
  30. package/server/service/arrival-notice/arrival-notice-types.ts +4 -1
  31. package/server/service/arrival-notice/arrival-notice.ts +1 -1
  32. package/server/service/order-inventory/order-inventory.ts +18 -0
  33. package/server/service/purchase-order/purchase-order-mutation.ts +1 -1
  34. package/server/service/release-good/release-good-query.ts +15 -13
  35. package/server/service/reverse-kitting-order/reverse-kitting-order-mutation.ts +2 -1
  36. package/server/service/reverse-kitting-order/reverse-kitting-order-query.ts +1 -2
  37. package/server/service/reverse-kitting-order/reverse-kitting-order-type.ts +2 -2
  38. package/server/service/reverse-kitting-order/reverse-kitting-order.ts +39 -3
  39. package/server/service/reverse-kitting-order-inventory/reverse-kitting-order-inventory-type.ts +7 -1
  40. package/server/service/reverse-kitting-order-inventory/reverse-kitting-order-inventory.ts +25 -0
@@ -455,7 +455,7 @@ export async function validateBulkArrivalNoticesFunction(
455
455
  WHEN tp.container_no NOTNULL AND tp.container_size ISNULL OR tp.container_no ISNULL AND tp.container_size NOTNULL THEN 'incomplete container information'
456
456
  WHEN tp.unit_price < 0 THEN 'invalid unit price'
457
457
  WHEN tp.pallet_qty < 0 THEN 'invalid pallet qty'
458
- ELSE '' END AS remark
458
+ ELSE '' END AS errorMsg
459
459
  FROM
460
460
  temp_order_products tp
461
461
  LEFT JOIN arrival_notices an ON tp.ref_no = an.ref_no
@@ -468,13 +468,15 @@ export async function validateBulkArrivalNoticesFunction(
468
468
  AND CASE WHEN tp.container_size NOTNULL THEN tp.container_size = an.container_size ELSE 1 = 1 END
469
469
  AND CASE WHEN tp.loose_item NOTNULL THEN tp.loose_item = an.loose_item ELSE 1 = 1 END
470
470
  AND CASE WHEN tp.import_cargo NOTNULL THEN tp.import_cargo = an.import_cargo ELSE 1 = 1 END
471
- LEFT JOIN products pr ON pr.sku = tp.sku
472
- LEFT JOIN product_details pd ON pr.id = pd.product_id
473
- AND CASE WHEN tp.packing_type NOTNULL
474
- AND tp.packing_size NOTNULL
475
- AND tp.uom NOTNULL THEN pd.packing_type = tp.packing_type
476
- AND pd.packing_size = tp.packing_size
477
- AND pd.uom = tp.uom ELSE pd.is_default = TRUE END
471
+ LEFT JOIN products pr ON LOWER(pr.sku) = LOWER(tp.sku)
472
+ LEFT JOIN product_details pd ON pr.id = pd.product_id
473
+ AND CASE WHEN tp.packing_type NOTNULL AND tp.packing_size NOTNULL AND tp.uom NOTNULL
474
+ THEN pd.packing_type = tp.packing_type AND pd.packing_size = tp.packing_size AND pd.uom = tp.uom
475
+ WHEN tp.packing_type NOTNULL AND tp.packing_size NOTNULL AND tp.uom ISNULL
476
+ THEN pd.packing_type = tp.packing_type AND pd.packing_size = tp.packing_size AND pd.is_default IS TRUE
477
+ WHEN tp.packing_type ISNULL AND tp.packing_size ISNULL AND tp.uom NOTNULL
478
+ THEN pd.uom = tp.uom AND pd.is_default IS TRUE ELSE pd.is_default IS TRUE
479
+ END
478
480
  WHERE
479
481
  pr.bizplace_id = $1
480
482
 
@@ -489,7 +491,7 @@ export async function validateBulkArrivalNoticesFunction(
489
491
 
490
492
  const regExp = /^(181[2-9]|18[2-9]\d|19\d\d|2\d{3}|30[0-3]\d|304[0-8])$/
491
493
 
492
- if (manufactureYear && !regExp.test(manufactureYear) && !item.remark) item.remark = 'invalid manufacture year'
494
+ if (manufactureYear && !regExp.test(manufactureYear) && !item.errorMsg) item.errorMsg = 'invalid manufacture year'
493
495
 
494
496
  return {
495
497
  refNo: item.ref_no,
@@ -517,7 +519,7 @@ export async function validateBulkArrivalNoticesFunction(
517
519
  palletQty: item.pallet_qty,
518
520
  unitPrice: item.unit_price,
519
521
  manufactureYear: item.manufacture_year,
520
- remark: item.remark
522
+ errorMsg: item.errorMsg
521
523
  }
522
524
  })
523
525
  }
@@ -121,6 +121,9 @@ export class NewArrivalNotice {
121
121
 
122
122
  @Field(type => Int, { nullable: true })
123
123
  manufactureYear?: number
124
+
125
+ @Field({ nullable: true })
126
+ errorMsg: string
124
127
  }
125
128
 
126
129
  @InputType()
@@ -288,5 +291,5 @@ export class RawArrivalNotice {
288
291
  manufactureYear?: number
289
292
 
290
293
  @Field({ nullable: true })
291
- remark?: string
294
+ errorMsg?: string
292
295
  }
@@ -145,7 +145,7 @@ export class ArrivalNotice {
145
145
 
146
146
  @OneToOne(type => PurchaseOrder, { nullable: true })
147
147
  @JoinColumn()
148
- @Field(type => [PurchaseOrder], { nullable: true })
148
+ @Field(type => PurchaseOrder, { nullable: true })
149
149
  purchaseOrder: PurchaseOrder
150
150
 
151
151
  @CreateDateColumn()
@@ -256,6 +256,9 @@ export class OrderInventory {
256
256
  @Field({ nullable: true })
257
257
  productName: string
258
258
 
259
+ @Field({ nullable: true })
260
+ productSKU: string
261
+
259
262
  @Field({ nullable: true })
260
263
  productBrand: string
261
264
 
@@ -303,6 +306,21 @@ export class OrderInventory {
303
306
  @Field({ nullable: true })
304
307
  status: string
305
308
 
309
+ @Field({ nullable: true })
310
+ remainQty: number
311
+
312
+ @Field({ nullable: true })
313
+ remainUomValue: string
314
+
315
+ @Field({ nullable: true })
316
+ remainUomValueWithUom: string
317
+
318
+ @Field({ nullable: true })
319
+ isError: boolean
320
+
321
+ @Field({ nullable: true })
322
+ groupType: string
323
+
306
324
  @CreateDateColumn()
307
325
  @Field()
308
326
  createdAt: Date
@@ -40,7 +40,7 @@ export class PurchaseOrderMutation {
40
40
  async upsertPurchaseOrder(
41
41
  @Ctx() context: any,
42
42
  @Arg('purchaseOrder', type => PurchaseOrderPatch) purchaseOrder: PurchaseOrderPatch,
43
- @Arg('file', type => GraphQLUpload, { nullable: true }) file?: FileUpload
43
+ @Arg('file', type => [GraphQLUpload], { nullable: true }) file?: FileUpload
44
44
  ): Promise<PurchaseOrder> {
45
45
  try {
46
46
  const { tx }: { tx: EntityManager } = context.state
@@ -3,7 +3,7 @@ import { Arg, Args, Ctx, Directive, FieldResolver, Query, Resolver, Root } from
3
3
  import { EntityManager, getRepository, In, Repository, SelectQueryBuilder } from 'typeorm'
4
4
 
5
5
  import { Attachment } from '@things-factory/attachment-base'
6
- import { User, checkUserBelongsDomain } from '@things-factory/auth-base'
6
+ import { checkUserBelongsDomain, User } from '@things-factory/auth-base'
7
7
  import { Bizplace, getCompanyBizplace, getMyBizplace, getPermittedBizplaceIds } from '@things-factory/biz-base'
8
8
  import { Product } from '@things-factory/product-base'
9
9
  import { buildQuery, Domain, Filter, ListParam, Pagination, Sorting } from '@things-factory/shell'
@@ -209,6 +209,8 @@ export class ReleaseGoodQuery {
209
209
  packingSize: inventory.packingSize,
210
210
  location: inventory.location,
211
211
  qty: inventory.qty,
212
+ lockedQty: inventory.lockedQty,
213
+ lockedUomValue: inventory.lockedUomValue,
212
214
  uom: inventory.uom,
213
215
  uomValue: inventory.uomValue,
214
216
  releaseQty: orderInv.releaseQty,
@@ -369,13 +371,9 @@ export class ReleaseGoodQuery {
369
371
  const PROD_ALIAS = 'PROD'
370
372
  const GAN_ALIAS = 'GAN'
371
373
  const conditions = filters
372
- let {
373
- batchId = null,
374
- containerNo = null,
375
- product = [],
376
- packingType = null,
377
- inventory = []
378
- } = getConditionValues(conditions)
374
+ let { batchId = null, containerNo = null, product = [], packingType = null, inventory = [] } = getConditionValues(
375
+ conditions
376
+ )
379
377
 
380
378
  const SELECT: string = `
381
379
  SELECT
@@ -634,7 +632,7 @@ export async function bulkReleaseGoodsAvailableItemsFunction(
634
632
  CASE WHEN js.packing_type NOTNULL AND js.packing_size NOTNULL THEN js.packing_size ELSE pd.packing_size END,
635
633
  CASE WHEN js.uom NOTNULL THEN js.uom ELSE pd.uom END
636
634
  FROM JSON_POPULATE_RECORDSET(NULL::raw_release_goods, $1) js
637
- LEFT JOIN products p ON js.sku = p.sku AND p.bizplace_id = $2
635
+ LEFT JOIN products p ON LOWER(js.sku) = LOWER(p.sku) AND p.bizplace_id = $2
638
636
  LEFT JOIN product_details pd ON p.id = pd.product_id
639
637
  AND CASE WHEN js.packing_type NOTNULL AND js.packing_size NOTNULL AND js.uom NOTNULL
640
638
  THEN pd.packing_type = js.packing_type AND pd.packing_size = js.packing_size AND pd.uom = js.uom
@@ -695,6 +693,8 @@ export async function bulkReleaseGoodsAvailableItemsFunction(
695
693
  [domain.id, bizplaceId, LOCATION_TYPE.QUARANTINE, LOCATION_TYPE.RESERVE]
696
694
  )
697
695
 
696
+ await tx.query(`DROP TABLE raw_release_goods`)
697
+
698
698
  availableItems = availableItems.map(item => {
699
699
  return {
700
700
  productId: item.product_id,
@@ -703,7 +703,7 @@ export async function bulkReleaseGoodsAvailableItemsFunction(
703
703
  sku: item.sku,
704
704
  batchId: item.batch_id,
705
705
  packingType: item.packing_type,
706
- packingSize: item.packing_size,
706
+ packingSize: Number(item.packing_size || 0),
707
707
  uom: item.uom,
708
708
  remainQty: item.remain_qty,
709
709
  remainUomValue: item.remain_uom_value
@@ -731,7 +731,7 @@ function _extractData(rawData, validatedData) {
731
731
  a = JSON.stringify(Object.fromEntries(Object.entries(a).sort()))
732
732
  b = JSON.stringify(Object.fromEntries(Object.entries(b).sort()))
733
733
 
734
- return val.sku == raw.sku && a === b
734
+ return val.sku.toLowerCase() == raw.sku.toLowerCase() && a === b
735
735
  })
736
736
 
737
737
  let releaseUomValue = 0
@@ -779,7 +779,7 @@ function _extractData(rawData, validatedData) {
779
779
  releaseUomValue,
780
780
  errorMsg:
781
781
  !raw.productId || !raw.productDetailId
782
- ? 'product not found'
782
+ ? 'inventory or product not found'
783
783
  : raw.releaseQty <= 0
784
784
  ? 'invalid release qty'
785
785
  : raw.assignedQty < raw.releaseQty
@@ -795,7 +795,9 @@ function _extractData(rawData, validatedData) {
795
795
  })
796
796
  }
797
797
 
798
- function getConditionValues(conditions: Filter[]): {
798
+ function getConditionValues(
799
+ conditions: Filter[]
800
+ ): {
799
801
  batchId?: string
800
802
  containerNo?: string
801
803
  product?: string[]
@@ -10,12 +10,13 @@ import {
10
10
  InventoryHistory,
11
11
  InventoryNoGenerator,
12
12
  InventoryPatch,
13
- InventoryUtil,
14
13
  Location,
15
14
  LOCATION_TYPE,
16
15
  Warehouse
17
16
  } from '@things-factory/warehouse-base'
18
17
 
18
+ import { InventoryUtil } from '../../utils'
19
+
19
20
  import { ORDER_STATUS, ORDER_TYPES, ORDER_VAS_STATUS } from '../../constants'
20
21
  import { OrderNoGenerator } from '../../utils/order-no-generator'
21
22
  import { ReverseKittingOrderInventory } from '../reverse-kitting-order-inventory/reverse-kitting-order-inventory'
@@ -34,14 +34,13 @@ export class ReverseKittingOrderQuery {
34
34
  'reverseKittingOrderInventories.inventory.product',
35
35
  'reverseKittingOrderInventories.inventory.location',
36
36
  'reverseKittingOrderInventories.inventory.warehouse',
37
- 'reverseKittingOrderInventories.targetProduct',
38
37
  'creator',
39
38
  'updater'
40
39
  ]
41
40
  })
42
41
  }
43
42
 
44
- @Query(returns => ReverseKittingOrder, { description: 'To fetch a ReverseKittingOrder' })
43
+ @Query(returns => [ReverseKittingOrder], { description: 'To fetch a ReverseKittingOrder' })
45
44
  async reverseKittingInventories(
46
45
  @Arg('reverseKittingOIName') reverseKittingOIName: string,
47
46
  @Arg('productDetailId') productDetailId: string,
@@ -13,8 +13,8 @@ import { ReverseKittingOrder } from './reverse-kitting-order'
13
13
 
14
14
  @InputType()
15
15
  export class NewReverseKittingOrder {
16
- @Field()
17
- name: string
16
+ @Field({ nullable: true })
17
+ name?: string
18
18
 
19
19
  @Field({ nullable: true })
20
20
  customerBizplaceId?: string
@@ -1,4 +1,4 @@
1
- import { Field, ID, ObjectType } from 'type-graphql'
1
+ import { Field, ID, ObjectType, Float, Int } from 'type-graphql'
2
2
  import {
3
3
  Column,
4
4
  CreateDateColumn,
@@ -14,6 +14,8 @@ import {
14
14
  import { User } from '@things-factory/auth-base'
15
15
  import { Bizplace } from '@things-factory/biz-base'
16
16
  import { Domain } from '@things-factory/shell'
17
+ import { Location } from '@things-factory/warehouse-base'
18
+ import { Product } from '@things-factory/product-base'
17
19
 
18
20
  import { ReverseKittingOrderInventory } from '../reverse-kitting-order-inventory/reverse-kitting-order-inventory'
19
21
 
@@ -37,6 +39,7 @@ export class ReverseKittingOrder {
37
39
  domainId?: string
38
40
 
39
41
  @ManyToOne(type => Bizplace)
42
+ @Field(type => Bizplace, { nullable: true })
40
43
  bizplace: Bizplace
41
44
 
42
45
  @RelationId((reverseKittingOrder: ReverseKittingOrder) => reverseKittingOrder.bizplace)
@@ -57,9 +60,42 @@ export class ReverseKittingOrder {
57
60
  @Field({ nullable: true })
58
61
  remark?: string
59
62
 
60
- @Column({ nullable: true })
61
63
  @Field({ nullable: true })
62
- status: string
64
+ batchId?: string
65
+
66
+ @Field({ nullable: true })
67
+ packingType?: string
68
+
69
+ @Field(type => Float, { nullable: true })
70
+ packingSize?: number
71
+
72
+ @Column()
73
+ @Field({ nullable: true })
74
+ status?: string
75
+
76
+ @Field({ nullable: true })
77
+ batchIdRef?: string
78
+
79
+ @Field({ nullable: true })
80
+ palletId?: string
81
+
82
+ @Field({ nullable: true })
83
+ cartonId?: string
84
+
85
+ @Field(type => Int, { nullable: true })
86
+ qty?: number
87
+
88
+ @Field({ nullable: true })
89
+ expirationDate?: string
90
+
91
+ @Field(type => Location, { nullable: true })
92
+ location?: Location
93
+
94
+ @Field(type => Product, { nullable: true })
95
+ product?: Product
96
+
97
+ @Field({ nullable: true })
98
+ productDetailId?: string
63
99
 
64
100
  @CreateDateColumn()
65
101
  @Field({ nullable: true })
@@ -27,7 +27,13 @@ export class NewReverseKittingOrderInventory {
27
27
  @Field(type => Float, { nullable: true })
28
28
  uomValue?: number
29
29
 
30
- @Field(type => ObjectRef)
30
+ @Field({ nullable: true })
31
+ productName?: string
32
+
33
+ @Field({ nullable: true })
34
+ packingType?: string
35
+
36
+ @Field(type => ObjectRef, { nullable: true })
31
37
  reverseKittingOrder?: ObjectRef
32
38
 
33
39
  @Field(type => ObjectRef)
@@ -14,6 +14,8 @@ import { User } from '@things-factory/auth-base'
14
14
  import { Bizplace } from '@things-factory/biz-base'
15
15
  import { Domain } from '@things-factory/shell'
16
16
  import { Inventory } from '@things-factory/warehouse-base'
17
+ import { Product } from '@things-factory/product-base'
18
+ import { Vas } from '@things-factory/sales-base'
17
19
 
18
20
  import { ReverseKittingOrder } from '../reverse-kitting-order/reverse-kitting-order'
19
21
 
@@ -93,6 +95,29 @@ export class ReverseKittingOrderInventory {
93
95
  @Field()
94
96
  status: string
95
97
 
98
+ @Field({ nullable: true })
99
+ targetType?: string
100
+
101
+ @Field({ nullable: true })
102
+ targetBatchId?: string
103
+
104
+ @ManyToOne(type => Product, { nullable: true })
105
+ @Field(type => Product, { nullable: true })
106
+ targetProduct?: Product
107
+
108
+ @ManyToOne(type => Vas, { nullable: true })
109
+ @Field(type => Vas, { nullable: true })
110
+ vas?: Vas
111
+
112
+ @Field({ nullable: true })
113
+ otherTarget?: string
114
+
115
+ @Field({ nullable: true })
116
+ description?: string
117
+
118
+ @Field({ nullable: true })
119
+ issue?: string
120
+
96
121
  @CreateDateColumn()
97
122
  @Field({ nullable: true })
98
123
  createdAt?: Date