@things-factory/sales-base 4.3.562 → 4.3.566

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.
@@ -1,5 +1,14 @@
1
- import { FileUpload, GraphQLUpload } from 'graphql-upload'
2
- import { Arg, Ctx, Directive, Mutation, Resolver } from 'type-graphql'
1
+ import {
2
+ FileUpload,
3
+ GraphQLUpload
4
+ } from 'graphql-upload'
5
+ import {
6
+ Arg,
7
+ Ctx,
8
+ Directive,
9
+ Mutation,
10
+ Resolver
11
+ } from 'type-graphql'
3
12
  import {
4
13
  Brackets,
5
14
  EntityManager,
@@ -12,8 +21,17 @@ import {
12
21
  SelectQueryBuilder
13
22
  } from 'typeorm'
14
23
 
15
- import { Attachment, createAttachments } from '@things-factory/attachment-base'
16
- import { Application, ApplicationType, Partner, Role, User } from '@things-factory/auth-base'
24
+ import {
25
+ Attachment,
26
+ createAttachments
27
+ } from '@things-factory/attachment-base'
28
+ import {
29
+ Application,
30
+ ApplicationType,
31
+ Partner,
32
+ Role,
33
+ User
34
+ } from '@things-factory/auth-base'
17
35
  import {
18
36
  Bizplace,
19
37
  getCompanyBizplace,
@@ -24,16 +42,31 @@ import {
24
42
  } from '@things-factory/biz-base'
25
43
  import { GeoCountry } from '@things-factory/geography'
26
44
  import { generateId } from '@things-factory/id-rule-base'
27
- import { webhookHandler, WebhookEventsEnum } from '@things-factory/integration-base'
45
+ import {
46
+ WebhookEventsEnum,
47
+ webhookHandler
48
+ } from '@things-factory/integration-base'
28
49
  import { LastMileDelivery } from '@things-factory/integration-lmd'
29
50
  import { MarketplaceStore } from '@things-factory/integration-marketplace'
30
- import { Sellercraft, SellercraftStatus } from '@things-factory/integration-sellercraft'
51
+ import {
52
+ Sellercraft,
53
+ SellercraftStatus
54
+ } from '@things-factory/integration-sellercraft'
31
55
  import { MarketplaceOrder } from '@things-factory/marketplace-base'
32
56
  // import { sendNotification } from '@things-factory/notification'
33
- import { ProductBundleSetting, ProductDetail } from '@things-factory/product-base'
34
- import { PartnerSetting, Setting } from '@things-factory/setting-base'
57
+ import {
58
+ ProductBundleSetting,
59
+ ProductDetail
60
+ } from '@things-factory/product-base'
61
+ import {
62
+ PartnerSetting,
63
+ Setting
64
+ } from '@things-factory/setting-base'
35
65
  import { Domain } from '@things-factory/shell'
36
- import { Inventory, ProductDetailStock } from '@things-factory/warehouse-base'
66
+ import {
67
+ Inventory,
68
+ ProductDetailStock
69
+ } from '@things-factory/warehouse-base'
37
70
 
38
71
  // import { NewOrderProduct } from '../order-product/order-product-types'
39
72
  import {
@@ -47,18 +80,32 @@ import {
47
80
  ORDER_VAS_STATUS,
48
81
  PRODUCT_GROUP_TYPE
49
82
  } from '../../constants'
50
- import { EcommerceController, PowrupController, SellercraftController } from '../../controllers'
83
+ import {
84
+ EcommerceController,
85
+ PowrupController,
86
+ SellercraftController
87
+ } from '../../controllers'
51
88
  import { ValidationError } from '../../errors'
52
- import { InventoryUtil, OrderNoGenerator } from '../../utils'
89
+ import {
90
+ InventoryUtil,
91
+ OrderNoGenerator
92
+ } from '../../utils'
53
93
  import { ArrivalNotice } from '../arrival-notice/arrival-notice'
54
- import { confirmArrivalNoticeFunction, deleteArrivalNotice } from '../arrival-notice/arrival-notice-mutation'
94
+ import {
95
+ confirmArrivalNoticeFunction,
96
+ deleteArrivalNotice
97
+ } from '../arrival-notice/arrival-notice-mutation'
55
98
  import { OrderInventory } from '../order-inventory/order-inventory'
56
99
  import { OrderPackage } from '../order-package/order-package'
57
100
  import { OrderProduct } from '../order-product/order-product'
58
101
  import { OrderVasItem } from '../order-vas-item/order-vas-item'
59
102
  import { OrderVas } from '../order-vas/order-vas'
60
103
  import { OrderVasPatch } from '../order-vas/order-vas-types'
61
- import { NewReleaseGood, ReleaseGoodPatch, ShippingOrderInfoPatch } from '../release-good/release-good-types'
104
+ import {
105
+ NewReleaseGood,
106
+ ReleaseGoodPatch,
107
+ ShippingOrderInfoPatch
108
+ } from '../release-good/release-good-types'
62
109
  import { ShippingOrder } from '../shipping-order/shipping-order'
63
110
  import { ShippingOrderPatch } from '../shipping-order/shipping-order-types'
64
111
  import { editVas } from '../vas'
@@ -694,32 +741,44 @@ export async function generateReleaseGoodFunction(
694
741
  recall: releaseGood.recall,
695
742
  marketplaceOrderStatus: releaseGood?.marketplaceOrderStatus || null,
696
743
  billingAddress:
697
- releaseGood.type == 'b2c' ? releaseGood?.billingAddress || null : shippingOrderInfo.billingAddress || null,
744
+ releaseGood.type == 'b2c' ? releaseGood?.billingAddress : shippingOrderInfo.billingAddress || null,
745
+ billingAddress2:
746
+ releaseGood.type == 'b2c' ? releaseGood?.billingAddress2 : shippingOrderInfo.billingAddress2 || null,
747
+ billingAddress3:
748
+ releaseGood.type == 'b2c' ? releaseGood?.billingAddress3 : shippingOrderInfo.billingAddress3 || null,
749
+ billingAddress4:
750
+ releaseGood.type == 'b2c' ? releaseGood?.billingAddress4 : shippingOrderInfo.billingAddress4 || null,
751
+ billingAddress5:
752
+ releaseGood.type == 'b2c' ? releaseGood?.billingAddress5 : shippingOrderInfo.billingAddress5 || null,
698
753
  deliveryAddress1:
699
- releaseGood.type == 'b2c' ? releaseGood?.deliveryAddress1 || null : shippingOrderInfo.deliveryAddress1 || null,
700
- deliveryAddress2: releaseGood?.deliveryAddress2 || null,
701
- deliveryAddress3: releaseGood?.deliveryAddress3 || null,
702
- deliveryAddress4: releaseGood?.deliveryAddress4 || null,
703
- deliveryAddress5: releaseGood?.deliveryAddress5 || null,
704
- attentionTo: releaseGood.type == 'b2c' ? releaseGood?.attentionTo || null : shippingOrderInfo.attentionTo || null,
754
+ releaseGood.type == 'b2c' ? releaseGood?.deliveryAddress1 : shippingOrderInfo.deliveryAddress1 || null,
755
+ deliveryAddress2:
756
+ releaseGood.type == 'b2c' ? releaseGood?.deliveryAddress2 : shippingOrderInfo.deliveryAddress2 || null,
757
+ deliveryAddress3:
758
+ releaseGood.type == 'b2c' ? releaseGood?.deliveryAddress3 : shippingOrderInfo.deliveryAddress3 || null,
759
+ deliveryAddress4:
760
+ releaseGood.type == 'b2c' ? releaseGood?.deliveryAddress4 : shippingOrderInfo.deliveryAddress4 || null,
761
+ deliveryAddress5:
762
+ releaseGood.type == 'b2c' ? releaseGood?.deliveryAddress5 : shippingOrderInfo.deliveryAddress5 || null,
763
+ attentionTo: releaseGood.type == 'b2c' ? releaseGood?.attentionTo : shippingOrderInfo.attentionTo || null,
705
764
  attentionCompany:
706
- releaseGood.type == 'b2c' ? releaseGood?.companyName || null : shippingOrderInfo.attentionCompany || null,
707
- city: releaseGood.type == 'b2c' ? releaseGood?.city || null : shippingOrderInfo.city || null,
708
- state: releaseGood.type == 'b2c' ? releaseGood?.state || null : shippingOrderInfo.state || null,
709
- postalCode: releaseGood.type == 'b2c' ? releaseGood?.postalCode || null : shippingOrderInfo.postalCode || null,
710
- country: releaseGood.type == 'b2c' ? releaseGood?.country || null : shippingOrderInfo.country || null,
711
- phone1: releaseGood.type == 'b2c' ? releaseGood?.phone1 || null : shippingOrderInfo.phone1 || null,
765
+ releaseGood.type == 'b2c' ? releaseGood?.companyName : shippingOrderInfo.attentionCompany || null,
766
+ city: releaseGood.type == 'b2c' ? releaseGood?.city : shippingOrderInfo.city || null,
767
+ state: releaseGood.type == 'b2c' ? releaseGood?.state : shippingOrderInfo.state || null,
768
+ postalCode: releaseGood.type == 'b2c' ? releaseGood?.postalCode : shippingOrderInfo.postalCode || null,
769
+ country: releaseGood.type == 'b2c' ? releaseGood?.country : shippingOrderInfo.country || null,
770
+ phone1: releaseGood.type == 'b2c' ? releaseGood?.phone1 : shippingOrderInfo.phone1 || null,
712
771
  phone2: releaseGood?.phone2 || null,
713
772
  email: releaseGood?.email || null,
714
- billingCity: releaseGood.type == 'b2c' ? releaseGood?.billingCity || null : shippingOrderInfo.billingCity || null,
773
+ billingCity: releaseGood.type == 'b2c' ? releaseGood?.billingCity : shippingOrderInfo.billingCity || null,
715
774
  billingCountry:
716
- releaseGood.type == 'b2c' ? releaseGood?.billingCountry || null : shippingOrderInfo.billingCountry || null,
775
+ releaseGood.type == 'b2c' ? releaseGood?.billingCountry : shippingOrderInfo.billingCountry || null,
717
776
  billingPostalCode:
718
777
  releaseGood.type == 'b2c'
719
778
  ? releaseGood?.billingPostalCode || null
720
779
  : shippingOrderInfo.billingPostalCode || null,
721
780
  billingState:
722
- releaseGood.type == 'b2c' ? releaseGood?.billingState || null : shippingOrderInfo.billingState || null,
781
+ releaseGood.type == 'b2c' ? releaseGood?.billingState : shippingOrderInfo.billingState || null,
723
782
  district: releaseGood.type == 'b2c' ? releaseGood?.city : null,
724
783
  transporter: releaseGood?.transporter,
725
784
  trackingNo: releaseGood?.trackingNo,
@@ -1536,6 +1595,7 @@ export async function bulkGenerateReleaseGood(
1536
1595
  deliveryAddress2: releaseGood?.deliveryAddress2 || null,
1537
1596
  deliveryAddress3: releaseGood?.deliveryAddress3 || null,
1538
1597
  deliveryAddress4: releaseGood?.deliveryAddress4 || null,
1598
+ deliveryAddress5: releaseGood?.deliveryAddress5 || null,
1539
1599
  attentionTo: releaseGood?.attentionTo || null,
1540
1600
  attentionCompany: releaseGood?.attentionCompany || null,
1541
1601
  city: releaseGood?.city || null,
@@ -1570,6 +1630,10 @@ export async function bulkGenerateReleaseGood(
1570
1630
  packingOption: releaseGood?.packingOption || false,
1571
1631
  courierOption: releaseGood?.courierOption || false,
1572
1632
  billingAddress: releaseGood?.billingAddress || null,
1633
+ billingAddress2: releaseGood?.billingAddress2 || null,
1634
+ billingAddress3: releaseGood?.billingAddress3 || null,
1635
+ billingAddress4: releaseGood?.billingAddress4 || null,
1636
+ billingAddress5: releaseGood?.billingAddress5 || null,
1573
1637
  billingCity: releaseGood?.billingCity || null,
1574
1638
  billingState: releaseGood?.billingState || null,
1575
1639
  billingPostalCode: releaseGood?.billingPostalCode ? releaseGood.billingPostalCode : null,
@@ -1833,6 +1897,7 @@ function extractRawReleaseGoods(rawReleaseGoods): Partial<ReleaseGood[]> {
1833
1897
  'deliveryAddress2',
1834
1898
  'deliveryAddress3',
1835
1899
  'deliveryAddress4',
1900
+ 'deliveryAddress5',
1836
1901
  'postalCode'
1837
1902
  ]
1838
1903
 
@@ -1884,8 +1949,13 @@ function extractRawReleaseGoods(rawReleaseGoods): Partial<ReleaseGood[]> {
1884
1949
  deliveryAddress2: item.deliveryAddress2,
1885
1950
  deliveryAddress3: item.deliveryAddress3,
1886
1951
  deliveryAddress4: item.deliveryAddress4,
1952
+ deliveryAddress5: item.deliveryAddress5,
1887
1953
  billingAddress: item.billingAddress,
1888
- billingCity: item.billingPostalCode,
1954
+ billingAddress2: item.billingAddress2,
1955
+ billingAddress3: item.billingAddress3,
1956
+ billingAddress4: item.billingAddress4,
1957
+ billingAddress5: item.billingAddress5,
1958
+ billingCity: item.billingCity,
1889
1959
  billingState: item.billingState,
1890
1960
  billingCountry: item.billingCountry,
1891
1961
  billingPostalCode: item.billingPostalCode,
@@ -2014,4 +2084,4 @@ async function autoAssignLmd(domain, countryId, postalCode, bizplace) {
2014
2084
  }
2015
2085
 
2016
2086
  return lmdResult
2017
- }
2087
+ }
@@ -1180,54 +1180,51 @@ function _extractData(rawData, validatedData) {
1180
1180
  return {
1181
1181
  ...raw,
1182
1182
  releaseUomValue,
1183
- errorMsg:
1184
- errMsg ? errMsg
1185
- : !raw.productId || !raw.productDetailId
1186
- ? 'inventory or product not found'
1187
- : raw.releaseQty <= 0 || raw.releaseQty % 1 !== 0
1188
- ? 'invalid release qty'
1189
- : raw.assignedQty < raw.releaseQty
1190
- ? 'insufficient stock'
1191
- : raw.releaseDate === ''
1192
- ? 'release date is empty'
1193
- : releaseDate < _getStdDateStr(new Date())
1194
- ? 'backdate is not allowed'
1195
- : !raw.refNo || raw.refNo === ''
1196
- ? 'ref no is empty'
1197
- : !Number.isInteger(raw.packingSize)
1198
- ? 'packing size must be an integer'
1199
- : raw?.type === 'b2c'
1200
- ? !raw.attentionTo
1201
- ? 'attention to is empty'
1202
- : !raw.postalCode
1203
- ? 'postal code is empty'
1204
- : !raw.country
1205
- ? 'country is empty'
1206
- : !raw.deliveryAddress1
1207
- ? 'delivery address 1 is empty'
1208
- : !raw.city
1209
- ? 'city is empty'
1210
- : !raw.phone1
1211
- ? 'contact is empty'
1212
- : !raw.state
1213
- ? 'state is empty'
1214
- : !raw.billingAddress
1215
- ? 'billing address is empty'
1216
- : !raw.billingPostalCode
1217
- ? 'billing postal code is empty'
1218
- : !raw.billingCity
1219
- ? 'billing city is empty'
1220
- : !raw.billingState
1221
- ? 'billing state is empty'
1222
- : !raw.billingCountry
1223
- ? 'billing country is empty'
1224
- : (raw.codOption && !raw.paidAmount) || raw.paidAmount < 0 || raw.paidAmount == null
1225
- ? 'invalid paid amount'
1226
- : raw.airwayBill && raw.lmdOption == true
1227
- ? 'kindly remove AWB as LMD is marked as true '
1228
- : ''
1229
- : ''
1230
- }
1183
+ errorMsg: (() => {
1184
+ const errors = [];
1185
+
1186
+ if (errMsg){
1187
+ errors.push(errMsg)
1188
+ }
1189
+ if (!raw.productId || !raw.productDetailId) {
1190
+ errors.push('inventory or product not found');
1191
+ }
1192
+ if (raw.releaseQty <= 0 || raw.releaseQty % 1 !== 0) {
1193
+ errors.push('invalid release qty');
1194
+ }
1195
+ if (raw.assignedQty < raw.releaseQty) {
1196
+ errors.push('insufficient stock');
1197
+ }
1198
+ if (raw.releaseDate === '') {
1199
+ errors.push('release date is empty');
1200
+ }
1201
+ if (releaseDate < _getStdDateStr(new Date())) {
1202
+ errors.push('backdate is not allowed');
1203
+ }
1204
+ if (!raw.refNo || raw.refNo === '') {
1205
+ errors.push('ref no is empty');
1206
+ }
1207
+
1208
+ if (raw?.type === 'b2c') {
1209
+ if (!raw.attentionTo) errors.push('attention to is empty');
1210
+ if (!raw.postalCode) errors.push('postal code is empty');
1211
+ if (!raw.country) errors.push('country is empty');
1212
+ if (!raw.deliveryAddress1) errors.push('delivery address 1 is empty');
1213
+ if (!raw.city) errors.push('city is empty');
1214
+ if (!raw.phone1) errors.push('contact is empty');
1215
+ if (!raw.state) errors.push('state is empty');
1216
+ if ((raw.codOption && !raw.paidAmount) || raw.paidAmount < 0 || raw.paidAmount == null) {
1217
+ errors.push('invalid paid amount');
1218
+ }
1219
+ if (raw.airwayBill && raw.lmdOption === true) {
1220
+ errors.push('kindly remove AWB as LMD is marked as true');
1221
+ }
1222
+ }
1223
+
1224
+ return errors.length > 0 ? errors.join(', ') : ''; // Combine all errors into a single string
1225
+ })(),
1226
+ };
1227
+
1231
1228
  })
1232
1229
  }
1233
1230
 
@@ -1254,4 +1251,4 @@ function _getStdDateStr(date) {
1254
1251
  date.setHours(date.getHours() + 8)
1255
1252
  return date.toISOString().split('T')[0]
1256
1253
  }
1257
- }
1254
+ }
@@ -1,6 +1,15 @@
1
- import { Field, Float, InputType, Int, ObjectType } from 'type-graphql'
2
-
3
- import { Product, ProductDetail } from '@things-factory/product-base'
1
+ import {
2
+ Field,
3
+ Float,
4
+ InputType,
5
+ Int,
6
+ ObjectType
7
+ } from 'type-graphql'
8
+
9
+ import {
10
+ Product,
11
+ ProductDetail
12
+ } from '@things-factory/product-base'
4
13
  import { ObjectRef } from '@things-factory/shell'
