@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,1298 @@
1
+ import { defineComponent as Pe, ref as I, watch as ue, computed as U, resolveComponent as S, openBlock as g, createBlock as j, withCtx as O, createElementVNode as n, createVNode as d, toDisplayString as L, createElementBlock as F, Fragment as Re, renderList as Be, unref as i, createTextVNode as aa, mergeModels as Nt, useModel as sa, onMounted as oa, createCommentVNode as q, normalizeClass as Yt, normalizeStyle as Xt, h as X, isRef as la, Teleport as na, mergeProps as qt } from "vue";
2
+ import { I as tt, g as he, m as ye, n as ra, b as lt, i as ua, C as at, u as ia, o as Ge, p as ca } from "./app-BzDhmCVx.js";
3
+ import { i as Xe } from "./init-date-range-M3Q03-Fd.js";
4
+ import { u as Zt, p as Lt, P, a as da, b as ma, _ as pa, g as fa } from "./TransferDetails.vue_vue_type_script_setup_true_lang-Ffe9bhq8.js";
5
+ import { a as ve, k as jt, b as Je, r as ot, s as va, u as It, v as _a, i as zt, w as ga, q as Qt, x as ba, j as ha, f as ya, t as Kt } from "./date2-C7HiAWQG.js";
6
+ import { i as xa, e as Ca } from "./id-to-date-ReZIpUDw.js";
7
+ import { d as st } from "./dayjs.min-Db57WhI9.js";
8
+ import { _ as Da } from "./SingleColumnLayout.vue_vue_type_script_setup_true_lang-CFjO4TPG.js";
9
+ import { _ as ka } from "./ChangeLocationComponent.vue_vue_type_script_setup_true_lang-DcixBOcX.js";
10
+ import { useDialog as Sa, useSnackbar as nt, components as re, useProxiedModel as wa, useBreakpoints as Va } from "@feedmepos/ui-library";
11
+ import { R as Gt, F as Te } from "./row-action.enum-BwQbURNh.js";
12
+ import { useCoreStore as Fa } from "@feedmepos/mf-common";
13
+ import { _ as Ta } from "./FmMultiselectDialog.vue_vue_type_script_setup_true_lang-BXU7x6di.js";
14
+ import { F as Q, _ as ea, u as Ra } from "./layout-BvUjg6JS.js";
15
+ import { R as We, B as Pa, a as Wt, M as Ua } from "./rules-DHfAMDW3.js";
16
+ import { u as ta } from "./supplier-DTiiOLtg.js";
17
+ const Aa = { class: "inline-flex rounded-md items-center gap-4 justify-center h-[30px] px-8 py-4 bg-fm-color-neutral-gray-100 cursor-pointer text-fm-color-neutral-gray-400" }, Ma = { class: "fm-typo-en-body-md-600 select-none text-ellipsis overflow-hidden whitespace-nowrap" }, $a = /* @__PURE__ */ Pe({
18
+ __name: "FmDateRangePickerChip",
19
+ props: {
20
+ modelValue: { default: (Z) => Z.modelValue ?? Xe() }
21
+ },
22
+ emits: ["update:modelValue"],
23
+ setup(Z, { emit: ee }) {
24
+ const K = ee, y = I(Xe());
25
+ ue(y, (w) => {
26
+ K("update:modelValue", w);
27
+ });
28
+ const k = U(() => {
29
+ const { startDate: w, endDate: f } = y.value;
30
+ return !w && !f ? "" : `${w} - ${f}`;
31
+ });
32
+ return (w, f) => {
33
+ const b = S("FmIcon"), D = S("FmDateRangePicker");
34
+ return g(), j(D, {
35
+ "show-predefined-range": "",
36
+ modelValue: y.value,
37
+ "onUpdate:modelValue": f[0] || (f[0] = (G) => y.value = G),
38
+ "start-label": "",
39
+ "end-label": ""
40
+ }, {
41
+ "trigger-button": O(() => [
42
+ n("div", Aa, [
43
+ d(b, {
44
+ name: "calendar_month",
45
+ size: "sm"
46
+ }),
47
+ n("div", Ma, L(k.value), 1)
48
+ ])
49
+ ]),
50
+ _: 1
51
+ }, 8, ["modelValue"]);
52
+ };
53
+ }
54
+ }), Ea = { class: "flex flex-col gap-8 px-16 xs:px-4 sm:px-4 py-4 items-center" }, Oa = { class: "fm-typo-body-md-400 mr-auto xs:w-full" }, Ha = { class: "hidden xs:inline" }, Na = {
55
+ key: 0,
56
+ class: "fm-typo-body-sm-700"
57
+ }, Ya = { class: "xs:hidden" }, qa = {
58
+ key: 1,
59
+ class: "fm-typo-body-sm-700 text-fm-color-typo-disabled"
60
+ }, La = { class: "fm-typo-body-sm-400 text-fm-color-typo-secondary" }, ja = {
61
+ key: 0,
62
+ class: "flex flex-col"
63
+ }, Ia = { key: 1 }, Jt = /* @__PURE__ */ Pe({
64
+ __name: "SupplierPriceHistory",
65
+ props: {
66
+ prices: {}
67
+ },
68
+ setup(Z) {
69
+ const ee = ta();
70
+ function K(y) {
71
+ return ee.suppliers.find((k) => k._id === y);
72
+ }
73
+ return (y, k) => {
74
+ const w = S("FmTooltip");
75
+ return g(), F("div", Ea, [
76
+ (g(!0), F(Re, null, Be(Object.keys(y.prices), (f) => {
77
+ var b, D, G;
78
+ return g(), F("div", {
79
+ key: f,
80
+ class: "flex items-center gap-12 xs:gap-4 xs:flex-wrap w-full"
81
+ }, [
82
+ n("div", Oa, [
83
+ n("span", null, L((b = K(f)) == null ? void 0 : b.name), 1),
84
+ n("span", Ha, " (per " + L((G = (D = y.prices[f].find((C) => C.unit)) == null ? void 0 : D.unit) == null ? void 0 : G.abbrev) + ") ", 1)
85
+ ]),
86
+ (g(!0), F(Re, null, Be(y.prices[f], (C) => (g(), F("div", {
87
+ key: C.date,
88
+ class: "flex flex-col w-120 xs:w-72 xs:flex-1 text-ellipsis cursor-pointer"
89
+ }, [
90
+ d(w, { "z-index": 50 }, {
91
+ content: O(() => [
92
+ C.totalUnits && C.unit && C.pricePerUnit ? (g(), F("div", ja, [
93
+ n("div", null, " Total units: " + L(i(ve)(C.totalUnits)) + " " + L(C.unit.abbrev), 1),
94
+ n("div", null, " Total bought: " + L(i(jt)({
95
+ ...i(Je)(C.pricePerUnit, C.totalUnits),
96
+ currency: C.pricePerUnit.currency
97
+ })), 1)
98
+ ])) : (g(), F("div", Ia, "No data"))
99
+ ]),
100
+ default: O(() => [
101
+ n("div", null, [
102
+ C.pricePerUnit && C.unit ? (g(), F("div", Na, [
103
+ aa(L(i(jt)(C.pricePerUnit)) + " ", 1),
104
+ n("span", Ya, "/ " + L(C.unit.abbrev), 1)
105
+ ])) : (g(), F("div", qa, "No data")),
106
+ n("div", La, L(i(ot)(new Date(C.date))), 1)
107
+ ])
108
+ ]),
109
+ _: 2
110
+ }, 1024)
111
+ ]))), 128))
112
+ ]);
113
+ }), 128))
114
+ ]);
115
+ };
116
+ }
117
+ }), za = { class: "flex flex-col w-full gap-40" }, Qa = { class: "flex flex-col gap-8" }, Ka = /* @__PURE__ */ n("div", { class: "fm-typo-en-title-sm-800" }, "Transfer details", -1), Ga = { class: "flex items-center gap-8" }, Wa = /* @__PURE__ */ n("div", null, null, -1), Ja = { class: "flex flex-col gap-4" }, Ba = {
118
+ key: 0,
119
+ class: "p-16 border border-fm-color-neutral-gray-300 fm-corner-radius-md flex flex-col"
120
+ }, Xa = { class: "flex xs:flex-col sm:flex-col" }, Za = /* @__PURE__ */ n("div", { class: "xs:hidden sm:hidden h-48 lg:w-16 md:w-16" }, null, -1), es = {
121
+ key: 0,
122
+ class: "flex-1 flex gap-8 h-48 xs:flex-col xs:pt-16 sm:flex-col sm:pt-16"
123
+ }, ts = { class: "flex-1" }, as = { class: "flex-1" }, ss = {
124
+ key: 1,
125
+ class: "flex items-center gap-4"
126
+ }, os = /* @__PURE__ */ n("span", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary translate-y-[1px]" }, " Cannot backdate without an initial closing made to the system. ", -1), ls = { class: "flex flex-col gap-8" }, ns = { class: "flex items-center xs:flex-col xs:gap-4" }, rs = /* @__PURE__ */ n("div", { class: "xs:w-full flex-1 fm-typo-en-title-sm-800" }, "Transfer items", -1), us = {
127
+ key: 0,
128
+ class: "xs:w-full"
129
+ }, is = { key: 0 }, cs = { class: "fm-typo-body-md-400 line-clamp-2 w-full" }, ds = { key: 0 }, ms = ["colspan"], ps = { class: "flex flex-col gap-4" }, fs = { class: "flex items-center" }, vs = { class: "flex-1" }, _s = { class: "grid grid-cols-2 gap-4" }, gs = { class: "flex flex-col" }, bs = { class: "flex flex-col" }, hs = { class: "flex flex-col" }, ys = { class: "flex flex-col" }, xs = {
130
+ key: 0,
131
+ class: "flex flex-col col-span-2",
132
+ "data-cy": "fm-table-list-view-cost-label"
133
+ }, Cs = /* @__PURE__ */ Pe({
134
+ __name: "TransferForm",
135
+ props: /* @__PURE__ */ Nt({
136
+ modelValue: {},
137
+ disabled: { type: Boolean },
138
+ suppliers: { default: () => [] },
139
+ skus: { default: () => [] },
140
+ lastClosingDate: {}
141
+ }, {
142
+ modelValue: {
143
+ default: {
144
+ ref: "",
145
+ supplier: null
146
+ }
147
+ },
148
+ modelModifiers: {}
149
+ }),
150
+ emits: /* @__PURE__ */ Nt(["validation-success"], ["update:modelValue"]),
151
+ setup(Z, { expose: ee, emit: K }) {
152
+ const y = lt(), k = Fa(), w = Zt(), f = ua(), b = Z, D = U(() => {
153
+ function e(a) {
154
+ return Object.prototype.hasOwnProperty.call(a, "_rev") && Object.prototype.hasOwnProperty.call(a, "status");
155
+ }
156
+ const t = b.modelValue;
157
+ return !e(t) || t.status === "DRAFT";
158
+ }), G = U(() => {
159
+ var a;
160
+ if (D.value)
161
+ return !0;
162
+ const e = b.lastClosingDate, t = (a = b.modelValue) != null && a._id ? Lt(b.modelValue._id) : null;
163
+ return !e || !t ? !1 : t.getTime() > e.getTime();
164
+ }), C = K, m = sa(Z, "modelValue"), z = U({
165
+ get() {
166
+ var e;
167
+ return ((e = m.value) == null ? void 0 : e.remark) ?? "";
168
+ },
169
+ set(e) {
170
+ m.value.remark = e;
171
+ }
172
+ });
173
+ ue([() => b.suppliers], () => {
174
+ if (v.value === P.PURCHASE) {
175
+ m.value.supplier = b.suppliers[0];
176
+ return;
177
+ }
178
+ });
179
+ const T = U(() => b.disabled), ie = U(() => m.value.items ?? []), W = (e) => {
180
+ const { name: t, address: a, regNo: o, phoneNo: s } = e.doc.profile;
181
+ return {
182
+ _id: e.doc._id,
183
+ internal: e.type === tt.restaurant ? ye.enum.restaurant : ye.enum.warehouse,
184
+ name: t,
185
+ registrationNumber: o,
186
+ address: a,
187
+ contactName: t,
188
+ phoneNumber: s,
189
+ disabled: !e.acceptRequest || e.dbName === y.currentLocation.dbName
190
+ };
191
+ }, A = [
192
+ {
193
+ label: "Purchase",
194
+ value: P.PURCHASE
195
+ },
196
+ {
197
+ label: "Transfer",
198
+ value: P.TRANSFER
199
+ }
200
+ ], v = I(P.PURCHASE), H = U(() => {
201
+ var t;
202
+ const e = ((t = y._currentLocation) == null ? void 0 : t.type) === tt.warehouse;
203
+ return y.locations.filter((a) => {
204
+ var s;
205
+ return !(a.dbName === ((s = y._currentLocation) == null ? void 0 : s.dbName)) && (!e || a.type === tt.warehouse) && a.acceptRequest;
206
+ });
207
+ }), $ = U(() => v.value === P.PURCHASE ? b.suppliers.map((e) => ({
208
+ label: e.name,
209
+ value: e._id,
210
+ disabled: !1
211
+ })) : H.value.map(W).map((e) => ({
212
+ label: e.disabled ? `${e.name} (Upgrade POS)` : e.name,
213
+ value: e._id,
214
+ disabled: e.disabled
215
+ }))), u = U({
216
+ get() {
217
+ var e;
218
+ return ((e = m.value.supplier) == null ? void 0 : e._id) ?? null;
219
+ },
220
+ set(e) {
221
+ if (v.value === P.PURCHASE) {
222
+ m.value.supplier = b.suppliers.find((a) => a._id === e) ?? null;
223
+ return;
224
+ }
225
+ const t = y.locations.find((a) => a.doc._id === e);
226
+ t ? m.value.supplier = W(t) : m.value.supplier = null;
227
+ }
228
+ });
229
+ function r(e) {
230
+ switch (e) {
231
+ case at.MY:
232
+ return "MYR";
233
+ case at.SG:
234
+ return "SGD";
235
+ case at.ID:
236
+ return "IDR";
237
+ default:
238
+ return "MYR";
239
+ }
240
+ }
241
+ ue([() => v.value], ([e]) => {
242
+ var t;
243
+ u.value = ((t = $.value.find((a) => !a.disabled)) == null ? void 0 : t.value) ?? null, e === P.PURCHASE && (m.value.items = m.value.items.map((a) => {
244
+ var o;
245
+ return {
246
+ ...a,
247
+ totalCost: a.totalCost ?? {
248
+ amount: 1,
249
+ precision: 0,
250
+ currency: r(((o = k.currentCountry) == null ? void 0 : o.value) ?? he)
251
+ }
252
+ };
253
+ }));
254
+ }), ue([() => b.modelValue], ([e]) => {
255
+ var t, a, o;
256
+ ((t = e == null ? void 0 : e.supplier) == null ? void 0 : t.internal) === ye.enum.restaurant || ((a = e == null ? void 0 : e.supplier) == null ? void 0 : a.internal) === ye.enum.warehouse ? v.value = P.TRANSFER : v.value = P.PURCHASE, u.value = ((o = $.value.find((s) => {
257
+ var c, l;
258
+ return s.value === ((l = (c = b.modelValue) == null ? void 0 : c.supplier) == null ? void 0 : l._id);
259
+ })) == null ? void 0 : o.value) ?? null;
260
+ }), oa(() => {
261
+ var e, t, a, o, s, c, l;
262
+ ((t = (e = b.modelValue) == null ? void 0 : e.supplier) == null ? void 0 : t.internal) === ye.enum.restaurant || ((o = (a = b.modelValue) == null ? void 0 : a.supplier) == null ? void 0 : o.internal) === ye.enum.warehouse ? v.value = P.TRANSFER : v.value = P.PURCHASE, u.value = (s = b.modelValue) != null && s.supplier ? ((c = $.value.find((_) => {
263
+ var V, N;
264
+ return _.value === ((N = (V = b.modelValue) == null ? void 0 : V.supplier) == null ? void 0 : N._id);
265
+ })) == null ? void 0 : c.value) ?? null : ((l = $.value.find((_) => !_.disabled)) == null ? void 0 : l.value) ?? null;
266
+ });
267
+ const R = Sa(), _e = nt();
268
+ function te() {
269
+ const e = b.skus.map((a) => ({
270
+ label: a.name,
271
+ sublabel: a.code,
272
+ value: a
273
+ })), t = e.filter((a) => {
274
+ var o;
275
+ return (o = m.value.items) == null ? void 0 : o.find((s) => s.sku._id === a.value._id);
276
+ }).map((a) => a.value);
277
+ R.open({
278
+ title: "Select item",
279
+ closeButton: !0,
280
+ contentComponent: Ta,
281
+ contentComponentProps: {
282
+ modelValue: t,
283
+ items: e
284
+ },
285
+ primaryActions: {
286
+ text: "Confirm",
287
+ close: !0
288
+ },
289
+ secondaryActions: {
290
+ text: "Close",
291
+ close: !0,
292
+ variant: "tertiary"
293
+ }
294
+ }).onPrimary((a) => {
295
+ const o = {
296
+ ...m.value
297
+ }, s = o.items ?? [], c = a.map((l) => {
298
+ var N;
299
+ const _ = s.find((ne) => ne.sku._id === l._id);
300
+ if (_)
301
+ return _;
302
+ const V = {
303
+ sku: l,
304
+ code: l.code,
305
+ name: l.name,
306
+ quantity: {
307
+ amount: 1,
308
+ precision: 0
309
+ }
310
+ };
311
+ return v.value === P.PURCHASE && f.enableTotalCost && (V.totalCost = {
312
+ amount: 1,
313
+ precision: 0,
314
+ currency: r(((N = k.currentCountry) == null ? void 0 : N.value) ?? he)
315
+ }), V;
316
+ });
317
+ c.sort((l, _) => l.sku.code.localeCompare(_.sku.code)), o.items = c, m.value = o;
318
+ });
319
+ }
320
+ function Ue(e, t) {
321
+ var a;
322
+ if (e === Gt.Delete) {
323
+ const o = ((a = m.value) == null ? void 0 : a.items) ?? [];
324
+ m.value.items = o.filter((s) => s.sku._id !== t);
325
+ return;
326
+ }
327
+ }
328
+ function ce(e) {
329
+ var c, l;
330
+ const t = ((c = m.value) == null ? void 0 : c.items) ?? [], a = (l = t == null ? void 0 : t.find((_) => _.sku._id === e)) == null ? void 0 : l.sku;
331
+ if (!a)
332
+ return [];
333
+ const o = a.unit.measurements ?? [];
334
+ return [
335
+ {
336
+ label: a.unit.abbrev,
337
+ value: null
338
+ },
339
+ ...o.map((_) => ({
340
+ label: _.abbrev,
341
+ value: _
342
+ }))
343
+ ];
344
+ }
345
+ function xe(e) {
346
+ var c;
347
+ const a = (((c = m.value) == null ? void 0 : c.items) ?? []).find((l) => l.sku._id === e), o = a == null ? void 0 : a.sku;
348
+ if (!a || !o) return null;
349
+ const s = ce(e);
350
+ return a.measurement ? s.find((l) => {
351
+ var _, V;
352
+ return ((_ = l.value) == null ? void 0 : _.id) === ((V = a.measurement) == null ? void 0 : V.id);
353
+ }) : s.find((l) => l.value === null);
354
+ }
355
+ function Ae(e, t) {
356
+ var o;
357
+ const a = ((o = m.value) == null ? void 0 : o.items) ?? [];
358
+ m.value.items = a.map((s) => s.sku._id !== e ? s : t ? (s.measurement = t, s) : (delete s.measurement, s));
359
+ }
360
+ function Me(e, t) {
361
+ const a = m.value, o = a.items ?? [];
362
+ a.items = o.map((s) => (s.sku._id !== e || (s.code = t), s));
363
+ }
364
+ function $e(e, t) {
365
+ const a = m.value, o = a.items ?? [];
366
+ a.items = o.map((s) => (s.sku._id !== e || (s.name = t), s));
367
+ }
368
+ function ge(e, t) {
369
+ const a = +t, o = m.value, s = o.items ?? [];
370
+ t.length > 0 && isFinite(a) ? o.items = s.map((c) => (c.sku._id !== e || (c.quantity = Kt(a)), c)) : o.items = s.map((c) => (c.sku._id !== e || (c.quantity = { amount: 0, precision: 0 }), c));
371
+ }
372
+ function Ee(e, t) {
373
+ const a = +t, o = m.value, s = o.items ?? [];
374
+ t.length > 0 && isFinite(a) ? o.items = s.map((c) => {
375
+ var l;
376
+ return c.sku._id !== e || (c.totalCost = {
377
+ ...Kt(a),
378
+ currency: r(((l = k.currentCountry) == null ? void 0 : l.value) ?? he)
379
+ }), c;
380
+ }) : o.items = s.map((c) => {
381
+ var l;
382
+ return c.sku._id !== e || (c.totalCost = {
383
+ amount: 0,
384
+ precision: 0,
385
+ currency: r(((l = k.currentCountry) == null ? void 0 : l.value) ?? he)
386
+ }), c;
387
+ });
388
+ }
389
+ const Ce = [
390
+ {
391
+ header: "Code",
392
+ accessorKey: "code",
393
+ cell(e) {
394
+ const t = e.row.original;
395
+ return D.value ? X(re.FmTextField, {
396
+ modelValue: t.code,
397
+ "onUpdate:modelValue": (a) => {
398
+ Me(t.sku._id, a);
399
+ },
400
+ rules: [We()],
401
+ labelMark: "required"
402
+ }) : t.code;
403
+ },
404
+ enableSorting: !1
405
+ },
406
+ {
407
+ id: "Name",
408
+ header: "Name",
409
+ cell(e) {
410
+ const t = e.row.original;
411
+ return D.value ? X(re.FmTextField, {
412
+ modelValue: t.name,
413
+ "onUpdate:modelValue": (a) => {
414
+ $e(t.sku._id, a);
415
+ },
416
+ rules: [We()],
417
+ labelMark: "required"
418
+ }) : t.name;
419
+ },
420
+ enableSorting: !1
421
+ },
422
+ {
423
+ id: "Amount",
424
+ header: "Amount",
425
+ cell(e) {
426
+ var o, s, c;
427
+ const t = e.row.original, a = (c = (s = (o = m.value) == null ? void 0 : o.items) == null ? void 0 : s.find) == null ? void 0 : c.call(s, (l) => l.sku._id === t.sku._id);
428
+ return D.value ? X(re.FmTextField, {
429
+ style: {
430
+ flex: "1 1 0%"
431
+ },
432
+ modelValue: +ve((a == null ? void 0 : a.quantity) ?? { amount: 1, precision: 0 }),
433
+ "onUpdate:modelValue": (l) => {
434
+ ge(t.sku._id, l);
435
+ },
436
+ rules: [Wt(a.sku.unit, a.measurement)]
437
+ }) : ve((a == null ? void 0 : a.quantity) ?? { amount: 1, precision: 0 });
438
+ },
439
+ enableSorting: !1,
440
+ meta: {
441
+ width: "120px"
442
+ }
443
+ },
444
+ {
445
+ id: "Unit",
446
+ header: "Unit",
447
+ cell(e) {
448
+ var a, o;
449
+ const t = e.row.original;
450
+ return D.value ? X(re.FmSelect, {
451
+ style: {
452
+ flex: "1 1 0%"
453
+ },
454
+ items: ce(t.sku._id),
455
+ modelValue: (a = xe(t.sku._id)) == null ? void 0 : a.value,
456
+ "onUpdate:modelValue": (s) => Ae(t.sku._id, s)
457
+ }) : (o = xe(t.sku._id)) == null ? void 0 : o.label;
458
+ },
459
+ enableSorting: !1,
460
+ meta: {
461
+ width: "120px"
462
+ }
463
+ },
464
+ {
465
+ id: "Cost",
466
+ header: () => {
467
+ var e, t;
468
+ return `Total Cost (${r(((e = k.currentCountry) == null ? void 0 : e.value) ?? he) === "MYR" ? "RM" : r(((t = k.currentCountry) == null ? void 0 : t.value) ?? he)})`;
469
+ },
470
+ cell(e) {
471
+ var o, s, c;
472
+ const t = e.row.original, a = (c = (s = (o = m.value) == null ? void 0 : o.items) == null ? void 0 : s.find) == null ? void 0 : c.call(s, (l) => l.sku._id === t.sku._id);
473
+ return G.value ? X(re.FmTextField, {
474
+ style: {
475
+ flex: "1 1 0%"
476
+ },
477
+ modelValue: +ve((a == null ? void 0 : a.totalCost) ?? { amount: 1, precision: 0 }),
478
+ "onUpdate:modelValue": (l) => {
479
+ Ee(t.sku._id, l);
480
+ },
481
+ rules: [Ua(0), Wt(2)]
482
+ }) : X(
483
+ "div",
484
+ {
485
+ style: {
486
+ display: "flex",
487
+ alignItems: "center",
488
+ gap: "4px"
489
+ }
490
+ },
491
+ [
492
+ X(
493
+ "div",
494
+ a != null && a.totalCost ? +ve((a == null ? void 0 : a.totalCost) ?? { amount: 1, precision: 0 }) : "0.00"
495
+ ),
496
+ X(
497
+ re.FmTooltip,
498
+ {
499
+ content: b.lastClosingDate ? `Last closing was already done at ${ya(b.lastClosingDate)}. You may no longer change total cost of this purchase order.` : "You may only change the total cost if you have done a closing with recent costing feature.",
500
+ placement: "left"
501
+ },
502
+ [
503
+ X(re.FmIcon, {
504
+ name: "info",
505
+ size: "sm",
506
+ color: "typo-secondary"
507
+ })
508
+ ]
509
+ )
510
+ ]
511
+ );
512
+ },
513
+ enableSorting: !1,
514
+ meta: {
515
+ width: "120px"
516
+ }
517
+ },
518
+ {
519
+ id: "Delete",
520
+ header: "",
521
+ cell(e) {
522
+ return X(re.FmButton, {
523
+ class: "delete-button",
524
+ type: "button",
525
+ icon: "delete",
526
+ variant: "tertiary",
527
+ size: "md",
528
+ onClick: () => {
529
+ Ue(Gt.Delete, e.row.original.sku._id);
530
+ }
531
+ });
532
+ },
533
+ enableSorting: !1,
534
+ meta: {
535
+ width: "40px"
536
+ }
537
+ }
538
+ ], De = U(
539
+ () => D.value ? Ce : Ce.filter((e) => e.id !== "Delete")
540
+ ), Oe = U(() => v.value === P.PURCHASE && f.enableTotalCost ? De.value : De.value.filter((e) => e.id !== "Cost")), ae = I();
541
+ ee({
542
+ validateInputs: () => {
543
+ var e, t;
544
+ (t = (e = ae.value) == null ? void 0 : e.validateInputs) == null || t.call(e);
545
+ },
546
+ resetInputsValidation: () => {
547
+ var e, t;
548
+ (t = (e = ae.value) == null ? void 0 : e.resetInputsValidation) == null || t.call(e);
549
+ },
550
+ resetInputs: () => {
551
+ var e, t;
552
+ (t = (e = ae.value) == null ? void 0 : e.resetInputs) == null || t.call(e);
553
+ }
554
+ });
555
+ const se = I(!1);
556
+ ue(se, (e) => {
557
+ e && (de.value = !0, He().finally(() => {
558
+ de.value = !1;
559
+ }));
560
+ });
561
+ async function He() {
562
+ try {
563
+ const { startDate: e, endDate: t } = va(3), s = (await w.getPurchaseOrders({ start: e, end: t })).filter(
564
+ (l) => {
565
+ var _, V;
566
+ return l.status === ra.enum.COMPLETE && ((_ = l.supplier) == null ? void 0 : _.internal) !== "warehouse" && ((V = l.supplier) == null ? void 0 : V.internal) !== "restaurant";
567
+ }
568
+ ).reduce((l, _) => {
569
+ var ne;
570
+ const V = Lt(_._id), N = _.supplier._id;
571
+ for (const E of _.items) {
572
+ if (!E.totalCost) continue;
573
+ const me = l[E.sku._id] ?? {}, x = me[N] ?? [], Y = E.measurement ? Je(E.quantity, E.measurement.conversion) : E.quantity;
574
+ x.push({
575
+ date: ((ne = V == null ? void 0 : V.toISOString) == null ? void 0 : ne.call(V)) ?? "",
576
+ pricePerUnit: {
577
+ ...It(E.totalCost, Y),
578
+ currency: E.totalCost.currency
579
+ },
580
+ totalUnits: Y,
581
+ unit: E.sku.unit
582
+ }), me[N] = x, l[E.sku._id] = me;
583
+ }
584
+ return l;
585
+ }, {}), c = Object.keys(s).reduce((l, _) => {
586
+ const V = Object.keys(s[_]);
587
+ for (const N of V) {
588
+ const E = s[_][N].reduce(
589
+ (x, Y) => {
590
+ const Ne = _a(new Date(Y.date)), J = ot(Ne);
591
+ if (x[J]) {
592
+ const be = Je(
593
+ x[J].pricePerUnit,
594
+ x[J].totalUnits
595
+ ), Ye = Je(
596
+ Y.pricePerUnit,
597
+ Y.totalUnits
598
+ ), qe = zt(
599
+ be,
600
+ Ye
601
+ ), Se = zt(x[J].totalUnits, Y.totalUnits), p = {
602
+ ...It(qe, Se),
603
+ currency: Y.pricePerUnit.currency
604
+ };
605
+ x[J].totalUnits = Se, x[J].pricePerUnit = p;
606
+ } else
607
+ x[J] = Y;
608
+ return x[J].date = Ne.toISOString(), x;
609
+ },
610
+ {}
611
+ );
612
+ l[_] ?? (l[_] = {});
613
+ const me = ga(3).map((x) => ot(x));
614
+ l[_][N] = me.map((x) => E[x] ? E[x] : {
615
+ date: x
616
+ }), Object.values(E).sort((x, Y) => Y.date.localeCompare(x.date)).slice(0, 3).reverse();
617
+ }
618
+ return l;
619
+ }, {});
620
+ le.value = c;
621
+ } catch {
622
+ _e.open({
623
+ title: "Something went wrong",
624
+ message: "Cannot retrieve supplier purchase history. Please try again."
625
+ }), se.value = !1;
626
+ }
627
+ }
628
+ const de = I(!1), le = I({});
629
+ function oe(e) {
630
+ return e.column.columnDef.meta;
631
+ }
632
+ const M = U({
633
+ get() {
634
+ var e, t;
635
+ return (e = b.modelValue) != null && e.effectiveAt ? new Date((t = b.modelValue) == null ? void 0 : t.effectiveAt) : null;
636
+ },
637
+ set(e) {
638
+ m.value.effectiveAt = (e == null ? void 0 : e.toISOString()) ?? null;
639
+ }
640
+ }), ke = U({
641
+ get() {
642
+ return !!M.value;
643
+ },
644
+ set(e) {
645
+ e ? M.value = /* @__PURE__ */ new Date() : M.value = null;
646
+ }
647
+ }), Ze = U({
648
+ get() {
649
+ return M.value === null ? "" : Qt(M.value);
650
+ },
651
+ set(e) {
652
+ e ? M.value = /* @__PURE__ */ new Date(`${e} ${et.value}`) : M.value = null;
653
+ }
654
+ }), et = U({
655
+ get() {
656
+ return M.value === null ? "" : ba(M.value);
657
+ },
658
+ set(e) {
659
+ e ? M.value = /* @__PURE__ */ new Date(`${Ze.value} ${e}`) : M.value = null;
660
+ }
661
+ }), rt = U(() => {
662
+ var e;
663
+ return (e = y._currentLocation) == null ? void 0 : e.dbName.startsWith("restaurant");
664
+ });
665
+ return (e, t) => {
666
+ const a = S("FmChip"), o = S("FmSelect"), s = S("FmMenuItem"), c = S("FmTextField"), l = S("FmTextarea"), _ = S("FmSwitch"), V = S("FmDatePicker"), N = S("FmTimePicker"), ne = S("FmFormGroup"), E = S("FmIcon"), me = S("FmButton"), x = S("FmLabel"), Y = S("FmSpacer"), Ne = S("FmTable"), J = S("FmForm");
667
+ return g(), j(J, {
668
+ ref_key: "formRef",
669
+ ref: ae,
670
+ onReset: t[10] || (t[10] = (be) => v.value = i(P).PURCHASE),
671
+ onValidationSuccess: t[11] || (t[11] = (be) => C("validation-success")),
672
+ disabled: T.value
673
+ }, {
674
+ default: O(() => {
675
+ var be, Ye, qe, Se;
676
+ return [
677
+ n("div", za, [
678
+ n("div", Qa, [
679
+ Ka,
680
+ n("div", Ga, [
681
+ d(a, {
682
+ label: i(y).currentLocation.name,
683
+ icon: "storefront",
684
+ compact: ""
685
+ }, null, 8, ["label"]),
686
+ (Ye = (be = i(k).currentRestaurant) == null ? void 0 : be.value) != null && Ye.posVersion ? (g(), j(a, {
687
+ key: 0,
688
+ label: `POS v${(Se = (qe = i(k).currentRestaurant) == null ? void 0 : qe.value) == null ? void 0 : Se.posVersion}`,
689
+ icon: "point_of_sale",
690
+ compact: ""
691
+ }, null, 8, ["label"])) : q("", !0),
692
+ e.lastClosingDate ? (g(), j(a, {
693
+ key: 1,
694
+ label: `Last closing: ${i(Qt)(e.lastClosingDate)} ${i(ha)(e.lastClosingDate)}`,
695
+ icon: "calendar_month",
696
+ compact: ""
697
+ }, null, 8, ["label"])) : q("", !0)
698
+ ]),
699
+ Wa,
700
+ n("div", Ja, [
701
+ d(o, {
702
+ items: A,
703
+ rules: [i(We)()],
704
+ "label-mark": "required",
705
+ label: "Transfer type",
706
+ modelValue: v.value,
707
+ "onUpdate:modelValue": t[0] || (t[0] = (p) => v.value = p),
708
+ disabled: T.value || !D.value,
709
+ "data-cy": "fm-select-transaction-type"
710
+ }, null, 8, ["rules", "modelValue", "disabled"]),
711
+ d(o, {
712
+ label: v.value === i(P).PURCHASE ? "Supplier" : "Transfer From",
713
+ items: $.value,
714
+ modelValue: u.value,
715
+ "onUpdate:modelValue": t[1] || (t[1] = (p) => u.value = p),
716
+ disabled: T.value || !D.value,
717
+ rules: [i(We)()],
718
+ "label-mark": "required"
719
+ }, {
720
+ "menu-wrapper": O(({ handleItemChange: p }) => [
721
+ (g(!0), F(Re, null, Be($.value, (h) => (g(), j(s, {
722
+ key: h.value,
723
+ "model-value": h.value === u.value,
724
+ disabled: h.disabled,
725
+ label: h.label,
726
+ "onUpdate:modelValue": (pe) => p(pe, h)
727
+ }, null, 8, ["model-value", "disabled", "label", "onUpdate:modelValue"]))), 128))
728
+ ]),
729
+ _: 1
730
+ }, 8, ["label", "items", "modelValue", "disabled", "rules"]),
731
+ d(c, {
732
+ label: "Reference",
733
+ modelValue: m.value.ref,
734
+ "onUpdate:modelValue": t[2] || (t[2] = (p) => m.value.ref = p),
735
+ "label-mark": "optional",
736
+ disabled: T.value || !D.value
737
+ }, null, 8, ["modelValue", "disabled"]),
738
+ d(l, {
739
+ label: "Remark",
740
+ modelValue: z.value,
741
+ "onUpdate:modelValue": t[3] || (t[3] = (p) => z.value = p),
742
+ "label-mark": "optional",
743
+ "max-length": 240,
744
+ disabled: T.value || !D.value,
745
+ "show-word-count": ""
746
+ }, null, 8, ["modelValue", "disabled"]),
747
+ i(f).enableBackdatePo ? (g(), F("div", Ba, [
748
+ n("div", Xa, [
749
+ d(_, {
750
+ modelValue: ke.value,
751
+ "onUpdate:modelValue": t[4] || (t[4] = (p) => ke.value = p),
752
+ label: "Backdate transfer",
753
+ sublabel: "Apply transfer to older date",
754
+ "label-placement": "right",
755
+ disabled: T.value || !D.value || rt.value && !e.lastClosingDate
756
+ }, null, 8, ["modelValue", "disabled"]),
757
+ Za,
758
+ ke.value ? (g(), F("div", es, [
759
+ n("div", ts, [
760
+ d(V, {
761
+ modelValue: Ze.value,
762
+ "onUpdate:modelValue": t[5] || (t[5] = (p) => Ze.value = p)
763
+ }, null, 8, ["modelValue"])
764
+ ]),
765
+ n("div", as, [
766
+ d(N, {
767
+ modelValue: et.value,
768
+ "onUpdate:modelValue": t[6] || (t[6] = (p) => et.value = p)
769
+ }, null, 8, ["modelValue"])
770
+ ])
771
+ ])) : q("", !0)
772
+ ]),
773
+ M.value ? (g(), j(ne, {
774
+ key: 0,
775
+ modelValue: M.value,
776
+ "onUpdate:modelValue": t[7] || (t[7] = (p) => M.value = p),
777
+ rules: [i(Pa)(new Date(e.lastClosingDate), /* @__PURE__ */ new Date())]
778
+ }, null, 8, ["modelValue", "rules"])) : q("", !0),
779
+ rt.value && !e.lastClosingDate ? (g(), F("div", ss, [
780
+ d(E, {
781
+ name: "error",
782
+ size: "sm",
783
+ class: "text-fm-color-typo-warning"
784
+ }),
785
+ os
786
+ ])) : q("", !0)
787
+ ])) : q("", !0)
788
+ ])
789
+ ]),
790
+ n("div", ls, [
791
+ d(ne, {
792
+ "model-value": m.value.items,
793
+ rules: [
794
+ function(h) {
795
+ return h && h.length > 0 || "Must have at least one item!";
796
+ }
797
+ ]
798
+ }, {
799
+ default: O(() => {
800
+ var p;
801
+ return [
802
+ n("div", ns, [
803
+ rs,
804
+ v.value === i(P).PURCHASE && D.value && i(f).enableTotalCost ? (g(), F("div", us, [
805
+ d(_, {
806
+ label: de.value ? "Fetching data..." : "Compare price history",
807
+ "prepend-icon": "compare_arrows",
808
+ "label-placement": "right",
809
+ "model-value": se.value,
810
+ "onUpdate:modelValue": t[8] || (t[8] = (h) => se.value = h),
811
+ disabled: de.value || !((p = m.value) != null && p.items) || m.value.items.length === 0
812
+ }, null, 8, ["label", "model-value", "disabled"])
813
+ ])) : q("", !0)
814
+ ])
815
+ ];
816
+ }),
817
+ _: 1
818
+ }, 8, ["model-value", "rules"]),
819
+ n("div", null, [
820
+ d(me, {
821
+ disabled: T.value || !D.value,
822
+ label: "Add Item",
823
+ "prepend-icon": "add",
824
+ variant: "plain",
825
+ onClick: t[9] || (t[9] = (p) => te()),
826
+ size: "md"
827
+ }, null, 8, ["disabled"])
828
+ ]),
829
+ ie.value.length ? (g(), F("div", is, [
830
+ (g(), j(Ne, {
831
+ "row-data": ie.value,
832
+ "column-defs": Oe.value,
833
+ key: v.value,
834
+ "data-cy": "fm-table-transfer-items",
835
+ "hide-footer": "",
836
+ "page-size": ie.value.length
837
+ }, {
838
+ "table-row": O((p) => {
839
+ var h, pe;
840
+ return [
841
+ n("tr", {
842
+ class: Yt(["border-b border-fm-color-neutral-gray-100 hover:bg-fm-color-opacity-sm", {
843
+ "bg-fm-color-neutral-gray-100": p.getIsSelected()
844
+ }])
845
+ }, [
846
+ (g(!0), F(Re, null, Be(p.getVisibleCells(), (B) => {
847
+ var we, fe, Ve, Fe;
848
+ return g(), F("td", {
849
+ key: B.id,
850
+ class: Yt([
851
+ "h-[52px] px-16 text-fm-color-typo-primary",
852
+ ((we = oe(B)) == null ? void 0 : we.cellClass) ?? "px-16"
853
+ ]),
854
+ style: Xt({
855
+ width: (fe = oe(B)) == null ? void 0 : fe.width,
856
+ maxWidth: (Ve = oe(B)) == null ? void 0 : Ve.maxWidth,
857
+ textAlign: ((Fe = oe(B)) == null ? void 0 : Fe.textAlign) ?? "left"
858
+ })
859
+ }, [
860
+ n("span", cs, [
861
+ d(i(Q), {
862
+ render: B.column.columnDef.cell,
863
+ props: B.getContext()
864
+ }, null, 8, ["render", "props"])
865
+ ])
866
+ ], 6);
867
+ }), 128))
868
+ ], 2),
869
+ v.value === i(P).PURCHASE && se.value && Object.keys(le.value[(h = p.original.sku) == null ? void 0 : h._id] ?? {}).length > 0 ? (g(), F("tr", ds, [
870
+ n("td", {
871
+ colspan: p.getVisibleCells().length
872
+ }, [
873
+ d(Jt, {
874
+ prices: le.value[(pe = p.original.sku) == null ? void 0 : pe._id]
875
+ }, null, 8, ["prices"])
876
+ ], 8, ms)
877
+ ])) : q("", !0)
878
+ ];
879
+ }),
880
+ "list-row": O((p) => [
881
+ d(ea, { row: p }, {
882
+ default: O((h) => {
883
+ var pe, B, we, fe, Ve, Fe, ut, it, Le, ct, dt, mt, pt, je, ft, vt, _t, gt, Ie, bt, ht, yt, xt, ze, Ct, Dt, kt, St, wt, Vt, Qe, Ft, Tt, Rt, Pt, Ut, At, Mt, $t, Ke, Et, Ot, Ht;
884
+ return [
885
+ n("div", ps, [
886
+ n("div", fs, [
887
+ n("div", vs, L(p.original.sku.name), 1),
888
+ n("div", null, [
889
+ d(i(Q), {
890
+ render: (we = (B = (pe = h.Delete) == null ? void 0 : pe.column) == null ? void 0 : B.columnDef) == null ? void 0 : we.cell,
891
+ props: (Ve = (fe = h.Delete) == null ? void 0 : fe.getContext) == null ? void 0 : Ve.call(fe)
892
+ }, null, 8, ["render", "props"])
893
+ ])
894
+ ]),
895
+ n("div", _s, [
896
+ n("div", gs, [
897
+ d(x, { label: "Code" }),
898
+ d(i(Q), {
899
+ render: (it = (ut = (Fe = h.code) == null ? void 0 : Fe.column) == null ? void 0 : ut.columnDef) == null ? void 0 : it.cell,
900
+ props: (ct = (Le = h.code) == null ? void 0 : Le.getContext) == null ? void 0 : ct.call(Le)
901
+ }, null, 8, ["render", "props"])
902
+ ]),
903
+ n("div", bs, [
904
+ d(x, { label: "Name" }),
905
+ d(i(Q), {
906
+ render: (pt = (mt = (dt = h.Name) == null ? void 0 : dt.column) == null ? void 0 : mt.columnDef) == null ? void 0 : pt.cell,
907
+ props: (ft = (je = h.Name) == null ? void 0 : je.getContext) == null ? void 0 : ft.call(je)
908
+ }, null, 8, ["render", "props"])
909
+ ]),
910
+ n("div", hs, [
911
+ d(x, { label: "Amount" }),
912
+ d(i(Q), {
913
+ render: (gt = (_t = (vt = h.Amount) == null ? void 0 : vt.column) == null ? void 0 : _t.columnDef) == null ? void 0 : gt.cell,
914
+ props: (bt = (Ie = h.Amount) == null ? void 0 : Ie.getContext) == null ? void 0 : bt.call(Ie)
915
+ }, null, 8, ["render", "props"])
916
+ ]),
917
+ n("div", ys, [
918
+ d(x, { label: "Unit" }),
919
+ d(i(Q), {
920
+ render: (xt = (yt = (ht = h.Unit) == null ? void 0 : ht.column) == null ? void 0 : yt.columnDef) == null ? void 0 : xt.cell,
921
+ props: (Ct = (ze = h.Unit) == null ? void 0 : ze.getContext) == null ? void 0 : Ct.call(ze)
922
+ }, null, 8, ["render", "props"])
923
+ ]),
924
+ v.value === i(P).PURCHASE ? (g(), F("div", xs, [
925
+ d(x, {
926
+ label: typeof ((St = (kt = (Dt = h.Cost) == null ? void 0 : Dt.column) == null ? void 0 : kt.columnDef) == null ? void 0 : St.header) == "function" ? (Tt = (Vt = (wt = h.Cost) == null ? void 0 : wt.column) == null ? void 0 : Vt.columnDef) == null ? void 0 : Tt.header(
927
+ (Ft = (Qe = h.Cost) == null ? void 0 : Qe.getContext) == null ? void 0 : Ft.call(Qe)
928
+ ) : ((Ut = (Pt = (Rt = h.Cost) == null ? void 0 : Rt.column) == null ? void 0 : Pt.columnDef) == null ? void 0 : Ut.header) ?? ""
929
+ }, null, 8, ["label"]),
930
+ d(i(Q), {
931
+ render: ($t = (Mt = (At = h.Cost) == null ? void 0 : At.column) == null ? void 0 : Mt.columnDef) == null ? void 0 : $t.cell,
932
+ props: (Et = (Ke = h.Cost) == null ? void 0 : Ke.getContext) == null ? void 0 : Et.call(Ke)
933
+ }, null, 8, ["render", "props"])
934
+ ])) : q("", !0)
935
+ ]),
936
+ v.value === i(P).PURCHASE && se.value && Object.keys(le.value[(Ot = p.original.sku) == null ? void 0 : Ot._id] ?? {}).length > 0 ? (g(), F(Re, { key: 0 }, [
937
+ d(Y, { class: "h-8" }),
938
+ d(Jt, {
939
+ prices: le.value[(Ht = p.original.sku) == null ? void 0 : Ht._id]
940
+ }, null, 8, ["prices"])
941
+ ], 64)) : q("", !0)
942
+ ])
943
+ ];
944
+ }),
945
+ _: 2
946
+ }, 1032, ["row"])
947
+ ]),
948
+ _: 1
949
+ }, 8, ["row-data", "column-defs", "page-size"]))
950
+ ])) : q("", !0)
951
+ ])
952
+ ])
953
+ ];
954
+ }),
955
+ _: 1
956
+ }, 8, ["disabled"]);
957
+ };
958
+ }
959
+ }), Ds = { class: "flex items-center" }, ks = { class: "fm-typo-en-title-md-800" }, Ss = { class: "flex gap-4" }, ws = /* @__PURE__ */ Pe({
960
+ __name: "TransferDialog",
961
+ props: {
962
+ mode: {},
963
+ modelValue: {},
964
+ show: { type: Boolean },
965
+ lastClosingDate: {}
966
+ },
967
+ emits: ["update:show", "submitted"],
968
+ setup(Z, { expose: ee, emit: K }) {
969
+ const y = Z, k = K, w = Zt(), f = nt(), b = ta(), D = ia(), G = lt();
970
+ async function C(u) {
971
+ if (u) {
972
+ T.value = !0;
973
+ try {
974
+ await b.readSuppliers(), T.value = !1;
975
+ } catch {
976
+ f.open({
977
+ title: "Unable to fetch list of suppliers",
978
+ message: "Try to refresh page to retry operation",
979
+ type: "error"
980
+ });
981
+ }
982
+ }
983
+ }
984
+ G.watchLocation(C);
985
+ const m = wa(y, "show"), z = I(y.modelValue ?? {});
986
+ ue([() => y.modelValue], () => {
987
+ z.value = y.modelValue ?? {};
988
+ });
989
+ const T = I(!1), ie = U(() => {
990
+ switch (y.mode) {
991
+ case Te.CREATE:
992
+ return "Add transfer";
993
+ case Te.READ:
994
+ return "View transfer";
995
+ case Te.UPDATE:
996
+ return "Edit transfer";
997
+ }
998
+ return "";
999
+ }), W = I();
1000
+ ee({
1001
+ validateInputs: () => {
1002
+ var u, r;
1003
+ (r = (u = W.value) == null ? void 0 : u.validateInputs) == null || r.call(u);
1004
+ },
1005
+ resetInputsValidation: () => {
1006
+ var u, r;
1007
+ (r = (u = W.value) == null ? void 0 : u.resetInputsValidation) == null || r.call(u);
1008
+ },
1009
+ resetInputs: () => {
1010
+ var u, r;
1011
+ (r = (u = W.value) == null ? void 0 : u.resetInputs) == null || r.call(u);
1012
+ }
1013
+ });
1014
+ async function A() {
1015
+ const u = z.value;
1016
+ T.value = !0, (u.supplier.internal === "warehouse" || u.supplier.internal === "restaurant") && (u.items = u.items.map(({ totalCost: r, ...R }) => R));
1017
+ try {
1018
+ await w.createPurchaseOrder(u), await new Promise((r) => setTimeout(r, 1e3)), f.open({
1019
+ title: "Created",
1020
+ message: "Your transfer draft has been created!",
1021
+ type: "success"
1022
+ }), k("update:show", !1), k("submitted");
1023
+ } catch (r) {
1024
+ f.open({
1025
+ title: "Cannot create purchase order",
1026
+ message: "Report to system administrator for troubleshooting.",
1027
+ type: "error"
1028
+ }), console.error("Error in creating purchase order", r);
1029
+ } finally {
1030
+ T.value = !1;
1031
+ }
1032
+ }
1033
+ async function v() {
1034
+ const u = z.value;
1035
+ T.value = !0, (u.supplier.internal === "warehouse" || u.supplier.internal === "restaurant") && (u.items = u.items.map(({ totalCost: r, ...R }) => R));
1036
+ try {
1037
+ await w.updatePurchaseOrder(u), await new Promise((r) => setTimeout(r, 1e3)), f.open({
1038
+ title: "Updated",
1039
+ message: "Your transfer draft has been updated!",
1040
+ type: "success"
1041
+ }), k("update:show", !1), k("submitted");
1042
+ } catch (r) {
1043
+ f.open({
1044
+ title: "Cannot update purchase order",
1045
+ message: "Report to system administrator for troubleshooting.",
1046
+ type: "error"
1047
+ }), console.error("Error in updating purchase order", r);
1048
+ } finally {
1049
+ T.value = !1;
1050
+ }
1051
+ }
1052
+ function H() {
1053
+ switch (y.mode) {
1054
+ case Te.CREATE:
1055
+ return A();
1056
+ case Te.UPDATE:
1057
+ return v();
1058
+ }
1059
+ }
1060
+ function $() {
1061
+ var u, r;
1062
+ (r = (u = W.value) == null ? void 0 : u.validateInputs) == null || r.call(u);
1063
+ }
1064
+ return (u, r) => {
1065
+ const R = S("FmButton"), _e = S("FmSideSheet");
1066
+ return g(), j(_e, {
1067
+ modelValue: i(m),
1068
+ "onUpdate:modelValue": r[2] || (r[2] = (te) => la(m) ? m.value = te : null),
1069
+ "dismiss-away": "",
1070
+ "close-button": "",
1071
+ "max-width": 900
1072
+ }, {
1073
+ "side-sheet-header": O(() => [
1074
+ n("div", Ds, [
1075
+ n("div", ks, L(ie.value), 1)
1076
+ ])
1077
+ ]),
1078
+ default: O(() => [
1079
+ (g(), j(Cs, {
1080
+ class: "w-full",
1081
+ ref_key: "formRef",
1082
+ ref: W,
1083
+ onValidationSuccess: H,
1084
+ modelValue: z.value,
1085
+ "onUpdate:modelValue": r[0] || (r[0] = (te) => z.value = te),
1086
+ disabled: T.value,
1087
+ suppliers: i(b).suppliers,
1088
+ skus: i(D).skus,
1089
+ key: z.value._id ?? "",
1090
+ "last-closing-date": u.lastClosingDate
1091
+ }, null, 8, ["modelValue", "disabled", "suppliers", "skus", "last-closing-date"]))
1092
+ ]),
1093
+ "side-sheet-footer": O(() => [
1094
+ n("div", Ss, [
1095
+ d(R, {
1096
+ loading: T.value,
1097
+ label: "Save",
1098
+ onClick: $
1099
+ }, null, 8, ["loading"]),
1100
+ d(R, {
1101
+ disabled: T.value,
1102
+ variant: "tertiary",
1103
+ label: "Close",
1104
+ onClick: r[1] || (r[1] = (te) => k("update:show", !1))
1105
+ }, null, 8, ["disabled"])
1106
+ ])
1107
+ ]),
1108
+ _: 1
1109
+ }, 8, ["modelValue"]);
1110
+ };
1111
+ }
1112
+ }), Vs = { class: "px-24 xs:p-0 sm:p-0 flex flex-col gap-8 max-h-full" }, Fs = { class: "px-8 flex gap-8 items-center xs:gap-0 xs:flex-col-reverse sm:gap-0 sm:flex-col-reverse" }, Ts = { class: "xs:w-full sm:w-full flex gap-8 items-center overflow-x-auto no-scrollbar py-8" }, Rs = { class: "flex-1 w-full" }, Ps = { class: "flex flex-col py-8" }, Us = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, As = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary line-clamp-1" }, Ms = { class: "fm-typo-en-body-md-400 text-fm-color-typo-primary line-clamp-1" }, $s = {
1113
+ key: 0,
1114
+ class: "fm-typo-en-body-md-400 text-fm-color-typo-primary line-clamp-1"
1115
+ }, Es = { class: "pt-8" }, Bt = "ReceiveRequestViewSearchCriteria", Zs = /* @__PURE__ */ Pe({
1116
+ __name: "ReceiveRequestView",
1117
+ setup(Z) {
1118
+ const ee = nt();
1119
+ Ge.object({
1120
+ name: Ge.string().optional().nullable(),
1121
+ startDate: Ge.string().optional().nullable(),
1122
+ endDate: Ge.string().optional().nullable()
1123
+ });
1124
+ const K = ca();
1125
+ function y() {
1126
+ const A = {
1127
+ name: "",
1128
+ ...Xe()
1129
+ }, v = K.getItem(Bt);
1130
+ if (!v)
1131
+ return A;
1132
+ try {
1133
+ return JSON.parse(v);
1134
+ } catch {
1135
+ return A;
1136
+ }
1137
+ }
1138
+ function k() {
1139
+ K.setItem(Bt, JSON.stringify(w.value));
1140
+ }
1141
+ const w = I(y()), f = da("receive/request", w.value), { columnDefs: b } = ma("receive/request", f), D = lt();
1142
+ async function G() {
1143
+ const A = `inventory-record_${st(w.value.startDate).format("DD-MM-YYYY_HH-mm")}-${st(w.value.endDate).format("DD-MM-YYYY_HH-mm")}.xlsx`, v = f.purchaseOrders.value.flatMap(
1144
+ (H) => H.items.map(($) => {
1145
+ const u = st(xa(H._id)).format("DD MMM YYYY"), r = ve(
1146
+ fa($.sku, H.deliveryOrder || [])
1147
+ ), R = ve($.quantity);
1148
+ return {
1149
+ "SKU Code": $.code,
1150
+ "SKU Name": $.name,
1151
+ "PO #": H.seqNumber,
1152
+ Date: u,
1153
+ Status: H.status,
1154
+ Reference: H.ref,
1155
+ "Received Quantity": r,
1156
+ "Ordered Quantity": R,
1157
+ Unit: $.sku.unit.abbrev
1158
+ };
1159
+ })
1160
+ );
1161
+ await Ca(
1162
+ [
1163
+ {
1164
+ name: "purchases",
1165
+ data: v,
1166
+ columns: [
1167
+ "SKU Code",
1168
+ "SKU Name",
1169
+ "PO #",
1170
+ "Date",
1171
+ "Status",
1172
+ "Reference",
1173
+ "Received Quantity",
1174
+ "Ordered Quantity",
1175
+ "Unit"
1176
+ ]
1177
+ }
1178
+ ],
1179
+ A
1180
+ ), ee.open({
1181
+ title: "Success",
1182
+ message: `Exported ${A}`,
1183
+ type: "success"
1184
+ });
1185
+ }
1186
+ const C = I(Xe()), m = I("");
1187
+ ue([() => C.value], ([A]) => {
1188
+ !A.startDate || !A.endDate || (w.value.startDate = A.startDate, w.value.endDate = A.endDate, f.updateDateRange(
1189
+ w.value.startDate,
1190
+ w.value.endDate
1191
+ ), k());
1192
+ }), ue([() => m.value], () => {
1193
+ k();
1194
+ });
1195
+ function z(A) {
1196
+ A === "create" && f.promptCreateTransferDialog();
1197
+ }
1198
+ const { breakpoints: T } = Va(), ie = U(() => T.value.xs || T.value.sm ? 10 : 20), W = Ra();
1199
+ return (A, v) => {
1200
+ const H = S("FmTableToolbar"), $ = S("FmTable");
1201
+ return g(), j(Da, {
1202
+ title: "Receive and Request",
1203
+ actions: [{ label: "Create transfer", value: "create", isPrimary: !0, prependIcon: "add" }],
1204
+ "onClick:action": z
1205
+ }, {
1206
+ default: O(() => {
1207
+ var u;
1208
+ return [
1209
+ n("div", Vs, [
1210
+ n("div", Fs, [
1211
+ n("div", Ts, [
1212
+ d(ka),
1213
+ d($a, {
1214
+ "model-value": C.value,
1215
+ "onUpdate:modelValue": v[0] || (v[0] = (r) => C.value = r)
1216
+ }, null, 8, ["model-value"])
1217
+ ]),
1218
+ n("div", Rs, [
1219
+ d(H, {
1220
+ searchable: "",
1221
+ "search-model": m.value,
1222
+ "onUpdate:searchModel": v[1] || (v[1] = (r) => m.value = r),
1223
+ actions: [{ label: "Export", icon: "ios_share", key: "export" }],
1224
+ "onClick:actionExport": G
1225
+ }, null, 8, ["search-model"])
1226
+ ])
1227
+ ]),
1228
+ (g(), j($, {
1229
+ style: Xt(i(W).tableHeight),
1230
+ "column-defs": i(b),
1231
+ "row-data": i(f).purchaseOrders.value,
1232
+ "search-value": m.value,
1233
+ loading: !i(D)._currentLocation || i(f).loading.value,
1234
+ onRowClick: v[2] || (v[2] = (r) => i(f).promptShowTransferDetails(r.original)),
1235
+ key: (u = i(D)._currentLocation) == null ? void 0 : u.dbName,
1236
+ "page-size": ie.value
1237
+ }, {
1238
+ "list-row": O((r) => [
1239
+ d(ea, {
1240
+ row: r,
1241
+ onRowClick: i(f).promptShowTransferDetails
1242
+ }, {
1243
+ default: O((R) => {
1244
+ var _e, te, Ue, ce, xe, Ae, Me, $e, ge, Ee, Ce, De, Oe, ae, se, He, de, le, oe, M;
1245
+ return [
1246
+ n("div", Ps, [
1247
+ n("div", Us, [
1248
+ d(i(Q), {
1249
+ render: (Ue = (te = (_e = R._id) == null ? void 0 : _e.column) == null ? void 0 : te.columnDef) == null ? void 0 : Ue.cell,
1250
+ props: (xe = (ce = R._id) == null ? void 0 : ce.getContext) == null ? void 0 : xe.call(ce)
1251
+ }, null, 8, ["render", "props"])
1252
+ ]),
1253
+ n("div", As, [
1254
+ d(i(Q), {
1255
+ render: ($e = (Me = (Ae = R.supplier_name) == null ? void 0 : Ae.column) == null ? void 0 : Me.columnDef) == null ? void 0 : $e.cell,
1256
+ props: (Ee = (ge = R.supplier_name) == null ? void 0 : ge.getContext) == null ? void 0 : Ee.call(ge)
1257
+ }, null, 8, ["render", "props"])
1258
+ ]),
1259
+ n("div", Ms, L(r.original.items.map((ke) => `${ke.name}`).join(", ")), 1),
1260
+ r.original.ref ? (g(), F("div", $s, [
1261
+ d(i(Q), {
1262
+ render: (Oe = (De = (Ce = R.ref) == null ? void 0 : Ce.column) == null ? void 0 : De.columnDef) == null ? void 0 : Oe.cell,
1263
+ props: (se = (ae = R.ref) == null ? void 0 : ae.getContext) == null ? void 0 : se.call(ae)
1264
+ }, null, 8, ["render", "props"])
1265
+ ])) : q("", !0),
1266
+ n("div", Es, [
1267
+ d(i(Q), {
1268
+ render: (le = (de = (He = R.status) == null ? void 0 : He.column) == null ? void 0 : de.columnDef) == null ? void 0 : le.cell,
1269
+ props: (M = (oe = R.status) == null ? void 0 : oe.getContext) == null ? void 0 : M.call(oe)
1270
+ }, null, 8, ["render", "props"])
1271
+ ])
1272
+ ])
1273
+ ];
1274
+ }),
1275
+ _: 2
1276
+ }, 1032, ["row", "onRowClick"])
1277
+ ]),
1278
+ _: 1
1279
+ }, 8, ["style", "column-defs", "row-data", "search-value", "loading", "page-size"]))
1280
+ ]),
1281
+ (g(), j(na, { to: "body" }, [
1282
+ d(ws, qt(i(f).transferDialogProps.value, {
1283
+ onSubmitted: i(f).fetchData
1284
+ }), null, 16, ["onSubmitted"]),
1285
+ d(pa, qt(i(f).transferDetailsProps.value, {
1286
+ onSubmitted: i(f).fetchData
1287
+ }), null, 16, ["onSubmitted"])
1288
+ ]))
1289
+ ];
1290
+ }),
1291
+ _: 1
1292
+ });
1293
+ };
1294
+ }
1295
+ });
1296
+ export {
1297
+ Zs as default
1298
+ };