@things-factory/sales-base 4.3.39 → 4.3.40

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 (43) hide show
  1. package/dist-server/service/delivery-order/delivery-order-mutation.js +58 -6
  2. package/dist-server/service/delivery-order/delivery-order-mutation.js.map +1 -1
  3. package/dist-server/service/delivery-order/delivery-order-types.js +20 -0
  4. package/dist-server/service/delivery-order/delivery-order-types.js.map +1 -1
  5. package/dist-server/service/goods-receival-note/goods-receival-note-query.js +96 -5
  6. package/dist-server/service/goods-receival-note/goods-receival-note-query.js.map +1 -1
  7. package/dist-server/service/goods-receival-note/goods-receival-note-types.js +65 -1
  8. package/dist-server/service/goods-receival-note/goods-receival-note-types.js.map +1 -1
  9. package/dist-server/service/goods-receival-note/goods-receival-note.js +41 -0
  10. package/dist-server/service/goods-receival-note/goods-receival-note.js.map +1 -1
  11. package/dist-server/service/order-inventory/order-inventory-query.js +111 -142
  12. package/dist-server/service/order-inventory/order-inventory-query.js.map +1 -1
  13. package/dist-server/service/order-inventory/order-inventory.js +24 -0
  14. package/dist-server/service/order-inventory/order-inventory.js.map +1 -1
  15. package/dist-server/service/purchase-order/purchase-order-mutation.js +4 -1
  16. package/dist-server/service/purchase-order/purchase-order-mutation.js.map +1 -1
  17. package/dist-server/service/release-good/release-good-mutation.js +52 -8
  18. package/dist-server/service/release-good/release-good-mutation.js.map +1 -1
  19. package/dist-server/service/release-good/release-good-types.js +153 -1
  20. package/dist-server/service/release-good/release-good-types.js.map +1 -1
  21. package/dist-server/service/release-good/release-good.js +20 -0
  22. package/dist-server/service/release-good/release-good.js.map +1 -1
  23. package/dist-server/utils/datetime-util.js +49 -0
  24. package/dist-server/utils/datetime-util.js.map +1 -0
  25. package/dist-server/utils/index.js +1 -0
  26. package/dist-server/utils/index.js.map +1 -1
  27. package/dist-server/utils/inventory-util.js +19 -2
  28. package/dist-server/utils/inventory-util.js.map +1 -1
  29. package/package.json +12 -12
  30. package/server/service/delivery-order/delivery-order-mutation.ts +91 -16
  31. package/server/service/delivery-order/delivery-order-types.ts +15 -0
  32. package/server/service/goods-receival-note/goods-receival-note-query.ts +120 -10
  33. package/server/service/goods-receival-note/goods-receival-note-types.ts +48 -0
  34. package/server/service/goods-receival-note/goods-receival-note.ts +32 -0
  35. package/server/service/order-inventory/order-inventory-query.ts +121 -166
  36. package/server/service/order-inventory/order-inventory.ts +18 -0
  37. package/server/service/purchase-order/purchase-order-mutation.ts +5 -1
  38. package/server/service/release-good/release-good-mutation.ts +67 -13
  39. package/server/service/release-good/release-good-types.ts +112 -0
  40. package/server/service/release-good/release-good.ts +16 -0
  41. package/server/utils/datetime-util.ts +54 -0
  42. package/server/utils/index.ts +1 -0
  43. package/server/utils/inventory-util.ts +20 -2
@@ -41,7 +41,7 @@ import { confirmArrivalNoticeFunction, deleteArrivalNotice } from '../arrival-no
41
41
  import { OrderInventory } from '../order-inventory/order-inventory'
42
42
  import { OrderProduct } from '../order-product/order-product'
43
43
  import { OrderVas } from '../order-vas/order-vas'
44
- import { NewReleaseGood, ReleaseGoodPatch } from '../release-good/release-good-types'
44
+ import { NewReleaseGood, ReleaseGoodPatch, ShippingOrderInfoPatch } from '../release-good/release-good-types'
45
45
  import { ShippingOrder } from '../shipping-order/shipping-order'
46
46
  import { ShippingOrderPatch } from '../shipping-order/shipping-order-types'
47
47
  import { Vas } from '../vas/vas'
