@things-factory/operato-hub 4.3.2 → 4.4.0-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/client/pages/constants/setting.js +0 -1
  2. package/config.development.js +49 -0
  3. package/dist-server/controllers/bizplace-initializer/dataset/codes.js +0 -9
  4. package/dist-server/controllers/bizplace-initializer/dataset/codes.js.map +1 -1
  5. package/dist-server/controllers/bizplace-initializer/dataset/index.js +5 -1
  6. package/dist-server/controllers/bizplace-initializer/dataset/index.js.map +1 -1
  7. package/dist-server/controllers/bizplace-initializer/dataset/settings.js +0 -10
  8. package/dist-server/controllers/bizplace-initializer/dataset/settings.js.map +1 -1
  9. package/dist-server/controllers/bizplace-initializer/index.js +5 -1
  10. package/dist-server/controllers/bizplace-initializer/index.js.map +1 -1
  11. package/dist-server/controllers/company-initializer/index.js +5 -1
  12. package/dist-server/controllers/company-initializer/index.js.map +1 -1
  13. package/dist-server/graphql/index.js +5 -1
  14. package/dist-server/graphql/index.js.map +1 -1
  15. package/dist-server/graphql/resolvers/index.js +5 -1
  16. package/dist-server/graphql/resolvers/index.js.map +1 -1
  17. package/dist-server/graphql/types/index.js +5 -1
  18. package/dist-server/graphql/types/index.js.map +1 -1
  19. package/dist-server/index.js +5 -1
  20. package/dist-server/index.js.map +1 -1
  21. package/dist-server/routers/api/restful-apis/unstable/add-marketplace-order.js +75 -85
  22. package/dist-server/routers/api/restful-apis/unstable/add-marketplace-order.js.map +1 -1
  23. package/dist-server/routers/api/restful-apis/unstable/add-release-order.js +35 -147
  24. package/dist-server/routers/api/restful-apis/unstable/add-release-order.js.map +1 -1
  25. package/dist-server/routers/api/restful-apis/unstable/index.js +0 -1
  26. package/dist-server/routers/api/restful-apis/unstable/index.js.map +1 -1
  27. package/dist-server/routers/api/restful-apis/v1/add-marketplace-order.js +75 -85
  28. package/dist-server/routers/api/restful-apis/v1/add-marketplace-order.js.map +1 -1
  29. package/dist-server/routers/api/restful-apis/v1/add-release-order.js +34 -146
  30. package/dist-server/routers/api/restful-apis/v1/add-release-order.js.map +1 -1
  31. package/dist-server/routers/api/restful-apis/v1/index.js +0 -1
  32. package/dist-server/routers/api/restful-apis/v1/index.js.map +1 -1
  33. package/dist-server/routers/api/restful-apis/v2/add-marketplace-order.js +75 -85
  34. package/dist-server/routers/api/restful-apis/v2/add-marketplace-order.js.map +1 -1
  35. package/dist-server/routers/api/restful-apis/v2/add-release-order.js +34 -149
  36. package/dist-server/routers/api/restful-apis/v2/add-release-order.js.map +1 -1
  37. package/dist-server/routers/api/restful-apis/v2/index.js +0 -1
  38. package/dist-server/routers/api/restful-apis/v2/index.js.map +1 -1
  39. package/dist-server/routers/business/index.js +5 -1
  40. package/dist-server/routers/business/index.js.map +1 -1
  41. package/dist-server/utils/index.js +5 -1
  42. package/dist-server/utils/index.js.map +1 -1
  43. package/package.json +54 -54
  44. package/server/controllers/bizplace-initializer/dataset/codes.ts +0 -9
  45. package/server/controllers/bizplace-initializer/dataset/settings.ts +0 -10
  46. package/server/routers/api/restful-apis/unstable/add-marketplace-order.ts +85 -97
  47. package/server/routers/api/restful-apis/unstable/add-release-order.ts +28 -211
  48. package/server/routers/api/restful-apis/unstable/index.ts +0 -1
  49. package/server/routers/api/restful-apis/v1/add-marketplace-order.ts +85 -97
  50. package/server/routers/api/restful-apis/v1/add-release-order.ts +26 -209
  51. package/server/routers/api/restful-apis/v1/index.ts +0 -1
  52. package/server/routers/api/restful-apis/v2/add-marketplace-order.ts +85 -97
  53. package/server/routers/api/restful-apis/v2/add-release-order.ts +26 -212
  54. package/server/routers/api/restful-apis/v2/index.ts +0 -1
  55. package/dist-server/routers/api/restful-apis/unstable/add-draft-release-order.js +0 -171
  56. package/dist-server/routers/api/restful-apis/unstable/add-draft-release-order.js.map +0 -1
  57. package/dist-server/routers/api/restful-apis/v1/add-draft-release-order.js +0 -171
  58. package/dist-server/routers/api/restful-apis/v1/add-draft-release-order.js.map +0 -1
  59. package/dist-server/routers/api/restful-apis/v2/add-draft-release-order.js +0 -171
  60. package/dist-server/routers/api/restful-apis/v2/add-draft-release-order.js.map +0 -1
  61. package/server/routers/api/restful-apis/unstable/add-draft-release-order.ts +0 -196
  62. package/server/routers/api/restful-apis/v1/add-draft-release-order.ts +0 -196
  63. package/server/routers/api/restful-apis/v2/add-draft-release-order.ts +0 -196
