@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,1733 @@
1
+ import { ref as L, defineComponent as se, computed as H, resolveComponent as V, openBlock as $, createBlock as K, withCtx as D, createElementVNode as s, normalizeClass as $e, toDisplayString as U, createVNode as y, createElementBlock as E, Fragment as ee, renderList as oe, unref as F, h as et, watch as pe, isRef as Be, createCommentVNode as J, reactive as tt, onMounted as Ye, normalizeStyle as ze, createTextVNode as we, Teleport as nt, normalizeProps as ge, mergeProps as be } from "vue";
2
+ import { _ as ot } from "./SingleColumnLayout.vue_vue_type_script_setup_true_lang-CFjO4TPG.js";
3
+ import { d as Ke, b as ae, c as Ae, u as De, e as Re, f as W, s as st, g as Ee, h as at, i as lt, C as ke } from "./app-BzDhmCVx.js";
4
+ import { useCoreStore as qe } from "@feedmepos/mf-common";
5
+ import { useSnackbar as ye, useDialog as Ge, useProxiedModel as Me, useBreakpoints as rt } from "@feedmepos/ui-library";
6
+ import { c as it, _ as ut, F as He, u as ct } from "./layout-BvUjg6JS.js";
7
+ import { g as fe } from "./decimal-D3a0BwVj.js";
8
+ import { d as dt } from "./dayjs.min-Db57WhI9.js";
9
+ import { e as mt, i as We } from "./id-to-date-ReZIpUDw.js";
10
+ import { _ as pt } from "./ChangeLocationComponent.vue_vue_type_script_setup_true_lang-DcixBOcX.js";
11
+ import { g as Fe, a as Q, b as ft, c as ve, t as ce, d as vt, e as Le, h as Xe, i as je, j as _t, f as Je, k as Ce, l as yt, m as ht, n as gt, p as bt, o as kt, q as xt } from "./date2-C7HiAWQG.js";
12
+ import { M as Ve, A as St, a as $t, R as wt } from "./rules-DHfAMDW3.js";
13
+ import { u as Ft, g as Qe } from "./use-inventory-binding-dialog-B6JO7050.js";
14
+ import { _ as Ct } from "./FmMultiselectDialog.vue_vue_type_script_setup_true_lang-BXU7x6di.js";
15
+ import { _ as Vt } from "./NumberPrecisionInput.vue_vue_type_script_setup_true_lang-DBK7mpQS.js";
16
+ import { i as Bt } from "./init-date-range-M3Q03-Fd.js";
17
+ import { E as At } from "./empty-placeholder-wf6-BWE8.js";
18
+ const he = Ke((r, c) => {
19
+ const l = ae(), n = qe(), _ = ye();
20
+ return c.onError(async (h) => {
21
+ h.name === "SvcForbiddenError" && (_ == null || _.open({
22
+ title: h.title,
23
+ message: h.message,
24
+ type: "error"
25
+ }));
26
+ }), {
27
+ async readStockBalance() {
28
+ const h = l.currentLocationDBName, u = `${r.inventoryBackendUrl}/${h}/stock-balance`;
29
+ return await c.get(u);
30
+ },
31
+ async readSkuBalance() {
32
+ var k;
33
+ const h = l.currentLocationDBName, u = `${r.inventoryBackendUrl}/${h}/sku/balance`;
34
+ return (((k = n.currentBusiness.value) == null ? void 0 : k.menuVersion) ?? "") === "v3" ? await c.get(u) : await c.get(`${u}?useInventoryDoc=true`);
35
+ },
36
+ async readSingleAdjustment(h) {
37
+ const u = l.currentLocationDBName, g = `${r.inventoryBackendUrl}/${u}/adjustment`;
38
+ return await c.get(`${g}?adjustmentId=${h}`);
39
+ },
40
+ async readStockAdjustment(h, u, g) {
41
+ const k = l.currentLocationDBName, m = `${r.inventoryBackendUrl}/${k}/sku`;
42
+ return await c.get(`${m}?skuId=${h}&start=${u}&end=${g}`);
43
+ },
44
+ async convertSku(h) {
45
+ var m;
46
+ const u = l.currentLocationDBName, g = `${r.inventoryBackendUrl}/${u}/sku/convert`;
47
+ return (((m = n.currentBusiness.value) == null ? void 0 : m.menuVersion) ?? "") === "v3" ? await c.post(g, h) : await c.post(`${g}?useInventoryDoc=true`, h);
48
+ },
49
+ async adjustSku(h) {
50
+ var m;
51
+ const u = l.currentLocationDBName, g = `${r.inventoryBackendUrl}/${u}/sku/adjust`;
52
+ return (((m = n.currentBusiness.value) == null ? void 0 : m.menuVersion) ?? "") === "v3" ? await c.post(g, h) : await c.post(`${g}?useInventoryDoc=true`, h);
53
+ }
54
+ };
55
+ });
56
+ function Dt() {
57
+ return {
58
+ stockBalance: {
59
+ _id: "",
60
+ items: []
61
+ },
62
+ productBalance: []
63
+ };
64
+ }
65
+ const de = L(Dt()), Ue = () => {
66
+ const r = he();
67
+ return {
68
+ // state
69
+ get stockBalance() {
70
+ return de.value.stockBalance;
71
+ },
72
+ set stockBalance(c) {
73
+ de.value.stockBalance = c;
74
+ },
75
+ get productBalance() {
76
+ return de.value.productBalance;
77
+ },
78
+ set productBalance(c) {
79
+ de.value.productBalance = c;
80
+ },
81
+ // actions
82
+ async readStockBalance() {
83
+ this.stockBalance = await r.readStockBalance();
84
+ },
85
+ async readProductBalance() {
86
+ this.productBalance = await r.readSkuBalance();
87
+ }
88
+ };
89
+ };
90
+ var me = /* @__PURE__ */ ((r) => (r.History = "History", r.Convert = "Convert", r.Adjust = "Adjust", r))(me || {});
91
+ const Mt = [
92
+ {
93
+ label: "History",
94
+ color: "text-neutral-700"
95
+ }
96
+ ], jt = [
97
+ {
98
+ label: "History",
99
+ color: "text-neutral-700"
100
+ },
101
+ {
102
+ label: "Convert",
103
+ color: "text-neutral-700"
104
+ },
105
+ {
106
+ label: "Adjust",
107
+ color: "text-neutral-700"
108
+ }
109
+ ];
110
+ async function Ut(r) {
111
+ const l = `${(ae().currentLocation.name || "").replace(
112
+ / /g,
113
+ "_"
114
+ )}_${dt().format("DD_MM_YYYY_HHmm")}.xlsx`;
115
+ await mt(
116
+ [
117
+ {
118
+ name: "stock",
119
+ data: r,
120
+ columns: [
121
+ {
122
+ name: "Code",
123
+ selector: "code"
124
+ },
125
+ {
126
+ name: "Name",
127
+ selector: "name"
128
+ },
129
+ {
130
+ name: "Balance",
131
+ selector: (n) => {
132
+ const _ = _e(n, n.unit);
133
+ return _.type === "unit" ? fe(n.balance, n.unit, null, !1) : fe(n.balance, n.unit, _.measurement, !1);
134
+ }
135
+ },
136
+ {
137
+ name: "Unit",
138
+ selector: (n) => {
139
+ var h;
140
+ const _ = _e(n, n.unit);
141
+ return _.type === "unit" ? n.unit.abbrev : ((h = n.unit.measurements.find((u) => u.id === _.measurement)) == null ? void 0 : h.abbrev) || "";
142
+ }
143
+ }
144
+ ]
145
+ }
146
+ ],
147
+ l
148
+ );
149
+ }
150
+ function _e(r, c) {
151
+ const l = localStorage.getItem(`uom:${r._id}`);
152
+ return l ? l === c._id ? {
153
+ type: "unit"
154
+ } : c.measurements.find((n) => n.id === l) ? {
155
+ type: "measurement",
156
+ measurement: l
157
+ } : {
158
+ type: "unit"
159
+ } : r.trackingMeasurement && c.measurements.find((n) => n.id === r.trackingMeasurement) ? {
160
+ type: "measurement",
161
+ measurement: r.trackingMeasurement
162
+ } : {
163
+ type: "unit"
164
+ };
165
+ }
166
+ const It = { class: "fm-typo-en-body-md-400 flex-grow" }, Ze = /* @__PURE__ */ se({
167
+ __name: "UnitDisplayControl",
168
+ props: {
169
+ unit: {},
170
+ sku: {},
171
+ amount: {},
172
+ defaultTrackingMeasurement: {}
173
+ },
174
+ setup(r) {
175
+ function c(m) {
176
+ return `uom:${m._id}`;
177
+ }
178
+ function l(m) {
179
+ const e = c(n.sku);
180
+ m ? localStorage.setItem(e, m) : localStorage.setItem(e, n.unit._id), _.value = _e(n.sku, n.unit);
181
+ }
182
+ const n = r, _ = L(_e(n.sku, n.unit)), h = H(() => {
183
+ const { measurements: m } = n.unit;
184
+ return [
185
+ {
186
+ label: `${fe(n.amount, n.unit)}`,
187
+ value: null
188
+ },
189
+ ...m.map(({ id: e }) => ({
190
+ label: `${fe(n.amount, n.unit, e)}`,
191
+ value: e
192
+ }))
193
+ ];
194
+ });
195
+ function u({ value: m }) {
196
+ return F(_).type === "unit" ? m === null : m === F(_).measurement;
197
+ }
198
+ const g = H(
199
+ () => {
200
+ var m;
201
+ return ((m = h.value.find((e) => u(e))) == null ? void 0 : m.label) ?? "";
202
+ }
203
+ ), k = L(!1);
204
+ return (m, e) => {
205
+ const f = V("FmIcon"), v = V("FmMenuItem"), i = V("FmMenu");
206
+ return $(), K(i, {
207
+ "stop-click-propagation": "",
208
+ onMenuChanged: e[0] || (e[0] = (a) => k.value = a)
209
+ }, {
210
+ "menu-button": D(() => [
211
+ s("button", {
212
+ type: "button",
213
+ class: $e([
214
+ "w-full text-left flex items-center gap-8 cursor-pointer fm-corner-radius-sm px-8 py-4 border bg-white",
215
+ k.value ? "border-fm-color-primary" : "border-fm-color-neutral-gray-100"
216
+ ])
217
+ }, [
218
+ s("div", It, U(g.value), 1),
219
+ y(f, {
220
+ class: "text-fm-color-neutral-gray-400",
221
+ name: "expand_more"
222
+ })
223
+ ], 2)
224
+ ]),
225
+ default: D(() => [
226
+ ($(!0), E(ee, null, oe(h.value, (a) => ($(), K(v, {
227
+ key: a.value ?? 0,
228
+ label: a.label,
229
+ "model-value": u(a),
230
+ onClick: (P) => l(a.value)
231
+ }, null, 8, ["label", "model-value", "onClick"]))), 128))
232
+ ]),
233
+ _: 1
234
+ });
235
+ };
236
+ }
237
+ });
238
+ function Tt(r) {
239
+ const c = ae(), l = Ue(), n = Ge(), _ = L();
240
+ async function h(v) {
241
+ const i = {
242
+ sku: v,
243
+ show: !0,
244
+ "onUpdate:show"(a) {
245
+ _.value.show = a;
246
+ }
247
+ };
248
+ _.value = i;
249
+ }
250
+ const u = L();
251
+ async function g(v) {
252
+ var M, b, B;
253
+ if (!!!((b = (M = v.convert) == null ? void 0 : M.inventoryBindings) != null && b.length)) {
254
+ n.open({
255
+ title: "Cannot convert stock",
256
+ message: "Stock is not convertable due to no recipe or ingredient to convert."
257
+ });
258
+ return;
259
+ }
260
+ const P = {
261
+ maxCount: ((B = l.productBalance.find(({ id: j }) => j === v._id)) == null ? void 0 : B.count) || 0,
262
+ sku: v,
263
+ show: !0,
264
+ "onUpdate:show"(j) {
265
+ u.value.show = j;
266
+ },
267
+ onSubmitted() {
268
+ r();
269
+ }
270
+ };
271
+ u.value = P;
272
+ }
273
+ const k = L();
274
+ async function m(v) {
275
+ const i = {
276
+ stock: v,
277
+ show: !0,
278
+ "onUpdate:show"(a) {
279
+ k.value.show = a;
280
+ },
281
+ onSubmitted() {
282
+ r();
283
+ }
284
+ };
285
+ k.value = i;
286
+ }
287
+ function e(v, i) {
288
+ const a = Ae(i);
289
+ switch (v) {
290
+ case me.History:
291
+ h(a);
292
+ return;
293
+ case me.Convert:
294
+ g(a);
295
+ return;
296
+ case me.Adjust:
297
+ m(a);
298
+ return;
299
+ }
300
+ }
301
+ return {
302
+ columnDefs: [
303
+ {
304
+ accessorKey: "code",
305
+ header: "Code",
306
+ enableSorting: !0,
307
+ size: 300
308
+ },
309
+ {
310
+ accessorKey: "name",
311
+ header: "Product",
312
+ enableSorting: !0,
313
+ size: "auto"
314
+ },
315
+ {
316
+ id: "UOM",
317
+ header: "Balance",
318
+ cell(v) {
319
+ const i = v.row.original, a = {
320
+ unit: i.unit,
321
+ sku: i,
322
+ amount: i.balance,
323
+ defaultTrackingMeasurement: i.trackingMeasurement ?? void 0
324
+ };
325
+ return et(Ze, a);
326
+ },
327
+ size: 180
328
+ },
329
+ {
330
+ id: "action",
331
+ cell(v) {
332
+ var i;
333
+ return it(
334
+ ((i = c._currentLocation) == null ? void 0 : i.type) === "restaurant" ? Mt : jt,
335
+ (a) => e(a, v.row.original)
336
+ );
337
+ },
338
+ enableSorting: !1,
339
+ size: 40,
340
+ meta: {
341
+ cellClass: "",
342
+ headerClass: ""
343
+ }
344
+ }
345
+ ],
346
+ stockHistoryProps: _,
347
+ convertSkuDialogProps: u,
348
+ adjustSkuDialogProps: k,
349
+ showSkuHistory: h
350
+ };
351
+ }
352
+ const Pt = {
353
+ context: null,
354
+ error: null,
355
+ isRequired(r = "This field is required") {
356
+ return `${this.context ?? ""}`.length === 0 && (this.error = r), this;
357
+ },
358
+ isString(r = "Must be a valid string") {
359
+ return this.error ? this : (typeof this.context != "string" && (this.error ?? (this.error = r)), this);
360
+ },
361
+ toInt() {
362
+ return this.error ? this : (this.context = +this.context, this);
363
+ },
364
+ isInteger(r = "Must be an integer") {
365
+ return this.error ? this : (this.toInt(), isNaN(this.context) && (this.error = r), this);
366
+ },
367
+ min(r, c) {
368
+ if (this.error) return this;
369
+ try {
370
+ typeof this.context == "number" ? +this.context < r && (this.error = c ?? `Must be at least ${r}`) : Object.prototype.hasOwnProperty.call(this.context, "length") ? +this.context.length < r && (this.error = c ?? `Must be at least ${r}`) : this.error = "Length cannot be determined";
371
+ } catch {
372
+ this.error = "Length cannot be determined";
373
+ }
374
+ return this;
375
+ },
376
+ max(r, c) {
377
+ if (this.error) return this;
378
+ try {
379
+ typeof this.context == "number" ? +this.context > r && (this.error = c ?? `Must be at most ${r}`) : "length" in this.context ? +this.context.length > r && (this.error = c ?? `Must be at most ${r}`) : this.error = "Length cannot be determined";
380
+ } catch {
381
+ this.error = "Length cannot be determined";
382
+ }
383
+ return this;
384
+ }
385
+ };
386
+ function Oe(r) {
387
+ return { ...Pt, context: r };
388
+ }
389
+ const Rt = { class: "flex items-center" }, Et = { class: "fm-typo-en-title-md-800" }, Ht = { class: "flex flex-col gap-24 w-full" }, Lt = { class: "flex flex-col gap-8" }, Ot = /* @__PURE__ */ s("div", { class: "fm-typo-en-body-lg-600" }, "Deduction summary", -1), Nt = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary flex-grow" }, Yt = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-error" }, zt = { class: "flex flex-col p-16 gap-8" }, Kt = { class: "flex flex-col gap-4" }, qt = /* @__PURE__ */ s("div", { class: "fm-typo-en-body-md-600 text-fm-color-typo-secondary bg-fm-color-neutral-gray-100 border-b py-12 px-16" }, " Ingredients ", -1), Gt = { class: "grid grid-cols-[auto_100px_100px_48px] xs:grid-cols-[auto_80px_120px_48px] gap-8 px-8 items-center" }, Wt = { class: "xs:col-span-3" }, Xt = { class: "flex gap-8" }, Jt = /* @__PURE__ */ se({
390
+ __name: "ConvertSkuDialog",
391
+ props: {
392
+ sku: {},
393
+ maxCount: {},
394
+ show: { type: Boolean }
395
+ },
396
+ emits: ["update:show", "submitted"],
397
+ setup(r, { expose: c, emit: l }) {
398
+ const n = r, _ = l, h = Ft(), u = De(), g = he(), k = ye(), m = L(0), e = L(null), f = H(() => u.skus), v = H(
399
+ () => {
400
+ var o, t;
401
+ return (((t = (o = n.sku) == null ? void 0 : o.convert) == null ? void 0 : t.inventoryBindings) ?? []).filter(
402
+ (d) => d.type === Re.enum.SKU
403
+ );
404
+ }
405
+ ), i = H({
406
+ get() {
407
+ return !!e.value;
408
+ },
409
+ set(o) {
410
+ o ? e.value = Ae(v.value) : (e.value = null, m.value = Math.min(m.value, n.maxCount ?? 0));
411
+ }
412
+ }), a = L(!1);
413
+ pe([() => n.show], ([o]) => {
414
+ o && (m.value = 0);
415
+ });
416
+ function P() {
417
+ G(n.sku, ve(m.value), e.value);
418
+ }
419
+ function M(o) {
420
+ if (e.value)
421
+ return !0;
422
+ const t = Oe(o).isInteger().max(n.maxCount ?? 0).error ?? "";
423
+ return t || !0;
424
+ }
425
+ function b(o) {
426
+ var C;
427
+ const t = (C = n.sku.convert) != null && C.measurement ? n.sku.unit.measurements.find((T) => {
428
+ var q;
429
+ return T.id === ((q = n.sku.convert) == null ? void 0 : q.measurement);
430
+ }) ?? null : null, d = Fe(n.sku.unit, t), p = vt(+o);
431
+ return Oe(p).isInteger().max(d).error ? "Precision cannot be more than " + d : !0;
432
+ }
433
+ const B = H(
434
+ () => {
435
+ var o, t;
436
+ return (o = n.sku.convert) != null && o.measurement ? (t = n.sku.unit.measurements.find((d) => {
437
+ var p;
438
+ return d.id === ((p = n.sku.convert) == null ? void 0 : p.measurement);
439
+ })) == null ? void 0 : t.abbrev : n.sku.unit.abbrev;
440
+ }
441
+ ), j = H(() => {
442
+ var d, p, x;
443
+ const o = (p = (d = n.sku.convert) == null ? void 0 : d.inventoryBindings) == null ? void 0 : p.filter((C) => C.type === "SKU");
444
+ return (x = e.value ?? o) == null ? void 0 : x.map((C) => {
445
+ var re, ie, ne, Ie, Te;
446
+ const T = u.skus.find((ue) => ue._id === C.id), q = ((re = C.measurement) == null ? void 0 : re.abbrev) ?? ((ie = T == null ? void 0 : T.unit) == null ? void 0 : ie.abbrev), te = (ne = n.sku.convert) != null && ne.measurement ? n.sku.unit.measurements.find((ue) => {
447
+ var Pe;
448
+ return ue.id === ((Pe = n.sku.convert) == null ? void 0 : Pe.measurement);
449
+ }) ?? null : null, le = Fe(n.sku.unit, te), A = b(`${m.value}`) === !0 ? Q(
450
+ ft(
451
+ C.amount,
452
+ ve(+m.value, le)
453
+ ),
454
+ !1
455
+ ) : "0", I = (Te = (Ie = e.value) == null ? void 0 : Ie.find((ue) => ue.id === (T == null ? void 0 : T._id))) == null ? void 0 : Te.amount, Z = I ? Q(I, !1) : null;
456
+ return {
457
+ sku: T,
458
+ convertAmount: Z ?? A,
459
+ abbrev: q
460
+ };
461
+ });
462
+ }), R = L();
463
+ c({
464
+ validateInputs: () => {
465
+ var o, t;
466
+ (t = (o = R.value) == null ? void 0 : o.validateInputs) == null || t.call(o);
467
+ },
468
+ resetInputsValidation: () => {
469
+ var o, t;
470
+ (t = (o = R.value) == null ? void 0 : o.resetInputsValidation) == null || t.call(o);
471
+ },
472
+ resetInputs: () => {
473
+ var o, t;
474
+ (t = (o = R.value) == null ? void 0 : o.resetInputs) == null || t.call(o);
475
+ }
476
+ });
477
+ const O = Me(n, "show");
478
+ async function G(o, t, d) {
479
+ a.value = !0;
480
+ try {
481
+ await g.convertSku({
482
+ conversions: [
483
+ {
484
+ doc: o,
485
+ amount: t,
486
+ overrides: d == null ? void 0 : d.map((p) => ({
487
+ ...p,
488
+ amount: {
489
+ ...p.amount,
490
+ amount: -1 * Math.abs(p.amount.amount)
491
+ // ensure truly negative
492
+ }
493
+ }))
494
+ }
495
+ ]
496
+ }), _("update:show", !1), _("submitted");
497
+ } catch (p) {
498
+ k.open({
499
+ title: "Something went wrong",
500
+ message: `Cannot convert ${o.name}. Please try again.`,
501
+ type: "error"
502
+ }), console.error("error at converting stock amount", o, t, p);
503
+ } finally {
504
+ a.value = !1;
505
+ }
506
+ }
507
+ function z(o, t, d) {
508
+ const p = +t;
509
+ let x = d;
510
+ t.length > 0 && isFinite(p) ? x = d.map((C) => (C.id !== o || (C.amount = ce(p)), C)) : x = d.map((C) => (C.id !== o || (C.amount = { amount: 0, precision: 0 }), C)), e.value = x;
511
+ }
512
+ function Y(o) {
513
+ const t = f.value.find((d) => d._id === o);
514
+ return t ? Qe(t.unit, !0) : [];
515
+ }
516
+ function N(o, t) {
517
+ const d = Y(o), p = d.find((x) => x.value === t) ?? d.find((x) => x.value === null);
518
+ return p ? {
519
+ ...p,
520
+ label: p.abbrev
521
+ } : null;
522
+ }
523
+ function X(o, t, d) {
524
+ let p;
525
+ if (t === null)
526
+ p = d.map((x) => (x.id !== o || (x.measurement = null), x)) ?? [];
527
+ else {
528
+ const x = f.value.find((C) => C._id === o);
529
+ p = d.map((C) => {
530
+ var T, q;
531
+ return C.id !== o || (C.measurement = (q = (T = x == null ? void 0 : x.unit) == null ? void 0 : T.measurements) == null ? void 0 : q.find((te) => te.id === t)), C;
532
+ }) ?? [];
533
+ }
534
+ e.value = p;
535
+ }
536
+ function S(o, t) {
537
+ const d = t.filter((p) => p.id !== o);
538
+ e.value = d;
539
+ }
540
+ function w() {
541
+ const o = (e.value ?? []).map((t) => ({
542
+ ...t,
543
+ type: Re.enum.SKU
544
+ }));
545
+ h.promptIngredientsBinding(
546
+ o,
547
+ (t) => e.value = t,
548
+ n.sku._id
549
+ );
550
+ }
551
+ return pe(
552
+ () => n.show,
553
+ (o) => {
554
+ o || (e.value = null, m.value = 0);
555
+ }
556
+ ), (o, t) => {
557
+ const d = V("FmTextField"), p = V("FmForm"), x = V("FmCard"), C = V("FmSwitch"), T = V("FmFormGroup"), q = V("FmSelect"), te = V("FmButton"), le = V("FmSideSheet");
558
+ return $(), K(le, {
559
+ "dismiss-away": "",
560
+ modelValue: F(O),
561
+ "onUpdate:modelValue": t[3] || (t[3] = (A) => Be(O) ? O.value = A : null),
562
+ "max-width": 500
563
+ }, {
564
+ "side-sheet-header": D(() => [
565
+ s("div", Rt, [
566
+ s("div", Et, U(`Convert ${o.sku.name}`), 1)
567
+ ])
568
+ ]),
569
+ default: D(() => [
570
+ s("div", Ht, [
571
+ y(p, {
572
+ ref_key: "formRef",
573
+ ref: R,
574
+ onValidationSuccess: P
575
+ }, {
576
+ default: D(() => [
577
+ y(d, {
578
+ disabled: a.value,
579
+ "model-value": m.value,
580
+ "onUpdate:modelValue": t[0] || (t[0] = (A) => m.value = A),
581
+ label: "Amount",
582
+ rules: [M, b, F(Ve)(0)],
583
+ "append-text": B.value,
584
+ "helper-text": e.value ? void 0 : `Max ${o.maxCount} ${B.value}`
585
+ }, null, 8, ["disabled", "model-value", "rules", "append-text", "helper-text"])
586
+ ]),
587
+ _: 1
588
+ }, 512),
589
+ y(x, {
590
+ variant: "outlined",
591
+ class: "p-16"
592
+ }, {
593
+ default: D(() => [
594
+ s("div", Lt, [
595
+ Ot,
596
+ ($(!0), E(ee, null, oe(j.value, (A) => {
597
+ var I, Z;
598
+ return $(), E("div", {
599
+ key: (I = A.sku) == null ? void 0 : I._id,
600
+ class: "flex items-center"
601
+ }, [
602
+ s("div", Nt, U((Z = A.sku) == null ? void 0 : Z.name), 1),
603
+ s("div", Yt, " -" + U(A.convertAmount) + " " + U(A.abbrev), 1)
604
+ ]);
605
+ }), 128))
606
+ ])
607
+ ]),
608
+ _: 1
609
+ }),
610
+ y(x, { variant: "outlined" }, {
611
+ default: D(() => [
612
+ s("div", zt, [
613
+ y(C, {
614
+ value: "",
615
+ modelValue: i.value,
616
+ "onUpdate:modelValue": t[1] || (t[1] = (A) => i.value = A),
617
+ label: "Override deduction",
618
+ "label-placement": "right"
619
+ }, null, 8, ["modelValue"]),
620
+ i.value ? ($(), E(ee, { key: 0 }, [
621
+ y(T, {
622
+ modelValue: e.value,
623
+ rules: [F(St)(1, "Must have at least one ingredient binding")]
624
+ }, null, 8, ["modelValue", "rules"]),
625
+ s("div", Kt, [
626
+ qt,
627
+ ($(!0), E(ee, null, oe(e.value, (A) => ($(), K(T, {
628
+ key: A.id,
629
+ disabled: a.value,
630
+ modelValue: +F(Q)(A.amount ?? { amount: 1, precision: 0 }),
631
+ rules: [
632
+ F($t)(
633
+ f.value.find((I) => I._id === A.id).unit,
634
+ A.measurement
635
+ ),
636
+ F(Ve)(0)
637
+ ]
638
+ }, {
639
+ default: D(({ invalid: I }) => {
640
+ var Z, re, ie;
641
+ return [
642
+ s("div", Gt, [
643
+ s("div", Wt, U((Z = f.value.find((ne) => ne._id === A.id)) == null ? void 0 : Z.name), 1),
644
+ y(d, {
645
+ class: "xs:col-span-2",
646
+ disabled: a.value,
647
+ modelValue: +F(Q)(
648
+ A.amount ?? { amount: 1, precision: 0 }
649
+ ),
650
+ "onUpdate:modelValue": (ne) => z(A.id, ne, e.value ?? []),
651
+ invalid: I
652
+ }, null, 8, ["disabled", "modelValue", "onUpdate:modelValue", "invalid"]),
653
+ y(q, {
654
+ disabled: a.value,
655
+ class: "translate-y-[2px]",
656
+ items: Y(A.id),
657
+ "model-value": (ie = N(A.id, (re = A.measurement) == null ? void 0 : re.id)) == null ? void 0 : ie.value,
658
+ "onUpdate:modelValue": (ne) => X(A.id, ne, e.value ?? []),
659
+ invalid: I
660
+ }, {
661
+ "helper-text": D(() => []),
662
+ _: 2
663
+ }, 1032, ["disabled", "items", "model-value", "onUpdate:modelValue", "invalid"]),
664
+ y(te, {
665
+ disabled: a.value,
666
+ type: "button",
667
+ variant: "tertiary",
668
+ icon: "delete",
669
+ onClick: (ne) => S(A.id, e.value ?? [])
670
+ }, null, 8, ["disabled", "onClick"])
671
+ ])
672
+ ];
673
+ }),
674
+ _: 2
675
+ }, 1032, ["disabled", "modelValue", "rules"]))), 128))
676
+ ]),
677
+ s("div", null, [
678
+ y(te, {
679
+ icon: "link",
680
+ label: "Link ingredient",
681
+ variant: "plain",
682
+ onClick: w
683
+ })
684
+ ])
685
+ ], 64)) : J("", !0)
686
+ ])
687
+ ]),
688
+ _: 1
689
+ })
690
+ ])
691
+ ]),
692
+ "side-sheet-footer": D(() => [
693
+ s("div", Xt, [
694
+ y(te, {
695
+ loading: a.value,
696
+ label: "Convert",
697
+ onClick: t[2] || (t[2] = (A) => {
698
+ var I, Z;
699
+ return (Z = (I = R.value) == null ? void 0 : I.validateInputs) == null ? void 0 : Z.call(I);
700
+ })
701
+ }, null, 8, ["loading"])
702
+ ])
703
+ ]),
704
+ _: 1
705
+ }, 8, ["modelValue"]);
706
+ };
707
+ }
708
+ });
709
+ function xe(r, c) {
710
+ const l = ve(r, c);
711
+ return { ...l, amount: -l.amount };
712
+ }
713
+ function Ne(r, c) {
714
+ return ve(Math.abs(r), c);
715
+ }
716
+ const Se = {
717
+ [W.enum.DAMAGE]: {
718
+ label: "Waste",
719
+ toAdjustmentAmount: xe
720
+ },
721
+ [W.enum.THEFT]: {
722
+ label: "Theft",
723
+ toAdjustmentAmount: xe
724
+ },
725
+ [W.enum.LOSE]: {
726
+ label: "Lose",
727
+ toAdjustmentAmount: xe
728
+ },
729
+ [W.enum.EXTRA]: {
730
+ label: "Extra",
731
+ toAdjustmentAmount: Ne
732
+ },
733
+ [W.enum.PURCHASE]: {
734
+ label: "Purchase",
735
+ toAdjustmentAmount: Ne
736
+ }
737
+ }, Qt = { class: "col-span-2 flex" }, Zt = { class: "fm-typo-en-body-lg-600 flex-1" }, en = /* @__PURE__ */ se({
738
+ __name: "AdjustedItemForm",
739
+ props: {
740
+ modelValue: {},
741
+ disabled: { type: Boolean }
742
+ },
743
+ emits: ["update:modelValue", "click:delete"],
744
+ setup(r, { emit: c }) {
745
+ const l = r, n = c, _ = H(
746
+ () => Object.keys(Se).map((e) => ({
747
+ label: st(e),
748
+ value: e
749
+ }))
750
+ ), h = H(() => Qe(l.modelValue.doc.unit, !0)), u = H({
751
+ get() {
752
+ return l.modelValue.type ?? W.enum.PURCHASE;
753
+ },
754
+ set(e) {
755
+ const f = {
756
+ ...l.modelValue
757
+ };
758
+ f.type = e;
759
+ const v = Le(l.modelValue.amount);
760
+ f.amount = Se[f.type].toAdjustmentAmount(
761
+ +Q(v),
762
+ v.precision
763
+ ), n("update:modelValue", f);
764
+ }
765
+ }), g = H({
766
+ get() {
767
+ const e = Le(l.modelValue.amount);
768
+ return +Q(e);
769
+ },
770
+ set(e) {
771
+ const f = {
772
+ ...l.modelValue
773
+ }, v = ce(e);
774
+ f.amount = Se[u.value].toAdjustmentAmount(
775
+ e,
776
+ v.precision
777
+ ), n("update:modelValue", f);
778
+ }
779
+ }), k = H({
780
+ get() {
781
+ var e;
782
+ return ((e = l.modelValue.measurement) == null ? void 0 : e.id) ?? null;
783
+ },
784
+ set(e) {
785
+ var v, i;
786
+ const f = {
787
+ ...l.modelValue
788
+ };
789
+ f.measurement = ((i = (v = l.modelValue.doc.unit) == null ? void 0 : v.measurements) == null ? void 0 : i.find((a) => a.id === e)) ?? null, n("update:modelValue", f);
790
+ }
791
+ }), m = H({
792
+ get() {
793
+ return l.modelValue.remark ?? "";
794
+ },
795
+ set(e) {
796
+ const f = {
797
+ ...l.modelValue
798
+ };
799
+ f.remark = e, n("update:modelValue", f);
800
+ }
801
+ });
802
+ return (e, f) => {
803
+ const v = V("FmButton"), i = V("FmSelect"), a = V("FmTextarea"), P = V("FmCard");
804
+ return $(), K(P, {
805
+ variant: "outlined",
806
+ class: "grid grid-cols-2 gap-8 p-16"
807
+ }, {
808
+ default: D(() => [
809
+ s("div", Qt, [
810
+ s("div", Zt, U(e.modelValue.doc.name), 1),
811
+ y(v, {
812
+ variant: "tertiary",
813
+ "prepend-icon": "delete",
814
+ onClick: f[0] || (f[0] = (M) => n("click:delete"))
815
+ })
816
+ ]),
817
+ y(i, {
818
+ disabled: e.disabled,
819
+ class: "col-span-2",
820
+ label: "Type",
821
+ items: _.value,
822
+ modelValue: u.value,
823
+ "onUpdate:modelValue": f[1] || (f[1] = (M) => u.value = M),
824
+ rules: [F(wt)()],
825
+ "label-mark": "required"
826
+ }, null, 8, ["disabled", "items", "modelValue", "rules"]),
827
+ y(Vt, {
828
+ disabled: e.disabled,
829
+ label: "Amount",
830
+ step: +F(Q)({
831
+ amount: 1,
832
+ precision: F(Fe)(e.modelValue.doc.unit, e.modelValue.measurement)
833
+ }),
834
+ modelValue: g.value,
835
+ "onUpdate:modelValue": f[2] || (f[2] = (M) => g.value = M),
836
+ rules: [F(Ve)(0)]
837
+ }, null, 8, ["disabled", "step", "modelValue", "rules"]),
838
+ y(i, {
839
+ disabled: e.disabled,
840
+ label: "Unit",
841
+ items: h.value,
842
+ modelValue: k.value,
843
+ "onUpdate:modelValue": f[3] || (f[3] = (M) => k.value = M)
844
+ }, null, 8, ["disabled", "items", "modelValue"]),
845
+ y(a, {
846
+ class: "col-span-2",
847
+ disabled: e.disabled,
848
+ label: "Remark",
849
+ modelValue: m.value,
850
+ "onUpdate:modelValue": f[4] || (f[4] = (M) => m.value = M),
851
+ "label-mark": "optional"
852
+ }, null, 8, ["disabled", "modelValue"])
853
+ ]),
854
+ _: 1
855
+ });
856
+ };
857
+ }
858
+ }), tn = /* @__PURE__ */ s("div", { class: "flex items-center" }, [
859
+ /* @__PURE__ */ s("div", { class: "fm-typo-en-title-md-800" }, "Adjust ingredients")
860
+ ], -1), nn = { class: "flex items-center" }, on = /* @__PURE__ */ s("div", { class: "fm-typo-en-title-sm-800 flex-1" }, "Adjusted items", -1), sn = { class: "flex gap-8" }, an = /* @__PURE__ */ se({
861
+ __name: "AdjustSkuDialog",
862
+ props: {
863
+ stock: {},
864
+ show: { type: Boolean }
865
+ },
866
+ emits: ["update:show", "submitted"],
867
+ setup(r, { expose: c, emit: l }) {
868
+ const n = r, _ = l, h = De(), u = Ge(), g = he(), k = ye(), m = L(!1);
869
+ function e() {
870
+ a(Ae(i));
871
+ }
872
+ const f = L();
873
+ c({
874
+ validateInputs: () => {
875
+ var b, B;
876
+ (B = (b = f.value) == null ? void 0 : b.validateInputs) == null || B.call(b);
877
+ },
878
+ resetInputsValidation: () => {
879
+ var b, B;
880
+ (B = (b = f.value) == null ? void 0 : b.resetInputsValidation) == null || B.call(b);
881
+ },
882
+ resetInputs: () => {
883
+ var b, B;
884
+ (B = (b = f.value) == null ? void 0 : b.resetInputs) == null || B.call(b);
885
+ }
886
+ });
887
+ const v = Me(n, "show"), i = tt({
888
+ remark: "",
889
+ adjustments: [
890
+ {
891
+ id: `sku_${(/* @__PURE__ */ new Date()).toISOString()}_${Math.random().toString(16).slice(2, 8)}`,
892
+ type: W.enum.PURCHASE,
893
+ doc: n.stock,
894
+ measurement: null,
895
+ remark: "",
896
+ amount: ce(1)
897
+ }
898
+ ]
899
+ });
900
+ pe([() => n.show], ([b]) => {
901
+ b && (i.remark = "", i.adjustments = [
902
+ {
903
+ id: `sku_${(/* @__PURE__ */ new Date()).toISOString()}_${Math.random().toString(16).slice(2, 8)}`,
904
+ type: W.enum.PURCHASE,
905
+ doc: n.stock,
906
+ measurement: null,
907
+ remark: "",
908
+ amount: ce(1)
909
+ }
910
+ ]);
911
+ });
912
+ async function a(b) {
913
+ m.value = !0;
914
+ try {
915
+ await g.adjustSku({
916
+ remark: b.remark,
917
+ adjustments: b.adjustments.map(({ doc: B, remark: j, type: R, amount: O, measurement: G }) => ({
918
+ id: B._id,
919
+ amount: O,
920
+ measurement: G,
921
+ remark: j,
922
+ doc: B,
923
+ type: R
924
+ }))
925
+ }), _("update:show", !1), _("submitted");
926
+ } catch (B) {
927
+ k.open({
928
+ title: "Something went wrong",
929
+ message: "Cannot adjust ingredients. Please try again.",
930
+ type: "error"
931
+ }), console.log("error on adjust ingredients", b, B);
932
+ } finally {
933
+ m.value = !1;
934
+ }
935
+ }
936
+ function P() {
937
+ const b = h.skus.map((j) => ({
938
+ label: j.name,
939
+ sublabel: j.code,
940
+ value: j._id
941
+ })), B = b.filter((j) => i.adjustments.find((R) => R.doc._id === j.value)).map((j) => j.value);
942
+ u.open({
943
+ title: "Select ingredients",
944
+ contentComponent: Ct,
945
+ contentComponentProps: {
946
+ items: b,
947
+ modelValue: B
948
+ },
949
+ overlay: !0,
950
+ closeButton: !0,
951
+ dismissAway: !0,
952
+ primaryActions: {
953
+ text: "Confirm",
954
+ close: !0
955
+ },
956
+ secondaryActions: {
957
+ text: "Close",
958
+ close: !0,
959
+ variant: "tertiary"
960
+ }
961
+ }).onPrimary((j) => {
962
+ i.adjustments = j.map(
963
+ (R) => i.adjustments.find((O) => O.doc._id === R) ?? {
964
+ id: `sku_${(/* @__PURE__ */ new Date()).toISOString()}_${Math.random().toString(16).slice(2, 8)}`,
965
+ type: W.enum.PURCHASE,
966
+ doc: h.skus.find((O) => O._id === R),
967
+ measurement: null,
968
+ remark: "",
969
+ amount: ce(1)
970
+ }
971
+ );
972
+ });
973
+ }
974
+ function M(b) {
975
+ i.adjustments.splice(b, 1);
976
+ }
977
+ return (b, B) => {
978
+ const j = V("FmTextarea"), R = V("FmButton"), O = V("FmForm"), G = V("FmSideSheet");
979
+ return $(), K(G, {
980
+ modelValue: F(v),
981
+ "onUpdate:modelValue": B[2] || (B[2] = (z) => Be(v) ? v.value = z : null),
982
+ "dismiss-away": "",
983
+ "max-width": 500
984
+ }, {
985
+ "side-sheet-header": D(() => [
986
+ tn
987
+ ]),
988
+ default: D(() => [
989
+ y(O, {
990
+ class: "w-full flex flex-col gap-12",
991
+ ref_key: "formRef",
992
+ ref: f,
993
+ onValidationSuccess: e
994
+ }, {
995
+ default: D(() => [
996
+ y(j, {
997
+ label: "Remark",
998
+ modelValue: i.remark,
999
+ "onUpdate:modelValue": B[0] || (B[0] = (z) => i.remark = z)
1000
+ }, null, 8, ["modelValue"]),
1001
+ s("div", nn, [
1002
+ on,
1003
+ y(R, {
1004
+ "prepend-icon": "add",
1005
+ variant: "tertiary",
1006
+ size: "md",
1007
+ onClick: P
1008
+ })
1009
+ ]),
1010
+ ($(!0), E(ee, null, oe(i.adjustments, (z, Y) => ($(), K(en, {
1011
+ key: z.id,
1012
+ modelValue: i.adjustments[Y],
1013
+ "onUpdate:modelValue": (N) => i.adjustments[Y] = N,
1014
+ "onClick:delete": (N) => M(Y)
1015
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "onClick:delete"]))), 128))
1016
+ ]),
1017
+ _: 1
1018
+ }, 512)
1019
+ ]),
1020
+ "side-sheet-footer": D(() => [
1021
+ s("div", sn, [
1022
+ y(R, {
1023
+ label: "Adjust",
1024
+ loading: m.value,
1025
+ onClick: B[1] || (B[1] = (z) => {
1026
+ var Y, N;
1027
+ return (N = (Y = f.value) == null ? void 0 : Y.validateInputs) == null ? void 0 : N.call(Y);
1028
+ })
1029
+ }, null, 8, ["loading"])
1030
+ ])
1031
+ ]),
1032
+ _: 1
1033
+ }, 8, ["modelValue"]);
1034
+ };
1035
+ }
1036
+ }), ln = Ke((r, c) => ({
1037
+ // TODO: remove once latest inventory backend has been push
1038
+ async findBillsByBusinessId(l, n, _) {
1039
+ const h = `${r.businessesBackendUrl}/${l}/reports/find-many`, u = {
1040
+ // type: TYPE.bill,
1041
+ type: "bill",
1042
+ restaurantIds: n,
1043
+ ids: _
1044
+ };
1045
+ return await c.post(h, u);
1046
+ },
1047
+ async findBillsById(l) {
1048
+ const _ = ae().currentLocationDBName, h = `${r.inventoryBackendUrl}/${_}/bill/search`, u = {
1049
+ ids: l
1050
+ };
1051
+ return await c.post(h, u);
1052
+ }
1053
+ })), rn = { class: "p-16" }, un = { class: "fm-typo-en-body-md-600 flex-grow" }, cn = { class: "flex-grow text-fm-color-typo-secondary" }, dn = {
1054
+ key: 0,
1055
+ class: "my-5"
1056
+ }, mn = { class: "text-neutral-400" }, pn = { class: "flex-grow" }, fn = { class: "flex gap-1" }, vn = { class: "flex flex-col gap-1" }, _n = {
1057
+ key: 1,
1058
+ class: "t-system text-fsecondary"
1059
+ }, yn = {
1060
+ key: 0,
1061
+ class: "shrink-0 text-fm-color-typo-secondary"
1062
+ }, hn = /* @__PURE__ */ se({
1063
+ __name: "StockRecordCard",
1064
+ props: {
1065
+ record: {},
1066
+ sku: {},
1067
+ bills: { default: () => [] }
1068
+ },
1069
+ setup(r) {
1070
+ const c = r, l = L(!1), n = L(), _ = L(null), h = H(() => _.value === null ? "unset" : l.value ? `${_.value}px` : "0px");
1071
+ Ye(() => {
1072
+ var k;
1073
+ _.value = ((k = n.value) == null ? void 0 : k.scrollHeight) || 0;
1074
+ });
1075
+ const u = H(() => {
1076
+ var i;
1077
+ const k = c.record.adjustments, m = c.sku, e = {}, v = k.flatMap((a) => {
1078
+ var P;
1079
+ return ((P = a.skus) == null ? void 0 : P.filter((M) => M.sku._id === m._id)) ?? [];
1080
+ }).flatMap((a) => a.amounts);
1081
+ for (const a of v) {
1082
+ const P = a.measurement ? Xe(a.measurement.conversion, a.amount) : a.amount;
1083
+ e[i = a.type] ?? (e[i] = { amount: 0, precision: 0 }), e[a.type] = je(P, e[a.type]);
1084
+ }
1085
+ return Object.entries(e).reduce(
1086
+ (a, [P, M]) => (a[P] = /// comment, because without it formatter makes code uglier
1087
+ `${Q(M, !1)} ${m.unit.abbrev}`, a),
1088
+ {}
1089
+ );
1090
+ }), g = H(() => c.record.adjustmentsByTime.map(({ date: k, adjustments: m }) => ({
1091
+ time: _t(new Date(k)),
1092
+ adjustments: m.flatMap(
1093
+ (e) => {
1094
+ var f, v;
1095
+ return ((v = (f = e.skus) == null ? void 0 : f.map) == null ? void 0 : v.call(f, (i) => ({
1096
+ ...i,
1097
+ ref: e.ref,
1098
+ backdateFrom: e.effectiveAt != null ? We(e._id) : null
1099
+ }))) ?? [];
1100
+ }
1101
+ ).flatMap((e) => {
1102
+ var i;
1103
+ const f = (i = c.bills.find((a) => a._id === e.ref)) == null ? void 0 : i.seqNumber, v = f ? `Bill ${f}` : "";
1104
+ return e.amounts.map((a) => {
1105
+ var P;
1106
+ return {
1107
+ amount: `${Q(a.amount, !1)} ${((P = a.measurement) == null ? void 0 : P.abbrev) ?? e.sku.unit.abbrev}`,
1108
+ backdateFrom: e.backdateFrom,
1109
+ name: a.type,
1110
+ remark: a.remark || v || "",
1111
+ cost: a.cost
1112
+ };
1113
+ });
1114
+ })
1115
+ })));
1116
+ return (k, m) => {
1117
+ const e = V("FmIcon"), f = V("FmTooltip"), v = V("FmCard");
1118
+ return $(), K(v, { variant: "outlined" }, {
1119
+ default: D(() => [
1120
+ s("div", rn, [
1121
+ s("div", {
1122
+ class: "flex items-center cursor-pointer mb-1",
1123
+ onClick: m[0] || (m[0] = (i) => l.value = !l.value)
1124
+ }, [
1125
+ s("div", un, U(k.record.date), 1),
1126
+ y(e, {
1127
+ name: l.value ? "expand_more" : "expand_less",
1128
+ color: "#777777",
1129
+ size: "md"
1130
+ }, null, 8, ["name"])
1131
+ ]),
1132
+ ($(!0), E(ee, null, oe(u.value, (i, a) => ($(), E("div", {
1133
+ key: a,
1134
+ class: "flex flex-row py-1",
1135
+ style: { "font-size": "0.8rem" }
1136
+ }, [
1137
+ s("div", cn, U(a), 1),
1138
+ s("div", {
1139
+ class: $e({
1140
+ "text-fm-color-typo-error": i.startsWith("-"),
1141
+ "text-fm-color-typo-success": !i.startsWith("-"),
1142
+ "ml-auto": !0
1143
+ })
1144
+ }, U(i), 3)
1145
+ ]))), 128)),
1146
+ s("div", {
1147
+ ref_key: "detailRef",
1148
+ ref: n,
1149
+ style: ze({
1150
+ fontSize: "0.8rem",
1151
+ maxHeight: h.value,
1152
+ overflow: "hidden",
1153
+ transition: "max-height 0.2s ease-out"
1154
+ })
1155
+ }, [
1156
+ g.value.length ? ($(), E("hr", dn)) : J("", !0),
1157
+ ($(!0), E(ee, null, oe(g.value, (i) => ($(), E("div", {
1158
+ key: i.time,
1159
+ class: "flex gap-1 w-full"
1160
+ }, [
1161
+ s("div", mn, U(i.time), 1),
1162
+ s("div", pn, [
1163
+ ($(!0), E(ee, null, oe(i.adjustments, (a) => ($(), E("div", {
1164
+ key: a.name,
1165
+ class: "flex gap-1"
1166
+ }, [
1167
+ s("div", fn, [
1168
+ we(U(a.name) + " ", 1),
1169
+ a.backdateFrom ? ($(), K(f, {
1170
+ key: 0,
1171
+ variant: "plain",
1172
+ placement: "top",
1173
+ "z-index": 50
1174
+ }, {
1175
+ content: D(() => [
1176
+ s("div", vn, " Backdate from " + U(F(Je)(new Date(a.backdateFrom))), 1)
1177
+ ]),
1178
+ default: D(() => [
1179
+ y(e, {
1180
+ name: "info",
1181
+ size: "sm",
1182
+ color: "primary"
1183
+ })
1184
+ ]),
1185
+ _: 2
1186
+ }, 1024)) : J("", !0),
1187
+ a.remark ? ($(), E("span", _n, " # " + U(a.remark), 1)) : J("", !0)
1188
+ ]),
1189
+ s("div", {
1190
+ class: $e({
1191
+ "text-fm-color-typo-error": a.amount.startsWith("-"),
1192
+ "text-fm-color-typo-success": !a.amount.startsWith("-"),
1193
+ "ml-auto": !0
1194
+ })
1195
+ }, U(a.amount), 3),
1196
+ a.cost ? ($(), E("div", yn, " (" + U(F(Ce)(a.cost, !1, a.cost.precision)) + ") ", 1)) : J("", !0)
1197
+ ]))), 128))
1198
+ ])
1199
+ ]))), 128))
1200
+ ], 4)
1201
+ ])
1202
+ ]),
1203
+ _: 1
1204
+ });
1205
+ };
1206
+ }
1207
+ });
1208
+ function gn(r, c) {
1209
+ var h;
1210
+ const l = Object.keys(W.enum).reduce(
1211
+ (u, g) => (u[g] = { amount: 0, precision: 0 }, u),
1212
+ {}
1213
+ );
1214
+ if (!c)
1215
+ return Object.entries(l).reduce(
1216
+ (u, [g]) => (u[g] = "", u),
1217
+ {}
1218
+ );
1219
+ const _ = r.flatMap((u) => {
1220
+ var g;
1221
+ return ((g = u.skus) == null ? void 0 : g.filter((k) => k.sku._id === c._id)) ?? [];
1222
+ }).flatMap((u) => u.amounts);
1223
+ for (const u of _) {
1224
+ const g = u.measurement ? Xe(u.measurement.conversion, u.amount) : u.amount;
1225
+ l[h = u.type] ?? (l[h] = { amount: 0, precision: 0 }), l[u.type] = je(g, l[u.type]);
1226
+ }
1227
+ return Object.entries(l).reduce(
1228
+ (u, [g, k]) => {
1229
+ const m = {
1230
+ ...k,
1231
+ amount: Math.abs(k.amount)
1232
+ };
1233
+ return u[g] = /// comment, because without it formatter makes code uglier
1234
+ `${Q(m, !1)} ${c.unit.abbrev}`, u;
1235
+ },
1236
+ {}
1237
+ );
1238
+ }
1239
+ Array.prototype.computeFirst = function(r) {
1240
+ const c = this.length;
1241
+ for (let l = 0; l < c; l++) {
1242
+ const n = this.at(l), _ = r(n, l, this);
1243
+ if (_ != null)
1244
+ return _;
1245
+ }
1246
+ };
1247
+ Array.prototype.computeLast = function(r) {
1248
+ const c = this.length - 1;
1249
+ for (let l = c; l >= 0; l--) {
1250
+ const n = this.at(l), _ = r(n, l, this);
1251
+ if (_ != null)
1252
+ return _;
1253
+ }
1254
+ };
1255
+ const bn = { class: "flex items-center w-full fm-typo-en-title-md-800" }, kn = { class: "flex-1 line-clamp-2" }, xn = { class: "flex flex-col gap-32 w-full h-full" }, Sn = { class: "flex items-center relative gap-4" }, $n = { class: "flex-1" }, wn = {
1256
+ key: 0,
1257
+ class: "flex-1 flex flex-col items-center gap-16"
1258
+ }, Fn = /* @__PURE__ */ s("div", { class: "fm-typo-en-body-lg-400 translate-x-4" }, "Loading...", -1), Cn = {
1259
+ key: 1,
1260
+ class: "flex flex-col gap-12"
1261
+ }, Vn = /* @__PURE__ */ s("div", { class: "pb-16" }, [
1262
+ /* @__PURE__ */ s("div", { class: "fm-typo-en-body-md-600" }, "Stock summary")
1263
+ ], -1), Bn = {
1264
+ class: "grid gap-12 fm-typo-en-body-md-400",
1265
+ style: { "grid-template-columns": "auto auto auto", "grid-auto-rows": "1fr" }
1266
+ }, An = { class: "flex flex-col gap-1" }, Dn = /* @__PURE__ */ s("div", { class: "text-fm-color-typo-secondary" }, "Total purchase", -1), Mn = { class: "font-bold" }, jn = { class: "flex flex-col gap-1" }, Un = /* @__PURE__ */ s("div", { class: "text-fm-color-typo-secondary" }, "Total sales", -1), In = { class: "font-bold" }, Tn = { class: "flex flex-col gap-1" }, Pn = /* @__PURE__ */ s("div", { class: "text-fm-color-typo-secondary" }, "Total lose", -1), Rn = { class: "font-bold" }, En = { class: "flex flex-col gap-1" }, Hn = /* @__PURE__ */ s("div", { class: "text-fm-color-typo-secondary" }, "Total request", -1), Ln = { class: "font-bold" }, On = {
1267
+ class: "flex flex-col gap-1",
1268
+ style: { "grid-column-end": "span 2" }
1269
+ }, Nn = /* @__PURE__ */ s("div", { class: "text-fm-color-typo-secondary" }, "Total receive", -1), Yn = { class: "font-bold" }, zn = { class: "flex flex-col gap-1" }, Kn = /* @__PURE__ */ s("div", { class: "text-fm-color-typo-secondary" }, "Last stock balance", -1), qn = { class: "font-bold" }, Gn = {
1270
+ key: 0,
1271
+ class: "flex flex-col gap-1"
1272
+ }, Wn = { class: "flex items-center text-fm-color-typo-secondary" }, Xn = { class: "font-bold" }, Jn = {
1273
+ key: 1,
1274
+ class: "flex flex-col gap-1"
1275
+ }, Qn = { class: "flex items-center gap-1 text-fm-color-typo-secondary" }, Zn = /* @__PURE__ */ s("div", null, "Closing value", -1), eo = /* @__PURE__ */ s("div", { class: "flex flex-col gap-1" }, " COGS are calculated by summing all inventory adjustment deductions that have a cost. ", -1), to = { class: "font-bold" }, no = /* @__PURE__ */ s("div", null, null, -1), oo = {
1276
+ key: 2,
1277
+ class: "flex-1 flex flex-col items-center gap-8"
1278
+ }, so = ["src"], ao = /* @__PURE__ */ s("div", { class: "font-bold text-lg" }, "No records found", -1), lo = /* @__PURE__ */ s("div", { class: "text-xs text-neutral-400 text-center" }, " Change your date range for different stock history. ", -1), ro = /* @__PURE__ */ se({
1279
+ __name: "StockHistory",
1280
+ props: {
1281
+ sku: {},
1282
+ show: { type: Boolean }
1283
+ },
1284
+ emits: ["update:show"],
1285
+ setup(r) {
1286
+ const c = qe(), l = Ue(), n = he(), _ = ln(), h = ae(), u = lt(), g = r, k = L(!1), m = ye(), e = L(Bt(0));
1287
+ async function f() {
1288
+ k.value = !0;
1289
+ try {
1290
+ await b(), await l.readStockBalance();
1291
+ } catch (S) {
1292
+ m.open({
1293
+ title: "Something went wrong",
1294
+ message: "Cannot fetch stock history. Please try again.",
1295
+ type: "error"
1296
+ }), console.log("failed at fetching item adjustment history", g.sku, e, S);
1297
+ } finally {
1298
+ k.value = !1;
1299
+ }
1300
+ }
1301
+ Ye(() => {
1302
+ f();
1303
+ }), pe([() => e.value, () => g.sku], () => {
1304
+ f();
1305
+ });
1306
+ const v = L([]), i = L([]), a = L(new Array());
1307
+ function P(S, w) {
1308
+ return w === "day" ? xt(S) : Je(S);
1309
+ }
1310
+ function M(S, w) {
1311
+ const o = S.reduce(
1312
+ (t, d) => {
1313
+ const p = d.effectiveAt ?? We(d._id);
1314
+ if (!p)
1315
+ return t;
1316
+ const x = P(new Date(p), w);
1317
+ return t[x] ?? (t[x] = []), t[x].push(d), t;
1318
+ },
1319
+ {}
1320
+ );
1321
+ return Object.keys(o).map((t) => ({
1322
+ date: t,
1323
+ adjustments: o[t]
1324
+ }));
1325
+ }
1326
+ async function b() {
1327
+ let S = await n.readStockAdjustment(
1328
+ g.sku._id,
1329
+ ht(new Date(e.value.startDate)).toISOString(),
1330
+ gt(new Date(e.value.endDate)).toISOString()
1331
+ );
1332
+ v.value = S;
1333
+ const w = S.filter(({ ref: o }) => o == null ? void 0 : o.startsWith("bill_")).map(({ ref: o }) => o);
1334
+ await B(w), i.value = M(S, "day").map(({ date: o, adjustments: t }) => ({
1335
+ date: o,
1336
+ adjustments: t,
1337
+ adjustmentsByTime: M(t, "minute")
1338
+ }));
1339
+ }
1340
+ async function B(S) {
1341
+ S.length && (a.value = await _.findBillsById(S).catch((w) => {
1342
+ var d;
1343
+ console.error("Error on using latest bill API, retrying using legacy api", w);
1344
+ const o = ((d = c.currentBusiness.value) == null ? void 0 : d._id) ?? "", t = h.currentLocation.doc._id;
1345
+ return _.findBillsByBusinessId(o, [t], S);
1346
+ }));
1347
+ }
1348
+ const j = H(() => {
1349
+ const S = v.value, w = g.sku;
1350
+ return gn(S, w);
1351
+ }), R = H(() => {
1352
+ const S = [...v.value].reverse().computeFirst((o) => {
1353
+ var d, p;
1354
+ const t = (p = (d = o.skus) == null ? void 0 : d.find) == null ? void 0 : p.call(d, (x) => x.sku._id === g.sku._id);
1355
+ return t == null ? void 0 : t.toBalance;
1356
+ }) ?? {
1357
+ amount: 0,
1358
+ precision: 0
1359
+ }, w = g.sku;
1360
+ return w ? `${Q(S, !1)} ${w.unit.abbrev}` : "";
1361
+ });
1362
+ function O(S) {
1363
+ switch (S) {
1364
+ case ke.MY:
1365
+ return "MYR";
1366
+ case ke.SG:
1367
+ return "SGD";
1368
+ case ke.ID:
1369
+ return "IDR";
1370
+ default:
1371
+ return "MYR";
1372
+ }
1373
+ }
1374
+ const G = H(() => {
1375
+ var o;
1376
+ const w = v.value.flatMap((t) => {
1377
+ var d;
1378
+ return ((d = t.skus) == null ? void 0 : d.flatMap((p) => p.amounts)) ?? [];
1379
+ }).filter(
1380
+ (t) => t.type !== W.enum.RECEIVE && t.type !== W.enum.PURCHASE && t.type !== W.enum.EXTRA
1381
+ ).reduce(
1382
+ (t, d) => {
1383
+ const p = d.cost;
1384
+ if (!p) return t;
1385
+ const x = {
1386
+ ...yt(t, Math.max(t.precision, p.precision)),
1387
+ currency: p.currency
1388
+ };
1389
+ return {
1390
+ ...je(x, p),
1391
+ currency: t.currency
1392
+ };
1393
+ },
1394
+ {
1395
+ amount: 0,
1396
+ precision: 0,
1397
+ currency: O(((o = c.currentCountry) == null ? void 0 : o.value) ?? Ee)
1398
+ }
1399
+ );
1400
+ return Ce(w);
1401
+ });
1402
+ function z() {
1403
+ const { startDate: S, endDate: w } = bt(e.value);
1404
+ S !== null && w !== null && (e.value = {
1405
+ startDate: S,
1406
+ endDate: w
1407
+ });
1408
+ }
1409
+ const Y = H(() => {
1410
+ var o;
1411
+ const S = [...v.value].reverse().computeFirst((t) => {
1412
+ var p, x;
1413
+ const d = (x = (p = t.skus) == null ? void 0 : p.find) == null ? void 0 : x.call(p, (C) => C.sku._id === g.sku._id);
1414
+ return d == null ? void 0 : d.toCostBalances;
1415
+ });
1416
+ return S ? S.reduce(
1417
+ (t, d) => at.DineroFactory(t).convertPrecision(Math.max(t.precision, d.cost.precision)).add(d.cost).toObject(),
1418
+ {
1419
+ amount: 0,
1420
+ precision: 0,
1421
+ currency: O(((o = c.currentCountry) == null ? void 0 : o.value) ?? Ee)
1422
+ }
1423
+ ) : "No data";
1424
+ });
1425
+ function N() {
1426
+ const { startDate: S, endDate: w } = kt(e.value);
1427
+ S !== null && w !== null && (e.value = {
1428
+ startDate: S,
1429
+ endDate: w
1430
+ });
1431
+ }
1432
+ const X = Me(g, "show");
1433
+ return (S, w) => {
1434
+ const o = V("FmButton"), t = V("FmField"), d = V("FmDateRangePicker"), p = V("FmSpacer"), x = V("FmCircularProgress"), C = V("FmIcon"), T = V("FmTooltip"), q = V("FmCardSection"), te = V("FmCard"), le = V("FmSideSheet");
1435
+ return $(), K(le, {
1436
+ "dismiss-away": "",
1437
+ modelValue: F(X),
1438
+ "onUpdate:modelValue": w[4] || (w[4] = (A) => Be(X) ? X.value = A : null),
1439
+ "close-button": !1,
1440
+ "max-width": 500
1441
+ }, {
1442
+ "side-sheet-header": D(() => [
1443
+ s("div", bn, [
1444
+ s("div", kn, U(S.sku.name) + " history", 1),
1445
+ y(o, {
1446
+ variant: "tertiary",
1447
+ "prepend-icon": "close",
1448
+ onClick: w[0] || (w[0] = (A) => X.value = !1)
1449
+ })
1450
+ ])
1451
+ ]),
1452
+ default: D(() => {
1453
+ var A;
1454
+ return [
1455
+ s("div", xn, [
1456
+ s("div", Sn, [
1457
+ s("div", $n, [
1458
+ y(d, {
1459
+ modelValue: e.value,
1460
+ "onUpdate:modelValue": w[1] || (w[1] = (I) => e.value = I),
1461
+ "show-predefined-range": "",
1462
+ "start-label": "",
1463
+ "end-label": ""
1464
+ }, {
1465
+ "trigger-button": D(({ opened: I }) => [
1466
+ y(t, {
1467
+ "prepend-icon": "calendar_month",
1468
+ focused: I
1469
+ }, {
1470
+ default: D(() => [
1471
+ we(U(e.value.startDate) + " - " + U(e.value.endDate), 1)
1472
+ ]),
1473
+ _: 2
1474
+ }, 1032, ["focused"])
1475
+ ]),
1476
+ _: 1
1477
+ }, 8, ["modelValue"])
1478
+ ]),
1479
+ y(o, {
1480
+ variant: "tertiary",
1481
+ onClick: w[2] || (w[2] = (I) => z()),
1482
+ "prepend-icon": "navigate_before"
1483
+ }),
1484
+ y(o, {
1485
+ variant: "tertiary",
1486
+ onClick: w[3] || (w[3] = (I) => N()),
1487
+ "prepend-icon": "navigate_next"
1488
+ })
1489
+ ]),
1490
+ k.value ? ($(), E("div", wn, [
1491
+ y(p),
1492
+ y(x, { size: "xl" }),
1493
+ Fn,
1494
+ y(p),
1495
+ y(p)
1496
+ ])) : i.value && ((A = i.value) == null ? void 0 : A.length) > 0 ? ($(), E("div", Cn, [
1497
+ y(te, { variant: "outlined" }, {
1498
+ default: D(() => [
1499
+ y(q, null, {
1500
+ default: D(() => [
1501
+ Vn,
1502
+ s("div", Bn, [
1503
+ s("div", An, [
1504
+ Dn,
1505
+ s("div", Mn, U(j.value.PURCHASE), 1)
1506
+ ]),
1507
+ s("div", jn, [
1508
+ Un,
1509
+ s("div", In, U(j.value.SALES), 1)
1510
+ ]),
1511
+ s("div", Tn, [
1512
+ Pn,
1513
+ s("div", Rn, U(j.value.LOSE), 1)
1514
+ ]),
1515
+ s("div", En, [
1516
+ Hn,
1517
+ s("div", Ln, U(j.value.REQUEST), 1)
1518
+ ]),
1519
+ s("div", On, [
1520
+ Nn,
1521
+ s("div", Yn, U(j.value.RECEIVE), 1)
1522
+ ]),
1523
+ s("div", zn, [
1524
+ Kn,
1525
+ s("div", qn, U(R.value), 1)
1526
+ ]),
1527
+ F(u).enableTotalCost ? ($(), E("div", Gn, [
1528
+ s("div", Wn, [
1529
+ we(" Estimated value  "),
1530
+ y(T, {
1531
+ variant: "plain",
1532
+ placement: "top",
1533
+ content: "Estimated value is calculated starting from last closing value.",
1534
+ "z-index": 50
1535
+ }, {
1536
+ default: D(() => [
1537
+ y(C, {
1538
+ name: "help",
1539
+ size: "sm"
1540
+ })
1541
+ ]),
1542
+ _: 1
1543
+ })
1544
+ ]),
1545
+ s("div", Xn, U(typeof Y.value != "string" ? F(Ce)(Y.value) : Y.value), 1)
1546
+ ])) : J("", !0),
1547
+ F(u).enableTotalCost ? ($(), E("div", Jn, [
1548
+ s("div", Qn, [
1549
+ Zn,
1550
+ y(T, {
1551
+ variant: "plain",
1552
+ placement: "left",
1553
+ "z-index": 50
1554
+ }, {
1555
+ content: D(() => [
1556
+ eo
1557
+ ]),
1558
+ default: D(() => [
1559
+ y(C, {
1560
+ name: "help",
1561
+ size: "sm"
1562
+ })
1563
+ ]),
1564
+ _: 1
1565
+ })
1566
+ ]),
1567
+ s("div", to, U(G.value), 1)
1568
+ ])) : J("", !0)
1569
+ ])
1570
+ ]),
1571
+ _: 1
1572
+ })
1573
+ ]),
1574
+ _: 1
1575
+ }),
1576
+ no,
1577
+ ($(!0), E(ee, null, oe(i.value, (I) => ($(), E(ee, {
1578
+ key: I.date
1579
+ }, [
1580
+ S.sku ? ($(), K(hn, {
1581
+ key: 0,
1582
+ record: I,
1583
+ sku: S.sku,
1584
+ bills: a.value
1585
+ }, null, 8, ["record", "sku", "bills"])) : J("", !0)
1586
+ ], 64))), 128))
1587
+ ])) : ($(), E("div", oo, [
1588
+ y(p),
1589
+ s("div", null, [
1590
+ s("img", {
1591
+ src: F(At),
1592
+ alt: "List is empty"
1593
+ }, null, 8, so)
1594
+ ]),
1595
+ ao,
1596
+ lo,
1597
+ y(p),
1598
+ y(p)
1599
+ ]))
1600
+ ])
1601
+ ];
1602
+ }),
1603
+ _: 1
1604
+ }, 8, ["modelValue"]);
1605
+ };
1606
+ }
1607
+ }), io = { class: "px-24 xs:p-0 sm:p-0 flex flex-col gap-8 h-full" }, uo = { class: "px-8 flex gap-8 items-center xs:gap-0 xs:flex-col-reverse sm:gap-0 sm:flex-col-reverse h-48" }, co = { class: "xs:w-full sm:w-full flex gap-8 items-center overflow-x-auto no-scrollbar py-8" }, mo = { class: "flex-1 w-full" }, po = { class: "flex flex-col gap-8" }, fo = { class: "flex flex-col" }, vo = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, _o = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary line-clamp-1" }, Uo = /* @__PURE__ */ se({
1608
+ __name: "StockView",
1609
+ setup(r) {
1610
+ const c = De(), l = ae(), n = Ue(), {
1611
+ columnDefs: _,
1612
+ stockHistoryProps: h,
1613
+ convertSkuDialogProps: u,
1614
+ adjustSkuDialogProps: g,
1615
+ showSkuHistory: k
1616
+ } = Tt(e);
1617
+ l.watchLocation(e);
1618
+ const m = L(!1);
1619
+ async function e() {
1620
+ if (l._currentLocation) {
1621
+ m.value = !0;
1622
+ try {
1623
+ await n.readStockBalance(), await n.readProductBalance();
1624
+ } finally {
1625
+ m.value = !1;
1626
+ }
1627
+ }
1628
+ }
1629
+ const f = H(
1630
+ () => c.skus.map((M) => {
1631
+ var R, O, G;
1632
+ const b = M.trackingMeasurement;
1633
+ let B = (O = (R = n.stockBalance.skus) == null ? void 0 : R.find(
1634
+ (z) => z.id === M._id
1635
+ )) == null ? void 0 : O.balance;
1636
+ return {
1637
+ ...M,
1638
+ balance: B ?? {
1639
+ amount: 0,
1640
+ precision: 0
1641
+ },
1642
+ trackingUnitAbbrev: b ? ((G = M.unit.measurements.find((z) => z.id === b)) == null ? void 0 : G.abbrev) ?? "" : M.unit.abbrev
1643
+ };
1644
+ })
1645
+ ), v = L(""), { breakpoints: i } = rt(), a = H(() => i.value.xs || i.value.sm ? 10 : 20), P = ct();
1646
+ return (M, b) => {
1647
+ const B = V("FmTableToolbar"), j = V("FmMenuDivider"), R = V("FmTable");
1648
+ return $(), K(ot, { title: "Stock" }, {
1649
+ default: D(() => {
1650
+ var O, G, z, Y;
1651
+ return [
1652
+ s("div", io, [
1653
+ s("div", uo, [
1654
+ s("div", co, [
1655
+ y(pt)
1656
+ ]),
1657
+ s("div", mo, [
1658
+ y(B, {
1659
+ searchable: "",
1660
+ "search-model": v.value,
1661
+ "onUpdate:searchModel": b[0] || (b[0] = (N) => v.value = N),
1662
+ actions: [{ label: "Export", icon: "ios_share", key: "export" }],
1663
+ "onClick:actionExport": b[1] || (b[1] = (N) => F(Ut)(f.value))
1664
+ }, null, 8, ["search-model"]),
1665
+ y(j, { class: "hidden xs:block" })
1666
+ ])
1667
+ ]),
1668
+ ($(), K(R, {
1669
+ style: ze(F(P).tableHeight),
1670
+ "column-defs": F(_),
1671
+ "row-data": f.value,
1672
+ "search-value": v.value,
1673
+ loading: m.value || !F(l)._currentLocation,
1674
+ key: (O = F(l)._currentLocation) == null ? void 0 : O.dbName,
1675
+ onRowClick: b[2] || (b[2] = (N) => F(k)(N.original)),
1676
+ "page-size": a.value
1677
+ }, {
1678
+ "list-row": D((N) => [
1679
+ y(ut, {
1680
+ row: N,
1681
+ onRowClick: F(k)
1682
+ }, {
1683
+ default: D((X) => {
1684
+ var S, w, o, t, d, p, x, C, T, q;
1685
+ return [
1686
+ s("div", po, [
1687
+ s("div", fo, [
1688
+ s("div", vo, [
1689
+ y(F(He), {
1690
+ render: (o = (w = (S = X.code) == null ? void 0 : S.column) == null ? void 0 : w.columnDef) == null ? void 0 : o.cell,
1691
+ props: (d = (t = X.code) == null ? void 0 : t.getContext) == null ? void 0 : d.call(t)
1692
+ }, null, 8, ["render", "props"])
1693
+ ]),
1694
+ s("div", _o, [
1695
+ y(F(He), {
1696
+ render: (C = (x = (p = X.name) == null ? void 0 : p.column) == null ? void 0 : x.columnDef) == null ? void 0 : C.cell,
1697
+ props: (q = (T = X.name) == null ? void 0 : T.getContext) == null ? void 0 : q.call(T)
1698
+ }, null, 8, ["render", "props"])
1699
+ ])
1700
+ ]),
1701
+ s("div", null, [
1702
+ y(Ze, {
1703
+ class: "xs:w-[160px]",
1704
+ unit: N.original.unit,
1705
+ sku: N.original,
1706
+ amount: N.original.balance,
1707
+ "default-tracking-measurement": N.original.trackingMeasurement ?? void 0
1708
+ }, null, 8, ["unit", "sku", "amount", "default-tracking-measurement"])
1709
+ ])
1710
+ ])
1711
+ ];
1712
+ }),
1713
+ _: 2
1714
+ }, 1032, ["row", "onRowClick"])
1715
+ ]),
1716
+ _: 1
1717
+ }, 8, ["style", "column-defs", "row-data", "search-value", "loading", "page-size"]))
1718
+ ]),
1719
+ ($(), K(nt, { to: "body" }, [
1720
+ (G = F(h)) != null && G.sku ? ($(), K(ro, ge(be({ key: 0 }, F(h))), null, 16)) : J("", !0),
1721
+ (z = F(u)) != null && z.sku ? ($(), K(Jt, ge(be({ key: 1 }, F(u))), null, 16)) : J("", !0),
1722
+ (Y = F(g)) != null && Y.stock ? ($(), K(an, ge(be({ key: 2 }, F(g))), null, 16)) : J("", !0)
1723
+ ]))
1724
+ ];
1725
+ }),
1726
+ _: 1
1727
+ });
1728
+ };
1729
+ }
1730
+ });
1731
+ export {
1732
+ Uo as default
1733
+ };