@feedmepos/mf-inventory-portal 0.0.5

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 (284) hide show
  1. package/README.md +31 -0
  2. package/dist/App.vue.d.ts +2 -0
  3. package/dist/ApprovalView-CTQdDgGH.js +119 -0
  4. package/dist/BindingsDialog-DvX_DRsO.js +82 -0
  5. package/dist/BindingsPicker-CQIGhTCR.js +124 -0
  6. package/dist/BindingsTable-Da4BLkvc.js +122 -0
  7. package/dist/ChangeLocationComponent.vue_vue_type_script_setup_true_lang-DcixBOcX.js +97 -0
  8. package/dist/Entry.vue.d.ts +2 -0
  9. package/dist/FmMultiselectDialog.vue_vue_type_script_setup_true_lang-BXU7x6di.js +144 -0
  10. package/dist/IngredientBindedItem.vue_vue_type_script_setup_true_lang-CD89qCIa.js +49 -0
  11. package/dist/IngredientsView-2ZKdzsgI.js +739 -0
  12. package/dist/IntegrationView-BRWYO3VE.js +1172 -0
  13. package/dist/InventoryBindingForm.vue_vue_type_script_setup_true_lang-CnsDmPTe.js +240 -0
  14. package/dist/NumberPrecisionInput.vue_vue_type_script_setup_true_lang-DBK7mpQS.js +66 -0
  15. package/dist/PurchaseOrderPrintPreview-CH9gVYDg.js +152 -0
  16. package/dist/ReceiveRequestView-DQBqc3GF.js +1298 -0
  17. package/dist/RecipeView-DFG9Wkx-.js +594 -0
  18. package/dist/SingleColumnLayout.vue_vue_type_script_setup_true_lang-CFjO4TPG.js +53 -0
  19. package/dist/Standalone.vue.d.ts +2 -0
  20. package/dist/StockView-DLWMp_I5.js +1733 -0
  21. package/dist/SupplierView-CZhM2ie3.js +607 -0
  22. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-Ffe9bhq8.js +1027 -0
  23. package/dist/UnitView-C3XVSbJY.js +626 -0
  24. package/dist/WarehouseView-BntzAdz3.js +1139 -0
  25. package/dist/api/bill.d.ts +1364 -0
  26. package/dist/api/closing.d.ts +3 -0
  27. package/dist/api/error.d.ts +31 -0
  28. package/dist/api/food-market-hub.d.ts +38 -0
  29. package/dist/api/inventory.d.ts +176 -0
  30. package/dist/api/purchase-order.d.ts +13 -0
  31. package/dist/api/stock.d.ts +9 -0
  32. package/dist/api/supplier.d.ts +7 -0
  33. package/dist/api/type.d.ts +12 -0
  34. package/dist/api/warehouse.d.ts +7 -0
  35. package/dist/app-BzDhmCVx.js +36639 -0
  36. package/dist/app.d.ts +2 -0
  37. package/dist/app.js +5 -0
  38. package/dist/components/ChangeLocationComponent.vue.d.ts +2 -0
  39. package/dist/components/DeferableLoading.vue.d.ts +19 -0
  40. package/dist/components/DeferableLoadingProps.d.ts +4 -0
  41. package/dist/components/DeleteDialog.vue.d.ts +18 -0
  42. package/dist/components/FmCoordinateInput.vue.d.ts +24 -0
  43. package/dist/components/FmCoordinateInputProps.d.ts +23 -0
  44. package/dist/components/FmFilterableSelect.vue.d.ts +25 -0
  45. package/dist/components/FmFilterableSelectProps.d.ts +28 -0
  46. package/dist/components/FmMultiselectDialog.vue.d.ts +30 -0
  47. package/dist/components/FmMultiselectDialogProps.d.ts +16 -0
  48. package/dist/components/FmTableToolbar.vue.d.ts +49 -0
  49. package/dist/components/MultiSelectDialog.vue.d.ts +12 -0
  50. package/dist/components/MultiSelectDialogProps.d.ts +7 -0
  51. package/dist/components/NavigationTab.vue.d.ts +2 -0
  52. package/dist/components/NumberPrecisionInput.vue.d.ts +16 -0
  53. package/dist/components/NumberPrecisionInputProps.d.ts +12 -0
  54. package/dist/components/TableActionableRow.vue.d.ts +40 -0
  55. package/dist/components/UnitDisplayControl.vue.d.ts +12 -0
  56. package/dist/components/UnitDisplayControlProp.d.ts +7 -0
  57. package/dist/components/fm-components.type.d.ts +8 -0
  58. package/dist/components/form/form-mode.enum.d.ts +5 -0
  59. package/dist/components/icons/IconCommunity.vue.d.ts +2 -0
  60. package/dist/components/icons/IconDocumentation.vue.d.ts +2 -0
  61. package/dist/components/icons/IconEcosystem.vue.d.ts +2 -0
  62. package/dist/components/icons/IconSupport.vue.d.ts +2 -0
  63. package/dist/components/icons/IconTooling.vue.d.ts +2 -0
  64. package/dist/components/inventory-binding/InventoryBinding.vue.d.ts +145 -0
  65. package/dist/components/inventory-binding/InventoryBindingProps.d.ts +11 -0
  66. package/dist/components/map/CoordinateDialog.vue.d.ts +24 -0
  67. package/dist/components/map/GoogleMap.vue.d.ts +79 -0
  68. package/dist/components/map/coordinates.d.ts +6 -0
  69. package/dist/components/map/helper/coords-to-latlong.d.ts +8 -0
  70. package/dist/components/map/type.d.ts +27 -0
  71. package/dist/components/nested-multiselect/FmNestedMultiselectDialog.vue.d.ts +7 -0
  72. package/dist/components/nested-multiselect/FmNestedMultiselectDialogProps.d.ts +22 -0
  73. package/dist/components/nested-multiselect/helper/multiselect-utils.d.ts +2 -0
  74. package/dist/components/row-action.enum.d.ts +13 -0
  75. package/dist/components/shell/inventory/binding-dialog.vue.d.ts +84 -0
  76. package/dist/components/shell/inventory/binding-ui.test.d.ts +1 -0
  77. package/dist/components/shell/inventory/binding-ui.vue.d.ts +110 -0
  78. package/dist/components/shell/inventory/utils.d.ts +5 -0
  79. package/dist/components/ui-library/FmDateRangePickerChip.vue.d.ts +36 -0
  80. package/dist/components/ui-library/FmSpecialChip.vue.d.ts +79 -0
  81. package/dist/composable/defineApi.d.ts +18 -0
  82. package/dist/composable/useBreakpoints.d.ts +7 -0
  83. package/dist/composable/useIframe.d.ts +37 -0
  84. package/dist/composable/useSearch.d.ts +5 -0
  85. package/dist/composable/useTabStorage.d.ts +2 -0
  86. package/dist/composable/useToast.d.ts +36 -0
  87. package/dist/core.d.ts +12 -0
  88. package/dist/cypress/component/FmFilterableSelect.cy.d.ts +1 -0
  89. package/dist/cypress/component/FmNestedMultiselectDialog.cy.d.ts +1 -0
  90. package/dist/cypress/component/UnitDisplayControl.cy.d.ts +1 -0
  91. package/dist/cypress/component/receive-request/KDI-15-total-price-currency.cy.d.ts +2 -0
  92. package/dist/cypress/e2e/views/MenuV3.spec.cy.d.ts +0 -0
  93. package/dist/cypress/e2e/views/MenuV4.spec.cy.d.ts +0 -0
  94. package/dist/cypress/e2e/views/Root.spec.cy.d.ts +0 -0
  95. package/dist/cypress/e2e/views/StockView.spec.cy.d.ts +0 -0
  96. package/dist/cypress/support/commands.d.ts +0 -0
  97. package/dist/cypress/support/component.d.ts +10 -0
  98. package/dist/cypress/support/e2e.d.ts +1 -0
  99. package/dist/date2-C7HiAWQG.js +209 -0
  100. package/dist/dayjs.min-Db57WhI9.js +282 -0
  101. package/dist/decimal-D3a0BwVj.js +98 -0
  102. package/dist/empty-placeholder-wf6-BWE8.js +4 -0
  103. package/dist/extensions/array.d.ts +15 -0
  104. package/dist/favicon.ico +0 -0
  105. package/dist/fuzzy-BW8ZYsDG.js +41 -0
  106. package/dist/helper/address.d.ts +2 -0
  107. package/dist/helper/component.d.ts +4 -0
  108. package/dist/helper/core/country/codes.d.ts +255 -0
  109. package/dist/helper/core/country/utils.d.ts +8 -0
  110. package/dist/helper/core/id-to-date.d.ts +1 -0
  111. package/dist/helper/core/store/type.d.ts +2 -0
  112. package/dist/helper/country.d.ts +260 -0
  113. package/dist/helper/date.spec.d.ts +1 -0
  114. package/dist/helper/date2.d.ts +20 -0
  115. package/dist/helper/decimal.d.ts +15 -0
  116. package/dist/helper/decimal.spec.d.ts +1 -0
  117. package/dist/helper/export.d.ts +12 -0
  118. package/dist/helper/form.d.ts +5 -0
  119. package/dist/helper/inventory.d.ts +1 -0
  120. package/dist/helper/iteration.d.ts +15 -0
  121. package/dist/helper/number.d.ts +27 -0
  122. package/dist/helper/number.spec.d.ts +1 -0
  123. package/dist/helper/object.d.ts +36 -0
  124. package/dist/helper/object.spec.d.ts +1 -0
  125. package/dist/helper/rules.d.ts +22 -0
  126. package/dist/helper/search.d.ts +21 -0
  127. package/dist/helper/semver.d.ts +20 -0
  128. package/dist/helper/semver.spec.d.ts +1 -0
  129. package/dist/helper/type.d.ts +8 -0
  130. package/dist/helper/url.d.ts +7 -0
  131. package/dist/helper/validate.d.ts +70 -0
  132. package/dist/helper/xlsx.util.d.ts +8 -0
  133. package/dist/helper/zod.d.ts +21 -0
  134. package/dist/id-to-date-ReZIpUDw.js +30 -0
  135. package/dist/index-D46it8Rk.js +12956 -0
  136. package/dist/init-date-range-M3Q03-Fd.js +21 -0
  137. package/dist/is-linked-ingredient-error-C6AghEwR.js +37 -0
  138. package/dist/layout/InventoryLayout.vue.d.ts +2 -0
  139. package/dist/layout/SingleColumnLayout.vue.d.ts +55 -0
  140. package/dist/layout/components/NavigationButton.vue.d.ts +22 -0
  141. package/dist/layout/layout-routes.d.ts +7 -0
  142. package/dist/layout/type.d.ts +17 -0
  143. package/dist/layout-BvUjg6JS.js +151 -0
  144. package/dist/locales/en/common.json +7 -0
  145. package/dist/main.d.ts +2 -0
  146. package/dist/router/index.d.ts +5 -0
  147. package/dist/router/name.d.ts +17 -0
  148. package/dist/router/shared.d.ts +11 -0
  149. package/dist/row-action.enum-BwQbURNh.js +28 -0
  150. package/dist/rules-DHfAMDW3.js +86 -0
  151. package/dist/stores/api.d.ts +10 -0
  152. package/dist/stores/env.d.ts +5 -0
  153. package/dist/stores/feature.d.ts +9 -0
  154. package/dist/stores/googlemap.d.ts +37 -0
  155. package/dist/stores/helper/generate-backend-urls.d.ts +8 -0
  156. package/dist/stores/inventory.d.ts +1983 -0
  157. package/dist/stores/layout.d.ts +5 -0
  158. package/dist/stores/location.d.ts +1898 -0
  159. package/dist/stores/route.d.ts +12 -0
  160. package/dist/stores/stock.d.ts +58 -0
  161. package/dist/stores/supplier.d.ts +30 -0
  162. package/dist/stores/warehouse.d.ts +88 -0
  163. package/dist/style.css +1 -0
  164. package/dist/supplier-DTiiOLtg.js +65 -0
  165. package/dist/tsconfig.app.tsbuildinfo +1 -0
  166. package/dist/use-inventory-binding-dialog-B6JO7050.js +109 -0
  167. package/dist/views/InventoryView.vue.d.ts +2 -0
  168. package/dist/views/SelectBussinessDialog.vue.d.ts +2 -0
  169. package/dist/views/approval/ApprovalView.vue.d.ts +2 -0
  170. package/dist/views/dev/ComponentPreview.vue.d.ts +2 -0
  171. package/dist/views/dev/components/CoordinateTest.vue.d.ts +2 -0
  172. package/dist/views/dev/components/DateRange.vue.d.ts +2 -0
  173. package/dist/views/dev/components/FmSelectTest.vue.d.ts +2 -0
  174. package/dist/views/dev/components/InventoryIframe.vue.d.ts +2 -0
  175. package/dist/views/dev/components/LayoutDev.vue.d.ts +2 -0
  176. package/dist/views/dev/components/MfCommontTest.vue.d.ts +2 -0
  177. package/dist/views/dev/components/NestedSelection.vue.d.ts +2 -0
  178. package/dist/views/dev/components/NumberStepper.vue.d.ts +2 -0
  179. package/dist/views/dev/components/TabStorageTest.vue.d.ts +2 -0
  180. package/dist/views/dev/helpers/debug.d.ts +22 -0
  181. package/dist/views/dev/helpers/nested-options.d.ts +60 -0
  182. package/dist/views/dev/helpers/pinia-test.d.ts +9 -0
  183. package/dist/views/home/HomeView.vue.d.ts +2 -0
  184. package/dist/views/iframe/inventory-bindings/bindings-dialog/BindingsDialog.vue.d.ts +2 -0
  185. package/dist/views/iframe/inventory-bindings/bindings-picker/BindingsPicker.vue.d.ts +2 -0
  186. package/dist/views/iframe/inventory-bindings/bindings-table/BindingsTable.vue.d.ts +2 -0
  187. package/dist/views/ingredients/IngredientsView.vue.d.ts +2 -0
  188. package/dist/views/ingredients/components/cannot-delete/CannotDelete.vue.d.ts +30 -0
  189. package/dist/views/ingredients/components/convert/ConvertForm.vue.d.ts +54 -0
  190. package/dist/views/ingredients/components/convert/ConvertFormProps.d.ts +8 -0
  191. package/dist/views/ingredients/components/ingredient-binded-item/IngredientBindedItem.vue.d.ts +12 -0
  192. package/dist/views/ingredients/components/ingredient-binded-item/IngredientBindedItemProps.d.ts +5 -0
  193. package/dist/views/ingredients/components/ingredient-dialog/IngredientDialog.vue.d.ts +31 -0
  194. package/dist/views/ingredients/components/ingredient-dialog/IngredientDialogProps.d.ts +9 -0
  195. package/dist/views/ingredients/components/ingredient-form/IngredientForm.vue.d.ts +104 -0
  196. package/dist/views/ingredients/components/ingredient-form/IngredientFormProps.d.ts +10 -0
  197. package/dist/views/ingredients/components/inventory-binding/InventoryBindingForm.vue.d.ts +88 -0
  198. package/dist/views/ingredients/components/inventory-binding/composables/use-inventory-binding-dialog.d.ts +4 -0
  199. package/dist/views/ingredients/components/inventory-binding/util.d.ts +7 -0
  200. package/dist/views/ingredients/composables/use-ingredient-form.d.ts +8 -0
  201. package/dist/views/ingredients/composables/use-ingredient-table.d.ts +46 -0
  202. package/dist/views/ingredients/helper/is-linked-ingredient-error.d.ts +7 -0
  203. package/dist/views/integration/IntegrationView.vue.d.ts +2 -0
  204. package/dist/views/integration/components/ApplyAddon.vue.d.ts +379 -0
  205. package/dist/views/integration/components/ApplyProduct.vue.d.ts +303 -0
  206. package/dist/views/integration/components/ApplyProductDialog.vue.d.ts +277 -0
  207. package/dist/views/integration/components/ApplyProductDialogProps.d.ts +17 -0
  208. package/dist/views/integration/components/ApplyProductDialogV4.vue.d.ts +277 -0
  209. package/dist/views/integration/helper/menu.d.ts +36 -0
  210. package/dist/views/receive-request/ReceiveRequestView.vue.d.ts +2 -0
  211. package/dist/views/receive-request/components/supplier-price-history/SupplierPriceHistory.vue.d.ts +12 -0
  212. package/dist/views/receive-request/components/supplier-price-history/SupplierPriceHistoryProps.d.ts +11 -0
  213. package/dist/views/receive-request/components/transfer-details/TransferDetails.vue.d.ts +18 -0
  214. package/dist/views/receive-request/components/transfer-details/TransferDetailsProps.d.ts +12 -0
  215. package/dist/views/receive-request/components/transfer-dialog/TransferDialog.vue.d.ts +22 -0
  216. package/dist/views/receive-request/components/transfer-dialog/TransferDialogProps.d.ts +11 -0
  217. package/dist/views/receive-request/components/transfer-form/TransferForm.vue.d.ts +450 -0
  218. package/dist/views/receive-request/components/transfer-form/TransferFormProps.d.ts +10 -0
  219. package/dist/views/receive-request/composables/use-receive-request-form.d.ts +369 -0
  220. package/dist/views/receive-request/composables/use-receive-request-table.d.ts +1202 -0
  221. package/dist/views/receive-request/constants/dialog-templates.d.ts +8 -0
  222. package/dist/views/receive-request/constants/purchase-order-transaction-type.d.ts +4 -0
  223. package/dist/views/receive-request/constants/purchase-row-actions.d.ts +2 -0
  224. package/dist/views/receive-request/helper/format-time-from-id.d.ts +2 -0
  225. package/dist/views/receive-request/helper/format-unit-display.d.ts +6 -0
  226. package/dist/views/receive-request/helper/get-received-amount.d.ts +2 -0
  227. package/dist/views/receive-request/helper/init-date-range.d.ts +8 -0
  228. package/dist/views/receive-request/helper/print-po.d.ts +2 -0
  229. package/dist/views/receive-request/helper/status-to-background.d.ts +2 -0
  230. package/dist/views/receive-request/print-preview/PurchaseOrderPrintPreview.vue.d.ts +47 -0
  231. package/dist/views/recipe/RecipeView.vue.d.ts +2 -0
  232. package/dist/views/recipe/components/recipe-dialog/RecipeDialog.vue.d.ts +31 -0
  233. package/dist/views/recipe/components/recipe-dialog/RecipeDialogProps.d.ts +9 -0
  234. package/dist/views/recipe/components/recipe-form/RecipeForm.vue.d.ts +62 -0
  235. package/dist/views/recipe/components/recipe-form/RecipeFormProps.d.ts +10 -0
  236. package/dist/views/recipe/composables/use-recipe-form.d.ts +9 -0
  237. package/dist/views/recipe/composables/use-recipe-table.d.ts +11 -0
  238. package/dist/views/recipe/helper/export-recipe.d.ts +1 -0
  239. package/dist/views/stock/StockView.vue.d.ts +2 -0
  240. package/dist/views/stock/components/StockHistory.vue.d.ts +17 -0
  241. package/dist/views/stock/components/StockHistoryProps.d.ts +7 -0
  242. package/dist/views/stock/components/StockRecordCard.vue.d.ts +712 -0
  243. package/dist/views/stock/components/dialog/AdjustSkuDialog.vue.d.ts +22 -0
  244. package/dist/views/stock/components/dialog/AdjustSkuDialogProps.d.ts +8 -0
  245. package/dist/views/stock/components/dialog/AdjustedItemForm.vue.d.ts +164 -0
  246. package/dist/views/stock/components/dialog/AdjustedItemFormProps.d.ts +8 -0
  247. package/dist/views/stock/components/dialog/ConvertSkuDialog.vue.d.ts +22 -0
  248. package/dist/views/stock/components/dialog/ConvertSkuDialogProps.d.ts +9 -0
  249. package/dist/views/stock/components/dialog/constant/adjustment-type-options.d.ts +7 -0
  250. package/dist/views/stock/components/dialog/helper/adjust.d.ts +3 -0
  251. package/dist/views/stock/components/dialog/helper/form-adjust.d.ts +10 -0
  252. package/dist/views/stock/composables/use-stock-table.d.ts +12 -0
  253. package/dist/views/stock/helper/compute-summary-total-test.d.ts +1 -0
  254. package/dist/views/stock/helper/compute-summary-total.d.ts +1 -0
  255. package/dist/views/stock/helper/compute-summary-total.spec.d.ts +1 -0
  256. package/dist/views/stock/helper/format-date-from-id.d.ts +2 -0
  257. package/dist/views/stock/helper/on-click-export-excel.d.ts +9 -0
  258. package/dist/views/stock/helper/stock-row-action.d.ts +13 -0
  259. package/dist/views/stock/type.d.ts +9 -0
  260. package/dist/views/supplier/SupplierView.vue.d.ts +2 -0
  261. package/dist/views/supplier/components/SupplierDialog.vue.d.ts +22 -0
  262. package/dist/views/supplier/components/SupplierDialogProps.d.ts +10 -0
  263. package/dist/views/supplier/components/SupplierForm.vue.d.ts +58 -0
  264. package/dist/views/supplier/components/SupplierFormProps.d.ts +8 -0
  265. package/dist/views/supplier/composables/use-supplier-table.d.ts +22 -0
  266. package/dist/views/unit/UnitView.vue.d.ts +2 -0
  267. package/dist/views/unit/components/unit-dialog/UnitDialog.vue.d.ts +31 -0
  268. package/dist/views/unit/components/unit-dialog/UnitDialogProps.d.ts +9 -0
  269. package/dist/views/unit/components/unit-form/UnitForm.vue.d.ts +50 -0
  270. package/dist/views/unit/components/unit-form/UnitFormProps.d.ts +10 -0
  271. package/dist/views/unit/components/unit-summary/UnitSummary.vue.d.ts +43 -0
  272. package/dist/views/unit/components/unit-used-by/UnitUsedBy.vue.d.ts +12 -0
  273. package/dist/views/unit/components/unit-used-by/UnitUsedByProps.d.ts +3 -0
  274. package/dist/views/unit/composables/use-unit-form.d.ts +8 -0
  275. package/dist/views/unit/composables/use-unit-table.d.ts +19 -0
  276. package/dist/views/unit/type.d.ts +2 -0
  277. package/dist/views/warehouse/WarehouseView.vue.d.ts +2 -0
  278. package/dist/views/warehouse/components/WarehouseDialog.vue.d.ts +22 -0
  279. package/dist/views/warehouse/components/WarehouseDialogProps.d.ts +10 -0
  280. package/dist/views/warehouse/components/WarehouseForm.vue.d.ts +174 -0
  281. package/dist/views/warehouse/components/WarehouseFormProps.d.ts +8 -0
  282. package/dist/views/warehouse/composables/use-warehouse-table.d.ts +12 -0
  283. package/dist/xlsx-BljO4Lx2.js +15510 -0
  284. package/package.json +93 -0