@@ -5,8 +5,6 @@
5
5
  import gql from 'graphql-tag'
6
6
 
7
7
  import { restfulApiRouter as router } from '@things-factory/api'
8
- import { EntityManager, getConnection } from 'typeorm'
9
- import { MarketplaceOrder } from '@things-factory/marketplace-base'
10
8
 
11
9
  import { businessMiddleware } from '../../../../middlewares/business-middleware'
12
10
  import { storeMiddleware } from '../../../../middlewares/store-middleware'
@@ -18,109 +16,99 @@ router.post(
18
16
  businessMiddleware,
19
17
  storeMiddleware,
20
18
  async (context, next) => {
21
- return await getConnection().transaction(async (tx: EntityManager) => {
22
- const { client, marketplaceStore, domain } = context.state
23
- const { t } = context
24
- const bodyReq = context.request.body
25
-
26
- if (typeof bodyReq === undefined || !Object.keys(bodyReq)?.length) {
27
- context.throw(400, t('error.invalid body request format'))
28
- }
29
-
30
- await checkMandatoryKey(context, bodyReq)
31
- debug('post:/add-marketplace-order body request', bodyReq)
32
-
33
- let existingMarketplaceOrder: MarketplaceOrder = await tx.getRepository(MarketplaceOrder).findOne({
34
- where: { name: bodyReq.name, domain, marketplaceStore }
35
- })
36
-
37
- if (existingMarketplaceOrder) {
38
- context.throw(400, `error.duplicate entry for order ${bodyReq.name}`)
39
- }
40
-
41
- context.body = {
42
- result: (
43
- await client.mutate({
44
- mutation: gql`
45
- mutation generateMarketplaceOrder($marketplaceOrder: NewMarketplaceOrder!) {
46
- generateMarketplaceOrder(marketplaceOrder: $marketplaceOrder) {
19
+ const { client, marketplaceStore, domain } = context.state
20
+ const { t } = context
21
+ const bodyReq = context.request.body
22
+
23
+ if (typeof bodyReq === undefined || !Object.keys(bodyReq)?.length) {
24
+ context.throw(400, t('error.invalid body request format'))
25
+ }
26
+
27
+ await checkMandatoryKey(context, bodyReq)
28
+ debug('post:/add-marketplace-order body request', bodyReq)
29
+
30
+ context.body = {
31
+ result: (
32
+ await client.mutate({
33
+ mutation: gql`
34
+ mutation generateMarketplaceOrder($marketplaceOrder: NewMarketplaceOrder!) {
35
+ generateMarketplaceOrder(marketplaceOrder: $marketplaceOrder) {
36
+ id
37
+ orderNo
38
+ currency
39
+ itemCount
40
+ totalAmount
41
+ paymentMethod
42
+ remark
43
+ giftOption
44
+ orderCreatedAt
45
+ orderUpdatedAt
46
+ marketplaceStore {
47
+ storeId
48
+ }
49
+ marketplaceOrderItems {
47
50
  id
48
- orderNo
49
- currency
50
- itemCount
51
- totalAmount
52
- paymentMethod
53
- remark
54
- giftOption
55
- orderCreatedAt
56
- orderUpdatedAt
57
- marketplaceStore {
58
- storeId
51
+ name
52
+ qty
53
+ cancelBy
54
+ returnStatus
55
+ paidPrice
56
+ packageId
57
+ invoiceNo
58
+ status
59
+ marketplaceOrderShippingItems {
60
+ marketplaceOrderShipping {
61
+ attentionTo
62
+ address1
63
+ address2
64
+ address3
65
+ address4
66
+ address5
67
+ state
68
+ city
69
+ postCode
70
+ country
71
+ phone1
72
+ phone2
73
+ email
74
+ orderType
75
+ freightType
76
+ parcelType
77
+ goodsType
78
+ deliveryMethod
79
+ totalWeight
80
+ totalVolume
81
+ transporter
82
+ }
59
83
  }
60
- marketplaceOrderItems {
84
+ marketplaceProductVariation {
61
85
  id
86
+ sku
87
+ variationId
88
+ variationSku
89
+ channelSku
62
90
  name
63
- qty
64
- cancelBy
65
- returnStatus
66
- paidPrice
67
- packageId
68
- invoiceNo
69
- status
70
- marketplaceOrderShippingItems {
71
- marketplaceOrderShipping {
72
- attentionTo
73
- address1
74
- address2
75
- address3
76
- address4
77
- address5
78
- state
79
- city
80
- postCode
81
- country
82
- phone1
83
- phone2
84
- email
85
- orderType
86
- freightType
87
- parcelType
88
- goodsType
89
- deliveryMethod
90
- totalWeight
91
- totalVolume
92
- transporter
93
- }
94
- }
95
- marketplaceProductVariation {
96
- id
97
- sku
98
- variationId
99
- variationSku
100
- channelSku
101
- name
102
- costPrice
103
- sellPrice
104
- marketplaceStatus
105
- }
91
+ costPrice
92
+ sellPrice
93
+ marketplaceStatus
106
94
  }
107
95
  }
108
96
  }
109
- `,
110
- variables: { marketplaceOrder: bodyReq },
111
- context: {
112
- ...context,
113
- state: {
114
- ...context.state,
115
- marketplaceStore,
116
- domain,
117
- type: 'api'
118
- }
119
97
  }
120
- } as any)
121
- ).data
122
- }
123
- })
98
+ `,
99
+ variables: { marketplaceOrder: bodyReq },
100
+ context: {
101
+ ...context,
102
+ state: {
103
+ ...context.state,
104
+ marketplaceStore,
105
+ domain,
106
+ type: 'api'
107
+ }
108
+ }
109
+ } as any)
110
+ ).data
111
+ }
124
112
  }
125
113
  )
126
114
 
@@ -257,37 +257,17 @@ router.post(
257
257
 
258
258
  if (!response.errors) {
259
259
  const items = response.data.inventoriesByPallet.items || []
260
- if (!items?.length) {
261
- context.body = {
262
- result: await createDraftOrder(
263
- client,
264
- customerBizplace,
265
- bodyReq,
266
- bundleInfo,
267
- domain,
268
- context,
269
- orderInventories,
270
- tx
260
+ if (!items?.length)
261
+ context.throw(
262
+ 404,
263
+ t(
264
+ `error.no inventories found for ${orderInventory.product?.sku} with batch ID ${orderInventory?.batchId}`
271
265
  )
272
- }
273
- return
274
- }
266
+ )
275
267
 
276
- items.forEach(async item => {
268
+ items.forEach(item => {
277
269
  if (orderInventory.releaseQty > item.remainQty || orderInventory.releaseQty <= 0) {
278
- context.body = {
279
- result: await createDraftOrder(
280
- client,
281
- customerBizplace,
282
- bodyReq,
283
- bundleInfo,
284
- domain,
285
- context,
286
- orderInventories,
287
- tx
288
- )
289
- }
290
- return
270
+ context.throw(404, t(`error.invalid release qty for ${orderInventory.product?.sku}`))
291
271
  }
292
272
 
293
273
  // 3. add more information to orderInventory
@@ -300,21 +280,7 @@ router.post(
300
280
  })
301
281
 
302
282
  return orderInventory
303
- } else {
304
- context.body = {
305
- result: await createDraftOrder(
306
- client,
307
- customerBizplace,
308
- bodyReq,
309
- bundleInfo,
310
- domain,
311
- context,
312
- orderInventories,
313
- tx
314
- )
315
- }
316
- return
317
- }
283
+ } else context.throw(404, t('error.failed to fetch inventory'))
318
284
  })
319
285
  )
320
286
  } else {
@@ -399,21 +365,8 @@ router.post(
399
365
  }
400
366
 
401
367
  let inventories: Inventory[] = await qb.getMany()
402
- if (!inventories?.length) {
403
- context.body = {
404
- result: await createDraftOrder(
405
- client,
406
- customerBizplace,
407
- bodyReq,
408
- bundleInfo,
409
- domain,
410
- context,
411
- orderInventories,
412
- tx
413
- )
414
- }
415
- return
416
- }
368
+ if (!inventories?.length) context.throw(404, t(`error.no inventories found for ${product.sku}`))
369
+
417
370
  inventories = inventories
418
371
  .map(inventory => {
419
372
  return {
@@ -424,27 +377,12 @@ router.post(
424
377
  })
425
378
  .filter(inventory => inventory.remainQty > 0)
426
379
 
427
- let targetInventories: WorksheetDetail[]
428
- try {
429
- targetInventories = _composeTargetInventories(context, product, orderInventory, inventories)
430
- } catch (e) {
431
- context.body = {
432
- result: await createDraftOrder(
433
- client,
434
- customerBizplace,
435
- bodyReq,
436
- bundleInfo,
437
- domain,
438
- context,
439
- orderInventories,
440
- tx
441
- )
442
- }
443
- return
444
- }
445
- targetInventories.map(item => {
446
- finalOrderInventories.push(item.targetInventory)
447
- })
380
+ const targetInventories: WorksheetDetail[] = _composeTargetInventories(
381
+ context,
382
+ product,
383
+ orderInventory,
384
+ inventories
385
+ )
448
386
  targetInventories.map(item => {
449
387
  finalOrderInventories.push(item.targetInventory)
450
388
  })
@@ -493,37 +431,17 @@ router.post(
493
431
 
494
432
  if (!response.errors) {
495
433
  const items = response.data.inventoryProductGroup.items || []
496
- if (!items?.length) {
497
- context.body = {
498
- result: await createDraftOrder(
499
- client,
500
- customerBizplace,
501
- bodyReq,
502
- bundleInfo,
503
- domain,
504
- context,
505
- orderInventories,
506
- tx
434
+ if (!items?.length)
435
+ context.throw(
436
+ 404,
437
+ t(
438
+ `error.no inventories found for ${orderInventory.product?.sku} with batch ID ${orderInventory?.batchId}`
507
439
  )
508
- }
509
- return
510
- }
440
+ )
511
441
 
512
- items.forEach(async item => {
442
+ items.forEach(item => {
513
443
  if (orderInventory.releaseQty > item.remainQty || orderInventory.releaseQty <= 0) {
514
- context.body = {
515
- result: await createDraftOrder(
516
- client,
517
- customerBizplace,
518
- bodyReq,
519
- bundleInfo,
520
- domain,
521
- context,
522
- orderInventories,
523
- tx
524
- )
525
- }
526
- return
444
+ context.throw(404, t(`error.invalid release qty for ${orderInventory.product?.sku}`))
527
445
  }
528
446
 
529
447
  // 3. add more information to orderInventory
@@ -537,21 +455,7 @@ router.post(
537
455
 
538
456
  delete orderInventory.uomValue
539
457
  finalOrderInventories.push(orderInventory)
540
- } else {
541
- context.body = {
542
- result: await createDraftOrder(
543
- client,
544
- customerBizplace,
545
- bodyReq,
546
- bundleInfo,
547
- domain,
548
- context,
549
- orderInventories,
550
- tx
551
- )
552
- }
553
- return
554
- }
458
+ } else context.throw(404, t('error.failed to fetch inventory'))
555
459
  }
556
460
  }
557
461
  }
@@ -825,93 +729,3 @@ function combineItems(inventoryList) {
825
729
 
826
730
  return mappedList
827
731
  }
828
-
829
- async function createDraftOrder(client, customerBizplace, bodyReq, bundleInfo, domain, context, orderInventories, tx) {
830
- return (
831
- await client.mutate({
832
- mutation: gql`
833
- mutation upsertDraftReleaseGood(
834
- $draftReleaseGood: DraftReleaseGoodPatch!
835
- $orderProducts: [OrderProductPatch!]!
836
- ) {
837
- upsertDraftReleaseGood(draftReleaseGood: $draftReleaseGood, orderProducts: $orderProducts) {
838
- id
839
- name
840
- refNo
841
- refNo2
842
- status
843
- truckNo
844
- ownTransport
845
- marketplaceOrderStatus
846
- billingAddress
847
- deliveryAddress1
848
- deliveryAddress2
849
- deliveryAddress3
850
- deliveryAddress4
851
- deliveryAddress5
852
- attentionTo
853
- attentionCompany
854
- city
855
- state
856
- postalCode
857
- country
858
- phone1
859
- phone2
860
- email
861
- type
862
- exportOption
863
- releaseDate
864
- collectionOrderNo
865
- bizplace {
866
- name
867
- }
868
- }
869
- }
870
- `,
871
- variables: {
872
- draftReleaseGood: {
873
- bizplace: {
874
- id: customerBizplace.id
875
- },
876
- courierOption: bodyReq.courierOption,
877
- collectionOrderNo: bodyReq.collectionOrderNo,
878
- exportOption: bodyReq.exportOption,
879
- ownTransport: bodyReq.ownTransport,
880
- packingOption: bodyReq.packingOption,
881
- refNo: bodyReq.refNo,
882
- refNo2: bodyReq?.refNo2,
883
- releaseDate: bodyReq.releaseDate,
884
- type: bodyReq.type,
885
- marketplaceOrderStatus: bodyReq?.marketplaceOrderStatus,
886
- remark: bodyReq?.remark || null,
887
- billingAddress: bodyReq?.billTo?.billingAddress || null,
888
- deliveryAddress1: bodyReq?.deliverTo?.deliveryAddress1 || null,
889
- deliveryAddress2: bodyReq?.deliverTo?.deliveryAddress2 || null,
890
- deliveryAddress3: bodyReq?.deliverTo?.deliveryAddress3 || null,
891
- deliveryAddress4: bodyReq?.deliverTo?.deliveryAddress4 || null,
892
- deliveryAddress5: bodyReq?.deliverTo?.deliveryAddress5 || null,
893
- attentionTo: bodyReq?.deliverTo?.attentionTo || null,
894
- attentionCompany: bodyReq?.deliverTo?.attentionCompany || null,
895
- city: bodyReq?.deliverTo?.city || null,
896
- state: bodyReq?.deliverTo?.state || null,
897
- postalCode: bodyReq?.deliverTo?.postalCode || null,
898
- country: bodyReq?.deliverTo?.country || null,
899
- phone1: bodyReq?.deliverTo?.phone1 || null,
900
- phone2: bodyReq?.deliverTo?.phone2 || null,
901
- email: bodyReq?.deliverTo?.email || null
902
- },
903
- orderProducts: orderInventories
904
- },
905
- context: {
906
- ...context,
907
- hasUpload: true,
908
- state: {
909
- ...context.state,
910
- customerBizplace,
911
- domain,
912
- type: 'api'
913
- }
914
- }
915
- } as any)
916
- ).data
917
- }
@@ -2,7 +2,6 @@ import './add-contact-point'
2
2
  import './add-inbound-order'
3
3
  import './add-marketplace-order'
4
4
  import './add-products'
5
- import './add-draft-release-order'
6
5
  import './add-release-order'
7
6
  import './bizplace'
8
7
  import './reject-inbound-order'
@@ -1,171 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.checkMandatoryKey = void 0;
7
- const graphql_tag_1 = __importDefault(require("graphql-tag"));
8
- const typeorm_1 = require("typeorm");
9
- const api_1 = require("@things-factory/api");
10
- const biz_base_1 = require("@things-factory/biz-base");
11
- const business_middleware_1 = require("../../../../middlewares/business-middleware");
12
- const warehouse_middleware_1 = require("../../../../middlewares/warehouse-middleware");
13
- const debug = require('debug')('things-factory:operato-hub:restful-api:unstable:add-draft-release-order');
14
- api_1.restfulApiRouter.post('/unstable/warehouse/:warehouseId/add-draft-release-order', business_middleware_1.businessMiddleware, warehouse_middleware_1.warehouseMiddleware, async (context, next) => {
15
- return await (0, typeorm_1.getConnection)().transaction(async (tx) => {
16
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
17
- const { client, domain } = context.state;
18
- const { warehouseId: customerBizplaceId } = context.params;
19
- const { t } = context;
20
- if (!customerBizplaceId)
21
- context.throw(404, t('error.warehouse id not found'));
22
- let bodyReq = context.request.body;
23
- if (typeof bodyReq === undefined || !((_a = Object.keys(bodyReq)) === null || _a === void 0 ? void 0 : _a.length)) {
24
- context.throw(400, t('error.invalid body request format'));
25
- }
26
- debug('post:/add-draft-release-order request.body', bodyReq);
27
- await checkMandatoryKey(context, bodyReq);
28
- // get customer company's bizplace
29
- const customerBizplace = await tx.getRepository(biz_base_1.Bizplace).findOne({
30
- where: { id: customerBizplaceId }
31
- });
32
- const orderInventories = bodyReq.orderInventories;
33
- context.body = {
34
- result: (await client.mutate({
35
- mutation: (0, graphql_tag_1.default) `
36
- mutation upsertDraftReleaseGood(
37
- $draftReleaseGood: DraftReleaseGoodPatch!
38
- $orderProducts: [OrderProductPatch!]!
39
- $files: [Upload!]
40
- ) {
41
- upsertDraftReleaseGood(
42
- draftReleaseGood: $draftReleaseGood
43
- orderProducts: $orderProducts
44
- files: $files
45
- ) {
46
- id
47
- name
48
- refNo
49
- refNo2
50
- refNo3
51
- status
52
- truckNo
53
- ownTransport
54
- marketplaceOrderStatus
55
- billingAddress
56
- deliveryAddress1
57
- deliveryAddress2
58
- deliveryAddress3
59
- deliveryAddress4
60
- deliveryAddress5
61
- attentionTo
62
- attentionCompany
63
- city
64
- state
65
- postalCode
66
- country
67
- phone1
68
- phone2
69
- email
70
- type
71
- exportOption
72
- releaseDate
73
- collectionOrderNo
74
- bizplace {
75
- name
76
- }
77
- orderProducts {
78
- product {
79
- sku
80
- name
81
- description
82
- }
83
- packingType
84
- packingSize
85
- releaseQty
86
- }
87
- }
88
- }
89
- `,
90
- variables: {
91
- draftReleaseGood: {
92
- bizplace: {
93
- id: customerBizplace.id
94
- },
95
- courierOption: bodyReq.courierOption,
96
- collectionOrderNo: bodyReq.collectionOrderNo,
97
- exportOption: bodyReq.exportOption,
98
- ownTransport: bodyReq.ownTransport,
99
- packingOption: bodyReq.packingOption,
100
- refNo: bodyReq.refNo,
101
- refNo2: bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.refNo2,
102
- refNo3: bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.refNo3,
103
- releaseDate: bodyReq.releaseDate,
104
- type: bodyReq.type,
105
- marketplaceOrderStatus: bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.marketplaceOrderStatus,
106
- remark: (bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.remark) || null,
107
- billingAddress: ((_b = bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.billTo) === null || _b === void 0 ? void 0 : _b.billingAddress) || null,
108
- deliveryAddress1: ((_c = bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.deliverTo) === null || _c === void 0 ? void 0 : _c.deliveryAddress1) || null,
109
- deliveryAddress2: ((_d = bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.deliverTo) === null || _d === void 0 ? void 0 : _d.deliveryAddress2) || null,
110
- deliveryAddress3: ((_e = bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.deliverTo) === null || _e === void 0 ? void 0 : _e.deliveryAddress3) || null,
111
- deliveryAddress4: ((_f = bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.deliverTo) === null || _f === void 0 ? void 0 : _f.deliveryAddress4) || null,
112
- deliveryAddress5: ((_g = bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.deliverTo) === null || _g === void 0 ? void 0 : _g.deliveryAddress5) || null,
113
- attentionTo: ((_h = bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.deliverTo) === null || _h === void 0 ? void 0 : _h.attentionTo) || null,
114
- attentionCompany: ((_j = bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.deliverTo) === null || _j === void 0 ? void 0 : _j.attentionCompany) || null,
115
- city: ((_k = bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.deliverTo) === null || _k === void 0 ? void 0 : _k.city) || null,
116
- state: ((_l = bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.deliverTo) === null || _l === void 0 ? void 0 : _l.state) || null,
117
- postalCode: ((_m = bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.deliverTo) === null || _m === void 0 ? void 0 : _m.postalCode) || null,
118
- country: ((_o = bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.deliverTo) === null || _o === void 0 ? void 0 : _o.country) || null,
119
- phone1: ((_p = bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.deliverTo) === null || _p === void 0 ? void 0 : _p.phone1) || null,
120
- phone2: ((_q = bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.deliverTo) === null || _q === void 0 ? void 0 : _q.phone2) || null,
121
- email: ((_r = bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.deliverTo) === null || _r === void 0 ? void 0 : _r.email) || null
122
- },
123
- orderProducts: orderInventories,
124
- files: []
125
- },
126
- context: Object.assign(Object.assign({}, context), { hasUpload: true, state: Object.assign(Object.assign({}, context.state), { customerBizplace,
127
- domain, type: 'api' }) })
128
- })).data
129
- };
130
- });
131
- });
132
- async function checkMandatoryKey(context, params) {
133
- let noparams = ['releaseDate', 'exportOption'].filter(param => !(param in params));
134
- if ('ownTransport' in params) {
135
- if (params.ownTransport == true) {
136
- if (!params.hasOwnProperty('collectionOrderNo')) {
137
- noparams.push('collectionOrderNo');
138
- }
139
- }
140
- }
141
- else {
142
- noparams.push('ownTransport');
143
- }
144
- if ('exportOption' in params) {
145
- if (params.exportOption === true) {
146
- if (params.exportOption.filter(record => !record.containerNo || !record.containerArrivalDate || !record.containerLeavingDate || !record.shipName).length) {
147
- noparams.push('exportOption');
148
- }
149
- }
150
- }
151
- if ('orderInventories' in params) {
152
- params.orderInventories.forEach((param, key) => {
153
- let noSubParams = [];
154
- if (!(param === null || param === void 0 ? void 0 : param.releaseQty))
155
- noSubParams.push('releaseQty');
156
- if (!(param === null || param === void 0 ? void 0 : param.product))
157
- noSubParams.push('product');
158
- if (noSubParams === null || noSubParams === void 0 ? void 0 : noSubParams.length)
159
- context.throw(400, context.t('error.required param x not found', { x: `${noSubParams.join(', ')}` }));
160
- });
161
- }
162
- else {
163
- noparams.push('orderInventories');
164
- }
165
- if (noparams === null || noparams === void 0 ? void 0 : noparams.length) {
166
- context.throw(400, context.t('error.required param x not found', { x: `${noparams.join(', ')}` }));
167
- }
168
- return params;
169
- }
170
- exports.checkMandatoryKey = checkMandatoryKey;
171
- //# sourceMappingURL=add-draft-release-order.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"add-draft-release-order.js","sourceRoot":"","sources":["../../../../../server/routers/api/restful-apis/unstable/add-draft-release-order.ts"],"names":[],"mappings":";;;;;;AAAA,8DAA6B;AA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