@things-factory/operato-hub 3.7.13 → 3.8.1

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 (46) hide show
  1. package/dist-server/controllers/bizplace-initializer/dataset/settings.js +5 -0
  2. package/dist-server/controllers/bizplace-initializer/dataset/settings.js.map +1 -1
  3. package/dist-server/graphql/resolvers/synchronization/fetch-sync-purchase-orders.js +3 -5
  4. package/dist-server/graphql/resolvers/synchronization/fetch-sync-purchase-orders.js.map +1 -1
  5. package/dist-server/routers/api/restful-apis/unstable/add-release-order.js +3 -1
  6. package/dist-server/routers/api/restful-apis/unstable/add-release-order.js.map +1 -1
  7. package/dist-server/routers/api/restful-apis/unstable/get-marketplace-order-shipping-list.js +11 -19
  8. package/dist-server/routers/api/restful-apis/unstable/get-marketplace-order-shipping-list.js.map +1 -1
  9. package/dist-server/routers/api/restful-apis/unstable/index.js +1 -0
  10. package/dist-server/routers/api/restful-apis/unstable/index.js.map +1 -1
  11. package/dist-server/routers/api/restful-apis/unstable/update-release-order-details.js +82 -0
  12. package/dist-server/routers/api/restful-apis/unstable/update-release-order-details.js.map +1 -0
  13. package/dist-server/routers/api/restful-apis/v1/add-release-order.js +3 -1
  14. package/dist-server/routers/api/restful-apis/v1/add-release-order.js.map +1 -1
  15. package/dist-server/routers/api/restful-apis/v1/get-marketplace-order-shipping-list.js +13 -22
  16. package/dist-server/routers/api/restful-apis/v1/get-marketplace-order-shipping-list.js.map +1 -1
  17. package/dist-server/routers/api/restful-apis/v1/index.js +1 -0
  18. package/dist-server/routers/api/restful-apis/v1/index.js.map +1 -1
  19. package/dist-server/routers/api/restful-apis/v1/update-release-order-details.js +82 -0
  20. package/dist-server/routers/api/restful-apis/v1/update-release-order-details.js.map +1 -0
  21. package/dist-server/routers/api/restful-apis/v2/add-release-order.js +3 -1
  22. package/dist-server/routers/api/restful-apis/v2/add-release-order.js.map +1 -1
  23. package/dist-server/routers/api/restful-apis/v2/get-marketplace-order-shipping-list.js +13 -22
  24. package/dist-server/routers/api/restful-apis/v2/get-marketplace-order-shipping-list.js.map +1 -1
  25. package/dist-server/routers/api/restful-apis/v2/index.js +1 -0
  26. package/dist-server/routers/api/restful-apis/v2/index.js.map +1 -1
  27. package/dist-server/routers/api/restful-apis/v2/update-release-order-details.js +82 -0
  28. package/dist-server/routers/api/restful-apis/v2/update-release-order-details.js.map +1 -0
  29. package/openapi/unstable/outbound.yaml +85 -0
  30. package/openapi/v1/outbound.yaml +85 -0
  31. package/openapi/v2/outbound.yaml +85 -0
  32. package/package.json +39 -39
  33. package/server/controllers/bizplace-initializer/dataset/settings.ts +5 -0
  34. package/server/graphql/resolvers/synchronization/fetch-sync-purchase-orders.ts +3 -5
  35. package/server/routers/api/restful-apis/unstable/add-release-order.ts +4 -2
  36. package/server/routers/api/restful-apis/unstable/get-marketplace-order-shipping-list.ts +12 -12
  37. package/server/routers/api/restful-apis/unstable/index.ts +1 -0
  38. package/server/routers/api/restful-apis/unstable/update-release-order-details.ts +94 -0
  39. package/server/routers/api/restful-apis/v1/add-release-order.ts +4 -2
  40. package/server/routers/api/restful-apis/v1/get-marketplace-order-shipping-list.ts +14 -15
  41. package/server/routers/api/restful-apis/v1/index.ts +1 -0
  42. package/server/routers/api/restful-apis/v1/update-release-order-details.ts +94 -0
  43. package/server/routers/api/restful-apis/v2/add-release-order.ts +4 -2
  44. package/server/routers/api/restful-apis/v2/get-marketplace-order-shipping-list.ts +14 -15
  45. package/server/routers/api/restful-apis/v2/index.ts +1 -0
  46. package/server/routers/api/restful-apis/v2/update-release-order-details.ts +94 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/operato-hub",
