@feedmepos/mf-inventory-portal 1.8.0-dev.2 → 1.8.0-dev.20

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 (248) hide show
  1. package/dist/App-5GYyCfFq.js +1445 -0
  2. package/dist/{ApprovalView-RaXuWWSu.js → ApprovalView-DY1ayl1W.js} +26 -25
  3. package/dist/{BindingsDialog-DomvXijP.js → BindingsDialog-Dm7uKMfV.js} +2 -2
  4. package/dist/{BindingsPicker-DGnzxEs7.js → BindingsPicker-DhnMlj4x.js} +2 -2
  5. package/dist/{BindingsTable-DfG9kWrv.js → BindingsTable-Cxibcjka.js} +10 -10
  6. package/dist/BulkReceiveRequestPage-w4AA6BxB.js +2839 -0
  7. package/dist/{ChangeLocationComponent.vue_vue_type_script_setup_true_lang-CVekIoiN.js → ChangeLocationComponent.vue_vue_type_script_setup_true_lang-B3ESPbQp.js} +1 -1
  8. package/dist/{ClosingDraftView-C3n66bbh.js → ClosingDraftView-DMaONEZ7.js} +748 -746
  9. package/dist/ClosingHistoryView-BBYruOux.js +769 -0
  10. package/dist/{ClosingTemplateView-DwGloYxn.js → ClosingTemplateView-DcwgokRl.js} +22 -21
  11. package/dist/{CustomPrintTemplatePreview.vue_vue_type_script_setup_true_lang-9eY_r8LF.js → CustomPrintTemplatePreview.vue_vue_type_script_setup_true_lang-a72IldDO.js} +1 -1
  12. package/dist/{DefaultView-JC_e4xgC.js → DefaultView-BVr_7JDn.js} +2 -2
  13. package/dist/{DeliveryOrderPrintPreview-BBCvI67S.js → DeliveryOrderPrintPreview-BXZFD3D5.js} +15 -15
  14. package/dist/{EmailDialog.vue_vue_type_script_setup_true_lang-H4FWc9ga.js → EmailDialog.vue_vue_type_script_setup_true_lang-Dne_9P3j.js} +10077 -9950
  15. package/dist/FeatureCapabilityBadge.vue_vue_type_script_setup_true_lang-CYkPbFSA.js +48 -0
  16. package/dist/FeatureCapabilityGate-DK_rTVyJ.js +82 -0
  17. package/dist/FeaturePageGate.vue_vue_type_script_setup_true_lang-DIhV51l7.js +189 -0
  18. package/dist/{FmDateRangePickerChip.vue_vue_type_script_setup_true_lang-Q8Mptiv3.js → FmDateRangePickerChip.vue_vue_type_script_setup_true_lang-B80EHMBT.js} +1 -1
  19. package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-CE1_yyHe.js → FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-C94IFGoH.js} +2 -2
  20. package/dist/{FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-CGJi3f86.js → FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-COZPDuAM.js} +2 -2
  21. package/dist/{FmMultiselectDialog-DCaRlBIy.js → FmMultiselectDialog-C1P22sj2.js} +2 -2
  22. package/dist/FmMultiselectDialog-Kb3IftHf.js +123 -0
  23. package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-ClaLVtpK.js → FmUnitInput.vue_vue_type_script_setup_true_lang-BqB71yfu.js} +105 -99
  24. package/dist/ImportView-EJ4u8NHM.js +1540 -0
  25. package/dist/{IngredientsView-DPj9lBTK.js → IngredientsView-Bxsgm4E7.js} +691 -689
  26. package/dist/{IntegrationExplorerView-CO2wpUR_.js → IntegrationExplorerView-owEaOVeG.js} +1537 -1620
  27. package/dist/IntegrationPlatformView-BuptPyjg.js +13385 -0
  28. package/dist/{IntegrationView-DIeZoey0.js → IntegrationView-DAcdY_d_.js} +2604 -2565
  29. package/dist/{InventoryBindingForm-Cj4_Chue.js → InventoryBindingForm-BvjY4zrn.js} +1 -1
  30. package/dist/InventoryBindingForm.vue_vue_type_script_setup_true_lang-DhbF-jgN.js +472 -0
  31. package/dist/{InventoryBindingSummary-yzGzd7jJ.js → InventoryBindingSummary-DPqm94GX.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-DDsigNJ4.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-0F-yOcPC.js +79 -0
  36. package/dist/PremiumUpgradePage.vue_vue_type_script_setup_true_lang-DGAxPOEh.js +58 -0
  37. package/dist/ProductionRunDetailPage-BaPCJUqT.js +2317 -0
  38. package/dist/{ProductionRunLifecycleDialogs.vue_vue_type_script_setup_true_lang-BYyiiAWb.js → ProductionRunLifecycleDialogs.vue_vue_type_script_setup_true_lang-CNRX3MYt.js} +3053 -3163
  39. package/dist/ProductionRunPage-B6Jsv9Hh.js +954 -0
  40. package/dist/{PublishView-CPK9NeVF.js → PublishView-DonUv6nP.js} +3 -3
  41. package/dist/{PurchaseOrderPrintPreview-DosqWQeN.js → PurchaseOrderPrintPreview-CK3Cqdwp.js} +17 -17
  42. package/dist/{ReceiveRequestView-BxSkpK2t.js → ReceiveRequestView-CMAnKxzm.js} +17 -16
  43. package/dist/RecipeView-Bx13Bckq.js +3272 -0
  44. package/dist/SettingsView-D1MiAkD8.js +1005 -0
  45. package/dist/StockView-CsxTjVEd.js +3003 -0
  46. package/dist/{SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-GdGJCuc0.js → SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-BT73j9SA.js} +1 -1
  47. package/dist/{SupplierView-BKxKoi_0.js → SupplierView-CFACoZya.js} +304 -301
  48. package/dist/{SurchargeView-Db4cwhZv.js → SurchargeView-CShhZa3x.js} +7 -7
  49. package/dist/{SystemTrailDialog.vue_vue_type_script_setup_true_lang-CpkF77Ow.js → SystemTrailDialog.vue_vue_type_script_setup_true_lang-B2OdmdI_.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-x3N2Oypo.js +332 -0
  52. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-BISmGBJE.js +4953 -0
  53. package/dist/TransferTemplateView-kx2IPqEv.js +2347 -0
  54. package/dist/{UnitCostHistoryView-CqcyjCCd.js → UnitCostHistoryView-DgPWsXaB.js} +4 -4
  55. package/dist/{UnitDisplayControl.vue_vue_type_script_setup_true_lang-DO80_8SZ.js → UnitDisplayControl.vue_vue_type_script_setup_true_lang-BtfJJgIP.js} +4 -4
  56. package/dist/{UnitView-BqdK1AM_.js → UnitView-aupXLRMk.js} +111 -106
  57. package/dist/{WarehouseView-COJM9IXM.js → WarehouseView-MTvbY4n4.js} +12 -11
  58. package/dist/{WastageTemplateView-DW3viTHN.js → WastageTemplateView-Bs9HL-LK.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 +4 -0
  63. package/dist/api/integration-sync-log.d.ts +0 -13
  64. package/dist/api/license.d.ts +0 -2
  65. package/dist/api/netsuite-explorer.d.ts +1 -0
  66. package/dist/api/stock.d.ts +1 -1
  67. package/dist/{app-yvK__CBL.js → app-D38sV2ls.js} +10177 -10126
  68. package/dist/app.d.ts +151 -164
  69. package/dist/app.js +1 -1
  70. package/dist/bulk-edit-simulation.helper-DgniL8FN.js +178 -0
  71. package/dist/{closing-template-DezidSM0.js → closing-template-D_NAj_mU.js} +4 -4
  72. package/dist/components/FeatureCapabilityBadge.vue.d.ts +4 -0
  73. package/dist/components/FeatureCapabilityGate.spec.d.ts +1 -0
  74. package/dist/components/FeatureCapabilityGate.vue.d.ts +5 -0
  75. package/dist/components/FeatureGateLayout.vue.d.ts +11 -0
  76. package/dist/components/FeaturePageGate.spec.d.ts +1 -0
  77. package/dist/components/FeaturePageGate.vue.d.ts +34 -0
  78. package/dist/components/FmAdminCollapsiblePanel.vue.d.ts +1 -1
  79. package/dist/components/FmDroppableField.vue.d.ts +1 -1
  80. package/dist/components/FmInventoryTableToolbar.vue.d.ts +2 -2
  81. package/dist/components/FmUnitInputProps.d.ts +1 -0
  82. package/dist/components/FmUnitInputRules.d.ts +1 -1
  83. package/dist/components/HrmPermissionGuard.vue.d.ts +1 -1
  84. package/dist/components/NumberPrecisionInput.spec.d.ts +1 -0
  85. package/dist/{views/ingredient-group/IngredientGroupView.vue.d.ts → components/PremiumUpgradePage.vue.d.ts} +0 -1
  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-2XjepIqc.js → date2-CvgxwuM1.js} +1 -1
  90. package/dist/{dayjs.min-CNp5DLBB.js → dayjs.min-BOKV8T5Q.js} +1 -1
  91. package/dist/{decimal-Z7oJdGk8.js → decimal-5xyg1WLu.js} +2 -2
  92. package/dist/{defineDeepModel-CMxJn_H2.js → defineDeepModel-BwB9XcMu.js} +5 -5
  93. package/dist/{duplicate-template-BetV5oy_.js → duplicate-template-DvIgjm4K.js} +1 -1
  94. package/dist/{feature-CkWaZ-5K.js → feature-CsPbMoeJ.js} +2088 -2853
  95. package/dist/feature-flags/core.d.ts +3 -2
  96. package/dist/feature-flags/portal-feature-catalog.d.ts +1 -6
  97. package/dist/feature-flags/portal-feature-catalog.spec.d.ts +1 -0
  98. package/dist/feature-flags/vue.d.ts +24 -1
  99. package/dist/feature-flags/vue.spec.d.ts +1 -0
  100. package/dist/{format-time-from-id-DatSI9uD.js → format-time-from-id-DD6Ik9EK.js} +1 -1
  101. package/dist/{format-unit-display-DM5We5cx.js → format-unit-display-DG564AN3.js} +209 -208
  102. package/dist/helper/country.spec.d.ts +1 -0
  103. package/dist/helper/menu-usage-module.d.ts +2 -1
  104. package/dist/helper/number.d.ts +5 -1
  105. package/dist/helper/rules.d.ts +1 -1
  106. package/dist/{id-to-date-Dxw2jKhy.js → id-to-date-DoN7OM21.js} +1 -1
  107. package/dist/{import-export.helper-BOmADwUw.js → import-export.helper-CevBRFTZ.js} +17 -17
  108. package/dist/{index-7fz5sGDO.js → index-BIh1oTQH.js} +3 -3
  109. package/dist/{index-CIH9NCvs.js → index-BP3Avix6.js} +1 -1
  110. package/dist/{JsonViewer.vue_vue_type_script_setup_true_lang-ig2zSXAB.js → index-C25C1Dg7.js} +1074 -1066
  111. package/dist/index-eGvSlWMU.js +1892 -0
  112. package/dist/{index-ClYgfwW7.js → index-mzXhLwrZ.js} +2234 -2163
  113. package/dist/layout/SingleColumnLayout.vue.d.ts +1 -1
  114. package/dist/{lz-string-CCsc2X7t.js → lz-string-DMjWYCk6.js} +1 -1
  115. package/dist/menu-usage-module-Bq_KLsO4.js +74 -0
  116. package/dist/{netsuite-COumFXC2.js → netsuite-ZtoZBFBX.js} +254 -263
  117. package/dist/netsuite-explorer-h_vID_ao.js +79 -0
  118. package/dist/{predefined-templates-Bw9A9LNA.js → predefined-templates-CdurFRJ4.js} +1 -1
  119. package/dist/production-run-list-DR1WsaBR.js +61 -0
  120. package/dist/{purchase-order-template-BaZjdGq8.js → purchase-order-template-BVdCftEo.js} +1 -1
  121. package/dist/{recalculationUtils-t32wAurN.js → recalculationUtils-DBG8HGiJ.js} +1 -1
  122. package/dist/router/name.d.ts +2 -2
  123. package/dist/{row-action.enum-BDeudY4d.js → row-action.enum-CGyAg4dC.js} +1 -1
  124. package/dist/rules-DbFiOzUd.js +243 -0
  125. package/dist/{stock-B59sfN28.js → stock-BATH4SoA.js} +1 -1
  126. package/dist/stock-DXxsDPEO.js +78 -0
  127. package/dist/stores/feature.d.ts +40 -10
  128. package/dist/stores/feature.load-state.spec.d.ts +1 -0
  129. package/dist/stores/inventory.d.ts +0 -47
  130. package/dist/stores/inventory.no-location.spec.d.ts +1 -0
  131. package/dist/stores/supplier.d.ts +1 -1
  132. package/dist/stores/warehouse.d.ts +1 -1
  133. package/dist/style.css +1 -1
  134. package/dist/{supplier-DnbLJ_cS.js → supplier-CKXQmBZn.js} +2 -2
  135. package/dist/{surcharge-C1uE3uQa.js → surcharge-qupRJjjO.js} +1 -1
  136. package/dist/tsconfig.app.tsbuildinfo +1 -1
  137. package/dist/{uom-rules-DjfyrFHJ.js → uom-rules-ALtgjANX.js} +1 -1
  138. package/dist/{use-ingredient-select-dialog-7A7fWyEH.js → use-ingredient-select-dialog-C1sJpjfV.js} +2 -2
  139. package/dist/use-inventory-binding-dialog-tl7-epun.js +113 -0
  140. package/dist/{use-template-enabled-locations-C-Hqqgzt.js → use-template-enabled-locations-DWk2ndDC.js} +2 -2
  141. package/dist/{use-transfer-locations-CqsXvOI2.js → use-transfer-locations-CsdYY996.js} +14 -14
  142. package/dist/{useHrmPermission-BzwD3Ctc.js → useHrmPermission-BtuqUrwj.js} +1 -1
  143. package/dist/{useNavigationMenu-PrZg9HS7.js → useNavigationMenu-DKxKXykI.js} +111 -117
  144. package/dist/{useSseClient-FCyLWq8k.js → useSseClient-CRfpltKK.js} +1 -1
  145. package/dist/views/changelog/composables/use-snapshot-diff.d.ts +2 -2
  146. package/dist/views/closing-draft/composables/use-closing-draft-table.d.ts +1 -1
  147. package/dist/views/closing-draft/helpers/draft-status-to-class-name.helper.d.ts +1 -1
  148. package/dist/views/import/helper/submit-rows.d.ts +1 -1
  149. package/dist/views/ingredients/components/inventory-binding/InventoryBindingForm.vue.d.ts +0 -1
  150. package/dist/views/ingredients/components/inventory-binding/composables/use-inventory-binding-dialog.d.ts +0 -1
  151. package/dist/views/ingredients/components/inventory-binding/recipe-amount-validation.spec.d.ts +1 -0
  152. package/dist/views/ingredients/components/inventory-binding/v2/InventoryBindingFormV2.vue.d.ts +0 -1
  153. package/dist/views/ingredients/components/inventory-binding/v2/composables/use-inventory-binding-dialog.d.ts +0 -1
  154. package/dist/views/ingredients/helper/is-linked-ingredient-error.d.ts +3 -1
  155. package/dist/views/{ingredient-group/components/ingredient-group-rule-field/IngredientGroupRuleField.vue.d.ts → integration/IntegrationPlatformView.vue.d.ts} +11 -24
  156. package/dist/views/integration/components/Synergy/importFn.spec.d.ts +1 -0
  157. package/dist/views/integration/components/Xilnex/importFn.spec.d.ts +1 -0
  158. package/dist/views/integration/helper/opening-balance.d.ts +22 -0
  159. package/dist/views/integration/helper/opening-balance.spec.d.ts +1 -0
  160. package/dist/views/production-run/ProductionRunDetailPage.spec.d.ts +1 -0
  161. package/dist/views/{integration/components/IntegrationSyncLogTab.vue.d.ts → production-run/ProductionRunDetailPage.vue.d.ts} +2 -2
  162. package/dist/views/production-run/ProductionRunPage.vue.d.ts +2 -0
  163. package/dist/views/production-run/features/detail/ProductionRunItemsTable.vue.d.ts +2 -2
  164. package/dist/views/production-run/features/detail/ProductionRunOverviewTab.vue.d.ts +4 -4
  165. package/dist/views/production-run/features/detail/use-production-run-detail.d.ts +19 -9
  166. package/dist/views/production-run/features/lifecycle/CancelRunDialog.vue.d.ts +4 -4
  167. package/dist/views/production-run/features/lifecycle/CloseRunDialog.vue.d.ts +4 -4
  168. package/dist/views/production-run/features/lifecycle/ProductionRunLifecycleDialogs.vue.d.ts +14 -14
  169. package/dist/views/production-run/features/lifecycle/TargetReachedDialog.vue.d.ts +4 -4
  170. package/dist/views/production-run/features/planning/ProductionRunFormDialog.vue.d.ts +4 -4
  171. package/dist/views/production-run/features/planning/ProductionRunPlanner.vue.d.ts +1 -1
  172. package/dist/views/production-run/features/planning/use-production-run-duplicate-sources.d.ts +6 -6
  173. package/dist/views/production-run/shared/helpers/production-run-navigation.d.ts +0 -1
  174. package/dist/views/production-run/shared/model/production-run-list.d.ts +1 -1
  175. package/dist/views/production-run/shared/ui/ProductionRunInfoBadge.vue.d.ts +1 -1
  176. package/dist/views/production-run/shared/ui/ProductionRunInfoText.vue.d.ts +1 -1
  177. package/dist/views/production-run/shared/ui/ProductionRunScrollHint.vue.d.ts +2 -2
  178. package/dist/views/production-run/shared/ui/ProductionRunTextarea.vue.d.ts +3 -3
  179. package/dist/views/receive-request/composables/netsuite-order-label.d.ts +11 -0
  180. package/dist/views/receive-request/composables/netsuite-order-label.spec.d.ts +1 -0
  181. package/dist/views/receive-request/composables/use-process-purchase-order.d.ts +1 -1
  182. package/dist/views/receive-request/composables/use-receive-request-form.d.ts +9 -9
  183. package/dist/views/receive-request/composables/use-receive-request-form.spec.d.ts +1 -0
  184. package/dist/views/receive-request/composables/use-receive-request-table.d.ts +7 -7
  185. package/dist/views/receive-request/import/export.spec.d.ts +1 -0
  186. package/dist/views/receive-request-bulk/BulkReceiveRequestPage.vue.d.ts +2 -0
  187. package/dist/views/receive-request-bulk/components/CreateTransferWizard.spec.d.ts +1 -0
  188. package/dist/views/receive-request-bulk/composables/use-bulk-receive-request-form.d.ts +20 -20
  189. package/dist/views/receive-request-bulk/composables/use-bulk-receive-request-form.readiness.spec.d.ts +1 -0
  190. package/dist/views/receive-request-bulk/composables/use-bulk-receive-request-table.d.ts +2 -2
  191. package/dist/views/recipe/components/recipe-bulk-editor/components/ModificationCard.spec.d.ts +1 -0
  192. package/dist/views/recipe/helper/bulk-edit-simulation.helper.d.ts +0 -1
  193. package/dist/views/recipe/helper/import-recipe.d.ts +32 -2
  194. package/dist/views/recipe/helper/import-recipe.spec.d.ts +1 -0
  195. package/dist/views/settings/PlanLicenseDisplay.spec.d.ts +1 -0
  196. package/dist/views/settings/PlanLicenseDisplay.vue.d.ts +2 -0
  197. package/dist/views/stock/components/StockRecordCard.spec.d.ts +1 -0
  198. package/dist/views/stock/components/StockRecordCard.vue.d.ts +19 -865
  199. package/dist/views/stock/components/dialog/AmendAdjustmentForm.spec.d.ts +1 -0
  200. package/dist/views/stock/components/dialog/BillInventoryInfoDialog.spec.d.ts +1 -0
  201. package/dist/views/stock/components/dialog/BillInventoryInfoDialog.vue.d.ts +36 -0
  202. package/dist/views/stock/components/dialog/ConvertSkuDialog.spec.d.ts +1 -0
  203. package/dist/views/stock/composables/use-last-closing-summary.d.ts +4 -0
  204. package/dist/views/stock/composables/use-last-closing-summary.spec.d.ts +1 -0
  205. package/dist/views/transfer-template/components/transfer-template-form/composables/use-transfer-template-items.spec.d.ts +1 -0
  206. package/dist/views/transfer-template/helpers/template-item.error.helper.spec.d.ts +1 -0
  207. package/dist/views/unit/composables/use-unit-form.spec.d.ts +1 -0
  208. package/dist/views/warehouse/components/WarehouseForm.vue.d.ts +2 -2
  209. package/dist/vue-CVco8McV.js +290 -0
  210. package/dist/{vue-i18n-C34f-Tph.js → vue-i18n-C443zpcA.js} +450 -450
  211. package/dist/{xlsx.util-X4amwe_k.js → xlsx.util-5_47Kslf.js} +2 -2
  212. package/package.json +71 -66
  213. package/dist/App-DVHgBTHP.js +0 -1499
  214. package/dist/BulkReceiveRequestView-DxHWrfbi.js +0 -2656
  215. package/dist/ClosingHistoryView-kdpYGy1Y.js +0 -761
  216. package/dist/DeprecateSoonWarningDialog.vue_vue_type_script_setup_true_lang-5Cc08Svt.js +0 -58
  217. package/dist/FeatureCapabilityBadge.vue_vue_type_script_setup_true_lang-C1C8aDA6.js +0 -61
  218. package/dist/FmMultiselectDialog-yVPY5aBV.js +0 -77
  219. package/dist/ImportView-DQrVMzxN.js +0 -1302
  220. package/dist/IngredientBindedItem.vue_vue_type_script_setup_true_lang-7lT5UZc8.js +0 -51
  221. package/dist/IngredientGroupView-BMUnEaY7.js +0 -1000
  222. package/dist/InventoryBindingForm.vue_vue_type_script_setup_true_lang-CaBOK7NC.js +0 -563
  223. package/dist/NumberPrecisionInput.vue_vue_type_script_setup_true_lang-DzzTPdyF.js +0 -72
  224. package/dist/ProductionRunDetailView-Cw-ecaey.js +0 -2312
  225. package/dist/ProductionRunView-C11eseXQ.js +0 -930
  226. package/dist/RecipeView-oHDWsT0P.js +0 -3624
  227. package/dist/SettingsView-QlUNwFhM.js +0 -983
  228. package/dist/StockView-a8LbVZ_7.js +0 -2614
  229. package/dist/TableActionableRow.vue_vue_type_script_setup_true_lang-DAMpuZ1X.js +0 -84
  230. package/dist/TemplatePublishDialog.vue_vue_type_script_setup_true_lang-CCCj4WVF.js +0 -299
  231. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-CFNPXqt5.js +0 -4796
  232. package/dist/TransferTemplateView-CzwxOBMQ.js +0 -2326
  233. package/dist/menu-usage-module-BdjYEk3s.js +0 -57
  234. package/dist/number-gSLvxNqA.js +0 -138
  235. package/dist/portal-feature-catalog-yGIESKTc.js +0 -246
  236. package/dist/random-CSbEbElR.js +0 -10
  237. package/dist/rules-C1btu0Md.js +0 -98
  238. package/dist/stock-BF86TMW0.js +0 -75
  239. package/dist/use-inventory-binding-dialog-Cc1tjTfV.js +0 -152
  240. package/dist/usePromise-CbVUCxhj.js +0 -29
  241. package/dist/views/ingredient-group/components/ingredient-group-dialog/IngredientGroupDialog.vue.d.ts +0 -31
  242. package/dist/views/ingredient-group/components/ingredient-group-dialog/IngredientGroupDialogProps.d.ts +0 -10
  243. package/dist/views/ingredient-group/components/ingredient-group-form/IngredientGroupForm.vue.d.ts +0 -21
  244. package/dist/views/ingredient-group/components/ingredient-group-form/IngredientGroupFormProps.d.ts +0 -12
  245. package/dist/views/ingredient-group/composables/use-ingredient-group-actions.d.ts +0 -24
  246. package/dist/views/ingredient-group/composables/use-ingredient-group-rule-item.d.ts +0 -31
  247. package/dist/views/ingredient-group/composables/use-ingredient-group-table.d.ts +0 -77
  248. package/dist/views/integration/composables/use-integration-sync-log.d.ts +0 -45
@@ -1,4796 +0,0 @@
1
- import { f as lt, p as ks } from "./format-time-from-id-DatSI9uD.js";
2
- import { defineComponent as Ve, ref as ne, watch as Ye, createElementBlock as v, openBlock as i, createCommentVNode as V, createElementVNode as e, withDirectives as Os, toDisplayString as k, unref as h, vModelText as xs, toRaw as ws, shallowRef as dt, onUnmounted as rs, triggerRef as $s, computed as H, readonly as Cs, h as re, resolveComponent as oe, createVNode as T, Fragment as Ce, renderList as Te, reactive as As, onMounted as os, createBlock as he, withCtx as ce, createTextVNode as Ge, normalizeClass as We, renderSlot as Ds, isRef as Rs, resolveDynamicComponent as Ns } from "vue";
3
- import { c as Ht } from "./component-BmLAdDiY.js";
4
- import { D as qe, R as Re } from "./row-action.enum-BDeudY4d.js";
5
- import { q as Ae, H as st, d as Ps, u as ze, _ as z, a3 as ns, a4 as yt, Z as ge, a as Dt, a5 as Gt, a6 as Fs, a7 as Is, G as Ts, s as Rt, c as wt, M as Wt, a8 as as, r as at, C as Ue, w as Pe, B as mt, a9 as Es } from "./app-yvK__CBL.js";
6
- import { h as Nt, a as qs, t as Vs, b as et } from "./date2-2XjepIqc.js";
7
- import { j as Ls, c as js, a as $e, t as Qe, d as ut } from "./number-gSLvxNqA.js";
8
- import { F as Be, u as Je, c as Us, b as Qt, d as St } from "./feature-CkWaZ-5K.js";
9
- import { L as Ms } from "./lz-string-CCsc2X7t.js";
10
- import { useI18n as ht, useCoreStore as bt } from "@feedmepos/mf-common";
11
- import { useDialog as gt, useSnackbar as Ze, components as pt, FmButtonVariant as je, useProxiedModel as Bs } from "@feedmepos/ui-library";
12
- import { u as _t, a as Pt, S as Me } from "./netsuite-COumFXC2.js";
13
- import { F as tt } from "./FmAdminBadge-DlplQOHb.js";
14
- import { _ as Yt } from "./empty-placeholder-B0QU467o.js";
15
- import { a as zs, b as Ks, f as ft } from "./format-unit-display-DM5We5cx.js";
16
- import { u as Xe, _ as Hs } from "./SystemTrailDialog.vue_vue_type_script_setup_true_lang-CpkF77Ow.js";
17
- import { _ as Gs, a as Ws, b as Qs } from "./FmUnitInput.vue_vue_type_script_setup_true_lang-ClaLVtpK.js";
18
- import { u as Ys, R as Jt } from "./usePromise-CbVUCxhj.js";
19
- import { e as Js } from "./index-7fz5sGDO.js";
20
- import { i as Zs } from "./FmDateRangePickerChip.vue_vue_type_script_setup_true_lang-Q8Mptiv3.js";
21
- import { F as Zt } from "./form-mode.enum-BKiNVH6A.js";
22
- import { u as ls } from "./supplier-DnbLJ_cS.js";
23
- import { u as Xs } from "./surcharge-C1uE3uQa.js";
24
- import { f as er, h as tr, r as sr, s as rr } from "./predefined-templates-Bw9A9LNA.js";
25
- import { F as or } from "./decimal-Z7oJdGk8.js";
26
- import { d as is } from "./defineDeepModel-CMxJn_H2.js";
27
- import { u as nr } from "./vue-i18n-C34f-Tph.js";
28
- import { u as ar } from "./useHrmPermission-BzwD3Ctc.js";
29
- function us(d, t) {
30
- return t.reduce(
31
- (n, m) => {
32
- const u = m.received.find((c) => c.sku._id === d._id);
33
- return u && (n = Ls(n, u.amount)), n;
34
- },
35
- or.toPrecision(js(0), d.unit.precision)
36
- );
37
- }
38
- function cs(d) {
39
- var n;
40
- const t = Ae(), r = (n = d.supplier.supplyItems) != null && n.length ? { ...d.supplier, registrationNumber: d.supplier.registrationNumber ?? "" } : void 0;
41
- return (m) => {
42
- var u, c;
43
- if ((u = m.totalCost) != null && u.amount) return m.totalCost;
44
- if (!m.isCustomCost)
45
- try {
46
- const { cost: s } = Be.calculateDefaultCost({
47
- item: m.sku,
48
- amount: m.quantity,
49
- measurement: m.measurement,
50
- overrides: r ? { supplier: r } : void 0,
51
- defaultCurrency: t
52
- });
53
- return s.amount ? s : void 0;
54
- } catch (s) {
55
- console.warn("[print] cost auto-calculation failed for item", (c = m.sku) == null ? void 0 : c._id, s);
56
- return;
57
- }
58
- };
59
- }
60
- function lr(d) {
61
- var Se, De, K, ve, P, x, w;
62
- const { po: t, currentLocation: r, business: n, fulfilling: m, por: u } = d, c = r.doc.profile || {}, { name: s, address: a, regNo: O, legalName: f } = c, R = {
63
- name: s || r.name || "",
64
- legalName: f || void 0,
65
- registrationNumber: O || void 0,
66
- line1: (a == null ? void 0 : a.line1) || "",
67
- line2: (a == null ? void 0 : a.line2) || void 0,
68
- postcode: (a == null ? void 0 : a.postcode) || "",
69
- city: (a == null ? void 0 : a.city) || "",
70
- state: (a == null ? void 0 : a.state) || "",
71
- country: (a == null ? void 0 : a.country) || ""
72
- }, N = {
73
- name: t.supplier.name,
74
- phoneNumber: t.supplier.phoneNumber || void 0,
75
- registrationNumber: t.supplier.registrationNumber || void 0,
76
- line1: ((Se = t.supplier.address) == null ? void 0 : Se.line1) || "",
77
- line2: ((De = t.supplier.address) == null ? void 0 : De.line2) || void 0,
78
- postcode: ((K = t.supplier.address) == null ? void 0 : K.postcode) || "",
79
- city: ((ve = t.supplier.address) == null ? void 0 : ve.city) || "",
80
- state: ((P = t.supplier.address) == null ? void 0 : P.state) || "",
81
- country: ((x = t.supplier.address) == null ? void 0 : x.country) || ""
82
- }, F = cs(t), _ = [], B = t.items.filter((A) => A.sku).map((A) => {
83
- var D;
84
- const { sku: G, measurement: X } = A, le = $e(
85
- us(A.sku, t.deliveryOrder || []),
86
- !1
87
- ), b = F(A);
88
- return b && _.push(b), {
89
- code: G.code,
90
- description: G.name,
91
- quantity: $e(A.quantity, !1),
92
- unit: (X == null ? void 0 : X.abbrev) || ((D = G.unit) == null ? void 0 : D.abbrev) || "",
93
- received: le,
94
- unitCost: b ? `${b.currency} ${Be.toFormatString({
95
- value: A.quantity.amount === 0 ? Be.fromNumber(0) : Be.divide([b, A.quantity])
96
- })}` : void 0,
97
- cost: b ? `${b.currency} ${Be.toFormatString({
98
- value: b
99
- })}` : void 0
100
- };
101
- }), E = _.length ? `${_[0].currency} ${Be.toFormatString({
102
- value: _.reduce((A, G) => Be.add([A, G]), Be.reset())
103
- })}` : void 0, te = (t.deliveryOrder || []).map((A) => ({
104
- createdAt: Nt(new Date(A.createdAt)),
105
- ref: A.deliveryOrderNumber,
106
- remark: A.remark || "",
107
- items: (A.received || []).map((G) => {
108
- var X, le, b, D, ie;
109
- return {
110
- code: ((X = G.sku) == null ? void 0 : X.code) || "",
111
- description: ((le = G.sku) == null ? void 0 : le.name) || "",
112
- quantity: $e(G.amount),
113
- unit: ((b = G.measurement) == null ? void 0 : b.abbrev) || ((ie = (D = G.sku) == null ? void 0 : D.unit) == null ? void 0 : ie.abbrev) || ""
114
- };
115
- })
116
- }));
117
- let se = st.Enum.purchaseOrder, Q = "Inventory Receive Note";
118
- if (t.supplier.internal ? (Q = "Inventory Transfer Note", se = st.Enum.transferOrder) : (Q = "Purchase Order", se = st.Enum.purchaseOrder), (w = u == null ? void 0 : u.from) != null && w.dbName) {
119
- const A = u.from.dbName;
120
- r.dbName === A || (Q = "Inventory Receive Note", se = st.Enum.goodsReceivedNote);
121
- }
122
- const Oe = {
123
- title: Q,
124
- businessName: n == null ? void 0 : n.name,
125
- logo: n == null ? void 0 : n.thumbnail,
126
- orderNumber: t.seqNumber.toString(),
127
- createdAt: lt(t._id),
128
- ref: t.ref || "",
129
- remark: t.remark || "",
130
- buyer: R,
131
- supplier: N,
132
- items: B,
133
- grandTotal: E,
134
- status: t.status,
135
- deliveryOrders: te
136
- }, ae = m && (t.deliveryFullfillment || []).length > 0;
137
- return ae && (se = st.Enum.deliveryOrder), { printData: Oe, templateType: se, isDeliveryPrint: ae };
138
- }
139
- function ds(d) {
140
- var f;
141
- const { printData: t, templateType: r } = lr(d), m = er().getTemplateByType(r), u = !!((f = m == null ? void 0 : m.blocks) != null && f.length), c = tr(r), s = u ? m.blocks : c.blocks, a = u ? m.name : c.name, O = !u;
142
- try {
143
- const R = sr(s, t), N = R.match(/<style>([\s\S]*?)<\/style>/), F = N ? `<style>${N[1]}</style>` : "", _ = R.replace(/<style>[\s\S]*?<\/style>/, "");
144
- return {
145
- html: `<!DOCTYPE html>
146
- <html>
147
- <head>
148
- <meta charset="utf-8">
149
- <title>Print Preview</title>
150
- <style>
151
- @page { margin: 0; }
152
- @media print {
153
- body { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
154
- }
155
- * { box-sizing: border-box; margin: 0; padding: 0; }
156
- </style>
157
- ${F}
158
- </head>
159
- <body>${_}</body>
160
- </html>`,
161
- templateName: a,
162
- isDefault: O
163
- };
164
- } catch {
165
- return alert("Failed to render print template. Please try recreating the template."), null;
166
- }
167
- }
168
- const ir = Ps((d, t) => {
169
- const r = ze();
170
- return {
171
- async getShipments({
172
- start: n,
173
- end: m
174
- }) {
175
- const u = r.currentLocationDBName, c = `${d.inventoryBackendUrl}/${u}/shipments`;
176
- return await t.get(`${c}?start=${n}&end=${m}`);
177
- },
178
- async getShipmentsByIds(n) {
179
- if (n.length === 0)
180
- return [];
181
- const m = r.currentLocationDBName, u = `${d.inventoryBackendUrl}/${m}/shipments/get`;
182
- return await t.post(u, { shipmentIds: n });
183
- }
184
- };
185
- }), ms = {
186
- [z.enum.confirmDraft]: {
187
- primaryActions: {
188
- text: "Confirm draft",
189
- close: !0
190
- },
191
- title: "Confirm draft?",
192
- message: "Purchase order cannot be changed after confirm draft.",
193
- successMessage: "Purchase order draft has been confirmed"
194
- },
195
- [z.enum.cancelDraft]: {
196
- primaryActions: {
197
- text: "Cancel draft",
198
- close: !0,
199
- variant: "destructive"
200
- },
201
- title: "Cancel draft?",
202
- message: "Purchase order cannot be changed after cancelled draft.",
203
- successMessage: "Purchase order draft has been cancelled"
204
- },
205
- [z.enum.approveDraft]: {
206
- primaryActions: {
207
- text: "Approve draft",
208
- close: !0
209
- },
210
- title: "Approve draft?",
211
- message: "Purchase order request will be accepted.",
212
- successMessage: "Purchase order has been approved"
213
- },
214
- [z.enum.rejectDraft]: {
215
- primaryActions: {
216
- text: "Reject draft",
217
- close: !0
218
- },
219
- title: "Reject draft?",
220
- message: "Purchase order request will be rejected. You may provide an optional reason for rejection.",
221
- successMessage: "Purchase order has been rejected"
222
- },
223
- [z.enum.submitRequest]: {
224
- primaryActions: {
225
- text: "Submit request",
226
- close: !0
227
- },
228
- title: "Confirm draft?",
229
- message: "Purchase order cannot be changed after confirm draft.",
230
- successMessage: "Purchase order draft has been submitted"
231
- },
232
- [z.enum.completeReceive]: {
233
- primaryActions: {
234
- text: "Mark received",
235
- close: !0
236
- },
237
- title: "Mark as received",
238
- message: "Purchase order cannot be changed after it has complete receiving.",
239
- successMessage: "Purchase order has been marked as received"
240
- },
241
- [z.enum.approveRequest]: {
242
- primaryActions: {
243
- text: "Accept request",
244
- close: !0
245
- },
246
- title: "Accept request?",
247
- message: "Transfer out request will be accepted.",
248
- successMessage: "Transfer out request has been approved"
249
- },
250
- [z.enum.rejectRequest]: {
251
- primaryActions: {
252
- text: "Reject request",
253
- close: !0,
254
- variant: "destructive"
255
- },
256
- title: "Reject request?",
257
- message: "Purchase order will be rejected.",
258
- successMessage: "Purchase order has been rejected"
259
- },
260
- [z.enum.processRequest]: {
261
- primaryActions: {
262
- text: "Process request",
263
- close: !0,
264
- variant: "destructive"
265
- },
266
- title: "Process request?",
267
- message: "Purchase order will be processed.",
268
- successMessage: "Purchase order has been processed"
269
- }
270
- }, ur = { class: "p-4" }, cr = {
271
- key: 0,
272
- class: "fm-typo-en-body-md-400 mb-3"
273
- }, dr = { class: "fm-typo-en-body-md-400" }, ps = /* @__PURE__ */ Ve({
274
- __name: "RejectDraftForm",
275
- props: {
276
- message: {},
277
- confirm: { type: Function },
278
- onChange: { type: Function }
279
- },
280
- setup(d) {
281
- const t = d, { t: r } = ht(), n = ne("");
282
- Ye(n, (u) => {
283
- var c;
284
- (c = t.onChange) == null || c.call(t, u ?? "");
285
- });
286
- function m() {
287
- n.value = "";
288
- }
289
- return (u, c) => (i(), v("div", ur, [
290
- t.message ? (i(), v("div", cr, k(t.message), 1)) : V("", !0),
291
- e("label", dr, k(h(r)("inventory.transfer.receiveRequest.details.rejectionReason")) + " (" + k(h(r)("inventory.common.optional")) + ")", 1),
292
- Os(e("textarea", {
293
- "onUpdate:modelValue": c[0] || (c[0] = (s) => n.value = s),
294
- rows: "4",
295
- class: "w-full mt-2 p-2 border rounded"
296
- }, null, 512), [
297
- [xs, n.value]
298
- ]),
299
- e("div", { class: "mt-3 flex gap-2" }, [
300
- e("button", {
301
- type: "button",
302
- class: "fm-btn fm-btn-tertiary",
303
- onClick: m
304
- }, "Clear")
305
- ])
306
- ]));
307
- }
308
- });
309
- function vt(d) {
310
- if (d.items == null)
311
- return {};
312
- const t = ns.safeParse(d);
313
- if (!t.success) {
314
- const r = t.error.issues.map((n) => `${n.path.join(".") || "(root)"}: ${n.message}`).join("; ");
315
- return console.error(
316
- `Cannot compute receive status for PO ${d == null ? void 0 : d._id}: invalid shape at ${r}`
317
- ), {};
318
- }
319
- return yt.generatedPOReceivedMap({
320
- purchaseOrder: d
321
- });
322
- }
323
- function mr(d) {
324
- return yt.validatePOItemReceivedStatus({
325
- dto: d
326
- });
327
- }
328
- function $t(d) {
329
- return yt.validatePOReceivedStatus({
330
- receivedMap: d
331
- });
332
- }
333
- function Ct(d, t, r) {
334
- if (!ge.safeParse(d).success)
335
- throw new Error(`Invalid purchase order status: ${d}`);
336
- const n = ge.parse(d);
337
- return yt.orderStatusCombination({
338
- status: n,
339
- isPOPartialReceive: t,
340
- isPOOverReceive: r
341
- });
342
- }
343
- function fs() {
344
- const d = ze(), t = Xe(), r = Je();
345
- async function n(u, c) {
346
- const s = d.currentLocationDBName;
347
- return u.doc.supplier.internal && u.operation === z.enum.confirmDraft && (u.operation = z.enum.submitRequest), await t.processPurchaseOrder(u, c || s);
348
- }
349
- async function m(u, c) {
350
- const s = d.currentLocationDBName;
351
- return await t.processPurchaseOrderV2(u, c || s);
352
- }
353
- return (u) => r.useOperatePurchaseOrderV2 ? m(u.operateV2, u.transferTo) : n(u.operate, u.transferTo);
354
- }
355
- function He(d) {
356
- const t = ws(d);
357
- if (Array.isArray(t))
358
- return t.map(He);
359
- if (t !== null && typeof t == "object") {
360
- const r = {};
361
- for (const n in t)
362
- Object.prototype.hasOwnProperty.call(t, n) && (r[n] = He(t[n]));
363
- return r;
364
- }
365
- return t;
366
- }
367
- const kt = {
368
- set: "set",
369
- add: "add",
370
- delete: "delete"
371
- };
372
- function Xt(d) {
373
- return {
374
- dbName: d.dbName,
375
- type: d.type,
376
- name: d.name,
377
- acceptRequest: d.acceptRequest ?? !1,
378
- doc: d.doc
379
- };
380
- }
381
- const vs = { line1: "", state: "", city: "", postcode: "", country: "" };
382
- function rt(d) {
383
- return d == null ? "" : String(d);
384
- }
385
- function ys(d) {
386
- const t = d.address, r = t != null ? {
387
- ...t,
388
- line1: rt(t.line1),
389
- state: rt(t.state),
390
- city: rt(t.city),
391
- postcode: rt(t.postcode),
392
- country: rt(t.country)
393
- } : { ...vs };
394
- return {
395
- ...d,
396
- registrationNumber: d.registrationNumber ?? "",
397
- address: r
398
- };
399
- }
400
- function es(d, t, r, n, m) {
401
- const u = He(d.suppliers ?? []).map(ys), c = He(t.allLocations ?? []).map(Xt), s = t._currentLocation ? Xt(He(t._currentLocation)) : null, a = r.inventory ? [He(r.inventory)] : [], O = n.state.setting ? He(n.state.setting) : null, f = He(m.surcharges ?? []);
402
- return {
403
- suppliers: u,
404
- locations: c,
405
- currentLocation: s,
406
- inventoryDoc: a,
407
- netSuiteSetting: O,
408
- surcharges: f
409
- };
410
- }
411
- function hs() {
412
- const d = ls(), t = ze(), r = Dt(), n = _t(), m = Xs(), u = es(
413
- d,
414
- t,
415
- r,
416
- n,
417
- m
418
- ), c = dt(Us({ env: u }));
419
- c.value.setUsePartialUpdates(!0);
420
- const s = dt(c.value.state()), a = (N) => {
421
- s.value = c.value.state();
422
- };
423
- c.value.addListener(a);
424
- const O = (N, F, _) => {
425
- switch (N) {
426
- case kt.set:
427
- Gt(s.value, F, _);
428
- break;
429
- case kt.add:
430
- Is(s.value, F, _);
431
- break;
432
- case kt.delete:
433
- Fs(s.value, F);
434
- break;
435
- default:
436
- console.warn(`Unknown partial update operation: ${N}, falling back to 'set'`), Gt(s.value, F, _);
437
- }
438
- F !== "remark" && F !== "ref" && $s(s);
439
- };
440
- c.value.addPartialListener(O);
441
- function f() {
442
- const N = es(
443
- d,
444
- t,
445
- r,
446
- n,
447
- m
448
- );
449
- try {
450
- c.value.updateFullEnv(N), s.value = c.value.state();
451
- } catch (F) {
452
- console.error("[PurchaseOrderFormController] updateFullEnv failed", F);
453
- }
454
- }
455
- Ye(
456
- [
457
- () => d.suppliers,
458
- () => t.allLocations,
459
- () => t._currentLocation,
460
- () => r.inventory,
461
- () => n.state.setting,
462
- () => m.surcharges
463
- ],
464
- () => {
465
- f();
466
- },
467
- { deep: !0 }
468
- ), rs(() => {
469
- c.value.removeListener(a), c.value.removePartialListener(O);
470
- });
471
- function R(N) {
472
- var F;
473
- if (N != null && N._id) {
474
- const _ = /* @__PURE__ */ new Set(["1", "2"]), B = N, E = B.supplier, te = E != null ? ys(E) : { _id: "", name: "", registrationNumber: "", address: { ...vs } }, se = {
475
- ...N,
476
- version: _.has(N.version) ? N.version : null,
477
- supplier: te,
478
- // items/deliveryOrder may be absent or contain null/corrupted elements.
479
- // The Dart bridge has no null guards on sku, sku.unit, and quantity —
480
- // all three produce "Uncaught (in promise) TypeError: $index on null".
481
- items: (B.items ?? []).filter((Q) => {
482
- if (Q == null || Q.sku == null || typeof Q.sku != "object") return !1;
483
- const de = Q;
484
- return de.sku.unit != null && de.quantity != null && typeof de.quantity == "object";
485
- }),
486
- // received[].sku/sku.unit/amount have the exact same Dart-bridge null-guard
487
- // gap as items[].sku/sku.unit/quantity above — filter the same way.
488
- deliveryOrder: (B.deliveryOrder ?? []).filter((Q) => Q != null).map((Q) => ({
489
- ...Q,
490
- received: (Q.received ?? []).filter((de) => {
491
- if (de == null || de.sku == null || typeof de.sku != "object") return !1;
492
- const Oe = de;
493
- return Oe.sku.unit != null && Oe.amount != null && typeof Oe.amount == "object";
494
- })
495
- }))
496
- };
497
- try {
498
- c.value.loadPurchaseOrder(se);
499
- } catch (Q) {
500
- console.error("[PurchaseOrderFormController] loadPurchaseOrder failed", Q);
501
- }
502
- return;
503
- }
504
- if (!Je().mustUsePoTemplate) {
505
- c.value.init();
506
- return;
507
- }
508
- N != null && N.template && ((F = N.templateDoc) != null && F.purchaseOrder) ? (N.items = N.templateDoc.purchaseOrder.items, c.value.initFromTemplate(N)) : c.value.initOutletToOutlet();
509
- }
510
- return {
511
- controller: c,
512
- state: s,
513
- init: R
514
- };
515
- }
516
- var At = /* @__PURE__ */ ((d) => (d.RECEIVE_REQUEST = "receive/request", d.APPROVAL = "approval", d))(At || {});
517
- const ot = ne(), Ot = ne(), xt = ne();
518
- function hi(d, t) {
519
- const r = gt(), n = ze(), m = Je(), u = ls(), c = bt(), s = zs(), a = Ks(), O = ne(!1), f = Ze(), R = Xe(), N = ir(), F = ne(new Array()), _ = ne(new Array()), B = ne(
520
- t != null && t.startDate && (t != null && t.endDate) ? t : Zs()
521
- ), E = H(() => {
522
- const b = new Date(B.value.startDate), D = new Date(B.value.endDate);
523
- return {
524
- start: Vs(b).toISOString(),
525
- end: qs(D).toISOString()
526
- };
527
- }), te = ne(new Array()), se = Ts(), Q = ne(null);
528
- async function de(b) {
529
- function D(ee) {
530
- const L = {
531
- mode: Zt.CREATE,
532
- modelValue: b || void 0,
533
- show: !0,
534
- "onUpdate:show"(g) {
535
- ot.value.show = g;
536
- },
537
- templateId: ee,
538
- lastClosingDate: Q.value
539
- };
540
- ot.value = L;
541
- }
542
- let ie;
543
- m.mustUsePoTemplate && !(b != null && b.template) ? r.open({
544
- title: "Create transfer",
545
- message: "",
546
- primaryActions: {
547
- text: "Select a template",
548
- close: !0
549
- },
550
- secondaryActions: {
551
- text: "Outlet to Outlet",
552
- variant: "secondary",
553
- close: !0
554
- }
555
- }).onPrimary(async () => {
556
- ie = await s.getTemplateId(), ie && D(ie);
557
- }).onSecondary(() => {
558
- D(void 0);
559
- }) : D(ie);
560
- }
561
- function Oe(b) {
562
- const D = {
563
- mode: Zt.UPDATE,
564
- modelValue: wt(b),
565
- show: !0,
566
- "onUpdate:show"(ie) {
567
- ot.value.show = ie;
568
- },
569
- lastClosingDate: Q.value
570
- };
571
- ot.value = D;
572
- }
573
- function ae(b) {
574
- if (!c.currentBusiness.value) return;
575
- const D = n.currentLocation;
576
- if (D.type === "restaurant") {
577
- const j = n.locationRestaurantFromCore(D.doc._id);
578
- j !== null && (D.doc = j);
579
- }
580
- const ie = ds({
581
- po: b,
582
- currentLocation: D,
583
- business: c.currentBusiness.value,
584
- fulfilling: d === "approval",
585
- por: b.request
586
- });
587
- if (!ie) return;
588
- const ee = rr(ie.html), L = u.supplierById[b.supplier._id], g = {
589
- recipientName: L.name,
590
- email: (L == null ? void 0 : L.email) ?? "",
591
- business: c.currentBusiness.value,
592
- modelValue: ee,
593
- show: !0,
594
- "onUpdate:show"(j) {
595
- Ot.value.show = j;
596
- }
597
- };
598
- Ot.value = g;
599
- }
600
- async function Se() {
601
- F.value = [], _.value = [], O.value = !0;
602
- try {
603
- const b = await R.getPurchaseOrders(E.value);
604
- F.value = b.sort((j, J) => J._id.localeCompare(j._id));
605
- const D = b.flatMap((j) => j.shipmentIds || []).filter(Boolean), ie = D.length > 0 ? await N.getShipmentsByIds(D) : [];
606
- _.value = ie;
607
- const ee = await se.readCurrentLocationLastClosing(!0), L = ee == null ? void 0 : ee._id;
608
- L && (Q.value = ks(L)), await m.awaitFeatureLoaded(() => m.mustUsePoTemplate) && await a.fetchTemplates();
609
- const g = F.value.map((j) => {
610
- var J;
611
- return ((J = j.request) == null ? void 0 : J.id) ?? "";
612
- }).filter((j) => j);
613
- te.value = await R.readRequestByIds(g);
614
- } catch {
615
- f.open({
616
- title: "Something went wrong",
617
- message: "Error at fetching purchase orders",
618
- type: "error"
619
- });
620
- } finally {
621
- O.value = !1;
622
- }
623
- }
624
- async function De() {
625
- te.value = [], O.value = !0;
626
- try {
627
- te.value = await R.readRequests(
628
- void 0,
629
- E.value.start,
630
- E.value.end
631
- ).then((b) => b.reverse());
632
- } catch {
633
- f.open({
634
- title: "Something went wrong",
635
- message: "Error at fetching purchase requests",
636
- type: "error"
637
- });
638
- } finally {
639
- O.value = !1;
640
- }
641
- }
642
- function K() {
643
- switch (d) {
644
- case "receive/request":
645
- return Se();
646
- case "approval":
647
- return De();
648
- }
649
- }
650
- function ve(b, D) {
651
- B.value = {
652
- startDate: b,
653
- endDate: D
654
- }, K();
655
- }
656
- n.watchLocation(async (b) => {
657
- if (!b) {
658
- F.value = [];
659
- return;
660
- }
661
- await K();
662
- });
663
- async function P(b) {
664
- return b;
665
- }
666
- const x = ne(), w = ne(Math.random().toString());
667
- async function A(b, D) {
668
- const ie = Math.random().toString();
669
- w.value = ie, D ?? (D = te.value.computeFirst(
670
- (j) => j.purchaseOrderId === b._id ? j : null
671
- ) ?? void 0);
672
- const ee = d === "receive/request" ? n.currentLocation : D == null ? void 0 : D.to, L = d === "approval", g = {
673
- poRequest: D,
674
- purchaseOrder: {
675
- ...b,
676
- status: L && (D != null && D.rejectedAt) ? ge.Enum.REJECT : b.status
677
- },
678
- transferTo: ee == null ? void 0 : ee.name,
679
- transferToDbName: ee == null ? void 0 : ee.dbName,
680
- show: !0,
681
- canResubmit: !1,
682
- canApprove: L,
683
- "onUpdate:show"(j) {
684
- x.value && (x.value = { ...x.value, show: j });
685
- },
686
- scope: d,
687
- receivedMap: vt(b) ?? {},
688
- shipments: _.value
689
- };
690
- x.value = g;
691
- }
692
- async function G(b, D, ie, ee, L) {
693
- const g = fs();
694
- O.value = !0;
695
- try {
696
- await g({
697
- operate: {
698
- operation: D,
699
- doc: b,
700
- options: (
701
- // auto receive for supplier to warehouse
702
- (D === z.enum.confirmDraft || // auto receive for warehouse to warehouse
703
- D === z.enum.completeReceive) && m.autoReceiveWarehouse ? {
704
- autoReceive: !0
705
- } : void 0
706
- )
707
- },
708
- operateV2: {
709
- _id: b._id,
710
- _rev: b._rev ?? "",
711
- action: D === z.enum.submitRequest ? z.enum.confirmDraft : D,
712
- payloads: L ?? []
713
- },
714
- transferTo: ee
715
- }), await new Promise((me) => setTimeout(me, 1e3));
716
- const J = ze().currentLocationDBName.startsWith("restaurant_");
717
- D === z.enum.confirmDraft && b.effectiveAt && J ? f.open({
718
- title: "Success",
719
- message: `${ie}. The backdate will be reflected once your POS has received this change.`,
720
- type: "success"
721
- }) : f.open({
722
- title: "Success",
723
- message: ie,
724
- type: "success"
725
- });
726
- } catch (j) {
727
- f.open({
728
- title: "Something went wrong",
729
- message: j instanceof Error ? j.message : "Please try again.",
730
- type: "error"
731
- }), console.error("Error when submitting PO operation", D, b, j);
732
- } finally {
733
- O.value = !1, K();
734
- }
735
- }
736
- async function X(b, D, ie) {
737
- const ee = ms[D];
738
- if (!ee) {
739
- f.open({
740
- title: "Something went wrong",
741
- message: `Cannot process order: ${Rt(D)}`,
742
- type: "error"
743
- });
744
- return;
745
- }
746
- const { successMessage: L, ...g } = ee;
747
- if (D === z.enum.rejectDraft) {
748
- let me = "";
749
- r.open({
750
- title: g.title,
751
- message: g.message,
752
- primaryActions: g.primaryActions,
753
- contentComponent: ps,
754
- contentComponentProps: {
755
- message: g.message,
756
- onChange: (ke) => me = ke
757
- }
758
- }).onPrimary(() => {
759
- const ke = [];
760
- ke.push({
761
- action: "rejectDraft",
762
- payload: {
763
- rejectReason: me
764
- }
765
- }), G(b, D, L, ie, ke);
766
- });
767
- return;
768
- }
769
- const j = [], J = hs();
770
- J.init(b), (D === z.enum.confirmDraft || D === z.enum.submitRequest) && j.push({
771
- action: "confirmDraft",
772
- payload: J.controller.value.toConfirmDraftData(Ae())
773
- }), r.open({
774
- title: g.title,
775
- message: g.message,
776
- primaryActions: g.primaryActions
777
- }).onPrimary(() => {
778
- G(b, D, L, ie, j);
779
- });
780
- }
781
- async function le() {
782
- r.open({
783
- title: "Upload Transfer",
784
- primaryActions: {
785
- text: "Xilnex transfer note",
786
- close: !0
787
- },
788
- secondaryActions: {
789
- text: "Cancel",
790
- close: !0
791
- }
792
- }).onPrimary(() => {
793
- const b = {
794
- show: !0,
795
- "onUpdate:show"(D) {
796
- xt.value.show = D;
797
- }
798
- };
799
- xt.value = b;
800
- });
801
- }
802
- return {
803
- purchaseOrders: F,
804
- shipments: _,
805
- purchaseRequests: te,
806
- updateDateRange: ve,
807
- fetchData: K,
808
- loading: O,
809
- transferDialogProps: ot,
810
- promptCreateTransferDialog: de,
811
- promptUpdateTransferDialog: Oe,
812
- transferDetailsProps: x,
813
- promptShowTransferDetails: A,
814
- resolvePO: P,
815
- submitAction: X,
816
- xilnexImportDialogProps: xt,
817
- promptUploadTransferDialog: le,
818
- emailDialogProps: Ot,
819
- promptEmailDialog: ae
820
- };
821
- }
822
- function pr(d) {
823
- var ae, Se, De, K, ve, P;
824
- const { po: t, currentLocation: r, business: n, fulfilling: m, por: u } = d, { name: c, address: s, regNo: a, legalName: O } = r.doc.profile, f = {
825
- name: c,
826
- legalName: O,
827
- registrationNumber: a,
828
- line1: s == null ? void 0 : s.line1,
829
- line2: s == null ? void 0 : s.line2,
830
- postcode: s == null ? void 0 : s.postcode,
831
- city: s == null ? void 0 : s.city,
832
- state: s == null ? void 0 : s.state,
833
- country: s == null ? void 0 : s.country
834
- }, R = {
835
- name: t.supplier.name,
836
- phoneNumber: t.supplier.phoneNumber,
837
- registrationNumber: t.supplier.registrationNumber,
838
- line1: (ae = t.supplier.address) == null ? void 0 : ae.line1,
839
- line2: (Se = t.supplier.address) == null ? void 0 : Se.line2,
840
- postcode: (De = t.supplier.address) == null ? void 0 : De.postcode,
841
- city: (K = t.supplier.address) == null ? void 0 : K.city,
842
- state: (ve = t.supplier.address) == null ? void 0 : ve.state,
843
- country: (P = t.supplier.address) == null ? void 0 : P.country
844
- }, N = cs(t), F = t.items.map((x) => {
845
- const { sku: w, measurement: A } = x, G = $e(
846
- us(x.sku, t.deliveryOrder || []),
847
- !1
848
- ), X = N(x);
849
- return {
850
- code: w.code,
851
- description: w.name,
852
- quantity: $e(x.quantity, !1),
853
- unit: (A == null ? void 0 : A.abbrev) || w.unit.abbrev,
854
- received: G,
855
- cost: X ? `${X.currency} ${Be.toFormatString({
856
- value: X
857
- })}` : void 0
858
- };
859
- }), _ = t.deliveryOrder.map((x) => ({
860
- createdAt: Nt(new Date(x.createdAt)),
861
- ref: x.deliveryOrderNumber,
862
- remark: x.remark || "",
863
- items: x.received.map((w) => {
864
- var A;
865
- return {
866
- code: w.sku.code,
867
- description: w.sku.name,
868
- quantity: $e(w.amount),
869
- unit: ((A = w.measurement) == null ? void 0 : A.abbrev) || w.sku.unit.abbrev
870
- };
871
- })
872
- })), B = [
873
- // Production
874
- "67ca5d2c80bd0e001c5bf5bc",
875
- // Dev
876
- "6880b36a3054c5001db19218"
877
- ];
878
- let E = "Inventory Receive Note";
879
- if (t.supplier.internal ? (E = "Inventory Transfer Note", B.includes((n == null ? void 0 : n._id) || "") && (E = "Stock Request")) : E = "Purchase Order", u) {
880
- const x = u.from.dbName;
881
- r.dbName === x || (E = "Inventory Receive Note");
882
- }
883
- const se = {
884
- title: E,
885
- businessName: n == null ? void 0 : n.name,
886
- logo: n == null ? void 0 : n.thumbnail,
887
- orderNumber: t.seqNumber.toString(),
888
- createdAt: lt(t._id),
889
- ref: t.ref || "",
890
- remark: t.remark || "",
891
- buyer: f,
892
- supplier: R,
893
- items: F,
894
- status: t.status,
895
- deliveryOrders: _
896
- }, Q = new URL(window.location.href), de = m && (t.deliveryFullfillment || []).length > 0 ? "receive-request/delivery-print-preview" : "receive-request/print-preview";
897
- Q.pathname = Q.hostname.includes("portal.feedme") ? `/inventory/${de}` : `/${de}`;
898
- const Oe = Ms.compressToEncodedURIComponent(JSON.stringify(se));
899
- Q.searchParams.append("data", Oe), window.open(Q.href, "_blank", "noreferrer");
900
- }
901
- const Ke = {
902
- submitRequest: {
903
- translationKey: "inventory.transfer.receiveRequest.actions.submitRequest",
904
- color: "text-fm-color-typo-primary",
905
- value: z.enum.submitRequest
906
- },
907
- confirmDraft: {
908
- translationKey: "inventory.transfer.receiveRequest.actions.confirmDraft",
909
- color: "text-fm-color-typo-primary",
910
- value: z.enum.confirmDraft
911
- },
912
- cancelDraft: {
913
- translationKey: "inventory.transfer.receiveRequest.actions.cancelDraft",
914
- color: "text-fm-color-typo-error",
915
- value: z.enum.cancelDraft
916
- },
917
- approveRequest: {
918
- translationKey: "inventory.transfer.receiveRequest.actions.approveRequest",
919
- color: "text-fm-color-typo-primary",
920
- value: z.enum.approveRequest
921
- },
922
- rejectRequest: {
923
- translationKey: "inventory.transfer.receiveRequest.actions.rejectRequest",
924
- color: "text-fm-color-typo-error",
925
- value: z.enum.rejectRequest
926
- },
927
- processRequest: {
928
- translationKey: "inventory.transfer.receiveRequest.actions.processRequest",
929
- color: "text-fm-color-typo-primary",
930
- value: z.enum.processRequest
931
- },
932
- receiveStock: {
933
- translationKey: "inventory.transfer.receiveRequest.actions.receiveStock",
934
- color: "text-fm-color-typo-primary",
935
- value: z.enum.receiveStock
936
- },
937
- completeReceive: {
938
- translationKey: "inventory.transfer.receiveRequest.actions.completeReceive",
939
- color: "text-fm-color-typo-primary",
940
- value: z.enum.completeReceive
941
- },
942
- closeRequest: {
943
- translationKey: "inventory.transfer.receiveRequest.actions.closeRequest",
944
- color: "system-error-300",
945
- value: z.enum.closeRequest
946
- },
947
- approveDraft: {
948
- translationKey: "inventory.transfer.receiveRequest.actions.approveDraft",
949
- color: "text-fm-color-typo-primary",
950
- value: z.enum.approveDraft
951
- },
952
- rejectDraft: {
953
- translationKey: "inventory.transfer.receiveRequest.actions.rejectDraft",
954
- color: "text-fm-color-typo-error",
955
- value: z.enum.rejectDraft
956
- },
957
- returnStock: {
958
- translationKey: "inventory.transfer.receiveRequest.actions.returnStock",
959
- color: "text-fm-color-typo-primary",
960
- value: z.enum.returnStock
961
- }
962
- };
963
- function bs() {
964
- const d = Je();
965
- return {
966
- ableToMarkReceived(t) {
967
- if (!t || t.status !== ge.enum.RECEIVING || d.useOperatePurchaseOrderV2) return !1;
968
- const n = ze().currentLocationDBName;
969
- return `${t.supplier.internal}_${t.supplier._id}` !== n;
970
- },
971
- ableToMarkApproved(t) {
972
- return !(!t || (t == null ? void 0 : t.status) !== ge.enum.REQUESTING);
973
- },
974
- ableToCreateFulfillment(t, r) {
975
- var u, c;
976
- if (!d.acceptRequireFulfillment || !t || !r || t.status !== ge.enum.PROCESSING || !r.processedAt)
977
- return !1;
978
- const n = (u = r == null ? void 0 : r.from) == null ? void 0 : u.dbName, m = (c = r == null ? void 0 : r.to) == null ? void 0 : c.dbName;
979
- return !(n.startsWith("restaurant_") && m.startsWith("restaurant_"));
980
- }
981
- };
982
- }
983
- function gs() {
984
- const d = H(() => [
985
- {
986
- action: Wt.Action.manage,
987
- subject: Wt.Subject.Business.inventory_orderDraftApproval
988
- }
989
- ]), { hasPermission: t } = ar(d);
990
- return {
991
- hasOrderDraftPermission: Cs(t)
992
- };
993
- }
994
- function bi(d, t, r, n) {
995
- const m = ze(), u = _t(), c = bt(), s = bs(), { t: a } = ht(), O = Ze(), { hasOrderDraftPermission: f } = gs(), R = Je(), N = H(
996
- () => R.enablePrintTemplate ? [qe[Re.PrintCustom]] : []
997
- ), F = H(
998
- () => R.enablePurchaseOrderEmail ? [qe[Re.Email]] : []
999
- );
1000
- function _(K) {
1001
- const ve = B(K), P = n == null ? void 0 : n.excludeRowActions;
1002
- return P != null && P.length ? ve.filter(
1003
- (x) => !P.includes(x.value)
1004
- ) : ve;
1005
- }
1006
- function B(K) {
1007
- switch (K.status) {
1008
- case "DRAFT":
1009
- return [
1010
- qe[Re.Update],
1011
- qe[Re.Details],
1012
- K.supplier.internal === "restaurant" || K.supplier.internal === "warehouse" ? Ke[z.enum.submitRequest] : Ke[z.enum.confirmDraft],
1013
- Ke[z.enum.cancelDraft]
1014
- ];
1015
- case "RECEIVING":
1016
- return [
1017
- ...s.ableToMarkReceived(K) ? [Ke[z.enum.completeReceive]] : [],
1018
- qe[Re.Details],
1019
- qe[Re.Print],
1020
- ...N.value,
1021
- ...F.value
1022
- ];
1023
- case "PENDING_APPROVAL": {
1024
- const P = [qe[Re.Details]];
1025
- return f.value && P.push(
1026
- qe[Re.Update],
1027
- Ke[z.enum.approveDraft],
1028
- Ke[z.enum.rejectDraft]
1029
- ), P;
1030
- }
1031
- case "REQUESTING":
1032
- return d === "receive/request" ? [
1033
- qe[Re.Details],
1034
- qe[Re.Print],
1035
- ...N.value
1036
- ] : [
1037
- Ke[z.enum.approveRequest],
1038
- Ke[z.enum.rejectRequest],
1039
- qe[Re.Details]
1040
- // DefaultRowActions[RowActionEnum.Print]
1041
- ];
1042
- case "PROCESSING":
1043
- return [
1044
- qe[Re.Details],
1045
- qe[Re.Print],
1046
- ...N.value
1047
- ];
1048
- case "COMPLETE":
1049
- case "CANCEL":
1050
- default:
1051
- return [
1052
- qe[Re.Details],
1053
- qe[Re.Print],
1054
- ...N.value
1055
- ];
1056
- }
1057
- }
1058
- function E(K) {
1059
- return Object.values(z.enum).includes(K);
1060
- }
1061
- async function te(K, ve, P) {
1062
- var A, G, X, le, b, D, ie, ee, L;
1063
- let x;
1064
- try {
1065
- x = t.resolvePO ? await t.resolvePO(ve) : ve;
1066
- } catch (g) {
1067
- console.error("Failed to load full purchase order for action", g), O.open({
1068
- title: a("inventory.common.somethingWentWrong"),
1069
- message: (g == null ? void 0 : g.message) || a("inventory.common.tryAgain"),
1070
- type: "error"
1071
- });
1072
- return;
1073
- }
1074
- const w = wt(x);
1075
- if (!(n != null && n.onCustomAction && await n.onCustomAction(K, w))) {
1076
- if (K === Re.Print || K === Re.PrintCustom) {
1077
- let g = w;
1078
- if (g.items == null && (n != null && n.fetchFullPo)) {
1079
- const o = await n.fetchFullPo(w);
1080
- if (o == null) return;
1081
- g = wt(o);
1082
- }
1083
- const j = (A = n == null ? void 0 : n.resolveLocation) == null ? void 0 : A.call(n, w), me = { ...(P == null ? void 0 : P.toInventoryLocation) ?? j ?? m.currentLocation };
1084
- if (me.type === "restaurant") {
1085
- const o = m.locationRestaurantFromCore(me.doc._id);
1086
- o !== null && (me.doc = o);
1087
- }
1088
- ((G = P == null ? void 0 : P.netSuite) != null && G.refNo || (X = g.netSuite) != null && X.refNo) && (g.ref = [((le = P == null ? void 0 : P.netSuite) == null ? void 0 : le.refNo) || ((b = g.netSuite) == null ? void 0 : b.refNo)].filter((o) => o).join(" "));
1089
- const ke = P ?? ((D = n == null ? void 0 : n.resolvePurchaseRequest) == null ? void 0 : D.call(n, w)), we = {
1090
- po: g,
1091
- currentLocation: me,
1092
- business: c.currentBusiness.value,
1093
- fulfilling: d === "approval",
1094
- por: ke
1095
- };
1096
- if (K === Re.PrintCustom) {
1097
- const o = ds(we);
1098
- o && (ae.value = o.html, Se.value = o.templateName, De.value = o.isDefault, Oe.value = !0);
1099
- } else
1100
- pr(we);
1101
- return;
1102
- }
1103
- if (K === Re.Details) {
1104
- t.promptShowTransferDetails(w, P);
1105
- return;
1106
- }
1107
- if (K === Re.Update) {
1108
- (ie = t.promptUpdateTransferDialog) == null || ie.call(t, w);
1109
- return;
1110
- }
1111
- if (K === Re.Email) {
1112
- (ee = t.promptEmailDialog) == null || ee.call(t, w);
1113
- return;
1114
- }
1115
- if (E(K)) {
1116
- t.submitAction(x, K, (L = P == null ? void 0 : P.to) == null ? void 0 : L.dbName);
1117
- return;
1118
- }
1119
- }
1120
- }
1121
- function se() {
1122
- var ve;
1123
- const K = [
1124
- {
1125
- accessorKey: "seqNumber",
1126
- header: () => a("inventory.transfer.table.seqNo"),
1127
- enableSorting: !0,
1128
- size: 80,
1129
- sortUndefined: "last"
1130
- },
1131
- {
1132
- accessorKey: "_id",
1133
- header: () => a("inventory.transfer.table.createdAt"),
1134
- cell(P) {
1135
- return lt(`${P.getValue()}`);
1136
- },
1137
- enableSorting: !0
1138
- },
1139
- {
1140
- accessorKey: "supplier.name",
1141
- header: () => a("inventory.transfer.table.transferFrom"),
1142
- enableSorting: !0,
1143
- size: 200
1144
- },
1145
- {
1146
- // Bulk-view summary rows carry itemCount instead of the items array
1147
- id: "noOfItems",
1148
- accessorFn: (P) => {
1149
- var x;
1150
- return P.itemCount ?? ((x = P.items) == null ? void 0 : x.length) ?? 0;
1151
- },
1152
- header: () => a("inventory.transfer.table.noOfItems"),
1153
- cell: (P) => {
1154
- const x = P.row.original.version || "1", w = P.getValue();
1155
- return re("div", { class: "flex items-center gap-2" }, [
1156
- w,
1157
- x !== "1" ? re(
1158
- "div",
1159
- { class: "py-3" },
1160
- re(
1161
- tt,
1162
- {},
1163
- () => re(
1164
- "div",
1165
- {
1166
- class: ["fm-status-badge", "fm-status-badge-draft"].join(" ")
1167
- },
1168
- `v${x}`
1169
- )
1170
- )
1171
- ) : null
1172
- ]);
1173
- },
1174
- enableSorting: !1,
1175
- meta: {
1176
- width: "10rem"
1177
- }
1178
- },
1179
- {
1180
- accessorKey: "ref",
1181
- header: () => a("inventory.transfer.table.reference"),
1182
- enableSorting: !1,
1183
- size: "auto"
1184
- },
1185
- ...(ve = c.sessionUser.value) != null && ve.role.isAdmin ? [
1186
- {
1187
- id: "statusForAdmin",
1188
- header: () => re(tt, {}, () => `${a("inventory.transfer.table.status")}`),
1189
- cell(P) {
1190
- return P.row.original.status;
1191
- },
1192
- enableSorting: !0,
1193
- size: 200
1194
- }
1195
- ] : [],
1196
- {
1197
- accessorKey: "status",
1198
- header: () => a("inventory.transfer.table.status"),
1199
- cell(P) {
1200
- const x = P.getValue(), w = P.row.original, { partial: A, over: G } = w.items == null ? { partial: !!w.partialReceived, over: !!w.overReceived } : $t(vt(w)), X = Ct(x ?? "", A, G);
1201
- let le = a(`inventory.transfer.status.${X}`), b = `${x ?? ""}`.toLocaleLowerCase("en-us");
1202
- X === ge.enum.CLOSE && (le = `${a(`inventory.transfer.status.${ge.enum.COMPLETE}`)}`), X === "PARTIAL_RECEIVED" && b === ge.enum.PROCESSING.toLocaleLowerCase("en-us") && (b = ge.enum.RECEIVING.toLocaleLowerCase("en-us"));
1203
- let D = null;
1204
- const ie = r.value.find((ee) => ee.ref === P.row.original._id);
1205
- if (ie != null && ie.milestones && ie.milestones.length > 0) {
1206
- const ee = ie.milestones[ie.milestones.length - 1];
1207
- if (ee.estimatedTime) {
1208
- const L = new Date(ee.estimatedTime), g = L.getDate().toString().padStart(2, "0");
1209
- D = `${L.toLocaleString("en-US", { month: "short" })} ${g}`;
1210
- }
1211
- }
1212
- return re(
1213
- "div",
1214
- {
1215
- class: "flex"
1216
- },
1217
- [
1218
- re(
1219
- "div",
1220
- { class: "flex items-center" },
1221
- re(
1222
- "div",
1223
- {
1224
- class: [
1225
- "fm-status-badge",
1226
- `fm-status-badge-${b}`,
1227
- G && "fm-status-badge-error"
1228
- ].filter(Boolean).join(" ")
1229
- },
1230
- `${le}`
1231
- )
1232
- ),
1233
- ...D ? [
1234
- re(
1235
- "div",
1236
- {
1237
- class: "flex items-center gap-1 ml-2"
1238
- },
1239
- [
1240
- re(pt.FmIcon, {
1241
- name: "local_shipping",
1242
- size: "md",
1243
- color: "neutral-gray-400"
1244
- }),
1245
- re(
1246
- "span",
1247
- { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" },
1248
- D
1249
- )
1250
- ]
1251
- )
1252
- ] : []
1253
- ]
1254
- );
1255
- },
1256
- enableSorting: !0,
1257
- size: 150
1258
- },
1259
- {
1260
- id: "action",
1261
- cell(P) {
1262
- var A;
1263
- const x = P.row.original, w = [
1264
- ..._(x),
1265
- ...((A = n == null ? void 0 : n.appendRowActions) == null ? void 0 : A.call(n, x)) ?? []
1266
- ];
1267
- return Ht(w, (G) => te(G, x));
1268
- },
1269
- enableSorting: !1,
1270
- size: 40,
1271
- meta: {
1272
- cellClass: "",
1273
- headerClass: ""
1274
- }
1275
- }
1276
- ];
1277
- if (u.isEnabled) {
1278
- const P = [
1279
- {
1280
- id: "netsuiteTransferOrder",
1281
- accessorFn: (x) => {
1282
- var w;
1283
- return (w = x.netSuite) != null && w.id ? `${x.netSuite.refNo} (${x.netSuite.id})` : "N/A";
1284
- },
1285
- header: () => "NetSuite Order (ID)",
1286
- cell(x) {
1287
- var A;
1288
- const w = x.row.original;
1289
- return (A = w.netSuite) != null && A.id ? `${w.netSuite.refNo} (${w.netSuite.id})` : "N/A";
1290
- },
1291
- enableSorting: !1,
1292
- size: 200,
1293
- meta: {
1294
- cellClass: "",
1295
- headerClass: ""
1296
- }
1297
- },
1298
- {
1299
- id: "netsuiteTransactionNumber",
1300
- accessorFn: (x) => {
1301
- var w, A;
1302
- return ((A = (w = x.netSuite) == null ? void 0 : w.additionalInfo) == null ? void 0 : A.transactionnumber) ?? "N/A";
1303
- },
1304
- header: () => "NetSuite Transaction No.",
1305
- cell(x) {
1306
- var A, G;
1307
- return ((G = (A = x.row.original.netSuite) == null ? void 0 : A.additionalInfo) == null ? void 0 : G.transactionnumber) ?? "N/A";
1308
- },
1309
- enableSorting: !1,
1310
- size: 200,
1311
- meta: {
1312
- cellClass: "",
1313
- headerClass: ""
1314
- }
1315
- },
1316
- {
1317
- id: "netsuiteRefNo",
1318
- accessorFn: (x) => {
1319
- var A, G;
1320
- const w = (A = x.deliveryOrder) == null ? void 0 : A.filter((X) => {
1321
- var le;
1322
- return (le = X.netSuite) == null ? void 0 : le.id;
1323
- });
1324
- return w != null && w.length ? w.map((X) => {
1325
- var le, b;
1326
- return `${((le = X.netSuite) == null ? void 0 : le.refNo) ?? "N/A"} (${((b = X.netSuite) == null ? void 0 : b.id) ?? "-"})`;
1327
- }).join(", ") : (G = x.netSuite) != null && G.id ? `${x.netSuite.refNo} (${x.netSuite.id})` : "N/A";
1328
- },
1329
- header: () => "Netsuite ref no.",
1330
- cell(x) {
1331
- var G, X;
1332
- const w = x.row.original, A = (G = w.deliveryOrder) == null ? void 0 : G.filter((le) => {
1333
- var b;
1334
- return (b = le.netSuite) == null ? void 0 : b.id;
1335
- });
1336
- return A != null && A.length ? A.map((le) => {
1337
- var b, D;
1338
- return `${((b = le.netSuite) == null ? void 0 : b.refNo) ?? "N/A"} (${((D = le.netSuite) == null ? void 0 : D.id) ?? "-"})`;
1339
- }).join(", ") : (X = w.netSuite) != null && X.id ? `${w.netSuite.refNo} (${w.netSuite.id})` : "N/A";
1340
- },
1341
- enableSorting: !1,
1342
- size: 200,
1343
- meta: {
1344
- cellClass: "",
1345
- headerClass: ""
1346
- }
1347
- }
1348
- ];
1349
- K.splice(K.length - 1, 0, ...P);
1350
- }
1351
- return K;
1352
- }
1353
- function Q() {
1354
- var ve;
1355
- const K = [
1356
- {
1357
- accessorKey: "purchaseOrder.seqNumber",
1358
- header: () => a("inventory.transfer.table.seqNo"),
1359
- enableSorting: !0,
1360
- size: 80,
1361
- sortUndefined: "last"
1362
- },
1363
- {
1364
- accessorKey: "purchaseOrder._id",
1365
- header: () => a("inventory.transfer.table.createdAt"),
1366
- cell(P) {
1367
- return lt(`${P.getValue()}`);
1368
- },
1369
- enableSorting: !0
1370
- },
1371
- {
1372
- accessorKey: "to.name",
1373
- header: () => a("inventory.transfer.table.transferTo"),
1374
- enableSorting: !1,
1375
- size: 200
1376
- },
1377
- {
1378
- accessorKey: "purchaseOrder.items.length",
1379
- header: () => a("inventory.transfer.table.noOfItems"),
1380
- enableSorting: !1
1381
- },
1382
- {
1383
- accessorKey: "purchaseOrder.ref",
1384
- header: () => a("inventory.transfer.table.reference"),
1385
- enableSorting: !1,
1386
- size: "auto"
1387
- },
1388
- ...(ve = c.sessionUser.value) != null && ve.role.isAdmin ? [
1389
- {
1390
- id: "statusForAdmin",
1391
- header: () => re(tt, {}, () => `${a("inventory.transfer.table.status")}`),
1392
- cell(P) {
1393
- return P.row.original.status;
1394
- },
1395
- enableSorting: !0,
1396
- size: 200
1397
- }
1398
- ] : [],
1399
- {
1400
- accessorKey: "purchaseOrder.status",
1401
- header: () => a("inventory.transfer.table.status"),
1402
- cell(P) {
1403
- const x = P.row.original, w = P.getValue();
1404
- if (!x.purchaseOrder)
1405
- return re(pt.FmChip, {
1406
- label: "N/A",
1407
- compact: !0
1408
- });
1409
- const A = vt(x.purchaseOrder), { partial: G, over: X } = $t(A), le = Ct(w ?? "", G, X);
1410
- let b = a(`inventory.transfer.status.${le}`), D = `${w ?? ""}`.toLocaleLowerCase("en-us");
1411
- return le === ge.enum.CLOSE && (b = `${a(`inventory.transfer.status.${ge.enum.COMPLETE}`)}`), le === "PARTIAL_RECEIVED" && D === ge.enum.PROCESSING.toLocaleLowerCase("en-us") && (D = ge.enum.RECEIVING.toLocaleLowerCase("en-us")), x.rejectedAt && (b = a("inventory.transfer.status.REJECT"), D = ge.enum.REJECT.toLocaleLowerCase("en-us")), re(
1412
- "div",
1413
- {
1414
- class: "flex"
1415
- },
1416
- re(
1417
- "div",
1418
- {
1419
- class: [
1420
- "fm-status-badge",
1421
- `fm-status-badge-${D}`,
1422
- X && "fm-status-badge-error"
1423
- ].filter(Boolean).join(" ")
1424
- },
1425
- `${b}`
1426
- )
1427
- );
1428
- },
1429
- enableSorting: !0
1430
- },
1431
- {
1432
- id: "action",
1433
- cell(P) {
1434
- const x = P.row.original, A = (x.purchaseOrder ? _(x.purchaseOrder) : []).map((G) => G.value === Re.Print ? {
1435
- ...G,
1436
- translationKey: "inventory.transfer.receiveRequest.details.printDeliveryOrder"
1437
- } : G);
1438
- return Ht(
1439
- A,
1440
- (G) => x.purchaseOrder ? te(G, x.purchaseOrder, x) : void 0
1441
- );
1442
- },
1443
- enableSorting: !1,
1444
- size: 40,
1445
- meta: {
1446
- cellClass: "",
1447
- headerClass: ""
1448
- }
1449
- }
1450
- ];
1451
- if (u.isEnabled) {
1452
- const P = [
1453
- {
1454
- id: "netsuiteTransferOrder",
1455
- accessorFn: (x) => {
1456
- var w;
1457
- return (w = x.netSuite) != null && w.id ? `${x.netSuite.refNo} (${x.netSuite.id})` : "N/A";
1458
- },
1459
- header: () => "NetSuite Order (ID)",
1460
- cell(x) {
1461
- var A;
1462
- const w = x.row.original;
1463
- return (A = w.netSuite) != null && A.id ? `${w.netSuite.refNo} (${w.netSuite.id})` : "N/A";
1464
- },
1465
- enableSorting: !1,
1466
- size: 200,
1467
- meta: {
1468
- cellClass: "",
1469
- headerClass: ""
1470
- }
1471
- },
1472
- {
1473
- id: "netsuiteTransactionNumber",
1474
- accessorFn: (x) => {
1475
- var w, A;
1476
- return ((A = (w = x.netSuite) == null ? void 0 : w.additionalInfo) == null ? void 0 : A.transactionnumber) ?? "N/A";
1477
- },
1478
- header: () => "NetSuite Transaction No.",
1479
- cell(x) {
1480
- var A, G;
1481
- return ((G = (A = x.row.original.netSuite) == null ? void 0 : A.additionalInfo) == null ? void 0 : G.transactionnumber) ?? "N/A";
1482
- },
1483
- enableSorting: !1,
1484
- size: 200,
1485
- meta: {
1486
- cellClass: "",
1487
- headerClass: ""
1488
- }
1489
- },
1490
- {
1491
- id: "netsuiteRefNo",
1492
- accessorFn: (x) => {
1493
- var A, G, X;
1494
- const w = (G = (A = x.purchaseOrder) == null ? void 0 : A.deliveryOrder) == null ? void 0 : G.filter((le) => {
1495
- var b;
1496
- return (b = le.netSuite) == null ? void 0 : b.id;
1497
- });
1498
- return w != null && w.length ? w.map((le) => {
1499
- var b, D;
1500
- return `${((b = le.netSuite) == null ? void 0 : b.refNo) ?? "N/A"} (${((D = le.netSuite) == null ? void 0 : D.id) ?? "-"})`;
1501
- }).join(", ") : (X = x.netSuite) != null && X.id ? `${x.netSuite.refNo} (${x.netSuite.id})` : "N/A";
1502
- },
1503
- header: () => "Netsuite ref no.",
1504
- cell(x) {
1505
- var G, X, le;
1506
- const w = x.row.original, A = (X = (G = w.purchaseOrder) == null ? void 0 : G.deliveryOrder) == null ? void 0 : X.filter((b) => {
1507
- var D;
1508
- return (D = b.netSuite) == null ? void 0 : D.id;
1509
- });
1510
- return A != null && A.length ? A.map((b) => {
1511
- var D, ie;
1512
- return `${((D = b.netSuite) == null ? void 0 : D.refNo) ?? "N/A"} (${((ie = b.netSuite) == null ? void 0 : ie.id) ?? "-"})`;
1513
- }).join(", ") : (le = w.netSuite) != null && le.id ? `${w.netSuite.refNo} (${w.netSuite.id})` : "N/A";
1514
- },
1515
- enableSorting: !1,
1516
- size: 200,
1517
- meta: {
1518
- cellClass: "",
1519
- headerClass: ""
1520
- }
1521
- }
1522
- ];
1523
- K.splice(K.length - 2, 0, ...P);
1524
- }
1525
- return K;
1526
- }
1527
- const de = H(() => d === "receive/request" ? se() : Q()), Oe = ne(!1), ae = ne(""), Se = ne(""), De = ne(!1);
1528
- return {
1529
- columnDefs: de,
1530
- showCustomPrintDialog: Oe,
1531
- customPrintHtml: ae,
1532
- customPrintTemplateName: Se,
1533
- customPrintIsDefault: De
1534
- };
1535
- }
1536
- const fr = { class: "flex flex-col gap-4 border border-fm-color-neutral-gray-200 fm-corner-radius-lg p-16" }, vr = { class: "flex items-center justify-between" }, yr = {
1537
- key: 0,
1538
- class: "fm-typo-en-body-md-400 text-fm-color-typo-tertiary"
1539
- }, hr = { class: "flex justify-between items-start py-1 gap-4" }, br = { class: "flex-1 min-w-0 flex flex-col gap-2" }, gr = { class: "flex flex-col gap-2 items-end w-52 shrink-0" }, _r = {
1540
- key: 0,
1541
- class: "border-b border-fm-color-stroke-secondary"
1542
- }, Ft = /* @__PURE__ */ Ve({
1543
- __name: "PriceAdjustmentEditor",
1544
- props: {
1545
- controller: {},
1546
- state: {}
1547
- },
1548
- setup(d) {
1549
- const t = d, r = H(() => t.state.adjustments ?? []);
1550
- function n(a) {
1551
- return +$e(a.dinero);
1552
- }
1553
- function m() {
1554
- t.controller.addAdjustment();
1555
- }
1556
- function u(a, O) {
1557
- t.controller.updateAdjustment(a, O);
1558
- }
1559
- function c(a, O) {
1560
- t.controller.updateAdjustment(a, null, O);
1561
- }
1562
- function s(a) {
1563
- t.controller.removeAdjustment(a);
1564
- }
1565
- return (a, O) => {
1566
- const f = oe("FmButton"), R = oe("FmTextField"), N = oe("FmStepperField");
1567
- return i(), v("div", fr, [
1568
- e("div", vr, [
1569
- O[0] || (O[0] = e("div", { class: "fm-typo-en-body-lg-600 text-fm-color-typo-secondary" }, "Price adjustments", -1)),
1570
- T(f, {
1571
- variant: "tertiary",
1572
- label: "Add adjustment",
1573
- "prepend-icon": "add",
1574
- size: "md",
1575
- onClick: m
1576
- })
1577
- ]),
1578
- r.value.length === 0 ? (i(), v("div", yr, " No price adjustments ")) : V("", !0),
1579
- (i(!0), v(Ce, null, Te(r.value, (F, _) => (i(), v("div", {
1580
- key: F.id
1581
- }, [
1582
- e("div", hr, [
1583
- e("div", br, [
1584
- T(R, {
1585
- "model-value": F.name,
1586
- "onUpdate:modelValue": (B) => u(F.id, B),
1587
- label: "Name",
1588
- placeholder: "e.g. Freight, Discount",
1589
- size: "md"
1590
- }, null, 8, ["model-value", "onUpdate:modelValue"])
1591
- ]),
1592
- e("div", gr, [
1593
- T(N, {
1594
- "model-value": n(F),
1595
- "onUpdate:modelValue": (B) => c(F.id, B),
1596
- label: "Amount (+/-)",
1597
- step: 0.01,
1598
- placeholder: "0.00",
1599
- size: "md",
1600
- "append-text": h(Ae)()
1601
- }, null, 8, ["model-value", "onUpdate:modelValue", "append-text"])
1602
- ]),
1603
- T(f, {
1604
- variant: "tertiary",
1605
- "prepend-icon": "delete",
1606
- size: "md",
1607
- class: "mt-6",
1608
- onClick: (B) => s(F.id)
1609
- }, null, 8, ["onClick"])
1610
- ]),
1611
- _ < r.value.length - 1 ? (i(), v("div", _r)) : V("", !0)
1612
- ]))), 128))
1613
- ]);
1614
- };
1615
- }
1616
- });
1617
- function It(d) {
1618
- const t = dt(
1619
- Qt({
1620
- currency: d.currency,
1621
- adjustments: d.adjustments ?? []
1622
- })
1623
- ), r = dt(t.value.state());
1624
- function n(c) {
1625
- const s = () => {
1626
- r.value = c.state();
1627
- };
1628
- return c.addListener(s), () => c.removeListener(s);
1629
- }
1630
- let m = n(t.value);
1631
- function u(c) {
1632
- m(), t.value = Qt({
1633
- currency: d.currency,
1634
- adjustments: c ?? []
1635
- }), m = n(t.value), r.value = t.value.state();
1636
- }
1637
- return rs(() => m()), { controller: t, state: r, reset: u };
1638
- }
1639
- const Sr = { class: "border border-fm-color-neutral-gray-200 fm-corner-radius-lg p-16" }, kr = { class: "flex flex-col gap-8" }, Or = { class: "flex w-full justify-end gap-16" }, xr = /* @__PURE__ */ Ve({
1640
- __name: "FulfillmentForm",
1641
- props: {
1642
- purchaseOrder: {},
1643
- confirm: { type: Function }
1644
- },
1645
- emits: ["update:show"],
1646
- setup(d, { emit: t }) {
1647
- const r = d, n = As({
1648
- id: "",
1649
- createdAt: (/* @__PURE__ */ new Date()).toISOString(),
1650
- items: []
1651
- }), m = ne(), u = t, c = (a) => a != null && a !== "";
1652
- os(() => {
1653
- r.purchaseOrder && (n.items = r.purchaseOrder.items.map((a) => ({
1654
- id: a.id,
1655
- sku: a.sku,
1656
- measurement: a.measurement,
1657
- amount: a.quantity ?? { amount: 1, precision: 0 }
1658
- })));
1659
- });
1660
- const s = H(() => n.items.length <= 10);
1661
- return (a, O) => {
1662
- const f = oe("FmTable"), R = oe("FmButton"), N = oe("FmForm");
1663
- return i(), he(N, {
1664
- ref_key: "formRef",
1665
- ref: m,
1666
- class: "bg-white flex flex-col gap-32 rounded-3xl p-24 w-[800px]",
1667
- onValidationFailed: console.log,
1668
- onValidationSuccess: O[1] || (O[1] = () => r.confirm(n))
1669
- }, {
1670
- default: ce(() => [
1671
- O[2] || (O[2] = e("div", { class: "fm-typo-en-title-sm-600" }, "Confirm the transfer amount", -1)),
1672
- e("div", Sr, [
1673
- e("div", kr, [
1674
- T(f, {
1675
- "column-defs": [
1676
- {
1677
- header: "Code",
1678
- cell: (F) => {
1679
- const _ = r.purchaseOrder.items.find((B) => c(F.row.original.id) ? B.id === F.row.original.id : B.sku._id === F.row.original.sku._id);
1680
- return re(
1681
- h(pt).FmTooltip,
1682
- {
1683
- content: _.code,
1684
- placement: "top",
1685
- variant: "plain",
1686
- zIndex: 50
1687
- },
1688
- re(
1689
- "span",
1690
- {
1691
- class: "flex-auto line-clamp-2 text-ellipsis break-all"
1692
- },
1693
- _.code
1694
- )
1695
- );
1696
- }
1697
- },
1698
- {
1699
- header: "Name",
1700
- cell: (F) => {
1701
- const _ = r.purchaseOrder.items.find((B) => c(F.row.original.id) ? B.id === F.row.original.id : B.sku._id === F.row.original.sku._id);
1702
- return re(
1703
- h(pt).FmTooltip,
1704
- {
1705
- content: _.name,
1706
- placement: "top",
1707
- variant: "plain",
1708
- zIndex: 50
1709
- },
1710
- re(
1711
- "span",
1712
- {
1713
- class: "flex-auto line-clamp-2 text-ellipsis break-all"
1714
- },
1715
- _.name
1716
- )
1717
- );
1718
- }
1719
- },
1720
- {
1721
- header: "Amount",
1722
- cell: (F) => {
1723
- const _ = F.row.original, B = r.purchaseOrder.items.find((te) => c(_.id) ? te.id === _.id : te.sku._id === _.sku._id), E = _.amount ?? {
1724
- amount: 1,
1725
- precision: 0
1726
- };
1727
- return re(Gs, {
1728
- style: {
1729
- flex: "1 1 0%"
1730
- },
1731
- modelValue: {
1732
- amount: E,
1733
- measurement: _.measurement ?? null
1734
- },
1735
- key: c(_.id) ? _.id : _.sku._id,
1736
- unit: _.sku.unit,
1737
- "onUpdate:modelValue": (te) => {
1738
- if (!te) return;
1739
- const se = n.items.find((Q) => c(_.id) ? Q.id === _.id : Q.sku._id === _.sku._id);
1740
- se && (se.amount = te.amount);
1741
- },
1742
- disableUnit: !0,
1743
- rules: [
1744
- h(Ws)(
1745
- +h($e)({ amount: 0, precision: 0 })
1746
- ),
1747
- h(Qs)(+h($e)(B.quantity))
1748
- ],
1749
- applyDefaultRules: !0
1750
- });
1751
- }
1752
- }
1753
- ],
1754
- "row-data": n.items,
1755
- "hide-footer": s.value
1756
- }, null, 8, ["column-defs", "row-data", "hide-footer"])
1757
- ])
1758
- ]),
1759
- e("div", Or, [
1760
- T(R, {
1761
- class: "px-16",
1762
- label: "Confirm",
1763
- size: "md",
1764
- variant: "primary",
1765
- type: "submit"
1766
- }),
1767
- T(R, {
1768
- class: "px-16",
1769
- label: "Cancel",
1770
- size: "md",
1771
- variant: "secondary",
1772
- onClick: O[0] || (O[0] = () => u("update:show", !1))
1773
- })
1774
- ])
1775
- ]),
1776
- _: 1
1777
- }, 8, ["onValidationFailed"]);
1778
- };
1779
- }
1780
- }), nt = {
1781
- submitRequest: {
1782
- translationKey: "inventory.transfer.receiveRequest.actions.submitRequest",
1783
- color: "primary",
1784
- buttonVariant: je.Primary
1785
- },
1786
- confirmDraft: {
1787
- translationKey: "inventory.transfer.receiveRequest.actions.confirmDraft",
1788
- color: "primary",
1789
- buttonVariant: je.Primary
1790
- },
1791
- cancelDraft: {
1792
- translationKey: "inventory.transfer.receiveRequest.actions.cancelDraft",
1793
- color: "system-error-300",
1794
- buttonVariant: je.Destructive
1795
- },
1796
- approveDraft: {
1797
- translationKey: "inventory.transfer.receiveRequest.actions.approveDraft",
1798
- color: "primary",
1799
- buttonVariant: je.Primary
1800
- },
1801
- rejectDraft: {
1802
- translationKey: "inventory.transfer.receiveRequest.actions.rejectDraft",
1803
- color: "system-error-300",
1804
- buttonVariant: je.Destructive
1805
- },
1806
- approveRequest: {
1807
- translationKey: "inventory.transfer.receiveRequest.actions.approveRequest",
1808
- color: "primary",
1809
- buttonVariant: je.Primary
1810
- },
1811
- processRequest: {
1812
- translationKey: "inventory.transfer.receiveRequest.actions.processRequest",
1813
- color: "primary",
1814
- buttonVariant: je.Primary
1815
- },
1816
- receiveStock: {
1817
- translationKey: "inventory.transfer.receiveRequest.actions.receiveStock",
1818
- color: "primary",
1819
- buttonVariant: je.Primary,
1820
- available: !1
1821
- },
1822
- completeReceive: {
1823
- translationKey: "inventory.transfer.receiveRequest.actions.completeReceive",
1824
- color: "primary",
1825
- buttonVariant: je.Plain
1826
- },
1827
- rejectRequest: {
1828
- translationKey: "inventory.transfer.receiveRequest.actions.rejectRequest",
1829
- color: "system-error-300",
1830
- buttonVariant: je.Destructive
1831
- },
1832
- closeRequest: {
1833
- translationKey: "inventory.transfer.receiveRequest.actions.closeRequest",
1834
- color: "system-error-300",
1835
- buttonVariant: je.Destructive,
1836
- available: !1
1837
- },
1838
- returnStock: {
1839
- translationKey: "inventory.transfer.receiveRequest.actions.returnStock",
1840
- color: "primary",
1841
- buttonVariant: je.Primary,
1842
- available: !1
1843
- }
1844
- }, wr = { class: "flex flex-row-reverse" }, $r = /* @__PURE__ */ Ve({
1845
- __name: "NetSuiteSync",
1846
- props: {
1847
- poRequest: {},
1848
- purchaseOrder: {},
1849
- isTransferBetweenOutlets: { type: Boolean },
1850
- scope: {}
1851
- },
1852
- setup(d) {
1853
- const t = d, r = _t(), n = Ze(), m = gt(), u = ne(!1);
1854
- H(() => {
1855
- var f, R, N, F;
1856
- let s = !0;
1857
- r.isEnabled || (s = !1);
1858
- const a = t.purchaseOrder, O = t.poRequest;
1859
- return a && ((f = a == null ? void 0 : a.supplier) != null && f.internal ? (!O && a.status == ge.enum.DRAFT && (s = !1), O && !((R = O == null ? void 0 : O.netSuite) != null && R.id) && (s = !1), t.isTransferBetweenOutlets && (s = !1)) : ((a == null ? void 0 : a.status) !== ge.enum.REQUESTING && a.supplier.internal && (s = !1), !O && !((N = a == null ? void 0 : a.netSuite) != null && N.id) && (s = !1), !O && ((F = a == null ? void 0 : a.netSuite) != null && F.id) && (a == null ? void 0 : a.status) == ge.enum.REQUESTING && (s = !1))), s;
1860
- });
1861
- async function c() {
1862
- u.value || m.open({
1863
- title: "Sync with NetSuite",
1864
- contentComponent: re("div", [
1865
- re("p", "Are you sure you want to sync now?"),
1866
- re("br"),
1867
- re(
1868
- "p",
1869
- { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" },
1870
- "Please wait a moment before syncing manually to avoid unnecessary actions."
1871
- )
1872
- ]),
1873
- primaryActions: {
1874
- text: "Sync",
1875
- close: !0,
1876
- variant: "destructive"
1877
- },
1878
- secondaryActions: { text: "Not now", close: !0 }
1879
- }).onPrimary(async () => {
1880
- var s, a, O, f, R, N, F;
1881
- try {
1882
- u.value = !0;
1883
- const _ = ((s = t.purchaseOrder) == null ? void 0 : s._id) || ((a = t.poRequest) == null ? void 0 : a.purchaseOrderId) || "", B = (O = t.poRequest) == null ? void 0 : O.to.dbName;
1884
- await r.syncPurchaseOrder({
1885
- purchaseOrderId: _,
1886
- locationId: t.scope === "approval" ? B : void 0,
1887
- netsuiteId: ((R = (f = t.purchaseOrder) == null ? void 0 : f.netSuite) == null ? void 0 : R.id) || ((F = (N = t.poRequest) == null ? void 0 : N.netSuite) == null ? void 0 : F.id)
1888
- }), n.open({
1889
- title: "Sync with NetSuite",
1890
- message: "Requested to sync with NetSuite. Please wait a moment.",
1891
- type: "success"
1892
- }), await new Promise((E) => setTimeout(E, 5e3)), u.value = !1;
1893
- } catch (_) {
1894
- console.log("Failed to sync with NetSuite", _), n.open({
1895
- title: "Error",
1896
- message: "Failed to sync with NetSuite",
1897
- type: "error"
1898
- }), u.value = !1;
1899
- }
1900
- });
1901
- }
1902
- return (s, a) => {
1903
- const O = oe("FmButton");
1904
- return i(), v("div", wr, [
1905
- T(O, {
1906
- "prepend-icon": "sync",
1907
- variant: "secondary",
1908
- label: "Sync",
1909
- loading: u.value,
1910
- onClick: c,
1911
- "text-color": "primary",
1912
- "bg-color": "transparent",
1913
- "border-color": "primary"
1914
- }, null, 8, ["loading"])
1915
- ]);
1916
- };
1917
- }
1918
- }), Cr = {
1919
- key: 0,
1920
- class: "flex flex-col gap-8"
1921
- }, Ar = { class: "flex flex-col gap-4" }, Dr = { class: "fm-typo-en-body-lg-600" }, Rr = {
1922
- key: 0,
1923
- class: "flex flex-col gap-4"
1924
- }, Nr = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Pr = { class: "fm-typo-en-body-lg-600" }, Fr = { key: 0 }, Ir = { key: 1 }, Tr = {
1925
- key: 1,
1926
- class: "flex flex-col gap-4"
1927
- }, Er = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, qr = { class: "fm-typo-en-body-lg-600" }, Vr = { key: 0 }, Lr = { key: 1 }, jr = {
1928
- key: 2,
1929
- class: "flex flex-col gap-4"
1930
- }, Ur = { class: "fm-typo-en-body-lg-600" }, Mr = {
1931
- key: 3,
1932
- class: "flex flex-col gap-4"
1933
- }, Br = { class: "fm-typo-en-body-lg-600" }, zr = /* @__PURE__ */ Ve({
1934
- __name: "NetSuiteInfo",
1935
- props: {
1936
- transferType: {},
1937
- transferToDbName: {},
1938
- poRequest: {},
1939
- purchaseOrder: {},
1940
- isTransferBetweenOutlets: { type: Boolean },
1941
- scope: {}
1942
- },
1943
- setup(d) {
1944
- const t = d, r = _t(), n = Xe(), m = ne(t.poRequest);
1945
- os(async () => {
1946
- var a;
1947
- if (!t.poRequest && ((a = t.purchaseOrder) != null && a._id)) {
1948
- const O = await n.getLatestPurchaseOrderRequest(t.purchaseOrder._id);
1949
- m.value = O;
1950
- }
1951
- });
1952
- const u = H(
1953
- () => {
1954
- var a, O, f, R, N, F;
1955
- return r.getSubsidiaryFullName(
1956
- ((f = (O = (a = t.purchaseOrder) == null ? void 0 : a.netSuite) == null ? void 0 : O.subsidiary) == null ? void 0 : f.id) || ((F = (N = (R = t.poRequest) == null ? void 0 : R.netSuite) == null ? void 0 : N.subsidiary) == null ? void 0 : F.id)
1957
- ).fullName;
1958
- }
1959
- ), c = H(() => {
1960
- var a, O, f, R, N, F, _, B, E, te, se, Q;
1961
- return (f = (O = (a = t.purchaseOrder) == null ? void 0 : a.netSuite) == null ? void 0 : O.additionalInfo) != null && f.transactionnumber ? (F = (N = (R = t.purchaseOrder) == null ? void 0 : R.netSuite) == null ? void 0 : N.additionalInfo) == null ? void 0 : F.transactionnumber : (E = (B = (_ = m.value) == null ? void 0 : _.netSuite) == null ? void 0 : B.additionalInfo) != null && E.transactionnumber ? (Q = (se = (te = m.value) == null ? void 0 : te.netSuite) == null ? void 0 : se.additionalInfo) == null ? void 0 : Q.transactionnumber : null;
1962
- }), s = H(() => {
1963
- var a, O, f, R, N, F;
1964
- return (O = (a = t.purchaseOrder) == null ? void 0 : a.deliveryFullfillment) != null && O.length && ((R = (f = t.purchaseOrder) == null ? void 0 : f.deliveryFullfillment) == null ? void 0 : R.length) > 0 ? (F = (N = t.purchaseOrder) == null ? void 0 : N.deliveryFullfillment) == null ? void 0 : F.map((_) => {
1965
- var B;
1966
- return (B = _.netSuite) == null ? void 0 : B.refNo;
1967
- }).join(", ") : "N/A";
1968
- });
1969
- return (a, O) => {
1970
- var f, R, N, F, _, B, E, te, se, Q, de, Oe, ae, Se, De, K;
1971
- return h(r).isEnabled ? (i(), v("div", Cr, [
1972
- e("div", Ar, [
1973
- O[0] || (O[0] = e("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, "NetSuite subsidiary", -1)),
1974
- e("div", Dr, k(u.value || "N/A"), 1)
1975
- ]),
1976
- !a.isTransferBetweenOutlets && a.scope === h(At).RECEIVE_REQUEST ? (i(), v("div", Rr, [
1977
- e("div", Nr, " NetSuite " + k((R = (f = a.purchaseOrder) == null ? void 0 : f.netSuite) != null && R.recordType ? h(as)((F = (N = a.purchaseOrder) == null ? void 0 : N.netSuite) == null ? void 0 : F.recordType) : a.transferType === h(at).enum.purchase ? "Purchase Order" : "Transfer Order") + " (ID) ", 1),
1978
- e("div", Pr, [
1979
- (B = (_ = a.purchaseOrder) == null ? void 0 : _.netSuite) != null && B.id ? (i(), v("span", Fr, k((te = (E = a.purchaseOrder) == null ? void 0 : E.netSuite) == null ? void 0 : te.refNo) + " (" + k((Q = (se = a.purchaseOrder) == null ? void 0 : se.netSuite) == null ? void 0 : Q.id) + ") ", 1)) : (i(), v("span", Ir, "N/A"))
1980
- ])
1981
- ])) : V("", !0),
1982
- !a.isTransferBetweenOutlets && m.value || a.scope === h(At).APPROVAL ? (i(), v("div", Tr, [
1983
- e("div", Er, " (Request) NetSuite " + k(a.transferType === h(at).enum.purchase ? "Purchase Order" : "Transfer Order") + " (ID) ", 1),
1984
- e("div", qr, [
1985
- (Oe = (de = m.value) == null ? void 0 : de.netSuite) != null && Oe.id ? (i(), v("span", Vr, k((Se = (ae = m.value) == null ? void 0 : ae.netSuite) == null ? void 0 : Se.refNo) + " (" + k((K = (De = m.value) == null ? void 0 : De.netSuite) == null ? void 0 : K.id) + ") ", 1)) : (i(), v("span", Lr, "N/A"))
1986
- ])
1987
- ])) : V("", !0),
1988
- c.value ? (i(), v("div", jr, [
1989
- O[1] || (O[1] = e("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " NetSuite Transaction Number ", -1)),
1990
- e("div", Ur, k(c.value), 1)
1991
- ])) : V("", !0),
1992
- h(r).isEnabled && a.transferType === h(at).enum.transfer && !a.isTransferBetweenOutlets ? (i(), v("div", Mr, [
1993
- O[2] || (O[2] = e("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " NetSuite fulfillment IDs ", -1)),
1994
- e("div", Br, k(s.value), 1)
1995
- ])) : V("", !0)
1996
- ])) : V("", !0);
1997
- };
1998
- }
1999
- }), Kr = { class: "flex flex-row-reverse" }, Hr = /* @__PURE__ */ Ve({
2000
- __name: "NetSuiteLog",
2001
- props: {
2002
- netsuiteId: {},
2003
- purchaseOrderId: {}
2004
- },
2005
- setup(d) {
2006
- const t = Ze(), r = Pt();
2007
- async function n(m, u) {
2008
- const c = [];
2009
- if (m && c.push(`body.message:*${m}*`), u) {
2010
- const f = u.replace(/:/g, "\\:");
2011
- c.push(`${f}`);
2012
- }
2013
- if (c.length === 0) {
2014
- t.open({
2015
- message: "Cannot open logs without valid filters.",
2016
- type: "error"
2017
- });
2018
- return;
2019
- }
2020
- const a = `attributes.pod:netsuite* AND (${c.join(" OR ")})`, { url: O } = await r.getSyncLogs(a);
2021
- t.open(
2022
- {
2023
- message: "Opening NetSuite logs...",
2024
- type: "info"
2025
- },
2026
- 800
2027
- ), await new Promise((f) => setTimeout(f, 800)), window.open(O, "_blank");
2028
- }
2029
- return (m, u) => {
2030
- const c = oe("FmButton");
2031
- return i(), v("div", Kr, [
2032
- T(c, {
2033
- "prepend-icon": "history",
2034
- variant: "secondary",
2035
- label: "Logs",
2036
- onClick: u[0] || (u[0] = (s) => n(m.netsuiteId, m.purchaseOrderId)),
2037
- "text-color": "primary",
2038
- "bg-color": "transparent",
2039
- "border-color": "primary"
2040
- })
2041
- ]);
2042
- };
2043
- }
2044
- }), Gr = { class: "flex flex-row-reverse" }, Wr = { key: 0 }, Qr = { key: 1 }, Yr = { class: "mb-6" }, Jr = { class: "fm-typo-en-body-md-400" }, Zr = { key: 0 }, Xr = { key: 1 }, eo = {
2045
- key: 0,
2046
- class: "flex"
2047
- }, to = {
2048
- key: 1,
2049
- class: "border-t pt-6"
2050
- }, so = { class: "fm-typo-en-body-lg-600 mb-4 flex items-center gap-2" }, ro = { class: "border border-fm-color-neutral-gray-200 fm-corner-radius-lg overflow-y-auto" }, oo = { class: "w-full" }, no = {
2051
- class: "p-3 fm-typo-en-body-sm-600",
2052
- style: { "min-width": "130px" }
2053
- }, ao = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, lo = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, io = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, uo = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, co = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, mo = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, po = { class: "p-3 fm-typo-en-body-sm-600" }, fo = { key: 2 }, vo = { key: 1 }, yo = /* @__PURE__ */ Ve({
2054
- __name: "NetSuiteLatestInfo",
2055
- props: {
2056
- netsuiteId: {},
2057
- purchaseOrderId: {}
2058
- },
2059
- setup(d) {
2060
- const t = d, r = Pt(), n = ne(!1), m = ze(), u = ne(!0), c = ne(!1), s = ne(!1), a = ne(!1), O = ne(null), f = ne([]);
2061
- async function R() {
2062
- if (!O.value) {
2063
- n.value = !0;
2064
- try {
2065
- u.value = !0;
2066
- const B = await r.getMoreInfo(
2067
- m.currentLocation.dbName,
2068
- t.purchaseOrderId
2069
- );
2070
- O.value = B, c.value = !1;
2071
- } catch {
2072
- c.value = !0;
2073
- } finally {
2074
- u.value = !1;
2075
- }
2076
- await N();
2077
- }
2078
- }
2079
- async function N() {
2080
- if (!(f.value.length > 0))
2081
- try {
2082
- s.value = !0;
2083
- const B = await r.getChangeLogs(t.netsuiteId);
2084
- f.value = B, a.value = !1;
2085
- } catch {
2086
- a.value = !0;
2087
- } finally {
2088
- s.value = !1;
2089
- }
2090
- }
2091
- function F(B) {
2092
- switch (B) {
2093
- case Me.Create:
2094
- return "text-green-600 bg-green-100";
2095
- case Me.Set:
2096
- return "text-blue-600 bg-blue-100";
2097
- case Me.Change:
2098
- return "text-yellow-600 bg-yellow-100";
2099
- case Me.Unset:
2100
- return "text-red-600 bg-red-100";
2101
- default:
2102
- return "text-gray-600 bg-gray-100";
2103
- }
2104
- }
2105
- function _(B) {
2106
- return new Date(B).toLocaleDateString("en-US", {
2107
- year: "numeric",
2108
- month: "short",
2109
- day: "numeric",
2110
- hour: "2-digit",
2111
- minute: "2-digit"
2112
- });
2113
- }
2114
- return (B, E) => {
2115
- const te = oe("FmButton"), se = oe("FmLabel"), Q = oe("FmCircularProgress"), de = oe("FmIcon"), Oe = oe("FmDialog");
2116
- return i(), v("div", Gr, [
2117
- T(Oe, {
2118
- modelValue: n.value,
2119
- "onUpdate:modelValue": E[2] || (E[2] = (ae) => n.value = ae),
2120
- overlay: !0,
2121
- "max-width": 800
2122
- }, {
2123
- "dialog-button": ce(() => [
2124
- T(te, {
2125
- "prepend-icon": "info",
2126
- variant: "secondary",
2127
- label: "Latest Info",
2128
- onClick: E[0] || (E[0] = (ae) => R()),
2129
- "text-color": "primary",
2130
- "bg-color": "transparent",
2131
- "border-color": "primary"
2132
- })
2133
- ]),
2134
- "dialog-header": ce(() => E[3] || (E[3] = [
2135
- e("div", null, "NetSuite latest info", -1)
2136
- ])),
2137
- default: ce(() => [
2138
- u.value ? (i(), v("div", Wr, "Loading...")) : (i(), v("div", Qr, [
2139
- c.value ? (i(), v("p", vo, "Something went wrong.")) : (i(), v(Ce, { key: 0 }, [
2140
- e("div", Yr, [
2141
- E[4] || (E[4] = e("h3", { class: "fm-typo-en-body-lg-600 mb-4" }, "NetSuite Order Details", -1)),
2142
- (i(!0), v(Ce, null, Te(O.value, (ae, Se) => (i(), v("div", {
2143
- key: Se,
2144
- class: "mb-2"
2145
- }, [
2146
- e("div", null, [
2147
- T(se, {
2148
- label: h(Rt)(Se)
2149
- }, null, 8, ["label"]),
2150
- e("div", Jr, [
2151
- Array.isArray(ae) ? (i(), v("span", Zr, k(ae.length > 0 ? ae.join(", ") : "N/A"), 1)) : (i(), v("span", Xr, k(ae), 1))
2152
- ])
2153
- ])
2154
- ]))), 128))
2155
- ]),
2156
- s.value ? (i(), v("div", eo, [
2157
- E[5] || (E[5] = e("span", null, "Change Log Loading...", -1)),
2158
- T(Q, { size: "md" })
2159
- ])) : V("", !0),
2160
- !s.value && f.value.length > 0 ? (i(), v("div", to, [
2161
- e("h3", so, [
2162
- T(de, {
2163
- name: "error",
2164
- color: "#ff9500",
2165
- size: "sm"
2166
- }),
2167
- E[6] || (E[6] = Ge(" Change Logs "))
2168
- ]),
2169
- e("div", ro, [
2170
- e("table", oo, [
2171
- E[7] || (E[7] = e("thead", { class: "bg-fm-color-neutral-gray-50" }, [
2172
- e("tr", { class: "border-b border-fm-color-neutral-gray-200" }, [
2173
- e("th", {
2174
- class: "text-left p-3 fm-typo-en-body-md-600",
2175
- style: { "min-width": "130px" }
2176
- }, " Date "),
2177
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Role"),
2178
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Name"),
2179
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Context"),
2180
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Type"),
2181
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Line ID"),
2182
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Field"),
2183
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Old Value"),
2184
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "New Value")
2185
- ])
2186
- ], -1)),
2187
- e("tbody", null, [
2188
- (i(!0), v(Ce, null, Te(f.value, (ae, Se) => (i(), v("tr", {
2189
- key: Se,
2190
- class: "border-b border-fm-color-neutral-gray-200 last:border-b-0"
2191
- }, [
2192
- e("td", no, k(_(ae._dateiso8601)), 1),
2193
- e("td", ao, k(ae._rolename), 1),
2194
- e("td", lo, k(ae._employeename), 1),
2195
- e("td", io, k(ae._contextname), 1),
2196
- e("td", {
2197
- class: We(`p-3 fm-typo-en-body-sm-600 ${F(Number(ae.type) - 1)}`)
2198
- }, k(h(Me)[Number(ae.type) - 1]), 3),
2199
- e("td", uo, k(ae.lineid || ""), 1),
2200
- e("td", co, k(ae._fieldname), 1),
2201
- e("td", mo, k(ae.oldvalue || ""), 1),
2202
- e("td", po, k(ae.newvalue || ""), 1)
2203
- ]))), 128))
2204
- ])
2205
- ])
2206
- ])
2207
- ])) : (i(), v("div", fo, E[8] || (E[8] = [
2208
- e("p", null, "No change logs available.", -1)
2209
- ])))
2210
- ], 64))
2211
- ]))
2212
- ]),
2213
- "dialog-footer": ce(() => [
2214
- T(te, {
2215
- class: "ml-auto sm:w-full xs:w-full",
2216
- label: "Close",
2217
- size: "md",
2218
- variant: "primary",
2219
- onClick: E[1] || (E[1] = (ae) => n.value = !1)
2220
- })
2221
- ]),
2222
- _: 1
2223
- }, 8, ["modelValue"])
2224
- ]);
2225
- };
2226
- }
2227
- }), ho = {
2228
- key: 0,
2229
- class: "border border-fm-color-neutral-gray-200 fm-corner-radius-lg p-16 flex flex-col gap-8"
2230
- }, bo = { class: "flex gap-8 items-center" }, go = { class: "ml-auto" }, _o = { class: "flex gap-3" }, So = /* @__PURE__ */ Ve({
2231
- __name: "NetSuitePanel",
2232
- props: {
2233
- poRequest: {},
2234
- purchaseOrder: {},
2235
- transferType: {},
2236
- transferToDbName: {},
2237
- scope: {}
2238
- },
2239
- setup(d) {
2240
- const t = d, r = Js(), n = H(() => r.isNetSuiteEnabled);
2241
- return (m, u) => {
2242
- var s, a;
2243
- const c = oe("FmMenuDivider");
2244
- return n.value ? (i(), v("div", ho, [
2245
- e("div", bo, [
2246
- u[0] || (u[0] = e("span", { class: "flex-1 fm-typo-en-body-lg-600" }, "NetSuite Info", -1)),
2247
- e("div", go, [
2248
- e("div", _o, [
2249
- (a = (s = t.purchaseOrder) == null ? void 0 : s.netSuite) != null && a.id ? (i(), he(tt, { key: 0 }, {
2250
- default: ce(() => {
2251
- var O, f, R;
2252
- return [
2253
- T(yo, {
2254
- "netsuite-id": (f = (O = m.purchaseOrder) == null ? void 0 : O.netSuite) == null ? void 0 : f.id,
2255
- "purchase-order-id": (R = m.purchaseOrder) == null ? void 0 : R._id
2256
- }, null, 8, ["netsuite-id", "purchase-order-id"])
2257
- ];
2258
- }),
2259
- _: 1
2260
- })) : V("", !0),
2261
- T(tt, null, {
2262
- default: ce(() => {
2263
- var O, f, R;
2264
- return [
2265
- T(Hr, {
2266
- "netsuite-id": (f = (O = m.purchaseOrder) == null ? void 0 : O.netSuite) == null ? void 0 : f.id,
2267
- "purchase-order-id": (R = m.purchaseOrder) == null ? void 0 : R._id
2268
- }, null, 8, ["netsuite-id", "purchase-order-id"])
2269
- ];
2270
- }),
2271
- _: 1
2272
- }),
2273
- T($r, {
2274
- "po-request": m.poRequest,
2275
- "purchase-order": m.purchaseOrder,
2276
- "is-transfer-between-outlets": !n.value,
2277
- scope: m.scope
2278
- }, null, 8, ["po-request", "purchase-order", "is-transfer-between-outlets", "scope"])
2279
- ])
2280
- ])
2281
- ]),
2282
- T(c),
2283
- T(zr, {
2284
- "po-request": m.poRequest,
2285
- "purchase-order": m.purchaseOrder,
2286
- "transfer-type": m.transferType,
2287
- "transfer-to-db-name": m.transferToDbName,
2288
- "is-transfer-between-outlets": !n.value,
2289
- scope: m.scope
2290
- }, null, 8, ["po-request", "purchase-order", "transfer-type", "transfer-to-db-name", "is-transfer-between-outlets", "scope"])
2291
- ])) : V("", !0);
2292
- };
2293
- }
2294
- }), ko = ["open"], Oo = { class: "fm-typo-en-body-sm-600 cursor-pointer select-none" }, ts = /* @__PURE__ */ Ve({
2295
- __name: "FmAdminCollapsiblePanel",
2296
- props: {
2297
- title: { default: "Admin" },
2298
- open: { type: Boolean, default: !1 },
2299
- selectable: { type: Boolean, default: !0 },
2300
- class: { default: void 0 },
2301
- contentClass: { default: void 0 }
2302
- },
2303
- setup(d) {
2304
- const t = d;
2305
- return (r, n) => (i(), he(tt, {
2306
- selectable: t.selectable,
2307
- class: We(t.class)
2308
- }, {
2309
- default: ce(() => [
2310
- e("details", {
2311
- open: t.open,
2312
- class: "w-full"
2313
- }, [
2314
- e("summary", Oo, k(t.title), 1),
2315
- e("div", {
2316
- class: We(["mt-4 flex flex-col gap-2", t.contentClass])
2317
- }, [
2318
- Ds(r.$slots, "default")
2319
- ], 2)
2320
- ], 8, ko)
2321
- ]),
2322
- _: 3
2323
- }, 8, ["selectable", "class"]));
2324
- }
2325
- });
2326
- function _s(d) {
2327
- if (!(d != null && d.itemsAtSubmission)) return [];
2328
- const t = new Set(d.itemsAtSubmission.map((m) => m.sku._id)), r = /* @__PURE__ */ new Set(), n = [];
2329
- for (const m of d.items) {
2330
- const u = m.sku._id;
2331
- t.has(u) || r.has(u) || (r.add(u), n.push(m));
2332
- }
2333
- return n;
2334
- }
2335
- function Ss(d, t) {
2336
- var m;
2337
- if (!d || t.length === 0) return {};
2338
- const r = new Set(t.map((u) => u.sku._id)), n = {};
2339
- for (const u of d.deliveryOrder ?? [])
2340
- for (const c of u.received ?? []) {
2341
- const s = c.sku._id;
2342
- s && r.has(s) && (n[s] = (n[s] ?? 0) + (((m = c.amount) == null ? void 0 : m.amount) ?? 0));
2343
- }
2344
- return t.reduce(
2345
- (u, c) => {
2346
- var R, N;
2347
- const s = c.sku._id ?? "", a = ((R = c.quantity) == null ? void 0 : R.amount) ?? 0, O = n[s] ?? 0, f = ((N = c.quantity) == null ? void 0 : N.precision) ?? 0;
2348
- return u[s] = {
2349
- key: s,
2350
- total: { amount: a, precision: f },
2351
- received: { amount: O, precision: f },
2352
- remaining: { amount: a - O, precision: f }
2353
- }, u;
2354
- },
2355
- {}
2356
- );
2357
- }
2358
- const xo = { class: "flex flex-col gap-3" }, wo = { class: "flex flex-col gap-4" }, $o = { class: "flex flex-col gap-4 fm-typo-en-body-lg-600" }, Co = { class: "flex flex-col gap-4" }, Ao = { class: "flex justify-between items-start py-1 gap-4" }, Do = { class: "flex flex-col flex-1 min-w-0" }, Ro = { class: "fm-typo-en-body-lg-600 truncate" }, No = { class: "fm-typo-en-body-md-400 truncate" }, Po = { class: "flex flex-col gap-2 items-end w-52 shrink-0" }, Fo = {
2359
- key: 0,
2360
- class: "flex items-center gap-2"
2361
- }, Io = {
2362
- key: 0,
2363
- class: "border-b border-fm-color-stroke-secondary"
2364
- }, To = { class: "flex flex-col gap-4" }, Eo = { class: "flex items-center justify-between" }, qo = {
2365
- key: 0,
2366
- class: "fm-typo-en-body-md-400 text-fm-color-typo-tertiary"
2367
- }, Vo = { class: "flex justify-between items-start py-1 gap-4" }, Lo = { class: "flex-1 min-w-0 flex flex-col gap-2" }, jo = { class: "flex flex-col gap-2 items-end w-52 shrink-0" }, Uo = {
2368
- key: 0,
2369
- class: "flex items-center gap-2"
2370
- }, Mo = {
2371
- key: 0,
2372
- class: "border-b border-fm-color-stroke-secondary"
2373
- }, Bo = { class: "flex flex-col gap-4" }, zo = { class: "flex flex-col gap-4" }, Ko = { class: "flex flex-col gap-4" }, Ho = { class: "flex flex-col gap-4 fm-typo-en-body-lg-600" }, Go = {
2374
- key: 1,
2375
- class: "flex flex-col gap-4"
2376
- }, Wo = { class: "flex flex-col gap-4 fm-typo-en-body-lg-600" }, ct = "Will be ignored on save (zero or negative quantity)", Qo = /* @__PURE__ */ Ve({
2377
- __name: "EditForm",
2378
- props: {
2379
- purchaseOrder: {},
2380
- deliveryOrder: {},
2381
- receivedInfoMap: {}
2382
- },
2383
- emits: ["submitted"],
2384
- setup(d, { emit: t }) {
2385
- var ee;
2386
- const { t: r } = nr(), n = Je(), m = Ze(), u = ne(!1), c = Dt(), s = d, a = (((ee = s.purchaseOrder) == null ? void 0 : ee.version) ?? Ue.enum[1]) === Ue.enum[2], O = t, f = is("deliveryOrder"), R = Xe(), {
2387
- controller: N,
2388
- state: F,
2389
- reset: _
2390
- } = It({
2391
- currency: Ae(),
2392
- adjustments: s.deliveryOrder.priceAdjustments
2393
- }), B = H(
2394
- () => {
2395
- var L;
2396
- return ((L = s.purchaseOrder.deliveryFullfillment) == null ? void 0 : L.findIndex(
2397
- (g) => s.deliveryOrder.fullfillmentId && g.id === s.deliveryOrder.fullfillmentId
2398
- )) ?? -1;
2399
- }
2400
- ), E = n.enablePurchaseOrderReceiveWithCustomCost, te = n.enablePortalDeliveryOrderWrite, se = ne({}), Q = H(
2401
- () => (s.purchaseOrder.itemsAtSubmission ?? s.purchaseOrder.items).length
2402
- ), de = H(() => _s(s.purchaseOrder)), Oe = H(
2403
- () => Ss(s.purchaseOrder, de.value)
2404
- ), ae = H(
2405
- () => s.purchaseOrder.items.map(
2406
- (L, g) => H({
2407
- get: () => {
2408
- var J;
2409
- const j = (J = f.received[g]) == null ? void 0 : J.amount;
2410
- return j ? +$e(j) : 0;
2411
- },
2412
- set: (j) => {
2413
- f.received[g].amount = Qe(j, L.sku.unit.precision);
2414
- }
2415
- })
2416
- )
2417
- ), Se = H(
2418
- () => s.purchaseOrder.items.map(
2419
- (L, g) => H({
2420
- get: () => {
2421
- var J;
2422
- const j = (J = f.received[g]) == null ? void 0 : J.cost;
2423
- return j ? +$e(j) : 0;
2424
- },
2425
- set: (j) => {
2426
- f.received[g].cost = {
2427
- currency: Ae(),
2428
- ...Qe(j, 4)
2429
- };
2430
- }
2431
- })
2432
- )
2433
- );
2434
- function De(L) {
2435
- var j;
2436
- const g = !se.value[L];
2437
- if (se.value[L] = g, g) {
2438
- const J = (j = f.received[L]) == null ? void 0 : j.cost;
2439
- f.received[L].cost = J ? { ...J, precision: 4 } : { currency: Ae(), amount: 0, precision: 4 };
2440
- } else
2441
- delete f.received[L].cost;
2442
- }
2443
- const K = ne([]), ve = H(
2444
- () => c.skus.filter((L) => !L.isInactive).map((L) => ({ label: `${L.name} (${L.code})`, value: L._id }))
2445
- );
2446
- function P() {
2447
- K.value.push({ skuId: null, costEnabled: !1 }), f.received.push({
2448
- sku: null,
2449
- amount: Pe.fromNumber(0),
2450
- measurement: null
2451
- });
2452
- }
2453
- function x(L) {
2454
- K.value.splice(L, 1), f.received.splice(Q.value + L, 1);
2455
- }
2456
- function w(L, g) {
2457
- K.value[L].skuId = g;
2458
- const j = g ? c.skuById[g] : null;
2459
- f.received[Q.value + L].sku = j;
2460
- }
2461
- function A(L, g) {
2462
- var ke, we;
2463
- const j = (ke = s.receivedInfoMap) == null ? void 0 : ke[g.sku._id], J = j ? `${r("inventory.transfer.receiveRequest.details.received")} ${Pe.toFormatString({ value: j.received })} / ${ft(g.quantity, g.sku.unit, g.measurement)}` : void 0;
2464
- return (((we = ae.value[L]) == null ? void 0 : we.value) ?? 0) > 0 ? J : J ? `${J} · ${ct}` : ct;
2465
- }
2466
- function G(L, g) {
2467
- var ke;
2468
- const J = (((ke = X.value[g]) == null ? void 0 : ke.value) ?? 0) <= 0;
2469
- let me;
2470
- if (L.skuId && Oe.value[L.skuId]) {
2471
- const we = Oe.value[L.skuId], o = Pe.toFormatString({ value: we.received });
2472
- me = `${r("inventory.transfer.receiveRequest.details.received")} ${o}`;
2473
- }
2474
- return J ? me ? `${me} · ${ct}` : ct : me;
2475
- }
2476
- const X = H(
2477
- () => K.value.map((L, g) => {
2478
- const j = Q.value + g;
2479
- return H({
2480
- get: () => {
2481
- var me;
2482
- const J = (me = f.received[j]) == null ? void 0 : me.amount;
2483
- return J ? +$e(J) : 0;
2484
- },
2485
- set: (J) => {
2486
- var ke, we, o;
2487
- const me = ((ke = L.historyItem) == null ? void 0 : ke.sku.unit.precision) ?? (L.skuId ? (o = (we = c.skuById[L.skuId]) == null ? void 0 : we.unit) == null ? void 0 : o.precision : void 0) ?? 2;
2488
- f.received[j].amount = Qe(J, me);
2489
- }
2490
- });
2491
- })
2492
- ), le = H(
2493
- () => K.value.map((L, g) => {
2494
- const j = Q.value + g;
2495
- return H({
2496
- get: () => {
2497
- var me;
2498
- const J = (me = f.received[j]) == null ? void 0 : me.cost;
2499
- return J ? +$e(J) : 0;
2500
- },
2501
- set: (J) => {
2502
- f.received[j].cost = {
2503
- currency: Ae(),
2504
- ...Qe(J, 4)
2505
- };
2506
- }
2507
- });
2508
- })
2509
- );
2510
- function b(L) {
2511
- const g = K.value[L], j = Q.value + L;
2512
- g.costEnabled = !g.costEnabled, g.costEnabled ? f.received[j].cost = { currency: Ae(), amount: 0, precision: 4 } : delete f.received[j].cost;
2513
- }
2514
- Ye(
2515
- () => u.value,
2516
- (L) => {
2517
- var o, l, $;
2518
- if (!L) {
2519
- K.value = [], se.value = {};
2520
- return;
2521
- }
2522
- _(s.deliveryOrder.priceAdjustments);
2523
- const g = s.purchaseOrder.itemsAtSubmission ?? s.purchaseOrder.items, j = new Set(g.map((C) => C.sku._id)), J = {}, me = [];
2524
- for (const C of s.deliveryOrder.received ?? []) {
2525
- const q = (o = C.sku) == null ? void 0 : o._id;
2526
- q && (j.has(q) ? J[q] = C : me.push(C));
2527
- }
2528
- f.received = g.map((C) => {
2529
- const q = J[C.sku._id];
2530
- return q ? { ...q } : {
2531
- // Propagate the stable id so V2 submissions match this existing PO line
2532
- // instead of the backend treating it as a new extra item (see CreateForm.vue).
2533
- ...a && C.id ? { id: C.id } : {},
2534
- sku: C.sku,
2535
- amount: Pe.fromNumber(0),
2536
- measurement: C.measurement ?? null
2537
- };
2538
- });
2539
- const ke = {};
2540
- for (let C = 0; C < g.length; C++)
2541
- (l = J[g[C].sku._id]) != null && l.cost && (ke[C] = !0);
2542
- se.value = ke, K.value = [];
2543
- const we = de.value;
2544
- for (const C of me) {
2545
- const q = we.find((Y) => {
2546
- var ye;
2547
- return Y.sku._id === ((ye = C.sku) == null ? void 0 : ye._id);
2548
- });
2549
- K.value.push({
2550
- skuId: (($ = C.sku) == null ? void 0 : $._id) ?? null,
2551
- costEnabled: !!C.cost,
2552
- locked: !0,
2553
- quantityLocked: !0,
2554
- historyItem: q
2555
- }), f.received.push({ ...C });
2556
- }
2557
- if (we.length) {
2558
- const C = new Set(me.map((q) => {
2559
- var Y;
2560
- return (Y = q.sku) == null ? void 0 : Y._id;
2561
- }));
2562
- for (const q of we)
2563
- C.has(q.sku._id) || (K.value.push({
2564
- skuId: q.sku._id,
2565
- costEnabled: !1,
2566
- locked: !0,
2567
- historyItem: q
2568
- }), f.received.push({
2569
- ...a && q.id ? { id: q.id } : {},
2570
- sku: q.sku,
2571
- amount: Pe.fromNumber(0),
2572
- measurement: q.measurement ?? null
2573
- }));
2574
- }
2575
- }
2576
- );
2577
- const D = ne(!1);
2578
- function ie() {
2579
- D.value = !0, R.updateDeliveryOrder({
2580
- deliveryOrder: {
2581
- ...s.deliveryOrder,
2582
- ...f,
2583
- priceAdjustments: N.value.state().adjustments
2584
- },
2585
- purchaseOrderId: s.purchaseOrder._id,
2586
- purchaseOrderRev: s.purchaseOrder._rev
2587
- }).then(() => {
2588
- m.open(
2589
- {
2590
- title: "Success",
2591
- message: `PO# ${s.purchaseOrder.seqNumber} Changes have been saved`,
2592
- type: "success"
2593
- },
2594
- 1e4
2595
- ), u.value = !1, O("submitted");
2596
- }).finally(() => {
2597
- D.value = !1;
2598
- });
2599
- }
2600
- return (L, g) => {
2601
- const j = oe("FmButton"), J = oe("FmStepperField"), me = oe("FmSwitch"), ke = oe("FmSelect"), we = oe("FmTextField"), o = oe("FmDialog");
2602
- return i(), he(o, {
2603
- modelValue: u.value,
2604
- "onUpdate:modelValue": g[1] || (g[1] = (l) => u.value = l),
2605
- overlay: !0,
2606
- "min-width": 800
2607
- }, {
2608
- "dialog-button": ce(() => [
2609
- h(te) ? (i(), he(j, {
2610
- key: 0,
2611
- variant: "plain",
2612
- label: "Edit",
2613
- size: "md",
2614
- "prepend-icon": "edit"
2615
- })) : V("", !0)
2616
- ]),
2617
- "dialog-header": ce(() => [
2618
- e("div", null, "Received on " + k(h(et)(s.deliveryOrder.createdAt)), 1)
2619
- ]),
2620
- "dialog-footer": ce(() => [
2621
- T(j, {
2622
- class: "ml-auto",
2623
- label: "Apply changes",
2624
- size: "md",
2625
- variant: "destructive",
2626
- disabled: D.value,
2627
- loading: D.value,
2628
- onClick: ie
2629
- }, null, 8, ["disabled", "loading"])
2630
- ]),
2631
- default: ce(() => [
2632
- e("div", xo, [
2633
- e("div", wo, [
2634
- g[2] || (g[2] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Adjustment date", -1)),
2635
- e("div", $o, k(s.deliveryOrder.adjustment ? h(et)(new Date(h(mt)(s.deliveryOrder.adjustment))) : "-"), 1)
2636
- ]),
2637
- e("div", Co, [
2638
- g[4] || (g[4] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, " Items going to receive ", -1)),
2639
- (i(!0), v(Ce, null, Te(s.purchaseOrder.items, (l, $) => {
2640
- var C;
2641
- return i(), v("div", { key: $ }, [
2642
- e("div", Ao, [
2643
- e("div", Do, [
2644
- e("span", Ro, k(l.sku.name), 1),
2645
- e("span", No, k(l.sku.code), 1)
2646
- ]),
2647
- e("div", Po, [
2648
- T(J, {
2649
- label: "Receive Quantity",
2650
- modelValue: ae.value[$].value,
2651
- "onUpdate:modelValue": (q) => ae.value[$].value = q,
2652
- "append-text": ((C = l.measurement) == null ? void 0 : C.abbrev) ?? l.sku.unit.abbrev,
2653
- "helper-text": A($, l)
2654
- }, null, 8, ["modelValue", "onUpdate:modelValue", "append-text", "helper-text"]),
2655
- h(E) ? (i(), v("div", Fo, [
2656
- T(me, {
2657
- "model-value": se.value[$],
2658
- "onUpdate:modelValue": (q) => De($),
2659
- size: "sm"
2660
- }, null, 8, ["model-value", "onUpdate:modelValue"]),
2661
- g[3] || (g[3] = e("span", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " Override cost ", -1))
2662
- ])) : V("", !0),
2663
- h(E) && se.value[$] ? (i(), he(J, {
2664
- key: 1,
2665
- modelValue: Se.value[$].value,
2666
- "onUpdate:modelValue": (q) => Se.value[$].value = q,
2667
- label: "Total Cost",
2668
- step: 1e-4,
2669
- min: 0,
2670
- placeholder: "0.0000",
2671
- size: "sm",
2672
- "append-text": h(Ae)()
2673
- }, null, 8, ["modelValue", "onUpdate:modelValue", "append-text"])) : V("", !0)
2674
- ])
2675
- ]),
2676
- $ < s.purchaseOrder.items.length - 1 ? (i(), v("div", Io)) : V("", !0)
2677
- ]);
2678
- }), 128))
2679
- ]),
2680
- e("div", To, [
2681
- e("div", Eo, [
2682
- g[5] || (g[5] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Extra items", -1)),
2683
- T(j, {
2684
- variant: "tertiary",
2685
- label: "Add item",
2686
- "prepend-icon": "add",
2687
- size: "md",
2688
- onClick: P
2689
- })
2690
- ]),
2691
- K.value.length === 0 ? (i(), v("div", qo, " No extra items added ")) : V("", !0),
2692
- (i(!0), v(Ce, null, Te(K.value, (l, $) => {
2693
- var C, q;
2694
- return i(), v("div", { key: $ }, [
2695
- e("div", Vo, [
2696
- e("div", Lo, [
2697
- T(ke, {
2698
- "model-value": l.skuId,
2699
- "onUpdate:modelValue": (Y) => w($, Y),
2700
- label: "Ingredient",
2701
- items: ve.value,
2702
- searchable: "",
2703
- searchTarget: "label",
2704
- placeholder: "Select ingredient",
2705
- disabled: l.locked
2706
- }, null, 8, ["model-value", "onUpdate:modelValue", "items", "disabled"])
2707
- ]),
2708
- e("div", jo, [
2709
- T(J, {
2710
- label: "Receive Quantity",
2711
- modelValue: X.value[$].value,
2712
- "onUpdate:modelValue": (Y) => X.value[$].value = Y,
2713
- "append-text": l.skuId ? ((q = (C = h(c).skuById[l.skuId]) == null ? void 0 : C.unit) == null ? void 0 : q.abbrev) ?? "" : "",
2714
- "helper-text": G(l, $),
2715
- disabled: l.quantityLocked || !l.skuId
2716
- }, null, 8, ["modelValue", "onUpdate:modelValue", "append-text", "helper-text", "disabled"]),
2717
- h(E) ? (i(), v("div", Uo, [
2718
- T(me, {
2719
- "model-value": l.costEnabled,
2720
- "onUpdate:modelValue": (Y) => b($),
2721
- size: "sm"
2722
- }, null, 8, ["model-value", "onUpdate:modelValue"]),
2723
- g[6] || (g[6] = e("span", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " Override cost ", -1))
2724
- ])) : V("", !0),
2725
- h(E) && l.costEnabled ? (i(), he(J, {
2726
- key: 1,
2727
- modelValue: le.value[$].value,
2728
- "onUpdate:modelValue": (Y) => le.value[$].value = Y,
2729
- label: "Total Cost",
2730
- step: 1e-4,
2731
- min: 0,
2732
- placeholder: "0.0000",
2733
- size: "sm",
2734
- "append-text": h(Ae)()
2735
- }, null, 8, ["modelValue", "onUpdate:modelValue", "append-text"])) : V("", !0)
2736
- ]),
2737
- l.locked ? V("", !0) : (i(), he(j, {
2738
- key: 0,
2739
- variant: "tertiary",
2740
- "prepend-icon": "delete",
2741
- size: "md",
2742
- class: "mt-6",
2743
- onClick: (Y) => x($)
2744
- }, null, 8, ["onClick"]))
2745
- ]),
2746
- $ < K.value.length - 1 ? (i(), v("div", Mo)) : V("", !0)
2747
- ]);
2748
- }), 128))
2749
- ]),
2750
- e("div", Bo, [
2751
- g[7] || (g[7] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Delivery order no.", -1)),
2752
- e("div", zo, [
2753
- T(we, {
2754
- modelValue: h(f).deliveryOrderNumber,
2755
- "onUpdate:modelValue": g[0] || (g[0] = (l) => h(f).deliveryOrderNumber = l),
2756
- size: "md",
2757
- placeholder: s.deliveryOrder.deliveryOrderNumber
2758
- }, null, 8, ["modelValue", "placeholder"])
2759
- ])
2760
- ]),
2761
- e("div", Ko, [
2762
- g[8] || (g[8] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Remark", -1)),
2763
- e("div", Ho, k(s.deliveryOrder.remark || "N/A"), 1)
2764
- ]),
2765
- h(n).enablePurchaseOrderPriceAdjustment ? (i(), he(Ft, {
2766
- key: 0,
2767
- controller: h(N),
2768
- state: h(F)
2769
- }, null, 8, ["controller", "state"])) : V("", !0),
2770
- B.value >= 0 ? (i(), v("div", Go, [
2771
- g[9] || (g[9] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Fulfilment's sequence", -1)),
2772
- e("div", Wo, k(B.value + 1), 1)
2773
- ])) : V("", !0)
2774
- ])
2775
- ]),
2776
- _: 1
2777
- }, 8, ["modelValue"]);
2778
- };
2779
- }
2780
- }), Yo = { class: "flex flex-col gap-3" }, Jo = { class: "flex flex-col gap-4" }, Zo = { class: "flex flex-col gap-4 fm-typo-en-body-lg-600" }, Xo = {
2781
- key: 0,
2782
- class: "flex flex-col gap-4"
2783
- }, en = { class: "flex items-center justify-between" }, tn = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, sn = {
2784
- key: 0,
2785
- class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
2786
- }, rn = { class: "flex gap-4" }, on = { class: "flex-1" }, nn = { class: "flex-1" }, an = {
2787
- key: 0,
2788
- class: "flex items-center text-fm-color-system-error-300"
2789
- }, ln = { class: "fm-typo-en-body-md-400" }, un = { class: "flex flex-col gap-4" }, cn = { class: "flex justify-between items-start py-1 gap-4" }, dn = { class: "flex flex-col flex-1 min-w-0" }, mn = { class: "fm-typo-en-body-lg-600 truncate" }, pn = { class: "fm-typo-en-body-md-400 truncate" }, fn = { class: "flex flex-col gap-2 items-end w-52 shrink-0" }, vn = {
2790
- key: 0,
2791
- class: "fm-typo-en-body-sm-400 text-fm-color-system-error-300 self-end text-right"
2792
- }, yn = {
2793
- key: 1,
2794
- class: "flex items-center gap-2"
2795
- }, hn = {
2796
- key: 0,
2797
- class: "border-b border-fm-color-stroke-secondary"
2798
- }, bn = { class: "flex flex-col gap-4" }, gn = { class: "flex items-center justify-between" }, _n = {
2799
- key: 0,
2800
- class: "fm-typo-en-body-md-400 text-fm-color-typo-tertiary"
2801
- }, Sn = { class: "flex justify-between items-start py-1 gap-4" }, kn = { class: "flex-1 min-w-0 flex flex-col gap-2" }, On = { class: "flex flex-col gap-2 items-end w-52 shrink-0" }, xn = {
2802
- key: 0,
2803
- class: "fm-typo-en-body-sm-400 text-fm-color-system-error-300 self-end text-right"
2804
- }, wn = {
2805
- key: 1,
2806
- class: "flex items-center gap-2"
2807
- }, $n = {
2808
- key: 0,
2809
- class: "border-b border-fm-color-stroke-secondary"
2810
- }, Cn = { class: "flex flex-col gap-4" }, An = { class: "flex flex-col gap-4" }, Dn = { class: "flex flex-col gap-4" }, Rn = { class: "flex flex-col gap-4 fm-typo-en-body-lg-600" }, ss = "Will be ignored on save (zero or negative quantity)", Nn = /* @__PURE__ */ Ve({
2811
- __name: "CreateForm",
2812
- props: {
2813
- purchaseOrder: {},
2814
- receivedInfoMap: {},
2815
- receivedMap: {}
2816
- },
2817
- emits: ["submitted"],
2818
- setup(d, { emit: t }) {
2819
- var ye, I, pe;
2820
- const { t: r } = ht(), n = ne(!1), m = bt(), u = d, c = t, s = is("", {
2821
- default: {
2822
- deliveryOrderNumber: "",
2823
- remark: "",
2824
- received: (u.purchaseOrder.itemsAtSubmission ?? u.purchaseOrder.items).map((y) => {
2825
- var p;
2826
- return {
2827
- // Propagate the stable id so V2 submissions match this existing PO line instead
2828
- // of the backend's classify-received.ts treating it as a new extra item (which
2829
- // appends a duplicate item record with quantity = this delivery's amount, on
2830
- // every single delivery — inflating the PO's total ordered quantity forever).
2831
- ...(((p = u.purchaseOrder) == null ? void 0 : p.version) ?? Ue.enum[1]) === Ue.enum[2] && y.id ? { id: y.id } : {},
2832
- sku: y.sku,
2833
- amount: Pe.fromNumber(0),
2834
- measurement: y.measurement
2835
- };
2836
- }),
2837
- createdBy: {
2838
- id: ((ye = m.sessionUser.value) == null ? void 0 : ye.id) || "",
2839
- name: ((I = m.sessionUser.value) == null ? void 0 : I.displayName) || ""
2840
- },
2841
- createdAt: ""
2842
- }
2843
- }), a = Xe(), O = gt(), f = Je(), R = Dt(), {
2844
- controller: N,
2845
- state: F,
2846
- reset: _
2847
- } = It({ currency: Ae() }), B = H(
2848
- () => u.purchaseOrder.deliveryFullfillment != null
2849
- ), E = H(
2850
- () => f.enablePortalDeliveryOrderWrite && (u.purchaseOrder.status === ge.Enum.RECEIVING || u.purchaseOrder.status === ge.Enum.COMPLETE) && !B.value
2851
- ), te = f.enablePurchaseOrderReceiveWithCustomCost, se = f.enableBackdateReceive, Q = ne({}), de = H(
2852
- () => u.purchaseOrder.itemsAtSubmission ?? u.purchaseOrder.items
2853
- ), Oe = H(() => _s(u.purchaseOrder)), ae = H(
2854
- () => Ss(u.purchaseOrder, Oe.value)
2855
- );
2856
- function Se(y) {
2857
- return y.sku._id ?? null;
2858
- }
2859
- const De = (((pe = u.purchaseOrder) == null ? void 0 : pe.version) ?? Ue.enum[1]) === Ue.enum[2], K = Ze(), ve = H({
2860
- get() {
2861
- if (!s.createdAt) return "";
2862
- const y = new Date(s.createdAt), p = y.getFullYear(), S = String(y.getMonth() + 1).padStart(2, "0"), U = String(y.getDate()).padStart(2, "0");
2863
- return `${p}-${S}-${U}`;
2864
- },
2865
- set(y) {
2866
- if (y) {
2867
- const p = s.createdAt ? new Date(s.createdAt) : /* @__PURE__ */ new Date(), [S, U, M] = y.split("-");
2868
- p.setFullYear(parseInt(S)), p.setMonth(parseInt(U) - 1), p.setDate(parseInt(M)), s.createdAt = p.toISOString();
2869
- }
2870
- }
2871
- }), P = H({
2872
- get() {
2873
- if (!s.createdAt) return "";
2874
- const y = new Date(s.createdAt), p = String(y.getHours()).padStart(2, "0"), S = String(y.getMinutes()).padStart(2, "0");
2875
- return `${p}:${S}`;
2876
- },
2877
- set(y) {
2878
- if (y) {
2879
- const p = s.createdAt ? new Date(s.createdAt) : /* @__PURE__ */ new Date(), [S, U] = y.split(":");
2880
- p.setHours(parseInt(S)), p.setMinutes(parseInt(U)), s.createdAt = p.toISOString();
2881
- }
2882
- }
2883
- }), x = H(() => {
2884
- const y = mt(u.purchaseOrder._id);
2885
- if (!y) return "";
2886
- const p = new Date(y), S = p.getFullYear(), U = String(p.getMonth() + 1).padStart(2, "0"), M = String(p.getDate()).padStart(2, "0");
2887
- return `${S}-${U}-${M}`;
2888
- }), w = H(() => {
2889
- const y = mt(u.purchaseOrder._id);
2890
- return y ? new Date(y) : null;
2891
- }), A = H(() => {
2892
- if (!ve.value || !P.value || !w.value) return null;
2893
- if (/* @__PURE__ */ new Date(`${ve.value}T${P.value}:00`) < w.value) {
2894
- const p = x.value, S = w.value.getHours(), U = w.value.getMinutes(), M = S >= 12 ? "PM" : "AM", _e = S % 12 || 12, xe = `${String(_e).padStart(2, "0")}:${String(U).padStart(2, "0")} ${M}`;
2895
- return `Delivery date & time cannot be earlier than order creation (${p} ${xe})`;
2896
- }
2897
- return null;
2898
- }), G = H(() => A.value || ee.value.some((p) => !p.skuId) ? !1 : s.received.some((p) => {
2899
- const S = p.amount;
2900
- return S ? +$e(S) > 0 : !1;
2901
- }));
2902
- function X(y) {
2903
- var U;
2904
- const p = (U = u.receivedInfoMap[y.sku._id]) == null ? void 0 : U.received, S = p != null ? Pe.toFormatString({ value: p }) : "0";
2905
- return `${r("inventory.transfer.receiveRequest.details.received")} ${S} / ${ft(y.quantity, y.sku.unit, y.measurement)}`;
2906
- }
2907
- function le() {
2908
- s.createdAt = "";
2909
- }
2910
- const b = H(() => de.value.map((y, p) => H({
2911
- get: () => {
2912
- var U;
2913
- const S = (U = s.received[p]) == null ? void 0 : U.amount;
2914
- return S ? +$e(S) : 0;
2915
- },
2916
- set: (S) => {
2917
- var M;
2918
- const U = ((M = de.value[p]) == null ? void 0 : M.sku.unit.precision) ?? 2;
2919
- s.received[p].amount = Qe(S, U);
2920
- }
2921
- })));
2922
- function D(y) {
2923
- const p = !Q.value[y];
2924
- if (Q.value[y] = p, p) {
2925
- const S = de.value[y];
2926
- S.totalCost ? s.received[y].cost = {
2927
- currency: S.totalCost.currency,
2928
- amount: S.totalCost.amount,
2929
- precision: 4
2930
- // Standardize to 4 decimals
2931
- } : s.received[y].cost = {
2932
- currency: Ae(),
2933
- amount: 0,
2934
- precision: 4
2935
- };
2936
- } else
2937
- delete s.received[y].cost;
2938
- }
2939
- const ie = H(() => de.value.map((y, p) => H({
2940
- get: () => {
2941
- var U;
2942
- const S = (U = s.received[p]) == null ? void 0 : U.cost;
2943
- return S ? +$e(S) : 0;
2944
- },
2945
- set: (S) => {
2946
- s.received[p].cost = {
2947
- currency: Ae(),
2948
- ...Qe(S, 4)
2949
- };
2950
- }
2951
- }))), ee = ne([]), L = H(
2952
- () => R.skus.filter((y) => !y.isInactive).map((y) => ({ label: `${y.name} (${y.code})`, value: y._id }))
2953
- ), g = H(() => de.value.length);
2954
- function j() {
2955
- ee.value.push({ skuId: null, stableKey: null, costEnabled: !1 }), s.received.push({
2956
- sku: null,
2957
- amount: Pe.fromNumber(0),
2958
- measurement: null
2959
- });
2960
- }
2961
- function J(y) {
2962
- ee.value.splice(y, 1), s.received.splice(g.value + y, 1);
2963
- }
2964
- function me(y, p) {
2965
- ee.value[y].skuId = p;
2966
- const S = p ? R.skuById[p] : null;
2967
- s.received[g.value + y].sku = S;
2968
- }
2969
- function ke(y) {
2970
- const p = y.stableKey;
2971
- if (p && ae.value[p]) {
2972
- const S = ae.value[p], U = Pe.toFormatString({ value: S.received });
2973
- return `${r("inventory.transfer.receiveRequest.details.received")} ${U}`;
2974
- }
2975
- }
2976
- const we = H(
2977
- () => ee.value.map((y, p) => {
2978
- const S = g.value + p;
2979
- return H({
2980
- get: () => {
2981
- var M;
2982
- const U = (M = s.received[S]) == null ? void 0 : M.amount;
2983
- return U ? +$e(U) : 0;
2984
- },
2985
- set: (U) => {
2986
- var xe, W, Z;
2987
- const M = ee.value[p], _e = ((xe = M == null ? void 0 : M.historyItem) == null ? void 0 : xe.sku.unit.precision) ?? (M != null && M.skuId ? (Z = (W = R.skuById[M.skuId]) == null ? void 0 : W.unit) == null ? void 0 : Z.precision : void 0) ?? 2;
2988
- s.received[S].amount = Qe(U, _e);
2989
- }
2990
- });
2991
- })
2992
- ), o = H(
2993
- () => ee.value.map((y, p) => {
2994
- const S = g.value + p;
2995
- return H({
2996
- get: () => {
2997
- var M;
2998
- const U = (M = s.received[S]) == null ? void 0 : M.cost;
2999
- return U ? +$e(U) : 0;
3000
- },
3001
- set: (U) => {
3002
- s.received[S].cost = {
3003
- currency: Ae(),
3004
- ...Qe(U, 4)
3005
- };
3006
- }
3007
- });
3008
- })
3009
- );
3010
- function l(y) {
3011
- const p = ee.value[y], S = g.value + y;
3012
- p.costEnabled = !p.costEnabled, p.costEnabled ? s.received[S].cost = { currency: Ae(), amount: 0, precision: 4 } : delete s.received[S].cost;
3013
- }
3014
- function $() {
3015
- Y() && O.open({
3016
- title: "Confirm Create Delivery Order",
3017
- message: `Are you sure you want to create delivery order for PO# ${u.purchaseOrder.seqNumber}?`,
3018
- primaryActions: {
3019
- text: "Create",
3020
- close: !0,
3021
- variant: "primary"
3022
- },
3023
- secondaryActions: {
3024
- text: "Cancel",
3025
- close: !0
3026
- }
3027
- }).onPrimary(() => q());
3028
- }
3029
- const C = ne(!1);
3030
- function q() {
3031
- Y() && (C.value = !0, a.createDeliveryOrder({
3032
- deliveryOrder: {
3033
- ...s,
3034
- priceAdjustments: N.value.state().adjustments
3035
- },
3036
- purchaseOrderId: u.purchaseOrder._id,
3037
- purchaseOrderRev: u.purchaseOrder._rev,
3038
- currency: Ae()
3039
- }).then(() => {
3040
- K.open(
3041
- {
3042
- title: "Success",
3043
- message: `New delivery order created for PO# ${u.purchaseOrder.seqNumber}`,
3044
- type: "success"
3045
- },
3046
- 1e4
3047
- ), n.value = !1, c("submitted");
3048
- }).finally(() => {
3049
- C.value = !1;
3050
- }));
3051
- }
3052
- function Y() {
3053
- return B.value ? (n.value = !1, K.open(
3054
- {
3055
- title: "Purchase order updated",
3056
- message: "This purchase order now uses fulfillment receiving. Refresh and receive stock from the fulfillment section.",
3057
- type: "error"
3058
- },
3059
- 1e4
3060
- ), !1) : !0;
3061
- }
3062
- return Ye(B, (y) => {
3063
- !y || !n.value || Y();
3064
- }), Ye(
3065
- () => n.value,
3066
- (y) => {
3067
- var U;
3068
- if (!y) {
3069
- ee.value = [], _([]), s.received = de.value.map((M) => ({
3070
- ...De && M.id ? { id: M.id } : {},
3071
- sku: M.sku,
3072
- amount: Pe.fromNumber(0),
3073
- measurement: M.measurement
3074
- }));
3075
- return;
3076
- }
3077
- const p = de.value;
3078
- for (let M = 0; M < p.length; M++) {
3079
- const _e = p[M], W = (((U = u.purchaseOrder) == null ? void 0 : U.version) ?? Ue.enum[1]) === Ue.enum[2] ? _e.id : _e.sku._id, Z = u.receivedMap[W], be = +$e(_e.quantity), Fe = Z ? +$e(Z.received) : 0;
3080
- b.value[M].value = Math.max(0, be - Fe);
3081
- }
3082
- const S = Oe.value;
3083
- if (S.length) {
3084
- for (const M of S) {
3085
- const _e = Se(M);
3086
- ee.value.push({
3087
- skuId: M.sku._id,
3088
- stableKey: _e,
3089
- costEnabled: !1,
3090
- historyItem: M
3091
- }), s.received.push({
3092
- // Propagate the stable id so V2 submissions align with the existing PO line.
3093
- ...De && M.id ? { id: M.id } : {},
3094
- sku: M.sku,
3095
- amount: Pe.fromNumber(0),
3096
- measurement: M.measurement ?? null
3097
- });
3098
- }
3099
- for (let M = 0; M < S.length; M++) {
3100
- const _e = Se(S[M]), xe = _e ? ae.value[_e] : void 0;
3101
- if (xe) {
3102
- const W = Math.pow(10, xe.remaining.precision ?? 2);
3103
- we.value[M].value = Math.max(0, xe.remaining.amount / W);
3104
- }
3105
- }
3106
- }
3107
- }
3108
- ), (y, p) => {
3109
- const S = oe("FmButton"), U = oe("FmDatePicker"), M = oe("FmTimePicker"), _e = oe("FmIcon"), xe = oe("FmStepperField"), W = oe("FmSwitch"), Z = oe("FmSelect"), be = oe("FmTextField"), Fe = oe("FmDialog");
3110
- return i(), he(Fe, {
3111
- modelValue: n.value,
3112
- "onUpdate:modelValue": p[4] || (p[4] = (Ie) => n.value = Ie),
3113
- overlay: !0,
3114
- "min-width": 800
3115
- }, {
3116
- "dialog-button": ce(() => [
3117
- E.value ? (i(), he(S, {
3118
- key: 0,
3119
- variant: "primary",
3120
- label: "Create",
3121
- size: "md",
3122
- "prepend-icon": "add",
3123
- class: "w-full"
3124
- })) : V("", !0)
3125
- ]),
3126
- "dialog-header": ce(() => [
3127
- e("div", null, "Order #" + k(u.purchaseOrder.seqNumber) + " (New Delivery Order)", 1)
3128
- ]),
3129
- "dialog-footer": ce(() => [
3130
- T(S, {
3131
- class: "ml-auto",
3132
- label: "Create",
3133
- size: "md",
3134
- variant: "destructive",
3135
- disabled: !G.value || C.value,
3136
- loading: C.value,
3137
- onClick: $
3138
- }, null, 8, ["disabled", "loading"])
3139
- ]),
3140
- default: ce(() => {
3141
- var Ie;
3142
- return [
3143
- e("div", Yo, [
3144
- e("div", Jo, [
3145
- p[5] || (p[5] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Received by", -1)),
3146
- e("div", Zo, k((Ie = h(m).sessionUser.value) == null ? void 0 : Ie.displayName), 1)
3147
- ]),
3148
- h(se) ? (i(), v("div", Xo, [
3149
- e("div", en, [
3150
- e("div", tn, [
3151
- p[6] || (p[6] = Ge(" Delivery Date & Time ")),
3152
- !ve.value && !P.value ? (i(), v("div", sn, " Leave blank to use current date & time ")) : V("", !0)
3153
- ]),
3154
- ve.value || P.value ? (i(), he(S, {
3155
- key: 0,
3156
- variant: "tertiary",
3157
- label: "Clear",
3158
- "prepend-icon": "close",
3159
- onClick: le
3160
- })) : V("", !0)
3161
- ]),
3162
- e("div", rn, [
3163
- e("div", on, [
3164
- T(U, {
3165
- modelValue: ve.value,
3166
- "onUpdate:modelValue": p[0] || (p[0] = (fe) => ve.value = fe)
3167
- }, null, 8, ["modelValue"])
3168
- ]),
3169
- e("div", nn, [
3170
- T(M, {
3171
- modelValue: P.value,
3172
- "onUpdate:modelValue": p[1] || (p[1] = (fe) => P.value = fe)
3173
- }, null, 8, ["modelValue"])
3174
- ])
3175
- ]),
3176
- A.value ? (i(), v("div", an, [
3177
- T(_e, {
3178
- name: "error",
3179
- class: "inline-block mr-1",
3180
- size: "sm"
3181
- }),
3182
- e("div", ln, k(A.value), 1)
3183
- ])) : V("", !0)
3184
- ])) : V("", !0),
3185
- e("div", un, [
3186
- p[8] || (p[8] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, " Items going to receive ", -1)),
3187
- (i(!0), v(Ce, null, Te(de.value, (fe, ue) => {
3188
- var Ne;
3189
- return i(), v("div", { key: ue }, [
3190
- e("div", cn, [
3191
- e("div", dn, [
3192
- e("span", mn, k(fe.sku.name), 1),
3193
- e("span", pn, k(fe.sku.code), 1)
3194
- ]),
3195
- e("div", fn, [
3196
- T(xe, {
3197
- label: "Receive Quantity",
3198
- modelValue: b.value[ue].value,
3199
- "onUpdate:modelValue": (Ee) => b.value[ue].value = Ee,
3200
- "helper-text": X(fe),
3201
- "append-text": ((Ne = fe.measurement) == null ? void 0 : Ne.abbrev) ?? fe.sku.unit.abbrev
3202
- }, null, 8, ["modelValue", "onUpdate:modelValue", "helper-text", "append-text"]),
3203
- b.value[ue].value <= 0 ? (i(), v("div", vn, k(ss))) : V("", !0),
3204
- h(te) ? (i(), v("div", yn, [
3205
- T(W, {
3206
- "model-value": Q.value[ue],
3207
- "onUpdate:modelValue": (Ee) => D(ue),
3208
- size: "sm"
3209
- }, null, 8, ["model-value", "onUpdate:modelValue"]),
3210
- p[7] || (p[7] = e("span", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " Override cost ", -1))
3211
- ])) : V("", !0),
3212
- h(te) && Q.value[ue] ? (i(), he(xe, {
3213
- key: 2,
3214
- modelValue: ie.value[ue].value,
3215
- "onUpdate:modelValue": (Ee) => ie.value[ue].value = Ee,
3216
- label: "Total Cost",
3217
- step: 1e-4,
3218
- min: 0,
3219
- placeholder: "0.0000",
3220
- size: "sm",
3221
- "append-text": h(Ae)()
3222
- }, null, 8, ["modelValue", "onUpdate:modelValue", "append-text"])) : V("", !0)
3223
- ])
3224
- ]),
3225
- ue < de.value.length - 1 ? (i(), v("div", hn)) : V("", !0)
3226
- ]);
3227
- }), 128))
3228
- ]),
3229
- e("div", bn, [
3230
- e("div", gn, [
3231
- p[9] || (p[9] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Extra items", -1)),
3232
- T(S, {
3233
- variant: "tertiary",
3234
- label: "Add item",
3235
- "prepend-icon": "add",
3236
- size: "md",
3237
- onClick: j
3238
- })
3239
- ]),
3240
- ee.value.length === 0 ? (i(), v("div", _n, " No extra items added ")) : V("", !0),
3241
- (i(!0), v(Ce, null, Te(ee.value, (fe, ue) => {
3242
- var Ne, Ee;
3243
- return i(), v("div", { key: ue }, [
3244
- e("div", Sn, [
3245
- e("div", kn, [
3246
- T(Z, {
3247
- "model-value": fe.skuId,
3248
- "onUpdate:modelValue": (Le) => me(ue, Le),
3249
- label: "Ingredient",
3250
- items: L.value,
3251
- searchable: "",
3252
- searchTarget: "label",
3253
- placeholder: "Select ingredient",
3254
- disabled: !!fe.historyItem
3255
- }, null, 8, ["model-value", "onUpdate:modelValue", "items", "disabled"])
3256
- ]),
3257
- e("div", On, [
3258
- T(xe, {
3259
- label: "Receive Quantity",
3260
- modelValue: we.value[ue].value,
3261
- "onUpdate:modelValue": (Le) => we.value[ue].value = Le,
3262
- "append-text": fe.skuId ? ((Ee = (Ne = h(R).skuById[fe.skuId]) == null ? void 0 : Ne.unit) == null ? void 0 : Ee.abbrev) ?? "" : "",
3263
- "helper-text": ke(fe)
3264
- }, null, 8, ["modelValue", "onUpdate:modelValue", "append-text", "helper-text"]),
3265
- we.value[ue].value <= 0 ? (i(), v("div", xn, k(ss))) : V("", !0),
3266
- h(te) ? (i(), v("div", wn, [
3267
- T(W, {
3268
- "model-value": fe.costEnabled,
3269
- "onUpdate:modelValue": (Le) => l(ue),
3270
- size: "sm"
3271
- }, null, 8, ["model-value", "onUpdate:modelValue"]),
3272
- p[10] || (p[10] = e("span", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " Override cost ", -1))
3273
- ])) : V("", !0),
3274
- h(te) && fe.costEnabled ? (i(), he(xe, {
3275
- key: 2,
3276
- modelValue: o.value[ue].value,
3277
- "onUpdate:modelValue": (Le) => o.value[ue].value = Le,
3278
- label: "Total Cost",
3279
- step: 1e-4,
3280
- min: 0,
3281
- placeholder: "0.0000",
3282
- size: "sm",
3283
- "append-text": h(Ae)()
3284
- }, null, 8, ["modelValue", "onUpdate:modelValue", "append-text"])) : V("", !0)
3285
- ]),
3286
- fe.historyItem ? V("", !0) : (i(), he(S, {
3287
- key: 0,
3288
- variant: "tertiary",
3289
- "prepend-icon": "delete",
3290
- size: "md",
3291
- class: "mt-6",
3292
- onClick: (Le) => J(ue)
3293
- }, null, 8, ["onClick"]))
3294
- ]),
3295
- ue < ee.value.length - 1 ? (i(), v("div", $n)) : V("", !0)
3296
- ]);
3297
- }), 128))
3298
- ]),
3299
- e("div", Cn, [
3300
- p[11] || (p[11] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Delivery order no.", -1)),
3301
- e("div", An, [
3302
- T(be, {
3303
- modelValue: h(s).deliveryOrderNumber,
3304
- "onUpdate:modelValue": p[2] || (p[2] = (fe) => h(s).deliveryOrderNumber = fe),
3305
- size: "md"
3306
- }, null, 8, ["modelValue"])
3307
- ])
3308
- ]),
3309
- e("div", Dn, [
3310
- p[12] || (p[12] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Remark", -1)),
3311
- e("div", Rn, [
3312
- T(be, {
3313
- modelValue: h(s).remark,
3314
- "onUpdate:modelValue": p[3] || (p[3] = (fe) => h(s).remark = fe),
3315
- size: "md"
3316
- }, null, 8, ["modelValue"])
3317
- ])
3318
- ]),
3319
- h(f).enablePurchaseOrderPriceAdjustment ? (i(), he(Ft, {
3320
- key: 1,
3321
- controller: h(N),
3322
- state: h(F)
3323
- }, null, 8, ["controller", "state"])) : V("", !0)
3324
- ])
3325
- ];
3326
- }),
3327
- _: 1
3328
- }, 8, ["modelValue"]);
3329
- };
3330
- }
3331
- }), Pn = {
3332
- key: 0,
3333
- class: "flex flex-col gap-1"
3334
- }, Fn = { class: "truncate" }, In = { class: "shrink-0" }, Tn = /* @__PURE__ */ Ve({
3335
- __name: "PriceAdjustmentList",
3336
- props: {
3337
- adjustments: {}
3338
- },
3339
- setup(d) {
3340
- const t = d, r = H(() => t.adjustments ?? []);
3341
- function n(m) {
3342
- const u = m.amount < 0 ? "-" : "+", c = $e({ ...m, amount: Math.abs(m.amount) });
3343
- return `${u}${m.currency} ${c}`;
3344
- }
3345
- return (m, u) => r.value.length ? (i(), v("div", Pn, [
3346
- (i(!0), v(Ce, null, Te(r.value, (c) => (i(), v("div", {
3347
- key: c.id,
3348
- class: "flex justify-between gap-4 fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
3349
- }, [
3350
- e("span", Fn, k(c.name), 1),
3351
- e("span", In, k(n(c.dinero)), 1)
3352
- ]))), 128))
3353
- ])) : V("", !0);
3354
- }
3355
- }), En = { class: "flex flex-col gap-3" }, qn = /* @__PURE__ */ Ve({
3356
- __name: "PriceAdjustmentEditForm",
3357
- props: {
3358
- purchaseOrder: {}
3359
- },
3360
- emits: ["submitted"],
3361
- setup(d, { emit: t }) {
3362
- const r = d, n = t, m = Xe(), u = Ze(), c = ne(!1), s = ne(!1), { controller: a, state: O, reset: f } = It({
3363
- currency: Ae(),
3364
- adjustments: r.purchaseOrder.priceAdjustments
3365
- });
3366
- Ye(
3367
- () => c.value,
3368
- (N) => {
3369
- N && f(r.purchaseOrder.priceAdjustments);
3370
- }
3371
- );
3372
- function R() {
3373
- s.value = !0, m.updatePurchaseOrder({
3374
- ...r.purchaseOrder,
3375
- priceAdjustments: a.value.state().adjustments
3376
- }).then(() => {
3377
- u.open(
3378
- {
3379
- title: "Success",
3380
- message: `PO# ${r.purchaseOrder.seqNumber} price adjustments saved`,
3381
- type: "success"
3382
- },
3383
- 1e4
3384
- ), c.value = !1, n("submitted");
3385
- }).finally(() => {
3386
- s.value = !1;
3387
- });
3388
- }
3389
- return (N, F) => {
3390
- const _ = oe("FmButton"), B = oe("FmDialog");
3391
- return i(), he(B, {
3392
- modelValue: c.value,
3393
- "onUpdate:modelValue": F[0] || (F[0] = (E) => c.value = E),
3394
- overlay: !0,
3395
- "min-width": 600
3396
- }, {
3397
- "dialog-button": ce(() => [
3398
- T(_, {
3399
- variant: "plain",
3400
- label: "Edit price adjustments",
3401
- size: "md",
3402
- "prepend-icon": "edit"
3403
- })
3404
- ]),
3405
- "dialog-header": ce(() => [
3406
- e("div", null, "Price adjustments — PO# " + k(r.purchaseOrder.seqNumber), 1)
3407
- ]),
3408
- "dialog-footer": ce(() => [
3409
- T(_, {
3410
- class: "ml-auto",
3411
- label: "Apply changes",
3412
- size: "md",
3413
- variant: "destructive",
3414
- disabled: s.value,
3415
- loading: s.value,
3416
- onClick: R
3417
- }, null, 8, ["disabled", "loading"])
3418
- ]),
3419
- default: ce(() => [
3420
- e("div", En, [
3421
- T(Ft, {
3422
- controller: h(a),
3423
- state: h(O)
3424
- }, null, 8, ["controller", "state"])
3425
- ])
3426
- ]),
3427
- _: 1
3428
- }, 8, ["modelValue"]);
3429
- };
3430
- }
3431
- }), Vn = { class: "flex flex-row-reverse" }, Ln = {
3432
- key: 0,
3433
- class: "flex"
3434
- }, jn = {
3435
- key: 1,
3436
- class: "border-t pt-6"
3437
- }, Un = { class: "fm-typo-en-body-lg-600 mb-4 flex items-center gap-2" }, Mn = { class: "border border-fm-color-neutral-gray-200 fm-corner-radius-lg overflow-y-auto" }, Bn = { class: "w-full" }, zn = {
3438
- class: "p-3 fm-typo-en-body-sm-600",
3439
- style: { "min-width": "130px" }
3440
- }, Kn = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Hn = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Gn = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Wn = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Qn = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Yn = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Jn = { class: "p-3 fm-typo-en-body-sm-600" }, Zn = { key: 2 }, Xn = /* @__PURE__ */ Ve({
3441
- __name: "NetSuiteTransactionChangeLog",
3442
- props: {
3443
- netsuiteId: {}
3444
- },
3445
- setup(d) {
3446
- const t = d, r = Pt(), n = ne(!1), m = ne(!1), u = ne(!1), c = ne([]);
3447
- async function s() {
3448
- if (!(c.value.length > 0))
3449
- try {
3450
- m.value = !0;
3451
- const f = await r.getChangeLogs(t.netsuiteId);
3452
- c.value = f, u.value = !1;
3453
- } catch {
3454
- u.value = !0;
3455
- } finally {
3456
- m.value = !1;
3457
- }
3458
- }
3459
- function a(f) {
3460
- switch (f) {
3461
- case Me.Create:
3462
- return "text-green-600 bg-green-100";
3463
- case Me.Set:
3464
- return "text-blue-600 bg-blue-100";
3465
- case Me.Change:
3466
- return "text-yellow-600 bg-yellow-100";
3467
- case Me.Unset:
3468
- return "text-red-600 bg-red-100";
3469
- default:
3470
- return "text-gray-600 bg-gray-100";
3471
- }
3472
- }
3473
- function O(f) {
3474
- return new Date(f).toLocaleDateString("en-US", {
3475
- year: "numeric",
3476
- month: "short",
3477
- day: "numeric",
3478
- hour: "2-digit",
3479
- minute: "2-digit"
3480
- });
3481
- }
3482
- return (f, R) => {
3483
- const N = oe("FmButton"), F = oe("FmCircularProgress"), _ = oe("FmIcon"), B = oe("FmDialog");
3484
- return i(), v("div", Vn, [
3485
- T(B, {
3486
- modelValue: n.value,
3487
- "onUpdate:modelValue": R[2] || (R[2] = (E) => n.value = E),
3488
- overlay: !0,
3489
- "max-width": 800
3490
- }, {
3491
- "dialog-button": ce(() => [
3492
- T(N, {
3493
- "prepend-icon": "info",
3494
- variant: "secondary",
3495
- label: "NetSuite",
3496
- onClick: R[0] || (R[0] = (E) => s()),
3497
- "text-color": "primary",
3498
- "bg-color": "transparent",
3499
- "border-color": "primary"
3500
- })
3501
- ]),
3502
- "dialog-header": ce(() => R[3] || (R[3] = [
3503
- e("div", null, "NetSuite info", -1)
3504
- ])),
3505
- default: ce(() => [
3506
- m.value ? (i(), v("div", Ln, [
3507
- R[4] || (R[4] = e("span", null, "Change Log Loading...", -1)),
3508
- T(F, { size: "md" })
3509
- ])) : V("", !0),
3510
- !m.value && c.value.length > 0 ? (i(), v("div", jn, [
3511
- e("h3", Un, [
3512
- T(_, {
3513
- name: "error",
3514
- color: "#ff9500",
3515
- size: "sm"
3516
- }),
3517
- R[5] || (R[5] = Ge(" Change Logs "))
3518
- ]),
3519
- e("div", Mn, [
3520
- e("table", Bn, [
3521
- R[6] || (R[6] = e("thead", { class: "bg-fm-color-neutral-gray-50" }, [
3522
- e("tr", { class: "border-b border-fm-color-neutral-gray-200" }, [
3523
- e("th", {
3524
- class: "text-left p-3 fm-typo-en-body-md-600",
3525
- style: { "min-width": "130px" }
3526
- }, " Date "),
3527
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Role"),
3528
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Name"),
3529
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Context"),
3530
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Type"),
3531
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Line ID"),
3532
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Field"),
3533
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Old Value"),
3534
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "New Value")
3535
- ])
3536
- ], -1)),
3537
- e("tbody", null, [
3538
- (i(!0), v(Ce, null, Te(c.value, (E, te) => (i(), v("tr", {
3539
- key: te,
3540
- class: "border-b border-fm-color-neutral-gray-200 last:border-b-0"
3541
- }, [
3542
- e("td", zn, k(O(E._dateiso8601)), 1),
3543
- e("td", Kn, k(E._rolename), 1),
3544
- e("td", Hn, k(E._employeename), 1),
3545
- e("td", Gn, k(E._contextname), 1),
3546
- e("td", {
3547
- class: We(`p-3 fm-typo-en-body-sm-600 ${a(Number(E.type) - 1)}`)
3548
- }, k(h(Me)[Number(E.type) - 1]), 3),
3549
- e("td", Wn, k(E.lineid || ""), 1),
3550
- e("td", Qn, k(E._fieldname), 1),
3551
- e("td", Yn, k(E.oldvalue || ""), 1),
3552
- e("td", Jn, k(E.newvalue || ""), 1)
3553
- ]))), 128))
3554
- ])
3555
- ])
3556
- ])
3557
- ])) : (i(), v("div", Zn, R[7] || (R[7] = [
3558
- e("p", null, "No change logs available.", -1)
3559
- ])))
3560
- ]),
3561
- "dialog-footer": ce(() => [
3562
- T(N, {
3563
- class: "ml-auto sm:w-full xs:w-full",
3564
- label: "Close",
3565
- size: "md",
3566
- variant: "primary",
3567
- onClick: R[1] || (R[1] = (E) => n.value = !1)
3568
- })
3569
- ]),
3570
- _: 1
3571
- }, 8, ["modelValue"])
3572
- ]);
3573
- };
3574
- }
3575
- }), ea = { class: "flex flex-col w-full gap-3" }, ta = { class: "flex" }, sa = { class: "fm-typo-en-title-md-600 text-fm-color-typo-primary" }, ra = { class: "flex flex-col gap-16 w-full h-full" }, oa = { class: "flex justify-between" }, na = { class: "fm-typo-en-body-lg-600" }, aa = { class: "flex gap-2" }, la = {
3576
- key: 0,
3577
- class: "flex items-center gap-1"
3578
- }, ia = { class: "fm-typo-en-body-md-400" }, ua = { class: "flex flex-col gap-8" }, ca = {
3579
- key: 0,
3580
- class: "flex items-start justify-between gap-6"
3581
- }, da = { class: "text-xs font-mono text-right break-all" }, ma = {
3582
- key: 1,
3583
- class: "flex items-start justify-between gap-6"
3584
- }, pa = { class: "fm-typo-en-body-sm-600" }, fa = {
3585
- key: 2,
3586
- class: "flex items-start justify-between gap-6"
3587
- }, va = { class: "text-xs font-mono text-right break-all" }, ya = {
3588
- key: 3,
3589
- class: "flex items-start justify-between gap-6"
3590
- }, ha = { class: "text-xs font-mono text-right break-all" }, ba = { class: "flex flex-col gap-4" }, ga = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, _a = { class: "flex gap-1" }, Sa = { class: "fm-typo-en-body-lg-600" }, ka = {
3591
- key: 0,
3592
- class: "flex flex-col gap-4"
3593
- }, Oa = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, xa = { class: "fm-typo-en-body-lg-600" }, wa = { class: "flex flex-col gap-4" }, $a = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Ca = { class: "fm-typo-en-body-lg-600" }, Aa = {
3594
- key: 1,
3595
- class: "flex flex-col gap-4"
3596
- }, Da = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Ra = { class: "fm-typo-en-body-lg-600" }, Na = {
3597
- key: 2,
3598
- class: "flex flex-col gap-4"
3599
- }, Pa = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Fa = { class: "fm-typo-en-body-lg-600" }, Ia = {
3600
- key: 3,
3601
- class: "flex flex-col gap-4"
3602
- }, Ta = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Ea = { class: "fm-typo-en-body-lg-600" }, qa = {
3603
- key: 4,
3604
- class: "flex flex-col gap-4"
3605
- }, Va = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, La = { class: "fm-typo-en-body-lg-600" }, ja = {
3606
- key: 5,
3607
- class: "flex flex-col gap-4"
3608
- }, Ua = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Ma = { class: "fm-typo-en-body-lg-600" }, Ba = { class: "border border-fm-color-neutral-gray-200 fm-corner-radius-lg p-16" }, za = { class: "flex flex-col gap-8" }, Ka = { class: "flex gap-8 items-center" }, Ha = { class: "flex-1 fm-typo-en-body-lg-600" }, Ga = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary flex flex-col gap-4" }, Wa = { class: "flex w-full gap-4" }, Qa = { class: "basis-1/2 shrink-0 grow fm-typo-en-body-lg-400 line-clamp-2 flex items-center gap-2" }, Ya = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary flex flex-col gap-2" }, Ja = { class: "fm-typo-en-body-lg-400 line-clamp-2" }, Za = ["innerHTML"], Xa = { class: "flex w-full gap-4 fm-typo-en-body-sm-400" }, el = { class: "grow fm-typo-en-body-lg-400 text-fm-color-typo-secondary line-clamp-1" }, tl = {
3609
- key: 0,
3610
- class: "flex items-center gap-4"
3611
- }, sl = { class: "line-clamp-1 fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, rl = {
3612
- key: 0,
3613
- class: "inline-flex items-center gap-1 text-xs font-medium text-gray-500 bg-gray-100 px-2 py-0.5 rounded-full"
3614
- }, ol = { class: "py-8" }, nl = { class: "flex justify-end gap-4 items-center" }, al = { class: "fm-typo-en-body-lg-600" }, ll = {
3615
- key: 0,
3616
- class: "flex justify-end"
3617
- }, il = {
3618
- key: 1,
3619
- class: "flex-1 xs:w-screen xs:max-w-full"
3620
- }, ul = {
3621
- key: 0,
3622
- class: "flex flex-col items-center gap-8 h-full"
3623
- }, cl = ["src"], dl = { class: "fm-typo-en-body-lg-600" }, ml = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary px-16" }, pl = {
3624
- key: 1,
3625
- class: "px-4 flex flex-col"
3626
- }, fl = { class: "flex gap-12 content-stretch" }, vl = {
3627
- class: "flex flex-col w-40",
3628
- name: "circles"
3629
- }, yl = { class: "flex-1 flex flex-col items-center" }, hl = { class: "h-40 w-40 bg-fm-color-primary rounded-full flex items-center justify-center" }, bl = { class: "flex-1 flex flex-col items-center" }, gl = { class: "flex w-full items-center gap-4" }, _l = {
3630
- class: "py-12 flex flex-col gap-4",
3631
- name: "received-at header"
3632
- }, Sl = { class: "fm-typo-en-body-lg-400" }, kl = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, Ol = { class: "ml-auto flex gap-1" }, xl = { class: "flex gap-12 content-stretch" }, wl = {
3633
- class: "flex flex-col w-40",
3634
- name: "circles"
3635
- }, $l = { class: "flex-1 flex flex-col items-center" }, Cl = {
3636
- class: "py-12 flex flex-col gap-4 flex-1",
3637
- name: "delivery details"
3638
- }, Al = { class: "flex flex-col gap-8" }, Dl = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, Rl = { class: "flex flex-col gap-4" }, Nl = {
3639
- key: 2,
3640
- class: "flex-1 xs:w-screen xs:max-w-full"
3641
- }, Pl = {
3642
- key: 0,
3643
- class: "flex flex-col items-center gap-8 h-full"
3644
- }, Fl = ["src"], Il = { class: "fm-typo-en-body-lg-600" }, Tl = {
3645
- key: 1,
3646
- class: "px-4 flex flex-col gap-12"
3647
- }, El = { class: "flex flex-col gap-4" }, ql = { class: "flex justify-between gap-8" }, Vl = { class: "fm-typo-en-body-lg-600" }, Ll = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary whitespace-nowrap" }, jl = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Ul = {
3648
- key: 0,
3649
- class: "fm-typo-en-body-md-400"
3650
- }, Ml = { class: "flex gap-8 xs:flex-col" }, gi = /* @__PURE__ */ Ve({
3651
- __name: "TransferDetails",
3652
- props: {
3653
- poRequest: {},
3654
- purchaseOrder: {},
3655
- transferTo: {},
3656
- transferToDbName: {},
3657
- show: { type: Boolean },
3658
- canResubmit: { type: Boolean },
3659
- canApprove: { type: Boolean },
3660
- scope: {},
3661
- receivedMap: {},
3662
- shipments: {}
3663
- },
3664
- emits: ["update:show", "submitted"],
3665
- setup(d, { emit: t }) {
3666
- const r = d, n = t, m = gt(), u = Ze(), c = Je(), s = ze(), a = bt(), { hasOrderDraftPermission: O } = gs(), f = hs();
3667
- function R(o) {
3668
- const l = o.isCustomCost, $ = o.totalCost;
3669
- return l != null ? l === !0 : $ != null;
3670
- }
3671
- Ye(
3672
- () => r.purchaseOrder,
3673
- (o) => {
3674
- f.init(o);
3675
- },
3676
- { immediate: !0 }
3677
- );
3678
- const N = H(
3679
- () => {
3680
- var o, l;
3681
- return {
3682
- id: ((o = a.sessionUser.value) == null ? void 0 : o.id) ?? "",
3683
- name: ((l = a.sessionUser.value) == null ? void 0 : l.displayName) ?? ""
3684
- };
3685
- }
3686
- ), F = bs(), { t: _ } = ht(), B = H(
3687
- () => {
3688
- var o, l, $, C;
3689
- return ((l = (o = r.purchaseOrder) == null ? void 0 : o.supplier) == null ? void 0 : l.internal) === "restaurant" || ((C = ($ = r.purchaseOrder) == null ? void 0 : $.supplier) == null ? void 0 : C.internal) === "warehouse" ? at.enum.transfer : at.enum.purchase;
3690
- }
3691
- ), E = H(() => {
3692
- var $;
3693
- const o = ($ = r.shipments) == null ? void 0 : $.find((C) => {
3694
- var q;
3695
- return C.ref === ((q = r.purchaseOrder) == null ? void 0 : q._id);
3696
- });
3697
- let l = null;
3698
- if (o != null && o.milestones && o.milestones.length > 0) {
3699
- const C = o.milestones[o.milestones.length - 1];
3700
- if (C.estimatedTime) {
3701
- const q = new Date(C.estimatedTime), Y = q.getDate().toString().padStart(2, "0");
3702
- l = `${q.toLocaleString("en-US", { month: "short" })} ${Y}`;
3703
- }
3704
- }
3705
- return l;
3706
- }), te = ne(!1), se = ne(""), Q = ne(!0), de = Xe(), Oe = Ys(de.getWorkflowConfig), ae = fs(), Se = [
3707
- z.enum.receiveStock,
3708
- z.enum.processRequest,
3709
- z.enum.closeRequest
3710
- ], De = H(() => {
3711
- var pe, y, p, S, U, M, _e, xe, W;
3712
- if (!r.purchaseOrder)
3713
- return [];
3714
- const o = Oe.result.value;
3715
- if (o.state === Jt.loading)
3716
- return [];
3717
- let l;
3718
- const $ = ns.safeParse(r.purchaseOrder);
3719
- if ($.success)
3720
- l = $.data;
3721
- else {
3722
- const Z = /* @__PURE__ */ new Set(["1", "2"]), be = { line1: "", state: "", city: "", postcode: "", country: "" };
3723
- l = {
3724
- _id: ((pe = r.purchaseOrder) == null ? void 0 : pe._id) ?? "",
3725
- status: ((y = r.purchaseOrder) == null ? void 0 : y.status) ?? ge.enum.DRAFT,
3726
- version: Z.has((p = r.purchaseOrder) == null ? void 0 : p.version) ? (S = r.purchaseOrder) == null ? void 0 : S.version : null,
3727
- seqNumber: typeof ((U = r.purchaseOrder) == null ? void 0 : U.seqNumber) == "number" ? r.purchaseOrder.seqNumber : 0,
3728
- supplier: {
3729
- _id: ((_e = (M = r.purchaseOrder) == null ? void 0 : M.supplier) == null ? void 0 : _e._id) ?? "",
3730
- name: ((W = (xe = r.purchaseOrder) == null ? void 0 : xe.supplier) == null ? void 0 : W.name) ?? "",
3731
- address: be
3732
- },
3733
- items: [],
3734
- deliveryOrder: []
3735
- };
3736
- }
3737
- const C = {
3738
- user: N.value,
3739
- executedAt: s.locations.computeFirst(
3740
- (Z) => {
3741
- var be;
3742
- return Z.dbName === ((be = s._currentLocation) == null ? void 0 : be.dbName) ? Z : null;
3743
- }
3744
- ),
3745
- // Strip purchaseOrder and netSuite from the POR before passing to the Dart
3746
- // bridge — both can carry legacy PO snapshots with "" fields that fail the
3747
- // bridge's unguarded `as Map<String,dynamic>` casts. Also validate the POR
3748
- // itself through Zod first: legacy PORs can have null required string fields
3749
- // (e.g. purchaseOrderId, from.dbName) that cause Dart's _asString to throw.
3750
- // The workflow engine only needs from/to/processedAt/rejectedAt — passing
3751
- // null for an unvalidatable POR yields the same available actions.
3752
- purchaseOrderRequest: (() => {
3753
- if (r.poRequest == null) return r.poRequest;
3754
- const Z = Es.safeParse(r.poRequest);
3755
- return Z.success ? { ...Z.data, purchaseOrder: null, netSuite: null } : null;
3756
- })(),
3757
- purchaseOrder: l
3758
- }, q = c.useOperatePurchaseOrderV2, Y = c.poWorkflowAllowToMarkCompleted, ye = [...Se];
3759
- q && !Y && ye.push(z.enum.completeReceive);
3760
- let I = [];
3761
- try {
3762
- o.state === Jt.error ? (console.error("Error fetching workflow config:", o.error), I = St.getAvailableActions({
3763
- ...C,
3764
- orderConfig: St.getDefaultConfig()
3765
- }).actions.filter((Z) => !ye.includes(Z))) : I = St.getAvailableActions({
3766
- ...C,
3767
- orderConfig: o.data
3768
- }).actions.filter((Z) => !ye.includes(Z));
3769
- } catch (Z) {
3770
- console.error("Error getting available actions:", Z);
3771
- }
3772
- return r.scope === "approval" && (I = I.filter((Z) => Z !== z.enum.completeReceive)), O.value || (I = I.filter(
3773
- (Z) => Z !== z.enum.approveDraft && Z !== z.enum.rejectDraft
3774
- )), I;
3775
- }), K = Bs(r, "show"), ve = H(() => [
3776
- {
3777
- label: _("inventory.transfer.receiveRequest.details.overview"),
3778
- value: "overview"
3779
- },
3780
- {
3781
- label: _("inventory.transfer.receiveRequest.details.deliveryHistory"),
3782
- value: "deliveryHistory"
3783
- },
3784
- {
3785
- label: _("inventory.transfer.receiveRequest.details.actionLogs"),
3786
- value: "actionLogs"
3787
- }
3788
- ]), P = ne(ve.value[0]);
3789
- Ye(
3790
- () => r.show,
3791
- (o) => {
3792
- o && (P.value = ve.value[0]);
3793
- }
3794
- );
3795
- function x(o) {
3796
- return o.map((l) => ({
3797
- ...l,
3798
- amount: {
3799
- ...l.amount,
3800
- amount: -Math.abs(l.amount.amount)
3801
- }
3802
- }));
3803
- }
3804
- async function w(o, l, $, C, q) {
3805
- return new Promise((Y, ye) => {
3806
- const I = {
3807
- closeButton: !1,
3808
- title: C.title,
3809
- message: C.message,
3810
- primaryActions: C.primaryActions,
3811
- secondaryActions: { text: "No", close: !1 }
3812
- };
3813
- let pe = l.rejectReason ?? "";
3814
- $ === z.enum.rejectDraft && (I.contentComponent = ps, I.contentComponentProps = {
3815
- message: C.message,
3816
- onChange: (y) => {
3817
- pe = y ?? "";
3818
- }
3819
- }), m.open(I).onPrimary(async () => {
3820
- var p, S, U, M;
3821
- const y = [];
3822
- $ === z.enum.confirmDraft || $ === z.enum.submitRequest ? y.push({
3823
- action: "confirmDraft",
3824
- payload: f.controller.value.toConfirmDraftData(Ae())
3825
- }) : $ === z.enum.approveRequest ? (y.push({
3826
- action: "approveRequest",
3827
- payload: null
3828
- }), l.fulfillment && y.push({
3829
- action: "processRequest",
3830
- payload: {
3831
- fulfillmentId: "",
3832
- deliveryOrderNumber: "",
3833
- deliveryRemark: null,
3834
- items: x(l.fulfillment.items),
3835
- createdBy: N.value
3836
- }
3837
- })) : $ === z.enum.processRequest ? l.fulfillment && y.push({
3838
- action: "processRequest",
3839
- payload: {
3840
- fulfillmentId: "",
3841
- deliveryOrderNumber: "",
3842
- deliveryRemark: null,
3843
- items: x(l.fulfillment.items),
3844
- createdBy: N.value
3845
- }
3846
- }) : $ === z.enum.rejectRequest ? y.push({
3847
- action: "rejectRequest",
3848
- payload: null
3849
- }) : $ === z.enum.closeRequest ? y.push({
3850
- action: "closeRequest",
3851
- payload: null
3852
- }) : $ === z.enum.rejectDraft && y.push({
3853
- action: "rejectDraft",
3854
- payload: {
3855
- rejectReason: pe ?? ""
3856
- }
3857
- });
3858
- try {
3859
- await ae({
3860
- operate: {
3861
- operation: $,
3862
- doc: o,
3863
- options: l
3864
- },
3865
- operateV2: {
3866
- _id: ((p = r.purchaseOrder) == null ? void 0 : p._id) ?? "",
3867
- _rev: ((S = r.purchaseOrder) == null ? void 0 : S._rev) ?? "",
3868
- action: $ === z.enum.submitRequest ? z.enum.confirmDraft : $,
3869
- payloads: y
3870
- // add payload if action is receiveStock or processRequest
3871
- },
3872
- transferTo: (M = (U = r.poRequest) == null ? void 0 : U.to) == null ? void 0 : M.dbName
3873
- }).delayed(1e3), Y("submitted");
3874
- } catch (_e) {
3875
- ye(_e);
3876
- }
3877
- }).onSecondary(() => {
3878
- Y("cancelled");
3879
- for (let y = 0; y < q + 2; y++)
3880
- m.close();
3881
- }).onClose(() => {
3882
- });
3883
- });
3884
- }
3885
- async function A(o) {
3886
- var q, Y, ye, I;
3887
- if (o === z.enum.receiveStock)
3888
- return;
3889
- const l = ms[o];
3890
- if (!l) {
3891
- u.open({
3892
- title: "Something went wrong",
3893
- message: `Cannot process order: ${Rt(o)}`,
3894
- type: "error"
3895
- });
3896
- return;
3897
- }
3898
- const { successMessage: $, ...C } = l;
3899
- if (r.purchaseOrder) {
3900
- se.value = `${o}`, te.value = !0, Q.value = !1;
3901
- const pe = {};
3902
- let y = 0;
3903
- if ((o === z.enum.confirmDraft || // auto receive for warehouse to warehouse
3904
- o === z.enum.completeReceive) && c.autoReceiveWarehouse)
3905
- pe.autoReceive = !0;
3906
- else if ((o === z.enum.approveRequest || o === z.enum.processRequest) && c.acceptRequireFulfillment) {
3907
- const p = (Y = (q = r.poRequest) == null ? void 0 : q.from) == null ? void 0 : Y.dbName, S = (I = (ye = r.poRequest) == null ? void 0 : ye.to) == null ? void 0 : I.dbName;
3908
- if (p && S && (p.startsWith("warehouse_") || S.startsWith("warehouse_"))) {
3909
- const U = await new Promise((M, _e) => {
3910
- m.open({
3911
- closeButton: !1,
3912
- title: "Confirm transfer amount",
3913
- dialogComponent: xr,
3914
- dialogComponentProps: {
3915
- purchaseOrder: r.purchaseOrder,
3916
- confirm: M,
3917
- "onUpdate:show": (xe) => {
3918
- xe || (se.value = "", te.value = !1, Q.value = !0, y++, m.close()), _e("cancelled");
3919
- }
3920
- }
3921
- });
3922
- });
3923
- pe.fulfillment = U;
3924
- }
3925
- }
3926
- try {
3927
- await w(
3928
- r.purchaseOrder,
3929
- pe,
3930
- o,
3931
- l,
3932
- y
3933
- ) === "submitted" && (u.open({
3934
- title: "Success",
3935
- message: $,
3936
- type: "success"
3937
- }), n("update:show", !1), n("submitted"));
3938
- } catch (p) {
3939
- u.open({
3940
- title: "Something went wrong",
3941
- message: p instanceof Error ? p.message : "Please try again.",
3942
- type: "error"
3943
- }), console.error("Error when submitting PO operation", o, r.purchaseOrder, p);
3944
- } finally {
3945
- se.value = "", te.value = !1, Q.value = !0;
3946
- }
3947
- }
3948
- }
3949
- const G = H(() => {
3950
- var o, l;
3951
- return ((o = r.purchaseOrder) == null ? void 0 : o.status) === ge.enum.RECEIVING || ((l = r.purchaseOrder) == null ? void 0 : l.status) === ge.enum.COMPLETE;
3952
- }), X = H(() => r.purchaseOrder ? vt(r.purchaseOrder) : {}), le = H(() => {
3953
- const o = r.purchaseOrder;
3954
- if (!o) return { status: "", statusClass: "" };
3955
- const { partial: l, over: $ } = $t(X.value), C = Ct(o.status, l, $);
3956
- let q = _(`inventory.transfer.status.${C}`), Y = `${o.status}`.toLocaleLowerCase("en-us");
3957
- return C === ge.enum.CLOSE && (q = `${_(`inventory.transfer.status.${ge.enum.COMPLETE}`)}`), C === "PARTIAL_RECEIVED" && Y === ge.enum.PROCESSING.toLocaleLowerCase("en-us") && (Y = ge.enum.RECEIVING.toLocaleLowerCase("en-us")), {
3958
- status: q,
3959
- statusClass: `fm-status-badge fm-status-badge-${Y}`
3960
- };
3961
- }), b = H(() => {
3962
- var Y, ye;
3963
- const o = ((Y = r.purchaseOrder) == null ? void 0 : Y.deliveryOrder) ?? [], l = ((ye = r.purchaseOrder) == null ? void 0 : ye.deliveryFullfillment) ?? [], $ = [
3964
- ...o.map((I) => ({
3965
- createdAt: I.createdAt,
3966
- type: "grn",
3967
- doc: I
3968
- })),
3969
- ...l.map((I) => ({
3970
- createdAt: I.createdAt,
3971
- type: "fulfillment",
3972
- doc: I
3973
- }))
3974
- ];
3975
- $.reverse().sort((I, pe) => I.createdAt.localeCompare(pe.createdAt));
3976
- function C(I) {
3977
- var p, S, U, M, _e, xe, W, Z, be, Fe, Ie, fe;
3978
- const pe = l.findIndex((ue) => ue.id === I.fullfillmentId), y = [
3979
- (S = (p = l[pe]) == null ? void 0 : p.netSuite) != null && S.id ? {
3980
- label: "Fulfillment's ref no. (Netsuite)",
3981
- values: [
3982
- `${((M = (U = l[pe]) == null ? void 0 : U.netSuite) == null ? void 0 : M.refNo) ?? "N/A"} (${((xe = (_e = l[pe]) == null ? void 0 : _e.netSuite) == null ? void 0 : xe.id) ?? "-"})`
3983
- ]
3984
- } : null,
3985
- (W = I == null ? void 0 : I.netSuite) != null && W.id ? {
3986
- label: "Netsuite ref no.",
3987
- values: [`${((Z = I == null ? void 0 : I.netSuite) == null ? void 0 : Z.refNo) ?? "N/A"} (${((be = I == null ? void 0 : I.netSuite) == null ? void 0 : be.id) ?? "-"})`]
3988
- } : null,
3989
- (Fe = I == null ? void 0 : I.netSuite) != null && Fe.recordType ? {
3990
- label: "Netsuite Type",
3991
- values: [as((Ie = I == null ? void 0 : I.netSuite) == null ? void 0 : Ie.recordType)]
3992
- } : null
3993
- ];
3994
- return {
3995
- header: "Received",
3996
- deliveryOrder: I,
3997
- date: et(new Date(I.createdAt)),
3998
- info: [
3999
- {
4000
- label: "Adjustment date",
4001
- values: [
4002
- I.adjustment ? et(new Date(mt(I.adjustment))) : "-"
4003
- ]
4004
- },
4005
- {
4006
- label: "Received by",
4007
- values: [(fe = I.createdBy) == null ? void 0 : fe.name]
4008
- },
4009
- {
4010
- label: "Received items",
4011
- values: I.received.map((ue) => {
4012
- var Ne;
4013
- return re("div", [
4014
- re(
4015
- "div",
4016
- {
4017
- class: "flex gap-4"
4018
- },
4019
- [
4020
- re(
4021
- "div",
4022
- {
4023
- class: "flex flex-col"
4024
- },
4025
- [
4026
- re(
4027
- "span",
4028
- {
4029
- class: "fm-typo-en-body-lg-800 basis-1/2 shrink-0 grow"
4030
- },
4031
- `${ue.sku.name}`
4032
- ),
4033
- re(
4034
- "span",
4035
- {
4036
- class: "fm-typo-en-body-md-400"
4037
- },
4038
- `${ue.sku.code} `
4039
- )
4040
- ]
4041
- ),
4042
- re(
4043
- "div",
4044
- {
4045
- class: "ml-auto flex flex-col"
4046
- },
4047
- [
4048
- re(
4049
- "div",
4050
- {
4051
- class: "ml-auto flex gap-1"
4052
- },
4053
- [
4054
- re(
4055
- "span",
4056
- {
4057
- class: "fm-typo-en-body-lg-600 self-end"
4058
- },
4059
- $e(ue.amount, !1)
4060
- ),
4061
- re(
4062
- "span",
4063
- {
4064
- class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary"
4065
- },
4066
- ((Ne = ue.measurement) == null ? void 0 : Ne.abbrev) ?? ue.sku.unit.abbrev
4067
- )
4068
- ]
4069
- ),
4070
- re(
4071
- "div",
4072
- {
4073
- class: "flex self-end fm-typo-en-body-md-400 text-fm-color-typo-secondary"
4074
- },
4075
- `${ue.cost ? `(${ut(ue.cost)})` : ""}`
4076
- )
4077
- ]
4078
- )
4079
- ]
4080
- )
4081
- ]);
4082
- })
4083
- },
4084
- {
4085
- label: "Delivery order no.",
4086
- values: [I.deliveryOrderNumber || "N/A"]
4087
- },
4088
- {
4089
- label: "Remark",
4090
- values: [I.remark || "N/A"]
4091
- },
4092
- pe > -1 ? {
4093
- label: "Fulfilment's sequence",
4094
- values: [`${pe + 1}`]
4095
- } : null,
4096
- ...y
4097
- ].filter((ue) => !!ue)
4098
- };
4099
- }
4100
- function q(I) {
4101
- var y, p, S;
4102
- const pe = l.findIndex((U) => U.id === I.id);
4103
- return {
4104
- header: "Fulfillment",
4105
- date: et(new Date(I.createdAt)),
4106
- info: [
4107
- {
4108
- label: "Sequence",
4109
- values: [String(pe + 1)]
4110
- },
4111
- {
4112
- label: "Receiveable items",
4113
- values: I.items.map((U) => {
4114
- var M;
4115
- return re("div", [
4116
- re(
4117
- "div",
4118
- {
4119
- class: "flex gap-4"
4120
- },
4121
- [
4122
- re(
4123
- "div",
4124
- {
4125
- class: "flex flex-col"
4126
- },
4127
- [
4128
- re(
4129
- "span",
4130
- {
4131
- class: "fm-typo-en-body-lg-800 basis-1/2 shrink-0 grow"
4132
- },
4133
- `${U.sku.name}`
4134
- ),
4135
- re(
4136
- "span",
4137
- {
4138
- class: "fm-typo-en-body-md-400"
4139
- },
4140
- `${U.sku.code} `
4141
- )
4142
- ]
4143
- ),
4144
- re(
4145
- "div",
4146
- {
4147
- class: "ml-auto flex flex-col"
4148
- },
4149
- [
4150
- re(
4151
- "div",
4152
- {
4153
- class: "ml-auto flex gap-1"
4154
- },
4155
- [
4156
- re(
4157
- "span",
4158
- {
4159
- class: "fm-typo-en-body-lg-600 self-end"
4160
- },
4161
- $e(U.amount, !1)
4162
- ),
4163
- re(
4164
- "span",
4165
- {
4166
- class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary"
4167
- },
4168
- ((M = U.measurement) == null ? void 0 : M.abbrev) ?? U.sku.unit.abbrev
4169
- )
4170
- ]
4171
- ),
4172
- re(
4173
- "div",
4174
- {
4175
- class: "flex self-end fm-typo-en-body-md-400 text-fm-color-typo-secondary"
4176
- },
4177
- `${U.cost ? `(${ut(U.cost)})` : ""}`
4178
- )
4179
- ]
4180
- )
4181
- ]
4182
- )
4183
- ]);
4184
- })
4185
- },
4186
- (y = I.netSuite) != null && y.refNo ? {
4187
- label: "Netsuite Ref no. (ID)",
4188
- values: [`${(p = I.netSuite) == null ? void 0 : p.refNo} (${((S = I.netSuite) == null ? void 0 : S.id) ?? "-"})`]
4189
- } : null
4190
- ].filter((U) => !!U)
4191
- };
4192
- }
4193
- return $.map(
4194
- (I) => I.type === "grn" ? C(I.doc) : q(I.doc)
4195
- );
4196
- }), D = H(() => {
4197
- const o = r.purchaseOrder;
4198
- if (!o) return [];
4199
- if (!o.itemsAtSubmission) return o.items ?? [];
4200
- const l = new Set(o.itemsAtSubmission.map((C) => C.sku._id)), $ = [];
4201
- for (const C of o.items ?? [])
4202
- l.has(C.sku._id) || (l.add(C.sku._id), $.push(C));
4203
- return [...o.itemsAtSubmission, ...$];
4204
- }), ie = H(() => {
4205
- const o = r.purchaseOrder;
4206
- if (!o || o.version !== Ue.enum[2]) return r.receivedMap;
4207
- const l = {}, $ = {};
4208
- for (const q of o.items ?? [])
4209
- l[q.sku._id] || (l[q.sku._id] = []), $[q.sku._id] = q.sku.unit.precision, q.id && l[q.sku._id].push(q.id);
4210
- const C = {};
4211
- for (const [q, Y] of Object.entries(l)) {
4212
- const ye = Y.map((p) => r.receivedMap[p]).filter(Boolean);
4213
- if (ye.length === 0) continue;
4214
- const I = { amount: 0, precision: $[q] ?? 0 }, pe = ye.reduce((p, S) => Pe.add([p, S.total]), I), y = ye.reduce((p, S) => Pe.add([p, S.received]), I);
4215
- C[q] = {
4216
- key: q,
4217
- total: pe,
4218
- received: y,
4219
- remaining: Pe.subtract([pe, y])
4220
- };
4221
- }
4222
- return C;
4223
- });
4224
- function ee(o) {
4225
- const l = ie.value[o.sku._id], $ = g(o);
4226
- return l ? `<span class="${$} fm-typo-en-body-lg-600">${Pe.toFormatString({ value: l.received })}</span>/${ft(o.quantity, o.sku.unit, o.measurement)}` : `<span class="fm-typo-en-body-lg-600">-</span>/${ft(o.quantity, o.sku.unit, o.measurement)}`;
4227
- }
4228
- function L(o) {
4229
- const l = r.purchaseOrder;
4230
- return l != null && l.itemsAtSubmission ? !l.itemsAtSubmission.some(($) => $.sku._id === o.sku._id) : !1;
4231
- }
4232
- function g(o) {
4233
- const l = ie.value[o.sku._id];
4234
- if (!l)
4235
- return "text-fm-color-typo-tertiary";
4236
- const { isPartialReceive: $, isNoReceive: C, isOverReceive: q, isFullReceive: Y } = mr(l);
4237
- return C ? "text-fm-color-typo-tertiary" : $ ? "text-fm-color-system-warning-300" : q ? "text-fm-color-system-error-300" : Y ? "text-fm-color-system-success-300" : "";
4238
- }
4239
- const j = H(() => {
4240
- var o, l, $;
4241
- return (o = r.purchaseOrder) != null && o.itemsAtSubmission ? ((l = r.purchaseOrder) == null ? void 0 : l.version) === Ue.enum[2] ? r.purchaseOrder.items.reduce((C, q) => {
4242
- var ye, I;
4243
- const Y = (I = (ye = r.purchaseOrder) == null ? void 0 : ye.itemsAtSubmission) == null ? void 0 : I.find(
4244
- (pe) => pe.id === q.id
4245
- );
4246
- return Y && Y.quantity !== q.quantity && C.set(q.sku.code, {
4247
- originalAmount: Number(Pe.toFormatString({ value: Y.quantity })),
4248
- newAmount: Number(Pe.toFormatString({ value: q.quantity }))
4249
- }), C;
4250
- }, /* @__PURE__ */ new Map()) : ($ = r.purchaseOrder) == null ? void 0 : $.items.reduce((C, q) => {
4251
- var pe, y;
4252
- const Y = (y = (pe = r.purchaseOrder) == null ? void 0 : pe.itemsAtSubmission) == null ? void 0 : y.find(
4253
- (p) => p.sku._id === q.sku._id
4254
- ), ye = Y ? Number(Pe.toFormatString({ value: Y.quantity })) : 0, I = Number(Pe.toFormatString({ value: q.quantity }));
4255
- return Y && ye !== I && C.set(q.sku.code, {
4256
- originalAmount: ye,
4257
- newAmount: I
4258
- }), C;
4259
- }, /* @__PURE__ */ new Map()) : /* @__PURE__ */ new Map();
4260
- }), J = (o) => {
4261
- var $, C;
4262
- const l = j.value;
4263
- return (($ = r.purchaseOrder) == null ? void 0 : $.version) === Ue.enum[2] ? l.has(o.id) : l.has((C = o.sku) == null ? void 0 : C.code);
4264
- }, me = (o) => {
4265
- var $, C;
4266
- const l = j.value;
4267
- return (($ = r.purchaseOrder) == null ? void 0 : $.version) === Ue.enum[2] ? l.get(o.id) : l.get((C = o.sku) == null ? void 0 : C.code);
4268
- }, ke = H(() => {
4269
- const o = r.purchaseOrder;
4270
- if (!o) return "";
4271
- const l = o.actionChangelogs ?? [], $ = l.length ? l[l.length - 1] : null;
4272
- if ($ && $.action === "rejectDraft") {
4273
- const C = $.remarks ?? "";
4274
- return C && C.toString().trim() !== "" ? C.toString() : "-";
4275
- }
4276
- return "";
4277
- }), we = H(() => {
4278
- const o = r.purchaseOrder;
4279
- return o ? [...o.actionChangelogs ?? []].reverse() : [];
4280
- });
4281
- return (o, l) => {
4282
- const $ = oe("FmButton"), C = oe("FmButtonGroup"), q = oe("FmChip"), Y = oe("FmIcon"), ye = oe("FmMenuDivider"), I = oe("FmCard"), pe = oe("FmTooltip"), y = oe("FmSpacer"), p = oe("FmSideSheet");
4283
- return i(), he(p, {
4284
- modelValue: h(K),
4285
- "onUpdate:modelValue": l[9] || (l[9] = (S) => Rs(K) ? K.value = S : null),
4286
- "dismiss-away": Q.value,
4287
- "max-width": 600,
4288
- "close-button": !1
4289
- }, {
4290
- "side-sheet-header": ce(() => {
4291
- var S, U;
4292
- return [
4293
- e("div", ea, [
4294
- e("div", ta, [
4295
- e("div", sa, k(h(_)("inventory.transfer.receiveRequest.details.title") + ((S = o.purchaseOrder) != null && S.seqNumber ? ` #${(U = o.purchaseOrder) == null ? void 0 : U.seqNumber}` : "")), 1),
4296
- T($, {
4297
- class: "ml-auto -m-2",
4298
- variant: "tertiary",
4299
- "prepend-icon": "close",
4300
- onClick: l[0] || (l[0] = (M) => n("update:show", !1))
4301
- })
4302
- ]),
4303
- T(C, {
4304
- items: ve.value,
4305
- modelValue: P.value,
4306
- "onUpdate:modelValue": l[1] || (l[1] = (M) => P.value = M)
4307
- }, null, 8, ["items", "modelValue"]),
4308
- o.purchaseOrder && P.value.value === "deliveryHistory" ? (i(), he(Nn, {
4309
- key: 0,
4310
- "purchase-order": o.purchaseOrder,
4311
- "received-info-map": X.value,
4312
- "received-map": o.receivedMap,
4313
- onSubmitted: l[2] || (l[2] = () => {
4314
- n("update:show", !1), n("submitted");
4315
- })
4316
- }, null, 8, ["purchase-order", "received-info-map", "received-map"])) : V("", !0)
4317
- ])
4318
- ];
4319
- }),
4320
- default: ce(() => {
4321
- var S, U, M, _e, xe;
4322
- return [
4323
- e("div", ra, [
4324
- P.value.value === "overview" ? (i(), v(Ce, { key: 0 }, [
4325
- e("div", null, [
4326
- T(I, {
4327
- variant: "outlined",
4328
- class: "flex flex-col gap-8 px-12 py-16"
4329
- }, {
4330
- default: ce(() => {
4331
- var W, Z, be, Fe, Ie, fe, ue, Ne, Ee, Le;
4332
- return [
4333
- e("div", oa, [
4334
- e("div", na, k(h(_)("inventory.transfer.receiveRequest.details.requestSummary")), 1),
4335
- e("div", aa, [
4336
- T(q, {
4337
- label: le.value.status,
4338
- class: We(le.value.statusClass),
4339
- compact: ""
4340
- }, null, 8, ["label", "class"]),
4341
- E.value ? (i(), v("div", la, [
4342
- T(Y, {
4343
- name: "local_shipping",
4344
- color: "#666666"
4345
- }),
4346
- e("span", ia, k(E.value), 1)
4347
- ])) : V("", !0)
4348
- ])
4349
- ]),
4350
- T(ye),
4351
- e("div", ua, [
4352
- T(ts, { title: "Debug Info" }, {
4353
- default: ce(() => {
4354
- var it, Tt, Et, qt, Vt, Lt, jt, Ut, Mt, Bt, zt, Kt;
4355
- return [
4356
- (it = o.purchaseOrder) != null && it._id ? (i(), v("div", ca, [
4357
- l[10] || (l[10] = e("span", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " Purchase Order ID ", -1)),
4358
- e("span", da, k((Tt = o.purchaseOrder) == null ? void 0 : Tt._id), 1)
4359
- ])) : V("", !0),
4360
- (Et = o.purchaseOrder) != null && Et.status ? (i(), v("div", ma, [
4361
- l[11] || (l[11] = e("span", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " Purchase Order Status ", -1)),
4362
- e("span", pa, k((qt = o.purchaseOrder) == null ? void 0 : qt.status), 1)
4363
- ])) : V("", !0),
4364
- (Lt = (Vt = o.purchaseOrder) == null ? void 0 : Vt.supplier) != null && Lt._id ? (i(), v("div", fa, [
4365
- l[12] || (l[12] = e("span", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " Source Location ID ", -1)),
4366
- e("span", va, k(((Ut = (jt = o.purchaseOrder) == null ? void 0 : jt.supplier) == null ? void 0 : Ut.internal) != null ? `${(Bt = (Mt = o.purchaseOrder) == null ? void 0 : Mt.supplier) == null ? void 0 : Bt.internal}_` : "") + k((Kt = (zt = o.purchaseOrder) == null ? void 0 : zt.supplier) == null ? void 0 : Kt._id), 1)
4367
- ])) : V("", !0),
4368
- o.transferToDbName ? (i(), v("div", ya, [
4369
- l[13] || (l[13] = e("span", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " Destination Location ID ", -1)),
4370
- e("span", ha, k(o.transferToDbName), 1)
4371
- ])) : V("", !0)
4372
- ];
4373
- }),
4374
- _: 1
4375
- }),
4376
- e("div", ba, [
4377
- e("div", ga, [
4378
- e("div", _a, k(h(_)("inventory.transfer.receiveRequest.details.createdAt")), 1)
4379
- ]),
4380
- e("div", Sa, k(h(lt)(((W = o.purchaseOrder) == null ? void 0 : W._id) ?? "")), 1)
4381
- ]),
4382
- (Z = o.purchaseOrder) != null && Z.effectiveAt ? (i(), v("div", ka, [
4383
- e("div", Oa, k(h(_)("inventory.transfer.receiveRequest.details.date")), 1),
4384
- e("div", xa, k(h(Nt)(new Date((be = o.purchaseOrder) == null ? void 0 : be.effectiveAt))), 1)
4385
- ])) : V("", !0),
4386
- e("div", wa, [
4387
- e("div", $a, k(h(_)("inventory.transfer.receiveRequest.details.type.title")), 1),
4388
- e("div", Ca, k(h(_)(
4389
- `inventory.transfer.receiveRequest.details.type.${B.value.toLocaleLowerCase("en-US")}`
4390
- )), 1)
4391
- ]),
4392
- (Ie = (Fe = o.purchaseOrder) == null ? void 0 : Fe.supplier) != null && Ie.name ? (i(), v("div", Aa, [
4393
- e("div", Da, k(h(_)("inventory.transfer.receiveRequest.details.from")), 1),
4394
- e("div", Ra, k((ue = (fe = o.purchaseOrder) == null ? void 0 : fe.supplier) == null ? void 0 : ue.name), 1)
4395
- ])) : V("", !0),
4396
- o.transferTo ? (i(), v("div", Na, [
4397
- e("div", Pa, k(h(_)("inventory.transfer.receiveRequest.details.to")), 1),
4398
- e("div", Fa, k(o.transferTo), 1)
4399
- ])) : V("", !0),
4400
- (Ne = o.purchaseOrder) != null && Ne.ref ? (i(), v("div", Ia, [
4401
- e("div", Ta, k(h(_)("inventory.transfer.receiveRequest.details.reference")), 1),
4402
- e("div", Ea, k(o.purchaseOrder.ref), 1)
4403
- ])) : V("", !0),
4404
- (Ee = o.purchaseOrder) != null && Ee.remark ? (i(), v("div", qa, [
4405
- e("div", Va, k(h(_)("inventory.transfer.receiveRequest.details.remark")), 1),
4406
- e("div", La, k(o.purchaseOrder.remark), 1)
4407
- ])) : V("", !0),
4408
- ((Le = o.purchaseOrder) == null ? void 0 : Le.status) === h(ge).enum.DRAFT && ke.value ? (i(), v("div", ja, [
4409
- e("div", Ua, k(h(_)("inventory.transfer.receiveRequest.details.rejectionReason")), 1),
4410
- e("div", Ma, k(ke.value !== "" ? ke.value : "-"), 1)
4411
- ])) : V("", !0)
4412
- ])
4413
- ];
4414
- }),
4415
- _: 1
4416
- })
4417
- ]),
4418
- T(So, {
4419
- "po-request": o.poRequest,
4420
- purchaseOrder: o.purchaseOrder,
4421
- transferType: B.value,
4422
- transferToDbName: o.transferToDbName,
4423
- scope: o.scope
4424
- }, null, 8, ["po-request", "purchaseOrder", "transferType", "transferToDbName", "scope"]),
4425
- e("div", Ba, [
4426
- e("div", za, [
4427
- e("div", Ka, [
4428
- e("span", Ha, [
4429
- Ge(k(G.value ? h(_)("inventory.transfer.receiveRequest.details.receivedItems") : h(_)("inventory.transfer.receiveRequest.details.requestedItems")) + " ", 1),
4430
- (U = (S = o.purchaseOrder) == null ? void 0 : S.netSuite) != null && U.missingItems && ((_e = (M = o.purchaseOrder) == null ? void 0 : M.netSuite) == null ? void 0 : _e.missingItems.length) > 0 ? (i(), he(pe, {
4431
- key: 0,
4432
- variant: "rich",
4433
- placement: "top",
4434
- "z-index": 51
4435
- }, {
4436
- content: ce(() => {
4437
- var W, Z;
4438
- return [
4439
- e("div", Ga, [
4440
- (i(!0), v(Ce, null, Te((Z = (W = o.purchaseOrder) == null ? void 0 : W.netSuite) == null ? void 0 : Z.missingItems, (be, Fe) => (i(), v("div", {
4441
- class: "flex justify-center align-middle",
4442
- key: Fe
4443
- }, [
4444
- T(Y, {
4445
- name: "arrow_right",
4446
- size: "sm"
4447
- }),
4448
- Ge(" " + k(`(${be.netSuiteId}) ${be.name}: ${be.reason}`), 1)
4449
- ]))), 128))
4450
- ])
4451
- ];
4452
- }),
4453
- default: ce(() => [
4454
- T(Y, {
4455
- name: "error",
4456
- color: "#ff2c2c",
4457
- size: "sm"
4458
- })
4459
- ]),
4460
- _: 1
4461
- })) : V("", !0)
4462
- ])
4463
- ]),
4464
- T(ye),
4465
- (i(!0), v(Ce, null, Te(D.value, (W, Z) => {
4466
- var be, Fe;
4467
- return i(), v("div", {
4468
- key: Z,
4469
- class: "flex flex-col"
4470
- }, [
4471
- e("div", Wa, [
4472
- e("div", Qa, [
4473
- Ge(k(W.name) + " ", 1),
4474
- L(W) ? (i(), he(pe, {
4475
- key: 0,
4476
- variant: "rich",
4477
- placement: "top",
4478
- "z-index": 51
4479
- }, {
4480
- content: ce(() => l[14] || (l[14] = [
4481
- e("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " Extra item (added during delivery) ", -1)
4482
- ])),
4483
- default: ce(() => [
4484
- T(Y, {
4485
- name: "add_circle",
4486
- color: "#6b7280",
4487
- size: "sm"
4488
- })
4489
- ]),
4490
- _: 1
4491
- })) : V("", !0),
4492
- J(W) ? (i(), he(pe, {
4493
- key: 1,
4494
- variant: "rich",
4495
- placement: "top",
4496
- "z-index": 51
4497
- }, {
4498
- content: ce(() => {
4499
- var Ie, fe;
4500
- return [
4501
- e("div", Ya, [
4502
- l[15] || (l[15] = e("div", { class: "font-semibold" }, "Submission changes", -1)),
4503
- e("div", null, "Original Amount: " + k((Ie = me(W)) == null ? void 0 : Ie.originalAmount), 1),
4504
- e("div", null, " New Amount: " + k((fe = me(W)) == null ? void 0 : fe.newAmount), 1)
4505
- ])
4506
- ];
4507
- }),
4508
- default: ce(() => [
4509
- T(Y, {
4510
- name: "error",
4511
- color: "#ff9500",
4512
- size: "sm"
4513
- })
4514
- ]),
4515
- _: 2
4516
- }, 1024)) : V("", !0)
4517
- ]),
4518
- e("div", Ja, [
4519
- e("span", {
4520
- innerHTML: ee(W)
4521
- }, null, 8, Za)
4522
- ])
4523
- ]),
4524
- e("div", Xa, [
4525
- e("div", el, k(W.code), 1),
4526
- h(c).enableTotalCost && ((be = W.totalCost) != null && be.amount || typeof W.sku == "object" && W.sku != null) ? (i(), v("div", tl, [
4527
- e("span", sl, k(h(ut)(
4528
- (Fe = W.totalCost) != null && Fe.amount ? W.totalCost : h(f).controller.value.getItemCost(W, h(Ae)()).cost
4529
- )), 1),
4530
- R(W) ? V("", !0) : (i(), v("span", rl, [
4531
- l[16] || (l[16] = e("span", { class: "w-1.5 h-1.5 rounded-full bg-gray-400" }, null, -1)),
4532
- Ge(" " + k(h(_)("inventory.transfer.form.items.autoCalculated")), 1)
4533
- ]))
4534
- ])) : V("", !0)
4535
- ])
4536
- ]);
4537
- }), 128)),
4538
- +h($e)(h(f).controller.value.getTotalCosts()) ? (i(), v(Ce, { key: 0 }, [
4539
- e("div", ol, [
4540
- T(ye)
4541
- ]),
4542
- e("div", nl, [
4543
- l[17] || (l[17] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Total:", -1)),
4544
- e("div", al, k(h(Ae)()) + " " + k(h(ut)({
4545
- ...h(f).controller.value.getTotalCosts(),
4546
- currency: h(Ae)()
4547
- }).replace(/[^0-9.,]/g, "")), 1)
4548
- ])
4549
- ], 64)) : V("", !0),
4550
- h(c).enablePurchaseOrderPriceAdjustment ? (i(), v(Ce, { key: 1 }, [
4551
- T(Tn, {
4552
- adjustments: (xe = o.purchaseOrder) == null ? void 0 : xe.priceAdjustments
4553
- }, null, 8, ["adjustments"]),
4554
- o.purchaseOrder ? (i(), v("div", ll, [
4555
- T(qn, {
4556
- "purchase-order": o.purchaseOrder,
4557
- onSubmitted: l[3] || (l[3] = () => {
4558
- n("update:show", !1), n("submitted");
4559
- })
4560
- }, null, 8, ["purchase-order"])
4561
- ])) : V("", !0)
4562
- ], 64)) : V("", !0)
4563
- ])
4564
- ])
4565
- ], 64)) : P.value.value === "deliveryHistory" ? (i(), v("div", il, [
4566
- b.value.length ? (i(), v("div", pl, [
4567
- (i(!0), v(Ce, null, Te(b.value, (W, Z) => {
4568
- var be, Fe, Ie, fe, ue;
4569
- return i(), v(Ce, { key: Z }, [
4570
- e("div", fl, [
4571
- e("div", vl, [
4572
- e("div", yl, [
4573
- e("div", {
4574
- class: We([
4575
- {
4576
- "bg-fm-color-primary": Z !== 0,
4577
- "bg-white": Z === 0
4578
- },
4579
- "w-[2px] h-full"
4580
- ])
4581
- }, null, 2)
4582
- ]),
4583
- e("div", hl, [
4584
- W.header === "Received" ? (i(), he(Y, {
4585
- key: 0,
4586
- name: "local_shipping",
4587
- outline: "",
4588
- color: "#ffffff"
4589
- })) : V("", !0)
4590
- ]),
4591
- e("div", bl, [
4592
- e("div", {
4593
- class: We([
4594
- {
4595
- "bg-fm-color-primary": Z < b.value.length - 1,
4596
- "bg-white": Z >= b.value.length - 1
4597
- },
4598
- "w-[2px] h-full"
4599
- ])
4600
- }, null, 2)
4601
- ])
4602
- ]),
4603
- e("div", gl, [
4604
- e("div", _l, [
4605
- e("div", Sl, k(W.header), 1),
4606
- e("div", kl, k(W.date), 1)
4607
- ]),
4608
- e("div", Ol, [
4609
- W.header === "Received" && W.deliveryOrder && o.purchaseOrder ? (i(), he(Qo, {
4610
- key: 0,
4611
- deliveryOrder: W.deliveryOrder,
4612
- purchaseOrder: o.purchaseOrder,
4613
- "received-info-map": X.value,
4614
- onSubmitted: l[4] || (l[4] = () => {
4615
- n("update:show", !1), n("submitted");
4616
- })
4617
- }, null, 8, ["deliveryOrder", "purchaseOrder", "received-info-map"])) : V("", !0),
4618
- (Fe = (be = W.deliveryOrder) == null ? void 0 : be.netSuite) != null && Fe.id ? (i(), he(ts, {
4619
- key: 1,
4620
- title: "Admin",
4621
- class: "min-w-[140px]"
4622
- }, {
4623
- default: ce(() => {
4624
- var Ne, Ee;
4625
- return [
4626
- T(Xn, {
4627
- "netsuite-id": (Ee = (Ne = W.deliveryOrder) == null ? void 0 : Ne.netSuite) == null ? void 0 : Ee.id
4628
- }, null, 8, ["netsuite-id"])
4629
- ];
4630
- }),
4631
- _: 2
4632
- }, 1024)) : V("", !0),
4633
- o.purchaseOrder && ((Ie = W.deliveryOrder) != null && Ie.id) ? (i(), he(Hs, {
4634
- key: 2,
4635
- "purchase-order-id": (fe = o.purchaseOrder) == null ? void 0 : fe._id,
4636
- "delivery-order-id": (ue = W.deliveryOrder) == null ? void 0 : ue.id
4637
- }, null, 8, ["purchase-order-id", "delivery-order-id"])) : V("", !0)
4638
- ])
4639
- ])
4640
- ]),
4641
- e("div", xl, [
4642
- e("div", wl, [
4643
- e("div", $l, [
4644
- e("div", {
4645
- class: We([
4646
- {
4647
- "bg-fm-color-primary": Z < b.value.length - 1,
4648
- "bg-white": Z >= b.value.length - 1
4649
- },
4650
- "w-[2px] h-full"
4651
- ])
4652
- }, null, 2)
4653
- ])
4654
- ]),
4655
- e("div", Cl, [
4656
- T(I, {
4657
- variant: "outlined",
4658
- class: "py-12 px-16"
4659
- }, {
4660
- default: ce(() => [
4661
- e("div", Al, [
4662
- (i(!0), v(Ce, null, Te(W.info, (Ne, Ee) => (i(), v("div", {
4663
- key: Ee,
4664
- class: "flex flex-col gap-4"
4665
- }, [
4666
- e("div", Dl, k(Ne == null ? void 0 : Ne.label), 1),
4667
- e("div", Rl, [
4668
- (i(!0), v(Ce, null, Te(Ne == null ? void 0 : Ne.values, (Le, it) => (i(), v("div", {
4669
- key: it,
4670
- class: "fm-typo-en-body-lg-600"
4671
- }, [
4672
- typeof Le == "string" ? (i(), v(Ce, { key: 0 }, [
4673
- Ge(k(Le), 1)
4674
- ], 64)) : (i(), he(Ns(Le), { key: 1 }))
4675
- ]))), 128))
4676
- ])
4677
- ]))), 128))
4678
- ])
4679
- ]),
4680
- _: 2
4681
- }, 1024)
4682
- ])
4683
- ])
4684
- ], 64);
4685
- }), 128))
4686
- ])) : (i(), v("div", ul, [
4687
- T(y),
4688
- e("div", null, [
4689
- e("img", {
4690
- src: h(Yt),
4691
- alt: "List is empty"
4692
- }, null, 8, cl)
4693
- ]),
4694
- e("div", dl, k(h(_)("inventory.transfer.receiveRequest.details.noRecordsFound")), 1),
4695
- e("div", ml, k(h(_)("inventory.transfer.receiveRequest.details.trackDeliveryMessage")), 1),
4696
- T(y),
4697
- T(y)
4698
- ]))
4699
- ])) : P.value.value === "actionLogs" ? (i(), v("div", Nl, [
4700
- we.value.length ? (i(), v("div", Tl, [
4701
- (i(!0), v(Ce, null, Te(we.value, (W, Z) => (i(), he(I, {
4702
- key: Z,
4703
- variant: "outlined",
4704
- class: "py-12 px-16"
4705
- }, {
4706
- default: ce(() => {
4707
- var be;
4708
- return [
4709
- e("div", El, [
4710
- e("div", ql, [
4711
- e("div", Vl, k(h(nt)[W.action] ? h(_)(h(nt)[W.action].translationKey) : W.action), 1),
4712
- e("div", Ll, k(h(et)(W.changedAt)), 1)
4713
- ]),
4714
- e("div", jl, k((be = W.changedBy) == null ? void 0 : be.name), 1),
4715
- W.remarks ? (i(), v("div", Ul, k(W.remarks), 1)) : V("", !0)
4716
- ])
4717
- ];
4718
- }),
4719
- _: 2
4720
- }, 1024))), 128))
4721
- ])) : (i(), v("div", Pl, [
4722
- T(y),
4723
- e("div", null, [
4724
- e("img", {
4725
- src: h(Yt),
4726
- alt: "List is empty"
4727
- }, null, 8, Fl)
4728
- ]),
4729
- e("div", Il, k(h(_)("inventory.transfer.receiveRequest.details.noActionLogs")), 1),
4730
- T(y),
4731
- T(y)
4732
- ]))
4733
- ])) : V("", !0)
4734
- ])
4735
- ];
4736
- }),
4737
- "side-sheet-footer": ce(() => [
4738
- e("div", Ml, [
4739
- (i(!0), v(Ce, null, Te(De.value, (S) => (i(), v(Ce, null, [
4740
- h(nt)[S].available != !1 ? (i(), he($, {
4741
- key: S,
4742
- label: h(_)(h(nt)[S].translationKey),
4743
- onClick: (U) => A(S),
4744
- loading: se.value === S,
4745
- disabled: se.value !== S && te.value,
4746
- variant: h(nt)[S].buttonVariant
4747
- }, null, 8, ["label", "onClick", "loading", "disabled", "variant"])) : V("", !0)
4748
- ], 64))), 256)),
4749
- h(F).ableToMarkReceived(o.purchaseOrder) && !De.value.includes("completeReceive") ? (i(), he($, {
4750
- key: 0,
4751
- label: h(_)("inventory.transfer.receiveRequest.actions.completeReceive"),
4752
- onClick: l[5] || (l[5] = (S) => A("completeReceive")),
4753
- loading: se.value === "completeReceive",
4754
- disabled: se.value !== "completeReceive" && te.value
4755
- }, null, 8, ["label", "loading", "disabled"])) : V("", !0),
4756
- h(F).ableToMarkApproved(o.purchaseOrder) && o.canApprove && !De.value.includes("approveRequest") ? (i(), he($, {
4757
- key: 1,
4758
- label: h(_)("inventory.transfer.approval.actions.approveRequest"),
4759
- onClick: l[6] || (l[6] = (S) => A("approveRequest")),
4760
- loading: se.value === "approveRequest",
4761
- disabled: se.value !== "approveRequest" && te.value
4762
- }, null, 8, ["label", "loading", "disabled"])) : V("", !0),
4763
- h(F).ableToCreateFulfillment(o.purchaseOrder, o.poRequest) && r.scope === "approval" ? (i(), he($, {
4764
- key: 2,
4765
- label: h(_)("inventory.transfer.receiveRequest.actions.processRequest"),
4766
- onClick: l[7] || (l[7] = (S) => A("processRequest")),
4767
- loading: se.value === "processRequest",
4768
- disabled: se.value !== "processRequest" && te.value
4769
- }, null, 8, ["label", "loading", "disabled"])) : V("", !0),
4770
- T($, {
4771
- label: h(_)("common.close"),
4772
- variant: "tertiary",
4773
- onClick: l[8] || (l[8] = (S) => n("update:show", !1))
4774
- }, null, 8, ["label"])
4775
- ])
4776
- ]),
4777
- _: 1
4778
- }, 8, ["modelValue", "dismiss-away"]);
4779
- };
4780
- }
4781
- });
4782
- export {
4783
- At as P,
4784
- gi as _,
4785
- bi as a,
4786
- ir as b,
4787
- ps as c,
4788
- ms as d,
4789
- hs as e,
4790
- vt as f,
4791
- us as g,
4792
- fs as h,
4793
- It as i,
4794
- Ft as j,
4795
- hi as u
4796
- };