@things-factory/operato-hub 4.0.9 → 4.0.13

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 (64) hide show
  1. package/config.development.js +49 -0
  2. package/dist-server/controllers/bizplace-initializer/dataset/codes.js +28 -4
  3. package/dist-server/controllers/bizplace-initializer/dataset/codes.js.map +1 -1
  4. package/dist-server/controllers/bizplace-initializer/dataset/menus.js +22 -0
  5. package/dist-server/controllers/bizplace-initializer/dataset/menus.js.map +1 -1
  6. package/dist-server/controllers/bizplace-initializer/dataset/roles-privileges.js +49 -0
  7. package/dist-server/controllers/bizplace-initializer/dataset/roles-privileges.js.map +1 -1
  8. package/dist-server/controllers/bizplace-initializer/dataset/settings.js +5 -0
  9. package/dist-server/controllers/bizplace-initializer/dataset/settings.js.map +1 -1
  10. package/dist-server/graphql/resolvers/synchronization/fetch-sync-invoices.js +1 -1
  11. package/dist-server/graphql/resolvers/synchronization/fetch-sync-invoices.js.map +1 -1
  12. package/dist-server/graphql/resolvers/synchronization/fetch-sync-purchase-orders.js +23 -10
  13. package/dist-server/graphql/resolvers/synchronization/fetch-sync-purchase-orders.js.map +1 -1
  14. package/dist-server/graphql/types/synchronization/index.js +1 -1
  15. package/dist-server/routers/api/restful-apis/unstable/add-inbound-order.js +9 -9
  16. package/dist-server/routers/api/restful-apis/unstable/add-inbound-order.js.map +1 -1
  17. package/dist-server/routers/api/restful-apis/unstable/add-release-order.js +396 -306
  18. package/dist-server/routers/api/restful-apis/unstable/add-release-order.js.map +1 -1
  19. package/dist-server/routers/api/restful-apis/unstable/get-marketplace-order-shipping-list.js +11 -19
  20. package/dist-server/routers/api/restful-apis/unstable/get-marketplace-order-shipping-list.js.map +1 -1
  21. package/dist-server/routers/api/restful-apis/unstable/index.js +1 -0
  22. package/dist-server/routers/api/restful-apis/unstable/index.js.map +1 -1
  23. package/dist-server/routers/api/restful-apis/unstable/update-release-order-details.js +82 -0
  24. package/dist-server/routers/api/restful-apis/unstable/update-release-order-details.js.map +1 -0
  25. package/dist-server/routers/api/restful-apis/v1/add-release-order.js +394 -307
  26. package/dist-server/routers/api/restful-apis/v1/add-release-order.js.map +1 -1
  27. package/dist-server/routers/api/restful-apis/v1/get-marketplace-order-shipping-list.js +13 -22
  28. package/dist-server/routers/api/restful-apis/v1/get-marketplace-order-shipping-list.js.map +1 -1
  29. package/dist-server/routers/api/restful-apis/v1/index.js +1 -0
  30. package/dist-server/routers/api/restful-apis/v1/index.js.map +1 -1
  31. package/dist-server/routers/api/restful-apis/v1/update-release-order-details.js +82 -0
  32. package/dist-server/routers/api/restful-apis/v1/update-release-order-details.js.map +1 -0
  33. package/dist-server/routers/api/restful-apis/v2/add-release-order.js +394 -307
  34. package/dist-server/routers/api/restful-apis/v2/add-release-order.js.map +1 -1
  35. package/dist-server/routers/api/restful-apis/v2/get-marketplace-order-shipping-list.js +13 -22
  36. package/dist-server/routers/api/restful-apis/v2/get-marketplace-order-shipping-list.js.map +1 -1
  37. package/dist-server/routers/api/restful-apis/v2/index.js +1 -0
  38. package/dist-server/routers/api/restful-apis/v2/index.js.map +1 -1
  39. package/dist-server/routers/api/restful-apis/v2/update-release-order-details.js +82 -0
  40. package/dist-server/routers/api/restful-apis/v2/update-release-order-details.js.map +1 -0
  41. package/openapi/unstable/outbound.yaml +85 -0
  42. package/openapi/v1/outbound.yaml +85 -0
  43. package/openapi/v2/outbound.yaml +85 -0
  44. package/package.json +67 -67
  45. package/server/controllers/bizplace-initializer/dataset/codes.ts +28 -4
  46. package/server/controllers/bizplace-initializer/dataset/menus.ts +22 -0
  47. package/server/controllers/bizplace-initializer/dataset/roles-privileges.ts +49 -0
  48. package/server/controllers/bizplace-initializer/dataset/settings.ts +5 -0
  49. package/server/graphql/resolvers/synchronization/fetch-sync-invoices.ts +1 -1
  50. package/server/graphql/resolvers/synchronization/fetch-sync-purchase-orders.ts +33 -9
  51. package/server/graphql/types/synchronization/index.ts +1 -1
  52. package/server/routers/api/restful-apis/unstable/add-inbound-order.ts +7 -7
  53. package/server/routers/api/restful-apis/unstable/add-release-order.ts +447 -336
  54. package/server/routers/api/restful-apis/unstable/get-marketplace-order-shipping-list.ts +12 -12
  55. package/server/routers/api/restful-apis/unstable/index.ts +1 -0
  56. package/server/routers/api/restful-apis/unstable/update-release-order-details.ts +94 -0
  57. package/server/routers/api/restful-apis/v1/add-release-order.ts +444 -339
  58. package/server/routers/api/restful-apis/v1/get-marketplace-order-shipping-list.ts +14 -15
  59. package/server/routers/api/restful-apis/v1/index.ts +1 -0
  60. package/server/routers/api/restful-apis/v1/update-release-order-details.ts +94 -0
  61. package/server/routers/api/restful-apis/v2/add-release-order.ts +444 -339
  62. package/server/routers/api/restful-apis/v2/get-marketplace-order-shipping-list.ts +14 -15
  63. package/server/routers/api/restful-apis/v2/index.ts +1 -0
  64. 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": "4.0.9",
