@things-factory/operato-hub 5.0.13 → 6.0.0-alpha.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 (217) hide show
  1. package/dist-server/controllers/bizplace-initializer/dataset/codes.js +9 -0
  2. package/dist-server/controllers/bizplace-initializer/dataset/codes.js.map +1 -1
  3. package/dist-server/controllers/bizplace-initializer/dataset/settings.js +5 -0
  4. package/dist-server/controllers/bizplace-initializer/dataset/settings.js.map +1 -1
  5. package/dist-server/controllers/bizplace-initializer/generate-bizplace-domain-roles.js +3 -3
  6. package/dist-server/controllers/bizplace-initializer/generate-bizplace-domain-roles.js.map +1 -1
  7. package/dist-server/controllers/bizplace-initializer/generate-bizplace-domain.js +2 -2
  8. package/dist-server/controllers/bizplace-initializer/generate-bizplace-domain.js.map +1 -1
  9. package/dist-server/controllers/bizplace-initializer/menus.js +2 -2
  10. package/dist-server/controllers/bizplace-initializer/menus.js.map +1 -1
  11. package/dist-server/controllers/company-initializer/business-register.js +6 -7
  12. package/dist-server/controllers/company-initializer/business-register.js.map +1 -1
  13. package/dist-server/controllers/company-initializer/generate-company-roles.js +4 -4
  14. package/dist-server/controllers/company-initializer/generate-company-roles.js.map +1 -1
  15. package/dist-server/controllers/invitation.js +9 -9
  16. package/dist-server/controllers/invitation.js.map +1 -1
  17. package/dist-server/controllers/utils/save-invitation-token.js +2 -2
  18. package/dist-server/controllers/utils/save-invitation-token.js.map +1 -1
  19. package/dist-server/graphql/resolvers/generators/generate-bizplace.js.map +1 -1
  20. package/dist-server/graphql/resolvers/generators/generate-company.js +4 -3
  21. package/dist-server/graphql/resolvers/generators/generate-company.js.map +1 -1
  22. package/dist-server/graphql/resolvers/generators/update-domain-extType.js +1 -1
  23. package/dist-server/graphql/resolvers/generators/update-domain-extType.js.map +1 -1
  24. package/dist-server/graphql/resolvers/invitations/partner-invitation.js +6 -6
  25. package/dist-server/graphql/resolvers/invitations/partner-invitation.js.map +1 -1
  26. package/dist-server/graphql/resolvers/oauth2/company-roles-by-scope.js +5 -2
  27. package/dist-server/graphql/resolvers/oauth2/company-roles-by-scope.js.map +1 -1
  28. package/dist-server/graphql/resolvers/synchronization/auto-update-all-marketplace-product-variation-quantity.js +149 -0
  29. package/dist-server/graphql/resolvers/synchronization/auto-update-all-marketplace-product-variation-quantity.js.map +1 -0
  30. package/dist-server/graphql/resolvers/synchronization/create-dat-shipments.js +58 -0
  31. package/dist-server/graphql/resolvers/synchronization/create-dat-shipments.js.map +1 -0
  32. package/dist-server/graphql/resolvers/synchronization/fetch-sync-products.js +3 -3
  33. package/dist-server/graphql/resolvers/synchronization/fetch-sync-products.js.map +1 -1
  34. package/dist-server/graphql/resolvers/synchronization/index.js +6 -2
  35. package/dist-server/graphql/resolvers/synchronization/index.js.map +1 -1
  36. package/dist-server/graphql/resolvers/synchronization/sellercraft-pack-marketplace-order.js +68 -0
  37. package/dist-server/graphql/resolvers/synchronization/sellercraft-pack-marketplace-order.js.map +1 -0
  38. package/dist-server/graphql/resolvers/synchronization/sync-all-products-to-sellercraft.js +35 -0
  39. package/dist-server/graphql/resolvers/synchronization/sync-all-products-to-sellercraft.js.map +1 -0
  40. package/dist-server/graphql/resolvers/synchronization/sync-products-from-account.js +1 -1
  41. package/dist-server/graphql/resolvers/synchronization/sync-products-from-account.js.map +1 -1
  42. package/dist-server/graphql/resolvers/synchronization/sync-products-to-account.js +1 -1
  43. package/dist-server/graphql/resolvers/synchronization/sync-products-to-account.js.map +1 -1
  44. package/dist-server/graphql/resolvers/synchronization/sync-products-to-sellercraft.js +4 -2
  45. package/dist-server/graphql/resolvers/synchronization/sync-products-to-sellercraft.js.map +1 -1
  46. package/dist-server/graphql/types/synchronization/index.js +4 -0
  47. package/dist-server/graphql/types/synchronization/index.js.map +1 -1
  48. package/dist-server/index.js +5 -5
  49. package/dist-server/index.js.map +1 -1
  50. package/dist-server/middlewares/business-middleware.js +2 -3
  51. package/dist-server/middlewares/business-middleware.js.map +1 -1
  52. package/dist-server/middlewares/store-middleware.js +2 -2
  53. package/dist-server/middlewares/store-middleware.js.map +1 -1
  54. package/dist-server/middlewares/warehouse-middleware.js +3 -2
  55. package/dist-server/middlewares/warehouse-middleware.js.map +1 -1
  56. package/dist-server/migrations/1597668478399-SeedBusinessDomain.js +2 -3
  57. package/dist-server/migrations/1597668478399-SeedBusinessDomain.js.map +1 -1
  58. package/dist-server/migrations/1597668478401-SeedBusinessRoles.js +2 -2
  59. package/dist-server/migrations/1597668478401-SeedBusinessRoles.js.map +1 -1
  60. package/dist-server/migrations/1608009991065-SeedUser.js +5 -6
  61. package/dist-server/migrations/1608009991065-SeedUser.js.map +1 -1
  62. package/dist-server/routers/api/restful-apis/unstable/add-draft-release-order.js +2 -1
  63. package/dist-server/routers/api/restful-apis/unstable/add-draft-release-order.js.map +1 -1
  64. package/dist-server/routers/api/restful-apis/unstable/add-inbound-order.js +5 -4
  65. package/dist-server/routers/api/restful-apis/unstable/add-inbound-order.js.map +1 -1
  66. package/dist-server/routers/api/restful-apis/unstable/add-marketplace-order.js +5 -2
  67. package/dist-server/routers/api/restful-apis/unstable/add-marketplace-order.js.map +1 -1
  68. package/dist-server/routers/api/restful-apis/unstable/add-products.js +32 -16
  69. package/dist-server/routers/api/restful-apis/unstable/add-products.js.map +1 -1
  70. package/dist-server/routers/api/restful-apis/unstable/add-release-order.js +149 -40
  71. package/dist-server/routers/api/restful-apis/unstable/add-release-order.js.map +1 -1
  72. package/dist-server/routers/api/restful-apis/unstable/cancel-release-order.js +4 -4
  73. package/dist-server/routers/api/restful-apis/unstable/cancel-release-order.js.map +1 -1
  74. package/dist-server/routers/api/restful-apis/unstable/get-delivery-orders.js +27 -11
  75. package/dist-server/routers/api/restful-apis/unstable/get-delivery-orders.js.map +1 -1
  76. package/dist-server/routers/api/restful-apis/unstable/get-goods-received-notes.js +9 -2
  77. package/dist-server/routers/api/restful-apis/unstable/get-goods-received-notes.js.map +1 -1
  78. package/dist-server/routers/api/restful-apis/unstable/get-onhand-inventories.js +2 -2
  79. package/dist-server/routers/api/restful-apis/unstable/get-onhand-inventories.js.map +1 -1
  80. package/dist-server/routers/api/restful-apis/unstable/get-partners.js +5 -4
  81. package/dist-server/routers/api/restful-apis/unstable/get-partners.js.map +1 -1
  82. package/dist-server/routers/api/restful-apis/unstable/get-products.js +1 -0
  83. package/dist-server/routers/api/restful-apis/unstable/get-products.js.map +1 -1
  84. package/dist-server/routers/api/restful-apis/unstable/get-warehouses.js +2 -2
  85. package/dist-server/routers/api/restful-apis/unstable/get-warehouses.js.map +1 -1
  86. package/dist-server/routers/api/restful-apis/unstable/update-release-order-details.js +2 -2
  87. package/dist-server/routers/api/restful-apis/unstable/update-release-order-details.js.map +1 -1
  88. package/dist-server/routers/api/restful-apis/v1/add-inbound-order.js +6 -5
  89. package/dist-server/routers/api/restful-apis/v1/add-inbound-order.js.map +1 -1
  90. package/dist-server/routers/api/restful-apis/v1/add-marketplace-order.js +8 -5
  91. package/dist-server/routers/api/restful-apis/v1/add-marketplace-order.js.map +1 -1
  92. package/dist-server/routers/api/restful-apis/v1/add-products.js +32 -16
  93. package/dist-server/routers/api/restful-apis/v1/add-products.js.map +1 -1
  94. package/dist-server/routers/api/restful-apis/v1/add-release-order.js +8 -6
  95. package/dist-server/routers/api/restful-apis/v1/add-release-order.js.map +1 -1
  96. package/dist-server/routers/api/restful-apis/v1/cancel-release-order.js +4 -4
  97. package/dist-server/routers/api/restful-apis/v1/cancel-release-order.js.map +1 -1
  98. package/dist-server/routers/api/restful-apis/v1/get-delivery-orders.js +27 -11
  99. package/dist-server/routers/api/restful-apis/v1/get-delivery-orders.js.map +1 -1
  100. package/dist-server/routers/api/restful-apis/v1/get-goods-received-notes.js +9 -2
  101. package/dist-server/routers/api/restful-apis/v1/get-goods-received-notes.js.map +1 -1
  102. package/dist-server/routers/api/restful-apis/v1/get-onhand-inventories.js +2 -2
  103. package/dist-server/routers/api/restful-apis/v1/get-onhand-inventories.js.map +1 -1
  104. package/dist-server/routers/api/restful-apis/v1/get-partners.js +5 -4
  105. package/dist-server/routers/api/restful-apis/v1/get-partners.js.map +1 -1
  106. package/dist-server/routers/api/restful-apis/v1/get-products.js +1 -0
  107. package/dist-server/routers/api/restful-apis/v1/get-products.js.map +1 -1
  108. package/dist-server/routers/api/restful-apis/v1/get-warehouses.js +2 -2
  109. package/dist-server/routers/api/restful-apis/v1/get-warehouses.js.map +1 -1
  110. package/dist-server/routers/api/restful-apis/v1/update-release-order-details.js +2 -2
  111. package/dist-server/routers/api/restful-apis/v1/update-release-order-details.js.map +1 -1
  112. package/dist-server/routers/api/restful-apis/v2/add-inbound-order.js +6 -5
  113. package/dist-server/routers/api/restful-apis/v2/add-inbound-order.js.map +1 -1
  114. package/dist-server/routers/api/restful-apis/v2/add-marketplace-order.js +8 -5
  115. package/dist-server/routers/api/restful-apis/v2/add-marketplace-order.js.map +1 -1
  116. package/dist-server/routers/api/restful-apis/v2/add-products.js +32 -16
  117. package/dist-server/routers/api/restful-apis/v2/add-products.js.map +1 -1
  118. package/dist-server/routers/api/restful-apis/v2/add-release-order.js +8 -6
  119. package/dist-server/routers/api/restful-apis/v2/add-release-order.js.map +1 -1
  120. package/dist-server/routers/api/restful-apis/v2/cancel-release-order.js +4 -4
  121. package/dist-server/routers/api/restful-apis/v2/cancel-release-order.js.map +1 -1
  122. package/dist-server/routers/api/restful-apis/v2/get-delivery-orders.js +27 -11
  123. package/dist-server/routers/api/restful-apis/v2/get-delivery-orders.js.map +1 -1
  124. package/dist-server/routers/api/restful-apis/v2/get-goods-received-notes.js +9 -2
  125. package/dist-server/routers/api/restful-apis/v2/get-goods-received-notes.js.map +1 -1
  126. package/dist-server/routers/api/restful-apis/v2/get-onhand-inventories.js +2 -2
  127. package/dist-server/routers/api/restful-apis/v2/get-onhand-inventories.js.map +1 -1
  128. package/dist-server/routers/api/restful-apis/v2/get-partners.js +5 -4
  129. package/dist-server/routers/api/restful-apis/v2/get-partners.js.map +1 -1
  130. package/dist-server/routers/api/restful-apis/v2/get-products.js +1 -0
  131. package/dist-server/routers/api/restful-apis/v2/get-products.js.map +1 -1
  132. package/dist-server/routers/api/restful-apis/v2/get-warehouses.js +2 -2
  133. package/dist-server/routers/api/restful-apis/v2/get-warehouses.js.map +1 -1
  134. package/dist-server/routers/api/restful-apis/v2/update-release-order-details.js +2 -2
  135. package/dist-server/routers/api/restful-apis/v2/update-release-order-details.js.map +1 -1
  136. package/dist-server/routers/auth-invitation-router.js +2 -2
  137. package/dist-server/routers/auth-invitation-router.js.map +1 -1
  138. package/dist-server/routers/business/bizplace-register-router.js +3 -3
  139. package/dist-server/routers/business/bizplace-register-router.js.map +1 -1
  140. package/dist-server/tsconfig.tsbuildinfo +1 -1
  141. package/dist-server/utils/get-warehouses.js +15 -11
  142. package/dist-server/utils/get-warehouses.js.map +1 -1
  143. package/openapi/unstable/product.yaml +9 -3
  144. package/openapi/v1/product.yaml +9 -3
  145. package/openapi/v2/product.yaml +9 -3
  146. package/package.json +47 -47
  147. package/server/controllers/bizplace-initializer/dataset/codes.ts +9 -0
  148. package/server/controllers/bizplace-initializer/dataset/settings.ts +5 -0
  149. package/server/controllers/bizplace-initializer/generate-bizplace-domain-roles.ts +4 -2
  150. package/server/controllers/bizplace-initializer/generate-bizplace-domain.ts +4 -3
  151. package/server/controllers/bizplace-initializer/menus.ts +4 -2
  152. package/server/controllers/company-initializer/business-register.ts +5 -3
  153. package/server/controllers/company-initializer/generate-company-roles.ts +4 -3
  154. package/server/controllers/invitation.ts +11 -7
  155. package/server/controllers/utils/save-invitation-token.ts +1 -1
  156. package/server/graphql/resolvers/generators/generate-bizplace.ts +1 -1
  157. package/server/graphql/resolvers/generators/generate-company.ts +5 -4
  158. package/server/graphql/resolvers/generators/update-domain-extType.ts +7 -5
  159. package/server/graphql/resolvers/invitations/partner-invitation.ts +5 -5
  160. package/server/graphql/resolvers/oauth2/company-roles-by-scope.ts +8 -6
  161. package/server/graphql/resolvers/synchronization/auto-update-all-marketplace-product-variation-quantity.ts +180 -0
  162. package/server/graphql/resolvers/synchronization/create-dat-shipments.ts +64 -0
  163. package/server/graphql/resolvers/synchronization/fetch-sync-products.ts +3 -2
  164. package/server/graphql/resolvers/synchronization/index.ts +10 -2
  165. package/server/graphql/resolvers/synchronization/sellercraft-pack-marketplace-order.ts +91 -0
  166. package/server/graphql/resolvers/synchronization/sync-all-products-to-sellercraft.ts +39 -0
  167. package/server/graphql/resolvers/synchronization/sync-products-from-account.ts +4 -4
  168. package/server/graphql/resolvers/synchronization/sync-products-to-account.ts +4 -4
  169. package/server/graphql/resolvers/synchronization/sync-products-to-sellercraft.ts +19 -12
  170. package/server/graphql/types/synchronization/index.ts +4 -0
  171. package/server/index.ts +7 -7
  172. package/server/middlewares/business-middleware.ts +1 -2
  173. package/server/middlewares/store-middleware.ts +1 -1
  174. package/server/middlewares/warehouse-middleware.ts +3 -2
  175. package/server/migrations/1597668478399-SeedBusinessDomain.ts +3 -2
  176. package/server/migrations/1597668478401-SeedBusinessRoles.ts +2 -2
  177. package/server/migrations/1608009991065-SeedUser.ts +5 -3
  178. package/server/routers/api/restful-apis/unstable/add-draft-release-order.ts +2 -1
  179. package/server/routers/api/restful-apis/unstable/add-inbound-order.ts +3 -2
  180. package/server/routers/api/restful-apis/unstable/add-marketplace-order.ts +13 -2
  181. package/server/routers/api/restful-apis/unstable/add-products.ts +40 -16
  182. package/server/routers/api/restful-apis/unstable/add-release-order.ts +98 -48
  183. package/server/routers/api/restful-apis/unstable/cancel-release-order.ts +2 -2
  184. package/server/routers/api/restful-apis/unstable/get-delivery-orders.ts +27 -11
  185. package/server/routers/api/restful-apis/unstable/get-goods-received-notes.ts +9 -2
  186. package/server/routers/api/restful-apis/unstable/get-onhand-inventories.ts +1 -1
  187. package/server/routers/api/restful-apis/unstable/get-partners.ts +4 -2
  188. package/server/routers/api/restful-apis/unstable/get-products.ts +1 -0
  189. package/server/routers/api/restful-apis/unstable/get-warehouses.ts +3 -2
  190. package/server/routers/api/restful-apis/unstable/update-release-order-details.ts +1 -1
  191. package/server/routers/api/restful-apis/v1/add-inbound-order.ts +4 -3
  192. package/server/routers/api/restful-apis/v1/add-marketplace-order.ts +17 -5
  193. package/server/routers/api/restful-apis/v1/add-products.ts +40 -16
  194. package/server/routers/api/restful-apis/v1/add-release-order.ts +10 -6
  195. package/server/routers/api/restful-apis/v1/cancel-release-order.ts +2 -2
  196. package/server/routers/api/restful-apis/v1/get-delivery-orders.ts +27 -11
  197. package/server/routers/api/restful-apis/v1/get-goods-received-notes.ts +9 -2
  198. package/server/routers/api/restful-apis/v1/get-onhand-inventories.ts +1 -1
  199. package/server/routers/api/restful-apis/v1/get-partners.ts +4 -2
  200. package/server/routers/api/restful-apis/v1/get-products.ts +1 -0
  201. package/server/routers/api/restful-apis/v1/get-warehouses.ts +3 -2
  202. package/server/routers/api/restful-apis/v1/update-release-order-details.ts +1 -1
  203. package/server/routers/api/restful-apis/v2/add-inbound-order.ts +4 -3
  204. package/server/routers/api/restful-apis/v2/add-marketplace-order.ts +17 -5
  205. package/server/routers/api/restful-apis/v2/add-products.ts +40 -16
  206. package/server/routers/api/restful-apis/v2/add-release-order.ts +10 -6
  207. package/server/routers/api/restful-apis/v2/cancel-release-order.ts +2 -2
  208. package/server/routers/api/restful-apis/v2/get-delivery-orders.ts +27 -11
  209. package/server/routers/api/restful-apis/v2/get-goods-received-notes.ts +9 -2
  210. package/server/routers/api/restful-apis/v2/get-onhand-inventories.ts +1 -1
  211. package/server/routers/api/restful-apis/v2/get-partners.ts +4 -2
  212. package/server/routers/api/restful-apis/v2/get-products.ts +1 -0
  213. package/server/routers/api/restful-apis/v2/get-warehouses.ts +3 -2
  214. package/server/routers/api/restful-apis/v2/update-release-order-details.ts +1 -1
  215. package/server/routers/auth-invitation-router.ts +2 -2
  216. package/server/routers/business/bizplace-register-router.ts +3 -1
  217. package/server/utils/get-warehouses.ts +46 -36