@@ -0,0 +1,1027 @@
1
+ import { ref as F, computed as re, h as Se, defineComponent as Ue, resolveComponent as H, openBlock as f, createBlock as I, unref as y, isRef as Me, withCtx as se, createElementVNode as e, createVNode as G, createElementBlock as x, Fragment as ee, normalizeClass as ae, toDisplayString as O, createCommentVNode as S, renderList as me } from "vue";
2
+ import { i as Fe } from "./init-date-range-M3Q03-Fd.js";
3
+ import { d as Le, b as oe, q as v, r as je, c as Ce, n as M, s as Y, i as xe } from "./app-BzDhmCVx.js";
4
+ import { y as ne, m as Be, n as Ie, i as Pe, t as pe, a as ce, l as Ve, k as Ge, j as Ke } from "./date2-C7HiAWQG.js";
5
+ import { F as ke, D as N, R as k } from "./row-action.enum-BwQbURNh.js";
6
+ import { useDialog as Ne, useSnackbar as Ee, components as Ae, useProxiedModel as ze } from "@feedmepos/ui-library";
7
+ import { c as Re } from "./layout-BvUjg6JS.js";
8
+ import { F as He } from "./decimal-D3a0BwVj.js";
9
+ import { E as Qe } from "./empty-placeholder-wf6-BWE8.js";
10
+ const Te = Le((a, i) => {
11
+ const d = oe();
12
+ return {
13
+ async readRequests(r) {
14
+ const g = r ?? d.currentLocationDBName, m = `${a.inventoryBackendUrl}/${g}/purchase-request`;
15
+ return await i.get(m);
16
+ },
17
+ async getPurchaseOrders({
18
+ start: r,
19
+ end: g
20
+ }) {
21
+ const m = d.currentLocationDBName, D = `${a.inventoryBackendUrl}/${m}/purchase-order`;
22
+ return await i.get(`${D}?start=${r}&end=${g}`);
23
+ },
24
+ async getPurchaseOrderById(r) {
25
+ const g = d.currentLocationDBName, m = `${a.inventoryBackendUrl}/${g}/purchase-order`;
26
+ return await i.get(`${m}/${r}`);
27
+ },
28
+ async processPurchaseOrder(r, g) {
29
+ const m = d.currentLocationDBName, D = g || m, T = `${a.inventoryBackendUrl}/${D}/purchase-order/run-operation`;
30
+ return await i.put(T, r);
31
+ },
32
+ async createPurchaseOrder(r) {
33
+ const g = d.currentLocationDBName, m = `${a.inventoryBackendUrl}/${g}/purchase-order`;
34
+ return await i.post(m, r);
35
+ },
36
+ async updatePurchaseOrder(r) {
37
+ const g = d.currentLocationDBName, m = `${a.inventoryBackendUrl}/${g}/purchase-order`;
38
+ return await i.put(m, r);
39
+ }
40
+ };
41
+ }), $e = {
42
+ [v.enum.confirmDraft]: {
43
+ primaryActions: {
44
+ text: "Confirm draft",
45
+ close: !0
46
+ },
47
+ title: "Confirm draft?",
48
+ message: "Purchase order cannot be changed after confirm draft.",
49
+ successMessage: "Purchase order draft has been confirmed"
50
+ },
51
+ [v.enum.cancelDraft]: {
52
+ primaryActions: {
53
+ text: "Cancel draft",
54
+ close: !0,
55
+ variant: "destructive"
56
+ },
57
+ title: "Cancel draft?",
58
+ message: "Purchase order cannot be changed after cancelled draft.",
59
+ successMessage: "Purchase order draft has been cancelled"
60
+ },
61
+ [v.enum.submitRequest]: {
62
+ primaryActions: {
63
+ text: "Submit request",
64
+ close: !0
65
+ },
66
+ title: "Confirm draft?",
67
+ message: "Purchase order cannot be changed after confirm draft.",
68
+ successMessage: "Purchase order draft has been submitted"
69
+ },
70
+ [v.enum.completeReceive]: {
71
+ primaryActions: {
72
+ text: "Mark received",
73
+ close: !0
74
+ },
75
+ title: "Mark as received",
76
+ message: "Purchase order cannot be changed after it has complete receiving.",
77
+ successMessage: "Purchase order has been marked as received"
78
+ },
79
+ [v.enum.approveRequest]: {
80
+ primaryActions: {
81
+ text: "Approve request",
82
+ close: !0
83
+ },
84
+ title: "Approve request?",
85
+ message: "Purchase order will be approved.",
86
+ successMessage: "Purchase order has been approved"
87
+ },
88
+ [v.enum.rejectRequest]: {
89
+ primaryActions: {
90
+ text: "Reject request",
91
+ close: !0,
92
+ variant: "destructive"
93
+ },
94
+ title: "Reject request?",
95
+ message: "Purchase order will be rejected.",
96
+ successMessage: "Purchase order has been rejected"
97
+ }
98
+ };
99
+ function le(a) {
100
+ const i = qe(a);
101
+ return i === null ? "" : ne(i);
102
+ }
103
+ function qe(a) {
104
+ const i = a.match(/\w+_(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z).*/);
105
+ if (!i) return null;
106
+ const d = /* @__PURE__ */ new Date(`${i[1]}`);
107
+ return isNaN(d.getTime()) ? null : d;
108
+ }
109
+ function br(a, i) {
110
+ const d = Ne(), r = oe(), g = xe(), m = F(!1), D = Ee(), T = Te(), L = F(new Array()), u = F(
111
+ i != null && i.startDate && (i != null && i.endDate) ? i : Fe()
112
+ ), l = re(() => {
113
+ const n = new Date(u.value.startDate), s = new Date(u.value.endDate);
114
+ return {
115
+ start: Be(n).toISOString(),
116
+ end: Ie(s).toISOString()
117
+ };
118
+ }), o = F(new Array()), h = je(), E = F(null), $ = F();
119
+ function ie() {
120
+ const n = {
121
+ mode: ke.CREATE,
122
+ modelValue: {},
123
+ show: !0,
124
+ "onUpdate:show"(s) {
125
+ $.value.show = s;
126
+ },
127
+ lastClosingDate: E.value
128
+ };
129
+ $.value = n;
130
+ }
131
+ function B(n) {
132
+ const s = {
133
+ mode: ke.UPDATE,
134
+ modelValue: Ce(n),
135
+ show: !0,
136
+ "onUpdate:show"(_) {
137
+ $.value.show = _;
138
+ },
139
+ lastClosingDate: E.value
140
+ };
141
+ $.value = s;
142
+ }
143
+ async function ue() {
144
+ L.value = [], m.value = !0;
145
+ try {
146
+ L.value = await T.getPurchaseOrders(l.value).then((_) => _.sort((w, A) => A._id.localeCompare(w._id)));
147
+ const n = await h.readLastClosing(!0), s = n == null ? void 0 : n._id;
148
+ s && (E.value = qe(s));
149
+ } catch {
150
+ D.open({
151
+ title: "Something went wrong",
152
+ message: "Error at fetching purchase orders",
153
+ type: "error"
154
+ });
155
+ } finally {
156
+ m.value = !1;
157
+ }
158
+ }
159
+ async function de() {
160
+ o.value = [], m.value = !0;
161
+ try {
162
+ o.value = await T.readRequests();
163
+ } catch {
164
+ D.open({
165
+ title: "Something went wrong",
166
+ message: "Error at fetching purchase requests",
167
+ type: "error"
168
+ });
169
+ } finally {
170
+ m.value = !1;
171
+ }
172
+ }
173
+ function t() {
174
+ switch (a) {
175
+ case "receive/request":
176
+ return ue();
177
+ case "approval":
178
+ return de();
179
+ }
180
+ }
181
+ function c(n, s) {
182
+ u.value = {
183
+ startDate: n,
184
+ endDate: s
185
+ }, t();
186
+ }
187
+ r.watchLocation(async (n) => {
188
+ if (!n) {
189
+ L.value = [];
190
+ return;
191
+ }
192
+ await t();
193
+ });
194
+ const R = F(), b = F(Math.random().toString());
195
+ async function W(n, s) {
196
+ var C, q;
197
+ const _ = Math.random().toString();
198
+ b.value = _;
199
+ const w = a === "receive/request" ? r.currentLocation : s == null ? void 0 : s.to, A = {
200
+ purchaseOrder: n,
201
+ transferTo: w == null ? void 0 : w.name,
202
+ transferToDbName: w == null ? void 0 : w.dbName,
203
+ show: !0,
204
+ canResubmit: !1,
205
+ canApprove: a === "approval",
206
+ "onUpdate:show"(j) {
207
+ R.value.show = j;
208
+ }
209
+ };
210
+ if (R.value = A, !(s || n.status !== M.enum.REQUESTING)) {
211
+ try {
212
+ s = (await T.readRequests(
213
+ `${n.supplier.internal}_${n.supplier._id}`
214
+ )).find((z) => z.purchaseOrderId === n._id);
215
+ } catch {
216
+ console.error("Error at fetching po request to check");
217
+ }
218
+ _ === b.value && (R.value.canResubmit = !s, R.value.transferTo = (C = s == null ? void 0 : s.to) == null ? void 0 : C.name, R.value.transferToDbName = (q = s == null ? void 0 : s.to) == null ? void 0 : q.dbName);
219
+ }
220
+ }
221
+ async function K(n, s, _, w) {
222
+ m.value = !0;
223
+ try {
224
+ await T.processPurchaseOrder(
225
+ {
226
+ operation: s,
227
+ doc: n,
228
+ options: (
229
+ // auto receive for supplier to warehouse
230
+ (s === v.enum.confirmDraft || // auto receive for warehouse to warehouse
231
+ s === v.enum.completeReceive) && g.autoReceiveWarehouse ? {
232
+ autoReceive: !0
233
+ } : void 0
234
+ )
235
+ },
236
+ w
237
+ ), await new Promise((q) => setTimeout(q, 1e3));
238
+ const C = oe().currentLocationDBName.startsWith("restaurant_");
239
+ s === v.enum.confirmDraft && n.effectiveAt && C ? D.open({
240
+ title: "Success",
241
+ message: `${_}. The backdate will be reflected once your POS has received this change.`,
242
+ type: "success"
243
+ }) : D.open({
244
+ title: "Success",
245
+ message: _,
246
+ type: "success"
247
+ });
248
+ } catch (A) {
249
+ D.open({
250
+ title: "Something went wrong",
251
+ message: "Please try again.",
252
+ type: "error"
253
+ }), console.error("Error when submitting PO operation", s, n, A);
254
+ } finally {
255
+ m.value = !1, t();
256
+ }
257
+ }
258
+ async function V(n, s, _) {
259
+ const w = $e[s];
260
+ if (!w) {
261
+ D.open({
262
+ title: "Something went wrong",
263
+ message: `Cannot process order: ${Y(s)}`,
264
+ type: "error"
265
+ });
266
+ return;
267
+ }
268
+ const { successMessage: A, ...C } = w;
269
+ d.open({
270
+ title: C.title,
271
+ message: C.message,
272
+ primaryActions: C.primaryActions
273
+ }).onPrimary(() => {
274
+ K(n, s, A, _);
275
+ });
276
+ }
277
+ return {
278
+ purchaseOrders: L,
279
+ purchaseRequests: o,
280
+ updateDateRange: c,
281
+ fetchData: t,
282
+ loading: m,
283
+ transferDialogProps: $,
284
+ promptCreateTransferDialog: ie,
285
+ promptUpdateTransferDialog: B,
286
+ transferDetailsProps: R,
287
+ promptShowTransferDetails: W,
288
+ submitAction: V
289
+ };
290
+ }
291
+ function Ye(a, i) {
292
+ return i.reduce(
293
+ (r, g) => {
294
+ const m = g.received.find((D) => D.sku._id === a._id);
295
+ return m && (r = Pe(r, m.amount)), r;
296
+ },
297
+ He.toPrecision(pe(0), a.unit.precision)
298
+ );
299
+ }
300
+ function fe(a, i, d) {
301
+ const r = (d == null ? void 0 : d.abbrev) ?? i.abbrev;
302
+ return `${ce(a, !1)} ${r}`;
303
+ }
304
+ function We(a, i) {
305
+ const { name: d, address: r, regNo: g } = i.doc.profile, m = {
306
+ name: d,
307
+ registrationNumber: g,
308
+ line1: r == null ? void 0 : r.line1,
309
+ line2: r == null ? void 0 : r.line2,
310
+ postcode: r == null ? void 0 : r.postcode,
311
+ city: r == null ? void 0 : r.city,
312
+ state: r == null ? void 0 : r.state,
313
+ country: r == null ? void 0 : r.country
314
+ }, D = {
315
+ name: a.supplier.name,
316
+ registrationNumber: a.supplier.registrationNumber,
317
+ line1: a.supplier.address.line1,
318
+ line2: a.supplier.address.line2,
319
+ postcode: a.supplier.address.postcode,
320
+ city: a.supplier.address.city,
321
+ state: a.supplier.address.state,
322
+ country: a.supplier.address.country
323
+ }, T = a.items.map((o) => {
324
+ const { sku: h, measurement: E } = o, $ = ce(
325
+ Ye(o.sku, a.deliveryOrder || []),
326
+ !1
327
+ );
328
+ return {
329
+ code: h.code,
330
+ description: h.name,
331
+ quantity: fe(o.quantity, h.unit, o.measurement),
332
+ unit: (E == null ? void 0 : E.abbrev) || h.unit.abbrev,
333
+ received: $
334
+ };
335
+ }), L = a.deliveryOrder.map((o) => ({
336
+ createdAt: ne(new Date(o.createdAt)),
337
+ ref: o.deliveryOrderNumber,
338
+ remark: o.remark || "",
339
+ items: o.received.map((h) => {
340
+ var E;
341
+ return {
342
+ code: h.sku.code,
343
+ description: h.sku.name,
344
+ quantity: ce(h.amount),
345
+ unit: ((E = h.measurement) == null ? void 0 : E.abbrev) || h.sku.unit.abbrev
346
+ };
347
+ })
348
+ })), u = {
349
+ orderNumber: a.seqNumber.toString(),
350
+ createdAt: le(a._id),
351
+ ref: a.ref || "",
352
+ remark: a.remark || "",
353
+ buyer: m,
354
+ supplier: D,
355
+ items: T,
356
+ status: a.status,
357
+ deliveryOrders: L
358
+ }, l = new URL(window.location.href);
359
+ l.pathname = "/receive-request/print-preview", l.searchParams.append("data", JSON.stringify(u)), window.open(l.href, "_blank", "noreferrer");
360
+ }
361
+ const Q = {
362
+ submitRequest: {
363
+ label: "Submit request",
364
+ color: "text-fm-color-typo-primary",
365
+ value: v.enum.submitRequest
366
+ },
367
+ confirmDraft: {
368
+ label: "Confirm draft",
369
+ color: "text-fm-color-typo-primary",
370
+ value: v.enum.confirmDraft
371
+ },
372
+ cancelDraft: {
373
+ label: "Cancel draft",
374
+ color: "text-fm-color-typo-error",
375
+ value: v.enum.cancelDraft
376
+ },
377
+ approveRequest: {
378
+ label: "Approve",
379
+ color: "text-fm-color-typo-primary",
380
+ value: v.enum.approveRequest
381
+ },
382
+ rejectRequest: {
383
+ label: "Reject",
384
+ color: "text-fm-color-typo-error",
385
+ value: v.enum.rejectRequest
386
+ },
387
+ processRequest: {
388
+ label: "Process",
389
+ color: "text-fm-color-typo-primary",
390
+ value: v.enum.processRequest
391
+ },
392
+ receiveStock: {
393
+ label: "Receive Stock",
394
+ color: "text-fm-color-typo-primary",
395
+ value: v.enum.receiveStock
396
+ },
397
+ completeReceive: {
398
+ label: "Mark completed",
399
+ color: "text-fm-color-typo-primary",
400
+ value: v.enum.completeReceive
401
+ }
402
+ };
403
+ function _r(a, i) {
404
+ const d = oe();
405
+ function r(u) {
406
+ switch (u.status) {
407
+ case "DRAFT":
408
+ return [
409
+ u.supplier.internal === "restaurant" || u.supplier.internal === "warehouse" ? Q[v.enum.submitRequest] : Q[v.enum.confirmDraft],
410
+ Q[v.enum.cancelDraft],
411
+ N[k.Update],
412
+ N[k.Details],
413
+ N[k.Print]
414
+ ];
415
+ case "RECEIVING":
416
+ return [
417
+ Q[v.enum.completeReceive],
418
+ N[k.Update],
419
+ N[k.Details],
420
+ N[k.Print]
421
+ ];
422
+ case "REQUESTING":
423
+ return a === "receive/request" ? [
424
+ N[k.Update],
425
+ N[k.Details],
426
+ N[k.Print]
427
+ ] : [
428
+ Q[v.enum.approveRequest],
429
+ Q[v.enum.rejectRequest],
430
+ N[k.Details],
431
+ N[k.Print]
432
+ ];
433
+ case "PROCESSING":
434
+ return [N[k.Details], N[k.Print]];
435
+ case "COMPLETE":
436
+ case "CANCEL":
437
+ default:
438
+ return [
439
+ N[k.Update],
440
+ N[k.Details],
441
+ N[k.Print]
442
+ ];
443
+ }
444
+ }
445
+ function g(u) {
446
+ return Object.values(v.enum).includes(u);
447
+ }
448
+ async function m(u, l, o) {
449
+ var E, $;
450
+ const h = Ce(l);
451
+ if (u === k.Print) {
452
+ We(h, d.currentLocation);
453
+ return;
454
+ }
455
+ if (u === k.Details) {
456
+ i.promptShowTransferDetails(h, o);
457
+ return;
458
+ }
459
+ if (u === k.Update) {
460
+ (E = i.promptUpdateTransferDialog) == null || E.call(i, h);
461
+ return;
462
+ }
463
+ if (g(u)) {
464
+ i.submitAction(l, u, ($ = o == null ? void 0 : o.to) == null ? void 0 : $.dbName);
465
+ return;
466
+ }
467
+ }
468
+ function D() {
469
+ return [
470
+ {
471
+ accessorKey: "seqNumber",
472
+ header: "#",
473
+ enableSorting: !0,
474
+ size: 80,
475
+ sortUndefined: "last"
476
+ },
477
+ {
478
+ accessorKey: "_id",
479
+ header: "Created At",
480
+ cell(u) {
481
+ return le(`${u.getValue()}`);
482
+ },
483
+ enableSorting: !0
484
+ },
485
+ {
486
+ accessorKey: "supplier.name",
487
+ header: "Transfer From",
488
+ enableSorting: !0,
489
+ size: 200
490
+ },
491
+ {
492
+ accessorKey: "items.length",
493
+ header: "No. of Items",
494
+ enableSorting: !1,
495
+ meta: {
496
+ width: "10rem"
497
+ }
498
+ },
499
+ {
500
+ accessorKey: "ref",
501
+ header: "Reference",
502
+ enableSorting: !1,
503
+ size: "auto"
504
+ },
505
+ {
506
+ accessorKey: "status",
507
+ header: "Status",
508
+ cell(u) {
509
+ const l = `${u.getValue() ?? ""}`.toLocaleLowerCase("en-us");
510
+ return Se(Ae.FmChip, {
511
+ label: l === "cancel" ? "Cancelled" : Y(l),
512
+ class: `fm-status-badge fm-status-badge-${l}`,
513
+ compact: !0
514
+ });
515
+ },
516
+ enableSorting: !0,
517
+ size: 200
518
+ },
519
+ {
520
+ id: "action",
521
+ cell(u) {
522
+ const l = u.row.original, o = r(l);
523
+ return Re(o, (h) => m(h, l));
524
+ },
525
+ enableSorting: !1,
526
+ size: 40,
527
+ meta: {
528
+ cellClass: "",
529
+ headerClass: ""
530
+ }
531
+ }
532
+ ];
533
+ }
534
+ function T() {
535
+ return [
536
+ {
537
+ accessorKey: "purchaseOrder.seqNumber",
538
+ header: "#",
539
+ enableSorting: !0,
540
+ size: 80,
541
+ sortUndefined: "last"
542
+ },
543
+ {
544
+ accessorKey: "purchaseOrder._id",
545
+ header: "Created At",
546
+ cell(u) {
547
+ return le(`${u.getValue()}`);
548
+ },
549
+ enableSorting: !0
550
+ },
551
+ {
552
+ accessorKey: "to.name",
553
+ header: "Transfer To",
554
+ enableSorting: !1,
555
+ size: 200
556
+ },
557
+ {
558
+ accessorKey: "purchaseOrder.items.length",
559
+ header: "No. of Items",
560
+ enableSorting: !1
561
+ },
562
+ {
563
+ accessorKey: "purchaseOrder.ref",
564
+ header: "Reference",
565
+ enableSorting: !1,
566
+ size: "auto"
567
+ },
568
+ {
569
+ accessorKey: "purchaseOrder.status",
570
+ header: "Status",
571
+ cell(u) {
572
+ const l = `${u.getValue() ?? ""}`.toLocaleLowerCase("en-us");
573
+ return Se(Ae.FmChip, {
574
+ label: Y(l),
575
+ class: `fm-status-badge fm-status-badge-${l}`,
576
+ compact: !0
577
+ });
578
+ },
579
+ enableSorting: !0
580
+ },
581
+ {
582
+ id: "action",
583
+ cell(u) {
584
+ const l = u.row.original, o = l.purchaseOrder ? r(l.purchaseOrder) : [];
585
+ return Re(
586
+ o,
587
+ (h) => l.purchaseOrder ? m(h, l.purchaseOrder, l) : void 0
588
+ );
589
+ },
590
+ enableSorting: !1,
591
+ size: 40,
592
+ meta: {
593
+ cellClass: "",
594
+ headerClass: ""
595
+ }
596
+ }
597
+ ];
598
+ }
599
+ const L = re(() => a === "receive/request" ? D() : T());
600
+ return {
601
+ get columnDefs() {
602
+ return L.value;
603
+ }
604
+ };
605
+ }
606
+ var te = /* @__PURE__ */ ((a) => (a.PURCHASE = "PURCHASE", a.TRANSFER = "TRANSFER", a))(te || {});
607
+ const Je = { class: "flex flex-col gap-16 w-full h-full" }, Ze = { class: "xs:w-screen max-w-full" }, Xe = { class: "flex justify-between" }, et = /* @__PURE__ */ e("div", { class: "fm-typo-en-body-lg-600" }, "Request summary", -1), tt = { class: "flex flex-col gap-8" }, rt = { class: "flex flex-col gap-4" }, st = /* @__PURE__ */ e("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, [
608
+ /* @__PURE__ */ e("div", { class: "flex gap-1" }, "Created at")
609
+ ], -1), at = { class: "fm-typo-en-body-lg-600" }, ot = {
610
+ key: 0,
611
+ class: "flex flex-col gap-4"
612
+ }, nt = /* @__PURE__ */ e("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " Backdated to ", -1), ct = { class: "fm-typo-en-body-lg-600" }, lt = { class: "flex flex-col gap-4" }, it = /* @__PURE__ */ e("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, "Type", -1), ut = { class: "fm-typo-en-body-lg-600" }, dt = {
613
+ key: 1,
614
+ class: "flex flex-col gap-4"
615
+ }, mt = /* @__PURE__ */ e("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, "From", -1), pt = { class: "fm-typo-en-body-lg-600" }, ft = {
616
+ key: 2,
617
+ class: "flex flex-col gap-4"
618
+ }, vt = /* @__PURE__ */ e("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, "To", -1), yt = { class: "fm-typo-en-body-lg-600" }, ht = {
619
+ key: 3,
620
+ class: "flex flex-col gap-4"
621
+ }, gt = /* @__PURE__ */ e("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, "Reference", -1), bt = { class: "fm-typo-en-body-lg-600" }, _t = {
622
+ key: 4,
623
+ class: "flex flex-col gap-4"
624
+ }, wt = /* @__PURE__ */ e("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, "Remark", -1), Ot = { class: "fm-typo-en-body-lg-600" }, Dt = { class: "border border-fm-color-neutral-gray-200 fm-corner-radius-lg p-16" }, St = { class: "flex flex-col gap-8" }, kt = { class: "fm-typo-en-body-lg-600" }, At = { class: "flex w-full gap-4" }, Rt = { class: "grow fm-typo-en-body-lg-400 line-clamp-2" }, Ct = /* @__PURE__ */ e("div", { class: "flex-1 min-w-32" }, null, -1), xt = { class: "fm-typo-en-body-lg-600 shrink-0" }, Pt = { class: "flex w-full gap-4 fm-typo-en-body-sm-400" }, Nt = { class: "grow fm-typo-en-body-lg-400 text-fm-color-typo-secondary line-clamp-2" }, Et = {
625
+ key: 0,
626
+ class: "shrink-0 fm-typo-en-body-lg-400 text-fm-color-typo-secondary"
627
+ }, Tt = {
628
+ key: 1,
629
+ class: "flex-1 xs:w-screen xs:max-w-full"
630
+ }, $t = {
631
+ key: 0,
632
+ class: "flex flex-col items-center gap-8 h-full"
633
+ }, qt = ["src"], Ut = /* @__PURE__ */ e("div", { class: "fm-typo-en-body-lg-600" }, "No records found", -1), Mt = /* @__PURE__ */ e("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary px-16" }, " Track and manage your delivery history here. ", -1), Ft = {
634
+ key: 1,
635
+ class: "px-4 flex flex-col"
636
+ }, Lt = { class: "flex gap-12 content-stretch" }, jt = {
637
+ class: "flex flex-col w-24",
638
+ name: "circles"
639
+ }, Bt = { class: "flex-1 flex flex-col items-center" }, It = /* @__PURE__ */ e("div", { class: "h-24 w-24 bg-fm-color-primary rounded-full" }, null, -1), Vt = { class: "flex-1 flex flex-col items-center" }, Gt = {
640
+ class: "py-12 flex flex-col gap-4",
641
+ name: "received-at header"
642
+ }, Kt = /* @__PURE__ */ e("div", { class: "fm-typo-en-body-lg-400" }, "Received", -1), zt = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, Ht = { class: "flex gap-12 content-stretch" }, Qt = {
643
+ class: "flex flex-col w-24",
644
+ name: "circles"
645
+ }, Yt = { class: "flex-1 flex flex-col items-center" }, Wt = {
646
+ class: "py-12 flex flex-col gap-4 flex-1",
647
+ name: "delivery details"
648
+ }, Jt = { class: "flex flex-col gap-8" }, Zt = { class: "flex flex-col gap-4" }, Xt = /* @__PURE__ */ e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, " Received by ", -1), er = { class: "fm-typo-en-body-lg-600" }, tr = { class: "flex flex-col gap-4" }, rr = /* @__PURE__ */ e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, " Received items ", -1), sr = { class: "flex flex-col gap-4" }, ar = /* @__PURE__ */ e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, " Delivery order no. ", -1), or = { class: "fm-typo-en-body-lg-600" }, nr = { class: "flex flex-col gap-4" }, cr = {
649
+ key: 0,
650
+ class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary"
651
+ }, lr = { class: "fm-typo-en-body-lg-600" }, ir = { class: "flex gap-8 xs:flex-col" }, wr = /* @__PURE__ */ Ue({
652
+ __name: "TransferDetails",
653
+ props: {
654
+ purchaseOrder: {},
655
+ transferTo: {},
656
+ transferToDbName: {},
657
+ show: { type: Boolean },
658
+ canResubmit: { type: Boolean },
659
+ canApprove: { type: Boolean }
660
+ },
661
+ emits: ["update:show", "submitted"],
662
+ setup(a, { emit: i }) {
663
+ const d = a, r = i, g = Ne(), m = Ee(), D = xe(), T = re(
664
+ () => {
665
+ var t, c, R, b;
666
+ return ((c = (t = d.purchaseOrder) == null ? void 0 : t.supplier) == null ? void 0 : c.internal) === "restaurant" || ((b = (R = d.purchaseOrder) == null ? void 0 : R.supplier) == null ? void 0 : b.internal) === "warehouse" ? te.TRANSFER : te.PURCHASE;
667
+ }
668
+ ), L = [
669
+ {
670
+ label: "Overview"
671
+ },
672
+ {
673
+ label: "Delivery history"
674
+ }
675
+ ], u = F(L[0]), l = F(!1), o = F(""), h = F(!0), E = Te(), $ = ze(d, "show");
676
+ async function ie(t, c, R) {
677
+ o.value = c, l.value = !0, h.value = !1;
678
+ try {
679
+ await E.processPurchaseOrder(
680
+ {
681
+ operation: c,
682
+ doc: t,
683
+ options: (
684
+ // auto receive for supplier to warehouse
685
+ (c === v.enum.confirmDraft || // auto receive for warehouse to warehouse
686
+ c === v.enum.completeReceive) && D.autoReceiveWarehouse ? {
687
+ autoReceive: !0
688
+ } : void 0
689
+ )
690
+ },
691
+ d.transferToDbName
692
+ ), await new Promise((b) => setTimeout(b, 1e3)), m.open({
693
+ title: "Success",
694
+ message: R,
695
+ type: "success"
696
+ }), r("update:show", !1), r("submitted");
697
+ } catch (b) {
698
+ m.open({
699
+ title: "Something went wrong",
700
+ message: "Please try again.",
701
+ type: "error"
702
+ }), console.error("Error when submitting PO operation", c, t, b);
703
+ } finally {
704
+ o.value = "", l.value = !1, h.value = !0;
705
+ }
706
+ }
707
+ async function B(t) {
708
+ const c = $e[t];
709
+ if (!c) {
710
+ m.open({
711
+ title: "Something went wrong",
712
+ message: `Cannot process order: ${Y(t)}`,
713
+ type: "error"
714
+ });
715
+ return;
716
+ }
717
+ const { successMessage: R, ...b } = c;
718
+ g.open({
719
+ title: b.title,
720
+ message: b.message,
721
+ primaryActions: b.primaryActions
722
+ }).onPrimary(() => {
723
+ d.purchaseOrder && ie(d.purchaseOrder, t, R);
724
+ });
725
+ }
726
+ const ue = re(() => {
727
+ var t, c;
728
+ return ((t = d.purchaseOrder) == null ? void 0 : t.status) === M.enum.RECEIVING || ((c = d.purchaseOrder) == null ? void 0 : c.status) === M.enum.COMPLETE;
729
+ }), de = re(() => {
730
+ var K, V, n;
731
+ const R = (((K = d.purchaseOrder) == null ? void 0 : K.deliveryOrder) ?? []).flatMap((s) => s.received ?? []).reduce(
732
+ (s, _) => {
733
+ const w = s[_.sku._id] ?? [];
734
+ return s[_.sku._id] = [...w, _], s;
735
+ },
736
+ {}
737
+ ), b = Object.entries(R).reduce(
738
+ (s, [_, w]) => {
739
+ const A = w.reduce((C, q) => {
740
+ const j = Ve(
741
+ C,
742
+ Math.max(C.precision, q.amount.precision)
743
+ );
744
+ return Pe(j, q.amount);
745
+ }, pe(0));
746
+ return s[_] = A, s;
747
+ },
748
+ {}
749
+ ), W = ((V = d.purchaseOrder) == null ? void 0 : V.items) ?? [];
750
+ for (const s of W)
751
+ b[n = s.sku._id] ?? (b[n] = pe(0));
752
+ return b;
753
+ });
754
+ return (t, c) => {
755
+ var _, w;
756
+ const R = H("FmButtonGroup"), b = H("FmChip"), W = H("FmMenuDivider"), K = H("FmCard"), V = H("FmSpacer"), n = H("FmButton"), s = H("FmSideSheet");
757
+ return f(), I(s, {
758
+ header: `Transfer details ${(_ = t.purchaseOrder) != null && _.seqNumber ? `#${(w = t.purchaseOrder) == null ? void 0 : w.seqNumber}` : ""}`,
759
+ modelValue: y($),
760
+ "onUpdate:modelValue": c[9] || (c[9] = (A) => Me($) ? $.value = A : null),
761
+ "dismiss-away": h.value,
762
+ "close-button": "",
763
+ "max-width": 500
764
+ }, {
765
+ default: se(() => {
766
+ var A, C, q, j, z, J, Z, X;
767
+ return [
768
+ e("div", Je, [
769
+ e("div", null, [
770
+ G(R, {
771
+ items: L,
772
+ modelValue: u.value,
773
+ "onUpdate:modelValue": c[0] || (c[0] = (p) => u.value = p)
774
+ }, null, 8, ["modelValue"])
775
+ ]),
776
+ ((A = u.value) == null ? void 0 : A.label) === "Overview" ? (f(), x(ee, { key: 0 }, [
777
+ e("div", Ze, [
778
+ G(K, {
779
+ variant: "outlined",
780
+ class: "flex flex-col gap-8 px-12 py-16"
781
+ }, {
782
+ default: se(() => {
783
+ var p, U, P, ve, ye, he, ge, be, _e, we, Oe, De;
784
+ return [
785
+ e("div", Xe, [
786
+ et,
787
+ e("div", null, [
788
+ G(b, {
789
+ label: ((p = t.purchaseOrder) == null ? void 0 : p.status) === "CANCEL" ? "Cancelled" : y(Y)(((U = t.purchaseOrder) == null ? void 0 : U.status) ?? ""),
790
+ class: ae(`fm-status-badge fm-status-badge-${(P = t.purchaseOrder) == null ? void 0 : P.status.toLocaleLowerCase("en-us")}`),
791
+ compact: ""
792
+ }, null, 8, ["label", "class"])
793
+ ])
794
+ ]),
795
+ G(W),
796
+ e("div", tt, [
797
+ e("div", rt, [
798
+ st,
799
+ e("div", at, O(y(le)(((ve = t.purchaseOrder) == null ? void 0 : ve._id) ?? "")), 1)
800
+ ]),
801
+ (ye = t.purchaseOrder) != null && ye.effectiveAt ? (f(), x("div", ot, [
802
+ nt,
803
+ e("div", ct, O(y(ne)(new Date((he = t.purchaseOrder) == null ? void 0 : he.effectiveAt))), 1)
804
+ ])) : S("", !0),
805
+ e("div", lt, [
806
+ it,
807
+ e("div", ut, O(y(Y)(T.value)), 1)
808
+ ]),
809
+ (be = (ge = t.purchaseOrder) == null ? void 0 : ge.supplier) != null && be.name ? (f(), x("div", dt, [
810
+ mt,
811
+ e("div", pt, O((we = (_e = t.purchaseOrder) == null ? void 0 : _e.supplier) == null ? void 0 : we.name), 1)
812
+ ])) : S("", !0),
813
+ t.transferTo ? (f(), x("div", ft, [
814
+ vt,
815
+ e("div", yt, O(t.transferTo), 1)
816
+ ])) : S("", !0),
817
+ (Oe = t.purchaseOrder) != null && Oe.ref ? (f(), x("div", ht, [
818
+ gt,
819
+ e("div", bt, O(t.purchaseOrder.ref), 1)
820
+ ])) : S("", !0),
821
+ (De = t.purchaseOrder) != null && De.remark ? (f(), x("div", _t, [
822
+ wt,
823
+ e("div", Ot, O(t.purchaseOrder.remark), 1)
824
+ ])) : S("", !0)
825
+ ])
826
+ ];
827
+ }),
828
+ _: 1
829
+ })
830
+ ]),
831
+ e("div", Dt, [
832
+ e("div", St, [
833
+ e("div", kt, O(ue.value ? "Received items" : "Requested items"), 1),
834
+ (f(!0), x(ee, null, me(((C = t.purchaseOrder) == null ? void 0 : C.items) ?? [], (p) => (f(), x("div", {
835
+ key: p.code,
836
+ class: "flex flex-col"
837
+ }, [
838
+ e("div", At, [
839
+ e("div", Rt, O(p.name), 1),
840
+ Ct,
841
+ e("div", xt, O(y(ce)(de.value[p.sku._id], !1)) + "/" + O(y(fe)(p.quantity, p.sku.unit, p.measurement)), 1)
842
+ ]),
843
+ e("div", Pt, [
844
+ e("div", Nt, O(p.code), 1),
845
+ p.totalCost && y(D).enableTotalCost ? (f(), x("div", Et, " (" + O(y(Ge)(p.totalCost)) + ") ", 1)) : S("", !0)
846
+ ])
847
+ ]))), 128))
848
+ ])
849
+ ])
850
+ ], 64)) : S("", !0),
851
+ ((q = u.value) == null ? void 0 : q.label) === "Delivery history" ? (f(), x("div", Tt, [
852
+ ((z = (j = t.purchaseOrder) == null ? void 0 : j.deliveryOrder) == null ? void 0 : z.length) === 0 ? (f(), x("div", $t, [
853
+ G(V),
854
+ e("div", null, [
855
+ e("img", {
856
+ src: y(Qe),
857
+ alt: "List is empty"
858
+ }, null, 8, qt)
859
+ ]),
860
+ Ut,
861
+ Mt,
862
+ G(V),
863
+ G(V)
864
+ ])) : S("", !0),
865
+ (J = t.purchaseOrder) != null && J.deliveryOrder && ((Z = t.purchaseOrder) == null ? void 0 : Z.deliveryOrder.length) > 0 ? (f(), x("div", Ft, [
866
+ (f(!0), x(ee, null, me((X = t.purchaseOrder) == null ? void 0 : X.deliveryOrder, (p, U) => (f(), x(ee, { key: U }, [
867
+ e("div", Lt, [
868
+ e("div", jt, [
869
+ e("div", Bt, [
870
+ e("div", {
871
+ class: ae([
872
+ {
873
+ "bg-fm-color-primary": U !== 0,
874
+ "bg-white": U === 0
875
+ },
876
+ "w-[2px] h-full"
877
+ ])
878
+ }, null, 2)
879
+ ]),
880
+ It,
881
+ e("div", Vt, [
882
+ e("div", {
883
+ class: ae([
884
+ {
885
+ "bg-fm-color-primary": U < t.purchaseOrder.deliveryOrder.length - 1,
886
+ "bg-white": U >= t.purchaseOrder.deliveryOrder.length - 1
887
+ },
888
+ "w-[2px] h-full"
889
+ ])
890
+ }, null, 2)
891
+ ])
892
+ ]),
893
+ e("div", Gt, [
894
+ Kt,
895
+ e("div", zt, O(y(ne)(new Date(p.createdAt))) + ", " + O(y(Ke)(new Date(p.createdAt))), 1)
896
+ ])
897
+ ]),
898
+ e("div", Ht, [
899
+ e("div", Qt, [
900
+ e("div", Yt, [
901
+ e("div", {
902
+ class: ae([
903
+ {
904
+ "bg-fm-color-primary": U < t.purchaseOrder.deliveryOrder.length - 1,
905
+ "bg-white": U >= t.purchaseOrder.deliveryOrder.length - 1
906
+ },
907
+ "w-[2px] h-full"
908
+ ])
909
+ }, null, 2)
910
+ ])
911
+ ]),
912
+ e("div", Wt, [
913
+ G(K, {
914
+ variant: "outlined",
915
+ class: "py-12 px-16"
916
+ }, {
917
+ default: se(() => [
918
+ e("div", Jt, [
919
+ e("div", Zt, [
920
+ Xt,
921
+ e("div", er, O(p.createdBy.name), 1)
922
+ ]),
923
+ e("div", tr, [
924
+ rr,
925
+ (f(!0), x(ee, null, me(p.received, (P) => (f(), x("div", {
926
+ class: "fm-typo-en-body-lg-600",
927
+ key: P.sku._id
928
+ }, O(P.sku.name) + " " + O(y(fe)(P.amount, P.sku.unit, P.measurement)), 1))), 128))
929
+ ]),
930
+ e("div", sr, [
931
+ ar,
932
+ e("div", or, O(p.deliveryOrderNumber.trim().length ? p.deliveryOrderNumber : "-"), 1)
933
+ ]),
934
+ e("div", nr, [
935
+ p.remark ? (f(), x("div", cr, " Delivery remark ")) : S("", !0),
936
+ e("div", lr, O(p.remark), 1)
937
+ ])
938
+ ])
939
+ ]),
940
+ _: 2
941
+ }, 1024)
942
+ ])
943
+ ])
944
+ ], 64))), 128))
945
+ ])) : S("", !0)
946
+ ])) : S("", !0)
947
+ ])
948
+ ];
949
+ }),
950
+ "side-sheet-footer": se(() => {
951
+ var A, C, q, j, z, J, Z, X, p, U;
952
+ return [
953
+ e("div", ir, [
954
+ ((A = t.purchaseOrder) == null ? void 0 : A.status) === y(M).enum.DRAFT && T.value === y(te).PURCHASE ? (f(), I(n, {
955
+ key: 0,
956
+ label: "Confirm draft",
957
+ onClick: c[1] || (c[1] = (P) => B("confirmDraft")),
958
+ loading: o.value === "confirmDraft",
959
+ disabled: o.value !== "confirmDraft" && l.value
960
+ }, null, 8, ["loading", "disabled"])) : S("", !0),
961
+ ((C = t.purchaseOrder) == null ? void 0 : C.status) === y(M).enum.DRAFT && T.value === y(te).TRANSFER ? (f(), I(n, {
962
+ key: 1,
963
+ label: "Submit request",
964
+ onClick: c[2] || (c[2] = (P) => B("submitRequest")),
965
+ loading: o.value === "submitRequest",
966
+ disabled: o.value !== "submitRequest" && l.value
967
+ }, null, 8, ["loading", "disabled"])) : S("", !0),
968
+ ((q = t.purchaseOrder) == null ? void 0 : q.status) === y(M).enum.DRAFT ? (f(), I(n, {
969
+ key: 2,
970
+ label: "Cancel draft",
971
+ onClick: c[3] || (c[3] = (P) => B("cancelDraft")),
972
+ loading: o.value === "cancelDraft",
973
+ disabled: o.value !== "cancelDraft" && l.value,
974
+ variant: "destructive"
975
+ }, null, 8, ["loading", "disabled"])) : S("", !0),
976
+ ((j = t.purchaseOrder) == null ? void 0 : j.status) === y(M).enum.RECEIVING ? (f(), I(n, {
977
+ key: 3,
978
+ label: "Mark completed",
979
+ onClick: c[4] || (c[4] = (P) => B("completeReceive")),
980
+ loading: o.value === "completeReceive",
981
+ disabled: o.value !== "completeReceive" && l.value
982
+ }, null, 8, ["loading", "disabled"])) : S("", !0),
983
+ t.canResubmit ? (f(), I(n, {
984
+ key: 4,
985
+ label: "Resubmit request",
986
+ onClick: c[5] || (c[5] = (P) => B("submitRequest")),
987
+ loading: o.value === "submitRequest",
988
+ disabled: o.value !== "submitRequest" && l.value
989
+ }, null, 8, ["loading", "disabled"])) : S("", !0),
990
+ (((z = t.purchaseOrder) == null ? void 0 : z.status) === y(M).enum.REQUESTING || ((J = t.purchaseOrder) == null ? void 0 : J.status) === y(M).enum.PROCESSING) && t.canApprove ? (f(), I(n, {
991
+ key: 5,
992
+ label: "Approve",
993
+ onClick: c[6] || (c[6] = (P) => B("approveRequest")),
994
+ loading: o.value === "approveRequest",
995
+ disabled: o.value !== "approveRequest" && l.value
996
+ }, null, 8, ["loading", "disabled"])) : S("", !0),
997
+ ((Z = t.purchaseOrder) == null ? void 0 : Z.status) === y(M).enum.REQUESTING && t.canApprove ? (f(), I(n, {
998
+ key: 6,
999
+ label: "Reject",
1000
+ onClick: c[7] || (c[7] = (P) => B("rejectRequest")),
1001
+ loading: o.value === "rejectRequest",
1002
+ disabled: o.value !== "rejectRequest" && l.value,
1003
+ variant: "destructive"
1004
+ }, null, 8, ["loading", "disabled"])) : S("", !0),
1005
+ ((X = t.purchaseOrder) == null ? void 0 : X.status) !== y(M).enum.COMPLETE && ((p = t.purchaseOrder) == null ? void 0 : p.status) !== y(M).enum.CANCEL && (((U = t.purchaseOrder) == null ? void 0 : U.status) !== y(M).enum.REQUESTING || t.canApprove) ? (f(), I(n, {
1006
+ key: 7,
1007
+ label: "Close",
1008
+ variant: "tertiary",
1009
+ onClick: c[8] || (c[8] = (P) => r("update:show", !1))
1010
+ })) : S("", !0)
1011
+ ])
1012
+ ];
1013
+ }),
1014
+ _: 1
1015
+ }, 8, ["header", "modelValue", "dismiss-away"]);
1016
+ };
1017
+ }
1018
+ });
1019
+ export {
1020
+ te as P,
1021
+ wr as _,
1022
+ br as a,
1023
+ _r as b,
1024
+ Ye as g,
1025
+ qe as p,
1026
+ Te as u
1027
+ };