3
+ "version": "4.0.13",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "client/index.js",
6
6
  "things-factory": true,
@@ -41,80 +41,80 @@
41
41
  "@material/mwc-formfield": "^0.25.3",
42
42
  "@material/mwc-linear-progress": "^0.25.3",
43
43
  "@material/mwc-radio": "^0.25.3",
44
- "@operato/scene-switch": "^0.0.9",
45
- "@things-factory/api": "^4.0.9",
46
- "@things-factory/apptool-ui": "^4.0.9",
47
- "@things-factory/attachment-base": "^4.0.9",
48
- "@things-factory/auth-base": "^4.0.9",
49
- "@things-factory/auth-ui": "^4.0.9",
50
- "@things-factory/biz-base": "^4.0.9",
51
- "@things-factory/biz-ui": "^4.0.9",
52
- "@things-factory/board-service": "^4.0.9",
53
- "@things-factory/board-ui": "^4.0.9",
54
- "@things-factory/code-ui": "^4.0.9",
55
- "@things-factory/component-ui": "^4.0.9",
56
- "@things-factory/context-ui": "^4.0.9",
57
- "@things-factory/document-template-ui": "^4.0.9",
58
- "@things-factory/export-ui": "^4.0.9",
59
- "@things-factory/export-ui-csv": "^4.0.9",
60
- "@things-factory/export-ui-excel": "^4.0.9",
61
- "@things-factory/grist-ui": "^4.0.9",
62
- "@things-factory/i18n-base": "^4.0.9",
63
- "@things-factory/i18n-ui": "^4.0.9",
64
- "@things-factory/import-ui": "^4.0.9",
65
- "@things-factory/import-ui-excel": "^4.0.9",
66
- "@things-factory/integration-accounting": "^4.0.9",
67
- "@things-factory/integration-fulfillment": "^4.0.9",
68
- "@things-factory/integration-lmd": "^4.0.9",
69
- "@things-factory/integration-marketplace": "^4.0.9",
70
- "@things-factory/integration-pos": "^4.0.9",
71
- "@things-factory/integration-sellercraft": "^4.0.9",
72
- "@things-factory/lite-menu": "^4.0.9",
73
- "@things-factory/more-ui": "^4.0.9",
74
- "@things-factory/notification": "^4.0.9",
75
- "@things-factory/pdf": "^4.0.9",
76
- "@things-factory/product-ui": "^4.0.9",
77
- "@things-factory/resource-ui": "^4.0.9",
78
- "@things-factory/sales-base": "^4.0.9",
79
- "@things-factory/scene-chartjs": "^4.0.9",
80
- "@things-factory/scene-clock": "^4.0.9",
81
- "@things-factory/scene-clone": "^4.0.9",
82
- "@things-factory/scene-compass": "^4.0.9",
83
- "@things-factory/scene-data-transform": "^4.0.9",
84
- "@things-factory/scene-excel": "^4.0.9",
85
- "@things-factory/scene-firebase": "^4.0.9",
86
- "@things-factory/scene-form": "^4.0.9",
87
- "@things-factory/scene-gauge": "^4.0.9",
88
- "@things-factory/scene-google-map": "^4.0.9",
89
- "@things-factory/scene-graphql": "^4.0.9",
44
+ "@operato/scene-chartjs": "^0.0.17",
45
+ "@operato/scene-clock": "^0.0.17",
46
+ "@operato/scene-clone": "^0.0.17",
47
+ "@operato/scene-compass": "^0.0.17",
48
+ "@operato/scene-gauge": "^0.0.17",
49
+ "@operato/scene-indoor-map": "^0.0.17",
50
+ "@operato/scene-legend": "^0.0.17",
51
+ "@operato/scene-progressbar": "^0.0.17",
52
+ "@operato/scene-random": "^0.0.17",
53
+ "@operato/scene-switch": "^0.0.17",
54
+ "@operato/scene-table": "^0.0.17",
55
+ "@operato/scene-wheel-sorter": "^0.0.17",
56
+ "@things-factory/api": "^4.0.13",
57
+ "@things-factory/apptool-ui": "^4.0.13",
58
+ "@things-factory/attachment-base": "^4.0.13",
59
+ "@things-factory/auth-base": "^4.0.13",
60
+ "@things-factory/auth-ui": "^4.0.13",
61
+ "@things-factory/biz-base": "^4.0.13",
62
+ "@things-factory/biz-ui": "^4.0.13",
63
+ "@things-factory/board-service": "^4.0.13",
64
+ "@things-factory/board-ui": "^4.0.13",
65
+ "@things-factory/code-ui": "^4.0.13",
66
+ "@things-factory/component-ui": "^4.0.13",
67
+ "@things-factory/context-ui": "^4.0.13",
68
+ "@things-factory/document-template-ui": "^4.0.13",
69
+ "@things-factory/export-ui": "^4.0.13",
70
+ "@things-factory/export-ui-csv": "^4.0.13",
71
+ "@things-factory/export-ui-excel": "^4.0.13",
72
+ "@things-factory/grist-ui": "^4.0.13",
73
+ "@things-factory/i18n-base": "^4.0.13",
74
+ "@things-factory/i18n-ui": "^4.0.13",
75
+ "@things-factory/import-ui": "^4.0.13",
76
+ "@things-factory/import-ui-excel": "^4.0.13",
77
+ "@things-factory/integration-accounting": "^4.0.13",
78
+ "@things-factory/integration-fulfillment": "^4.0.13",
79
+ "@things-factory/integration-lmd": "^4.0.13",
80
+ "@things-factory/integration-marketplace": "^4.0.13",
81
+ "@things-factory/integration-pos": "^4.0.13",
82
+ "@things-factory/integration-sellercraft": "^4.0.13",
83
+ "@things-factory/lite-menu": "^4.0.13",
84
+ "@things-factory/more-ui": "^4.0.13",
85
+ "@things-factory/notification": "^4.0.13",
86
+ "@things-factory/pdf": "^4.0.13",
87
+ "@things-factory/product-ui": "^4.0.13",
88
+ "@things-factory/resource-ui": "^4.0.13",
89
+ "@things-factory/sales-base": "^4.0.13",
90
+ "@things-factory/scene-data-transform": "^4.0.13",
91
+ "@things-factory/scene-excel": "^4.0.13",
92
+ "@things-factory/scene-firebase": "^4.0.13",
93
+ "@things-factory/scene-form": "^4.0.13",
94
+ "@things-factory/scene-google-map": "^4.0.13",
95
+ "@things-factory/scene-graphql": "^4.0.13",
90
96
  "@things-factory/scene-half-roundrect": "^4.0.9",