3
- "version": "3.7.13",
3
+ "version": "3.8.1",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "client/index.js",
6
6
  "things-factory": true,
@@ -41,40 +41,40 @@
41
41
  "@material/mwc-formfield": "^0.22.1",
42
42
  "@material/mwc-linear-progress": "^0.22.1",
43
43
  "@material/mwc-radio": "^0.22.1",
44
- "@things-factory/api": "^3.7.5",
45
- "@things-factory/apptool-ui": "^3.7.5",
46
- "@things-factory/attachment-base": "^3.7.5",
47
- "@things-factory/auth-base": "^3.7.5",
48
- "@things-factory/auth-ui": "^3.7.7",
49
- "@things-factory/biz-base": "^3.7.5",
50
- "@things-factory/biz-ui": "^3.7.5",
51
- "@things-factory/board-service": "^3.7.5",
52
- "@things-factory/board-ui": "^3.7.5",
53
- "@things-factory/code-ui": "^3.7.5",
44
+ "@things-factory/api": "^3.8.0",
45
+ "@things-factory/apptool-ui": "^3.8.0",
46
+ "@things-factory/attachment-base": "^3.8.0",
47
+ "@things-factory/auth-base": "^3.8.0",
48
+ "@things-factory/auth-ui": "^3.8.0",
49
+ "@things-factory/biz-base": "^3.8.0",
50
+ "@things-factory/biz-ui": "^3.8.0",
51
+ "@things-factory/board-service": "^3.8.0",
52
+ "@things-factory/board-ui": "^3.8.0",
53
+ "@things-factory/code-ui": "^3.8.0",
54
54
  "@things-factory/component-ui": "^3.7.5",
55
- "@things-factory/context-ui": "^3.7.5",
56
- "@things-factory/document-template-ui": "^3.7.5",
57
- "@things-factory/export-ui": "^3.7.5",
58
- "@things-factory/export-ui-csv": "^3.7.5",
59
- "@things-factory/export-ui-excel": "^3.7.5",
55
+ "@things-factory/context-ui": "^3.8.0",
56
+ "@things-factory/document-template-ui": "^3.8.0",
57
+ "@things-factory/export-ui": "^3.8.0",
58
+ "@things-factory/export-ui-csv": "^3.8.0",
59
+ "@things-factory/export-ui-excel": "^3.8.0",
60
60
  "@things-factory/grist-ui": "^3.7.5",
61
- "@things-factory/i18n-base": "^3.7.5",
62
- "@things-factory/i18n-ui": "^3.7.5",
63
- "@things-factory/import-ui": "^3.7.5",
64
- "@things-factory/import-ui-excel": "^3.7.5",
65
- "@things-factory/integration-accounting": "^3.7.13",
66
- "@things-factory/integration-fulfillment": "^3.7.7",
67
- "@things-factory/integration-lmd": "^3.7.11",
68
- "@things-factory/integration-marketplace": "^3.7.11",
69
- "@things-factory/integration-pos": "^3.7.7",
70
- "@things-factory/integration-sellercraft": "^3.7.7",
71
- "@things-factory/lite-menu": "^3.7.5",
72
- "@things-factory/more-ui": "^3.7.5",
73
- "@things-factory/notification": "^3.7.5",
61
+ "@things-factory/i18n-base": "^3.8.0",
62
+ "@things-factory/i18n-ui": "^3.8.0",
63
+ "@things-factory/import-ui": "^3.8.0",
64
+ "@things-factory/import-ui-excel": "^3.8.0",
65
+ "@things-factory/integration-accounting": "^3.8.1",
66
+ "@things-factory/integration-fulfillment": "^3.8.0",
67
+ "@things-factory/integration-lmd": "^3.8.0",
68
+ "@things-factory/integration-marketplace": "^3.8.0",
69
+ "@things-factory/integration-pos": "^3.8.0",
70
+ "@things-factory/integration-sellercraft": "^3.8.0",
71
+ "@things-factory/lite-menu": "^3.8.0",
72
+ "@things-factory/more-ui": "^3.8.0",
73
+ "@things-factory/notification": "^3.8.0",
74
74
  "@things-factory/pdf": "^3.7.5",