5
14
  import { Location } from '@things-factory/warehouse-base'
6
15
 
@@ -240,6 +249,18 @@ export class NewReleaseGood {
240
249
  @Field({ nullable: true })
241
250
  billingAddress: string
242
251
 
252
+ @Field({ nullable: true })
253
+ billingAddress2: string
254
+
255
+ @Field({ nullable: true })
256
+ billingAddress3: string
257
+
258
+ @Field({ nullable: true })
259
+ billingAddress4: string
260
+
261
+ @Field({ nullable: true })
262
+ billingAddress5: string
263
+
243
264
  @Field({ nullable: true })
244
265
  deliveryAddress1: string
245
266
 
@@ -520,6 +541,18 @@ export class ReleaseGoodPatch {
520
541
  @Field({ nullable: true })
521
542
  billingAddress: string
522
543
 
544
+ @Field({ nullable: true })
545
+ billingAddress2: string
546
+
547
+ @Field({ nullable: true })
548
+ billingAddress3: string
549
+
550
+ @Field({ nullable: true })
551
+ billingAddress4: string
552
+
553
+ @Field({ nullable: true })
554
+ billingAddress5: string
555
+
523
556
  @Field({ nullable: true })
524
557
  deliveryAddress1: string
525
558
 
@@ -628,9 +661,6 @@ export class ExportInformationPatch {
628
661
 
629
662
  @InputType()
630
663
  export class ShippingOrderInfoPatch {
631
- @Field({ nullable: true })
632
- billingAddress: string
633
-
634
664
  @Field({ nullable: true })
635
665
  billingCity: string
636
666
 
@@ -667,9 +697,36 @@ export class ShippingOrderInfoPatch {
667
697
  @Field({ nullable: true })
668
698
  attentionTo: string
669
699
 
700
+ @Field({ nullable: true })
701
+ billingAddress: string
702
+
703
+ @Field({ nullable: true })
704
+ billingAddress2: string
705
+
706
+ @Field({ nullable: true })
707
+ billingAddress3: string
708
+
709
+ @Field({ nullable: true })
710
+ billingAddress4: string
711
+
712
+ @Field({ nullable: true })
713
+ billingAddress5: string
714
+
670
715
  @Field({ nullable: true })
671
716
  deliveryAddress1: string
672
717
 
718
+ @Field({ nullable: true })
719
+ deliveryAddress2: string
720
+
721
+ @Field({ nullable: true })
722
+ deliveryAddress3: string
723
+
724
+ @Field({ nullable: true })
725
+ deliveryAddress4: string
726
+
727
+ @Field({ nullable: true })
728
+ deliveryAddress5: string
729
+
673
730
  @Field({ nullable: true })
674
731
  country: string
675
732
 
@@ -702,4 +759,4 @@ export class ShippingOrderInfoPatch {
702
759
 
703
760
  @Field({ nullable: true })
704
761
  ward: string
705
- }
762
+ }
@@ -1,4 +1,8 @@
1
- import { Field, ID, ObjectType } from 'type-graphql'
1
+ import {
2
+ Field,
3
+ ID,
4
+ ObjectType
5
+ } from 'type-graphql'
2
6
  import {
3
7
  Column,
4
8
  CreateDateColumn,
@@ -15,7 +19,10 @@ import {
15
19
 
16
20
  import { Attachment } from '@things-factory/attachment-base'
17
21
  import { User } from '@things-factory/auth-base'
18
- import { Bizplace, ContactPoint } from '@things-factory/biz-base'
22
+ import {
23
+ Bizplace,
24
+ ContactPoint
25
+ } from '@things-factory/biz-base'
19
26
  import { config } from '@things-factory/env'
20
27
  import { LastMileDelivery } from '@things-factory/integration-lmd'
21
28
  import { Domain } from '@things-factory/shell'
@@ -250,6 +257,22 @@ export class ReleaseGood {
250
257
  @Field({ nullable: true })
251
258
  billingAddress: string
252
259
 
260
+ @Column({ nullable: true })
261
+ @Field({ nullable: true })
262
+ billingAddress2: string
263
+
264
+ @Column({ nullable: true })
265
+ @Field({ nullable: true })
266
+ billingAddress3: string
267
+
268
+ @Column({ nullable: true })
269
+ @Field({ nullable: true })
270
+ billingAddress4: string
271
+
272
+ @Column({ nullable: true })
273
+ @Field({ nullable: true })
274
+ billingAddress5: string
275
+
253
276
  @Column({ nullable: true })
254
277
  @Field({ nullable: true })
255
278
  billingCountry: string
@@ -640,4 +663,4 @@ export class ReleaseGood {
640
663
  })
641
664
  @Field({ nullable: true })
642
665
  sourceData: string
643
- }
666
+ }