91
- "@things-factory/scene-indoor-map": "^4.0.9",
92
- "@things-factory/scene-label": "^4.0.9",
93
- "@things-factory/scene-legend": "^4.0.9",
94
- "@things-factory/scene-marker": "^4.0.9",
95
- "@things-factory/scene-mqtt": "^4.0.9",
96
- "@things-factory/scene-news-ticker": "^4.0.9",
97
- "@things-factory/scene-progressbar": "^4.0.9",
98
- "@things-factory/scene-random": "^4.0.9",
99
- "@things-factory/scene-restful": "^4.0.9",
100
- "@things-factory/scene-tab": "^4.0.9",
101
- "@things-factory/scene-table": "^4.0.9",
102
- "@things-factory/scene-visualizer": "^4.0.9",
103
- "@things-factory/scene-wheel-sorter": "^4.0.9",
104
- "@things-factory/setting-ui": "^4.0.9",
105
- "@things-factory/shell": "^4.0.9",
106
- "@things-factory/system-ui": "^4.0.9",
107
- "@things-factory/warehouse-base": "^4.0.9",
108
- "@things-factory/worksheet-base": "^4.0.9",
97
+ "@things-factory/scene-label": "^4.0.13",
98
+ "@things-factory/scene-marker": "^4.0.13",
99
+ "@things-factory/scene-mqtt": "^4.0.13",
100
+ "@things-factory/scene-news-ticker": "^4.0.13",
101
+ "@things-factory/scene-restful": "^4.0.13",
102
+ "@things-factory/scene-tab": "^4.0.13",
103
+ "@things-factory/scene-visualizer": "^4.0.13",
104
+ "@things-factory/setting-ui": "^4.0.13",
105
+ "@things-factory/shell": "^4.0.13",
106
+ "@things-factory/system-ui": "^4.0.13",
107
+ "@things-factory/warehouse-base": "^4.0.13",
108
+ "@things-factory/worksheet-base": "^4.0.13",
109
109
  "koa2-swagger-ui": "^5.0.2",