@@ -134,7 +134,7 @@ export class ReleaseGoodMutation {
134
134
  context,
135
135
  tx
136
136
  )
137
- } catch (error) {}
137
+ } catch (error) { }
138
138
 
139
139
  if (errorsCaught.length)
140
140
  throw new ValidationError({
@@ -172,13 +172,16 @@ export class ReleaseGoodMutation {
172
172
  @Ctx() context: any,
173
173
  @Arg('attachments', type => [GraphQLUpload], { nullable: true }) attachments?: FileUpload[],
174
174
  @Arg('releaseGood', type => NewReleaseGood, { nullable: true }) releaseGood?: NewReleaseGood,
175
- @Arg('shippingOrder', type => ShippingOrderPatch, { nullable: true }) shippingOrder?: ShippingOrderPatch
175
+ @Arg('shippingOrder', type => ShippingOrderPatch, { nullable: true }) shippingOrder?: ShippingOrderPatch,
176
+ @Arg('shippingOrderInfo', type => ShippingOrderInfoPatch, { nullable: true })
177
+ shippingOrderInfo?: ShippingOrderInfoPatch
176
178
  ): Promise<ReleaseGood> {
177
179
  const { tx }: { tx: EntityManager } = context.state
178
180
  const createdReleaseGood: ReleaseGood = await generateReleaseGoodFunction(
179
181
  null,
180
182
  releaseGood,
181
183
  shippingOrder,
184
+ shippingOrderInfo,
182
185
  attachments,
183
186
  context,
184
187
  tx
@@ -193,7 +196,9 @@ export class ReleaseGoodMutation {
193
196
  async updateReleaseGoodDetails(
194
197
  @Ctx() context: any,
195
198
  @Arg('releaseGood', type => ReleaseGoodPatch, { nullable: true }) releaseGood?: ReleaseGoodPatch,
196
- @Arg('shippingOrder', type => ShippingOrderPatch, { nullable: true }) shippingOrder?: ShippingOrderPatch
199
+ @Arg('shippingOrder', type => ShippingOrderPatch, { nullable: true }) shippingOrder?: ShippingOrderPatch,
200
+ @Arg('shippingOrderInfo', type => ShippingOrderInfoPatch, { nullable: true })
201
+ shippingOrderInfo?: ShippingOrderInfoPatch
197
202
  ): Promise<ReleaseGood> {
198
203
  const { tx, domain, user } = context.state
199
204
  let foundReleaseGood = await tx.getRepository(ReleaseGood).findOne({
@@ -224,9 +229,18 @@ export class ReleaseGoodMutation {
224
229
  releaseGood.shippingOrder = newShippingOrder
225
230
  }
226
231
 
232
+ shippingOrderInfo.deliveryAddress1 = shippingOrderInfo.deliveryFullAddress
233
+ shippingOrderInfo.country = shippingOrderInfo.deliveryCountry
234
+ shippingOrderInfo.state = shippingOrderInfo.deliveryState
235
+ shippingOrderInfo.city = shippingOrderInfo.deliveryCity
236
+ shippingOrderInfo.phone1 = shippingOrderInfo.contact
237
+ shippingOrderInfo.postalCode = shippingOrderInfo.deliveryPostalCode
238
+ shippingOrderInfo.attentionCompany = shippingOrderInfo.companyName
239
+
227
240
  foundReleaseGood = await tx.getRepository(ReleaseGood).save({
228
241
  ...foundReleaseGood,
229
242
  ...releaseGood,
243
+ ...shippingOrderInfo,
230
244
  remark: releaseGood?.remark ? releaseGood.remark : null
231
245
  })
232
246
 
@@ -412,6 +426,7 @@ export async function generateReleaseGoodFunction(
412
426
  _: any,
413
427
  releaseGood: any,
414
428
  shippingOrder: any,
429
+ shippingOrderInfo: any,
415
430
  attachments: FileUpload[],
416
431
  context: any,
417
432
  tx?: EntityManager
@@ -545,6 +560,36 @@ export async function generateReleaseGoodFunction(
545
560
  }
546
561
  })
547
562
 
563
+ let attentionToBind = releaseGood?.attentionTo
564
+ let billingAddressBind = releaseGood?.billingAddress
565
+ let deliveryAddressBind = releaseGood?.deliveryAddress1
566
+ let attentionCompanyBind = releaseGood?.companyName
567
+ let cityBind = releaseGood?.city
568
+ let stateBind = releaseGood?.state
569
+ let postalCodeBind = releaseGood?.postalCode
570
+ let countryBind = releaseGood?.country
571
+ let contactBind = releaseGood?.phone1
572
+ let billingCityBind = releaseGood?.billingCity
573
+ let billingCountryBind = releaseGood?.billingCountry
574
+ let billingPostalCodeBind = releaseGood?.billingPostalCode
575
+ let billingStateBind = releaseGood?.billingState
576
+
577
+ if (Object.keys(shippingOrderInfo).length > 0) {
578
+ attentionToBind = shippingOrderInfo.attentionTo
579
+ billingAddressBind = shippingOrderInfo.billingAddress
580
+ deliveryAddressBind = shippingOrderInfo.deliveryAddress
581
+ attentionCompanyBind = shippingOrderInfo.companyName
582
+ cityBind = shippingOrderInfo.deliveryCity
583
+ stateBind = shippingOrderInfo.deliveryState
584
+ postalCodeBind = shippingOrderInfo.deliveryPostalCode
585
+ countryBind = shippingOrderInfo.deliveryCountry
586
+ contactBind = shippingOrderInfo.contact
587
+ billingCityBind = shippingOrderInfo.billingCity
588
+ billingCountryBind = shippingOrderInfo.billingCountry
589
+ billingPostalCodeBind = shippingOrderInfo.billingPostalCode
590
+ billingStateBind = shippingOrderInfo.billingState
591
+ }
592
+
548
593
  newReleaseGood = {
549
594
  ...newReleaseGood,
550
595
  name: roNoSetting
@@ -558,21 +603,25 @@ export async function generateReleaseGoodFunction(
558
603
  ownTransport: releaseGood.ownTransport,
559
604
  packingOption: releaseGood.packingOption,
560
605
  marketplaceOrderStatus: releaseGood?.marketplaceOrderStatus || null,
561
- billingAddress: releaseGood?.billingAddress || null,
562
- deliveryAddress1: releaseGood?.deliveryAddress1 || null,
606
+ billingAddress: billingAddressBind || null,
607
+ deliveryAddress1: deliveryAddressBind || null,
563
608
  deliveryAddress2: releaseGood?.deliveryAddress2 || null,
564
609
  deliveryAddress3: releaseGood?.deliveryAddress3 || null,
565
610
  deliveryAddress4: releaseGood?.deliveryAddress4 || null,
566
611
  deliveryAddress5: releaseGood?.deliveryAddress5 || null,
567
- attentionTo: releaseGood?.attentionTo || null,
568
- attentionCompany: releaseGood?.attentionCompany || null,
569
- city: releaseGood?.city || null,
570
- state: releaseGood?.state || null,
571
- postalCode: releaseGood?.postalCode || null,
572
- country: releaseGood?.country || null,
573
- phone1: releaseGood?.phone1 || null,
612
+ attentionTo: attentionToBind || null,
613
+ attentionCompany: attentionCompanyBind || null,
614
+ city: cityBind || null,
615
+ state: stateBind || null,
616
+ postalCode: postalCodeBind || null,
617
+ country: countryBind || null,
618
+ phone1: contactBind || null,
574
619
  phone2: releaseGood?.phone2 || null,
575
620
  email: releaseGood?.email || null,
621
+ billingCity: billingCityBind || null,
622
+ billingCountry: billingCountryBind || null,
623
+ billingPostalCode: billingPostalCodeBind || null,
624
+ billingState: billingStateBind || null,
576
625
  transporter: releaseGood?.transporter,
577
626
  trackingNo: releaseGood?.trackingNo,
578
627
  airwayBill: releaseGood?.airwayBill,
@@ -1416,6 +1465,11 @@ function extractRawReleaseGoods(rawReleaseGoods): Partial<ReleaseGood[]> {
1416
1465
  deliveryAddress2: item.deliveryAddress2,
1417
1466
  deliveryAddress3: item.deliveryAddress3,
1418
1467
  deliveryAddress4: item.deliveryAddress4,
1468
+ billingAddress: item.billingAddress,
1469
+ billingCity: item.billingPostalCode,
1470
+ billingState: item.billingState,
1471
+ billingCountry: item.billingCountry,
1472
+ billingPostalCode: item.billingPostalCode,
1419
1473
  city: item.city,
1420
1474
  postalCode: item.postalCode,
1421
1475
  state: item.state,
@@ -359,6 +359,18 @@ export class NewReleaseGood {
359
359
 
360
360
  @Field({ nullable: true })
361
361
  stopId: string
362
+
363
+ @Field({ nullable: true})
364
+ billingCity: string
365
+
366
+ @Field({ nullable: true})
367
+ billingPostalCode: string
368
+
369
+ @Field({ nullable: true})
370
+ billingCountry: string
371
+
372
+ @Field({ nullable: true})
373
+ billingState: string
362
374
  }
363
375
 
364
376
  @InputType()
@@ -528,3 +540,103 @@ export class ReleaseGoodPatch {
528
540
  @Field({ nullable: true })
529
541
  stopId: string
530
542
  }
543
+
544
+ @InputType()
545
+ export class ShippingOrderInformationPatch {
546
+ @Field({ nullable: true })
547
+ id?: string
548
+
549
+ @Field({ nullable: true })
550
+ containerNo?: string
551
+
552
+ @Field({ nullable: true })
553
+ containerLeavingDate?: string
554
+
555
+ @Field({ nullable: true })
556
+ containerArrivalDate?: string
557
+
558
+ @Field({ nullable: true })
559
+ containerLeavingDateTime?: string
560
+
561
+ @Field({ nullable: true })
562
+ containerArrivalDateTime?: string
563
+
564
+ @Field({ nullable: true })
565
+ shipName?: string
566
+ }
567
+
568
+ @InputType()
569
+ export class ShippingOrderInfoPatch {
570
+ @Field({ nullable: true })
571
+ billingAddress: string
572
+
573
+ @Field({ nullable: true })
574
+ billingCity: string
575
+
576
+ @Field({ nullable: true })
577
+ billingPostalCode: string
578
+
579
+ @Field({ nullable: true })
580
+ billingState: string
581
+
582
+ @Field({ nullable: true })
583
+ billingCountry: string
584
+
585
+ @Field({ nullable: true })
586
+ companyName: string
587
+
588
+ @Field({ nullable: true })
589
+ contact: string
590
+
591
+ @Field({ nullable: true })
592
+ deliveryAddress: string
593
+
594
+ @Field({ nullable: true })
595
+ deliveryCity: string
596
+
597
+ @Field({ nullable: true })
598
+ deliveryCountry: string
599
+
600
+ @Field({ nullable: true })
601
+ deliveryPostalCode: string
602
+
603
+ @Field({ nullable: true })
604
+ deliveryState: string
605
+
606
+ @Field({ nullable: true })
607
+ attentionTo: string
608
+
609
+ @Field({ nullable: true })
610
+ deliveryAddress1: string
611
+
612
+ @Field({ nullable: true })
613
+ country: string
614
+
615
+ @Field({ nullable: true })
616
+ city: string
617
+
618
+ @Field({ nullable: true })
619
+ state: string
620
+
621
+ @Field({ nullable: true })
622
+ phone1: string
623
+
624
+ @Field({ nullable: true })
625
+ postalCode: string
626
+
627
+ @Field({ nullable: true })
628
+ attentionCompany: string
629
+
630
+ @Field({ nullable: true})
631
+ collectionOrderNo: string
632
+
633
+ @Field({ nullable: true})
634
+ billingFullAddress: string
635
+
636
+ @Field({ nullable: true})
637
+ deliveryFullAddress: string
638
+
639
+ @Field(type => ShippingOrderInformationPatch, { nullable: true })
640
+ shippingOrder: ShippingOrderInformationPatch
641
+ }
642
+
@@ -203,6 +203,22 @@ export class ReleaseGood {
203
203
  @Field({ nullable: true })
204
204
  billingAddress: string
205
205
 
206
+ @Column({ nullable: true })
207
+ @Field({ nullable: true })
208
+ billingCountry: string
209
+
210
+ @Column({ nullable: true })
211
+ @Field({ nullable: true })
212
+ billingPostalCode: string
213
+
214
+ @Column({ nullable: true })
215
+ @Field({ nullable: true })
216
+ billingState: string
217
+
218
+ @Column({ nullable: true })
219
+ @Field({ nullable: true })
220
+ billingCity: string
221
+
206
222
  @Column({ nullable: true })
207
223
  @Field({ nullable: true })
208
224
  pickupAddress: string
@@ -0,0 +1,54 @@
1
+ export class DateGenerator {
2
+ static generateDate() {
3
+ const today = new Date()
4
+ const year = today.getFullYear()
5
+ const month = today.getMonth()
6
+ const day = today.getDate()
7
+
8
+ const yy = String(year).substr(String(year).length - 2)
9
+ const mm = String(month + 1).padStart(2, '0')
10
+ const dd = String(day).padStart(2, '0')
11
+
12
+ return yy + mm + dd
13
+ }
14
+ }
15
+
16
+ export class DateTimeConverter {
17
+ static date(dateTime) {
18
+ let unloadDate = ''
19
+ if (dateTime) {
20
+ const unloadDateTime: Date = new Date(dateTime)
21
+ var year = unloadDateTime.getFullYear()
22
+
23
+ var month = (1 + unloadDateTime.getMonth()).toString()
24
+ month = month.length > 1 ? month : '0' + month
25
+
26
+ var day = unloadDateTime.getDate().toString()
27
+ day = day.length > 1 ? day : '0' + day
28
+
29
+ unloadDate = day + '-' + month + '-' + year
30
+ }
31
+ return unloadDate
32
+ }
33
+
34
+ static datetime(dateTime, timezone) {
35
+ let unloadDate = ''
36
+ if (dateTime) {
37
+ const datetime = Number(dateTime)
38
+ const timezoneOffset = timezone * 60000
39
+ const newUnloadDate = new Date(datetime - timezoneOffset).toISOString().slice(0, -1)
40
+
41
+ var dateTimeParts: any = newUnloadDate.split('T')
42
+
43
+ //handle date parts
44
+ var dateParts = dateTimeParts[0].split('-')
45
+ var newDate = DateTimeConverter.date(dateParts)
46
+
47
+ //handle time part
48
+ var timeParts = dateTimeParts[1].slice(0, -7)
49
+
50
+ unloadDate = newDate + ' ' + timeParts
51
+ }
52
+ return unloadDate
53
+ }
54
+ }
@@ -1,2 +1,3 @@
1
1
  export * from './order-no-generator'
2
2
  export * from './inventory-util'
3
+ export * from './datetime-util'
@@ -578,7 +578,23 @@ export const InventoryUtil = {
578
578
  : qb.addOrderBy(`loc.${rule.name}`, rule.desc ? 'DESC' : 'ASC')
579
579
  })
580
580
  } else {
581
- qb.addOrderBy('"iv"."created_at"', 'ASC')
581
+ switch (product?.pickingStrategy) {
582
+ case 'FIFO':
583
+ qb.addOrderBy('"iv"."created_at"', 'ASC')
584
+ break
585
+ case 'FEFO':
586
+ qb.addOrderBy('"iv"."expiration_date"', 'ASC')
587
+ break
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
597
+ }
582
598
  }
583
599
 
584
600
  let inventories: Inventory[] = await qb.getMany()
@@ -1007,8 +1023,9 @@ export function _composeTargetInventories(product: Product, record: any, invento
1007
1023
  packingType,
1008
1024
  packingSize,
1009
1025
  batchId,
1026
+ batchIdRef,
1010
1027
  uom
1011
- }: { packingType: string; packingSize: number; batchId: string; uom: string } = inventory
1028
+ }: { packingType: string; packingSize: number; batchId: string; batchIdRef: string; uom: string } = inventory
1012
1029
 
1013
1030
  let orderInventory: OrderInventory = new OrderInventory()
1014
1031
 
@@ -1042,6 +1059,7 @@ export function _composeTargetInventories(product: Product, record: any, invento
1042
1059
  packingType,
1043
1060
  packingSize,
1044
1061
  batchId,
1062
+ batchIdRef,
1045
1063
  uom,
1046
1064
  product,
1047
1065
  type: ORDER_TYPES.RELEASE_OF_GOODS