@feedmepos/mf-inventory-portal 1.8.0-dev.8 → 1.8.0

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