@feedmepos/mf-inventory-portal 1.8.0-dev.0 → 1.8.0-dev.10

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 (247) hide show
  1. package/dist/App-BjFIh5km.js +1466 -0
  2. package/dist/{ApprovalView-BK6E_3Cw.js → ApprovalView-CauRuf64.js} +26 -25
  3. package/dist/{BindingsDialog-BAVPQ_Eq.js → BindingsDialog-U-tzIfGX.js} +2 -2
  4. package/dist/{BindingsPicker-bAuDX7Af.js → BindingsPicker-CV_oghtz.js} +2 -2
  5. package/dist/{BindingsTable-LGlvV0lt.js → BindingsTable-TKSQxAxV.js} +4 -4
  6. package/dist/{BulkReceiveRequestView-CQf7FYos.js → BulkReceiveRequestView-Cyeq26qc.js} +21 -21
  7. package/dist/ChangeLocationComponent.vue_vue_type_script_setup_true_lang-BpJhboKU.js +151 -0
  8. package/dist/{ClosingDraftView-DH7iYiE9.js → ClosingDraftView-UqeHsxyJ.js} +748 -746
  9. package/dist/ClosingHistoryView-Cr6cQq6j.js +769 -0
  10. package/dist/{ClosingTemplateView-D532GNTn.js → ClosingTemplateView-DZ0Mdc87.js} +303 -291
  11. package/dist/{CustomPrintTemplatePreview.vue_vue_type_script_setup_true_lang-CvqZGcvX.js → CustomPrintTemplatePreview.vue_vue_type_script_setup_true_lang-C-OsCTxZ.js} +1 -1
  12. package/dist/{DefaultView-DqqXJVba.js → DefaultView-DQKHG5Jl.js} +2 -2
  13. package/dist/{DeliveryOrderPrintPreview-DkHNDEKP.js → DeliveryOrderPrintPreview-Z_kBbMMO.js} +2 -2
  14. package/dist/{EmailDialog.vue_vue_type_script_setup_true_lang-Cyj3ka37.js → EmailDialog.vue_vue_type_script_setup_true_lang-Ce6Ly9pT.js} +6228 -6216
  15. package/dist/FeatureCapabilityBadge.vue_vue_type_script_setup_true_lang-BUYI8koH.js +47 -0
  16. package/dist/FeatureCapabilityGate-DOn2IVJb.js +74 -0
  17. package/dist/{FmDateRangePickerChip.vue_vue_type_script_setup_true_lang-BCuhx2cN.js → FmDateRangePickerChip.vue_vue_type_script_setup_true_lang-BJuo4lEh.js} +1 -1
  18. package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-CDNqm_9N.js → FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-DZxz5hbo.js} +2 -2
  19. package/dist/FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-CiBhz5sq.js +120 -0
  20. package/dist/FmMultiselectDialog-Bx9cLdYs.js +123 -0
  21. package/dist/{FmMultiselectDialog-eH3nO3P3.js → FmMultiselectDialog-DvaWLGY5.js} +2 -2
  22. package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-BCIkEl75.js → FmUnitInput.vue_vue_type_script_setup_true_lang-D6f1M96D.js} +72 -73
  23. package/dist/ImportView-1-cjN7ay.js +1290 -0
  24. package/dist/{IngredientsView-DtDtzaMt.js → IngredientsView-JfKlUU2E.js} +656 -649
  25. package/dist/{IntegrationExplorerView-C4lYc_LH.js → IntegrationExplorerView-uElgWH8i.js} +602 -614
  26. package/dist/IntegrationPlatformView-g2dU5SG6.js +13061 -0
  27. package/dist/{IntegrationView-Bx5VdV5l.js → IntegrationView-B9g888K4.js} +2956 -2922
  28. package/dist/{InventoryBindingForm-DKa1DwYs.js → InventoryBindingForm-DfGOKZWg.js} +1 -1
  29. package/dist/InventoryBindingForm.vue_vue_type_script_setup_true_lang-CNjTdNL7.js +472 -0
  30. package/dist/{InventoryBindingSummary-CNqwcsrX.js → InventoryBindingSummary-CSii8B2X.js} +1 -1
  31. package/dist/JsonViewer.vue_vue_type_script_setup_true_lang-C_hg75l0.js +25 -0
  32. package/dist/NumberPrecisionInput.vue_vue_type_script_setup_true_lang-D_Xk4SOH.js +79 -0
  33. package/dist/PlanTierBadge.vue_vue_type_script_setup_true_lang-DJvfMOND.js +274 -0
  34. package/dist/PlanUpgradeDialog.vue_vue_type_script_setup_true_lang-Bdjm0Y4w.js +79 -0
  35. package/dist/ProductionRunDetailView-HgH2Wp99.js +2312 -0
  36. package/dist/{production-run-prepare-sheet-aQOcxgaC.js → ProductionRunLifecycleDialogs.vue_vue_type_script_setup_true_lang-C88pjV2s.js} +11039 -3661
  37. package/dist/ProductionRunView-BkvQHeCP.js +931 -0
  38. package/dist/{PublishView-D0oSoJ5a.js → PublishView-CIei_T5e.js} +3 -3
  39. package/dist/{PurchaseOrderPrintPreview-CE-l4mvB.js → PurchaseOrderPrintPreview-Wmv7676h.js} +2 -2
  40. package/dist/{ReceiveRequestView-B2z8Ji0e.js → ReceiveRequestView-MqOIpIDB.js} +15 -15
  41. package/dist/RecipeView-WzXJX4JU.js +3440 -0
  42. package/dist/SettingsView-1YlgjyzB.js +1032 -0
  43. package/dist/StockView-C-dIRXPv.js +2651 -0
  44. package/dist/{SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-BTh5E4Tt.js → SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-CewKTZzy.js} +1 -1
  45. package/dist/{SupplierView-qqhUQ-SY.js → SupplierView-53rHhQ63.js} +577 -571
  46. package/dist/{SurchargeView-B0TYUfqY.js → SurchargeView-DuJb5EUn.js} +7 -7
  47. package/dist/{SystemTrailDialog.vue_vue_type_script_setup_true_lang-tfMHi9Yv.js → SystemTrailDialog.vue_vue_type_script_setup_true_lang-C_YmC-ZX.js} +2 -2
  48. package/dist/TableActionableRow.vue_vue_type_script_setup_true_lang-gJQQKKAC.js +71 -0
  49. package/dist/{TemplatePublishDialog.vue_vue_type_script_setup_true_lang-Dxc-jNte.js → TemplatePublishDialog.vue_vue_type_script_setup_true_lang-CyQujMzv.js} +1 -1
  50. package/dist/{TransferDetails.vue_vue_type_script_setup_true_lang-BX36zWMb.js → TransferDetails.vue_vue_type_script_setup_true_lang-CMwqjlb0.js} +1722 -1672
  51. package/dist/TransferTemplateView-B6OGfKQr.js +2343 -0
  52. package/dist/{UnitCostHistoryView-xdRSkjD7.js → UnitCostHistoryView-BVlq4BNG.js} +4 -4
  53. package/dist/{UnitDisplayControl.vue_vue_type_script_setup_true_lang-BT2v1gZv.js → UnitDisplayControl.vue_vue_type_script_setup_true_lang-CULJEeCU.js} +4 -4
  54. package/dist/{UnitView-p-V_TMMo.js → UnitView-AuIJokVF.js} +84 -84
  55. package/dist/{WarehouseView-BOGYcUHH.js → WarehouseView-Cjv8S1ov.js} +194 -189
  56. package/dist/{WastageTemplateView-CiifZMq6.js → WastageTemplateView-mxSTzVSZ.js} +19 -18
  57. package/dist/api/bill.d.ts +144 -88
  58. package/dist/api/feature-flags.d.ts +12 -0
  59. package/dist/api/food-market-hub.d.ts +2 -2
  60. package/dist/api/integration-sync-log.d.ts +0 -13
  61. package/dist/api/inventory.d.ts +9 -9
  62. package/dist/api/license.d.ts +8 -0
  63. package/dist/{app-CGcDbrt8.js → app-OztWApio.js} +27841 -28064
  64. package/dist/app.d.ts +36 -150
  65. package/dist/app.js +1 -1
  66. package/dist/{closing-template-B4lQetjU.js → closing-template-DIxXDgZQ.js} +1 -1
  67. package/dist/components/ChangeLocationComponent.vue.d.ts +21 -14
  68. package/dist/components/DeprecateSoonWarningDialog.vue.d.ts +22 -0
  69. package/dist/components/FeatureCapabilityBadge.vue.d.ts +29 -0
  70. package/dist/components/FeatureCapabilityGate.vue.d.ts +29 -0
  71. package/dist/components/FmUnitInputRules.d.ts +1 -1
  72. package/dist/components/MultiLocationSelector.vue.d.ts +6 -6
  73. package/dist/components/{PreviewBadge.vue.d.ts → PlanTierBadge.vue.d.ts} +5 -13
  74. package/dist/components/PlanUpgradeDialog.vue.d.ts +30 -0
  75. package/dist/composable/useNavigationMenu.d.ts +2 -1
  76. package/dist/{date2-CHOcS7LX.js → date2-BTzYzk-x.js} +1 -1
  77. package/dist/{dayjs.min-DrqpmBJQ.js → dayjs.min-BIg6CfC4.js} +1 -1
  78. package/dist/{decimal-BJ-B2ZXz.js → decimal-B34w3X7O.js} +2 -2
  79. package/dist/{defineDeepModel-DLlTW3xL.js → defineDeepModel-CrZAv12u.js} +1 -1
  80. package/dist/{duplicate-template-Dyz7iXqd.js → duplicate-template-BKVPhi40.js} +1 -1
  81. package/dist/{inventory-core-dart.default-DGI40oFz.js → feature-BUVZ_ab3.js} +766 -398
  82. package/dist/feature-flags/core.d.ts +28 -0
  83. package/dist/feature-flags/navigation-capabilities.d.ts +23 -0
  84. package/dist/feature-flags/navigation-capabilities.spec.d.ts +1 -0
  85. package/dist/feature-flags/plan-tier.d.ts +6 -0
  86. package/dist/feature-flags/plan-tier.spec.d.ts +1 -0
  87. package/dist/feature-flags/portal-feature-catalog.d.ts +19 -0
  88. package/dist/feature-flags/portal-feature-catalog.spec.d.ts +1 -0
  89. package/dist/feature-flags/vue.d.ts +16 -0
  90. package/dist/feature-flags/vue.spec.d.ts +1 -0
  91. package/dist/{format-time-from-id-DBFdt14U.js → format-time-from-id-DGLxhRFH.js} +1 -1
  92. package/dist/{format-unit-display-BXCWhtXb.js → format-unit-display-BhudItCc.js} +118 -119
  93. package/dist/helper/menu-usage-module.d.ts +1 -1
  94. package/dist/helper/number.d.ts +5 -1
  95. package/dist/helper/rules.d.ts +1 -1
  96. package/dist/id-to-date-BfwadWDS.js +67 -0
  97. package/dist/{import-export.helper-BgaADwYQ.js → import-export.helper-BdQ_d-fT.js} +16 -17
  98. package/dist/{index-BT-a2SOP.js → index-BTNI4XZ2.js} +1 -1
  99. package/dist/{index-BS5wlvV_.js → index-B_hoeQNL.js} +3 -3
  100. package/dist/{JsonViewer.vue_vue_type_script_setup_true_lang-ig2zSXAB.js → index-C25C1Dg7.js} +1074 -1066
  101. package/dist/{index-CqgYx0tx.js → index-CCvxPS3E.js} +1 -1
  102. package/dist/index-eGvSlWMU.js +1892 -0
  103. package/dist/{lz-string-CRDgHWib.js → lz-string-CVEGZpSC.js} +1 -1
  104. package/dist/{netsuite-CaILEA4R.js → netsuite-DEhdSyBn.js} +9 -3
  105. package/dist/{predefined-templates-CTLn4dgR.js → predefined-templates-BTdQl7jj.js} +1 -1
  106. package/dist/{purchase-order-template-CE4_gQyK.js → purchase-order-template-DfMmpsrJ.js} +1 -1
  107. package/dist/{recalculationUtils-DoBJhZjA.js → recalculationUtils-Ds9Jcg0l.js} +1 -1
  108. package/dist/router/name.d.ts +2 -3
  109. package/dist/{row-action.enum-ncgDYAjP.js → row-action.enum-B2Y5YFbc.js} +2 -2
  110. package/dist/rules-D01xYhgI.js +238 -0
  111. package/dist/{stock-WxsPiRKa.js → stock-D3kBNq3e.js} +1 -1
  112. package/dist/stock-DyTC4Teu.js +74 -0
  113. package/dist/stores/feature.d.ts +20 -2
  114. package/dist/stores/integration/codemax.d.ts +2 -2
  115. package/dist/stores/integration/foodmarkethub.d.ts +2 -2
  116. package/dist/stores/integration/netsuite.d.ts +2 -2
  117. package/dist/stores/inventory.d.ts +0 -47
  118. package/dist/stores/inventory.no-location.spec.d.ts +1 -0
  119. package/dist/stores/location.d.ts +42 -42
  120. package/dist/stores/supplier.d.ts +49 -49
  121. package/dist/stores/warehouse.d.ts +3 -2
  122. package/dist/style.css +1 -1
  123. package/dist/{supplier-DbdPWPj7.js → supplier-DaidezrO.js} +2 -2
  124. package/dist/{surcharge-BsvY29nN.js → surcharge-C-PFvvlU.js} +1 -1
  125. package/dist/tsconfig.app.tsbuildinfo +1 -1
  126. package/dist/{uom-rules-dxyRNetA.js → uom-rules-Un5bhcrm.js} +1 -1
  127. package/dist/{use-ingredient-select-dialog-eYM-6q4s.js → use-ingredient-select-dialog-DV_hkAt9.js} +2 -2
  128. package/dist/use-inventory-binding-dialog-CTceyFrg.js +113 -0
  129. package/dist/{use-template-enabled-locations-C0o5r4_0.js → use-template-enabled-locations-DGqw8tvz.js} +2 -2
  130. package/dist/{use-transfer-locations-CC35SlyA.js → use-transfer-locations-DgtKajec.js} +2 -2
  131. package/dist/{useHrmPermission-DxzYJX4n.js → useHrmPermission-BMpZlah6.js} +1 -1
  132. package/dist/useNavigationMenu-D0NtXAnB.js +346 -0
  133. package/dist/{useSseClient-ml-_A-4u.js → useSseClient-CHZZxy7Z.js} +1 -1
  134. package/dist/views/adjustment-template/wastage-template/actions.d.ts +36 -36
  135. package/dist/views/adjustment-template/wastage-template/table.d.ts +36 -36
  136. package/dist/views/closing-draft/components/closing-draft-dialog/ClosingDraftApprovalDialog.vue.d.ts +6 -6
  137. package/dist/views/closing-draft/components/closing-draft-dialog/ClosingDraftDialog.vue.d.ts +12 -12
  138. package/dist/views/closing-draft/components/closing-draft-groups/ClosingGroupDetailSideSheet.vue.d.ts +6 -6
  139. package/dist/views/closing-draft/composables/use-closing-draft-import.d.ts +3 -3
  140. package/dist/views/closing-draft/composables/use-closing-draft-table.d.ts +18 -18
  141. package/dist/views/closing-template/composables/use-closing-template-actions.d.ts +45 -45
  142. package/dist/views/closing-template/composables/use-closing-template-table.d.ts +36 -36
  143. package/dist/views/ingredients/components/inventory-binding/InventoryBindingForm.vue.d.ts +0 -1
  144. package/dist/views/ingredients/components/inventory-binding/composables/use-inventory-binding-dialog.d.ts +0 -1
  145. package/dist/views/ingredients/components/inventory-binding/recipe-amount-validation.spec.d.ts +1 -0
  146. package/dist/views/ingredients/components/inventory-binding/v2/InventoryBindingFormV2.vue.d.ts +0 -1
  147. package/dist/views/ingredients/components/inventory-binding/v2/composables/use-inventory-binding-dialog.d.ts +0 -1
  148. package/dist/views/ingredients/helper/is-linked-ingredient-error.d.ts +1 -1
  149. package/dist/{components/PremiumBadge.vue.d.ts → views/integration/IntegrationPlatformView.vue.d.ts} +11 -13
  150. package/dist/views/integration/components/ApplyProductDialog.vue.d.ts +4 -4
  151. package/dist/views/integration/components/ApplyProductDialogCodemax.vue.d.ts +4 -4
  152. package/dist/views/integration/components/ApplyProductDialogV4.vue.d.ts +4 -4
  153. package/dist/views/integration/components/CodemaxDialog.vue.d.ts +4 -4
  154. package/dist/views/integration/components/IntegrationCard.vue.d.ts +38 -0
  155. package/dist/views/integration/components/Synergy/importFn.spec.d.ts +1 -0
  156. package/dist/views/integration/components/Xilnex/importFn.spec.d.ts +1 -0
  157. package/dist/views/integration/components/netsuite/business/AddLocationDialog.vue.d.ts +36 -36
  158. package/dist/views/integration/components/netsuite/business/AddVendorDialog.vue.d.ts +24 -24
  159. package/dist/views/integration/helper/opening-balance.d.ts +22 -0
  160. package/dist/views/integration/helper/opening-balance.spec.d.ts +1 -0
  161. package/dist/views/production-run/features/detail/ProductionRunDetailTabs.spec.d.ts +1 -0
  162. package/dist/views/production-run/features/detail/{ProductionRunTabs.vue.d.ts → ProductionRunDetailTabs.vue.d.ts} +4 -8
  163. package/dist/views/production-run/features/detail/ProductionRunOverviewTab.vue.d.ts +2 -2
  164. package/dist/views/production-run/features/detail/use-production-run-detail.d.ts +4 -4
  165. package/dist/views/production-run/features/lifecycle/CancelRunDialog.vue.d.ts +2 -2
  166. package/dist/views/production-run/features/lifecycle/CloseRunDialog.vue.d.ts +2 -2
  167. package/dist/views/production-run/features/lifecycle/ProductionRunLifecycleDialogs.vue.d.ts +11 -11
  168. package/dist/views/production-run/features/lifecycle/TargetReachedDialog.vue.d.ts +2 -2
  169. package/dist/views/production-run/features/planning/ProductionRunFormDialog.vue.d.ts +2 -2
  170. package/dist/views/production-run/features/planning/use-production-run-duplicate-sources.d.ts +3 -3
  171. package/dist/views/production-run/features/prepare/production-run-prepare-sheet.d.ts +0 -9
  172. package/dist/views/production-run/shared/helpers/production-run-navigation.d.ts +0 -2
  173. package/dist/views/production-run/shared/model/production-run-list.d.ts +0 -1
  174. package/dist/views/production-run/shared/ui/ProductionRunScrollHint.vue.d.ts +10 -0
  175. package/dist/views/receive-request/components/transfer-form/TransferFormWithController.vue.d.ts +5 -5
  176. package/dist/views/receive-request/composables/netsuite-order-label.d.ts +11 -0
  177. package/dist/views/receive-request/composables/netsuite-order-label.spec.d.ts +1 -0
  178. package/dist/views/receive-request/composables/use-process-purchase-order.d.ts +6 -6
  179. package/dist/views/receive-request/composables/use-receive-request-form.d.ts +48 -48
  180. package/dist/views/receive-request/composables/use-receive-request-table.d.ts +42 -42
  181. package/dist/views/receive-request/import/export.spec.d.ts +1 -0
  182. package/dist/views/receive-request-bulk/composables/use-bulk-receive-request-form.d.ts +42 -42
  183. package/dist/views/receive-request-bulk/composables/use-bulk-receive-request-table.d.ts +8 -8
  184. package/dist/views/recipe/components/recipe-bulk-editor/components/ModificationCard.spec.d.ts +1 -0
  185. package/dist/views/recipe/helper/bulk-edit-simulation.helper.d.ts +0 -1
  186. package/dist/views/recipe/helper/import-recipe.d.ts +2 -2
  187. package/dist/views/recipe/helper/import-recipe.spec.d.ts +1 -0
  188. package/dist/views/settings/PlanLicenseDisplay.spec.d.ts +1 -0
  189. package/dist/views/{integration/components/IntegrationSyncLogTab.vue.d.ts → settings/PlanLicenseDisplay.vue.d.ts} +2 -2
  190. package/dist/views/stock/components/StockRecordCard.vue.d.ts +72 -44
  191. package/dist/views/stock/components/dialog/AmendAdjustmentForm.spec.d.ts +1 -0
  192. package/dist/views/stock/components/dialog/ConvertSkuDialog.spec.d.ts +1 -0
  193. package/dist/views/supplier/components/SupplierForm.vue.d.ts +4 -4
  194. package/dist/views/supplier/composables/use-supplier-table.d.ts +2 -2
  195. package/dist/views/transfer-template/components/transfer-template-dialog/TransferTemplateDialog.vue.d.ts +8 -8
  196. package/dist/views/transfer-template/components/transfer-template-form/composables/use-transfer-locations.d.ts +4 -4
  197. package/dist/views/transfer-template/components/transfer-template-form/composables/use-transfer-template-items.spec.d.ts +1 -0
  198. package/dist/views/transfer-template/composables/use-template-item-bulk-editor.d.ts +24 -24
  199. package/dist/views/transfer-template/composables/use-transfer-template-actions.d.ts +48 -48
  200. package/dist/views/transfer-template/composables/use-transfer-template-table.d.ts +48 -48
  201. package/dist/views/warehouse/components/WarehouseForm.vue.d.ts +6 -4
  202. package/dist/{vue-i18n-DYapak10.js → vue-i18n-mXrQUZTi.js} +235 -235
  203. package/dist/{xlsx.util-DrElrKDx.js → xlsx.util-CKx0NYTq.js} +2 -2
  204. package/package.json +72 -67
  205. package/dist/App-CBS1Tqpl.js +0 -1476
  206. package/dist/ClosingHistoryView-3z17ZJzK.js +0 -761
  207. package/dist/FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-CB50Gqot.js +0 -243
  208. package/dist/FmMultiselectDialog-7xh6h5AX.js +0 -77
  209. package/dist/ImportView-C3Fc0e_X.js +0 -1302
  210. package/dist/IngredientBindedItem.vue_vue_type_script_setup_true_lang-6naVJEke.js +0 -51
  211. package/dist/IngredientGroupView-DA1buE1C.js +0 -985
  212. package/dist/InventoryBindingForm.vue_vue_type_script_setup_true_lang-tEKGPtHZ.js +0 -563
  213. package/dist/NumberPrecisionInput.vue_vue_type_script_setup_true_lang-Cbg0j7Jz.js +0 -72
  214. package/dist/PremiumBadge.vue_vue_type_script_setup_true_lang-Btrg9HNc.js +0 -93
  215. package/dist/PreviewBadge.vue_vue_type_script_setup_true_lang-DX2MJqL4.js +0 -29
  216. package/dist/ProductionRunDetailView-DYeSPsIY.js +0 -2284
  217. package/dist/ProductionRunPreparePrintView-DJOejqOC.js +0 -34
  218. package/dist/ProductionRunTabs.vue_vue_type_script_setup_true_lang-JKMI-vVw.js +0 -7543
  219. package/dist/ProductionRunView-Cg3aYOg9.js +0 -911
  220. package/dist/RecipeView-DC0p9RKL.js +0 -3625
  221. package/dist/SettingsView-DaKfCVY5.js +0 -698
  222. package/dist/StockView-DdweBRFv.js +0 -2612
  223. package/dist/TableActionableRow.vue_vue_type_script_setup_true_lang-DAMpuZ1X.js +0 -84
  224. package/dist/TransferTemplateView-CSXcAB3-.js +0 -2327
  225. package/dist/feature-DtpSrELx.js +0 -1136
  226. package/dist/number-DE6ovaTs.js +0 -138
  227. package/dist/random-CSbEbElR.js +0 -10
  228. package/dist/rules-CkaU7yFU.js +0 -98
  229. package/dist/stock-B3Q9e174.js +0 -75
  230. package/dist/use-inventory-binding-dialog-CCV1iieA.js +0 -152
  231. package/dist/useNavigationMenu-IKam6CEf.js +0 -172
  232. package/dist/usePromise-CbVUCxhj.js +0 -29
  233. package/dist/views/ingredient-group/IngredientGroupView.vue.d.ts +0 -3
  234. package/dist/views/ingredient-group/components/ingredient-group-dialog/IngredientGroupDialog.vue.d.ts +0 -31
  235. package/dist/views/ingredient-group/components/ingredient-group-dialog/IngredientGroupDialogProps.d.ts +0 -10
  236. package/dist/views/ingredient-group/components/ingredient-group-form/IngredientGroupForm.vue.d.ts +0 -21
  237. package/dist/views/ingredient-group/components/ingredient-group-form/IngredientGroupFormProps.d.ts +0 -12
  238. package/dist/views/ingredient-group/components/ingredient-group-rule-field/IngredientGroupRuleField.vue.d.ts +0 -37
  239. package/dist/views/ingredient-group/composables/use-ingredient-group-actions.d.ts +0 -24
  240. package/dist/views/ingredient-group/composables/use-ingredient-group-rule-item.d.ts +0 -31
  241. package/dist/views/ingredient-group/composables/use-ingredient-group-table.d.ts +0 -77
  242. package/dist/views/integration/composables/use-integration-sync-log.d.ts +0 -45
  243. /package/dist/components/{FmFeatureFlagDialog.vue.d.ts → DeprecateSoonPill.vue.d.ts} +0 -0
  244. /package/dist/{views/production-run/ProductionRunPreparePrintView.spec.d.ts → components/FeatureCapabilityGate.spec.d.ts} +0 -0
  245. /package/dist/{views/production-run/features/detail/ProductionRunTabs.spec.d.ts → components/NumberPrecisionInput.spec.d.ts} +0 -0
  246. /package/dist/{views/production-run/features/prepare/production-run-prepare-sheet-cleanup.spec.d.ts → feature-flags/core.spec.d.ts} +0 -0
  247. /package/dist/views/{production-run/ProductionRunPreparePrintView.vue.d.ts → settings/FeatureFlagView.vue.d.ts} +0 -0