75
- "@things-factory/product-ui": "^3.7.13",
76
- "@things-factory/resource-ui": "^3.7.7",
77
- "@things-factory/sales-base": "^3.7.13",
75
+ "@things-factory/product-ui": "^3.8.1",
76
+ "@things-factory/resource-ui": "^3.8.0",
77
+ "@things-factory/sales-base": "^3.8.1",
78
78
  "@things-factory/scene-chartjs": "^3.7.5",
79
79
  "@things-factory/scene-clock": "^3.7.5",
80
80
  "@things-factory/scene-clone": "^3.7.5",
@@ -88,7 +88,7 @@
88
88
  "@things-factory/scene-graphql": "^3.7.5",
89
89
  "@things-factory/scene-half-roundrect": "^3.7.5",
90
90
  "@things-factory/scene-indoor-map": "^3.7.5",
91
- "@things-factory/scene-label": "^3.7.7",
91
+ "@things-factory/scene-label": "^3.8.0",
92
92
  "@things-factory/scene-legend": "^3.7.5",
93
93
  "@things-factory/scene-marker": "^3.7.5",
94
94
  "@things-factory/scene-mqtt": "^3.7.5",
@@ -101,11 +101,11 @@
101
101
  "@things-factory/scene-table": "^3.7.5",
102
102
  "@things-factory/scene-visualizer": "^3.7.5",
103
103
  "@things-factory/scene-wheel-sorter": "^3.7.5",
104
- "@things-factory/setting-ui": "^3.7.5",
105
- "@things-factory/shell": "^3.7.5",
106
- "@things-factory/system-ui": "^3.7.5",
107
- "@things-factory/warehouse-base": "^3.7.13",
108
- "@things-factory/worksheet-base": "^3.7.13",
104
+ "@things-factory/setting-ui": "^3.8.0",
105
+ "@things-factory/shell": "^3.8.0",
106
+ "@things-factory/system-ui": "^3.8.0",
107
+ "@things-factory/warehouse-base": "^3.8.1",
108
+ "@things-factory/worksheet-base": "^3.8.1",
109
109
  "koa2-swagger-ui": "^5.0.2",
110
110
  "swagger-jsdoc": "^5.0.0",
111
111
  "yamljs": "^0.3.0"
@@ -116,5 +116,5 @@
116
116
  "resolutions": {
117
117
  "core-js": "^3.16.0"
118
118
  },
119
- "gitHead": "48a64e051ed22ee4f0cbf11052a96bd17eef3b0d"
119
+ "gitHead": "2f2534de2c0866a693f6ec9949b35a5a0e65065f"
120
120
  }
@@ -48,6 +48,11 @@ export const SETTINGS = {
48
48
  name: 'hide-cc-columns',
49
49
  description: 'hide cycle count info for blind count. true - blind count , false - normal count',
50
50
  category: 'id-rule'
51
+ },
52
+ {
53
+ name: 'allow-ro-add-product',
54
+ description: 'allow edit release order product',
55
+ category: 'id-rule'
51
56
  }
52
57
  ],
53
58
  retail: []