110
110
  "swagger-jsdoc": "^5.0.0",
111
111
  "yamljs": "^0.3.0"
112
112
  },
113
113
  "devDependencies": {
114
- "@things-factory/builder": "^4.0.9"
114
+ "@things-factory/builder": "^4.0.13"
115
115
  },
116
116
  "resolutions": {
117
117
  "core-js": "^3.16.0"
118
118
  },
119
- "gitHead": "81c8ae24487cfe79da62717f12bb6752761911ae"
119
+ "gitHead": "a542fdd4e7c447c3b571fe91c92f5919561bdc2c"
120
120
  }
@@ -31,8 +31,9 @@ export const CODES = {
31
31
  description: 'grn status',
32
32
  details: [
33
33
  { name: 'PENDING_PROCESS', description: 'executing' },
34
+ { name: 'PENDING_RECEIVE', description: 'pending_receive' },
34
35
  { name: 'RECEIVED', description: 'received' },
35
- { name: 'SUBMITTED', description: 'submitted' }
36
+ { name: 'SUBMITTED', description: 'submitted' },
36
37
  ]
37
38
  },
38
39
  {
@@ -75,7 +76,8 @@ export const CODES = {
75
76
  details: [
76
77
  { name: 'DO_TEMPLATE', description: 'template for delivery order' },
77
78
  { name: 'LOGO', description: 'template for logo' },
78
- { name: 'GRN_TEMPLATE', description: 'template for goods received note' }
79
+ { name: 'GRN_TEMPLATE', description: 'template for goods received note' },
80
+ { name: 'MANIFEST_TEMPLATE', description: 'template for manifest' }
79
81
  ]
80
82
  },
81
83
  {
@@ -124,14 +126,36 @@ export const CODES = {
124
126
  },
125
127
  {
126
128
  name: 'RO_REQUESTS_STATUS',
129
+ description: 'release order requests status',
130
+ details: [
131
+ { name: 'PENDING', description: 'order_status_pending' },
132
+ { name: 'PENDING_RECEIVE', description: 'order_status_pending_receive' },
133
+ { name: 'PENDING_WORKSHEET', description: 'order_status_pending_worksheet' },
134
+ { name: 'PENDING_CANCEL', description: 'order_status_pending_cancel' },
135
+ { name: 'DEACTIVATED', description: 'order_status_deactivated' },
136
+ { name: 'READY_TO_PICK', description: 'order_status_ready_to_pick' },
137
+ { name: 'PICKING', description: 'order_status_picking' },
138
+ { name: 'READY_TO_PACK', description: 'order_status_ready_to_pack' },
139
+ { name: 'PACKING', description: 'order_status_packing' },
140
+ { name: 'LOADING', description: 'order_status_loading' },
141
+ { name: 'PARTIAL_RETURN', description: 'order_status_partial_return' },
142
+ { name: 'DONE', description: 'order_status_done' },
143
+ { name: 'REJECTED', description: 'order_status_rejected' },
144
+ { name: 'CANCELLED', description: 'order_status_cancelled' }
145
+ ]
146
+ },
147
+ {
148
+ name: 'RO_LIST_STATUS',
127
149
  description: 'release order status',
128
150
  details: [
129
151
  { name: 'PENDING', description: 'order_status_pending' },
130
152
  { name: 'PENDING_RECEIVE', description: 'order_status_pending_receive' },
131
153
  { name: 'PENDING_WORKSHEET', description: 'order_status_pending_worksheet' },
132
154
  { name: 'PENDING_CANCEL', description: 'order_status_pending_cancel' },
155
+ { name: 'DEACTIVATED', description: 'order_status_deactivated' },
133
156
  { name: 'READY_TO_PICK', description: 'order_status_ready_to_pick' },
134
157
  { name: 'PICKING', description: 'order_status_picking' },
158
+ { name: 'READY_TO_PACK', description: 'order_status_ready_to_pack' },
135
159
  { name: 'PACKING', description: 'order_status_packing' },
136
160
  { name: 'LOADING', description: 'order_status_loading' },
137
161
  { name: 'PARTIAL_RETURN', description: 'order_status_partial_return' },
@@ -218,7 +242,7 @@ export const CODES = {
218
242
  details: [
219
243
  { name: 'PENDING', description: 'order_status_pending' },
220
244
  { name: 'PENDING_RECEIVE', description: 'order_status_pending_receive' },
221
- { name: 'IN_TRANSIT', description: 'order_status_in_transit' },
245
+ { name: 'INTRANSIT', description: 'order_status_in_transit' },
222
246
  { name: 'ARRIVED', description: 'order_status_arrived' },
223
247
  { name: 'READY_TO_UNLOAD', description: 'order_status_ready_to_unload' },
224
248
  { name: 'READY_TO_PUTAWAY', description: 'order_status_ready_to_putaway' },
@@ -278,7 +302,7 @@ export const CODES = {
278
302
  { name: 'cm', description: 'Centimeter' },
279
303
  { name: 'm', description: 'Meter' },
280
304
  { name: 'inch', description: 'Inch' },
281
- { name: 'ft', description: 'Foot' },
305
+ { name: 'ft', description: 'Foot' }
282
306
  ]
283
307
  },
284
308
  {
@@ -128,6 +128,28 @@ export const MENUS = {
128
128
  }
129
129
  ]
130
130
  },
131
+ {
132
+ name: 'Loading Manifest',
133
+ menuType: 'MENU',
134
+ children: [
135
+ {
136
+ name: 'Create Loading Manifest',
137
+ template: 'create-loading-manifest',
138
+ menuType: 'SCREEN',
139
+ routingType: 'STATIC',
140
+ resourceUrl: 'create_loading_manifest',
141
+ roles: ['Business Owner', 'Office Admin']
142
+ },
143
+ {
144
+ name: 'Manifest List',
145
+ template: 'loading-manifest-list',
146
+ menuType: 'SCREEN',
147
+ routingType: 'STATIC',
148
+ resourceUrl: 'loading_manifest_list',
149
+ roles: ['Business Owner', 'Office Admin']
150
+ }
151
+ ]
152
+ },
131
153
  {
132
154
  name: 'Return Order',
133
155
  menuType: 'MENU',
@@ -248,6 +248,55 @@ export const ROLES_PRIVILEGES = {
248
248
  { name: 'query', category: 'vas' },
249
249
  { name: 'query', category: 'warehouse' }
250
250
  ]
251
+ },
252
+ {
253
+ name: 'Support',
254
+ description: 'SUPPORT',
255
+ privileges: [
256
+ { name: 'mutation', category: 'bizplace' },
257
+ { name: 'mutation', category: 'claim' },
258
+ { name: 'mutation', category: 'company' },
259
+ { name: 'mutation', category: 'contact_point' },
260
+ { name: 'mutation', category: 'inventory' },
261
+ { name: 'mutation', category: 'inventory_adjustment_approval' },
262
+ { name: 'mutation', category: 'movement' },
263
+ { name: 'mutation', category: 'order' },
264
+ { name: 'mutation', category: 'order_customer' },
265
+ { name: 'mutation', category: 'order_warehouse' },
266
+ { name: 'mutation', category: 'partner' },
267
+ { name: 'mutation', category: 'setting' },
268
+ { name: 'mutation', category: 'system' },
269
+ { name: 'mutation', category: 'transport' },
270
+ { name: 'mutation', category: 'vas' },
271
+ { name: 'mutation', category: 'warehouse' },
272
+ { name: 'mutation', category: 'worker' },
273
+ { name: 'mutation', category: 'worksheet' },
274
+ { name: 'mutation', category: 'worksheet_execute' },
275
+ { name: 'query', category: 'bizplace' },
276
+ { name: 'query', category: 'claim' },
277
+ { name: 'query', category: 'company' },
278
+ { name: 'query', category: 'contact_point' },
279
+ { name: 'query', category: 'customer' },
280
+ { name: 'query', category: 'inventory' },
281
+ { name: 'query', category: 'movement' },
282
+ { name: 'query', category: 'order' },
283
+ { name: 'query', category: 'order_customer' },
284
+ { name: 'query', category: 'order_warehouse' },
285
+ { name: 'query', category: 'partner' },
286
+ { name: 'query', category: 'setting' },
287
+ { name: 'query', category: 'system' },
288
+ { name: 'query', category: 'transport' },
289
+ { name: 'query', category: 'user' },
290
+ { name: 'query', category: 'vas' },
291
+ { name: 'query', category: 'vendor' },
292
+ { name: 'query', category: 'warehouse' },
293
+ { name: 'query', category: 'worker' },
294
+ { name: 'query', category: 'worksheet' },
295
+ { name: 'query', category: 'worksheet_execute' },
296
+ { name: 'role', category: 'owner' },
297
+ { name: 'role', category: 'warehouse' },
298
+ { name: 'query', category: 'inventory_comparison' }
299
+ ]
251
300
  }
252
301
  ],
253
302
  retail: [
@@ -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: []
@@ -29,7 +29,7 @@ export async function getAccountingInvoices(accountId: string, warehouseId: stri
29
29
  const accounting: AccountingAPI = await AccountingAPI.getAccounting(accountId)
30
30
 
31
31
  const fulfilmentCenter: FulfillmentCenter = await FulfillmentAPI.getFulfillmentCenter(warehouseId)
32
- const invoices: any[] = await AccountingAPI.getInvoices(accounting)
32
+ const invoices: any[] = await AccountingAPI.getInvoices(accounting, { Statuses: 'AUTHORISED' })
33
33
 
34
34
  for (var i = 0; i < invoices.length; i++) {
35
35
  const releaseOrder = invoices[i]
@@ -7,26 +7,52 @@ export const fetchSyncPurchaseOrdersResolver = {
7
7
  {
8
8
  accountId,
9
9
  warehouseId,
10
- customerBizplaceId
11
- }: { accountId: string; warehouseId: string; customerBizplaceId: string },
10
+ customerBizplaceId,
11
+ fromDate,
12
+ toDate
13
+ }: { accountId: string; warehouseId: string; customerBizplaceId: string; fromDate: string; toDate: string },
12
14
  context: any
13
15
  ): Promise<void> {
14
16
  try {
15
- await getAccountingPurchaseOrders(accountId, warehouseId, customerBizplaceId)
17
+ await getAccountingPurchaseOrders(accountId, warehouseId, customerBizplaceId, fromDate, toDate)
16
18
  } catch (e) {
17
19
  throw e
18
20
  }
19
21
  }
20
22
  }
21
23
 
22
- export async function getAccountingPurchaseOrders(accountId: string, warehouseId: string, customerBizplaceId: string) {
24
+ export async function getAccountingPurchaseOrders(
25
+ accountId: string,
26
+ warehouseId: string,
27
+ customerBizplaceId: string,
28
+ fromDate: string,
29
+ toDate: string
30
+ ) {
23
31
  try {
24
32
  const accounting: AccountingAPI = await AccountingAPI.getAccounting(accountId)
25
33
 
26
34
  const fulfilmentCenter: FulfillmentCenter = await FulfillmentAPI.getFulfillmentCenter(warehouseId)
27
- const purchaseOrders: any[] = await AccountingAPI.getPurchaseOrders(accounting)
35
+ let parameters: any = { status: 'AUTHORISED' }
28
36
 
29
- for (var i = 0; i < purchaseOrders.length; i++) {
37
+ if (fromDate) {
38
+ if (!toDate) throw new Error('From Date setting requires To Date')
39
+ parameters = { ...parameters, DateFrom: fromDate, DateTo: toDate }
40
+ }
41
+
42
+ const purchaseOrders: any[] = await AccountingAPI.getPurchaseOrders(accounting, { ...parameters })
43
+ await createInboundOrder(fulfilmentCenter, purchaseOrders, customerBizplaceId)
44
+ } catch (e) {
45
+ throw new Error(e.statusText)
46
+ }
47
+ }
48
+
49
+ export async function createInboundOrder(
50
+ fulfilmentCenter: FulfillmentCenter,
51
+ purchaseOrders: any[],
52
+ customerBizplaceId: string
53
+ ) {
54
+ for (var i = 0; i < purchaseOrders.length; i++) {
55
+ try {
30
56
  const purchaseOrder = purchaseOrders[i]
31
57
 
32
58
  const existingArrivalNotice = await FulfillmentAPI.getInboundOrder(fulfilmentCenter, {
@@ -41,8 +67,6 @@ export async function getAccountingPurchaseOrders(accountId: string, warehouseId
41
67
  purchaseOrder
42
68
  })
43
69
  }
44
- }
45
- } catch (e) {
46
- throw new Error(e.statusText)
70
+ } catch (e) {}
47
71
  }
48
72
  }
@@ -7,7 +7,7 @@ import { SyncPurchaseOrderSet, Types as pTypes } from './sync-purchase-order-set
7
7
 
8
8
  export const Query = /* GraphQL */ `
9
9
  fetchSyncProducts(accountId: String!, bizplaceId: String!, pagination: Pagination): SyncProductList
10
- fetchSyncPurchaseOrders(accountId: String!, warehouseId: String!, customerBizplaceId: String): Boolean
10
+ fetchSyncPurchaseOrders(accountId: String!, warehouseId: String!, customerBizplaceId: String, fromDate: String, toDate: String): Boolean
11
11
  fetchSyncInvoices(accountId: String!, warehouseId: String!, customerBizplaceId: String!): Boolean
12
12
  `
13
13
 
@@ -46,7 +46,8 @@ router.post(
46
46
  })
47
47
 
48
48
  //#2 assign product id found to order product
49
- bodyReq.orderProducts = bodyReq.orderProducts.map(orderProduct => {
49
+ let orderProducts: any[] = []
50
+ bodyReq.orderProducts.map(orderProduct => {
50
51
  productDetails.forEach(productDetail => {
51
52
  const product: Product = productDetail.product
52
53
  const packingType: string = productDetail.packingType
@@ -77,13 +78,12 @@ router.post(
77
78
  }
78
79
  })
79
80
 
80
- return orderProduct
81
+ if (orderProduct.product?.id) orderProducts.push({ ...orderProduct })
81
82
  })
82
83
 
83
- //#3 check if product is not found
84
- bodyReq.orderProducts.forEach(orderProduct => {
85
- if (!orderProduct.product?.id) context.throw(404, t(`error.sku code ${orderProduct.product.sku} is not exist`))
86
- })
84
+ if (!orderProducts?.length) {
85
+ context.throw(404, t(`no matching product found`))
86
+ }
87
87
 
88
88
  //#4 include supplier id if there's any
89
89
  if (bodyReq?.supplier) {
@@ -173,7 +173,7 @@ router.post(
173
173
  }
174
174
  }
175
175
  `,
176
- variables: { arrivalNotice: { ...bodyReq, warehouseId }, attachments },
176
+ variables: { arrivalNotice: { ...bodyReq, orderProducts, warehouseId }, attachments },
177
177
  context: {
178
178
  ...context,
179
179
  hasUpload: true,