@@ -1,2612 +0,0 @@
1
- import { defineComponent as pe, createBlock as te, openBlock as j, withCtx as M, createElementVNode as e, toDisplayString as f, unref as s, ref as Y, h as be, computed as T, watch as Fe, resolveComponent as D, isRef as Pe, createVNode as _, createElementBlock as q, Fragment as ue, renderList as ve, createCommentVNode as se, normalizeClass as He, reactive as _t, mergeModels as nt, useModel as jt, onMounted as qe, createTextVNode as me, normalizeStyle as kt, watchEffect as Vt, renderSlot as st, onUnmounted as Ct, Teleport as Bt, normalizeProps as at, mergeProps as ze } from "vue";
2
- import { u as Dt, _ as Mt } from "./SingleColumnLayout.vue_vue_type_script_setup_true_lang-DpwneGOV.js";
3
- import { u as Se, c as Re, a as Ne, F as rt, t as It, E as ie, s as Ht, d as Tt, B as Et, w as ne, h as Ce, i as lt, e as it, L as ge, M as Be } from "./app-CGcDbrt8.js";
4
- import { u as Oe } from "./stock-B3Q9e174.js";
5
- import { c as Ut } from "./component-BmLAdDiY.js";
6
- import { _ as ht, o as Pt } from "./UnitDisplayControl.vue_vue_type_script_setup_true_lang-BT2v1gZv.js";
7
- import { _ as Ke, S as Ge, g as bt, a as Rt } from "./SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-BTh5E4Tt.js";
8
- import { _ as Nt } from "./PreviewBadge.vue_vue_type_script_setup_true_lang-DX2MJqL4.js";
9
- import { useI18n as ye, useCoreStore as Xe } from "@feedmepos/mf-common";
10
- import { u as gt, i as Te, _ as ut } from "./PremiumBadge.vue_vue_type_script_setup_true_lang-Btrg9HNc.js";
11
- import { useSnackbar as we, useDialog as Le, useProxiedModel as Ye, useBreakpoints as Ot } from "@feedmepos/ui-library";
12
- import { defineStore as Lt } from "pinia";
13
- import { F as Je } from "./FmAdminBadge-DlplQOHb.js";
14
- import { g as $e, a as he, e as Yt, t as Ee, c as xe, f as zt, h as ct, i as xt, j as Qe, d as Me, k as Gt } from "./number-DE6ovaTs.js";
15
- import { u as Ae } from "./stock-WxsPiRKa.js";
16
- import { c as Ue, A as Wt, M as Kt, R as qt } from "./rules-CkaU7yFU.js";
17
- import { u as Xt } from "./use-inventory-binding-dialog-CCV1iieA.js";
18
- import { a as St } from "./FmMultiselectDialog-eH3nO3P3.js";
19
- import { d as ke } from "./dayjs.min-DrqpmBJQ.js";
20
- import { _ as Jt } from "./NumberPrecisionInput.vue_vue_type_script_setup_true_lang-Cbg0j7Jz.js";
21
- import { g as Qt } from "./decimal-BJ-B2ZXz.js";
22
- import { b as Zt, d as eo, f as wt, t as dt, a as mt, p as to, n as oo, c as no } from "./date2-CHOcS7LX.js";
23
- import { i as so } from "./FmDateRangePickerChip.vue_vue_type_script_setup_true_lang-BCuhx2cN.js";
24
- import { _ as ao } from "./empty-placeholder-B0QU467o.js";
25
- import { F as _e } from "./inventory-core-dart.default-DGI40oFz.js";
26
- import { u as ro } from "./feature-DtpSrELx.js";
27
- import { u as At } from "./useHrmPermission-DxzYJX4n.js";
28
- import { _ as lo, F as ft } from "./TableActionableRow.vue_vue_type_script_setup_true_lang-DAMpuZ1X.js";
29
- import { _ as io } from "./FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-CB50Gqot.js";
30
- import { u as uo } from "./useSseClient-ml-_A-4u.js";
31
- import { u as co } from "./netsuite-CaILEA4R.js";
32
- import { P as mo, J as fo } from "./app-C39bYJmq.js";
33
- var Ie = /* @__PURE__ */ ((A) => (A.History = "History", A.Convert = "Convert", A.Adjust = "Adjust", A))(Ie || {});
34
- const vo = [
35
- {
36
- translationKey: "inventory.stock.action.history",
37
- color: "text-neutral-700",
38
- value: "History"
39
- /* History */
40
- }
41
- ], po = [
42
- {
43
- translationKey: "inventory.stock.action.history",
44
- color: "text-neutral-700",
45
- value: "History"
46
- /* History */
47
- },
48
- {
49
- translationKey: "inventory.stock.action.convert",
50
- color: "text-neutral-700",
51
- value: "Convert"
52
- /* Convert */
53
- },
54
- {
55
- translationKey: "inventory.stock.action.adjust",
56
- color: "text-neutral-700",
57
- value: "Adjust"
58
- /* Adjust */
59
- }
60
- ], yo = { class: "whitespace-nowrap" }, _o = /* @__PURE__ */ pe({
61
- __name: "StockHeaderPreview",
62
- setup(A) {
63
- const { t: c } = ye();
64
- return (k, y) => (j(), te(Nt, null, {
65
- default: M(() => [
66
- e("div", yo, f(s(c)("inventory.stock.prediction.daysRemaining")), 1)
67
- ]),
68
- _: 1
69
- }));
70
- }
71
- }), Ft = Lt("stockActions", () => {
72
- const A = Y(!1), c = Se(), k = Oe(), y = gt(), w = we(), V = Le(), { t: d } = ye();
73
- async function r() {
74
- if (c._currentLocation) {
75
- A.value = !0;
76
- try {
77
- await k.readStockBalance(), await k.readProductBalance(), await y.readStockEstimateBalance();
78
- } catch {
79
- w.open({
80
- title: d("inventory.stock.error.title"),
81
- message: d("inventory.stock.error.message"),
82
- type: "error"
83
- });
84
- } finally {
85
- A.value = !1;
86
- }
87
- }
88
- }
89
- const b = Y();
90
- async function R(g) {
91
- var $, E, N;
92
- if (!!!((E = ($ = g.convert) == null ? void 0 : $.inventoryBindings) != null && E.length)) {
93
- V.open({
94
- title: d("inventory.stock.error.convert.title"),
95
- message: d("inventory.stock.error.convert.message")
96
- });
97
- return;
98
- }
99
- const n = {
100
- maxCount: ((N = k.productBalance.find(({ id: O }) => O === g._id)) == null ? void 0 : N.count) || 0,
101
- sku: g,
102
- show: !0,
103
- "onUpdate:show"(O) {
104
- b.value.show = O;
105
- },
106
- onSubmitted() {
107
- r();
108
- }
109
- };
110
- b.value = n;
111
- }
112
- const C = Y();
113
- async function l(g) {
114
- const o = {
115
- stock: g,
116
- show: !0,
117
- "onUpdate:show"(t) {
118
- C.value.show = t;
119
- },
120
- onSubmitted() {
121
- r();
122
- }
123
- };
124
- C.value = o;
125
- }
126
- const a = Y();
127
- async function B(g) {
128
- const o = {
129
- sku: g,
130
- show: !0,
131
- "onUpdate:show"(t) {
132
- a.value.show = t;
133
- }
134
- };
135
- a.value = o;
136
- }
137
- function v(g, o) {
138
- const t = Re(o);
139
- switch (g) {
140
- case Ie.History:
141
- B(t);
142
- return;
143
- case Ie.Convert:
144
- R(t);
145
- return;
146
- case Ie.Adjust:
147
- l(t);
148
- return;
149
- }
150
- }
151
- return {
152
- fetchStockBalance: r,
153
- onActionMenu: v,
154
- stockHistoryProps: a,
155
- showSkuHistory: B,
156
- convertSkuDialogProps: b,
157
- adjustSkuDialogProps: C
158
- };
159
- });
160
- function ko() {
161
- var V;
162
- const A = Se(), c = Ft(), k = Xe(), { t: y } = ye();
163
- return {
164
- columnDefs: [
165
- {
166
- accessorKey: "code",
167
- header: () => y("inventory.stock.code"),
168
- enableSorting: !0,
169
- size: 300
170
- },
171
- {
172
- accessorKey: "name",
173
- header: () => y("inventory.stock.product"),
174
- enableSorting: !0,
175
- size: "auto"
176
- },
177
- {
178
- id: "UOM",
179
- header: () => y("inventory.stock.balance"),
180
- cell(d) {
181
- const r = d.row.original, b = {
182
- unit: r.unit,
183
- sku: r,
184
- amount: r.balance,
185
- defaultTrackingMeasurement: r.trackingMeasurement ?? void 0
186
- };
187
- return be(ht, b);
188
- },
189
- size: 180
190
- },
191
- ...(V = k.sessionUser.value) != null && V.role.isAdmin ? [
192
- {
193
- accessorKey: "isInactive",
194
- header: () => be(Je, {}, () => `${y("inventory.ingredient.status.title")}`),
195
- cell(d) {
196
- const r = d.row.original.isInactive;
197
- return be(
198
- "span",
199
- {
200
- class: [
201
- "inline-block px-3 py-1 rounded-full text-xs font-semibold",
202
- r ? "bg-red-100 text-red-700" : "bg-green-100 text-green-700"
203
- ].join(" ")
204
- },
205
- y(r ? "inventory.ingredient.status.inactive" : "inventory.ingredient.status.active")
206
- );
207
- },
208
- enableSorting: !0
209
- }
210
- ] : [],
211
- {
212
- accessorKey: "day",
213
- id: "expireDate",
214
- header: () => be(_o),
215
- enableSorting: !0,
216
- sortUndefined: "last",
217
- cell(d) {
218
- var B, v;
219
- const r = d.row.original.day, b = d.row.original.operator, R = (B = d.row.original.thresholds) == null ? void 0 : B.low, C = (v = d.row.original.thresholds) == null ? void 0 : v.mid;
220
- if (typeof r != "number" || typeof R != "number" || typeof C != "number")
221
- return be(Ke, {
222
- days: r,
223
- operator: b
224
- });
225
- const l = r <= R ? Ge.low : r <= C ? Ge.mid : Ge.high;
226
- return be(Ke, {
227
- days: r,
228
- level: l
229
- });
230
- },
231
- size: 200
232
- },
233
- {
234
- id: "action",
235
- cell(d) {
236
- var r;
237
- return Ut(
238
- ((r = A._currentLocation) == null ? void 0 : r.type) === "restaurant" ? vo : po,
239
- (b) => c.onActionMenu(b, d.row.original)
240
- );
241
- },
242
- enableSorting: !1,
243
- size: 40,
244
- meta: {
245
- cellClass: "",
246
- headerClass: ""
247
- }
248
- }
249
- ]
250
- };
251
- }
252
- const ho = {
253
- context: null,
254
- error: null,
255
- isRequired(A = "This field is required") {
256
- return `${this.context ?? ""}`.length === 0 && (this.error = A), this;
257
- },
258
- isString(A = "Must be a valid string") {
259
- return this.error ? this : (typeof this.context != "string" && (this.error ?? (this.error = A)), this);
260
- },
261
- toInt() {
262
- return this.error ? this : (this.context = +this.context, this);
263
- },
264
- isInteger(A = "Must be an integer") {
265
- return this.error ? this : (this.toInt(), isNaN(this.context) && (this.error = A), this);
266
- },
267
- min(A, c) {
268
- if (this.error) return this;
269
- try {
270
- typeof this.context == "number" ? +this.context < A && (this.error = c ?? `Must be at least ${A}`) : Object.prototype.hasOwnProperty.call(this.context, "length") ? +this.context.length < A && (this.error = c ?? `Must be at least ${A}`) : this.error = "Length cannot be determined";
271
- } catch {
272
- this.error = "Length cannot be determined";
273
- }
274
- return this;
275
- },
276
- max(A, c) {
277
- if (this.error) return this;
278
- try {
279
- typeof this.context == "number" ? +this.context > A && (this.error = c ?? `Must be at most ${A}`) : "length" in this.context ? +this.context.length > A && (this.error = c ?? `Must be at most ${A}`) : this.error = "Length cannot be determined";
280
- } catch {
281
- this.error = "Length cannot be determined";
282
- }
283
- return this;
284
- }
285
- };
286
- function vt(A) {
287
- return { ...ho, context: A };
288
- }
289
- const bo = { class: "flex items-center" }, go = { class: "fm-typo-en-title-md-800" }, xo = { class: "flex flex-col gap-24 w-full" }, So = { class: "flex flex-col gap-8" }, wo = { class: "fm-typo-en-body-lg-600" }, Ao = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary flex-grow" }, Fo = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-error" }, $o = { class: "flex flex-col p-16 gap-8" }, jo = { class: "flex flex-col gap-4" }, Vo = { class: "fm-typo-en-body-md-600 text-fm-color-typo-secondary bg-fm-color-neutral-gray-100 border-b py-12 px-16" }, Co = { class: "grid grid-cols-[auto_100px_100px_48px] xs:grid-cols-[auto_80px_120px_48px] gap-8 px-8 items-center" }, Bo = { class: "xs:col-span-3" }, Do = { class: "flex gap-8" }, Mo = /* @__PURE__ */ pe({
290
- __name: "ConvertSkuDialog",
291
- props: {
292
- sku: {},
293
- maxCount: {},
294
- show: { type: Boolean }
295
- },
296
- emits: ["update:show", "submitted"],
297
- setup(A, { expose: c, emit: k }) {
298
- const y = A, w = k, V = Xt(), d = Ne(), r = Ae(), b = we(), { t: R } = ye(), C = Y(0), l = Y(null), a = T(() => d.skus), B = T(
299
- () => {
300
- var x, F;
301
- return (((F = (x = y.sku) == null ? void 0 : x.convert) == null ? void 0 : F.inventoryBindings) ?? []).filter(
302
- (G) => G.type === rt.enum.SKU
303
- );
304
- }
305
- ), v = T({
306
- get() {
307
- return !!l.value;
308
- },
309
- set(x) {
310
- x ? l.value = Re(B.value) : (l.value = null, C.value = Math.min(C.value, y.maxCount ?? 0));
311
- }
312
- }), g = Y(!1);
313
- Fe([() => y.show], ([x]) => {
314
- x && (C.value = 0);
315
- });
316
- function o() {
317
- L(y.sku, Ee(C.value), l.value);
318
- }
319
- function t(x) {
320
- if (l.value)
321
- return !0;
322
- const F = vt(x).isInteger().max(y.maxCount ?? 0).error ?? "";
323
- return F || !0;
324
- }
325
- function n(x) {
326
- var I;
327
- const F = (I = y.sku.convert) != null && I.measurement ? y.sku.unit.measurements.find((u) => {
328
- var h;
329
- return u.id === ((h = y.sku.convert) == null ? void 0 : h.measurement);
330
- }) ?? null : null, G = $e(y.sku.unit, F), H = zt(+x);
331
- return vt(H).isInteger().max(G).error ? "Precision cannot be more than " + G : !0;
332
- }
333
- const $ = T(
334
- () => {
335
- var x, F;
336
- return (x = y.sku.convert) != null && x.measurement ? (F = y.sku.unit.measurements.find((G) => {
337
- var H;
338
- return G.id === ((H = y.sku.convert) == null ? void 0 : H.measurement);
339
- })) == null ? void 0 : F.abbrev : y.sku.unit.abbrev;
340
- }
341
- ), E = T(() => {
342
- var H, J;
343
- const F = It({
344
- bindings: ((H = y.sku.convert) == null ? void 0 : H.inventoryBindings) ?? [],
345
- skus: d.skus,
346
- skuGroups: d.skuGroups,
347
- recipes: d.recipes
348
- }).inventoryBindings.filter((I) => "success" in I && I.success).map((I) => I).map((I) => I.binding);
349
- return (J = l.value ?? F) == null ? void 0 : J.map((I) => {
350
- var ee, ae, Q, W, oe;
351
- const u = d.skus.find((le) => le._id === I.id), h = ((ee = I.measurement) == null ? void 0 : ee.abbrev) ?? ((ae = u == null ? void 0 : u.unit) == null ? void 0 : ae.abbrev), p = (Q = y.sku.convert) != null && Q.measurement ? y.sku.unit.measurements.find((le) => {
352
- var ce;
353
- return le.id === ((ce = y.sku.convert) == null ? void 0 : ce.measurement);
354
- }) ?? null : null, m = $e(y.sku.unit, p), i = n(`${C.value}`) === !0 ? he(
355
- Yt(
356
- I.amount,
357
- Ee(+C.value, m)
358
- ),
359
- !1
360
- ) : "0", S = (oe = (W = l.value) == null ? void 0 : W.find((le) => le.id === (u == null ? void 0 : u._id))) == null ? void 0 : oe.amount, P = S ? he(S, !1) : null;
361
- return {
362
- sku: u,
363
- convertAmount: P ?? i,
364
- abbrev: h
365
- };
366
- });
367
- }), N = Y();
368
- c({
369
- validateInputs: () => {
370
- var x, F;
371
- (F = (x = N.value) == null ? void 0 : x.validateInputs) == null || F.call(x);
372
- },
373
- resetInputsValidation: () => {
374
- var x, F;
375
- (F = (x = N.value) == null ? void 0 : x.resetInputsValidation) == null || F.call(x);
376
- },
377
- resetInputs: () => {
378
- var x, F;
379
- (F = (x = N.value) == null ? void 0 : x.resetInputs) == null || F.call(x);
380
- }
381
- });
382
- const O = Ye(y, "show");
383
- async function L(x, F, G) {
384
- g.value = !0;
385
- try {
386
- await r.convertSku({
387
- conversions: [
388
- {
389
- doc: x,
390
- amount: F,
391
- overrides: G == null ? void 0 : G.map((H) => ({
392
- ...H,
393
- amount: {
394
- ...H.amount,
395
- amount: -1 * Math.abs(H.amount.amount)
396
- // ensure truly negative
397
- }
398
- }))
399
- }
400
- ]
401
- }), w("update:show", !1), w("submitted");
402
- } catch (H) {
403
- b.open({
404
- title: "Something went wrong",
405
- message: `Cannot convert ${x.name}. Please try again.`,
406
- type: "error"
407
- }), console.error("error at converting stock amount", x, F, H);
408
- } finally {
409
- g.value = !1;
410
- }
411
- }
412
- function X(x, F, G) {
413
- const H = +F;
414
- let J = G;
415
- F.length > 0 && isFinite(H) ? J = G.map((I) => (I.id !== x || (I.amount = xe(H)), I)) : J = G.map((I) => (I.id !== x || (I.amount = { amount: 0, precision: 0 }), I)), l.value = J;
416
- }
417
- function z(x) {
418
- const F = a.value.find((G) => G._id === x);
419
- return F ? bt(F.unit, !0) : [];
420
- }
421
- function K(x, F) {
422
- const G = z(x), H = G.find((J) => J.value === F) ?? G.find((J) => J.value === null);
423
- return H ? {
424
- ...H,
425
- label: H.abbrev
426
- } : null;
427
- }
428
- function U(x, F, G) {
429
- let H;
430
- if (F === null)
431
- H = G.map((J) => (J.id !== x || (J.measurement = null), J)) ?? [];
432
- else {
433
- const J = a.value.find((I) => I._id === x);
434
- H = G.map((I) => {
435
- var u, h;
436
- return I.id !== x || (I.measurement = (h = (u = J == null ? void 0 : J.unit) == null ? void 0 : u.measurements) == null ? void 0 : h.find((p) => p.id === F)), I;
437
- }) ?? [];
438
- }
439
- l.value = H;
440
- }
441
- function Z(x, F) {
442
- const G = F.filter((H) => H.id !== x);
443
- l.value = G;
444
- }
445
- function re() {
446
- const x = (l.value ?? []).map((F) => ({
447
- ...F,
448
- type: rt.enum.SKU
449
- }));
450
- V.promptIngredientsBinding(
451
- x,
452
- (F) => l.value = F,
453
- y.sku._id
454
- );
455
- }
456
- return Fe(
457
- () => y.show,
458
- (x) => {
459
- x || (l.value = null, C.value = 0);
460
- }
461
- ), (x, F) => {
462
- const G = D("FmTextField"), H = D("FmForm"), J = D("FmCard"), I = D("FmSwitch"), u = D("FmFormGroup"), h = D("FmSelect"), p = D("FmButton"), m = D("FmSideSheet");
463
- return j(), te(m, {
464
- "dismiss-away": "",
465
- modelValue: s(O),
466
- "onUpdate:modelValue": F[3] || (F[3] = (i) => Pe(O) ? O.value = i : null),
467
- "max-width": 500
468
- }, {
469
- "side-sheet-header": M(() => [
470
- e("div", bo, [
471
- e("div", go, f(s(R)("inventory.stock.convert.title", { name: x.sku.name })), 1)
472
- ])
473
- ]),
474
- default: M(() => [
475
- e("div", xo, [
476
- _(H, {
477
- ref_key: "formRef",
478
- ref: N,
479
- onValidationSuccess: o
480
- }, {
481
- default: M(() => [
482
- _(G, {
483
- disabled: g.value,
484
- "model-value": C.value,
485
- "onUpdate:modelValue": F[0] || (F[0] = (i) => C.value = i),
486
- label: s(R)("inventory.stock.convert.amount"),
487
- rules: [t, n, s(Ue)(0)],
488
- "append-text": $.value,
489
- "helper-text": l.value ? void 0 : `Max ${x.maxCount} ${$.value}`
490
- }, null, 8, ["disabled", "model-value", "label", "rules", "append-text", "helper-text"])
491
- ]),
492
- _: 1
493
- }, 512),
494
- _(J, {
495
- variant: "outlined",
496
- class: "p-16"
497
- }, {
498
- default: M(() => [
499
- e("div", So, [
500
- e("div", wo, f(s(R)("inventory.stock.convert.deductionSummary")), 1),
501
- (j(!0), q(ue, null, ve(E.value, (i) => {
502
- var S, P;
503
- return j(), q("div", {
504
- key: (S = i.sku) == null ? void 0 : S._id,
505
- class: "flex items-center"
506
- }, [
507
- e("div", Ao, f((P = i.sku) == null ? void 0 : P.name), 1),
508
- e("div", Fo, " -" + f(i.convertAmount) + " " + f(i.abbrev), 1)
509
- ]);
510
- }), 128))
511
- ])
512
- ]),
513
- _: 1
514
- }),
515
- _(J, { variant: "outlined" }, {
516
- default: M(() => [
517
- e("div", $o, [
518
- _(I, {
519
- value: "",
520
- modelValue: v.value,
521
- "onUpdate:modelValue": F[1] || (F[1] = (i) => v.value = i),
522
- label: s(R)("inventory.stock.convert.overrideDeduction"),
523
- "label-placement": "right"
524
- }, null, 8, ["modelValue", "label"]),
525
- v.value ? (j(), q(ue, { key: 0 }, [
526
- _(u, {
527
- modelValue: l.value,
528
- rules: [s(Wt)(1, "Must have at least one ingredient binding")]
529
- }, null, 8, ["modelValue", "rules"]),
530
- e("div", jo, [
531
- e("div", Vo, f(s(R)("inventory.stock.convert.ingredients")), 1),
532
- (j(!0), q(ue, null, ve(l.value, (i) => (j(), te(u, {
533
- key: i.id,
534
- disabled: g.value,
535
- modelValue: +s(he)(i.amount ?? { amount: 1, precision: 0 }),
536
- rules: [
537
- s(Kt)(
538
- a.value.find((S) => S._id === i.id).unit,
539
- i.measurement
540
- ),
541
- s(Ue)(0)
542
- ]
543
- }, {
544
- default: M(({ invalid: S }) => {
545
- var P, ee, ae;
546
- return [
547
- e("div", Co, [
548
- e("div", Bo, f((P = a.value.find((Q) => Q._id === i.id)) == null ? void 0 : P.name), 1),
549
- _(G, {
550
- class: "xs:col-span-2",
551
- disabled: g.value,
552
- modelValue: +s(he)(
553
- i.amount ?? { amount: 1, precision: 0 }
554
- ),
555
- "onUpdate:modelValue": (Q) => X(i.id, Q, l.value ?? []),
556
- invalid: S
557
- }, null, 8, ["disabled", "modelValue", "onUpdate:modelValue", "invalid"]),
558
- _(h, {
559
- disabled: g.value,
560
- class: "translate-y-[2px]",
561
- items: z(i.id),
562
- "model-value": (ae = K(i.id, (ee = i.measurement) == null ? void 0 : ee.id)) == null ? void 0 : ae.value,
563
- "onUpdate:modelValue": (Q) => U(i.id, Q, l.value ?? []),
564
- invalid: S
565
- }, {
566
- "helper-text": M(() => F[4] || (F[4] = [])),
567
- _: 2
568
- }, 1032, ["disabled", "items", "model-value", "onUpdate:modelValue", "invalid"]),
569
- _(p, {
570
- disabled: g.value,
571
- type: "button",
572
- variant: "tertiary",
573
- icon: "delete",
574
- onClick: (Q) => Z(i.id, l.value ?? [])
575
- }, null, 8, ["disabled", "onClick"])
576
- ])
577
- ];
578
- }),
579
- _: 2
580
- }, 1032, ["disabled", "modelValue", "rules"]))), 128))
581
- ]),
582
- e("div", null, [
583
- _(p, {
584
- icon: "link",
585
- label: s(R)("inventory.stock.convert.linkIngredient"),
586
- variant: "plain",
587
- onClick: re
588
- }, null, 8, ["label"])
589
- ])
590
- ], 64)) : se("", !0)
591
- ])
592
- ]),
593
- _: 1
594
- })
595
- ])
596
- ]),
597
- "side-sheet-footer": M(() => [
598
- e("div", Do, [
599
- _(p, {
600
- loading: g.value,
601
- label: s(R)("inventory.stock.convert.convertButton"),
602
- onClick: F[2] || (F[2] = (i) => {
603
- var S, P;
604
- return (P = (S = N.value) == null ? void 0 : S.validateInputs) == null ? void 0 : P.call(S);
605
- })
606
- }, null, 8, ["loading", "label"])
607
- ])
608
- ]),
609
- _: 1
610
- }, 8, ["modelValue"]);
611
- };
612
- }
613
- });
614
- function De(A, c) {
615
- const k = Ee(A, c);
616
- return { ...k, amount: -k.amount };
617
- }
618
- function pt(A, c) {
619
- return Ee(Math.abs(A), c);
620
- }
621
- const We = {
622
- [ie.enum.DAMAGE]: {
623
- label: "Damage",
624
- toAdjustmentAmount: De
625
- },
626
- [ie.enum.WASTAGE]: {
627
- label: "Wastage",
628
- toAdjustmentAmount: De
629
- },
630
- [ie.enum.THEFT]: {
631
- label: "Theft",
632
- toAdjustmentAmount: De
633
- },
634
- [ie.enum.LOSE]: {
635
- label: "Lose",
636
- toAdjustmentAmount: De
637
- },
638
- [ie.enum.EXTRA]: {
639
- label: "Extra",
640
- toAdjustmentAmount: pt
641
- },
642
- [ie.enum.PURCHASE]: {
643
- label: "Purchase",
644
- toAdjustmentAmount: pt
645
- }
646
- }, Io = { class: "col-span-2 flex" }, Ho = { class: "flex-1" }, To = { class: "fm-typo-en-body-lg-600" }, Eo = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Uo = { class: "col-span-2 flex flex-col gap-4" }, Po = { class: "flex gap-4 text-fm-color-typo-primary fm-typo-en-body-lg-600" }, Ro = {
647
- key: 0,
648
- class: "fm-typo-en-body-md-400 text-fm-color-typo-warning"
649
- }, $t = /* @__PURE__ */ pe({
650
- __name: "AdjustedItemForm",
651
- props: {
652
- modelValue: {},
653
- disabled: { type: Boolean },
654
- isBackdate: { type: Boolean }
655
- },
656
- emits: ["update:modelValue", "click:delete"],
657
- setup(A, { emit: c }) {
658
- const k = A, y = c, { t: w } = ye(), V = Oe(), d = T(
659
- () => Object.keys(We).map((t) => ({
660
- label: Ht(t),
661
- value: t
662
- }))
663
- ), r = T(() => bt(k.modelValue.doc.unit, !0)), b = T({
664
- get() {
665
- return k.modelValue.type ?? ie.enum.PURCHASE;
666
- },
667
- set(t) {
668
- const n = {
669
- ...k.modelValue
670
- };
671
- n.type = t;
672
- const $ = ct(k.modelValue.amount);
673
- n.amount = We[n.type].toAdjustmentAmount(
674
- +he($),
675
- $.precision
676
- ), y("update:modelValue", n);
677
- }
678
- }), R = T({
679
- get() {
680
- const t = ct(k.modelValue.amount);
681
- return +he(t);
682
- },
683
- set(t) {
684
- const n = {
685
- ...k.modelValue
686
- }, $ = xe(t);
687
- n.amount = We[b.value].toAdjustmentAmount(
688
- t,
689
- $.precision
690
- ), y("update:modelValue", n);
691
- }
692
- }), C = T({
693
- get() {
694
- var t;
695
- return ((t = k.modelValue.measurement) == null ? void 0 : t.id) ?? null;
696
- },
697
- set(t) {
698
- var $, E;
699
- const n = {
700
- ...k.modelValue
701
- };
702
- n.measurement = ((E = ($ = k.modelValue.doc.unit) == null ? void 0 : $.measurements) == null ? void 0 : E.find((N) => N.id === t)) ?? null, y("update:modelValue", n);
703
- }
704
- }), l = T({
705
- get() {
706
- return k.modelValue.remark ?? "";
707
- },
708
- set(t) {
709
- const n = {
710
- ...k.modelValue
711
- };
712
- n.remark = t, y("update:modelValue", n);
713
- }
714
- }), a = T(() => {
715
- var n;
716
- const t = (n = V.stockBalance.skus) == null ? void 0 : n.find(($) => $.id === k.modelValue.doc._id);
717
- return (t == null ? void 0 : t.balance) ?? { amount: 0, precision: 0 };
718
- }), B = T(() => {
719
- const t = k.modelValue.amount, n = k.modelValue.measurement;
720
- return n ? xt(t, n.conversion) : t;
721
- }), v = T(
722
- () => k.isBackdate ? a.value : Qe(a.value, B.value)
723
- ), g = T(
724
- () => Qt(v.value, k.modelValue.doc.unit)
725
- ), o = T(
726
- () => !k.isBackdate && B.value.amount < 0
727
- );
728
- return (t, n) => {
729
- const $ = D("FmButton"), E = D("FmSelect"), N = D("FmTextarea"), O = D("FmCard");
730
- return j(), te(O, {
731
- variant: "outlined",
732
- class: "grid grid-cols-2 gap-8 p-16"
733
- }, {
734
- default: M(() => [
735
- e("div", Io, [
736
- e("div", Ho, [
737
- e("div", To, f(t.modelValue.doc.name), 1),
738
- e("div", Eo, f(t.modelValue.doc.code), 1)
739
- ]),
740
- _($, {
741
- variant: "tertiary",
742
- "prepend-icon": "delete",
743
- onClick: n[0] || (n[0] = (L) => y("click:delete"))
744
- })
745
- ]),
746
- _(E, {
747
- disabled: t.disabled,
748
- class: "col-span-2",
749
- label: "Type",
750
- items: d.value,
751
- modelValue: b.value,
752
- "onUpdate:modelValue": n[1] || (n[1] = (L) => b.value = L),
753
- rules: [s(qt)()],
754
- "label-mark": "required"
755
- }, null, 8, ["disabled", "items", "modelValue", "rules"]),
756
- _(Jt, {
757
- disabled: t.disabled,
758
- label: "Amount",
759
- step: +s(he)({
760
- amount: 1,
761
- precision: s($e)(t.modelValue.doc.unit, t.modelValue.measurement)
762
- }),
763
- modelValue: R.value,
764
- "onUpdate:modelValue": n[2] || (n[2] = (L) => R.value = L),
765
- rules: [s(Ue)(0)]
766
- }, null, 8, ["disabled", "step", "modelValue", "rules"]),
767
- _(E, {
768
- disabled: t.disabled,
769
- label: "Unit",
770
- items: r.value,
771
- modelValue: C.value,
772
- "onUpdate:modelValue": n[3] || (n[3] = (L) => C.value = L)
773
- }, null, 8, ["disabled", "items", "modelValue"]),
774
- _(N, {
775
- class: "col-span-2",
776
- disabled: t.disabled,
777
- label: "Remark",
778
- modelValue: l.value,
779
- "onUpdate:modelValue": n[4] || (n[4] = (L) => l.value = L),
780
- "label-mark": "optional"
781
- }, null, 8, ["disabled", "modelValue"]),
782
- e("div", Uo, [
783
- e("div", Po, f(s(w)("inventory.stock.stock_adjustment.stockAfter")), 1),
784
- e("div", {
785
- class: He(["fm-typo-en-body-lg-600", o.value ? "text-red-700" : "text-green-700"])
786
- }, f(g.value), 3),
787
- t.isBackdate ? (j(), q("div", Ro, f(s(w)("inventory.stock.stock_adjustment.backdatePreviewWarning")), 1)) : se("", !0)
788
- ])
789
- ]),
790
- _: 1
791
- });
792
- };
793
- }
794
- }), No = { class: "flex items-center" }, Oo = { class: "fm-typo-en-title-md-800" }, Lo = { class: "flex items-center" }, Yo = { class: "fm-typo-en-title-sm-800 flex-1" }, zo = { class: "flex gap-8" }, Go = /* @__PURE__ */ pe({
795
- __name: "AdjustSkuDialog",
796
- props: {
797
- stock: {},
798
- show: { type: Boolean }
799
- },
800
- emits: ["update:show", "submitted"],
801
- setup(A, { expose: c, emit: k }) {
802
- const y = A, w = k, V = Ne(), d = Le(), r = Ae(), b = we(), R = Y(!1), { t: C } = ye();
803
- function l() {
804
- g(Re(v));
805
- }
806
- const a = Y();
807
- c({
808
- validateInputs: () => {
809
- var n, $;
810
- ($ = (n = a.value) == null ? void 0 : n.validateInputs) == null || $.call(n);
811
- },
812
- resetInputsValidation: () => {
813
- var n, $;
814
- ($ = (n = a.value) == null ? void 0 : n.resetInputsValidation) == null || $.call(n);
815
- },
816
- resetInputs: () => {
817
- var n, $;
818
- ($ = (n = a.value) == null ? void 0 : n.resetInputs) == null || $.call(n);
819
- }
820
- });
821
- const B = Ye(y, "show"), v = _t({
822
- remark: "",
823
- adjustments: [
824
- {
825
- id: `sku_${(/* @__PURE__ */ new Date()).toISOString()}_${Math.random().toString(16).slice(2, 8)}`,
826
- type: ie.enum.PURCHASE,
827
- doc: y.stock,
828
- measurement: null,
829
- remark: "",
830
- amount: xe(1)
831
- }
832
- ]
833
- });
834
- Fe([() => y.show], ([n]) => {
835
- n && (v.remark = "", v.adjustments = [
836
- {
837
- id: `sku_${(/* @__PURE__ */ new Date()).toISOString()}_${Math.random().toString(16).slice(2, 8)}`,
838
- type: ie.enum.PURCHASE,
839
- doc: y.stock,
840
- measurement: null,
841
- remark: "",
842
- amount: xe(1)
843
- }
844
- ]);
845
- });
846
- async function g(n) {
847
- R.value = !0;
848
- try {
849
- await r.adjustSku({
850
- remark: n.remark,
851
- adjustments: n.adjustments.map(({ doc: $, remark: E, type: N, amount: O, measurement: L }) => ({
852
- id: $._id,
853
- amount: O,
854
- measurement: L,
855
- remark: E,
856
- doc: $,
857
- type: N
858
- }))
859
- }), w("update:show", !1), w("submitted");
860
- } catch ($) {
861
- b.open({
862
- title: C("inventory.stock.adjust.error.title"),
863
- message: C("inventory.stock.adjust.error.message"),
864
- type: "error"
865
- }), console.log("error on adjust ingredients", n, $);
866
- } finally {
867
- R.value = !1;
868
- }
869
- }
870
- function o() {
871
- const n = V.skus.map((E) => ({
872
- label: E.name,
873
- sublabel: E.code,
874
- value: E._id
875
- })), $ = n.filter((E) => v.adjustments.find((N) => N.doc._id === E.value)).map((E) => E.value);
876
- d.open({
877
- title: "Select ingredients",
878
- contentComponent: St,
879
- contentComponentProps: {
880
- items: n,
881
- modelValue: $
882
- },
883
- overlay: !0,
884
- closeButton: !0,
885
- dismissAway: !0,
886
- primaryActions: {
887
- text: "Confirm",
888
- close: !0
889
- },
890
- secondaryActions: {
891
- text: "Close",
892
- close: !0,
893
- variant: "tertiary"
894
- }
895
- }).onPrimary((E) => {
896
- v.adjustments = E.map(
897
- (N) => v.adjustments.find((O) => O.doc._id === N) ?? {
898
- id: `sku_${(/* @__PURE__ */ new Date()).toISOString()}_${Math.random().toString(16).slice(2, 8)}`,
899
- type: ie.enum.PURCHASE,
900
- doc: V.skus.find((O) => O._id === N),
901
- measurement: null,
902
- remark: "",
903
- amount: xe(1)
904
- }
905
- );
906
- });
907
- }
908
- function t(n) {
909
- v.adjustments.splice(n, 1);
910
- }
911
- return (n, $) => {
912
- const E = D("FmTextarea"), N = D("FmButton"), O = D("FmForm"), L = D("FmSideSheet");
913
- return j(), te(L, {
914
- modelValue: s(B),
915
- "onUpdate:modelValue": $[2] || ($[2] = (X) => Pe(B) ? B.value = X : null),
916
- "dismiss-away": "",
917
- "max-width": 500
918
- }, {
919
- "side-sheet-header": M(() => [
920
- e("div", No, [
921
- e("div", Oo, f(s(C)("inventory.stock.adjust.title")), 1)
922
- ])
923
- ]),
924
- default: M(() => [
925
- _(O, {
926
- class: "w-full flex flex-col gap-12",
927
- ref_key: "formRef",
928
- ref: a,
929
- onValidationSuccess: l
930
- }, {
931
- default: M(() => [
932
- _(E, {
933
- label: s(C)("inventory.stock.adjust.remark"),
934
- modelValue: v.remark,
935
- "onUpdate:modelValue": $[0] || ($[0] = (X) => v.remark = X)
936
- }, null, 8, ["label", "modelValue"]),
937
- e("div", Lo, [
938
- e("div", Yo, f(s(C)("inventory.stock.adjust.adjustedItems")), 1),
939
- _(N, {
940
- "prepend-icon": "add",
941
- variant: "tertiary",
942
- size: "md",
943
- onClick: o
944
- })
945
- ]),
946
- (j(!0), q(ue, null, ve(v.adjustments, (X, z) => (j(), te($t, {
947
- key: X.id,
948
- modelValue: v.adjustments[z],
949
- "onUpdate:modelValue": (K) => v.adjustments[z] = K,
950
- "onClick:delete": (K) => t(z)
951
- }, null, 8, ["modelValue", "onUpdate:modelValue", "onClick:delete"]))), 128))
952
- ]),
953
- _: 1
954
- }, 512)
955
- ]),
956
- "side-sheet-footer": M(() => [
957
- e("div", zo, [
958
- _(N, {
959
- label: s(C)("inventory.stock.adjust.adjustButton"),
960
- loading: R.value,
961
- onClick: $[1] || ($[1] = (X) => {
962
- var z, K;
963
- return (K = (z = a.value) == null ? void 0 : z.validateInputs) == null ? void 0 : K.call(z);
964
- })
965
- }, null, 8, ["label", "loading"])
966
- ])
967
- ]),
968
- _: 1
969
- }, 8, ["modelValue"]);
970
- };
971
- }
972
- }), Wo = { class: "flex items-center w-full gap-8" }, Ko = { class: "fm-typo-en-title-md-800 flex-1" }, qo = {
973
- key: 0,
974
- class: "flex flex-col gap-4"
975
- }, Xo = { class: "fm-typo-en-body-md-600" }, Jo = { class: "flex gap-8 items-start" }, Qo = { class: "flex-1 min-w-0" }, Zo = { class: "flex-1 min-w-0" }, en = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, tn = { class: "flex items-center" }, on = { class: "fm-typo-en-title-sm-800 flex-1" }, nn = { class: "flex gap-8" }, yt = 14, sn = /* @__PURE__ */ pe({
976
- __name: "StockAdjustmentSideSheet",
977
- props: {
978
- show: { type: Boolean }
979
- },
980
- emits: ["update:show", "submitted"],
981
- setup(A, { emit: c }) {
982
- const k = A, y = c, { t: w } = ye(), V = Ne(), d = Ae(), r = Le(), b = we(), R = Ye(k, "show"), C = Y(!1), l = _t({
983
- remark: "",
984
- effectiveAt: /* @__PURE__ */ new Date(),
985
- adjustments: []
986
- }), a = Y(!1), B = Y(ke().format("YYYY-MM-DD")), v = Y(ke().format("HH:mm")), g = Y();
987
- Fe([B, v], () => {
988
- if (B.value && v.value) {
989
- const K = ke(`${B.value} ${v.value}`, "YYYY-MM-DD HH:mm");
990
- K.isValid() && (l.effectiveAt = K.toDate());
991
- }
992
- });
993
- const o = T(() => `${B.value} ${v.value}`);
994
- function t() {
995
- if (!a.value) return !0;
996
- const K = ke(`${B.value} ${v.value}`, "YYYY-MM-DD HH:mm");
997
- if (!K.isValid()) return w("inventory.stock.stock_adjustment.invalidDateTime");
998
- const U = ke();
999
- if (K.isAfter(U))
1000
- return w("inventory.stock.stock_adjustment.futureDateNotAllowed");
1001
- const Z = U.subtract(yt, "day");
1002
- return K.isBefore(Z) ? w("inventory.stock.stock_adjustment.backdateLimitError", { days: yt }) : !0;
1003
- }
1004
- const n = T(() => [() => t()]), $ = T(() => l.adjustments.length === 0 || t() !== !0);
1005
- function E() {
1006
- l.remark = "", l.effectiveAt = /* @__PURE__ */ new Date(), l.adjustments = [], a.value = !1, B.value = ke(l.effectiveAt).format("YYYY-MM-DD"), v.value = ke(l.effectiveAt).format("HH:mm");
1007
- }
1008
- function N() {
1009
- E();
1010
- }
1011
- const O = T(() => {
1012
- const K = {};
1013
- return V.skus.forEach((U) => {
1014
- K[U._id] = U;
1015
- }), K;
1016
- });
1017
- function L() {
1018
- const K = V.skus.map((Z) => ({
1019
- label: Z.name,
1020
- sublabel: Z.code,
1021
- value: Z._id
1022
- })), U = l.adjustments.map((Z) => Z.doc._id);
1023
- r.open({
1024
- title: w("inventory.stock.adjust.selectIngredients"),
1025
- contentComponent: St,
1026
- contentComponentProps: {
1027
- items: K,
1028
- modelValue: U,
1029
- virtualScroll: !0
1030
- },
1031
- overlay: !0,
1032
- closeButton: !0,
1033
- dismissAway: !0,
1034
- primaryActions: {
1035
- text: w("common.confirm"),
1036
- close: !0
1037
- },
1038
- secondaryActions: {
1039
- text: w("common.close"),
1040
- close: !0,
1041
- variant: "tertiary"
1042
- }
1043
- }).onPrimary((Z) => {
1044
- l.adjustments = Z.map(
1045
- (re) => l.adjustments.find((x) => x.doc._id === re) ?? {
1046
- id: "",
1047
- type: ie.enum.PURCHASE,
1048
- doc: O.value[re],
1049
- measurement: null,
1050
- remark: "",
1051
- amount: xe(1)
1052
- }
1053
- );
1054
- });
1055
- }
1056
- function X(K) {
1057
- l.adjustments.splice(K, 1);
1058
- }
1059
- async function z() {
1060
- if (l.adjustments.length === 0) {
1061
- b.open({
1062
- title: w("inventory.stock.error.title"),
1063
- message: w("inventory.stock.stock_adjustment.noAdjustments"),
1064
- type: "warning"
1065
- });
1066
- return;
1067
- }
1068
- C.value = !0;
1069
- try {
1070
- const K = l.adjustments.map(
1071
- ({ doc: Z, remark: re, type: x, amount: F, measurement: G }) => ({
1072
- id: Z._id,
1073
- amount: F,
1074
- measurement: G,
1075
- remark: re,
1076
- doc: Z,
1077
- type: x
1078
- })
1079
- ), U = {
1080
- remark: l.remark,
1081
- adjustments: K,
1082
- ...a.value ? { effectiveAt: l.effectiveAt.toISOString() } : {}
1083
- };
1084
- await d.adjustSku(Re(U)), y("submitted"), y("update:show", !1);
1085
- } catch (K) {
1086
- b.open({
1087
- title: w("inventory.stock.adjust.error.title"),
1088
- message: w("inventory.stock.adjust.error.message"),
1089
- type: "error"
1090
- }), console.error("error on stock adjustment", K);
1091
- } finally {
1092
- C.value = !1;
1093
- }
1094
- }
1095
- return (K, U) => {
1096
- const Z = D("FmTextarea"), re = D("FmSwitch"), x = D("FmDatePicker"), F = D("FmTimePicker"), G = D("FmFormGroup"), H = D("FmButton"), J = D("FmForm"), I = D("FmSideSheet");
1097
- return j(), te(I, {
1098
- modelValue: s(R),
1099
- "onUpdate:modelValue": U[6] || (U[6] = (u) => Pe(R) ? R.value = u : null),
1100
- "dismiss-away": "",
1101
- "max-width": 560,
1102
- onAfterEnter: N
1103
- }, {
1104
- "side-sheet-header": M(() => [
1105
- e("div", Wo, [
1106
- e("div", Ko, f(s(w)("inventory.stock.stock_adjustment.title")), 1)
1107
- ])
1108
- ]),
1109
- default: M(() => [
1110
- _(J, {
1111
- class: "flex flex-col gap-16",
1112
- ref_key: "formRef",
1113
- ref: g,
1114
- onValidationSuccess: z
1115
- }, {
1116
- default: M(() => [
1117
- _(Z, {
1118
- label: s(w)("inventory.stock.adjust.remark"),
1119
- modelValue: l.remark,
1120
- "onUpdate:modelValue": U[0] || (U[0] = (u) => l.remark = u),
1121
- "label-mark": "optional"
1122
- }, null, 8, ["label", "modelValue"]),
1123
- _(re, {
1124
- value: "",
1125
- "model-value": a.value,
1126
- "onUpdate:modelValue": U[1] || (U[1] = (u) => a.value = u),
1127
- label: s(w)("inventory.stock.stock_adjustment.backdateLabel"),
1128
- sublabel: s(w)("inventory.stock.stock_adjustment.backdateSublabel"),
1129
- labelPlacement: "right"
1130
- }, null, 8, ["model-value", "label", "sublabel"]),
1131
- a.value ? (j(), q("div", qo, [
1132
- e("label", Xo, f(s(w)("inventory.stock.stock_adjustment.effectiveAt")), 1),
1133
- e("div", Jo, [
1134
- e("div", Qo, [
1135
- _(x, {
1136
- class: "w-full",
1137
- modelValue: B.value,
1138
- "onUpdate:modelValue": U[2] || (U[2] = (u) => B.value = u),
1139
- clearable: !1
1140
- }, null, 8, ["modelValue"])
1141
- ]),
1142
- e("div", Zo, [
1143
- _(F, {
1144
- class: "w-full",
1145
- modelValue: v.value,
1146
- "onUpdate:modelValue": U[3] || (U[3] = (u) => v.value = u),
1147
- format: "HH:mm"
1148
- }, null, 8, ["modelValue"])
1149
- ])
1150
- ]),
1151
- _(G, {
1152
- "model-value": o.value,
1153
- rules: n.value
1154
- }, null, 8, ["model-value", "rules"]),
1155
- e("div", en, f(s(w)("inventory.stock.stock_adjustment.immediateHint")), 1)
1156
- ])) : se("", !0),
1157
- e("div", tn, [
1158
- e("div", on, f(s(w)("inventory.stock.adjust.adjustedItems")), 1),
1159
- _(H, {
1160
- "prepend-icon": "add",
1161
- variant: "tertiary",
1162
- size: "md",
1163
- onClick: L
1164
- })
1165
- ]),
1166
- (j(!0), q(ue, null, ve(l.adjustments, (u, h) => (j(), te($t, {
1167
- key: u.doc._id,
1168
- modelValue: l.adjustments[h],
1169
- "onUpdate:modelValue": (p) => l.adjustments[h] = p,
1170
- "is-backdate": a.value,
1171
- "onClick:delete": (p) => X(h)
1172
- }, null, 8, ["modelValue", "onUpdate:modelValue", "is-backdate", "onClick:delete"]))), 128))
1173
- ]),
1174
- _: 1
1175
- }, 512)
1176
- ]),
1177
- "side-sheet-footer": M(() => [
1178
- e("div", nn, [
1179
- _(H, {
1180
- label: s(w)("common.confirm"),
1181
- loading: C.value,
1182
- disabled: $.value,
1183
- onClick: U[4] || (U[4] = (u) => {
1184
- var h, p;
1185
- return (p = (h = g.value) == null ? void 0 : h.validateInputs) == null ? void 0 : p.call(h);
1186
- })
1187
- }, null, 8, ["label", "loading", "disabled"]),
1188
- _(H, {
1189
- label: s(w)("common.close"),
1190
- variant: "tertiary",
1191
- onClick: U[5] || (U[5] = (u) => y("update:show", !1))
1192
- }, null, 8, ["label"])
1193
- ])
1194
- ]),
1195
- _: 1
1196
- }, 8, ["modelValue"]);
1197
- };
1198
- }
1199
- }), an = Tt((A, c) => ({
1200
- // TODO: remove once latest inventory backend has been push
1201
- async findBillsByBusinessId(k, y, w) {
1202
- const V = `${A.businessesBackendUrl}/${k}/reports/find-many`, d = {
1203
- // type: TYPE.bill,
1204
- type: "bill",
1205
- restaurantIds: y,
1206
- ids: w
1207
- };
1208
- return await c.post(V, d);
1209
- },
1210
- async findBillsById(k) {
1211
- const w = Se().currentLocationDBName, V = `${A.inventoryBackendUrl}/${w}/bill/search`, d = {
1212
- ids: k
1213
- };
1214
- return await c.post(V, d);
1215
- }
1216
- })), rn = {
1217
- key: 0,
1218
- class: "flex justify-center items-center h-32"
1219
- }, ln = { class: "mb-3" }, un = { class: "flex flex-col gap-8" }, cn = { class: "flex flex-col text-fm-color-typo-primary mb-3 text-center" }, dn = { class: "text-fm-color-neutral-gray-400 fm-typo-en-body-sm-600" }, mn = { class: "flex flex-col gap-4 text-fm-color-typo-primary mb-3" }, fn = { class: "flex flex-col gap-4 text-fm-color-typo-primary mb-3" }, vn = { class: "flex flex-col gap-4 text-fm-color-typo-primary mb-3" }, pn = { class: "flex flex-col w-full px-2" }, yn = { class: "flex gap-2" }, _n = /* @__PURE__ */ pe({
1220
- __name: "AmendAdjustmentForm",
1221
- props: /* @__PURE__ */ nt({
1222
- adjustmentId: {}
1223
- }, {
1224
- modelValue: {},
1225
- modelModifiers: {}
1226
- }),
1227
- emits: /* @__PURE__ */ nt(["refreshHistory"], ["update:modelValue"]),
1228
- setup(A, { emit: c }) {
1229
- const k = A, y = c, w = Ae(), V = jt(A, "modelValue"), d = Y(!1), r = Y(!1), b = Y(!1), R = Y({
1230
- _id: `inventoryAdjustment_${(/* @__PURE__ */ new Date()).toISOString()}_XXXXX`,
1231
- skus: []
1232
- }), C = Y();
1233
- qe(async () => {
1234
- d.value = !0;
1235
- const o = await w.readSingleAdjustment(k.adjustmentId);
1236
- if (!o) throw new Error("Adjustment not found");
1237
- R.value = o, d.value = !1;
1238
- });
1239
- async function l() {
1240
- var t, n;
1241
- if ((n = (t = C == null ? void 0 : C.value) == null ? void 0 : t.validateInputs) == null || n.call(t), !r.value) return;
1242
- const o = {};
1243
- Object.keys(V.value || {}).forEach(($) => {
1244
- var E;
1245
- Object.keys(((E = V.value) == null ? void 0 : E[$]) || {}).forEach((N) => {
1246
- var L, X;
1247
- const O = (X = (L = V.value) == null ? void 0 : L[$]) == null ? void 0 : X[Number(N)];
1248
- O && B(O.amount) > 0 && (o[$] || (o[$] = []), o[$].push(O));
1249
- });
1250
- }), await w.revertWastageAdjustment({
1251
- targetWastageAdjustmentId: k.adjustmentId,
1252
- amountsGoingToAdjust: o
1253
- }), y("refreshHistory"), b.value = !1, V.value = {};
1254
- }
1255
- function a(o) {
1256
- const { skuId: t, idx: n, unit: $, measurement: E } = o;
1257
- return T({
1258
- get: () => {
1259
- var L, X, z;
1260
- const N = (z = (X = (L = V.value) == null ? void 0 : L[t]) == null ? void 0 : X[n]) == null ? void 0 : z.amount;
1261
- return N ? Number(_e.toFormatString({ value: N })) : 0;
1262
- },
1263
- set: (N) => {
1264
- V.value || (V.value = {});
1265
- const O = { ...V.value };
1266
- O[t] || (O[t] = {}), O[t][n] = {
1267
- amount: _e.convertPrecision({
1268
- value: _e.fromNumber(N),
1269
- precision: $e($)
1270
- }),
1271
- type: ie.Enum.WASTAGE,
1272
- measurement: E
1273
- }, V.value = O;
1274
- }
1275
- });
1276
- }
1277
- function B(o, t = !0) {
1278
- const n = Number(_e.toFormatString({ value: o }));
1279
- return t ? Math.abs(n) : n;
1280
- }
1281
- function v(o, t) {
1282
- return t.measurement ? t.measurement.abbrev : o.sku.unit.abbrev;
1283
- }
1284
- function g(o, t) {
1285
- if (t.amount === 0) return "N/A";
1286
- const n = _e.add([o, t]);
1287
- return n ? _e.toFormatString({ value: n }) : "N/A";
1288
- }
1289
- return (o, t) => {
1290
- const n = D("FmIcon"), $ = D("FmStepperField"), E = D("FmCard"), N = D("FmForm"), O = D("FmSpacer"), L = D("FmButton"), X = D("FmDialog");
1291
- return j(), te(X, {
1292
- modelValue: b.value,
1293
- "onUpdate:modelValue": t[4] || (t[4] = (z) => b.value = z),
1294
- overlay: !0
1295
- }, {
1296
- "dialog-button": M(() => [
1297
- _(Je, null, {
1298
- default: M(() => [
1299
- e("button", {
1300
- onClick: t[0] || (t[0] = (z) => b.value = !0),
1301
- class: "rounded-md hover:bg-gray-100 transition-colors"
1302
- }, [
1303
- _(n, {
1304
- name: "edit",
1305
- size: "sm"
1306
- })
1307
- ])
1308
- ]),
1309
- _: 1
1310
- })
1311
- ]),
1312
- "dialog-header": M(() => t[5] || (t[5] = [
1313
- e("div", null, "Amend Adjustment", -1)
1314
- ])),
1315
- "dialog-footer": M(() => [
1316
- e("div", pn, [
1317
- t[13] || (t[13] = e("span", { class: "text-fm-color-system-warning-400 fm-typo-en-body-sm-400" }, "1. New adjustment EXTRA will be created for each reversal", -1)),
1318
- e("div", yn, [
1319
- _(O),
1320
- _(L, {
1321
- class: "sm:w-full xs:w-full",
1322
- label: "Close",
1323
- size: "md",
1324
- variant: "tertiary",
1325
- onClick: t[3] || (t[3] = (z) => b.value = !1)
1326
- }),
1327
- _(L, {
1328
- class: "sm:w-full xs:w-full",
1329
- label: "Submit",
1330
- size: "md",
1331
- variant: "primary",
1332
- onClick: l
1333
- })
1334
- ])
1335
- ])
1336
- ]),
1337
- default: M(() => [
1338
- d.value ? (j(), q("div", rn)) : (j(), te(N, {
1339
- key: 1,
1340
- ref_key: "formRef",
1341
- ref: C,
1342
- onValidationFailed: t[1] || (t[1] = () => {
1343
- r.value = !1;
1344
- }),
1345
- onValidationSuccess: t[2] || (t[2] = () => {
1346
- r.value = !0;
1347
- }),
1348
- blameFormChildOnValidationFailed: ""
1349
- }, {
1350
- default: M(() => [
1351
- e("p", ln, [
1352
- t[6] || (t[6] = e("b", null, "Date:", -1)),
1353
- t[7] || (t[7] = e("br", null, null, -1)),
1354
- me(" " + f(s(Zt)(s(Et)(R.value._id))), 1)
1355
- ]),
1356
- e("div", un, [
1357
- (j(!0), q(ue, null, ve(R.value.skus, (z, K) => (j(), q(ue, { key: K }, [
1358
- (j(!0), q(ue, null, ve(z.amounts, (U, Z) => (j(), te(E, {
1359
- key: Z,
1360
- variant: "outlined",
1361
- class: "p-2"
1362
- }, {
1363
- default: M(() => [
1364
- e("div", cn, [
1365
- e("span", dn, f(z.sku.code), 1),
1366
- e("span", null, f(z.sku.name), 1)
1367
- ]),
1368
- t[12] || (t[12] = e("hr", { class: "m-2" }, null, -1)),
1369
- e("div", mn, [
1370
- t[8] || (t[8] = e("span", { class: "fm-typo-en-body-lg-600" }, "Adjustment type:", -1)),
1371
- e("span", null, f(U.type), 1)
1372
- ]),
1373
- e("div", fn, [
1374
- t[9] || (t[9] = e("span", { class: "fm-typo-en-body-lg-600" }, "Current amount:", -1)),
1375
- e("span", null, f(s(_e).toFormatString({ value: U.amount })) + " " + f(v(z, U)), 1)
1376
- ]),
1377
- _($, {
1378
- "max-fraction-digits": s($e)(z.sku.unit),
1379
- "model-value": a({
1380
- skuId: z.sku._id,
1381
- idx: Z,
1382
- unit: z.sku.unit
1383
- }).value,
1384
- "onUpdate:modelValue": (re) => a({
1385
- skuId: z.sku._id,
1386
- idx: Z,
1387
- unit: z.sku.unit
1388
- }).value = re,
1389
- class: "mb-3",
1390
- label: "Adjust Amount (Leave 0 to skip)",
1391
- "helper-text": `Max: ${B(U.amount)}`,
1392
- "append-text": v(z, U),
1393
- rules: [
1394
- (re) => re <= B(U.amount) || `Cannot be more than ${B(U.amount)}`,
1395
- s(Ue)(-1)
1396
- ]
1397
- }, null, 8, ["max-fraction-digits", "model-value", "onUpdate:modelValue", "helper-text", "append-text", "rules"]),
1398
- e("div", vn, [
1399
- t[10] || (t[10] = e("span", { class: "fm-typo-en-body-lg-600" }, "Amount after amend:", -1)),
1400
- t[11] || (t[11] = e("span", { class: "text-fm-color-system-warning-400 fm-typo-en-body-sm-400" }, "* It's an estimate for your reference, as it didn't include all the reversals related to this adjustment", -1)),
1401
- me(" " + f(g(
1402
- U.amount,
1403
- s(_e).fromNumber(
1404
- a({
1405
- skuId: z.sku._id,
1406
- idx: Z,
1407
- unit: z.sku.unit
1408
- }).value
1409
- )
1410
- )) + " " + f(v(z, U)), 1)
1411
- ])
1412
- ]),
1413
- _: 2
1414
- }, 1024))), 128))
1415
- ], 64))), 128))
1416
- ])
1417
- ]),
1418
- _: 1
1419
- }, 512))
1420
- ]),
1421
- _: 1
1422
- }, 8, ["modelValue"]);
1423
- };
1424
- }
1425
- }), kn = { class: "p-16" }, hn = { class: "fm-typo-en-body-md-600 flex-grow" }, bn = { class: "flex-grow text-fm-color-typo-secondary" }, gn = {
1426
- key: 0,
1427
- class: "my-5"
1428
- }, xn = { class: "text-neutral-400" }, Sn = { class: "flex-grow" }, wn = { class: "flex gap-1" }, An = { class: "flex flex-col gap-1" }, Fn = {
1429
- key: 1,
1430
- class: "t-system text-fsecondary"
1431
- }, $n = {
1432
- key: 2,
1433
- class: "text-xs text-gray-400"
1434
- }, jn = { key: 3 }, Vn = { key: 4 }, Cn = { class: "inline-flex items-center gap-0.5 text-fm-color-typo-secondary" }, Bn = {
1435
- key: 6,
1436
- class: "inline-flex items-center rounded-md bg-yellow-400/10 px-2 text-xs font-medium text-yellow-500 inset-ring inset-ring-yellow-400/20"
1437
- }, Dn = {
1438
- key: 1,
1439
- class: "shrink-0 text-fm-color-typo-secondary"
1440
- }, Mn = /* @__PURE__ */ pe({
1441
- __name: "StockRecordCard",
1442
- props: {
1443
- record: {},
1444
- sku: {},
1445
- bills: { default: () => [] },
1446
- unitCostHistory: { default: () => [] },
1447
- costMechanism: { default: "adjustment" }
1448
- },
1449
- setup(A) {
1450
- const c = A;
1451
- function k(C, l) {
1452
- if (c.costMechanism === "adjustment")
1453
- return null;
1454
- const a = c.unitCostHistory.filter(
1455
- (g) => g.mechanism === c.costMechanism && g.skuId === c.sku._id
1456
- );
1457
- if (a.length === 0) return null;
1458
- const B = a.find((g) => {
1459
- const o = g.meta;
1460
- return (o == null ? void 0 : o.adjustmentId) === C;
1461
- });
1462
- if (B) return B.cost;
1463
- const v = [...a].filter((g) => new Date(g.snapshotAt) <= new Date(l)).sort((g, o) => new Date(o.snapshotAt).getTime() - new Date(g.snapshotAt).getTime());
1464
- return v.length > 0 ? v[0].cost : null;
1465
- }
1466
- const y = Y(!1), w = Y(), V = Y(null), d = T(() => V.value === null ? "unset" : y.value ? `${V.value}px` : "0px");
1467
- qe(() => {
1468
- var C;
1469
- V.value = ((C = w.value) == null ? void 0 : C.scrollHeight) || 0;
1470
- });
1471
- const r = T(() => {
1472
- var g;
1473
- const C = c.record.adjustments, l = c.sku, a = {}, v = C.flatMap((o) => {
1474
- var t;
1475
- return ((t = o.skus) == null ? void 0 : t.filter((n) => n.sku._id === l._id)) ?? [];
1476
- }).flatMap((o) => o.amounts);
1477
- for (const o of v) {
1478
- const t = o.measurement ? xt(o.measurement.conversion, o.amount) : o.amount;
1479
- a[g = o.type] ?? (a[g] = { amount: 0, precision: 0 }), a[o.type] = Qe(t, a[o.type]);
1480
- }
1481
- return Object.entries(a).reduce(
1482
- (o, [t, n]) => (o[t] = /// comment, because without it formatter makes code uglier
1483
- `${ne.toFormatString({
1484
- value: n,
1485
- precision: 4
1486
- })} ${l.unit.abbrev}`, o),
1487
- {}
1488
- );
1489
- }), { t: b } = ye(), R = T(() => c.record.adjustmentsByTime.map(({ date: C, adjustments: l }) => ({
1490
- time: eo(new Date(C)),
1491
- adjustments: l.flatMap(
1492
- (a) => {
1493
- var B, v;
1494
- return ((v = (B = a.skus) == null ? void 0 : B.map) == null ? void 0 : v.call(B, (g) => {
1495
- var o, t;
1496
- return {
1497
- ...g,
1498
- ref: a.ref,
1499
- reason: a.reason,
1500
- adjustmentRemark: a.remark,
1501
- backdateFrom: a.effectiveAt != null ? Te(a._id) : null,
1502
- toBalance: (t = (o = a.skus) == null ? void 0 : o[0]) == null ? void 0 : t.toBalance,
1503
- adjustmentId: a._id,
1504
- adjustmentTime: a.effectiveAt ?? Te(a._id),
1505
- createdBy: a.createdBy
1506
- };
1507
- })) ?? [];
1508
- }
1509
- ).flatMap((a) => {
1510
- var t;
1511
- const B = (t = c.bills.find((n) => n._id === a.ref)) == null ? void 0 : t.seqNumber, v = B ? b("inventory.stock.record.bill", [B]) : "", g = a.adjustmentTime ?? (/* @__PURE__ */ new Date()).toISOString(), o = k(a.adjustmentId, g);
1512
- return (a.amounts || []).filter((n) => n != null).map((n) => {
1513
- var N;
1514
- let $ = n.cost;
1515
- if (o) {
1516
- const O = ne.fromDinero(o), L = n.amount, X = n.measurement ? ne.multiply([L, n.measurement.conversion]) : L;
1517
- $ = {
1518
- ...ne.multiply([
1519
- O,
1520
- X
1521
- ]),
1522
- currency: o.currency
1523
- };
1524
- }
1525
- let E = "";
1526
- return v ? E = n.remark || "" : E = [a.adjustmentRemark, n.remark].filter((L) => L).join("/"), {
1527
- amount: `${ne.toFormatString({ value: n.amount, precision: 4 })} ${((N = n.measurement) == null ? void 0 : N.abbrev) ?? a.sku.unit.abbrev}`,
1528
- backdateFrom: a.backdateFrom,
1529
- name: n.type,
1530
- billRemark: v,
1531
- remark: E,
1532
- reason: a.reason || "",
1533
- cost: $,
1534
- toBalance: ne.toFormatString({
1535
- value: a.toBalance ?? ne.fromNumber(0),
1536
- precision: 4
1537
- }),
1538
- baseUnit: a.sku.unit.abbrev,
1539
- adjustmentId: a.adjustmentId,
1540
- createdBy: a.createdBy
1541
- };
1542
- });
1543
- })
1544
- })));
1545
- return (C, l) => {
1546
- const a = D("FmIcon"), B = D("FmTooltip"), v = D("FmCard");
1547
- return j(), te(v, { variant: "outlined" }, {
1548
- default: M(() => [
1549
- e("div", kn, [
1550
- e("div", {
1551
- class: "flex items-center cursor-pointer mb-1",
1552
- onClick: l[0] || (l[0] = (g) => y.value = !y.value)
1553
- }, [
1554
- e("div", hn, f(C.record.date), 1),
1555
- _(a, {
1556
- name: y.value ? "expand_more" : "expand_less",
1557
- color: "#777777",
1558
- size: "md"
1559
- }, null, 8, ["name"])
1560
- ]),
1561
- (j(!0), q(ue, null, ve(r.value, (g, o) => (j(), q("div", {
1562
- key: o,
1563
- class: "flex flex-row py-1",
1564
- style: { "font-size": "0.8rem" }
1565
- }, [
1566
- e("div", bn, f(s(b)(`inventory.inventoryAdjustment.type.${o}`)), 1),
1567
- e("div", {
1568
- class: He({
1569
- "text-fm-color-typo-error": g.startsWith("-"),
1570
- "text-fm-color-typo-success": !g.startsWith("-"),
1571
- "ml-auto": !0
1572
- })
1573
- }, f(g), 3)
1574
- ]))), 128)),
1575
- e("div", {
1576
- ref_key: "detailRef",
1577
- ref: w,
1578
- style: kt({
1579
- fontSize: "0.8rem",
1580
- maxHeight: d.value,
1581
- overflow: "hidden",
1582
- transition: "max-height 0.2s ease-out"
1583
- })
1584
- }, [
1585
- R.value.length ? (j(), q("hr", gn)) : se("", !0),
1586
- (j(!0), q(ue, null, ve(R.value, (g) => (j(), q("div", {
1587
- key: g.time,
1588
- class: "flex gap-1 w-full"
1589
- }, [
1590
- e("div", xn, f(g.time), 1),
1591
- e("div", Sn, [
1592
- (j(!0), q(ue, null, ve(g.adjustments, (o) => {
1593
- var t;
1594
- return j(), q("div", {
1595
- key: o.name,
1596
- class: "flex gap-1"
1597
- }, [
1598
- e("div", wn, [
1599
- me(f(s(b)(`inventory.inventoryAdjustment.type.${o.name}`)) + " ", 1),
1600
- o.backdateFrom ? (j(), te(B, {
1601
- key: 0,
1602
- variant: "plain",
1603
- placement: "top",
1604
- "z-index": 50
1605
- }, {
1606
- content: M(() => [
1607
- e("div", An, f(s(b)("inventory.stock.record.backdate", [
1608
- s(wt)(new Date(o.backdateFrom))
1609
- ])), 1)
1610
- ]),
1611
- default: M(() => [
1612
- _(a, {
1613
- name: "info",
1614
- size: "sm",
1615
- color: "primary"
1616
- })
1617
- ]),
1618
- _: 2
1619
- }, 1024)) : se("", !0),
1620
- o.billRemark ? (j(), q("span", Fn, " # " + f(o.billRemark), 1)) : se("", !0),
1621
- o.billRemark && o.remark ? (j(), q("span", $n, " (" + f(o.remark) + ") ", 1)) : se("", !0),
1622
- !o.billRemark && o.reason ? (j(), q("span", jn, " (" + f(o.reason) + ") ", 1)) : se("", !0),
1623
- !o.billRemark && o.remark ? (j(), q("span", Vn, " # " + f(o.remark), 1)) : se("", !0),
1624
- (t = o.createdBy) != null && t.name ? (j(), te(B, {
1625
- key: 5,
1626
- variant: "plain",
1627
- placement: "top",
1628
- "z-index": 50
1629
- }, {
1630
- content: M(() => [
1631
- me(f(s(b)("inventory.stock.record.createdBy", [o.createdBy.name])), 1)
1632
- ]),
1633
- default: M(() => [
1634
- e("span", Cn, [
1635
- _(a, {
1636
- name: "person",
1637
- size: "sm",
1638
- color: "primary"
1639
- }),
1640
- me(" " + f(o.createdBy.name), 1)
1641
- ])
1642
- ]),
1643
- _: 2
1644
- }, 1024)) : se("", !0),
1645
- o.name === s(ie).Enum.CLOSING ? (j(), q("span", Bn, " Actual Balance: " + f(o.toBalance) + " " + f(o.baseUnit), 1)) : se("", !0)
1646
- ]),
1647
- e("div", {
1648
- class: He({
1649
- "text-fm-color-typo-error": o.amount.startsWith("-"),
1650
- "text-fm-color-typo-success": !o.amount.startsWith("-"),
1651
- "ml-auto": !0
1652
- })
1653
- }, f(o.amount), 3),
1654
- o.name === s(ie).Enum.WASTAGE ? (j(), te(_n, {
1655
- key: 0,
1656
- adjustmentId: o.adjustmentId,
1657
- onRefreshHistory: l[1] || (l[1] = (n) => C.$emit("refreshHistory"))
1658
- }, null, 8, ["adjustmentId"])) : se("", !0),
1659
- o.cost ? (j(), q("div", Dn, " (" + f(s(Me)(o.cost, !1, o.cost.precision)) + ") ", 1)) : se("", !0)
1660
- ]);
1661
- }), 128))
1662
- ])
1663
- ]))), 128))
1664
- ], 4)
1665
- ])
1666
- ]),
1667
- _: 1
1668
- });
1669
- };
1670
- }
1671
- });
1672
- function In(A, c) {
1673
- var V;
1674
- const k = Object.keys(ie.enum).reduce(
1675
- (d, r) => (d[r] = { amount: 0, precision: 0 }, d),
1676
- {}
1677
- );
1678
- if (!c)
1679
- return Object.entries(k).reduce(
1680
- (d, [r]) => (d[r] = ne.fromNumber(0), d),
1681
- {}
1682
- );
1683
- const w = A.flatMap((d) => {
1684
- var r;
1685
- return ((r = d.skus) == null ? void 0 : r.filter((b) => b.sku._id === c._id)) ?? [];
1686
- }).flatMap((d) => d.amounts);
1687
- for (const d of w) {
1688
- const r = d.measurement ? ne.multiply([d.measurement.conversion, d.amount]) : d.amount;
1689
- k[V = d.type] ?? (k[V] = { amount: 0, precision: 0 }), k[d.type] = ne.add([r, k[d.type]]);
1690
- }
1691
- return Object.entries(k).reduce(
1692
- (d, [r, b]) => {
1693
- const R = {
1694
- ...b,
1695
- amount: Math.abs(b.amount)
1696
- };
1697
- return d[r] = /// comment, because without it formatter makes code uglier
1698
- `${ne.toFormatString({
1699
- value: R,
1700
- precision: 4
1701
- })} ${c.unit.abbrev}`, d;
1702
- },
1703
- {}
1704
- );
1705
- }
1706
- function Hn(A, c) {
1707
- if (!c)
1708
- return null;
1709
- let k = null;
1710
- const w = A.flatMap((V) => {
1711
- var d;
1712
- return ((d = V.skus) == null ? void 0 : d.filter((r) => r.sku._id === c._id)) ?? [];
1713
- }).flatMap((V) => {
1714
- var d;
1715
- return !V.history || ((d = V.history) == null ? void 0 : d.length) === 0 ? [] : V.history[0];
1716
- });
1717
- for (const V of w) {
1718
- const d = V.amounts;
1719
- for (const r of d) {
1720
- if (r.type !== ie.Enum.SALES)
1721
- continue;
1722
- const b = r.measurement ? ne.multiply([r.measurement.conversion, r.amount]) : r.amount;
1723
- k ?? (k = ne.fromNumber(0)), k = ne.add([k, b]);
1724
- }
1725
- }
1726
- return k != null ? (k.amount = Math.abs(k.amount), `${ne.toFormatString({
1727
- value: k,
1728
- precision: 4
1729
- })} ${c.unit.abbrev}`) : null;
1730
- }
1731
- const Tn = { class: "flex items-center w-full fm-typo-en-title-md-800" }, En = { class: "flex-1 line-clamp-2" }, Un = { class: "flex flex-col gap-32 w-full h-full" }, Pn = { class: "flex items-center relative gap-4" }, Rn = { class: "flex-1" }, Nn = {
1732
- key: 0,
1733
- class: "flex-1 flex flex-col items-center gap-16"
1734
- }, On = { class: "fm-typo-en-body-lg-400 translate-x-4" }, Ln = {
1735
- key: 1,
1736
- class: "flex flex-col gap-12"
1737
- }, Yn = { class: "pb-16" }, zn = { class: "fm-typo-cn-body-lg-600" }, Gn = {
1738
- class: "grid gap-12 fm-typo-en-body-md-400",
1739
- style: { "grid-template-columns": "auto auto auto", "grid-auto-rows": "1fr" }
1740
- }, Wn = { class: "flex flex-col gap-1" }, Kn = { class: "text-fm-color-typo-secondary" }, qn = { class: "font-bold" }, Xn = { class: "flex flex-col gap-1" }, Jn = { class: "text-fm-color-typo-secondary flex" }, Qn = { class: "font-bold" }, Zn = { class: "flex flex-col gap-1" }, es = { class: "text-fm-color-typo-secondary" }, ts = { class: "font-bold" }, os = { class: "flex flex-col gap-1" }, ns = { class: "text-fm-color-typo-secondary" }, ss = { class: "font-bold" }, as = { class: "flex flex-col gap-1" }, rs = { class: "text-fm-color-typo-secondary" }, ls = { class: "font-bold" }, is = { class: "flex flex-col gap-1" }, us = { class: "text-fm-color-typo-secondary" }, cs = { class: "font-bold" }, ds = { class: "flex flex-col gap-1" }, ms = { class: "text-fm-color-typo-secondary" }, fs = { class: "font-bold" }, vs = { class: "flex flex-col gap-1" }, ps = { class: "text-fm-color-typo-secondary" }, ys = { class: "font-bold" }, _s = { class: "flex flex-col gap-1" }, ks = { class: "text-fm-color-typo-secondary" }, hs = { class: "font-bold" }, bs = {
1741
- key: 0,
1742
- class: "flex flex-col gap-8"
1743
- }, gs = { class: "flex" }, xs = { class: "flex-1 flex flex-col gap-1" }, Ss = { class: "flex gap-1 items-center text-fm-color-typo-secondary" }, ws = { class: "font-bold" }, As = { class: "flex-1 flex flex-col gap-1" }, Fs = { class: "flex gap-1 items-center text-fm-color-typo-secondary" }, $s = { class: "flex flex-col gap-1" }, js = { class: "font-bold" }, Vs = {
1744
- key: 2,
1745
- class: "flex-1 flex flex-col items-center gap-8"
1746
- }, Cs = ["src"], Bs = { class: "font-bold text-lg" }, Ds = { class: "text-xs text-neutral-400 text-center" }, Ms = /* @__PURE__ */ pe({
1747
- __name: "StockHistory",
1748
- props: {
1749
- sku: {},
1750
- show: { type: Boolean }
1751
- },
1752
- emits: ["update:show"],
1753
- setup(A) {
1754
- const c = Xe(), k = Oe(), y = Ae(), w = an(), V = Se(), d = ro(), { t: r } = ye(), b = A, R = Y(!1), C = we(), l = Y("adjustment"), a = Y([
1755
- { label: "Adjustment (Default)", value: "adjustment" }
1756
- ]), B = Y([]), v = Y(so(0));
1757
- async function g() {
1758
- R.value = !0;
1759
- try {
1760
- await N(), await k.readStockBalance();
1761
- } catch (u) {
1762
- C.open({
1763
- title: "Something went wrong",
1764
- message: "Cannot fetch stock history. Please try again.",
1765
- type: "error"
1766
- }), console.log("failed at fetching item adjustment history", b.sku, v, u);
1767
- } finally {
1768
- R.value = !1;
1769
- }
1770
- }
1771
- qe(() => {
1772
- g();
1773
- }), Fe([() => v.value, () => b.sku], () => {
1774
- g();
1775
- });
1776
- const o = Y([]), t = Y([]), n = Y(new Array());
1777
- function $(u, h) {
1778
- return h === "day" ? no(u) : wt(u);
1779
- }
1780
- function E(u, h) {
1781
- const p = u.reduce(
1782
- (m, i) => {
1783
- const S = i.effectiveAt ?? Te(i._id);
1784
- if (!S)
1785
- return m;
1786
- const P = $(new Date(S), h);
1787
- return m[P] ?? (m[P] = []), m[P].push(i), m;
1788
- },
1789
- {}
1790
- );
1791
- return Object.keys(p).map((m) => ({
1792
- date: m,
1793
- adjustments: p[m]
1794
- }));
1795
- }
1796
- async function N() {
1797
- let u = await y.readStockAdjustment(
1798
- b.sku._id,
1799
- dt(new Date(v.value.startDate)).toISOString(),
1800
- mt(new Date(v.value.endDate)).toISOString()
1801
- );
1802
- o.value = u;
1803
- const h = u.filter(({ ref: p }) => p == null ? void 0 : p.startsWith("bill_")).map(({ ref: p }) => p);
1804
- await O(h), t.value = E(u, "day").map(({ date: p, adjustments: m }) => ({
1805
- date: p,
1806
- adjustments: m,
1807
- adjustmentsByTime: E(m, "minute")
1808
- }));
1809
- try {
1810
- const p = await y.readUnitCostHistory(
1811
- b.sku._id,
1812
- dt(new Date(v.value.startDate)).toISOString(),
1813
- mt(new Date(v.value.endDate)).toISOString()
1814
- );
1815
- B.value = p;
1816
- const m = /* @__PURE__ */ new Set();
1817
- p.forEach((S) => {
1818
- m.add(S.mechanism);
1819
- });
1820
- const i = [{ label: "Default", value: "adjustment" }];
1821
- m.has(ge.Enum.weightedAverage) && i.push({
1822
- label: "Weighted Average (Beta)",
1823
- value: ge.Enum.weightedAverage
1824
- }), m.has(ge.Enum.netsuite) && i.push({ label: "NetSuite (Beta)", value: ge.Enum.netsuite }), m.has(ge.Enum["netsuite-average"]) && i.push({
1825
- label: "NetSuite Average (Beta)",
1826
- value: ge.Enum["netsuite-average"]
1827
- }), a.value = i, !m.has(l.value) && l.value !== "adjustment" && (l.value = "adjustment");
1828
- } catch (p) {
1829
- console.error("Failed to fetch unit cost history:", p);
1830
- }
1831
- }
1832
- async function O(u) {
1833
- u.length && (n.value = await w.findBillsById(u).catch((h) => {
1834
- var i;
1835
- console.error("Error on using latest bill API, retrying using legacy api", h);
1836
- const p = ((i = c.currentBusiness.value) == null ? void 0 : i._id) ?? "", m = V.currentLocation.doc._id;
1837
- return w.findBillsByBusinessId(p, [m], u);
1838
- }));
1839
- }
1840
- const L = T(() => {
1841
- const u = o.value, h = b.sku;
1842
- return In(u, h);
1843
- }), X = T(() => {
1844
- const u = o.value, h = b.sku;
1845
- return Hn(u, h);
1846
- }), z = T(() => {
1847
- const u = [...o.value].computeFirst((p) => {
1848
- var i, S;
1849
- const m = (S = (i = p.skus) == null ? void 0 : i.find) == null ? void 0 : S.call(i, (P) => P.sku._id === b.sku._id);
1850
- return m == null ? void 0 : m.fromBalance;
1851
- }) ?? {
1852
- amount: 0,
1853
- precision: 0
1854
- }, h = b.sku;
1855
- return h ? `${ne.toFormatString({
1856
- value: u,
1857
- precision: 4
1858
- })} ${h.unit.abbrev}` : "";
1859
- }), K = T(() => {
1860
- const u = [...o.value].reverse().computeFirst((p) => {
1861
- var i, S;
1862
- const m = (S = (i = p.skus) == null ? void 0 : i.find) == null ? void 0 : S.call(i, (P) => P.sku._id === b.sku._id);
1863
- return m == null ? void 0 : m.toBalance;
1864
- }) ?? {
1865
- amount: 0,
1866
- precision: 0
1867
- }, h = b.sku;
1868
- return h ? `${ne.toFormatString({ value: u, precision: 4 })} ${h.unit.abbrev}` : "";
1869
- }), U = T(() => {
1870
- var p;
1871
- const h = o.value.flatMap((m) => {
1872
- var i;
1873
- return ((i = m.skus) == null ? void 0 : i.flatMap((S) => S.amounts)) ?? [];
1874
- }).filter((m) => m.amount.amount < 0).reduce(
1875
- (m, i) => {
1876
- const S = i.cost;
1877
- if (!S) return m;
1878
- const P = {
1879
- ...Gt(m, Math.max(m.precision, S.precision)),
1880
- currency: S.currency
1881
- };
1882
- return {
1883
- ...Qe(P, S),
1884
- currency: m.currency
1885
- };
1886
- },
1887
- {
1888
- amount: 0,
1889
- precision: 0,
1890
- currency: Ce((p = c.currentCountry) == null ? void 0 : p.value)
1891
- }
1892
- );
1893
- return Me(h, !1, h.precision);
1894
- });
1895
- function Z() {
1896
- const { startDate: u, endDate: h } = to(v.value);
1897
- u !== null && h !== null && (v.value = {
1898
- startDate: u,
1899
- endDate: h
1900
- });
1901
- }
1902
- const re = T(() => r("inventory.ingredient.valuationMethod.WAVG"));
1903
- function x(u, h) {
1904
- if (l.value === "adjustment")
1905
- return null;
1906
- const p = B.value.filter(
1907
- (S) => S.mechanism === l.value && S.skuId === b.sku._id
1908
- );
1909
- if (p.length === 0) return null;
1910
- const m = p.find((S) => {
1911
- const P = S.meta;
1912
- return (P == null ? void 0 : P.adjustmentId) === u;
1913
- });
1914
- if (m) return m.cost;
1915
- const i = [...p].filter((S) => new Date(S.snapshotAt) <= new Date(h)).sort((S, P) => new Date(P.snapshotAt).getTime() - new Date(S.snapshotAt).getTime());
1916
- return i.length > 0 ? i[0].cost : null;
1917
- }
1918
- const F = T(() => {
1919
- var m, i, S, P, ee, ae;
1920
- const u = [...o.value].reverse().find((Q) => {
1921
- var W, oe;
1922
- return (oe = (W = Q.skus) == null ? void 0 : W.find) == null ? void 0 : oe.call(W, (le) => le.sku._id === b.sku._id);
1923
- });
1924
- if (!u) return "No data";
1925
- const h = (m = u.skus) == null ? void 0 : m.find((Q) => Q.sku._id === b.sku._id);
1926
- if (!h) return "No data";
1927
- const p = h.toBalance;
1928
- if (l.value === "adjustment") {
1929
- const Q = [...h.amounts].reverse()[0], W = {
1930
- amount: ((i = Q.cost) == null ? void 0 : i.amount) ?? 0,
1931
- precision: ((S = Q.cost) == null ? void 0 : S.precision) ?? 0
1932
- }, oe = Q.amount, le = oe.amount == 0 ? ne.fromNumber(0) : ne.divide([W, oe]);
1933
- return {
1934
- ...ne.multiply([le, p]),
1935
- currency: ((P = Q.cost) == null ? void 0 : P.currency) || Ce(((ee = c.currentCountry) == null ? void 0 : ee.value) ?? lt)
1936
- };
1937
- } else {
1938
- const Q = u.effectiveAt ?? Te(u._id), W = x(
1939
- u._id,
1940
- Q ?? (/* @__PURE__ */ new Date()).toISOString()
1941
- );
1942
- if (!W) return "No data";
1943
- const oe = ne.fromDinero(W);
1944
- return {
1945
- ...ne.multiply([oe, p]),
1946
- currency: W.currency || Ce(((ae = c.currentCountry) == null ? void 0 : ae.value) ?? lt)
1947
- };
1948
- }
1949
- }), G = T(() => {
1950
- var p;
1951
- const u = [...o.value].reverse().computeFirst((m) => {
1952
- var S, P;
1953
- const i = (P = (S = m.skus) == null ? void 0 : S.find) == null ? void 0 : P.call(S, (ee) => ee.sku._id === b.sku._id);
1954
- return i == null ? void 0 : i.toCostBalances;
1955
- });
1956
- return !u || u.some((m) => m.cost == null) ? "No data" : {
1957
- ...u.reduce((m, i) => ne.add([m, ne.fromDinero(i.cost)]), {
1958
- amount: 0,
1959
- precision: 0
1960
- }),
1961
- currency: Ce((p = c.currentCountry) == null ? void 0 : p.value)
1962
- };
1963
- }), H = T(() => b.sku.valuation === it.Enum.FIFO ? G.value : F.value);
1964
- function J() {
1965
- const { startDate: u, endDate: h } = oo(v.value);
1966
- u !== null && h !== null && (v.value = {
1967
- startDate: u,
1968
- endDate: h
1969
- });
1970
- }
1971
- const I = Ye(b, "show");
1972
- return (u, h) => {
1973
- const p = D("FmButton"), m = D("FmField"), i = D("FmDateRangePicker"), S = D("FmSpacer"), P = D("FmCircularProgress"), ee = D("FmIcon"), ae = D("FmTooltip"), Q = D("FmMenuDivider"), W = D("FmChip"), oe = D("FmSelect"), le = D("FmCardSection"), ce = D("FmCard"), je = D("FmSideSheet");
1974
- return j(), te(je, {
1975
- "dismiss-away": "",
1976
- modelValue: s(I),
1977
- "onUpdate:modelValue": h[5] || (h[5] = (fe) => Pe(I) ? I.value = fe : null),
1978
- "close-button": !1,
1979
- "max-width": 560
1980
- }, {
1981
- "side-sheet-header": M(() => [
1982
- e("div", Tn, [
1983
- e("div", En, f(s(r)("inventory.stock.history.title", [u.sku.name])), 1),
1984
- _(p, {
1985
- variant: "tertiary",
1986
- "prepend-icon": "close",
1987
- onClick: h[0] || (h[0] = (fe) => I.value = !1)
1988
- })
1989
- ])
1990
- ]),
1991
- default: M(() => {
1992
- var fe;
1993
- return [
1994
- e("div", Un, [
1995
- e("div", Pn, [
1996
- e("div", Rn, [
1997
- _(i, {
1998
- modelValue: v.value,
1999
- "onUpdate:modelValue": h[1] || (h[1] = (de) => v.value = de),
2000
- "show-predefined-range": "",
2001
- "start-label": "",
2002
- "end-label": "",
2003
- "z-index": 50
2004
- }, {
2005
- "trigger-button": M(({ opened: de }) => [
2006
- _(m, {
2007
- "prepend-icon": "calendar_month",
2008
- focused: de
2009
- }, {
2010
- default: M(() => [
2011
- me(f(v.value.startDate) + " - " + f(v.value.endDate), 1)
2012
- ]),
2013
- _: 2
2014
- }, 1032, ["focused"])
2015
- ]),
2016
- _: 1
2017
- }, 8, ["modelValue"])
2018
- ]),
2019
- _(p, {
2020
- variant: "tertiary",
2021
- onClick: h[2] || (h[2] = (de) => Z()),
2022
- "prepend-icon": "navigate_before"
2023
- }),
2024
- _(p, {
2025
- variant: "tertiary",
2026
- onClick: h[3] || (h[3] = (de) => J()),
2027
- "prepend-icon": "navigate_next"
2028
- })
2029
- ]),
2030
- R.value ? (j(), q("div", Nn, [
2031
- _(S),
2032
- _(P, { size: "xl" }),
2033
- e("div", On, f(s(r)("inventory.stock.history.loading")), 1),
2034
- _(S),
2035
- _(S)
2036
- ])) : t.value && ((fe = t.value) == null ? void 0 : fe.length) > 0 ? (j(), q("div", Ln, [
2037
- _(ce, { variant: "outlined" }, {
2038
- default: M(() => [
2039
- _(le, { class: "flex flex-col gap-4" }, {
2040
- default: M(() => [
2041
- e("div", Yn, [
2042
- e("div", zn, f(s(r)("inventory.stock.history.summary.title")), 1)
2043
- ]),
2044
- e("div", Gn, [
2045
- e("div", Wn, [
2046
- e("div", Kn, f(s(r)("inventory.stock.history.summary.totalPurchase")), 1),
2047
- e("div", qn, f(L.value.PURCHASE), 1)
2048
- ]),
2049
- e("div", Xn, [
2050
- e("div", Jn, [
2051
- me(f(s(r)("inventory.stock.history.summary.totalSales")) + "  ", 1),
2052
- X.value != null ? (j(), te(ae, {
2053
- key: 0,
2054
- variant: "plain",
2055
- placement: "top",
2056
- content: `Before: ${X.value}`,
2057
- "z-index": 50
2058
- }, {
2059
- default: M(() => [
2060
- _(ee, {
2061
- name: "warning",
2062
- size: "sm"
2063
- })
2064
- ]),
2065
- _: 1
2066
- }, 8, ["content"])) : se("", !0)
2067
- ]),
2068
- e("div", Qn, f(L.value.SALES), 1)
2069
- ]),
2070
- e("div", Zn, [
2071
- e("div", es, f(s(r)("inventory.stock.history.summary.totalLose")), 1),
2072
- e("div", ts, f(L.value.LOSE), 1)
2073
- ]),
2074
- e("div", os, [
2075
- e("div", ns, f(s(r)("inventory.stock.history.summary.totalRequest")), 1),
2076
- e("div", ss, f(L.value.REQUEST), 1)
2077
- ]),
2078
- e("div", as, [
2079
- e("div", rs, f(s(r)("inventory.stock.history.summary.totalReceive")), 1),
2080
- e("div", ls, f(L.value.RECEIVE), 1)
2081
- ]),
2082
- e("div", is, [
2083
- e("div", us, f(s(r)("inventory.stock.history.summary.totalConvert")), 1),
2084
- e("div", cs, f(L.value.CONVERT), 1)
2085
- ]),
2086
- e("div", ds, [
2087
- e("div", ms, f(s(r)("inventory.stock.history.summary.totalDamage")), 1),
2088
- e("div", fs, f(L.value.DAMAGE), 1)
2089
- ]),
2090
- e("div", vs, [
2091
- e("div", ps, f(s(r)("inventory.stock.history.summary.openingBalance")), 1),
2092
- e("div", ys, f(z.value), 1)
2093
- ]),
2094
- e("div", _s, [
2095
- e("div", ks, f(s(r)("inventory.stock.history.summary.lastStockBalance")), 1),
2096
- e("div", hs, f(K.value), 1)
2097
- ])
2098
- ]),
2099
- s(d).enableTotalCost ? (j(), q("div", bs, [
2100
- _(Q, { class: "w-full" }),
2101
- e("div", gs, [
2102
- e("div", xs, [
2103
- _(ut, { "z-index": 50 }, {
2104
- default: M(() => [
2105
- e("div", Ss, [
2106
- me(f(s(r)("inventory.stock.history.estimatedValue")) + " ", 1),
2107
- _(ae, {
2108
- variant: "plain",
2109
- placement: "top",
2110
- content: `[${re.value}] ${s(r)("inventory.stock.history.estimatedValueTooltip")}`,
2111
- "z-index": 50
2112
- }, {
2113
- default: M(() => [
2114
- _(ee, {
2115
- name: "help",
2116
- size: "sm"
2117
- })
2118
- ]),
2119
- _: 1
2120
- }, 8, ["content"])
2121
- ])
2122
- ]),
2123
- _: 1
2124
- }),
2125
- e("div", ws, [
2126
- u.sku.valuation === s(it).Enum.FIFO ? (j(), q(ue, { key: 0 }, [
2127
- _(W, {
2128
- label: "FIFO",
2129
- compact: ""
2130
- }),
2131
- me(" " + f(typeof H.value != "string" ? s(Me)(
2132
- H.value,
2133
- !1,
2134
- H.value.precision
2135
- ) : H.value), 1)
2136
- ], 64)) : (j(), q(ue, { key: 1 }, [
2137
- me(f(typeof H.value != "string" ? s(Me)(
2138
- H.value,
2139
- !1,
2140
- H.value.precision
2141
- ) : H.value), 1)
2142
- ], 64))
2143
- ]),
2144
- _(oe, {
2145
- modelValue: l.value,
2146
- "onUpdate:modelValue": h[4] || (h[4] = (de) => l.value = de),
2147
- items: a.value,
2148
- compact: "",
2149
- size: "sm",
2150
- style: { width: "200px" }
2151
- }, null, 8, ["modelValue", "items"])
2152
- ]),
2153
- e("div", As, [
2154
- _(ut, { "z-index": 50 }, {
2155
- default: M(() => [
2156
- e("div", Fs, [
2157
- me(f(s(r)("inventory.stock.history.costSold")) + " ", 1),
2158
- _(ae, {
2159
- variant: "plain",
2160
- placement: "top",
2161
- "z-index": 50
2162
- }, {
2163
- content: M(() => [
2164
- e("div", $s, f(s(r)("inventory.stock.history.costSoldTooltip")), 1)
2165
- ]),
2166
- default: M(() => [
2167
- _(ee, {
2168
- name: "help",
2169
- size: "sm"
2170
- })
2171
- ]),
2172
- _: 1
2173
- })
2174
- ])
2175
- ]),
2176
- _: 1
2177
- }),
2178
- e("div", js, f(U.value), 1)
2179
- ])
2180
- ])
2181
- ])) : se("", !0)
2182
- ]),
2183
- _: 1
2184
- })
2185
- ]),
2186
- _: 1
2187
- }),
2188
- h[6] || (h[6] = e("div", null, null, -1)),
2189
- (j(!0), q(ue, null, ve(t.value, (de) => (j(), q(ue, {
2190
- key: de.date
2191
- }, [
2192
- u.sku ? (j(), te(Mn, {
2193
- key: 0,
2194
- record: de,
2195
- sku: u.sku,
2196
- bills: n.value,
2197
- "unit-cost-history": B.value,
2198
- "cost-mechanism": l.value,
2199
- onRefreshHistory: g
2200
- }, null, 8, ["record", "sku", "bills", "unit-cost-history", "cost-mechanism"])) : se("", !0)
2201
- ], 64))), 128))
2202
- ])) : (j(), q("div", Vs, [
2203
- _(S),
2204
- e("div", null, [
2205
- e("img", {
2206
- src: s(ao),
2207
- alt: "List is empty"
2208
- }, null, 8, Cs)
2209
- ]),
2210
- e("div", Bs, f(s(r)("inventory.stock.history.noRecords")), 1),
2211
- e("div", Ds, f(s(r)("inventory.stock.history.changeDateRange")), 1),
2212
- _(S),
2213
- _(S)
2214
- ]))
2215
- ])
2216
- ];
2217
- }),
2218
- _: 1
2219
- }, 8, ["modelValue"]);
2220
- };
2221
- }
2222
- }), Is = /* @__PURE__ */ pe({
2223
- __name: "HrmPermissionGuard",
2224
- props: {
2225
- permission: { default: void 0 },
2226
- permissions: { default: void 0 },
2227
- mode: { default: "all" }
2228
- },
2229
- setup(A) {
2230
- const c = A, k = T(() => {
2231
- const w = [];
2232
- return c.permission && w.push(c.permission), c.permissions && w.push(...c.permissions), w;
2233
- });
2234
- Vt(() => {
2235
- });
2236
- const { hasPermission: y } = At(k, () => c.mode);
2237
- return (w, V) => s(y) ? st(w.$slots, "default", { key: 0 }) : st(w.$slots, "fallback", { key: 1 });
2238
- }
2239
- });
2240
- function Hs(A) {
2241
- const c = uo(), k = Se(), y = Y(!1), w = Y(null), V = Y(null);
2242
- let d = null, r = !1, b = !1;
2243
- function R() {
2244
- if (b) return;
2245
- const a = k.currentLocationDBName;
2246
- if (!a) return;
2247
- b = !0;
2248
- const B = {
2249
- type: "refresh-balance",
2250
- params: { locationId: a }
2251
- }, { unsubscribe: v, initialState: g } = c.subscribe(
2252
- B,
2253
- C
2254
- );
2255
- d = v, g.then((o) => {
2256
- o != null && o.initialState && C(o.initialState);
2257
- }).catch((o) => {
2258
- console.error("Failed to fetch refresh-balance initial state", o);
2259
- });
2260
- }
2261
- async function C(a) {
2262
- var B, v, g;
2263
- if (!(!b || !a)) {
2264
- if (w.value = a, a.completedAt && (V.value = a.completedAt), a.message === "processing" || !a.completedAt && !a.message) {
2265
- r = !0, y.value = !0;
2266
- return;
2267
- }
2268
- if (a.message === "completed" || a.completedAt) {
2269
- if (!r) return;
2270
- l();
2271
- try {
2272
- await A.onCompleted();
2273
- } catch (o) {
2274
- console.error("Failed to reload after refresh", o);
2275
- }
2276
- return;
2277
- }
2278
- if (a.message === "error" || (B = a.message) != null && B.startsWith("error:")) {
2279
- console.log("Stock balance refresh error:", a.message);
2280
- const o = (v = a.message) != null && v.startsWith("error:") ? a.message.slice(6).trim() : "Failed to refresh stock balance.";
2281
- l(), await ((g = A.onError) == null ? void 0 : g.call(A, o));
2282
- }
2283
- }
2284
- }
2285
- function l() {
2286
- d && (d(), d = null), b = !1, r = !1, y.value = !1, w.value = null;
2287
- }
2288
- return Ct(() => {
2289
- l();
2290
- }), {
2291
- refreshing: y,
2292
- refreshStatus: w,
2293
- lastCompletedAt: V,
2294
- startListening: R,
2295
- stopListening: l
2296
- };
2297
- }
2298
- const Ts = {
2299
- key: 0,
2300
- class: "flex items-center gap-1"
2301
- }, Es = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Us = { class: "flex flex-col gap-8" }, Ps = { class: "flex flex-col" }, Rs = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Ns = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary line-clamp-1" }, ba = /* @__PURE__ */ pe({
2302
- __name: "StockView",
2303
- setup(A) {
2304
- const { t: c } = ye(), k = Ne(), y = Se(), w = Oe(), V = Ft(), d = Ae(), r = gt(), b = co(), { columnDefs: R } = ko(), C = Xe(), { hasPermission: l } = At(
2305
- T(() => [
2306
- {
2307
- action: Be.Action.manage,
2308
- subject: Be.Subject.Business.inventory_stockAdjustment
2309
- }
2310
- ])
2311
- ), a = T(
2312
- () => {
2313
- var p;
2314
- return l.value || ((p = C.sessionUser.value) == null ? void 0 : p.role.isAdmin);
2315
- }
2316
- ), B = Le(), v = we();
2317
- y.watchLocation(X);
2318
- const g = T(
2319
- () => new Set(b.getAvailableItems(b.businessSubsidiaryId))
2320
- ), o = Y(!1), t = Y(!1), { refreshing: n, lastCompletedAt: $, startListening: E, stopListening: N } = Hs({
2321
- onCompleted: async () => {
2322
- await X(), t.value = !1, v.open({
2323
- title: "Balance refreshed",
2324
- message: "Stock balance has been recalculated.",
2325
- type: "success"
2326
- });
2327
- },
2328
- onError: (p) => {
2329
- t.value = !1, console.log("Error refreshing stock balance", p), v.open({
2330
- title: c("inventory.common.refreshFailed"),
2331
- message: p || c("inventory.stock.stock_balance.refreshBalanceError"),
2332
- type: "error"
2333
- });
2334
- }
2335
- }), O = T(() => n.value || t.value);
2336
- async function L() {
2337
- E();
2338
- const p = c("inventory.stock.stock_balance.refreshBalanceDescription"), m = $.value ? `${p}
2339
-
2340
- Last refreshed: ${new Date($.value).toLocaleString()}` : p;
2341
- B.open({
2342
- title: c("inventory.stock.stock_balance.refreshBalance"),
2343
- message: m,
2344
- closeButton: !0,
2345
- primaryActions: {
2346
- text: c("common.confirm"),
2347
- close: !1,
2348
- isLoading: O,
2349
- disabled: O
2350
- },
2351
- secondaryActions: {
2352
- text: c("common.close"),
2353
- close: !0,
2354
- variant: "tertiary",
2355
- disabled: O
2356
- }
2357
- }).onPrimary(async () => {
2358
- if (!t.value) {
2359
- t.value = !0;
2360
- try {
2361
- await d.recalculation.refreshCurrentBalances();
2362
- } catch (i) {
2363
- console.log("Failed to queue refresh balan22ce", typeof i);
2364
- const S = typeof i == "object" ? JSON.stringify(i) : String(i);
2365
- console.log("Error details:", S), t.value = !1, v.open({
2366
- title: c("inventory.common.refreshFailed"),
2367
- message: (i instanceof Error ? i.message : null) ?? c("inventory.stock.stock_balance.refreshBalanceError"),
2368
- type: "error"
2369
- });
2370
- }
2371
- }
2372
- }).onClose(() => {
2373
- t.value = !1, N();
2374
- });
2375
- }
2376
- async function X() {
2377
- if (y._currentLocation) {
2378
- o.value = !0;
2379
- try {
2380
- await w.readStockBalance(), await w.readProductBalance(), await r.readStockEstimateBalance();
2381
- } catch (p) {
2382
- v.open({
2383
- title: c("inventory.stock.error.title"),
2384
- message: c("inventory.stock.error.message"),
2385
- type: "error"
2386
- }), console.error("error on fetch stock balance", p);
2387
- } finally {
2388
- o.value = !1;
2389
- }
2390
- }
2391
- }
2392
- const z = T(() => [
2393
- {
2394
- type: "string",
2395
- key: "status",
2396
- entity: "sku",
2397
- values: ["Active", "Inactive"]
2398
- }
2399
- ]), K = Y({
2400
- logic: "AND",
2401
- rules: [
2402
- {
2403
- property: "status",
2404
- operator: "$in",
2405
- value: ["Active"],
2406
- type: "string"
2407
- }
2408
- ]
2409
- }), U = T(() => {
2410
- var i, S, P;
2411
- const p = K.value ? mo.build(K.value) : null, m = [];
2412
- for (const ee of k.skus) {
2413
- let ae = !0;
2414
- if (b.isEnabled && re.value && g.value && ae && (ae = g.value.has(ee._id)), p && ae && (ae = fo(
2415
- {
2416
- status: ee.isInactive ? "Inactive" : "Active"
2417
- },
2418
- p
2419
- )), ae) {
2420
- const Q = ee.trackingMeasurement;
2421
- let W = (S = (i = w.stockBalance.skus) == null ? void 0 : i.find(
2422
- (ce) => ce.id === ee._id
2423
- )) == null ? void 0 : S.balance, oe = r.inventoryForecast.skus.find(
2424
- (ce) => ce.id === ee._id
2425
- );
2426
- const le = {
2427
- ...ee,
2428
- balance: W ?? {
2429
- amount: 0,
2430
- precision: 0
2431
- },
2432
- operator: oe == null ? void 0 : oe.operator,
2433
- day: (oe == null ? void 0 : oe.depletionDays) ?? void 0,
2434
- trackingUnitAbbrev: Q ? ((P = ee.unit.measurements.find((ce) => ce.id === Q)) == null ? void 0 : P.abbrev) ?? "" : ee.unit.abbrev
2435
- };
2436
- m.push(le);
2437
- }
2438
- }
2439
- return m;
2440
- }), Z = Y(""), re = Y(!0), { breakpoints: x } = Ot(), F = T(() => x.value.xs || x.value.sm), G = T(() => F.value ? 10 : 20), H = Dt(), J = T(() => {
2441
- const p = [
2442
- {
2443
- label: c("inventory.stock.stock_balance.refreshBalance"),
2444
- value: "refresh-balance",
2445
- isPrimary: !0,
2446
- prependIcon: "calculate"
2447
- },
2448
- {
2449
- label: c("inventory.common.refresh"),
2450
- value: "refresh"
2451
- },
2452
- {
2453
- label: c("inventory.common.export"),
2454
- value: "export"
2455
- }
2456
- ];
2457
- return a.value && p.push({
2458
- label: c("inventory.stock.stock_adjustment.title"),
2459
- value: "stockAdjustment"
2460
- }), p;
2461
- }), I = Y(!1);
2462
- function u() {
2463
- I.value = !0;
2464
- }
2465
- function h(p) {
2466
- switch (p) {
2467
- case "refresh-balance":
2468
- return L();
2469
- case "refresh":
2470
- return X();
2471
- case "export":
2472
- return Pt(U.value);
2473
- case "stockAdjustment":
2474
- return u();
2475
- }
2476
- }
2477
- return (p, m) => {
2478
- const i = D("FmSwitch"), S = D("FmTable");
2479
- return j(), te(Mt, {
2480
- title: s(c)("inventory.stock.title"),
2481
- actions: J.value,
2482
- "onClick:action": h
2483
- }, {
2484
- default: M(() => {
2485
- var P, ee, ae, Q;
2486
- return [
2487
- e("div", {
2488
- class: He([
2489
- "flex flex-col gap-8 max-h-full",
2490
- {
2491
- "p-0": F.value,
2492
- "px-24 ": !F.value
2493
- }
2494
- ])
2495
- }, [
2496
- _(io, {
2497
- searchable: "",
2498
- "change-location": "",
2499
- search: Z.value,
2500
- "onUpdate:search": m[1] || (m[1] = (W) => Z.value = W),
2501
- "hide-filter-options": !0,
2502
- filterable: "",
2503
- "filter-attributes": z.value,
2504
- filter: K.value,
2505
- "onUpdate:filter": m[2] || (m[2] = (W) => K.value = W)
2506
- }, {
2507
- default: M(() => [
2508
- s(b).isEnabled ? (j(), q("div", Ts, [
2509
- e("span", Es, f(s(c)("inventory.integration.netsuite.subsidiaryHierarchy.filtering")), 1),
2510
- _(Rt),
2511
- _(Je, null, {
2512
- default: M(() => [
2513
- _(i, {
2514
- modelValue: re.value,
2515
- "onUpdate:modelValue": m[0] || (m[0] = (W) => re.value = W)
2516
- }, null, 8, ["modelValue"])
2517
- ]),
2518
- _: 1
2519
- })
2520
- ])) : se("", !0)
2521
- ]),
2522
- _: 1
2523
- }, 8, ["search", "filter-attributes", "filter"]),
2524
- (j(), te(S, {
2525
- style: kt(s(H).tableHeight),
2526
- "column-defs": s(R),
2527
- "row-data": U.value,
2528
- "search-value": Z.value,
2529
- loading: o.value || s(n) || !s(y)._currentLocation,
2530
- key: (P = s(y)._currentLocation) == null ? void 0 : P.dbName,
2531
- onRowClick: m[3] || (m[3] = (W) => s(V).showSkuHistory(W.original)),
2532
- "page-size": G.value
2533
- }, {
2534
- "list-row": M((W) => [
2535
- _(lo, {
2536
- row: W,
2537
- onRowClick: s(V).showSkuHistory
2538
- }, {
2539
- default: M((oe) => {
2540
- var le, ce, je, fe, de, Ze, et, tt, Ve, ot;
2541
- return [
2542
- e("div", Us, [
2543
- e("div", Ps, [
2544
- e("div", Rs, [
2545
- _(s(ft), {
2546
- render: (je = (ce = (le = oe.code) == null ? void 0 : le.column) == null ? void 0 : ce.columnDef) == null ? void 0 : je.cell,
2547
- props: (de = (fe = oe.code) == null ? void 0 : fe.getContext) == null ? void 0 : de.call(fe)
2548
- }, null, 8, ["render", "props"])
2549
- ]),
2550
- e("div", Ns, [
2551
- _(s(ft), {
2552
- render: (tt = (et = (Ze = oe.name) == null ? void 0 : Ze.column) == null ? void 0 : et.columnDef) == null ? void 0 : tt.cell,
2553
- props: (ot = (Ve = oe.name) == null ? void 0 : Ve.getContext) == null ? void 0 : ot.call(Ve)
2554
- }, null, 8, ["render", "props"])
2555
- ])
2556
- ]),
2557
- e("div", null, [
2558
- _(Ke, {
2559
- days: W.original.day
2560
- }, null, 8, ["days"])
2561
- ]),
2562
- e("div", null, [
2563
- _(ht, {
2564
- class: "xs:w-[160px]",
2565
- unit: W.original.unit,
2566
- sku: W.original,
2567
- amount: W.original.balance,
2568
- "default-tracking-measurement": W.original.trackingMeasurement ?? void 0
2569
- }, null, 8, ["unit", "sku", "amount", "default-tracking-measurement"])
2570
- ])
2571
- ])
2572
- ];
2573
- }),
2574
- _: 2
2575
- }, 1032, ["row", "onRowClick"])
2576
- ]),
2577
- _: 1
2578
- }, 8, ["style", "column-defs", "row-data", "search-value", "loading", "page-size"]))
2579
- ], 2),
2580
- (j(), te(Bt, { to: "body" }, [
2581
- (ee = s(V).stockHistoryProps) != null && ee.sku ? (j(), te(Ms, at(ze({ key: 0 }, s(V).stockHistoryProps)), null, 16)) : se("", !0),
2582
- (ae = s(V).convertSkuDialogProps) != null && ae.sku ? (j(), te(Mo, at(ze({ key: 1 }, s(V).convertSkuDialogProps)), null, 16)) : se("", !0),
2583
- (Q = s(V).adjustSkuDialogProps) != null && Q.stock ? (j(), te(Go, ze({ key: 2 }, s(V).adjustSkuDialogProps, {
2584
- onSubmitted: m[4] || (m[4] = (W) => X())
2585
- }), null, 16)) : se("", !0),
2586
- _(Is, {
2587
- permission: {
2588
- action: s(Be).Action.manage,
2589
- subject: s(Be).Subject.Business.inventory_stockAdjustment
2590
- }
2591
- }, {
2592
- default: M(() => [
2593
- I.value ? (j(), te(sn, {
2594
- key: 0,
2595
- show: I.value,
2596
- "onUpdate:show": m[5] || (m[5] = (W) => I.value = W),
2597
- onSubmitted: m[6] || (m[6] = (W) => X())
2598
- }, null, 8, ["show"])) : se("", !0)
2599
- ]),
2600
- _: 1
2601
- }, 8, ["permission"])
2602
- ]))
2603
- ];
2604
- }),
2605
- _: 1
2606
- }, 8, ["title", "actions"]);
2607
- };
2608
- }
2609
- });
2610
- export {
2611
- ba as default
2612
- };