@@ -51,8 +51,8 @@ export async function createInboundOrder(
51
51
  purchaseOrders: any[],
52
52
  customerBizplaceId: string
53
53
  ) {
54
- try {
55
- for (var i = 0; i < purchaseOrders.length; i++) {
54
+ for (var i = 0; i < purchaseOrders.length; i++) {
55
+ try {
56
56
  const purchaseOrder = purchaseOrders[i]
57
57
 
58
58
  const existingArrivalNotice = await FulfillmentAPI.getInboundOrder(fulfilmentCenter, {
@@ -67,8 +67,6 @@ export async function createInboundOrder(
67
67
  purchaseOrder
68
68
  })
69
69
  }
70
- }
71
- } catch (e) {
72
- throw new Error(e)
70
+ } catch (e) {}
73
71
  }
74
72
  }
@@ -6,7 +6,7 @@ import { Bizplace, getCompanyBizplace } from '@things-factory/biz-base'
6
6
  import { Product, ProductBundle, ProductDetail } from '@things-factory/product-base'
7
7
  import { ORDER_TYPES, OrderInventory } from '@things-factory/sales-base'
8
8
  import { Setting } from '@things-factory/setting-base'
9
- import { Inventory, INVENTORY_STATUS } from '@things-factory/warehouse-base'
9
+ import { Inventory, INVENTORY_STATUS, LOCATION_TYPE } from '@things-factory/warehouse-base'
10
10
  import { WorksheetDetail } from '@things-factory/worksheet-base'
11
11
 
12
12
  import { businessMiddleware } from '../../../../middlewares/business-middleware'
@@ -255,12 +255,14 @@ router.post(
255
255
  .andWhere('"iv"."packing_type" = :packingType')
256
256
  .andWhere('"iv"."product_id" = :productId')
257
257
  .andWhere('"iv"."status" = :status')
258
+ .andWhere('"loc"."type" NOT IN (:...locationTypes)')
258
259
  .setParameters({
259
260
  domainId: domain.id,
260
261
  bizplaceId: customerBizplace.id,
261
262
  packingType: packingType,
262
263
  productId: product.id,
263
- status: INVENTORY_STATUS.STORED
264
+ status: INVENTORY_STATUS.STORED,
265
+ locationTypes: [LOCATION_TYPE.QUARANTINE, LOCATION_TYPE.RESERVE]
264
266
  })
265
267
 
266
268
  if (locationSortingRules?.length > 0) {
@@ -15,7 +15,7 @@ router.get(
15
15
  const { shippingNo, orderNo, status, fromDate, toDate, paginationEntriesPerPage, paginationOffset } = context.query
16
16
 
17
17
  let filters: any = [
18
- { name: 'marketplaceStore', operator: 'eq', value: marketplaceStore?.id, relation: true },
18
+ { name: 'marketplace_store_id', operator: 'eq', value: marketplaceStore?.id, relation: true },
19
19
  { name: 'domain', operator: 'eq', value: domain.id, relation: true }
20
20
  ]
21
21
  let pagination: any = { page: 1, limit: 20 }
@@ -105,17 +105,17 @@ export async function validateFilters(context, filters, shippingNo, orderNo, sta
105
105
 
106
106
  if (status && status !== '') filters = [...filters, { name: 'status', operator: 'eq', value: status }]
107
107
 
108
- if (fromDate && fromDate !== '') {
109
- fromDate = new Date(`${fromDate.split(' ').join('')} 00:00:00`)
110
- if (fromDate instanceof Date && !isNaN(fromDate.getTime())) fromDate = fromDate.toLocaleString()
111
- else context.throw(400, context.t('fromDate is invalid'))
112
- } else fromDate = ''
113
-
114
- if (toDate && toDate !== '') {
115
- toDate = new Date(`${toDate.split(' ').join('')} 23:59:59`)
116
- if (toDate instanceof Date && !isNaN(toDate.getTime())) toDate = toDate.toLocaleString()
117
- else context.throw(400, context.t('toDate is invalid'))
118
- } else toDate = ''
108
+ // if (fromDate && fromDate !== '') {
109
+ // fromDate = new Date(`${fromDate.split(' ').join('')} 00:00:00`)
110
+ // // if (fromDate instanceof Date && !isNaN(fromDate.getTime())) fromDate = fromDate.toLocaleString()
111
+ // // else context.throw(400, context.t('fromDate is invalid'))
112
+ // } else fromDate = ''
113
+
114
+ // if (toDate && toDate !== '') {
115
+ // toDate = new Date(`${toDate.split(' ').join('')} 23:59:59`)
116
+ // // if (toDate instanceof Date && !isNaN(toDate.getTime())) toDate = toDate.toLocaleString()
117
+ // // else context.throw(400, context.t('toDate is invalid'))
118
+ // } else toDate = ''
119
119
 
120
120
  if (fromDate !== '' && toDate !== '')
121
121
  filters = [...filters, { name: 'createdAt', operator: 'between', value: [fromDate, toDate] }]
@@ -24,3 +24,4 @@ import './set-marketplace-order-delivered'
24
24
  import './set-marketplace-order-failed-delivery'
25
25
  import './update-marketplace-order'
26
26
  import './update-marketplace-shipping-order'
27
+ import './update-release-order-details'
@@ -0,0 +1,94 @@
1
+ import gql from 'graphql-tag'
2
+ import { getRepository } from 'typeorm'
3
+
4
+ import { restfulApiRouter as router } from '@things-factory/api'
5
+ import { Bizplace } from '@things-factory/biz-base'
6
+
7
+ import { businessMiddleware } from '../../../../middlewares/business-middleware'
8
+ import { warehouseMiddleware } from '../../../../middlewares/warehouse-middleware'
9
+
10
+ const debug = require('debug')('things-factory:operato-hub:restful-api:unstable:update-release-order-details')
11
+
12
+ router.post(
13
+ '/unstable/warehouse/:warehouseId/update-release-order-details',
14
+ businessMiddleware,
15
+ warehouseMiddleware,
16
+ async (context, next) => {
17
+ const { client, domain } = context.state
18
+ const { warehouseId: customerBizplaceId } = context.params
19
+ const { t } = context
20
+ const bodyReq = context.request.body
21
+
22
+ if (!customerBizplaceId) context.throw(404, t('error.warehouse id not found'))
23
+ const customerBizplace: Bizplace = await getRepository(Bizplace).findOne({
24
+ where: { id: customerBizplaceId }
25
+ })
26
+
27
+ if (typeof bodyReq === undefined || !Object.keys(bodyReq)?.length) {
28
+ debug('bodyReq', bodyReq)
29
+ context.throw(400, t('error.invalid body request format'))
30
+ }
31
+
32
+ let patch: any = {}
33
+ if (bodyReq?.releaseOrder) patch.releaseGood = bodyReq.releaseOrder
34
+ else context.throw(400, t('error.body request require releaseGood property'))
35
+
36
+ if (bodyReq?.shippingOrder) patch.shippingOrder = bodyReq.shippingOrder
37
+ else patch.shippingOrder = null
38
+
39
+ context.body = {
40
+ result: (
41
+ await client.mutate({
42
+ mutation: gql`
43
+ mutation updateReleaseGoodDetails($releaseGood: ReleaseGoodPatch!, $shippingOrder: ShippingOrderPatch) {
44
+ updateReleaseGoodDetails(releaseGood: $releaseGood, shippingOrder: $shippingOrder) {
45
+ id
46
+ name
47
+ refNo
48
+ refNo2
49
+ refNo3
50
+ ownTransport
51
+ collectionOrderNo
52
+ exportOption
53
+ courierOption
54
+ packingOption
55
+ type
56
+ billingAddress
57
+ deliveryAddress1
58
+ deliveryAddress2
59
+ deliveryAddress3
60
+ deliveryAddress4
61
+ deliveryAddress5
62
+ attentionTo
63
+ attentionCompany
64
+ city
65
+ state
66
+ postalCode
67
+ country
68
+ phone1
69
+ phone2
70
+ email
71
+ handoverType
72
+ dropoffAddress
73
+ pickupAddress
74
+ transporter
75
+ trackingNo
76
+ marketplaceOrderStatus
77
+ }
78
+ }
79
+ `,
80
+ variables: { ...patch },
81
+ context: {
82
+ ...context,
83
+ state: {
84
+ ...context.state,
85
+ bizplace: customerBizplace,
86
+ domain,
87
+ type: 'api'
88
+ }
89
+ }
90
+ } as any)
91
+ ).data
92
+ }
93
+ }
94
+ )
@@ -6,7 +6,7 @@ import { Bizplace, getCompanyBizplace } from '@things-factory/biz-base'
6
6
  import { Product, ProductBundle, ProductDetail } from '@things-factory/product-base'
7
7
  import { ORDER_TYPES, OrderInventory } from '@things-factory/sales-base'
8
8
  import { Setting } from '@things-factory/setting-base'
9
- import { Inventory, INVENTORY_STATUS } from '@things-factory/warehouse-base'
9
+ import { Inventory, INVENTORY_STATUS, LOCATION_TYPE } from '@things-factory/warehouse-base'
10
10
  import { WorksheetDetail } from '@things-factory/worksheet-base'
11
11
 
12
12
  import { businessMiddleware } from '../../../../middlewares/business-middleware'
@@ -249,12 +249,14 @@ router.post(
249
249
  .andWhere('"iv"."packing_type" = :packingType')
250
250
  .andWhere('"iv"."product_id" = :productId')
251
251
  .andWhere('"iv"."status" = :status')
252
+ .andWhere('"loc"."type" NOT IN (:...locationTypes)')
252
253
  .setParameters({
253
254
  domainId: domain.id,
254
255
  bizplaceId: customerBizplace.id,
255
256
  packingType: packingType,
256
257
  productId: product.id,
257
- status: INVENTORY_STATUS.STORED
258
+ status: INVENTORY_STATUS.STORED,
259
+ locationTypes: [LOCATION_TYPE.QUARANTINE, LOCATION_TYPE.RESERVE]
258
260
  })
259
261
 
260
262
  if (locationSortingRules?.length > 0) {
@@ -15,7 +15,7 @@ router.get(
15
15
  const { shippingNo, orderNo, status, fromDate, toDate, paginationEntriesPerPage, paginationOffset } = context.query
16
16
 
17
17
  let filters: any = [
18
- { name: 'marketplaceStore', operator: 'eq', value: marketplaceStore?.id, relation: true },
18
+ { name: 'marketplace_store_id', operator: 'eq', value: marketplaceStore?.id, relation: true },
19
19
  { name: 'domain', operator: 'eq', value: domain.id, relation: true }
20
20
  ]
21
21
  let pagination: any = { page: 1, limit: 20 }
@@ -48,14 +48,13 @@ router.get(
48
48
  phone2
49
49
  email
50
50
  orderType
51
- freightType
52
- parcelType
53
- goodsType
54
51
  trackingNo
55
52
  ownTrackingNo
56
53
  airwayBill
57
54
  deliveryMethod
55
+ weightUnit
58
56
  totalWeight
57
+ volumeUnit
59
58
  totalVolume
60
59
  transporter
61
60
  ownTransporter
@@ -106,17 +105,17 @@ export async function validateFilters(context, filters, shippingNo, orderNo, sta
106
105
 
107
106
  if (status && status !== '') filters = [...filters, { name: 'status', operator: 'eq', value: status }]
108
107
 
109
- if (fromDate && fromDate !== '') {
110
- fromDate = new Date(`${fromDate.split(' ').join('')} 00:00:00`)
111
- if (fromDate instanceof Date && !isNaN(fromDate.getTime())) fromDate = fromDate.toLocaleString()
112
- else context.throw(400, context.t('fromDate is invalid'))
113
- } else fromDate = ''
114
-
115
- if (toDate && toDate !== '') {
116
- toDate = new Date(`${toDate.split(' ').join('')} 23:59:59`)
117
- if (toDate instanceof Date && !isNaN(toDate.getTime())) toDate = toDate.toLocaleString()
118
- else context.throw(400, context.t('toDate is invalid'))
119
- } else toDate = ''
108
+ // if (fromDate && fromDate !== '') {
109
+ // fromDate = new Date(`${fromDate.split(' ').join('')} 00:00:00`)
110
+ // // if (fromDate instanceof Date && !isNaN(fromDate.getTime())) fromDate = fromDate.toLocaleString()
111
+ // // else context.throw(400, context.t('fromDate is invalid'))
112
+ // } else fromDate = ''
113
+
114
+ // if (toDate && toDate !== '') {
115
+ // toDate = new Date(`${toDate.split(' ').join('')} 23:59:59`)
116
+ // // if (toDate instanceof Date && !isNaN(toDate.getTime())) toDate = toDate.toLocaleString()
117
+ // // else context.throw(400, context.t('toDate is invalid'))
118
+ // } else toDate = ''
120
119
 
121
120
  if (fromDate !== '' && toDate !== '')
122
121
  filters = [...filters, { name: 'createdAt', operator: 'between', value: [fromDate, toDate] }]
@@ -24,3 +24,4 @@ import './set-marketplace-order-delivered'
24
24
  import './set-marketplace-order-failed-delivery'
25
25
  import './update-marketplace-shipping-order'
26
26
  import './update-marketplace-order'
27
+ import './update-release-order-details'
@@ -0,0 +1,94 @@
1
+ import gql from 'graphql-tag'
2
+ import { getRepository } from 'typeorm'
3
+
4
+ import { restfulApiRouter as router } from '@things-factory/api'
5
+ import { Bizplace } from '@things-factory/biz-base'
6
+
7
+ import { businessMiddleware } from '../../../../middlewares/business-middleware'
8
+ import { warehouseMiddleware } from '../../../../middlewares/warehouse-middleware'
9
+
10
+ const debug = require('debug')('things-factory:operato-hub:restful-api:v1:update-release-order-details')
11
+
12
+ router.post(
13
+ '/v1/warehouse/:warehouseId/update-release-order-details',
14
+ businessMiddleware,
15
+ warehouseMiddleware,
16
+ async (context, next) => {
17
+ const { client, domain } = context.state
18
+ const { warehouseId: customerBizplaceId } = context.params
19
+ const { t } = context
20
+ const bodyReq = context.request.body
21
+
22
+ if (!customerBizplaceId) context.throw(404, t('error.warehouse id not found'))
23
+ const customerBizplace: Bizplace = await getRepository(Bizplace).findOne({
24
+ where: { id: customerBizplaceId }
25
+ })
26
+
27
+ if (typeof bodyReq === undefined || !Object.keys(bodyReq)?.length) {
28
+ debug('bodyReq', bodyReq)
29
+ context.throw(400, t('error.invalid body request format'))
30
+ }
31
+
32
+ let patch: any = {}
33
+ if (bodyReq?.releaseOrder) patch.releaseGood = bodyReq.releaseOrder
34
+ else context.throw(400, t('error.body request require releaseGood property'))
35
+
36
+ if (bodyReq?.shippingOrder) patch.shippingOrder = bodyReq.shippingOrder
37
+ else patch.shippingOrder = null
38
+
39
+ context.body = {
40
+ result: (
41
+ await client.mutate({
42
+ mutation: gql`
43
+ mutation updateReleaseGoodDetails($releaseGood: ReleaseGoodPatch!, $shippingOrder: ShippingOrderPatch) {
44
+ updateReleaseGoodDetails(releaseGood: $releaseGood, shippingOrder: $shippingOrder) {
45
+ id
46
+ name
47
+ refNo
48
+ refNo2
49
+ refNo3
50
+ ownTransport
51
+ collectionOrderNo
52
+ exportOption
53
+ courierOption
54
+ packingOption
55
+ type
56
+ billingAddress
57
+ deliveryAddress1
58
+ deliveryAddress2
59
+ deliveryAddress3
60
+ deliveryAddress4
61
+ deliveryAddress5
62
+ attentionTo
63
+ attentionCompany
64
+ city
65
+ state
66
+ postalCode
67
+ country
68
+ phone1
69
+ phone2
70
+ email
71
+ handoverType
72
+ dropoffAddress
73
+ pickupAddress
74
+ transporter
75
+ trackingNo
76
+ marketplaceOrderStatus
77
+ }
78
+ }
79
+ `,
80
+ variables: { ...patch },
81
+ context: {
82
+ ...context,
83
+ state: {
84
+ ...context.state,
85
+ bizplace: customerBizplace,
86
+ domain,
87
+ type: 'api'
88
+ }
89
+ }
90
+ } as any)
91
+ ).data
92
+ }
93
+ }
94
+ )
@@ -6,7 +6,7 @@ import { Bizplace, getCompanyBizplace } from '@things-factory/biz-base'
6
6
  import { Product, ProductBundle, ProductDetail } from '@things-factory/product-base'
7
7
  import { ORDER_TYPES, OrderInventory } from '@things-factory/sales-base'
8
8
  import { Setting } from '@things-factory/setting-base'
9
- import { Inventory, INVENTORY_STATUS } from '@things-factory/warehouse-base'
9
+ import { Inventory, INVENTORY_STATUS, LOCATION_TYPE } from '@things-factory/warehouse-base'
10
10
  import { WorksheetDetail } from '@things-factory/worksheet-base'
11
11
 
12
12
  import { businessMiddleware } from '../../../../middlewares/business-middleware'
@@ -249,12 +249,14 @@ router.post(
249
249
  .andWhere('"iv"."packing_type" = :packingType')
250
250
  .andWhere('"iv"."product_id" = :productId')
251
251
  .andWhere('"iv"."status" = :status')
252
+ .andWhere('"loc"."type" NOT IN (:...locationTypes)')
252
253
  .setParameters({
253
254
  domainId: domain.id,
254
255
  bizplaceId: customerBizplace.id,
255
256
  packingType: packingType,
256
257
  productId: product.id,
257
- status: INVENTORY_STATUS.STORED
258
+ status: INVENTORY_STATUS.STORED,
259
+ locationTypes: [LOCATION_TYPE.QUARANTINE, LOCATION_TYPE.RESERVE]
258
260
  })
259
261
 
260
262
  if (locationSortingRules?.length > 0) {
@@ -15,7 +15,7 @@ router.get(
15
15
  const { shippingNo, orderNo, status, fromDate, toDate, paginationEntriesPerPage, paginationOffset } = context.query
16
16
 
17
17
  let filters: any = [
18
- { name: 'marketplaceStore', operator: 'eq', value: marketplaceStore?.id, relation: true },
18
+ { name: 'marketplace_store_id', operator: 'eq', value: marketplaceStore?.id, relation: true },
19
19
  { name: 'domain', operator: 'eq', value: domain.id, relation: true }
20
20
  ]
21
21
  let pagination: any = { page: 1, limit: 20 }
@@ -48,14 +48,13 @@ router.get(
48
48
  phone2
49
49
  email
50
50
  orderType
51
- freightType
52
- parcelType
53
- goodsType
54
51
  trackingNo
55
52
  ownTrackingNo
56
53
  airwayBill
57
54
  deliveryMethod
55
+ weightUnit
58
56
  totalWeight
57
+ volumeUnit
59
58
  totalVolume
60
59
  transporter
61
60
  ownTransporter
@@ -106,17 +105,17 @@ export async function validateFilters(context, filters, shippingNo, orderNo, sta
106
105
 
107
106
  if (status && status !== '') filters = [...filters, { name: 'status', operator: 'eq', value: status }]
108
107
 
109
- if (fromDate && fromDate !== '') {
110
- fromDate = new Date(`${fromDate.split(' ').join('')} 00:00:00`)
111
- if (fromDate instanceof Date && !isNaN(fromDate.getTime())) fromDate = fromDate.toLocaleString()
112
- else context.throw(400, context.t('fromDate is invalid'))
113
- } else fromDate = ''
114
-
115
- if (toDate && toDate !== '') {
116
- toDate = new Date(`${toDate.split(' ').join('')} 23:59:59`)
117
- if (toDate instanceof Date && !isNaN(toDate.getTime())) toDate = toDate.toLocaleString()
118
- else context.throw(400, context.t('toDate is invalid'))
119
- } else toDate = ''
108
+ // if (fromDate && fromDate !== '') {
109
+ // fromDate = new Date(`${fromDate.split(' ').join('')} 00:00:00`)
110
+ // // if (fromDate instanceof Date && !isNaN(fromDate.getTime())) fromDate = fromDate.toLocaleString()
111
+ // // else context.throw(400, context.t('fromDate is invalid'))
112
+ // } else fromDate = ''
113
+
114
+ // if (toDate && toDate !== '') {
115
+ // toDate = new Date(`${toDate.split(' ').join('')} 23:59:59`)
116
+ // // if (toDate instanceof Date && !isNaN(toDate.getTime())) toDate = toDate.toLocaleString()
117
+ // // else context.throw(400, context.t('toDate is invalid'))
118
+ // } else toDate = ''
120
119
 
121
120
  if (fromDate !== '' && toDate !== '')
122
121
  filters = [...filters, { name: 'createdAt', operator: 'between', value: [fromDate, toDate] }]
@@ -24,3 +24,4 @@ import './set-marketplace-order-delivered'
24
24
  import './set-marketplace-order-failed-delivery'
25
25
  import './update-marketplace-shipping-order'
26
26
  import './update-marketplace-order'
27
+ import './update-release-order-details'