@@ -1 +1 @@
1
- {"version":3,"file":"get-onhand-inventories.js","sourceRoot":"","sources":["../../../../../server/routers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E,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAA;SACjG;aAAM;YACL,OAAO,GAAG,CAAC,GAAG,OAAO,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,KAAK,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAA;SAC5F;KACF;IAED,IAAI,OAAO,EAAE;QACX,OAAO,GAAG,CAAC,GAAG,OAAO,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAA;KAC5E;IAED,OAAO,OAAO,CAAA;AAChB,CAAC;AAjCD,sCAiCC","sourcesContent":["import gql from 'graphql-tag'\nimport { getRepository } from 'typeorm'\n\nimport { restfulApiRouter as router } from '@things-factory/api'\nimport { Product } from '@things-factory/product-base'\n\nimport { businessMiddleware } from '../../../../middlewares/business-middleware'\nimport { warehouseMiddleware } from '../../../../middlewares/warehouse-middleware'\n\nconst debug = require('debug')('things-factory:operato-hub:restful-api:unstable:onhand-inventories')\n\nrouter.get(\n '/unstable/warehouse/:warehouseId/onhand-inventories',\n businessMiddleware,\n warehouseMiddleware,\n async (context, next) => {\n const { client, warehouse: bizplace, domain } = context.state\n const { skuId, batchId } = context.query\n const { t } = context\n const { warehouseId } = context.params\n\n if (!warehouseId) context.throw(404, t('error.warehouse id not found'))\n if (!skuId) context.throw(400, context.t('error.required param x not found', { x: 'skuId' }))\n if (!batchId) context.throw(400, context.t('error.required param x not found', { x: 'batchId' }))\n debug('query-params', context.query)\n\n let filters = await checkValidity(bizplace, skuId, batchId)\n\n context.body = {\n result: (\n await client.query({\n query: gql`\n query inventories($filters: [Filter!]) {\n inventories(filters: $filters) {\n items {\n id\n palletId\n batchId\n packingType\n weight\n bizplace {\n id\n name\n description\n }\n product {\n id\n name\n description\n sku\n }\n qty\n remainQty\n warehouse {\n id\n name\n description\n }\n zone\n location {\n id\n name\n description\n }\n updatedAt\n updater {\n name\n description\n }\n }\n total\n }\n }\n `,\n variables: {\n filters\n },\n context: {\n ...context,\n state: {\n ...context.state,\n bizplace,\n domain\n }\n }\n } as any)\n ).data\n }\n }\n)\n\nexport async function checkValidity(bizplace, skuId, batchId) {\n let product: Product = []\n\n let filters: any = [\n { name: 'status', operator: 'notin', value: ['INTRANSIT', 'TERMINATED', 'DELETED'] },\n { name: 'remainOnly', operator: 'eq', value: true },\n { name: 'unlockOnly', operator: 'eq', value: true }\n ]\n\n if (bizplace.id != '') {\n filters = [...filters, { name: 'bizplace', operator: 'in', value: [bizplace.id], relation: true }]\n }\n\n if (skuId) {\n product = await getRepository(Product).findOne({\n where: {\n sku: skuId\n },\n relations: ['domain']\n })\n\n if (product) {\n filters = [...filters, { name: 'product', operator: 'in', value: [product.id], relation: true }]\n } else {\n filters = [...filters, { name: 'product', operator: 'in', value: [skuId], relation: true }]\n }\n }\n\n if (batchId) {\n filters = [...filters, { name: 'batchId', operator: 'eq', value: batchId }]\n }\n\n return filters\n}\n"]}
1
+ {"version":3,"file":"get-onhand-inventories.js","sourceRoot":"","sources":["../../../../../server/routers/api/restful-apis/unstable/get-onhand-inventories.ts"],"names":[],"mappings":";;;;AAAA,sEAA6B;AAE7B,6CAAgE;AAChE,+DAAsD;AACtD,iDAAqD;AAErD,qFAAgF;AAChF,uFAAkF;AAElF,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,oEAAoE,CAAC,CAAA;AAEpG,sBAAM,CAAC,GAAG,CACR,qDAAqD,EACrD,wCAAkB,EAClB,0CAAmB,EACnB,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;IACtB,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;IA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,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAA;KAC5E;IAED,OAAO,OAAO,CAAA;AAChB,CAAC;AAjCD,sCAiCC","sourcesContent":["import gql from 'graphql-tag'\n\nimport { restfulApiRouter as router } from '@things-factory/api'\nimport { Product } from '@things-factory/product-base'\nimport { getRepository } from '@things-factory/shell'\n\nimport { businessMiddleware } from '../../../../middlewares/business-middleware'\nimport { warehouseMiddleware } from '../../../../middlewares/warehouse-middleware'\n\nconst debug = require('debug')('things-factory:operato-hub:restful-api:unstable:onhand-inventories')\n\nrouter.get(\n '/unstable/warehouse/:warehouseId/onhand-inventories',\n businessMiddleware,\n warehouseMiddleware,\n async (context, next) => {\n const { client, warehouse: bizplace, domain } = context.state\n const { skuId, batchId } = context.query\n const { t } = context\n const { warehouseId } = context.params\n\n if (!warehouseId) context.throw(404, t('error.warehouse id not found'))\n if (!skuId) context.throw(400, context.t('error.required param x not found', { x: 'skuId' }))\n if (!batchId) context.throw(400, context.t('error.required param x not found', { x: 'batchId' }))\n debug('query-params', context.query)\n\n let filters = await checkValidity(bizplace, skuId, batchId)\n\n context.body = {\n result: (\n await client.query({\n query: gql`\n query inventories($filters: [Filter!]) {\n inventories(filters: $filters) {\n items {\n id\n palletId\n batchId\n packingType\n weight\n bizplace {\n id\n name\n description\n }\n product {\n id\n name\n description\n sku\n }\n qty\n remainQty\n warehouse {\n id\n name\n description\n }\n zone\n location {\n id\n name\n description\n }\n updatedAt\n updater {\n name\n description\n }\n }\n total\n }\n }\n `,\n variables: {\n filters\n },\n context: {\n ...context,\n state: {\n ...context.state,\n bizplace,\n domain\n }\n }\n } as any)\n ).data\n }\n }\n)\n\nexport async function checkValidity(bizplace, skuId, batchId) {\n let product: Product = []\n\n let filters: any = [\n { name: 'status', operator: 'notin', value: ['INTRANSIT', 'TERMINATED', 'DELETED'] },\n { name: 'remainOnly', operator: 'eq', value: true },\n { name: 'unlockOnly', operator: 'eq', value: true }\n ]\n\n if (bizplace.id != '') {\n filters = [...filters, { name: 'bizplace', operator: 'in', value: [bizplace.id], relation: true }]\n }\n\n if (skuId) {\n product = await getRepository(Product).findOne({\n where: {\n sku: skuId\n },\n relations: ['domain']\n })\n\n if (product) {\n filters = [...filters, { name: 'product', operator: 'in', value: [product.id], relation: true }]\n } else {\n filters = [...filters, { name: 'product', operator: 'in', value: [skuId], relation: true }]\n }\n }\n\n if (batchId) {\n filters = [...filters, { name: 'batchId', operator: 'eq', value: batchId }]\n }\n\n return filters\n}\n"]}
@@ -1,18 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ const typeorm_1 = require("typeorm");
3
4
  const api_1 = require("@things-factory/api");
4
5
  const biz_base_1 = require("@things-factory/biz-base");
5
- const typeorm_1 = require("typeorm");
6
+ const shell_1 = require("@things-factory/shell");
6
7
  const debug = require('debug')('things-factory:operato-hub:restful-api:unstable:get-partners');
7
8
  api_1.restfulApiRouter.get('/unstable/partners/:bizplaceId', async (context, next) => {
8
9
  const { bizplaceId } = context.params;
9
- const bizplace = await (0, typeorm_1.getRepository)(biz_base_1.Bizplace).findOne(bizplaceId);
10
- const partners = await (0, typeorm_1.getRepository)(biz_base_1.Partner).find({
10
+ const bizplace = await (0, shell_1.getRepository)(biz_base_1.Bizplace).findOneBy({ id: bizplaceId });
11
+ const partners = await (0, shell_1.getRepository)(biz_base_1.Partner).find({
11
12
  where: { partnerBizplace: bizplace },
12
13
  relations: ['domainBizplace']
13
14
  });
14
15
  const domainBizplacesId = partners.map((p) => p.domainBizplace.id);
15
- const domainBizplaces = await (0, typeorm_1.getRepository)(biz_base_1.Bizplace).find({
16
+ const domainBizplaces = await (0, shell_1.getRepository)(biz_base_1.Bizplace).find({
16
17
  where: { id: (0, typeorm_1.In)(domainBizplacesId) },
17
18
  relations: ['domain']
18
19
  });
@@ -1 +1 @@
1
- {"version":3,"file":"get-partners.js","sourceRoot":"","sources":["../../../../../server/routers/api/restful-apis/unstable/get-partners.ts"],"names":[],"mappings":";;AAAA,6CAAgE;AAChE,uDAA4D;AAC5D,qCAA2C;AAE3C,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,8DAA8D,CAAC,CAAA;AAE9F,sBAAM,CAAC,GAAG,CAAC,gCAAgC,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;IACnE,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,MAAM,CAAA;IACrC,MAAM,QAAQ,GAAa,MAAM,IAAA,uBAAa,EAAC,mBAAQ,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;IAC5E,MAAM,QAAQ,GAAc,MAAM,IAAA,uBAAa,EAAC,kBAAO,CAAC,CAAC,IAAI,CAAC;QAC5D,KAAK,EAAE,EAAE,eAAe,EAAE,QAAQ,EAAE;QACpC,SAAS,EAAE,CAAC,gBAAgB,CAAC;KAC9B,CAAC,CAAA;IAEF,MAAM,iBAAiB,GAAa,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAU,EAAE,EAAE,CAAC,CAAC,CAAC,cAAc,CAAC,EAAE,CAAC,CAAA;IACrF,MAAM,eAAe,GAAa,MAAM,IAAA,uBAAa,EAAC,mBAAQ,CAAC,CAAC,IAAI,CAAC;QACnE,KAAK,EAAE,EAAE,EAAE,EAAE,IAAA,YAAE,EAAC,iBAAiB,CAAC,EAAE;QACpC,SAAS,EAAE,CAAC,QAAQ,CAAC;KACtB,CAAC,CAAA;IAEF,OAAO,CAAC,IAAI,GAAG;QACb,MAAM,EAAE,eAAe,CAAC,GAAG,CAAC,CAAC,CAAW,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;KACvD,CAAA;AACH,CAAC,CAAC,CAAA","sourcesContent":["import { restfulApiRouter as router } from '@things-factory/api'\nimport { Bizplace, Partner } from '@things-factory/biz-base'\nimport { getRepository, In } from 'typeorm'\n\nconst debug = require('debug')('things-factory:operato-hub:restful-api:unstable:get-partners')\n\nrouter.get('/unstable/partners/:bizplaceId', async (context, next) => {\n const { bizplaceId } = context.params\n const bizplace: Bizplace = await getRepository(Bizplace).findOne(bizplaceId)\n const partners: Partner[] = await getRepository(Partner).find({\n where: { partnerBizplace: bizplace },\n relations: ['domainBizplace']\n })\n\n const domainBizplacesId: string[] = partners.map((p: Partner) => p.domainBizplace.id)\n const domainBizplaces: Bizplace = await getRepository(Bizplace).find({\n where: { id: In(domainBizplacesId) },\n relations: ['domain']\n })\n\n context.body = {\n result: domainBizplaces.map((b: Bizplace) => b.domain)\n }\n})\n"]}
1
+ {"version":3,"file":"get-partners.js","sourceRoot":"","sources":["../../../../../server/routers/api/restful-apis/unstable/get-partners.ts"],"names":[],"mappings":";;AAAA,qCAA4B;AAE5B,6CAAgE;AAChE,uDAA4D;AAC5D,iDAAqD;AAErD,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,8DAA8D,CAAC,CAAA;AAE9F,sBAAM,CAAC,GAAG,CAAC,gCAAgC,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;IACnE,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,MAAM,CAAA;IACrC,MAAM,QAAQ,GAAa,MAAM,IAAA,qBAAa,EAAC,mBAAQ,CAAC,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC,CAAA;IACtF,MAAM,QAAQ,GAAc,MAAM,IAAA,qBAAa,EAAC,kBAAO,CAAC,CAAC,IAAI,CAAC;QAC5D,KAAK,EAAE,EAAE,eAAe,EAAE,QAAQ,EAAE;QACpC,SAAS,EAAE,CAAC,gBAAgB,CAAC;KAC9B,CAAC,CAAA;IAEF,MAAM,iBAAiB,GAAa,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAU,EAAE,EAAE,CAAC,CAAC,CAAC,cAAc,CAAC,EAAE,CAAC,CAAA;IACrF,MAAM,eAAe,GAAa,MAAM,IAAA,qBAAa,EAAC,mBAAQ,CAAC,CAAC,IAAI,CAAC;QACnE,KAAK,EAAE,EAAE,EAAE,EAAE,IAAA,YAAE,EAAC,iBAAiB,CAAC,EAAE;QACpC,SAAS,EAAE,CAAC,QAAQ,CAAC;KACtB,CAAC,CAAA;IAEF,OAAO,CAAC,IAAI,GAAG;QACb,MAAM,EAAE,eAAe,CAAC,GAAG,CAAC,CAAC,CAAW,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;KACvD,CAAA;AACH,CAAC,CAAC,CAAA","sourcesContent":["import { In } from 'typeorm'\n\nimport { restfulApiRouter as router } from '@things-factory/api'\nimport { Bizplace, Partner } from '@things-factory/biz-base'\nimport { getRepository } from '@things-factory/shell'\n\nconst debug = require('debug')('things-factory:operato-hub:restful-api:unstable:get-partners')\n\nrouter.get('/unstable/partners/:bizplaceId', async (context, next) => {\n const { bizplaceId } = context.params\n const bizplace: Bizplace = await getRepository(Bizplace).findOneBy({ id: bizplaceId })\n const partners: Partner[] = await getRepository(Partner).find({\n where: { partnerBizplace: bizplace },\n relations: ['domainBizplace']\n })\n\n const domainBizplacesId: string[] = partners.map((p: Partner) => p.domainBizplace.id)\n const domainBizplaces: Bizplace = await getRepository(Bizplace).find({\n where: { id: In(domainBizplacesId) },\n relations: ['domain']\n })\n\n context.body = {\n result: domainBizplaces.map((b: Bizplace) => b.domain)\n }\n})\n"]}
@@ -33,6 +33,7 @@ api_1.restfulApiRouter.get('/unstable/warehouse/:warehouseId/get-products', busi
33
33
  brandSku
34
34
  isRequiredCheckExpiry
35
35
  expirationPeriod
36
+ pickingStrategy
36
37
  auxUnit1
37
38
  auxValue1
38
39
  auxUnit2
@@ -1 +1 @@
1
- {"version":3,"file":"get-products.js","sourceRoot":"","sources":["../../../../../server/routers/api/restful-apis/unstable/get-products.ts"],"names":[],"mappings":";;;;AAAA,sEAA6B;AAE7B,6CAAgE;AAEhE,qFAAgF;AAChF,uFAAkF;AAElF,sBAAM,CAAC,GAAG,CACR,+CAA+C,EAC/C,wCAAkB,EAClB,0CAAmB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GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,gDAAgD,CAAC,CAAC,CAAA;aAChG,IAAI,OAAO,GAAG,GAAG;YAAE,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,kDAAkD,CAAC,CAAC,CAAA;;YACpG,UAAU,mCAAQ,UAAU,KAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAE,CAAA;KAClE;SAAM,IAAI,OAAO,KAAK,EAAE,IAAI,MAAM,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,EAAE;QACvE,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAA;QAE3B,IAAI,OAAO,GAAG,CAAC;YAAE,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,gDAAgD,CAAC,CAAC,CAAA;aAC3F,IAAI,OAAO,GAAG,GAAG;YAAE,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,kDAAkD,CAAC,CAAC,CAAA;;YACpG,UAAU,mCAAQ,UAAU,KAAE,KAAK,EAAE,OAAO,GAAE,CAAA;KACpD;IAED,OAAO,UAAU,CAAA;AACnB,CAAC;AArBD,gDAqBC","sourcesContent":["import gql from 'graphql-tag'\n\nimport { restfulApiRouter as router } from '@things-factory/api'\n\nimport { businessMiddleware } from '../../../../middlewares/business-middleware'\nimport { warehouseMiddleware } from '../../../../middlewares/warehouse-middleware'\n\nrouter.get(\n '/unstable/warehouse/:warehouseId/get-products',\n businessMiddleware,\n warehouseMiddleware,\n async (context, next) => {\n const { client, warehouse: bizplace, domain } = context.state\n const { warehouseId } = context.params\n const { t } = context\n const { skuId, name, paginationEntriesPerPage, paginationOffset } = context.query\n\n if (!warehouseId) context.throw(404, t('error.warehouse id not found'))\n\n let filters: any = [{ name: 'bizplace_id', operator: 'eq', value: warehouseId }]\n let pagination: any = { page: 1, limit: 20 }\n\n filters = await validateFilters(filters, skuId, name)\n pagination = await validatePagination(context, pagination, paginationEntriesPerPage, paginationOffset)\n\n context.body = {\n result: (\n await client.query({\n query: gql`\n query products($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {\n products(filters: $filters, pagination: $pagination, sortings: $sortings) {\n items {\n id\n sku\n name\n description\n type\n brand\n subBrand\n brandSku\n isRequiredCheckExpiry\n expirationPeriod\n auxUnit1\n auxValue1\n auxUnit2\n auxValue2\n auxUnit3\n auxValue3\n updatedAt\n ###############################################\n ## TEMPORARY REMOVE DUE TO TYPEGRAPHQL ISSUE ##\n # updater {\n # id\n # name\n # }\n # creator {\n # id\n # name\n # }\n ###############################################\n productDetails {\n id\n gtin\n sku\n description\n type\n refCode\n isDefault\n packingType\n packingSize\n movement\n uom\n uomValue\n childProductDetail {\n id\n gtin\n sku\n description\n type\n refCode\n product {\n id\n }\n isDefault\n packingType\n packingSize\n movement\n uom\n uomValue\n bundleQty\n weightUnit\n nettWeight\n grossWeight\n lengthUnit\n width\n depth\n height\n volume\n bufferQty\n minQty\n maxQty\n auxUnit1\n auxValue1\n auxUnit2\n auxValue2\n auxUnit3\n auxValue3\n auxUnit4\n auxValue4\n auxUnit5\n auxValue5\n costPrice\n sellPrice\n afterTaxCostPrice\n afterTaxSalesPrice\n updatedAt\n createdAt\n deletedAt\n }\n childQty\n bundleQty\n weightUnit\n nettWeight\n grossWeight\n lengthUnit\n width\n depth\n height\n volume\n bufferQty\n minQty\n maxQty\n auxUnit1\n auxValue1\n auxUnit2\n auxValue2\n auxUnit3\n auxValue3\n auxUnit4\n auxValue4\n auxUnit5\n auxValue5\n costPrice\n sellPrice\n afterTaxCostPrice\n afterTaxSalesPrice\n ###############################################\n ## TEMPORARY REMOVE DUE TO TYPEGRAPHQL ISSUE ##\n # updater {\n # id\n # name\n # }\n # creator {\n # id\n # name\n # }\n ###############################################\n updatedAt\n createdAt\n deletedAt\n }\n }\n total\n }\n }\n `,\n variables: {\n filters,\n pagination,\n sortings: []\n },\n context: {\n ...context,\n state: {\n ...context.state,\n bizplace,\n domain\n }\n }\n } as any)\n ).data\n }\n }\n)\n\nexport async function validateFilters(filters, skuId, name) {\n if (skuId && skuId !== '') filters = [...filters, { name: 'sku', operator: 'i_like', value: skuId }]\n\n if (name && name !== '') filters = [...filters, { name: 'name', operator: 'i_like', value: name }]\n\n return filters\n}\n\nexport async function validatePagination(context, pagination, entries, offset) {\n if (!entries) entries = ''\n if (!offset) offset = ''\n\n if (entries !== '' && offset !== '' && !isNaN(parseInt(entries)) && !isNaN(parseInt(offset))) {\n entries = parseInt(entries)\n offset = parseInt(offset)\n\n if (offset < 1) context.throw(400, context.t('paginationOffset cannot be less than 1'))\n else if (entries < 1) context.throw(400, context.t('paginationEntriesPerPage cannot be less than 1'))\n else if (entries > 100) context.throw(400, context.t('paginationEntriesPerPage cannot be more than 100'))\n else pagination = { ...pagination, page: offset, limit: entries }\n } else if (entries !== '' && offset === '' && !isNaN(parseInt(entries))) {\n entries = parseInt(entries)\n\n if (entries < 1) context.throw(400, context.t('paginationEntriesPerPage cannot be less than 1'))\n else if (entries > 100) context.throw(400, context.t('paginationEntriesPerPage cannot be more than 100'))\n else pagination = { ...pagination, limit: entries }\n }\n\n return pagination\n}\n"]}
1
+ {"version":3,"file":"get-products.js","sourceRoot":"","sources":["../../../../../server/routers/api/restful-apis/unstable/get-products.ts"],"names":[],"mappings":";;;;AAAA,sEAA6B;AAE7B,6CAAgE;AAEhE,qFAAgF;AAChF,uFAAkF;AAElF,sBAAM,CAAC,GAAG,CACR,+CAA+C,EAC/C,wCAAkB,EAClB,0CAAmB,EACnB,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;IACtB,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;IAC7D,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,MAAM,CAAA;IACtC,MAAM,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IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAE,CAAA;KAClE;SAAM,IAAI,OAAO,KAAK,EAAE,IAAI,MAAM,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,EAAE;QACvE,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAA;QAE3B,IAAI,OAAO,GAAG,CAAC;YAAE,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,gDAAgD,CAAC,CAAC,CAAA;aAC3F,IAAI,OAAO,GAAG,GAAG;YAAE,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,kDAAkD,CAAC,CAAC,CAAA;;YACpG,UAAU,mCAAQ,UAAU,KAAE,KAAK,EAAE,OAAO,GAAE,CAAA;KACpD;IAED,OAAO,UAAU,CAAA;AACnB,CAAC;AArBD,gDAqBC","sourcesContent":["import gql from 'graphql-tag'\n\nimport { restfulApiRouter as router } from '@things-factory/api'\n\nimport { businessMiddleware } from '../../../../middlewares/business-middleware'\nimport { warehouseMiddleware } from '../../../../middlewares/warehouse-middleware'\n\nrouter.get(\n '/unstable/warehouse/:warehouseId/get-products',\n businessMiddleware,\n warehouseMiddleware,\n async (context, next) => {\n const { client, warehouse: bizplace, domain } = context.state\n const { warehouseId } = context.params\n const { t } = context\n const { skuId, name, paginationEntriesPerPage, paginationOffset } = context.query\n\n if (!warehouseId) context.throw(404, t('error.warehouse id not found'))\n\n let filters: any = [{ name: 'bizplace_id', operator: 'eq', value: warehouseId }]\n let pagination: any = { page: 1, limit: 20 }\n\n filters = await validateFilters(filters, skuId, name)\n pagination = await validatePagination(context, pagination, paginationEntriesPerPage, paginationOffset)\n\n context.body = {\n result: (\n await client.query({\n query: gql`\n query products($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {\n products(filters: $filters, pagination: $pagination, sortings: $sortings) {\n items {\n id\n sku\n name\n description\n type\n brand\n subBrand\n brandSku\n isRequiredCheckExpiry\n expirationPeriod\n pickingStrategy\n auxUnit1\n auxValue1\n auxUnit2\n auxValue2\n auxUnit3\n auxValue3\n updatedAt\n ###############################################\n ## TEMPORARY REMOVE DUE TO TYPEGRAPHQL ISSUE ##\n # updater {\n # id\n # name\n # }\n # creator {\n # id\n # name\n # }\n ###############################################\n productDetails {\n id\n gtin\n sku\n description\n type\n refCode\n isDefault\n packingType\n packingSize\n movement\n uom\n uomValue\n childProductDetail {\n id\n gtin\n sku\n description\n type\n refCode\n product {\n id\n }\n isDefault\n packingType\n packingSize\n movement\n uom\n uomValue\n bundleQty\n weightUnit\n nettWeight\n grossWeight\n lengthUnit\n width\n depth\n height\n volume\n bufferQty\n minQty\n maxQty\n auxUnit1\n auxValue1\n auxUnit2\n auxValue2\n auxUnit3\n auxValue3\n auxUnit4\n auxValue4\n auxUnit5\n auxValue5\n costPrice\n sellPrice\n afterTaxCostPrice\n afterTaxSalesPrice\n updatedAt\n createdAt\n deletedAt\n }\n childQty\n bundleQty\n weightUnit\n nettWeight\n grossWeight\n lengthUnit\n width\n depth\n height\n volume\n bufferQty\n minQty\n maxQty\n auxUnit1\n auxValue1\n auxUnit2\n auxValue2\n auxUnit3\n auxValue3\n auxUnit4\n auxValue4\n auxUnit5\n auxValue5\n costPrice\n sellPrice\n afterTaxCostPrice\n afterTaxSalesPrice\n ###############################################\n ## TEMPORARY REMOVE DUE TO TYPEGRAPHQL ISSUE ##\n # updater {\n # id\n # name\n # }\n # creator {\n # id\n # name\n # }\n ###############################################\n updatedAt\n createdAt\n deletedAt\n }\n }\n total\n }\n }\n `,\n variables: {\n filters,\n pagination,\n sortings: []\n },\n context: {\n ...context,\n state: {\n ...context.state,\n bizplace,\n domain\n }\n }\n } as any)\n ).data\n }\n }\n)\n\nexport async function validateFilters(filters, skuId, name) {\n if (skuId && skuId !== '') filters = [...filters, { name: 'sku', operator: 'i_like', value: skuId }]\n\n if (name && name !== '') filters = [...filters, { name: 'name', operator: 'i_like', value: name }]\n\n return filters\n}\n\nexport async function validatePagination(context, pagination, entries, offset) {\n if (!entries) entries = ''\n if (!offset) offset = ''\n\n if (entries !== '' && offset !== '' && !isNaN(parseInt(entries)) && !isNaN(parseInt(offset))) {\n entries = parseInt(entries)\n offset = parseInt(offset)\n\n if (offset < 1) context.throw(400, context.t('paginationOffset cannot be less than 1'))\n else if (entries < 1) context.throw(400, context.t('paginationEntriesPerPage cannot be less than 1'))\n else if (entries > 100) context.throw(400, context.t('paginationEntriesPerPage cannot be more than 100'))\n else pagination = { ...pagination, page: offset, limit: entries }\n } else if (entries !== '' && offset === '' && !isNaN(parseInt(entries))) {\n entries = parseInt(entries)\n\n if (entries < 1) context.throw(400, context.t('paginationEntriesPerPage cannot be less than 1'))\n else if (entries > 100) context.throw(400, context.t('paginationEntriesPerPage cannot be more than 100'))\n else pagination = { ...pagination, limit: entries }\n }\n\n return pagination\n}\n"]}
@@ -2,13 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const api_1 = require("@things-factory/api");
4
4
  const biz_base_1 = require("@things-factory/biz-base");
5
- const typeorm_1 = require("typeorm");
5
+ const shell_1 = require("@things-factory/shell");
6
6
  const utils_1 = require("../../../../utils");
7
7
  const debug = require('debug')('things-factory:operato-hub:restful-api:unstable:get-partners');
8
8
  api_1.restfulApiRouter.get('/unstable/get-warehouses/:bizplaceId', async (context, next) => {
9
9
  try {
10
10
  const { bizplaceId } = context.params;
11
- const bizplace = await (0, typeorm_1.getRepository)(biz_base_1.Bizplace).findOne(bizplaceId);
11
+ const bizplace = await (0, shell_1.getRepository)(biz_base_1.Bizplace).findOneBy({ id: bizplaceId });
12
12
  context.body = {
13
13
  result: await (0, utils_1.getBizplaceAccessibleWarehouses)(bizplace)
14
14
  };
@@ -1 +1 @@
1
- {"version":3,"file":"get-warehouses.js","sourceRoot":"","sources":["../../../../../server/routers/api/restful-apis/unstable/get-warehouses.ts"],"names":[],"mappings":";;AAAA,6CAAgE;AAChE,uDAAmD;AACnD,qCAAuC;AACvC,6CAAmE;AAEnE,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,8DAA8D,CAAC,CAAA;AAE9F,sBAAM,CAAC,GAAG,CAAC,sCAAsC,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;IACzE,IAAI;QACF,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,MAAM,CAAA;QACrC,MAAM,QAAQ,GAAa,MAAM,IAAA,uBAAa,EAAC,mBAAQ,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;QAC5E,OAAO,CAAC,IAAI,GAAG;YACb,MAAM,EAAE,MAAM,IAAA,uCAA+B,EAAC,QAAQ,CAAC;SACxD,CAAA;KACF;IAAC,OAAO,KAAK,EAAE;QACd,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAA;KACrC;AACH,CAAC,CAAC,CAAA","sourcesContent":["import { restfulApiRouter as router } from '@things-factory/api'\nimport { Bizplace } from '@things-factory/biz-base'\nimport { getRepository } from 'typeorm'\nimport { getBizplaceAccessibleWarehouses } from '../../../../utils'\n\nconst debug = require('debug')('things-factory:operato-hub:restful-api:unstable:get-partners')\n\nrouter.get('/unstable/get-warehouses/:bizplaceId', async (context, next) => {\n try {\n const { bizplaceId } = context.params\n const bizplace: Bizplace = await getRepository(Bizplace).findOne(bizplaceId)\n context.body = {\n result: await getBizplaceAccessibleWarehouses(bizplace)\n }\n } catch (error) {\n context.throw(400, context.t(error))\n }\n})\n"]}
1
+ {"version":3,"file":"get-warehouses.js","sourceRoot":"","sources":["../../../../../server/routers/api/restful-apis/unstable/get-warehouses.ts"],"names":[],"mappings":";;AAAA,6CAAgE;AAChE,uDAAmD;AACnD,iDAAqD;AAErD,6CAAmE;AAEnE,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,8DAA8D,CAAC,CAAA;AAE9F,sBAAM,CAAC,GAAG,CAAC,sCAAsC,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;IACzE,IAAI;QACF,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,MAAM,CAAA;QACrC,MAAM,QAAQ,GAAa,MAAM,IAAA,qBAAa,EAAC,mBAAQ,CAAC,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC,CAAA;QACtF,OAAO,CAAC,IAAI,GAAG;YACb,MAAM,EAAE,MAAM,IAAA,uCAA+B,EAAC,QAAQ,CAAC;SACxD,CAAA;KACF;IAAC,OAAO,KAAK,EAAE;QACd,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAA;KACrC;AACH,CAAC,CAAC,CAAA","sourcesContent":["import { restfulApiRouter as router } from '@things-factory/api'\nimport { Bizplace } from '@things-factory/biz-base'\nimport { getRepository } from '@things-factory/shell'\n\nimport { getBizplaceAccessibleWarehouses } from '../../../../utils'\n\nconst debug = require('debug')('things-factory:operato-hub:restful-api:unstable:get-partners')\n\nrouter.get('/unstable/get-warehouses/:bizplaceId', async (context, next) => {\n try {\n const { bizplaceId } = context.params\n const bizplace: Bizplace = await getRepository(Bizplace).findOneBy({ id: bizplaceId })\n context.body = {\n result: await getBizplaceAccessibleWarehouses(bizplace)\n }\n } catch (error) {\n context.throw(400, context.t(error))\n }\n})\n"]}
@@ -2,9 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const graphql_tag_1 = tslib_1.__importDefault(require("graphql-tag"));
5
- const typeorm_1 = require("typeorm");
6
5
  const api_1 = require("@things-factory/api");
7
6
  const biz_base_1 = require("@things-factory/biz-base");
7
+ const shell_1 = require("@things-factory/shell");
8
8
  const business_middleware_1 = require("../../../../middlewares/business-middleware");
9
9
  const warehouse_middleware_1 = require("../../../../middlewares/warehouse-middleware");
10
10
  const debug = require('debug')('things-factory:operato-hub:restful-api:unstable:update-release-order-details');
@@ -16,7 +16,7 @@ api_1.restfulApiRouter.post('/unstable/warehouse/:warehouseId/update-release-ord
16
16
  const bodyReq = context.request.body;
17
17
  if (!customerBizplaceId)
18
18
  context.throw(404, t('error.warehouse id not found'));
19
- const customerBizplace = await (0, typeorm_1.getRepository)(biz_base_1.Bizplace).findOne({
19
+ const customerBizplace = await (0, shell_1.getRepository)(biz_base_1.Bizplace).findOne({
20
20
  where: { id: customerBizplaceId }
21
21
  });
22
22
  if (typeof bodyReq === undefined || !((_a = Object.keys(bodyReq)) === null || _a === void 0 ? void 0 : _a.length)) {
@@ -1 +1 @@
1
- {"version":3,"file":"update-release-order-details.js","sourceRoot":"","sources":["../../../../../server/routers/api/restful-apis/unstable/update-release-order-details.ts"],"names":[],"mappings":";;;AAAA,sEAA6B;AAC7B,qCAAuC;AAEvC,6CAAgE;AAChE,uDAAmD;AAEnD,qFAAgF;AAChF,uFAAkF;AAElF,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,8EAA8E,CAAC,CAAA;AAE9G,sBAAM,CAAC,IAAI,CACT,+DAA+D,EAC/D,wCAAkB,EAClB,0CAAmB,EACnB,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;;IACtB,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;IACxC,MAAM,EAAE,WAAW,EAAE,kBAAkB,EAAE,GAAG,OAAO,CAAC,MAAM,CAAA;IAC1D,MAAM,EAAE,CAAC,EAAE,GAAG,OAAO,CAAA;IACrB,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAA;IAEpC,IAAI,CAAC,kBAAkB;QAAE,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,8BAA8B,CAAC,CAAC,CAAA;IAC9E,MAAM,gBAAgB,GAAa,MAAM,IAAA,uBAAa,EAAC,mBAAQ,CAAC,CAAC,OAAO,CAAC;QACvE,KAAK,EAAE,EAAE,EAAE,EAAE,kBAAkB,EAAE;KAClC,CAAC,CAAA;IAEF,IAAI,OAAO,OAAO,KAAK,SAAS,IAAI,CAAC,CAAA,MAAA,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,0CAAE,MAAM,CAAA,EAAE;QACjE,KAAK,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA;QACzB,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,mCAAmC,CAAC,CAAC,CAAA;KAC3D;IAED,IAAI,KAAK,GAAQ,EAAE,CAAA;IACnB,IAAI,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,YAAY;QAAE,KAAK,CAAC,WAAW,GAAG,OAAO,CAAC,YAAY,CAAA;;QAC9D,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,iDAAiD,CAAC,CAAC,CAAA;IAE7E,IAAI,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,aAAa;QAAE,KAAK,CAAC,aAAa,GAAG,OAAO,CAAC,aAAa,CAAA;;QAClE,KAAK,CAAC,aAAa,GAAG,IAAI,CAAA;IAE/B,OAAO,CAAC,IAAI,GAAG;QACb,MAAM,EAAE,CACN,MAAM,MAAM,CAAC,MAAM,CAAC;YAClB,QAAQ,EAAE,IAAA,qBAAG,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WAqCZ;YACD,SAAS,oBAAO,KAAK,CAAE;YACvB,OAAO,kCACF,OAAO,KACV,KAAK,kCACA,OAAO,CAAC,KAAK,KAChB,QAAQ,EAAE,gBAAgB,EAC1B,MAAM,EACN,IAAI,EAAE,KAAK,MAEd;SACK,CAAC,CACV,CAAC,IAAI;KACP,CAAA;AACH,CAAC,CACF,CAAA","sourcesContent":["import gql from 'graphql-tag'\nimport { getRepository } from 'typeorm'\n\nimport { restfulApiRouter as router } from '@things-factory/api'\nimport { Bizplace } from '@things-factory/biz-base'\n\nimport { businessMiddleware } from '../../../../middlewares/business-middleware'\nimport { warehouseMiddleware } from '../../../../middlewares/warehouse-middleware'\n\nconst debug = require('debug')('things-factory:operato-hub:restful-api:unstable:update-release-order-details')\n\nrouter.post(\n '/unstable/warehouse/:warehouseId/update-release-order-details',\n businessMiddleware,\n warehouseMiddleware,\n async (context, next) => {\n const { client, domain } = context.state\n const { warehouseId: customerBizplaceId } = context.params\n const { t } = context\n const bodyReq = context.request.body\n\n if (!customerBizplaceId) context.throw(404, t('error.warehouse id not found'))\n const customerBizplace: Bizplace = await getRepository(Bizplace).findOne({\n where: { id: customerBizplaceId }\n })\n\n if (typeof bodyReq === undefined || !Object.keys(bodyReq)?.length) {\n debug('bodyReq', bodyReq)\n context.throw(400, t('error.invalid body request format'))\n }\n\n let patch: any = {}\n if (bodyReq?.releaseOrder) patch.releaseGood = bodyReq.releaseOrder\n else context.throw(400, t('error.body request require releaseGood property'))\n\n if (bodyReq?.shippingOrder) patch.shippingOrder = bodyReq.shippingOrder\n else patch.shippingOrder = null\n\n context.body = {\n result: (\n await client.mutate({\n mutation: gql`\n mutation updateReleaseGoodDetails($releaseGood: ReleaseGoodPatch, $shippingOrder: ShippingOrderPatch) {\n updateReleaseGoodDetails(releaseGood: $releaseGood, shippingOrder: $shippingOrder) {\n id\n name\n refNo\n refNo2\n refNo3\n ownTransport\n collectionOrderNo\n exportOption\n courierOption\n packingOption\n type\n billingAddress\n deliveryAddress1\n deliveryAddress2\n deliveryAddress3\n deliveryAddress4\n deliveryAddress5\n attentionTo\n attentionCompany\n city\n state\n postalCode\n country\n phone1\n phone2\n email\n handoverType\n dropoffAddress\n pickupAddress\n transporter\n trackingNo\n marketplaceOrderStatus\n }\n }\n `,\n variables: { ...patch },\n context: {\n ...context,\n state: {\n ...context.state,\n bizplace: customerBizplace,\n domain,\n type: 'api'\n }\n }\n } as any)\n ).data\n }\n }\n)\n"]}
1
+ {"version":3,"file":"update-release-order-details.js","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,CAAC,WAAW,GAAG,OAAO,CAAC,YAAY,CAAA;;QAC9D,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,iDAAiD,CAAC,CAAC,CAAA;IAE7E,IAAI,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,aAAa;QAAE,KAAK,CAAC,aAAa,GAAG,OAAO,CAAC,aAAa,CAAA;;QAClE,KAAK,CAAC,aAAa,GAAG,IAAI,CAAA;IAE/B,OAAO,CAAC,IAAI,GAAG;QACb,MAAM,EAAE,CACN,MAAM,MAAM,CAAC,MAAM,CAAC;YAClB,QAAQ,EAAE,IAAA,qBAAG,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WAqCZ;YACD,SAAS,oBAAO,KAAK,CAAE;YACvB,OAAO,kCACF,OAAO,KACV,KAAK,kCACA,OAAO,CAAC,KAAK,KAChB,QAAQ,EAAE,gBAAgB,EAC1B,MAAM,EACN,IAAI,EAAE,KAAK,MAEd;SACK,CAAC,CACV,CAAC,IAAI;KACP,CAAA;AACH,CAAC,CACF,CAAA","sourcesContent":["import gql from 'graphql-tag'\n\nimport { restfulApiRouter as router } from '@things-factory/api'\nimport { Bizplace } from '@things-factory/biz-base'\nimport { getRepository } from '@things-factory/shell'\n\nimport { businessMiddleware } from '../../../../middlewares/business-middleware'\nimport { warehouseMiddleware } from '../../../../middlewares/warehouse-middleware'\n\nconst debug = require('debug')('things-factory:operato-hub:restful-api:unstable:update-release-order-details')\n\nrouter.post(\n '/unstable/warehouse/:warehouseId/update-release-order-details',\n businessMiddleware,\n warehouseMiddleware,\n async (context, next) => {\n const { client, domain } = context.state\n const { warehouseId: customerBizplaceId } = context.params\n const { t } = context\n const bodyReq = context.request.body\n\n if (!customerBizplaceId) context.throw(404, t('error.warehouse id not found'))\n const customerBizplace: Bizplace = await getRepository(Bizplace).findOne({\n where: { id: customerBizplaceId }\n })\n\n if (typeof bodyReq === undefined || !Object.keys(bodyReq)?.length) {\n debug('bodyReq', bodyReq)\n context.throw(400, t('error.invalid body request format'))\n }\n\n let patch: any = {}\n if (bodyReq?.releaseOrder) patch.releaseGood = bodyReq.releaseOrder\n else context.throw(400, t('error.body request require releaseGood property'))\n\n if (bodyReq?.shippingOrder) patch.shippingOrder = bodyReq.shippingOrder\n else patch.shippingOrder = null\n\n context.body = {\n result: (\n await client.mutate({\n mutation: gql`\n mutation updateReleaseGoodDetails($releaseGood: ReleaseGoodPatch, $shippingOrder: ShippingOrderPatch) {\n updateReleaseGoodDetails(releaseGood: $releaseGood, shippingOrder: $shippingOrder) {\n id\n name\n refNo\n refNo2\n refNo3\n ownTransport\n collectionOrderNo\n exportOption\n courierOption\n packingOption\n type\n billingAddress\n deliveryAddress1\n deliveryAddress2\n deliveryAddress3\n deliveryAddress4\n deliveryAddress5\n attentionTo\n attentionCompany\n city\n state\n postalCode\n country\n phone1\n phone2\n email\n handoverType\n dropoffAddress\n pickupAddress\n transporter\n trackingNo\n marketplaceOrderStatus\n }\n }\n `,\n variables: { ...patch },\n context: {\n ...context,\n state: {\n ...context.state,\n bizplace: customerBizplace,\n domain,\n type: 'api'\n }\n }\n } as any)\n ).data\n }\n }\n)\n"]}
@@ -7,6 +7,7 @@ const typeorm_1 = require("typeorm");
7
7
  const api_1 = require("@things-factory/api");
8
8
  const biz_base_1 = require("@things-factory/biz-base");
9
9
  const product_base_1 = require("@things-factory/product-base");
10
+ const shell_1 = require("@things-factory/shell");
10
11
  const business_middleware_1 = require("../../../../middlewares/business-middleware");
11
12
  const warehouse_middleware_1 = require("../../../../middlewares/warehouse-middleware");
12
13
  const debug = require('debug')('things-factory:operato-hub:restful-api:v1:add-inbound-order');
@@ -26,11 +27,11 @@ api_1.restfulApiRouter.post('/v1/warehouse/:warehouseId/add-inbound-order', busi
26
27
  debug('post:/add-inbound-order request.body', bodyReq);
27
28
  // get customer company's bizplace
28
29
  const custCompanyBizplace = await (0, biz_base_1.getCompanyBizplace)(null, null, warehouseId);
29
- const customerBizplace = await (0, typeorm_1.getRepository)(biz_base_1.Bizplace).findOne({
30
+ const customerBizplace = await (0, shell_1.getRepository)(biz_base_1.Bizplace).findOne({
30
31
  where: { id: warehouseId }
31
32
  });
32
33
  //#1 to get all product list
33
- const productDetails = await (0, typeorm_1.getRepository)(product_base_1.ProductDetail).find({
34
+ const productDetails = await (0, shell_1.getRepository)(product_base_1.ProductDetail).find({
34
35
  where: {
35
36
  domain: custCompanyBizplace.domain,
36
37
  refCode: (0, typeorm_1.In)(bodyReq.orderProducts.map(orderProduct => orderProduct.product.sku))
@@ -73,10 +74,10 @@ api_1.restfulApiRouter.post('/v1/warehouse/:warehouseId/add-inbound-order', busi
73
74
  //#4 include supplier id if there's any
74
75
  if (bodyReq === null || bodyReq === void 0 ? void 0 : bodyReq.supplier) {
75
76
  const supplierInfo = bodyReq.supplier;
76
- const foundSupplier = await (0, typeorm_1.getRepository)(biz_base_1.ContactPoint).findOne({
77
+ const foundSupplier = await (0, shell_1.getRepository)(biz_base_1.ContactPoint).findOne({
77
78
  where: {
78
- domain,
79
- bizplace: warehouseId,
79
+ domain: { id: domain.id },
80
+ bizplace: { id: warehouseId },
80
81
  name: supplierInfo.name,
81
82
  companyName: supplierInfo.companyName,
82
83
  email: supplierInfo.email,
@@ -1 +1 @@
1
- {"version":3,"file":"add-inbound-order.js","sourceRoot":"","sources":["../../../../../server/routers/api/restful-apis/v1/add-inbound-order.ts"],"names":[],"mappings":";;;;AAAA,sEAA6B;AAC7B,qCAA2C;AAE3C,6CAAgE;AAChE,uDAAqF;AACrF,+DAAqE;AAErE,qFAAgF;AAChF,uFAAkF;AAElF,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,6DAA6D,CAAC,CAAA;AAE7F,sBAAM,CAAC,IAAI,CACT,8CAA8C,EAC9C,wCAAkB,EAClB,0CAAmB,EACnB,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;;IACtB,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,O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uBAAZ,YAAY,CAAE,SAAS,CAAA;YAC1B,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,kCAAkC,EAAE,EAAE,CAAC,EAAE,wBAAwB,EAAE,CAAC,CAAC,CAAA;KACrG;IAED,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE;QACvB,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,kCAAkC,EAAE,EAAE,CAAC,EAAE,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,CAAA;KACnG;AACH,CAAC;AAjDD,8CAiDC","sourcesContent":["import gql from 'graphql-tag'\nimport { getRepository, In } from 'typeorm'\n\nimport { restfulApiRouter as router } from '@things-factory/api'\nimport { Bizplace, ContactPoint, getCompanyBizplace } from '@things-factory/biz-base'\nimport { Product, ProductDetail } from '@things-factory/product-base'\n\nimport { businessMiddleware } from '../../../../middlewares/business-middleware'\nimport { warehouseMiddleware } from '../../../../middlewares/warehouse-middleware'\n\nconst debug = require('debug')('things-factory:operato-hub:restful-api:v1:add-inbound-order')\n\nrouter.post(\n '/v1/warehouse/:warehouseId/add-inbound-order',\n businessMiddleware,\n warehouseMiddleware,\n async (context, next) => {\n const { client, domain } = context.state\n const { warehouseId } = context.params\n const { t } = context\n const attachments = undefined\n let bodyReq = context.request.body\n\n if (!warehouseId) context.throw(404, t('error.warehouse id not found'))\n\n if (typeof bodyReq === undefined || !Object.keys(bodyReq)?.length) {\n context.throw(400, t('error.invalid body request format'))\n }\n\n await checkMandatoryKey(context, bodyReq)\n debug('post:/add-inbound-order request.body', bodyReq)\n\n // get customer company's bizplace\n const custCompanyBizplace: Bizplace = await getCompanyBizplace(null, null, warehouseId)\n const customerBizplace: Bizplace = await getRepository(Bizplace).findOne({\n where: { id: warehouseId }\n })\n\n //#1 to get all product list\n const productDetails: ProductDetail[] = await getRepository(ProductDetail).find({\n where: {\n domain: custCompanyBizplace.domain,\n refCode: In(bodyReq.orderProducts.map(orderProduct => orderProduct.product.sku))\n },\n relations: ['product']\n })\n\n //#2 assign product id found to order product\n bodyReq.orderProducts = bodyReq.orderProducts.map(orderProduct => {\n productDetails.forEach(productDetail => {\n const product: Product = productDetail.product\n const packingType: string = productDetail.packingType\n const packingSize: number = productDetail.packingSize\n\n if (orderProduct.product.sku === productDetail.refCode) {\n orderProduct.product.id = product.id\n\n if (packingType) {\n orderProduct.packingType = packingType\n orderProduct.packingSize = packingSize\n orderProduct.uom = productDetail.uom\n orderProduct.uomValue = productDetail.uomValue\n orderProduct.totalUomValue = `${(productDetail.uomValue * orderProduct.packQty).toFixed(2)} ${\n productDetail.uom\n }`\n } else {\n productDetail = productDetails.find(productDetail => productDetail.isDefault)\n\n orderProduct.packingType = productDetail.packingType\n orderProduct.packingSize = productDetail.packingSize\n orderProduct.uom = productDetail.uom\n orderProduct.uomValue = productDetail.uomValue\n orderProduct.totalUomValue = `${(productDetail.uomValue * orderProduct.packQty).toFixed(2)} ${\n productDetail.uom\n }`\n }\n }\n })\n\n return orderProduct\n })\n\n //#3 check if product is not found\n bodyReq.orderProducts.forEach(orderProduct => {\n if (!orderProduct.product?.id) context.throw(404, t(`error.sku code ${orderProduct.product.sku} is not exist`))\n })\n\n //#4 include supplier id if there's any\n if (bodyReq?.supplier) {\n const supplierInfo = bodyReq.supplier\n const foundSupplier: ContactPoint = await getRepository(ContactPoint).findOne({\n where: {\n domain,\n bizplace: warehouseId,\n name: supplierInfo.name,\n companyName: supplierInfo.companyName,\n email: supplierInfo.email,\n accountNo: supplierInfo.accountNo,\n type: 'SUPPLIER'\n }\n })\n\n if (foundSupplier) bodyReq.supplier = foundSupplier.id\n else context.throw(404, t('error.supplier not found'))\n }\n\n context.body = {\n result: (\n await client.mutate({\n mutation: gql`\n mutation addArrivalNotice($arrivalNotice: NewArrivalNotice!, $attachments: Upload) {\n addArrivalNotice(arrivalNotice: $arrivalNotice, file: $attachments) {\n name\n refNo\n etaDate\n containerNo\n ownTransport\n crossDocking\n releaseGood {\n name\n }\n etaDate\n looseItem\n deliveryOrderNo\n status\n truckNo\n refNo\n importCargo\n orderProducts {\n batchId\n product {\n sku\n name\n description\n packingType\n type\n }\n packingType\n uom\n uomValue\n packQty\n totalUomValue\n palletQty\n }\n orderVass {\n vas {\n name\n operationGuide\n operationGuideType\n }\n set\n targetType\n targetBatchId\n targetProduct {\n name\n description\n }\n packingType\n qty\n uomValue\n otherTarget\n description\n remark\n operationGuide\n }\n supplier {\n companyName\n name\n phone\n email\n address\n }\n }\n }\n `,\n variables: { arrivalNotice: { ...bodyReq, warehouseId }, attachments },\n context: {\n ...context,\n hasUpload: true,\n state: {\n ...context.state,\n bizplace: customerBizplace,\n domain,\n type: 'api'\n }\n }\n } as any)\n ).data\n }\n }\n)\n\nexport function checkMandatoryKey(context, params) {\n let noparams = []\n\n if ('container' in params) {\n if (params.container === true) {\n if (!params.hasOwnProperty('containerNo') || !params.hasOwnProperty('containerSize')) {\n noparams.push('containerInfo')\n }\n }\n }\n\n if ('orderProducts' in params) {\n params.orderProducts.forEach((param, key) => {\n let noSubParams = []\n\n if (!param.batchId) noSubParams.push('batchId')\n\n if (!param.packQty) noSubParams.push('packQty')\n\n if (!param.product.sku) noSubParams.push('sku')\n\n if (noSubParams?.length)\n context.throw(400, context.t('error.required param x not found', { x: `${noSubParams.join(', ')}` }))\n })\n } else {\n noparams.push('orderProducts')\n }\n\n if ('etaDate' in params) {\n const etaDate = new Date(params.etaDate)\n\n if (isNaN(etaDate.getDate())) context.throw(400, context.t('error.eta date is invalid'))\n }\n\n if ('supplier' in params) {\n const supplierInfo = params.supplier\n if (!supplierInfo?.name)\n context.throw(400, context.t('error.required param x not found', { x: 'supplierInfo.name' }))\n if (!supplierInfo?.companyName)\n context.throw(400, context.t('error.required param x not found', { x: 'supplierInfo.companyName' }))\n if (!supplierInfo?.email)\n context.throw(400, context.t('error.required param x not found', { x: 'supplierInfo.email' }))\n if (!supplierInfo?.accountNo)\n context.throw(400, context.t('error.required param x not found', { x: 'supplierInfo.accountNo' }))\n }\n\n if (noparams.length > 0) {\n context.throw(400, context.t('error.required param x not found', { x: `${noparams.join(', ')}` }))\n }\n}\n"]}
1
+ {"version":3,"file":"add-inbound-order.js","sourceRoot":"","sources":["../../../../../server/routers/api/restful-apis/v1/add-inbound-order.ts"],"names":[],"mappings":";;;;AAAA,sEAA6B;AAC7B,qCAA4B;AAE5B,6CAAgE;AAChE,uDAAqF;AACrF,+DAAqE;AACrE,iDAAqD;AAErD,qFAAgF;AAChF,uFAAkF;AAElF,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,6DAA6D,CAAC,CAAA;AAE7F,sBAAM,CAAC,IAAI,CACT,8CAA8C,EAC9C,wCAAkB,EAClB,0CAAmB,EACnB,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;;IACtB,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;IACxC,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,MAAM,CAAA;IACtC,MAAM,EAAE,CAAC,EAAE,GAAG,OAAO,CAAA;IACrB,MAAM,WAAW,GAAG,SAAS,CAAA;IAC7B,IAAI,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAA;IAElC,IAAI,CAAC,WAAW;QAAE,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,8BAA8B,CAAC,CAAC,CAAA;IAEvE,IAAI,OAAO,OAAO,KAAK,SAAS,IAAI,CAAC,CAAA,MAAA,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,0CAAE,MAAM,CAAA,EAAE;QACjE,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,mCAAmC,CAAC,CAAC,CAAA;KAC3D;IAED,MAAM,iBAAiB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;IACzC,KAAK,CAAC,sCAA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AAC,QAAQ,CAAA;QACpC,IAAI,CAAC,CAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,IAAI,CAAA;YACrB,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,kCAAkC,EAAE,EAAE,CAAC,EAAE,mBAAmB,EAAE,CAAC,CAAC,CAAA;QAC/F,IAAI,CAAC,CAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,WAAW,CAAA;YAC5B,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,kCAAkC,EAAE,EAAE,CAAC,EAAE,0BAA0B,EAAE,CAAC,CAAC,CAAA;QACtG,IAAI,CAAC,CAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,KAAK,CAAA;YACtB,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,kCAAkC,EAAE,EAAE,CAAC,EAAE,oBAAoB,EAAE,CAAC,CAAC,CAAA;QAChG,IAAI,CAAC,CAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,SAAS,CAAA;YAC1B,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,kCAAkC,EAAE,EAAE,CAAC,EAAE,wBAAwB,EAAE,CAAC,CAAC,CAAA;KACrG;IAED,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE;QACvB,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,kCAAkC,EAAE,EAAE,CAAC,EAAE,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,CAAA;KACnG;AACH,CAAC;AAjDD,8CAiDC","sourcesContent":["import gql from 'graphql-tag'\nimport { In } from 'typeorm'\n\nimport { restfulApiRouter as router } from '@things-factory/api'\nimport { Bizplace, ContactPoint, getCompanyBizplace } from '@things-factory/biz-base'\nimport { Product, ProductDetail } from '@things-factory/product-base'\nimport { getRepository } from '@things-factory/shell'\n\nimport { businessMiddleware } from '../../../../middlewares/business-middleware'\nimport { warehouseMiddleware } from '../../../../middlewares/warehouse-middleware'\n\nconst debug = require('debug')('things-factory:operato-hub:restful-api:v1:add-inbound-order')\n\nrouter.post(\n '/v1/warehouse/:warehouseId/add-inbound-order',\n businessMiddleware,\n warehouseMiddleware,\n async (context, next) => {\n const { client, domain } = context.state\n const { warehouseId } = context.params\n const { t } = context\n const attachments = undefined\n let bodyReq = context.request.body\n\n if (!warehouseId) context.throw(404, t('error.warehouse id not found'))\n\n if (typeof bodyReq === undefined || !Object.keys(bodyReq)?.length) {\n context.throw(400, t('error.invalid body request format'))\n }\n\n await checkMandatoryKey(context, bodyReq)\n debug('post:/add-inbound-order request.body', bodyReq)\n\n // get customer company's bizplace\n const custCompanyBizplace: Bizplace = await getCompanyBizplace(null, null, warehouseId)\n const customerBizplace: Bizplace = await getRepository(Bizplace).findOne({\n where: { id: warehouseId }\n })\n\n //#1 to get all product list\n const productDetails: ProductDetail[] = await getRepository(ProductDetail).find({\n where: {\n domain: custCompanyBizplace.domain,\n refCode: In(bodyReq.orderProducts.map(orderProduct => orderProduct.product.sku))\n },\n relations: ['product']\n })\n\n //#2 assign product id found to order product\n bodyReq.orderProducts = bodyReq.orderProducts.map(orderProduct => {\n productDetails.forEach(productDetail => {\n const product: Product = productDetail.product\n const packingType: string = productDetail.packingType\n const packingSize: number = productDetail.packingSize\n\n if (orderProduct.product.sku === productDetail.refCode) {\n orderProduct.product.id = product.id\n\n if (packingType) {\n orderProduct.packingType = packingType\n orderProduct.packingSize = packingSize\n orderProduct.uom = productDetail.uom\n orderProduct.uomValue = productDetail.uomValue\n orderProduct.totalUomValue = `${(productDetail.uomValue * orderProduct.packQty).toFixed(2)} ${\n productDetail.uom\n }`\n } else {\n productDetail = productDetails.find(productDetail => productDetail.isDefault)\n\n orderProduct.packingType = productDetail.packingType\n orderProduct.packingSize = productDetail.packingSize\n orderProduct.uom = productDetail.uom\n orderProduct.uomValue = productDetail.uomValue\n orderProduct.totalUomValue = `${(productDetail.uomValue * orderProduct.packQty).toFixed(2)} ${\n productDetail.uom\n }`\n }\n }\n })\n\n return orderProduct\n })\n\n //#3 check if product is not found\n bodyReq.orderProducts.forEach(orderProduct => {\n if (!orderProduct.product?.id) context.throw(404, t(`error.sku code ${orderProduct.product.sku} is not exist`))\n })\n\n //#4 include supplier id if there's any\n if (bodyReq?.supplier) {\n const supplierInfo = bodyReq.supplier\n const foundSupplier: ContactPoint = await getRepository(ContactPoint).findOne({\n where: {\n domain: { id: domain.id },\n bizplace: { id: warehouseId },\n name: supplierInfo.name,\n companyName: supplierInfo.companyName,\n email: supplierInfo.email,\n accountNo: supplierInfo.accountNo,\n type: 'SUPPLIER'\n }\n })\n\n if (foundSupplier) bodyReq.supplier = foundSupplier.id\n else context.throw(404, t('error.supplier not found'))\n }\n\n context.body = {\n result: (\n await client.mutate({\n mutation: gql`\n mutation addArrivalNotice($arrivalNotice: NewArrivalNotice!, $attachments: Upload) {\n addArrivalNotice(arrivalNotice: $arrivalNotice, file: $attachments) {\n name\n refNo\n etaDate\n containerNo\n ownTransport\n crossDocking\n releaseGood {\n name\n }\n etaDate\n looseItem\n deliveryOrderNo\n status\n truckNo\n refNo\n importCargo\n orderProducts {\n batchId\n product {\n sku\n name\n description\n packingType\n type\n }\n packingType\n uom\n uomValue\n packQty\n totalUomValue\n palletQty\n }\n orderVass {\n vas {\n name\n operationGuide\n operationGuideType\n }\n set\n targetType\n targetBatchId\n targetProduct {\n name\n description\n }\n packingType\n qty\n uomValue\n otherTarget\n description\n remark\n operationGuide\n }\n supplier {\n companyName\n name\n phone\n email\n address\n }\n }\n }\n `,\n variables: { arrivalNotice: { ...bodyReq, warehouseId }, attachments },\n context: {\n ...context,\n hasUpload: true,\n state: {\n ...context.state,\n bizplace: customerBizplace,\n domain,\n type: 'api'\n }\n }\n } as any)\n ).data\n }\n }\n)\n\nexport function checkMandatoryKey(context, params) {\n let noparams = []\n\n if ('container' in params) {\n if (params.container === true) {\n if (!params.hasOwnProperty('containerNo') || !params.hasOwnProperty('containerSize')) {\n noparams.push('containerInfo')\n }\n }\n }\n\n if ('orderProducts' in params) {\n params.orderProducts.forEach((param, key) => {\n let noSubParams = []\n\n if (!param.batchId) noSubParams.push('batchId')\n\n if (!param.packQty) noSubParams.push('packQty')\n\n if (!param.product.sku) noSubParams.push('sku')\n\n if (noSubParams?.length)\n context.throw(400, context.t('error.required param x not found', { x: `${noSubParams.join(', ')}` }))\n })\n } else {\n noparams.push('orderProducts')\n }\n\n if ('etaDate' in params) {\n const etaDate = new Date(params.etaDate)\n\n if (isNaN(etaDate.getDate())) context.throw(400, context.t('error.eta date is invalid'))\n }\n\n if ('supplier' in params) {\n const supplierInfo = params.supplier\n if (!supplierInfo?.name)\n context.throw(400, context.t('error.required param x not found', { x: 'supplierInfo.name' }))\n if (!supplierInfo?.companyName)\n context.throw(400, context.t('error.required param x not found', { x: 'supplierInfo.companyName' }))\n if (!supplierInfo?.email)\n context.throw(400, context.t('error.required param x not found', { x: 'supplierInfo.email' }))\n if (!supplierInfo?.accountNo)\n context.throw(400, context.t('error.required param x not found', { x: 'supplierInfo.accountNo' }))\n }\n\n if (noparams.length > 0) {\n context.throw(400, context.t('error.required param x not found', { x: `${noparams.join(', ')}` }))\n }\n}\n"]}
@@ -1,18 +1,20 @@
1
1
  "use strict";
2
2
  /** Customer list to inform when there are changes */
3
- /** 1. Sweetmag */
4
- /** 2. Beidzia */
3
+ /** 1. Bridzia */
4
+ /** 2. Sweetmag */
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.checkMandatoryKey = void 0;
7
7
  const tslib_1 = require("tslib");
8
8
  const graphql_tag_1 = tslib_1.__importDefault(require("graphql-tag"));
9
- const api_1 = require("@things-factory/api");
10
9
  const typeorm_1 = require("typeorm");
10
+ const api_1 = require("@things-factory/api");
11
+ const integration_base_1 = require("@things-factory/integration-base");
11
12
  const marketplace_base_1 = require("@things-factory/marketplace-base");
12
13
  const business_middleware_1 = require("../../../../middlewares/business-middleware");
13
14
  const store_middleware_1 = require("../../../../middlewares/store-middleware");
14
- const debug = require('debug')('things-factory:operato-hub:restful-api:v1:add-marketplace-order');
15
- api_1.restfulApiRouter.post('/v1/warehouse/:storeId/add-marketplace-order', business_middleware_1.businessMiddleware, store_middleware_1.storeMiddleware, async (context, next) => {
15
+ const debug = require('debug')('things-factory:operato-hub:restful-api:unstable:add-marketplace-order');
16
+ const apiVersion = 'v1';
17
+ api_1.restfulApiRouter.post(`/${apiVersion}/warehouse/:storeId/add-marketplace-order`, business_middleware_1.businessMiddleware, store_middleware_1.storeMiddleware, async (context, next) => {
16
18
  return await (0, typeorm_1.getConnection)().transaction(async (tx) => {
17
19
  var _a;
18
20
  const { client, marketplaceStore, domain } = context.state;
@@ -102,6 +104,7 @@ api_1.restfulApiRouter.post('/v1/warehouse/:storeId/add-marketplace-order', busi
102
104
  domain, type: 'api' }) })
103
105
  })).data
104
106
  };
107
+ (0, integration_base_1.createPayloadLog)(marketplaceStore.id, `/${apiVersion}/warehouse/:storeId/add-marketplace-order`, bodyReq, context.body.result, context, integration_base_1.PayloadType.INGESTION, 'hub-api');
105
108
  });
106
109
  });
107
110
  function checkMandatoryKey(context, params) {
@@ -1 +1 @@
1
- {"version":3,"file":"add-marketplace-order.js","sourceRoot":"","sources":["../../../../../server/routers/api/restful-apis/v1/add-marketplace-order.ts"],"names":[],"mappings":";AAAA,qDAAqD;AACrD,kBAAkB;AAClB,iBAAiB;;;;AAEjB,sEAA6B;AAE7B,6CAAgE;AAChE,qCAAsD;AACtD,uEAAmE;AAEnE,qFAAgF;AAChF,+EAA0E;AAE1E,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,iEAAiE,CAAC,CAAA;AAEjG,sBAAM,CAAC,IAAI,CACT,8CAA8C,EAC9C,wCAAkB,EAClB,kCAAe,EACf,KAAK,EAAE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AE,MAAM;gBACrB,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,kCAAkC,EAAE,EAAE,CAAC,EAAE,GAAG,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,CAAA;QACzG,CAAC,CAAC,CAAA;KACH;SAAM;QACL,QAAQ,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAA;KACvC;IAED,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE;QACvB,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,kCAAkC,EAAE,EAAE,CAAC,EAAE,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,CAAA;KACnG;AACH,CAAC;AAjCD,8CAiCC","sourcesContent":["/** Customer list to inform when there are changes */\n/** 1. Sweetmag */\n/** 2. Beidzia */\n\nimport gql from 'graphql-tag'\n\nimport { restfulApiRouter as router } from '@things-factory/api'\nimport { EntityManager, getConnection } from 'typeorm'\nimport { MarketplaceOrder } from '@things-factory/marketplace-base'\n\nimport { businessMiddleware } from '../../../../middlewares/business-middleware'\nimport { storeMiddleware } from '../../../../middlewares/store-middleware'\n\nconst debug = require('debug')('things-factory:operato-hub:restful-api:v1:add-marketplace-order')\n\nrouter.post(\n '/v1/warehouse/:storeId/add-marketplace-order',\n businessMiddleware,\n storeMiddleware,\n async (context, next) => {\n return await getConnection().transaction(async (tx: EntityManager) => {\n const { client, marketplaceStore, domain } = context.state\n const { t } = context\n const bodyReq = context.request.body\n\n if (typeof bodyReq === undefined || !Object.keys(bodyReq)?.length) {\n context.throw(400, t('error.invalid body request format'))\n }\n\n await checkMandatoryKey(context, bodyReq)\n debug('post:/add-marketplace-order body request', bodyReq)\n\n let existingMarketplaceOrder: MarketplaceOrder = await tx.getRepository(MarketplaceOrder).findOne({\n where: { name: bodyReq.name, domain, marketplaceStore }\n })\n\n if (existingMarketplaceOrder) {\n context.throw(400, `error.duplicate entry for order ${bodyReq.name}`)\n }\n\n context.body = {\n result: (\n await client.mutate({\n mutation: gql`\n mutation generateMarketplaceOrder($marketplaceOrder: NewMarketplaceOrder!) {\n generateMarketplaceOrder(marketplaceOrder: $marketplaceOrder) {\n id\n orderNo\n currency\n itemCount\n totalAmount\n paymentMethod\n remark\n giftOption\n orderCreatedAt\n orderUpdatedAt\n marketplaceStore {\n storeId\n }\n marketplaceOrderItems {\n id\n name\n qty\n cancelBy\n returnStatus\n paidPrice\n packageId\n invoiceNo\n status\n marketplaceOrderShippingItems {\n marketplaceOrderShipping {\n attentionTo\n address1\n address2\n address3\n address4\n address5\n state\n city\n postCode\n country\n phone1\n phone2\n email\n orderType\n freightType\n parcelType\n goodsType\n deliveryMethod\n totalWeight\n totalVolume\n transporter\n }\n }\n marketplaceProductVariation {\n id\n sku\n variationId\n variationSku\n channelSku\n name\n costPrice\n sellPrice\n marketplaceStatus\n }\n }\n }\n }\n `,\n variables: { marketplaceOrder: bodyReq },\n context: {\n ...context,\n state: {\n ...context.state,\n marketplaceStore,\n domain,\n type: 'api'\n }\n }\n } as any)\n ).data\n }\n })\n }\n)\n\nexport function checkMandatoryKey(context, params) {\n let noparams = []\n\n if (!params?.orderNo) {\n noparams.push('orderNo')\n }\n\n if (!params?.status) {\n noparams.push('status')\n }\n\n if (params.marketplaceOrderItems) {\n params.marketplaceOrderItems.forEach(param => {\n let noSubParams = []\n\n if (!param?.qty) noSubParams.push('qty')\n\n if (!param?.status) noSubParams.push('status')\n\n if (!param?.marketplaceProductVariation) noSubParams.push('marketplaceProductVariation')\n\n if (!param?.marketplaceProductVariation?.variationId) noSubParams.push('variationId')\n\n if (noSubParams?.length)\n context.throw(400, context.t('error.required param x not found', { x: `${noSubParams.join(', ')}` }))\n })\n } else {\n noparams.push('marketplaceOrderItems')\n }\n\n if (noparams.length > 0) {\n context.throw(400, context.t('error.required param x not found', { x: `${noparams.join(', ')}` }))\n }\n}\n"]}
1
+ {"version":3,"file":"add-marketplace-order.js","sourceRoot":"","sources":["../../../../../server/routers/api/restful-apis/v1/add-marketplace-order.ts"],"names":[],"mappings":";AAAA,qDAAqD;AACrD,iBAAiB;AACjB,kBAAkB;;;;AAElB,sEAA6B;AAC7B,qCAAsD;AAEtD,6CAAgE;AAChE,uEAAgF;AAChF,uEAAmE;AAEnE,qFAAgF;AAChF,+EAA0E;AAE1E,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,uEAAuE,CAAC,CAAA;AACvG,MAAM,UAAU,GAAG,IAAI,CAAA;AAEvB,sBAAM,CAAC,IAAI,CACT,IAAI,UAAU,2CAA2C,EACzD,wCAAkB,EAClB,kCAAe,EACf,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;IACtB,OAAO,MAAM,IAAA,uBAAa,GAAE,CAAC,WAAW,CAAC,KAAK,EAAE,EAAiB,EAAE,EAAE;;QACnE,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAC1D,MAAM,EAAE,CAAC,EAAE,GAAG,OAAO,CAAA;QACrB,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAA;QAEpC,IAAI,OAAO,OAAO,KAAK,SAAS,IAAI,CAAC,CAAA,MAAA,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,0CAAE,MAAM,CAAA,EAAE;YACjE,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,mCAAmC,CAAC,CAAC,CAAA;SAC3D;QAED,MAAM,iBAAiB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;QACzC,KAAK,CAAC,0CAA0C,EAAE,OAAO,CAAC,CAAA;QAE1D,IAAI,wBAAwB,GAAqB,MAAM,EAAE,CAAC,aAAa,CAAC,mCAAgB,CAAC,CAAC,OAAO,CAAC;YAChG,KAAK,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC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gql from 'graphql-tag'\nimport { EntityManager, getConnection } from 'typeorm'\n\nimport { restfulApiRouter as router } from '@things-factory/api'\nimport { createPayloadLog, PayloadType } from '@things-factory/integration-base'\nimport { MarketplaceOrder } from '@things-factory/marketplace-base'\n\nimport { businessMiddleware } from '../../../../middlewares/business-middleware'\nimport { storeMiddleware } from '../../../../middlewares/store-middleware'\n\nconst debug = require('debug')('things-factory:operato-hub:restful-api:unstable:add-marketplace-order')\nconst apiVersion = 'v1'\n\nrouter.post(\n `/${apiVersion}/warehouse/:storeId/add-marketplace-order`,\n businessMiddleware,\n storeMiddleware,\n async (context, next) => {\n return await getConnection().transaction(async (tx: EntityManager) => {\n const { client, marketplaceStore, domain } = context.state\n const { t } = context\n const bodyReq = context.request.body\n\n if (typeof bodyReq === undefined || !Object.keys(bodyReq)?.length) {\n context.throw(400, t('error.invalid body request format'))\n }\n\n await checkMandatoryKey(context, bodyReq)\n debug('post:/add-marketplace-order body request', bodyReq)\n\n let existingMarketplaceOrder: MarketplaceOrder = await tx.getRepository(MarketplaceOrder).findOne({\n where: { name: bodyReq.name, domain, marketplaceStore }\n })\n\n if (existingMarketplaceOrder) {\n context.throw(400, `error.duplicate entry for order ${bodyReq.name}`)\n }\n\n context.body = {\n result: (\n await client.mutate({\n mutation: gql`\n mutation generateMarketplaceOrder($marketplaceOrder: NewMarketplaceOrder!) {\n generateMarketplaceOrder(marketplaceOrder: $marketplaceOrder) {\n id\n orderNo\n currency\n itemCount\n totalAmount\n paymentMethod\n remark\n giftOption\n orderCreatedAt\n orderUpdatedAt\n marketplaceStore {\n storeId\n }\n marketplaceOrderItems {\n id\n name\n qty\n cancelBy\n returnStatus\n paidPrice\n packageId\n invoiceNo\n status\n marketplaceOrderShippingItems {\n marketplaceOrderShipping {\n attentionTo\n address1\n address2\n address3\n address4\n address5\n state\n city\n postCode\n country\n phone1\n phone2\n email\n orderType\n freightType\n parcelType\n goodsType\n deliveryMethod\n totalWeight\n totalVolume\n transporter\n }\n }\n marketplaceProductVariation {\n id\n sku\n variationId\n variationSku\n channelSku\n name\n costPrice\n sellPrice\n marketplaceStatus\n }\n }\n }\n }\n `,\n variables: { marketplaceOrder: bodyReq },\n context: {\n ...context,\n state: {\n ...context.state,\n marketplaceStore,\n domain,\n type: 'api'\n }\n }\n } as any)\n ).data\n }\n\n createPayloadLog(\n marketplaceStore.id,\n `/${apiVersion}/warehouse/:storeId/add-marketplace-order`,\n bodyReq,\n context.body.result,\n context,\n PayloadType.INGESTION,\n 'hub-api'\n )\n })\n }\n)\n\nexport function checkMandatoryKey(context, params) {\n let noparams = []\n\n if (!params?.orderNo) {\n noparams.push('orderNo')\n }\n\n if (!params?.status) {\n noparams.push('status')\n }\n\n if (params.marketplaceOrderItems) {\n params.marketplaceOrderItems.forEach(param => {\n let noSubParams = []\n\n if (!param?.qty) noSubParams.push('qty')\n\n if (!param?.status) noSubParams.push('status')\n\n if (!param?.marketplaceProductVariation) noSubParams.push('marketplaceProductVariation')\n\n if (!param?.marketplaceProductVariation?.variationId) noSubParams.push('variationId')\n\n if (noSubParams?.length)\n context.throw(400, context.t('error.required param x not found', { x: `${noSubParams.join(', ')}` }))\n })\n } else {\n noparams.push('marketplaceOrderItems')\n }\n\n if (noparams.length > 0) {\n context.throw(400, context.t('error.required param x not found', { x: `${noparams.join(', ')}` }))\n }\n}\n"]}
@@ -22,6 +22,7 @@ api_1.restfulApiRouter.post('/v1/warehouse/:warehouseId/add-products', business_
22
22
  const custCompanyBizplace = await (0, biz_base_1.getCompanyBizplace)(null, null, warehouseId);
23
23
  await checkMandatoryKey(context, bodyReq);
24
24
  debug('post:/add-product request.body', bodyReq);
25
+ let products = checkProductDetails(bodyReq);
25
26
  context.body = {
26
27
  result: (await client.mutate({
27
28
  mutation: (0, graphql_tag_1.default) `
@@ -31,7 +32,7 @@ api_1.restfulApiRouter.post('/v1/warehouse/:warehouseId/add-products', business_
31
32
  }
32
33
  }
33
34
  `,
34
- variables: { products: bodyReq },
35
+ variables: { products },
35
36
  context: Object.assign(Object.assign({}, context), { state: Object.assign(Object.assign({}, context.state), { bizplace: custCompanyBizplace, domain: custCompanyBizplace === null || custCompanyBizplace === void 0 ? void 0 : custCompanyBizplace.domain }) })
36
37
  })).data
37
38
  };
@@ -47,24 +48,39 @@ async function checkMandatoryKey(context, params) {
47
48
  noparams.push('type');
48
49
  if (param === null || param === void 0 ? void 0 : param.productDetails) {
49
50
  let noSubParams = [];
50
- param.productDetails.forEach((subParam, key) => {
51
- if (!subParam.gtin)
52
- noSubParams.push('gtin');
53
- if (!subParam.packingType)
54
- noSubParams.push('packingType');
55
- if (!subParam.packingSize)
56
- noSubParams.push('packingSize');
57
- if (!subParam.uom)
58
- noSubParams.push('uom');
59
- if (!subParam.uomValue)
60
- noSubParams.push('uomValue');
61
- if (noSubParams === null || noSubParams === void 0 ? void 0 : noSubParams.length)
62
- context.throw(400, context.t('error.required param x not found', { x: `${noSubParams.join(', ')}` }));
63
- });
51
+ if (param.productDetails.length == 0) {
52
+ context.throw(400, context.t('error.required param {x} not found in productDetails', {
53
+ x: 'gtin, packingType, packingSize, uom, uomValue'
54
+ }));
55
+ }
56
+ else {
57
+ param.productDetails.forEach((subParam, key) => {
58
+ if (!subParam.gtin)
59
+ noSubParams.push('gtin');
60
+ if (!subParam.packingType)
61
+ noSubParams.push('packingType');
62
+ if (!subParam.packingSize)
63
+ noSubParams.push('packingSize');
64
+ if (!subParam.uom)
65
+ noSubParams.push('uom');
66
+ if (!subParam.uomValue)
67
+ noSubParams.push('uomValue');
68
+ if (noSubParams === null || noSubParams === void 0 ? void 0 : noSubParams.length)
69
+ context.throw(400, context.t('error.required param {x} not found in productDetails', { x: `${noSubParams.join(', ')}` }));
70
+ });
71
+ }
64
72
  }
65
73
  if (noparams === null || noparams === void 0 ? void 0 : noparams.length)
66
- context.throw(400, context.t('error.required param x not found', { x: `${noparams.join(', ')}` }));
74
+ context.throw(400, context.t('error.required param {x} not found', { x: `${noparams.join(', ')}` }));
67
75
  });
68
76
  }
69
77
  exports.checkMandatoryKey = checkMandatoryKey;
78
+ function checkProductDetails(params) {
79
+ params.forEach(param => {
80
+ if (!(param === null || param === void 0 ? void 0 : param.productDetails.some(pd => pd.isDefault))) {
81
+ param.productDetails[0].isDefault = true;
82
+ }
83
+ });
84
+ return params;
85
+ }
70
86
  //# sourceMappingURL=add-products.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"add-products.js","sourceRoot":"","sources":["../../../../../server/routers/api/restful-apis/v1/add-products.ts"],"names":[],"mappings":";;;;AAAA,sEAA6B;AAE7B,6CAAgE;AAChE,uDAAuE;AAEvE,qFAAgF;AAChF,uFAAkF;AAElF,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,wDAAwD,CAAC,CAAA;AAExF,sBAAM,CAAC,IAAI,CACT,yCAAyC,EACzC,wCAAkB,EAClB,0CAAmB,EACnB,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;;IACtB,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;IACxC,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,MAAM,CAAA;IACtC,MAAM,EAAE,CAAC,EAAE,GAAG,OAAO,CAAA;IACrB,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAA;IAEpC,IAAI,CAAC,WAAW;QAAE,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,8BAA8B,CAAC,CAAC,CAAA;IAEvE,IAAI,OAAO,OAAO,KAAK,SAAS,IAAI,CAAC,CAAA,MAAA,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,0CAAE,MAAM,CAAA,EAAE;QACjE,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,mCAAmC,CAAC,CAAC,CAAA;KACnE;IAED,MAAM,mBAAmB,GAAa,MAAM,IAAA,6BAAkB,EAAC,IAAI,EAAE,IAAI,EAAE,WA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AC,QAAQ,CAAC,WAAW;oBAAE,WAAW,CAAC,IAAI,CAAC,aAAa,CAAC,CAAA;gBAE1D,IAAI,CAAC,QAAQ,CAAC,WAAW;oBAAE,WAAW,CAAC,IAAI,CAAC,aAAa,CAAC,CAAA;gBAE1D,IAAI,CAAC,QAAQ,CAAC,GAAG;oBAAE,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;gBAE1C,IAAI,CAAC,QAAQ,CAAC,QAAQ;oBAAE,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;gBAEpD,IAAI,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,MAAM;oBACrB,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,kCAAkC,EAAE,EAAE,CAAC,EAAE,GAAG,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,CAAA;YACzG,CAAC,CAAC,CAAA;SACH;QAED,IAAI,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,MAAM;YAClB,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,kCAAkC,EAAE,EAAE,CAAC,EAAE,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,CAAA;IACtG,CAAC,CAAC,CAAA;AACJ,CAAC;AA/BD,8CA+BC","sourcesContent":["import gql from 'graphql-tag'\n\nimport { restfulApiRouter as router } from '@things-factory/api'\nimport { Bizplace, getCompanyBizplace } from '@things-factory/biz-base'\n\nimport { businessMiddleware } from '../../../../middlewares/business-middleware'\nimport { warehouseMiddleware } from '../../../../middlewares/warehouse-middleware'\n\nconst debug = require('debug')('things-factory:operato-hub:restful-api:v1:add-products')\n\nrouter.post(\n '/v1/warehouse/:warehouseId/add-products',\n businessMiddleware,\n warehouseMiddleware,\n async (context, next) => {\n const { client, domain } = context.state\n const { warehouseId } = context.params\n const { t } = context\n const bodyReq = context.request.body\n\n if (!warehouseId) context.throw(404, t('error.warehouse id not found'))\n\n if (typeof bodyReq === undefined || !Object.keys(bodyReq)?.length) {\n context.throw(400, context.t('error.invalid body request format'))\n }\n\n const custCompanyBizplace: Bizplace = await getCompanyBizplace(null, null, warehouseId)\n\n await checkMandatoryKey(context, bodyReq)\n debug('post:/add-product request.body', bodyReq)\n\n context.body = {\n result: (\n await client.mutate({\n mutation: gql`\n mutation createProducts($products: [NewProduct!]!) {\n createProducts(products: $products) {\n id\n }\n }\n `,\n variables: { products: bodyReq },\n context: {\n ...context,\n state: {\n ...context.state,\n bizplace: custCompanyBizplace,\n domain: custCompanyBizplace?.domain\n }\n }\n } as any)\n ).data\n }\n }\n)\n\nexport async function checkMandatoryKey(context, params) {\n params.forEach((param, key) => {\n let noparams = []\n\n if (!param.sku) noparams.push('sku')\n\n if (!param.name) noparams.push('name')\n\n if (!param.type) noparams.push('type')\n\n if (param?.productDetails) {\n let noSubParams = []\n param.productDetails.forEach((subParam, key) => {\n if (!subParam.gtin) noSubParams.push('gtin')\n\n if (!subParam.packingType) noSubParams.push('packingType')\n\n if (!subParam.packingSize) noSubParams.push('packingSize')\n\n if (!subParam.uom) noSubParams.push('uom')\n\n if (!subParam.uomValue) noSubParams.push('uomValue')\n\n if (noSubParams?.length)\n context.throw(400, context.t('error.required param x not found', { x: `${noSubParams.join(', ')}` }))\n })\n }\n\n if (noparams?.length)\n context.throw(400, context.t('error.required param x not found', { x: `${noparams.join(', ')}` }))\n })\n}\n"]}
1
+ {"version":3,"file":"add-products.js","sourceRoot":"","sources":["../../../../../server/routers/api/restful-apis/v1/add-products.ts"],"names":[],"mappings":";;;;AAAA,sEAA6B;AAE7B,6CAAgE;AAChE,uDAAuE;AAEvE,qFAAgF;AAChF,uFAAkF;AAElF,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,wDAAwD,CAAC,CAAA;AAExF,sBAAM,CAAC,IAAI,CACT,yCAAyC,EACzC,wCAA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C,QAAQ,CAAC,QAAQ;wBAAE,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;oBAEpD,IAAI,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,MAAM;wBACrB,OAAO,CAAC,KAAK,CACX,GAAG,EACH,OAAO,CAAC,CAAC,CAAC,sDAAsD,EAAE,EAAE,CAAC,EAAE,GAAG,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CACtG,CAAA;gBACL,CAAC,CAAC,CAAA;aACH;SACF;QAED,IAAI,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,MAAM;YAClB,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,oCAAoC,EAAE,EAAE,CAAC,EAAE,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,CAAA;IACxG,CAAC,CAAC,CAAA;AACJ,CAAC;AA3CD,8CA2CC;AAED,SAAS,mBAAmB,CAAC,MAAM;IACjC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QACrB,IAAI,CAAC,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,SAAS,CAAC,CAAA,EAAE;YACnD,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,SAAS,GAAG,IAAI,CAAA;SACzC;IACH,CAAC,CAAC,CAAA;IAEF,OAAO,MAAM,CAAA;AACf,CAAC","sourcesContent":["import gql from 'graphql-tag'\n\nimport { restfulApiRouter as router } from '@things-factory/api'\nimport { Bizplace, getCompanyBizplace } from '@things-factory/biz-base'\n\nimport { businessMiddleware } from '../../../../middlewares/business-middleware'\nimport { warehouseMiddleware } from '../../../../middlewares/warehouse-middleware'\n\nconst debug = require('debug')('things-factory:operato-hub:restful-api:v1:add-products')\n\nrouter.post(\n '/v1/warehouse/:warehouseId/add-products',\n businessMiddleware,\n warehouseMiddleware,\n async (context, next) => {\n const { client, domain } = context.state\n const { warehouseId } = context.params\n const { t } = context\n const bodyReq = context.request.body\n\n if (!warehouseId) context.throw(404, t('error.warehouse id not found'))\n\n if (typeof bodyReq === undefined || !Object.keys(bodyReq)?.length) {\n context.throw(400, context.t('error.invalid body request format'))\n }\n\n const custCompanyBizplace: Bizplace = await getCompanyBizplace(null, null, warehouseId)\n\n await checkMandatoryKey(context, bodyReq)\n debug('post:/add-product request.body', bodyReq)\n\n let products = checkProductDetails(bodyReq)\n\n context.body = {\n result: (\n await client.mutate({\n mutation: gql`\n mutation createProducts($products: [NewProduct!]!) {\n createProducts(products: $products) {\n id\n }\n }\n `,\n variables: { products },\n context: {\n ...context,\n state: {\n ...context.state,\n bizplace: custCompanyBizplace,\n domain: custCompanyBizplace?.domain\n }\n }\n } as any)\n ).data\n }\n }\n)\n\nexport async function checkMandatoryKey(context, params) {\n params.forEach((param, key) => {\n let noparams = []\n\n if (!param.sku) noparams.push('sku')\n\n if (!param.name) noparams.push('name')\n\n if (!param.type) noparams.push('type')\n\n if (param?.productDetails) {\n let noSubParams = []\n if (param.productDetails.length == 0) {\n context.throw(\n 400,\n context.t('error.required param {x} not found in productDetails', {\n x: 'gtin, packingType, packingSize, uom, uomValue'\n })\n )\n } else {\n param.productDetails.forEach((subParam, key) => {\n if (!subParam.gtin) noSubParams.push('gtin')\n\n if (!subParam.packingType) noSubParams.push('packingType')\n\n if (!subParam.packingSize) noSubParams.push('packingSize')\n\n if (!subParam.uom) noSubParams.push('uom')\n\n if (!subParam.uomValue) noSubParams.push('uomValue')\n\n if (noSubParams?.length)\n context.throw(\n 400,\n context.t('error.required param {x} not found in productDetails', { x: `${noSubParams.join(', ')}` })\n )\n })\n }\n }\n\n if (noparams?.length)\n context.throw(400, context.t('error.required param {x} not found', { x: `${noparams.join(', ')}` }))\n })\n}\n\nfunction checkProductDetails(params) {\n params.forEach(param => {\n if (!param?.productDetails.some(pd => pd.isDefault)) {\n param.productDetails[0].isDefault = true\n }\n })\n\n return params\n}\n"]}
@@ -39,7 +39,7 @@ api_1.restfulApiRouter.post(`/${apiVersion}/warehouse/:warehouseId/add-release-o
39
39
  });
40
40
  let locationSortingRules = [];
41
41
  const inventoryAssignmentSetting = await tx.getRepository(setting_base_1.Setting).findOne({
42
- where: { domain, name: 'rule-for-inventory-assignment' }
42
+ where: { domain: { id: domain.id }, name: 'rule-for-inventory-assignment' }
43
43
  });
44
44
  if (inventoryAssignmentSetting) {
45
45
  let locationSetting = JSON.parse(inventoryAssignmentSetting.value);
@@ -49,7 +49,7 @@ api_1.restfulApiRouter.post(`/${apiVersion}/warehouse/:warehouseId/add-release-o
49
49
  }
50
50
  else {
51
51
  const pickingProductSetting = await tx.getRepository(setting_base_1.Setting).findOne({
52
- where: { domain, name: 'rule-for-picking-product' }
52
+ where: { domain: { id: domain.id }, name: 'rule-for-picking-product' }
53
53
  });
54
54
  if (pickingProductSetting) {
55
55
  let locationSetting = JSON.parse(pickingProductSetting.value);
@@ -177,10 +177,10 @@ api_1.restfulApiRouter.post(`/${apiVersion}/warehouse/:warehouseId/add-release-o
177
177
  sortings.push({ name: 'created_at', desc: true });
178
178
  break;
179
179
  case 'FEFO':
180
- sortings.push({ name: 'expiration_date', desc: false });
180
+ sortings.push({ name: 'expiration_date', desc: false }, { name: 'created_at', desc: false });
181
181
  break;
182
182
  case 'FMFO':
183
- sortings.push({ name: 'manufacture_date', desc: false });
183
+ sortings.push({ name: 'manufacture_date', desc: false }, { name: 'created_at', desc: false });
184
184
  break;
185
185
  }
186
186
  // 2. get all inventory data according to SKU and batchId
@@ -299,6 +299,7 @@ api_1.restfulApiRouter.post(`/${apiVersion}/warehouse/:warehouseId/add-release-o
299
299
  break;
300
300
  case 'FEFO':
301
301
  qb.orderBy('"iv"."expiration_date"', 'ASC');
302
+ qb.orderBy('"iv"."created_at"', 'ASC');
302
303
  if ((locationSortingRules === null || locationSortingRules === void 0 ? void 0 : locationSortingRules.length) > 0) {
303
304
  locationSortingRules.forEach((rule, idx) => {
304
305
  qb.addOrderBy(`loc.${rule.name}`, rule.desc ? 'DESC' : 'ASC');
@@ -307,6 +308,7 @@ api_1.restfulApiRouter.post(`/${apiVersion}/warehouse/:warehouseId/add-release-o
307
308
  break;
308
309
  case 'FMFO':
309
310
  qb.orderBy('"iv"."manufacture_date"', 'ASC');
311
+ qb.orderBy('"iv"."created_at"', 'ASC');
310
312
  if ((locationSortingRules === null || locationSortingRules === void 0 ? void 0 : locationSortingRules.length) > 0) {
311
313
  locationSortingRules.forEach((rule, idx) => {
312
314
  qb.addOrderBy(`loc.${rule.name}`, rule.desc ? 'DESC' : 'ASC');
@@ -569,10 +571,10 @@ api_1.restfulApiRouter.post(`/${apiVersion}/warehouse/:warehouseId/add-release-o
569
571
  domain, type: 'api' }) })
570
572
  })).data
571
573
  };
572
- (0, integration_base_1.createPayloadLog)(customerBizplaceId, `/${apiVersion}/warehouse/:warehouseId/add-release-order`, bodyReq, context.body, context, integration_base_1.PayloadType.INGESTION);
574
+ (0, integration_base_1.createPayloadLog)(customerBizplaceId, `/${apiVersion}/warehouse/:warehouseId/add-release-order`, bodyReq, context.body, context, integration_base_1.PayloadType.INGESTION, 'hub-api');
573
575
  }
574
576
  catch (error) {
575
- (0, integration_base_1.createPayloadLog)(customerBizplaceId, `/${apiVersion}/warehouse/:warehouseId/add-release-order`, bodyReq, error, context, integration_base_1.PayloadType.INGESTION);
577
+ (0, integration_base_1.createPayloadLog)(customerBizplaceId, `/${apiVersion}/warehouse/:warehouseId/add-release-order`, bodyReq, error, context, integration_base_1.PayloadType.INGESTION, 'hub-api');
576
578
  throw error;
577
579
  }
578
580
  });