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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (240) hide show
  1. package/dist/{App-C8i7vBxz.js → App-BPdZMhM8.js} +515 -536
  2. package/dist/{ApprovalView-GHgTeCBV.js → ApprovalView-UzjSuZ2L.js} +26 -25
  3. package/dist/{BindingsDialog-C4-S2CWk.js → BindingsDialog-Cb6WRlKq.js} +2 -2
  4. package/dist/{BindingsPicker-C7YUArBj.js → BindingsPicker-CtD4U4lv.js} +2 -2
  5. package/dist/{BindingsTable-1Zoqi4ZS.js → BindingsTable-CX-3403K.js} +10 -10
  6. package/dist/BulkReceiveRequestPage-CUq1Lmww.js +2839 -0
  7. package/dist/{ChangeLocationComponent.vue_vue_type_script_setup_true_lang-DFSg0-gv.js → ChangeLocationComponent.vue_vue_type_script_setup_true_lang-C5cA-lGH.js} +1 -1
  8. package/dist/{ClosingDraftView-CnWFyWSE.js → ClosingDraftView-Ca_SvdWQ.js} +748 -746
  9. package/dist/{ClosingHistoryView-Bkm0voU6.js → ClosingHistoryView-DzkeJYoe.js} +7 -7
  10. package/dist/{ClosingTemplateView-Bz81JTsg.js → ClosingTemplateView-DSrelbso.js} +22 -21
  11. package/dist/{CustomPrintTemplatePreview.vue_vue_type_script_setup_true_lang-6s-24euf.js → CustomPrintTemplatePreview.vue_vue_type_script_setup_true_lang-BuOuXPy1.js} +1 -1
  12. package/dist/{DefaultView-1RRzbPB3.js → DefaultView-Dw-7Y8vD.js} +2 -2
  13. package/dist/{DeliveryOrderPrintPreview-KcLqjOj1.js → DeliveryOrderPrintPreview-C5qJsv_O.js} +15 -15
  14. package/dist/{EmailDialog.vue_vue_type_script_setup_true_lang-r0Q0qhoK.js → EmailDialog.vue_vue_type_script_setup_true_lang-D8od7aKT.js} +9847 -9723
  15. package/dist/{FeatureCapabilityBadge.vue_vue_type_script_setup_true_lang-Cwmk3NLS.js → FeatureCapabilityBadge.vue_vue_type_script_setup_true_lang-ChekXW32.js} +11 -10
  16. package/dist/FeatureCapabilityGate-C-IM5_7n.js +82 -0
  17. package/dist/FeaturePageGate.vue_vue_type_script_setup_true_lang-DEDU1XUC.js +189 -0
  18. package/dist/{FmDateRangePickerChip.vue_vue_type_script_setup_true_lang-pzIzIWpX.js → FmDateRangePickerChip.vue_vue_type_script_setup_true_lang-B861gqIJ.js} +1 -1
  19. package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-B6cFB4vX.js → FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-Ckli_nZx.js} +2 -2
  20. package/dist/{FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-D_o6pX9i.js → FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-BEjFoMJJ.js} +2 -2
  21. package/dist/{FmMultiselectDialog-CC_Na_p1.js → FmMultiselectDialog-CShFKSIW.js} +2 -2
  22. package/dist/{FmMultiselectDialog-D0GhmOQ9.js → FmMultiselectDialog-Ci-6NMsV.js} +2 -2
  23. package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-DQlSMRoB.js → FmUnitInput.vue_vue_type_script_setup_true_lang-Dkx5vVap.js} +105 -99
  24. package/dist/ImportView-7ij7RUHI.js +1540 -0
  25. package/dist/{IngredientsView-B2I2OPSb.js → IngredientsView-fIPtTyFD.js} +367 -365
  26. package/dist/{IntegrationExplorerView-WK1EmwLA.js → IntegrationExplorerView-DLYT4T-I.js} +1537 -1620
  27. package/dist/IntegrationPlatformView-CwywuK_y.js +13385 -0
  28. package/dist/{IntegrationView-CeaL92Yj.js → IntegrationView-DnyVHXge.js} +2380 -2340
  29. package/dist/{InventoryBindingForm-DgtaDM0I.js → InventoryBindingForm-BBs8v7CL.js} +1 -1
  30. package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-CqDN355J.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang--pI5wz_M.js} +134 -134
  31. package/dist/{InventoryBindingSummary-C_W456aj.js → InventoryBindingSummary-CwIrQ8lG.js} +1 -1
  32. package/dist/JsonViewer.vue_vue_type_script_setup_true_lang-C_hg75l0.js +25 -0
  33. package/dist/NumberPrecisionInput.vue_vue_type_script_setup_true_lang-DJSbskyn.js +79 -0
  34. package/dist/PlanTierBadge.vue_vue_type_script_setup_true_lang-CM3gtYZo.js +19 -0
  35. package/dist/{PlanUpgradeDialog.vue_vue_type_script_setup_true_lang-D6-lo7iI.js → PlanUpgradeDialog.vue_vue_type_script_setup_true_lang-0F-yOcPC.js} +1 -1
  36. package/dist/PremiumUpgradePage.vue_vue_type_script_setup_true_lang-DGAxPOEh.js +58 -0
  37. package/dist/ProductionRunDetailPage-C_WC4qfP.js +2317 -0
  38. package/dist/{ProductionRunLifecycleDialogs.vue_vue_type_script_setup_true_lang-DwBY6gIb.js → ProductionRunLifecycleDialogs.vue_vue_type_script_setup_true_lang-BIkoMOM2.js} +3051 -3161
  39. package/dist/ProductionRunPage-DuzVrjbZ.js +954 -0
  40. package/dist/{PublishView-Dv-W6ntx.js → PublishView-BVg44yke.js} +3 -3
  41. package/dist/{PurchaseOrderPrintPreview-D1TAnJd_.js → PurchaseOrderPrintPreview-CNx6unyj.js} +17 -17
  42. package/dist/{ReceiveRequestView-Rc_uw_Ad.js → ReceiveRequestView-DeNrYOUt.js} +17 -16
  43. package/dist/RecipeView-De3pLsPR.js +3272 -0
  44. package/dist/{SettingsView-K5wAt8oo.js → SettingsView-B5ud0KtI.js} +398 -425
  45. package/dist/StockView-4N3NRjY8.js +3003 -0
  46. package/dist/{SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-CsRLy0xI.js → SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-DvlRRKdt.js} +1 -1
  47. package/dist/{SupplierView-CLVupRN0.js → SupplierView-fC9oe5nu.js} +21 -20
  48. package/dist/{SurchargeView-CToB_z5v.js → SurchargeView-H6rv7u8A.js} +7 -7
  49. package/dist/{SystemTrailDialog.vue_vue_type_script_setup_true_lang-CvqIw9q6.js → SystemTrailDialog.vue_vue_type_script_setup_true_lang-DFdrmR2Z.js} +2 -2
  50. package/dist/TableActionableRow.vue_vue_type_script_setup_true_lang-gJQQKKAC.js +71 -0
  51. package/dist/TemplatePublishDialog.vue_vue_type_script_setup_true_lang-BivHE94R.js +332 -0
  52. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-Df01LqHp.js +4953 -0
  53. package/dist/TransferTemplateView-CVUnofkI.js +2347 -0
  54. package/dist/{UnitCostHistoryView-BMB2MeTh.js → UnitCostHistoryView-DjD2WAFI.js} +4 -4
  55. package/dist/{UnitDisplayControl.vue_vue_type_script_setup_true_lang-Dn8Y8zfp.js → UnitDisplayControl.vue_vue_type_script_setup_true_lang-CE0zHU6c.js} +4 -4
  56. package/dist/{UnitView-Bl8jws6R.js → UnitView-DCfsbE8e.js} +111 -106
  57. package/dist/{WarehouseView-BurSM1jg.js → WarehouseView-BCebmbcj.js} +12 -11
  58. package/dist/{WastageTemplateView-DRfJ9LGR.js → WastageTemplateView-BXYNMBun.js} +19 -18
  59. package/dist/api/bill.d.ts +4 -2
  60. package/dist/api/bill.spec.d.ts +1 -0
  61. package/dist/api/closing.d.ts +1 -0
  62. package/dist/api/feature-flags.d.ts +2 -0
  63. package/dist/api/integration-sync-log.d.ts +0 -13
  64. package/dist/api/inventory.d.ts +9 -9
  65. package/dist/api/license.d.ts +0 -1
  66. package/dist/api/netsuite-explorer.d.ts +1 -0
  67. package/dist/api/stock.d.ts +1 -1
  68. package/dist/{app-Duum3eHx.js → app-VtVYHCDF.js} +9785 -9546
  69. package/dist/app.d.ts +151 -14
  70. package/dist/app.js +1 -1
  71. package/dist/bulk-edit-simulation.helper-Nd6CtWGf.js +178 -0
  72. package/dist/{closing-template-BE41yfue.js → closing-template-LCe0U9w9.js} +4 -4
  73. package/dist/components/FeatureCapabilityGate.vue.d.ts +3 -0
  74. package/dist/components/FeatureGateLayout.vue.d.ts +11 -0
  75. package/dist/components/FeaturePageGate.spec.d.ts +1 -0
  76. package/dist/components/FeaturePageGate.vue.d.ts +34 -0
  77. package/dist/components/FmAdminCollapsiblePanel.vue.d.ts +1 -1
  78. package/dist/components/FmDroppableField.vue.d.ts +1 -1
  79. package/dist/components/FmInventoryTableToolbar.vue.d.ts +2 -2
  80. package/dist/components/FmUnitInputProps.d.ts +1 -0
  81. package/dist/components/FmUnitInputRules.d.ts +1 -1
  82. package/dist/components/HrmPermissionGuard.vue.d.ts +1 -1
  83. package/dist/components/MultiLocationSelector.vue.d.ts +6 -6
  84. package/dist/components/NumberPrecisionInput.spec.d.ts +1 -0
  85. package/dist/components/PremiumUpgradePage.vue.d.ts +2 -0
  86. package/dist/components/TemplatePublishDialog.d.ts +2 -0
  87. package/dist/components/TemplatePublishDialog.spec.d.ts +1 -0
  88. package/dist/composable/defineApi.d.ts +1 -1
  89. package/dist/{date2-DrhO3BxU.js → date2-Cfb6DXM4.js} +1 -1
  90. package/dist/{dayjs.min-CQp6EpOp.js → dayjs.min-BOndKK7B.js} +1 -1
  91. package/dist/{decimal-Cq0qUT4r.js → decimal-nbuisP61.js} +2 -2
  92. package/dist/{defineDeepModel-DRC39nJs.js → defineDeepModel-DKySrdwp.js} +5 -5
  93. package/dist/{duplicate-template-j2ymeDNH.js → duplicate-template-BxcKb3Jp.js} +1 -1
  94. package/dist/{feature-C0hQza5A.js → feature-VDUlSvM1.js} +435 -359
  95. package/dist/feature-flags/core.d.ts +1 -0
  96. package/dist/feature-flags/vue.d.ts +22 -1
  97. package/dist/{format-time-from-id-BmJoI3jT.js → format-time-from-id-CfVH4LZ_.js} +1 -1
  98. package/dist/{format-unit-display-CRgIMXsD.js → format-unit-display-BjTeAtgS.js} +209 -208
  99. package/dist/helper/country.spec.d.ts +1 -0
  100. package/dist/helper/menu-usage-module.d.ts +2 -1
  101. package/dist/helper/number.d.ts +5 -1
  102. package/dist/helper/rules.d.ts +1 -1
  103. package/dist/{id-to-date-CuFZDvIr.js → id-to-date-Jr9SlHLO.js} +1 -1
  104. package/dist/{import-export.helper-B43zbsbj.js → import-export.helper-FT9Wbigh.js} +17 -17
  105. package/dist/{index-BYDjs08n.js → index-BV9b3Ulp.js} +2234 -2163
  106. package/dist/{index-DXNYZeq3.js → index-By5-VjVg.js} +1 -1
  107. package/dist/{JsonViewer.vue_vue_type_script_setup_true_lang-ig2zSXAB.js → index-C25C1Dg7.js} +1074 -1066
  108. package/dist/{index-Cwvg7EHd.js → index-DXHVgUHU.js} +3 -3
  109. package/dist/index-eGvSlWMU.js +1892 -0
  110. package/dist/layout/SingleColumnLayout.vue.d.ts +1 -1
  111. package/dist/{lz-string-6DgW1cPF.js → lz-string-BAzqO9xf.js} +1 -1
  112. package/dist/menu-usage-module-Bq_KLsO4.js +74 -0
  113. package/dist/{netsuite-BSpmyaE1.js → netsuite-BhGuduqd.js} +254 -263
  114. package/dist/netsuite-explorer-9Qj7qAum.js +79 -0
  115. package/dist/{predefined-templates-C0jtb4T7.js → predefined-templates-BlRafgnc.js} +1 -1
  116. package/dist/production-run-list-DR1WsaBR.js +61 -0
  117. package/dist/{purchase-order-template-B5Pjddfi.js → purchase-order-template-By_Zxu1b.js} +1 -1
  118. package/dist/{recalculationUtils-DtJWwWSj.js → recalculationUtils-VsBar7jB.js} +1 -1
  119. package/dist/router/name.d.ts +2 -1
  120. package/dist/{row-action.enum-BDDJNSi0.js → row-action.enum-76yLYmPA.js} +1 -1
  121. package/dist/rules-fOcvgt4t.js +243 -0
  122. package/dist/{stock-BKMDvf5S.js → stock-C-dQaxY2.js} +1 -1
  123. package/dist/stock-Dh0KXA1P.js +78 -0
  124. package/dist/stores/feature.d.ts +26 -2
  125. package/dist/stores/feature.load-state.spec.d.ts +1 -0
  126. package/dist/stores/integration/netsuite.d.ts +2 -2
  127. package/dist/stores/inventory.no-location.spec.d.ts +1 -0
  128. package/dist/stores/location.d.ts +42 -42
  129. package/dist/stores/supplier.d.ts +48 -48
  130. package/dist/stores/warehouse.d.ts +2 -2
  131. package/dist/style.css +1 -1
  132. package/dist/{supplier-Cv8HRNou.js → supplier-XHHHN8vZ.js} +2 -2
  133. package/dist/{surcharge-ktE1pRyy.js → surcharge-0-oBiYoF.js} +1 -1
  134. package/dist/tsconfig.app.tsbuildinfo +1 -1
  135. package/dist/{uom-rules-DCnXmEkb.js → uom-rules-DrRuSFgM.js} +1 -1
  136. package/dist/{use-ingredient-select-dialog-CYUUVrCI.js → use-ingredient-select-dialog-mQ7aQChK.js} +2 -2
  137. package/dist/{use-inventory-binding-dialog-Dugj9i-6.js → use-inventory-binding-dialog-5Wu0ItnH.js} +2 -2
  138. package/dist/{use-template-enabled-locations-BlZ7WAqX.js → use-template-enabled-locations-CgpPMl8g.js} +2 -2
  139. package/dist/{use-transfer-locations-CUDFnsVH.js → use-transfer-locations-DZ6B7eMT.js} +14 -14
  140. package/dist/{useHrmPermission-BOwmXi9H.js → useHrmPermission-BaGxz4EV.js} +1 -1
  141. package/dist/{useNavigationMenu-CbNKFBwx.js → useNavigationMenu-CyP39v3U.js} +39 -39
  142. package/dist/{useSseClient-CdyQh47h.js → useSseClient-CaD4MVg0.js} +1 -1
  143. package/dist/views/adjustment-template/wastage-template/actions.d.ts +36 -36
  144. package/dist/views/adjustment-template/wastage-template/table.d.ts +36 -36
  145. package/dist/views/changelog/composables/use-snapshot-diff.d.ts +2 -2
  146. package/dist/views/closing-draft/components/closing-draft-dialog/ClosingDraftApprovalDialog.vue.d.ts +6 -6
  147. package/dist/views/closing-draft/components/closing-draft-dialog/ClosingDraftDialog.vue.d.ts +12 -12
  148. package/dist/views/closing-draft/components/closing-draft-groups/ClosingGroupDetailSideSheet.vue.d.ts +6 -6
  149. package/dist/views/closing-draft/composables/use-closing-draft-import.d.ts +3 -3
  150. package/dist/views/closing-draft/composables/use-closing-draft-table.d.ts +19 -19
  151. package/dist/views/closing-draft/helpers/draft-status-to-class-name.helper.d.ts +1 -1
  152. package/dist/views/closing-template/composables/use-closing-template-actions.d.ts +45 -45
  153. package/dist/views/closing-template/composables/use-closing-template-table.d.ts +36 -36
  154. package/dist/views/import/helper/submit-rows.d.ts +1 -1
  155. package/dist/views/ingredients/components/inventory-binding/recipe-amount-validation.spec.d.ts +1 -0
  156. package/dist/views/ingredients/helper/is-linked-ingredient-error.d.ts +3 -1
  157. package/dist/views/integration/IntegrationPlatformView.vue.d.ts +24 -0
  158. package/dist/views/integration/components/IntegrationCard.vue.d.ts +3 -3
  159. package/dist/views/integration/components/Synergy/importFn.spec.d.ts +1 -0
  160. package/dist/views/integration/components/Xilnex/importFn.spec.d.ts +1 -0
  161. package/dist/views/integration/components/netsuite/business/AddLocationDialog.vue.d.ts +36 -36
  162. package/dist/views/integration/components/netsuite/business/AddVendorDialog.vue.d.ts +24 -24
  163. package/dist/views/integration/helper/opening-balance.d.ts +22 -0
  164. package/dist/views/integration/helper/opening-balance.spec.d.ts +1 -0
  165. package/dist/views/production-run/ProductionRunDetailPage.spec.d.ts +1 -0
  166. package/dist/views/{integration/components/IntegrationSyncLogTab.vue.d.ts → production-run/ProductionRunDetailPage.vue.d.ts} +2 -2
  167. package/dist/views/production-run/ProductionRunPage.vue.d.ts +2 -0
  168. package/dist/views/production-run/features/detail/ProductionRunItemsTable.vue.d.ts +2 -2
  169. package/dist/views/production-run/features/detail/ProductionRunOverviewTab.vue.d.ts +4 -4
  170. package/dist/views/production-run/features/detail/use-production-run-detail.d.ts +19 -9
  171. package/dist/views/production-run/features/lifecycle/CancelRunDialog.vue.d.ts +4 -4
  172. package/dist/views/production-run/features/lifecycle/CloseRunDialog.vue.d.ts +4 -4
  173. package/dist/views/production-run/features/lifecycle/ProductionRunLifecycleDialogs.vue.d.ts +14 -14
  174. package/dist/views/production-run/features/lifecycle/TargetReachedDialog.vue.d.ts +4 -4
  175. package/dist/views/production-run/features/planning/ProductionRunFormDialog.vue.d.ts +4 -4
  176. package/dist/views/production-run/features/planning/ProductionRunPlanner.vue.d.ts +1 -1
  177. package/dist/views/production-run/features/planning/use-production-run-duplicate-sources.d.ts +6 -6
  178. package/dist/views/production-run/shared/helpers/production-run-navigation.d.ts +0 -1
  179. package/dist/views/production-run/shared/model/production-run-list.d.ts +1 -1
  180. package/dist/views/production-run/shared/ui/ProductionRunInfoBadge.vue.d.ts +1 -1
  181. package/dist/views/production-run/shared/ui/ProductionRunInfoText.vue.d.ts +1 -1
  182. package/dist/views/production-run/shared/ui/ProductionRunScrollHint.vue.d.ts +2 -2
  183. package/dist/views/production-run/shared/ui/ProductionRunTextarea.vue.d.ts +3 -3
  184. package/dist/views/receive-request/components/transfer-form/TransferFormWithController.vue.d.ts +5 -5
  185. package/dist/views/receive-request/composables/netsuite-order-label.d.ts +11 -0
  186. package/dist/views/receive-request/composables/netsuite-order-label.spec.d.ts +1 -0
  187. package/dist/views/receive-request/composables/use-process-purchase-order.d.ts +6 -6
  188. package/dist/views/receive-request/composables/use-receive-request-form.d.ts +48 -48
  189. package/dist/views/receive-request/composables/use-receive-request-form.spec.d.ts +1 -0
  190. package/dist/views/receive-request/composables/use-receive-request-table.d.ts +42 -42
  191. package/dist/views/receive-request/import/export.spec.d.ts +1 -0
  192. package/dist/views/receive-request-bulk/BulkReceiveRequestPage.vue.d.ts +2 -0
  193. package/dist/views/receive-request-bulk/components/CreateTransferWizard.spec.d.ts +1 -0
  194. package/dist/views/receive-request-bulk/composables/use-bulk-receive-request-form.d.ts +54 -54
  195. package/dist/views/receive-request-bulk/composables/use-bulk-receive-request-form.readiness.spec.d.ts +1 -0
  196. package/dist/views/receive-request-bulk/composables/use-bulk-receive-request-table.d.ts +8 -8
  197. package/dist/views/recipe/components/recipe-bulk-editor/components/ModificationCard.spec.d.ts +1 -0
  198. package/dist/views/recipe/helper/import-recipe.d.ts +30 -0
  199. package/dist/views/recipe/helper/import-recipe.spec.d.ts +1 -0
  200. package/dist/views/settings/PlanLicenseDisplay.vue.d.ts +1 -14
  201. package/dist/views/stock/components/StockRecordCard.spec.d.ts +1 -0
  202. package/dist/views/stock/components/StockRecordCard.vue.d.ts +19 -865
  203. package/dist/views/stock/components/dialog/AmendAdjustmentForm.spec.d.ts +1 -0
  204. package/dist/views/stock/components/dialog/BillInventoryInfoDialog.spec.d.ts +1 -0
  205. package/dist/views/stock/components/dialog/BillInventoryInfoDialog.vue.d.ts +36 -0
  206. package/dist/views/stock/components/dialog/ConvertSkuDialog.spec.d.ts +1 -0
  207. package/dist/views/stock/composables/use-last-closing-summary.d.ts +4 -0
  208. package/dist/views/stock/composables/use-last-closing-summary.spec.d.ts +1 -0
  209. package/dist/views/supplier/components/SupplierForm.vue.d.ts +4 -4
  210. package/dist/views/supplier/composables/use-supplier-table.d.ts +2 -2
  211. package/dist/views/transfer-template/components/transfer-template-dialog/TransferTemplateDialog.vue.d.ts +8 -8
  212. package/dist/views/transfer-template/components/transfer-template-form/composables/use-transfer-locations.d.ts +4 -4
  213. package/dist/views/transfer-template/components/transfer-template-form/composables/use-transfer-template-items.spec.d.ts +1 -0
  214. package/dist/views/transfer-template/composables/use-template-item-bulk-editor.d.ts +24 -24
  215. package/dist/views/transfer-template/composables/use-transfer-template-actions.d.ts +48 -48
  216. package/dist/views/transfer-template/composables/use-transfer-template-table.d.ts +48 -48
  217. package/dist/views/transfer-template/helpers/template-item.error.helper.spec.d.ts +1 -0
  218. package/dist/views/unit/composables/use-unit-form.spec.d.ts +1 -0
  219. package/dist/views/warehouse/components/WarehouseForm.vue.d.ts +4 -4
  220. package/dist/{PlanTierBadge.vue_vue_type_script_setup_true_lang-BSR_nyHY.js → vue-KHCpiw_e.js} +101 -80
  221. package/dist/{vue-i18n-dSKy66Jh.js → vue-i18n-D6btLtve.js} +513 -513
  222. package/dist/{xlsx.util-pjzuMquw.js → xlsx.util-Dr5i_LBa.js} +2 -2
  223. package/package.json +71 -66
  224. package/dist/BulkReceiveRequestView-Lakk8011.js +0 -2656
  225. package/dist/FeatureCapabilityGate-C6t1VwKD.js +0 -74
  226. package/dist/ImportView-DCcdEvy4.js +0 -1291
  227. package/dist/NumberPrecisionInput.vue_vue_type_script_setup_true_lang-BMDjCk9T.js +0 -72
  228. package/dist/ProductionRunDetailView-C9rxLBbL.js +0 -2312
  229. package/dist/ProductionRunView-DvMdVGz1.js +0 -930
  230. package/dist/RecipeView-ByUaGc4w.js +0 -3428
  231. package/dist/StockView-B3EjdjVx.js +0 -2615
  232. package/dist/TableActionableRow.vue_vue_type_script_setup_true_lang-DAMpuZ1X.js +0 -84
  233. package/dist/TemplatePublishDialog.vue_vue_type_script_setup_true_lang-BGPuaJlU.js +0 -299
  234. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-8ydaQEw-.js +0 -4836
  235. package/dist/TransferTemplateView-BnfALwmw.js +0 -2326
  236. package/dist/menu-usage-module-BdjYEk3s.js +0 -57
  237. package/dist/number-5ZeFx-wN.js +0 -138
  238. package/dist/rules-CinZKpvV.js +0 -98
  239. package/dist/stock-1n-4iyqz.js +0 -75
  240. package/dist/views/integration/composables/use-integration-sync-log.d.ts +0 -45
@@ -1,4836 +0,0 @@
1
- import { f as lt, p as Os } from "./format-time-from-id-BmJoI3jT.js";
2
- import { defineComponent as Ve, ref as re, watch as Ye, createElementBlock as h, openBlock as i, createCommentVNode as V, createElementVNode as e, withDirectives as xs, toDisplayString as k, unref as y, vModelText as ws, toRaw as $s, shallowRef as dt, onUnmounted as os, triggerRef as Cs, computed as H, readonly as As, h as oe, resolveComponent as ne, createVNode as T, Fragment as Ne, renderList as Te, reactive as Ds, onMounted as ns, createBlock as fe, withCtx as ue, createTextVNode as Ge, normalizeClass as We, renderSlot as Ns, isRef as Rs, resolveDynamicComponent as Ps } from "vue";
3
- import { c as Gt } from "./component-BmLAdDiY.js";
4
- import { D as qe, R as De } from "./row-action.enum-BDDJNSi0.js";
5
- import { q as Ce, H as st, d as Fs, u as ze, _ as z, a3 as as, a4 as yt, Z as be, a as Nt, a5 as Wt, a6 as Is, a7 as Ts, G as Es, s as Rt, c as wt, M as Qt, a8 as ls, r as at, C as Ue, w as Fe, B as mt, a9 as qs } from "./app-Duum3eHx.js";
6
- import { h as Pt, a as Vs, t as Ls, b as et } from "./date2-DrhO3BxU.js";
7
- import { j as js, c as Us, a as $e, t as Qe, d as ut } from "./number-5ZeFx-wN.js";
8
- import { F as Be, u as Je, c as Ms, d as Yt, e as St } from "./feature-C0hQza5A.js";
9
- import { L as Bs } from "./lz-string-6DgW1cPF.js";
10
- import { useI18n as ht, useCoreStore as gt } from "@feedmepos/mf-common";
11
- import { useDialog as bt, useSnackbar as Ze, components as pt, FmButtonVariant as je, useProxiedModel as zs } from "@feedmepos/ui-library";
12
- import { u as _t, a as Ft, S as Me } from "./netsuite-BSpmyaE1.js";
13
- import { F as tt } from "./FmAdminBadge-DlplQOHb.js";
14
- import { _ as Jt } from "./empty-placeholder-B0QU467o.js";
15
- import { a as Ks, b as Hs, f as ft } from "./format-unit-display-CRgIMXsD.js";
16
- import { u as Xe, _ as Gs } from "./SystemTrailDialog.vue_vue_type_script_setup_true_lang-CvqIw9q6.js";
17
- import { F as Zt } from "./FeatureCapabilityGate-C6t1VwKD.js";
18
- import { _ as Ws, a as Qs, b as Ys } from "./FmUnitInput.vue_vue_type_script_setup_true_lang-DQlSMRoB.js";
19
- import { e as Js } from "./index-Cwvg7EHd.js";
20
- import { i as Zs } from "./FmDateRangePickerChip.vue_vue_type_script_setup_true_lang-pzIzIWpX.js";
21
- import { F as Xt } from "./form-mode.enum-BKiNVH6A.js";
22
- import { u as is } from "./supplier-Cv8HRNou.js";
23
- import { u as Xs } from "./surcharge-ktE1pRyy.js";
24
- import { f as er, h as tr, r as sr, s as rr } from "./predefined-templates-C0jtb4T7.js";
25
- import { F as or } from "./decimal-Cq0qUT4r.js";
26
- import { d as us } from "./defineDeepModel-DRC39nJs.js";
27
- import { u as nr } from "./vue-i18n-dSKy66Jh.js";
28
- import { u as ar } from "./useHrmPermission-BOwmXi9H.js";
29
- function cs(c, t) {
30
- return t.reduce(
31
- (n, m) => {
32
- const u = m.received.find((d) => d.sku._id === c._id);
33
- return u && (n = js(n, u.amount)), n;
34
- },
35
- or.toPrecision(Us(0), c.unit.precision)
36
- );
37
- }
38
- function ds(c) {
39
- var n;
40
- const t = Ce(), s = (n = c.supplier.supplyItems) != null && n.length ? { ...c.supplier, registrationNumber: c.supplier.registrationNumber ?? "" } : void 0;
41
- return (m) => {
42
- var u, d;
43
- if ((u = m.totalCost) != null && u.amount) return m.totalCost;
44
- if (!m.isCustomCost)
45
- try {
46
- const { cost: r } = Be.calculateDefaultCost({
47
- item: m.sku,
48
- amount: m.quantity,
49
- measurement: m.measurement,
50
- overrides: s ? { supplier: s } : void 0,
51
- defaultCurrency: t
52
- });
53
- return r.amount ? r : void 0;
54
- } catch (r) {
55
- console.warn("[print] cost auto-calculation failed for item", (d = m.sku) == null ? void 0 : d._id, r);
56
- return;
57
- }
58
- };
59
- }
60
- function lr(c) {
61
- var Se, Ae, K, ve, P, x, w;
62
- const { po: t, currentLocation: s, business: n, fulfilling: m, por: u } = c, d = s.doc.profile || {}, { name: r, address: a, regNo: O, legalName: f } = d, N = {
63
- name: r || s.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
- }, R = {
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: ((Ae = t.supplier.address) == null ? void 0 : Ae.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 = ds(t), _ = [], B = t.items.filter((A) => A.sku).map((A) => {
83
- var D;
84
- const { sku: G, measurement: X } = A, le = $e(
85
- cs(A.sku, t.deliveryOrder || []),
86
- !1
87
- ), g = F(A);
88
- return g && _.push(g), {
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: g ? `${g.currency} ${Be.toFormatString({
95
- value: A.quantity.amount === 0 ? Be.fromNumber(0) : Be.divide([g, A.quantity])
96
- })}` : void 0,
97
- cost: g ? `${g.currency} ${Be.toFormatString({
98
- value: g
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: Pt(new Date(A.createdAt)),
105
- ref: A.deliveryOrderNumber,
106
- remark: A.remark || "",
107
- items: (A.received || []).map((G) => {
108
- var X, le, g, 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: ((g = G.measurement) == null ? void 0 : g.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
- s.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: N,
131
- supplier: R,
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 ms(c) {
140
- var f;
141
- const { printData: t, templateType: s } = lr(c), m = er().getTemplateByType(s), u = !!((f = m == null ? void 0 : m.blocks) != null && f.length), d = tr(s), r = u ? m.blocks : d.blocks, a = u ? m.name : d.name, O = !u;
142
- try {
143
- const N = sr(r, t), R = N.match(/<style>([\s\S]*?)<\/style>/), F = R ? `<style>${R[1]}</style>` : "", _ = N.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 = Fs((c, t) => {
169
- const s = ze();
170
- return {
171
- async getShipments({
172
- start: n,
173
- end: m
174
- }) {
175
- const u = s.currentLocationDBName, d = `${c.inventoryBackendUrl}/${u}/shipments`;
176
- return await t.get(`${d}?start=${n}&end=${m}`);
177
- },
178
- async getShipmentsByIds(n) {
179
- if (n.length === 0)
180
- return [];
181
- const m = s.currentLocationDBName, u = `${c.inventoryBackendUrl}/${m}/shipments/get`;
182
- return await t.post(u, { shipmentIds: n });
183
- }
184
- };
185
- }), ps = {
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" }, fs = /* @__PURE__ */ Ve({
274
- __name: "RejectDraftForm",
275
- props: {
276
- message: {},
277
- confirm: { type: Function },
278
- onChange: { type: Function }
279
- },
280
- setup(c) {
281
- const t = c, { t: s } = ht(), n = re("");
282
- Ye(n, (u) => {
283
- var d;
284
- (d = t.onChange) == null || d.call(t, u ?? "");
285
- });
286
- function m() {
287
- n.value = "";
288
- }
289
- return (u, d) => (i(), h("div", ur, [
290
- t.message ? (i(), h("div", cr, k(t.message), 1)) : V("", !0),
291
- e("label", dr, k(y(s)("inventory.transfer.receiveRequest.details.rejectionReason")) + " (" + k(y(s)("inventory.common.optional")) + ")", 1),
292
- xs(e("textarea", {
293
- "onUpdate:modelValue": d[0] || (d[0] = (r) => n.value = r),
294
- rows: "4",
295
- class: "w-full mt-2 p-2 border rounded"
296
- }, null, 512), [
297
- [ws, 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(c) {
310
- if (c.items == null)
311
- return {};
312
- const t = as.safeParse(c);
313
- if (!t.success) {
314
- const s = t.error.issues.map((n) => `${n.path.join(".") || "(root)"}: ${n.message}`).join("; ");
315
- return console.error(
316
- `Cannot compute receive status for PO ${c == null ? void 0 : c._id}: invalid shape at ${s}`
317
- ), {};
318
- }
319
- return yt.generatedPOReceivedMap({
320
- purchaseOrder: c
321
- });
322
- }
323
- function mr(c) {
324
- return yt.validatePOItemReceivedStatus({
325
- dto: c
326
- });
327
- }
328
- function $t(c) {
329
- return yt.validatePOReceivedStatus({
330
- receivedMap: c
331
- });
332
- }
333
- function Ct(c, t, s) {
334
- if (!be.safeParse(c).success)
335
- throw new Error(`Invalid purchase order status: ${c}`);
336
- const n = be.parse(c);
337
- return yt.orderStatusCombination({
338
- status: n,
339
- isPOPartialReceive: t,
340
- isPOOverReceive: s
341
- });
342
- }
343
- function vs() {
344
- const c = ze(), t = Xe(), s = Je();
345
- async function n(u, d) {
346
- const r = c.currentLocationDBName;
347
- return u.doc.supplier.internal && u.operation === z.enum.confirmDraft && (u.operation = z.enum.submitRequest), await t.processPurchaseOrder(u, d || r);
348
- }
349
- async function m(u, d) {
350
- const r = c.currentLocationDBName;
351
- return await t.processPurchaseOrderV2(u, d || r);
352
- }
353
- return (u) => s.useOperatePurchaseOrderV2 ? m(u.operateV2, u.transferTo) : n(u.operate, u.transferTo);
354
- }
355
- function He(c) {
356
- const t = $s(c);
357
- if (Array.isArray(t))
358
- return t.map(He);
359
- if (t !== null && typeof t == "object") {
360
- const s = {};
361
- for (const n in t)
362
- Object.prototype.hasOwnProperty.call(t, n) && (s[n] = He(t[n]));
363
- return s;
364
- }
365
- return t;
366
- }
367
- const kt = {
368
- set: "set",
369
- add: "add",
370
- delete: "delete"
371
- };
372
- function es(c) {
373
- return {
374
- dbName: c.dbName,
375
- type: c.type,
376
- name: c.name,
377
- acceptRequest: c.acceptRequest ?? !1,
378
- doc: c.doc
379
- };
380
- }
381
- const ys = { line1: "", state: "", city: "", postcode: "", country: "" };
382
- function rt(c) {
383
- return c == null ? "" : String(c);
384
- }
385
- function hs(c) {
386
- const t = c.address, s = 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
- } : { ...ys };
394
- return {
395
- ...c,
396
- registrationNumber: c.registrationNumber ?? "",
397
- address: s
398
- };
399
- }
400
- function ts(c, t, s, n, m) {
401
- const u = He(c.suppliers ?? []).map(hs), d = He(t.allLocations ?? []).map(es), r = t._currentLocation ? es(He(t._currentLocation)) : null, a = s.inventory ? [He(s.inventory)] : [], O = n.state.setting ? He(n.state.setting) : null, f = He(m.surcharges ?? []);
402
- return {
403
- suppliers: u,
404
- locations: d,
405
- currentLocation: r,
406
- inventoryDoc: a,
407
- netSuiteSetting: O,
408
- surcharges: f
409
- };
410
- }
411
- function gs() {
412
- const c = is(), t = ze(), s = Nt(), n = _t(), m = Xs(), u = ts(
413
- c,
414
- t,
415
- s,
416
- n,
417
- m
418
- ), d = dt(Ms({ env: u }));
419
- d.value.setUsePartialUpdates(!0);
420
- const r = dt(d.value.state()), a = (R) => {
421
- r.value = d.value.state();
422
- };
423
- d.value.addListener(a);
424
- const O = (R, F, _) => {
425
- switch (R) {
426
- case kt.set:
427
- Wt(r.value, F, _);
428
- break;
429
- case kt.add:
430
- Ts(r.value, F, _);
431
- break;
432
- case kt.delete:
433
- Is(r.value, F);
434
- break;
435
- default:
436
- console.warn(`Unknown partial update operation: ${R}, falling back to 'set'`), Wt(r.value, F, _);
437
- }
438
- F !== "remark" && F !== "ref" && Cs(r);
439
- };
440
- d.value.addPartialListener(O);
441
- function f() {
442
- const R = ts(
443
- c,
444
- t,
445
- s,
446
- n,
447
- m
448
- );
449
- try {
450
- d.value.updateFullEnv(R), r.value = d.value.state();
451
- } catch (F) {
452
- console.error("[PurchaseOrderFormController] updateFullEnv failed", F);
453
- }
454
- }
455
- Ye(
456
- [
457
- () => c.suppliers,
458
- () => t.allLocations,
459
- () => t._currentLocation,
460
- () => s.inventory,
461
- () => n.state.setting,
462
- () => m.surcharges
463
- ],
464
- () => {
465
- f();
466
- },
467
- { deep: !0 }
468
- ), os(() => {
469
- d.value.removeListener(a), d.value.removePartialListener(O);
470
- });
471
- function N(R) {
472
- var F;
473
- if (R != null && R._id) {
474
- const _ = /* @__PURE__ */ new Set(["1", "2"]), B = R, E = B.supplier, te = E != null ? hs(E) : { _id: "", name: "", registrationNumber: "", address: { ...ys } }, se = {
475
- ...R,
476
- version: _.has(R.version) ? R.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
- d.value.loadPurchaseOrder(se);
499
- } catch (Q) {
500
- console.error("[PurchaseOrderFormController] loadPurchaseOrder failed", Q);
501
- }
502
- return;
503
- }
504
- if (!Je().mustUsePoTemplate) {
505
- d.value.init();
506
- return;
507
- }
508
- R != null && R.template && ((F = R.templateDoc) != null && F.purchaseOrder) ? (R.items = R.templateDoc.purchaseOrder.items, d.value.initFromTemplate(R)) : d.value.initOutletToOutlet();
509
- }
510
- return {
511
- controller: d,
512
- state: r,
513
- init: N
514
- };
515
- }
516
- var At = /* @__PURE__ */ ((c) => (c.RECEIVE_REQUEST = "receive/request", c.APPROVAL = "approval", c))(At || {});
517
- const ot = re(), Ot = re(), xt = re();
518
- function gi(c, t) {
519
- const s = bt(), n = ze(), m = Je(), u = is(), d = gt(), r = Ks(), a = Hs(), O = re(!1), f = Ze(), N = Xe(), R = ir(), F = re(new Array()), _ = re(new Array()), B = re(
520
- t != null && t.startDate && (t != null && t.endDate) ? t : Zs()
521
- ), E = H(() => {
522
- const g = new Date(B.value.startDate), D = new Date(B.value.endDate);
523
- return {
524
- start: Ls(g).toISOString(),
525
- end: Vs(D).toISOString()
526
- };
527
- }), te = re(new Array()), se = Es(), Q = re(null);
528
- async function de(g) {
529
- function D(ee) {
530
- const L = {
531
- mode: Xt.CREATE,
532
- modelValue: g || void 0,
533
- show: !0,
534
- "onUpdate:show"(b) {
535
- ot.value.show = b;
536
- },
537
- templateId: ee,
538
- lastClosingDate: Q.value
539
- };
540
- ot.value = L;
541
- }
542
- let ie;
543
- m.mustUsePoTemplate && !(g != null && g.template) ? s.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 r.getTemplateId(), ie && D(ie);
557
- }).onSecondary(() => {
558
- D(void 0);
559
- }) : D(ie);
560
- }
561
- function Oe(g) {
562
- const D = {
563
- mode: Xt.UPDATE,
564
- modelValue: wt(g),
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(g) {
574
- if (!d.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 = ms({
581
- po: g,
582
- currentLocation: D,
583
- business: d.currentBusiness.value,
584
- fulfilling: c === "approval",
585
- por: g.request
586
- });
587
- if (!ie) return;
588
- const ee = rr(ie.html), L = u.supplierById[g.supplier._id], b = {
589
- recipientName: L.name,
590
- email: (L == null ? void 0 : L.email) ?? "",
591
- business: d.currentBusiness.value,
592
- modelValue: ee,
593
- show: !0,
594
- "onUpdate:show"(j) {
595
- Ot.value.show = j;
596
- }
597
- };
598
- Ot.value = b;
599
- }
600
- async function Se() {
601
- F.value = [], _.value = [], O.value = !0;
602
- try {
603
- const g = await N.getPurchaseOrders(E.value);
604
- F.value = g.sort((j, J) => J._id.localeCompare(j._id));
605
- const D = g.flatMap((j) => j.shipmentIds || []).filter(Boolean), ie = D.length > 0 ? await R.getShipmentsByIds(D) : [];
606
- _.value = ie;
607
- const ee = await se.readCurrentLocationLastClosing(!0), L = ee == null ? void 0 : ee._id;
608
- L && (Q.value = Os(L)), await m.awaitFeatureLoaded(() => m.mustUsePoTemplate) && await a.fetchTemplates();
609
- const b = 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 N.readRequestByIds(b);
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 Ae() {
625
- te.value = [], O.value = !0;
626
- try {
627
- te.value = await N.readRequests(
628
- void 0,
629
- E.value.start,
630
- E.value.end
631
- ).then((g) => g.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 (c) {
644
- case "receive/request":
645
- return Se();
646
- case "approval":
647
- return Ae();
648
- }
649
- }
650
- function ve(g, D) {
651
- B.value = {
652
- startDate: g,
653
- endDate: D
654
- }, K();
655
- }
656
- n.watchLocation(async (g) => {
657
- if (!g) {
658
- F.value = [];
659
- return;
660
- }
661
- await K();
662
- });
663
- async function P(g) {
664
- return g;
665
- }
666
- const x = re(), w = re(Math.random().toString());
667
- async function A(g, D) {
668
- const ie = Math.random().toString();
669
- w.value = ie, D ?? (D = te.value.computeFirst(
670
- (j) => j.purchaseOrderId === g._id ? j : null
671
- ) ?? void 0);
672
- const ee = c === "receive/request" ? n.currentLocation : D == null ? void 0 : D.to, L = c === "approval", b = {
673
- poRequest: D,
674
- purchaseOrder: {
675
- ...g,
676
- status: L && (D != null && D.rejectedAt) ? be.Enum.REJECT : g.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: c,
687
- receivedMap: vt(g) ?? {},
688
- shipments: _.value
689
- };
690
- x.value = b;
691
- }
692
- async function G(g, D, ie, ee, L) {
693
- const b = vs();
694
- O.value = !0;
695
- try {
696
- await b({
697
- operate: {
698
- operation: D,
699
- doc: g,
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: g._id,
710
- _rev: g._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 && g.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, g, j);
732
- } finally {
733
- O.value = !1, K();
734
- }
735
- }
736
- async function X(g, D, ie) {
737
- const ee = ps[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, ...b } = ee;
747
- if (D === z.enum.rejectDraft) {
748
- let me = "";
749
- s.open({
750
- title: b.title,
751
- message: b.message,
752
- primaryActions: b.primaryActions,
753
- contentComponent: fs,
754
- contentComponentProps: {
755
- message: b.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(g, D, L, ie, ke);
766
- });
767
- return;
768
- }
769
- const j = [], J = gs();
770
- J.init(g), (D === z.enum.confirmDraft || D === z.enum.submitRequest) && j.push({
771
- action: "confirmDraft",
772
- payload: J.controller.value.toConfirmDraftData(Ce())
773
- }), s.open({
774
- title: b.title,
775
- message: b.message,
776
- primaryActions: b.primaryActions
777
- }).onPrimary(() => {
778
- G(g, D, L, ie, j);
779
- });
780
- }
781
- async function le() {
782
- s.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 g = {
794
- show: !0,
795
- "onUpdate:show"(D) {
796
- xt.value.show = D;
797
- }
798
- };
799
- xt.value = g;
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(c) {
823
- var ae, Se, Ae, K, ve, P;
824
- const { po: t, currentLocation: s, business: n, fulfilling: m, por: u } = c, { name: d, address: r, regNo: a, legalName: O } = s.doc.profile, f = {
825
- name: d,
826
- legalName: O,
827
- registrationNumber: a,
828
- line1: r == null ? void 0 : r.line1,
829
- line2: r == null ? void 0 : r.line2,
830
- postcode: r == null ? void 0 : r.postcode,
831
- city: r == null ? void 0 : r.city,
832
- state: r == null ? void 0 : r.state,
833
- country: r == null ? void 0 : r.country
834
- }, N = {
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: (Ae = t.supplier.address) == null ? void 0 : Ae.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
- }, R = ds(t), F = t.items.map((x) => {
845
- const { sku: w, measurement: A } = x, G = $e(
846
- cs(x.sku, t.deliveryOrder || []),
847
- !1
848
- ), X = R(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: Pt(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
- s.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: N,
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 = Bs.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 c = Je();
965
- return {
966
- ableToMarkReceived(t) {
967
- if (!t || t.status !== be.enum.RECEIVING || c.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) !== be.enum.REQUESTING);
973
- },
974
- ableToCreateFulfillment(t, s) {
975
- var u, d;
976
- if (!c.acceptRequireFulfillment || !t || !s || t.status !== be.enum.PROCESSING || !s.processedAt)
977
- return !1;
978
- const n = (u = s == null ? void 0 : s.from) == null ? void 0 : u.dbName, m = (d = s == null ? void 0 : s.to) == null ? void 0 : d.dbName;
979
- return !(n.startsWith("restaurant_") && m.startsWith("restaurant_"));
980
- }
981
- };
982
- }
983
- function _s() {
984
- const c = H(() => [
985
- {
986
- action: Qt.Action.manage,
987
- subject: Qt.Subject.Business.inventory_orderDraftApproval
988
- }
989
- ]), { hasPermission: t } = ar(c);
990
- return {
991
- hasOrderDraftPermission: As(t)
992
- };
993
- }
994
- function bi(c, t, s, n) {
995
- const m = ze(), u = _t(), d = gt(), r = bs(), { t: a } = ht(), O = Ze(), { hasOrderDraftPermission: f } = _s(), N = Je(), R = H(
996
- () => N.enablePrintTemplate ? [qe[De.PrintCustom]] : []
997
- ), F = H(
998
- () => N.enablePurchaseOrderEmail ? [qe[De.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[De.Update],
1011
- qe[De.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
- ...r.ableToMarkReceived(K) ? [Ke[z.enum.completeReceive]] : [],
1018
- qe[De.Details],
1019
- qe[De.Print],
1020
- ...R.value,
1021
- ...F.value
1022
- ];
1023
- case "PENDING_APPROVAL": {
1024
- const P = [qe[De.Details]];
1025
- return f.value && P.push(
1026
- qe[De.Update],
1027
- Ke[z.enum.approveDraft],
1028
- Ke[z.enum.rejectDraft]
1029
- ), P;
1030
- }
1031
- case "REQUESTING":
1032
- return c === "receive/request" ? [
1033
- qe[De.Details],
1034
- qe[De.Print],
1035
- ...R.value
1036
- ] : [
1037
- Ke[z.enum.approveRequest],
1038
- Ke[z.enum.rejectRequest],
1039
- qe[De.Details]
1040
- // DefaultRowActions[RowActionEnum.Print]
1041
- ];
1042
- case "PROCESSING":
1043
- return [
1044
- qe[De.Details],
1045
- qe[De.Print],
1046
- ...R.value
1047
- ];
1048
- case "COMPLETE":
1049
- case "CANCEL":
1050
- default:
1051
- return [
1052
- qe[De.Details],
1053
- qe[De.Print],
1054
- ...R.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, g, D, ie, ee, L;
1063
- let x;
1064
- try {
1065
- x = t.resolvePO ? await t.resolvePO(ve) : ve;
1066
- } catch (b) {
1067
- console.error("Failed to load full purchase order for action", b), O.open({
1068
- title: a("inventory.common.somethingWentWrong"),
1069
- message: (b == null ? void 0 : b.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 === De.Print || K === De.PrintCustom) {
1077
- let b = w;
1078
- if (b.items == null && (n != null && n.fetchFullPo)) {
1079
- const o = await n.fetchFullPo(w);
1080
- if (o == null) return;
1081
- b = 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 = b.netSuite) != null && X.refNo) && (b.ref = [((le = P == null ? void 0 : P.netSuite) == null ? void 0 : le.refNo) || ((g = b.netSuite) == null ? void 0 : g.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: b,
1091
- currentLocation: me,
1092
- business: d.currentBusiness.value,
1093
- fulfilling: c === "approval",
1094
- por: ke
1095
- };
1096
- if (K === De.PrintCustom) {
1097
- const o = ms(we);
1098
- o && (ae.value = o.html, Se.value = o.templateName, Ae.value = o.isDefault, Oe.value = !0);
1099
- } else
1100
- pr(we);
1101
- return;
1102
- }
1103
- if (K === De.Details) {
1104
- t.promptShowTransferDetails(w, P);
1105
- return;
1106
- }
1107
- if (K === De.Update) {
1108
- (ie = t.promptUpdateTransferDialog) == null || ie.call(t, w);
1109
- return;
1110
- }
1111
- if (K === De.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 oe("div", { class: "flex items-center gap-2" }, [
1156
- w,
1157
- x !== "1" ? oe(
1158
- "div",
1159
- { class: "py-3" },
1160
- oe(
1161
- tt,
1162
- {},
1163
- () => oe(
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 = d.sessionUser.value) != null && ve.role.isAdmin ? [
1186
- {
1187
- id: "statusForAdmin",
1188
- header: () => oe(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}`), g = `${x ?? ""}`.toLocaleLowerCase("en-us");
1202
- X === be.enum.CLOSE && (le = `${a(`inventory.transfer.status.${be.enum.COMPLETE}`)}`), X === "PARTIAL_RECEIVED" && g === be.enum.PROCESSING.toLocaleLowerCase("en-us") && (g = be.enum.RECEIVING.toLocaleLowerCase("en-us"));
1203
- let D = null;
1204
- const ie = s.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), b = L.getDate().toString().padStart(2, "0");
1209
- D = `${L.toLocaleString("en-US", { month: "short" })} ${b}`;
1210
- }
1211
- }
1212
- return oe(
1213
- "div",
1214
- {
1215
- class: "flex"
1216
- },
1217
- [
1218
- oe(
1219
- "div",
1220
- { class: "flex items-center" },
1221
- oe(
1222
- "div",
1223
- {
1224
- class: [
1225
- "fm-status-badge",
1226
- `fm-status-badge-${g}`,
1227
- G && "fm-status-badge-error"
1228
- ].filter(Boolean).join(" ")
1229
- },
1230
- `${le}`
1231
- )
1232
- ),
1233
- ...D ? [
1234
- oe(
1235
- "div",
1236
- {
1237
- class: "flex items-center gap-1 ml-2"
1238
- },
1239
- [
1240
- oe(pt.FmIcon, {
1241
- name: "local_shipping",
1242
- size: "md",
1243
- color: "neutral-gray-400"
1244
- }),
1245
- oe(
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 Gt(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, g;
1326
- return `${((le = X.netSuite) == null ? void 0 : le.refNo) ?? "N/A"} (${((g = X.netSuite) == null ? void 0 : g.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 g;
1334
- return (g = le.netSuite) == null ? void 0 : g.id;
1335
- });
1336
- return A != null && A.length ? A.map((le) => {
1337
- var g, D;
1338
- return `${((g = le.netSuite) == null ? void 0 : g.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 = d.sessionUser.value) != null && ve.role.isAdmin ? [
1389
- {
1390
- id: "statusForAdmin",
1391
- header: () => oe(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 oe(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 g = a(`inventory.transfer.status.${le}`), D = `${w ?? ""}`.toLocaleLowerCase("en-us");
1411
- return le === be.enum.CLOSE && (g = `${a(`inventory.transfer.status.${be.enum.COMPLETE}`)}`), le === "PARTIAL_RECEIVED" && D === be.enum.PROCESSING.toLocaleLowerCase("en-us") && (D = be.enum.RECEIVING.toLocaleLowerCase("en-us")), x.rejectedAt && (g = a("inventory.transfer.status.REJECT"), D = be.enum.REJECT.toLocaleLowerCase("en-us")), oe(
1412
- "div",
1413
- {
1414
- class: "flex"
1415
- },
1416
- oe(
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
- `${g}`
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 === De.Print ? {
1435
- ...G,
1436
- translationKey: "inventory.transfer.receiveRequest.details.printDeliveryOrder"
1437
- } : G);
1438
- return Gt(
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 g;
1496
- return (g = le.netSuite) == null ? void 0 : g.id;
1497
- });
1498
- return w != null && w.length ? w.map((le) => {
1499
- var g, D;
1500
- return `${((g = le.netSuite) == null ? void 0 : g.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((g) => {
1507
- var D;
1508
- return (D = g.netSuite) == null ? void 0 : D.id;
1509
- });
1510
- return A != null && A.length ? A.map((g) => {
1511
- var D, ie;
1512
- return `${((D = g.netSuite) == null ? void 0 : D.refNo) ?? "N/A"} (${((ie = g.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(() => c === "receive/request" ? se() : Q()), Oe = re(!1), ae = re(""), Se = re(""), Ae = re(!1);
1528
- return {
1529
- columnDefs: de,
1530
- showCustomPrintDialog: Oe,
1531
- customPrintHtml: ae,
1532
- customPrintTemplateName: Se,
1533
- customPrintIsDefault: Ae
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" }, gr = { class: "flex-1 min-w-0 flex flex-col gap-2" }, br = { 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
- }, It = /* @__PURE__ */ Ve({
1543
- __name: "PriceAdjustmentEditor",
1544
- props: {
1545
- controller: {},
1546
- state: {}
1547
- },
1548
- setup(c) {
1549
- const t = c, s = 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 d(a, O) {
1560
- t.controller.updateAdjustment(a, null, O);
1561
- }
1562
- function r(a) {
1563
- t.controller.removeAdjustment(a);
1564
- }
1565
- return (a, O) => {
1566
- const f = ne("FmButton"), N = ne("FmTextField"), R = ne("FmStepperField");
1567
- return i(), h("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
- s.value.length === 0 ? (i(), h("div", yr, " No price adjustments ")) : V("", !0),
1579
- (i(!0), h(Ne, null, Te(s.value, (F, _) => (i(), h("div", {
1580
- key: F.id
1581
- }, [
1582
- e("div", hr, [
1583
- e("div", gr, [
1584
- T(N, {
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", br, [
1593
- T(R, {
1594
- "model-value": n(F),
1595
- "onUpdate:modelValue": (B) => d(F.id, B),
1596
- label: "Amount (+/-)",
1597
- step: 0.01,
1598
- placeholder: "0.00",
1599
- size: "md",
1600
- "append-text": y(Ce)()
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) => r(F.id)
1609
- }, null, 8, ["onClick"])
1610
- ]),
1611
- _ < s.value.length - 1 ? (i(), h("div", _r)) : V("", !0)
1612
- ]))), 128))
1613
- ]);
1614
- };
1615
- }
1616
- });
1617
- function Tt(c) {
1618
- const t = dt(
1619
- Yt({
1620
- currency: c.currency,
1621
- adjustments: c.adjustments ?? []
1622
- })
1623
- ), s = dt(t.value.state());
1624
- function n(d) {
1625
- const r = () => {
1626
- s.value = d.state();
1627
- };
1628
- return d.addListener(r), () => d.removeListener(r);
1629
- }
1630
- let m = n(t.value);
1631
- function u(d) {
1632
- m(), t.value = Yt({
1633
- currency: c.currency,
1634
- adjustments: d ?? []
1635
- }), m = n(t.value), s.value = t.value.state();
1636
- }
1637
- return os(() => m()), { controller: t, state: s, 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(c, { emit: t }) {
1647
- const s = c, n = Ds({
1648
- id: "",
1649
- createdAt: (/* @__PURE__ */ new Date()).toISOString(),
1650
- items: []
1651
- }), m = re(), u = t, d = (a) => a != null && a !== "";
1652
- ns(() => {
1653
- s.purchaseOrder && (n.items = s.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 r = H(() => n.items.length <= 10);
1661
- return (a, O) => {
1662
- const f = ne("FmTable"), N = ne("FmButton"), R = ne("FmForm");
1663
- return i(), fe(R, {
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] = () => s.confirm(n))
1669
- }, {
1670
- default: ue(() => [
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 _ = s.purchaseOrder.items.find((B) => d(F.row.original.id) ? B.id === F.row.original.id : B.sku._id === F.row.original.sku._id);
1680
- return oe(
1681
- y(pt).FmTooltip,
1682
- {
1683
- content: _.code,
1684
- placement: "top",
1685
- variant: "plain",
1686
- zIndex: 50
1687
- },
1688
- oe(
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 _ = s.purchaseOrder.items.find((B) => d(F.row.original.id) ? B.id === F.row.original.id : B.sku._id === F.row.original.sku._id);
1702
- return oe(
1703
- y(pt).FmTooltip,
1704
- {
1705
- content: _.name,
1706
- placement: "top",
1707
- variant: "plain",
1708
- zIndex: 50
1709
- },
1710
- oe(
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 = s.purchaseOrder.items.find((te) => d(_.id) ? te.id === _.id : te.sku._id === _.sku._id), E = _.amount ?? {
1724
- amount: 1,
1725
- precision: 0
1726
- };
1727
- return oe(Ws, {
1728
- style: {
1729
- flex: "1 1 0%"
1730
- },
1731
- modelValue: {
1732
- amount: E,
1733
- measurement: _.measurement ?? null
1734
- },
1735
- key: d(_.id) ? _.id : _.sku._id,
1736
- unit: _.sku.unit,
1737
- "onUpdate:modelValue": (te) => {
1738
- if (!te) return;
1739
- const se = n.items.find((Q) => d(_.id) ? Q.id === _.id : Q.sku._id === _.sku._id);
1740
- se && (se.amount = te.amount);
1741
- },
1742
- disableUnit: !0,
1743
- rules: [
1744
- y(Qs)(
1745
- +y($e)({ amount: 0, precision: 0 })
1746
- ),
1747
- y(Ys)(+y($e)(B.quantity))
1748
- ],
1749
- applyDefaultRules: !0
1750
- });
1751
- }
1752
- }
1753
- ],
1754
- "row-data": n.items,
1755
- "hide-footer": r.value
1756
- }, null, 8, ["column-defs", "row-data", "hide-footer"])
1757
- ])
1758
- ]),
1759
- e("div", Or, [
1760
- T(N, {
1761
- class: "px-16",
1762
- label: "Confirm",
1763
- size: "md",
1764
- variant: "primary",
1765
- type: "submit"
1766
- }),
1767
- T(N, {
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
- });
1781
- var Dt = /* @__PURE__ */ ((c) => (c.loading = "loading", c.error = "error", c.success = "success", c))(Dt || {});
1782
- function wr(c) {
1783
- const t = re({
1784
- state: "loading"
1785
- /* loading */
1786
- }), s = async (n) => {
1787
- const m = n || c;
1788
- if (!m) {
1789
- t.value = { state: "error", error: new Error("No promise task provided") };
1790
- return;
1791
- }
1792
- t.value = {
1793
- state: "loading"
1794
- /* loading */
1795
- };
1796
- try {
1797
- const u = await m();
1798
- t.value = { state: "success", data: u };
1799
- } catch (u) {
1800
- t.value = { state: "error", error: u };
1801
- }
1802
- };
1803
- return c && s(), { result: t, execute: s };
1804
- }
1805
- const nt = {
1806
- submitRequest: {
1807
- translationKey: "inventory.transfer.receiveRequest.actions.submitRequest",
1808
- color: "primary",
1809
- buttonVariant: je.Primary
1810
- },
1811
- confirmDraft: {
1812
- translationKey: "inventory.transfer.receiveRequest.actions.confirmDraft",
1813
- color: "primary",
1814
- buttonVariant: je.Primary
1815
- },
1816
- cancelDraft: {
1817
- translationKey: "inventory.transfer.receiveRequest.actions.cancelDraft",
1818
- color: "system-error-300",
1819
- buttonVariant: je.Destructive
1820
- },
1821
- approveDraft: {
1822
- translationKey: "inventory.transfer.receiveRequest.actions.approveDraft",
1823
- color: "primary",
1824
- buttonVariant: je.Primary
1825
- },
1826
- rejectDraft: {
1827
- translationKey: "inventory.transfer.receiveRequest.actions.rejectDraft",
1828
- color: "system-error-300",
1829
- buttonVariant: je.Destructive
1830
- },
1831
- approveRequest: {
1832
- translationKey: "inventory.transfer.receiveRequest.actions.approveRequest",
1833
- color: "primary",
1834
- buttonVariant: je.Primary
1835
- },
1836
- processRequest: {
1837
- translationKey: "inventory.transfer.receiveRequest.actions.processRequest",
1838
- color: "primary",
1839
- buttonVariant: je.Primary
1840
- },
1841
- receiveStock: {
1842
- translationKey: "inventory.transfer.receiveRequest.actions.receiveStock",
1843
- color: "primary",
1844
- buttonVariant: je.Primary,
1845
- available: !1
1846
- },
1847
- completeReceive: {
1848
- translationKey: "inventory.transfer.receiveRequest.actions.completeReceive",
1849
- color: "primary",
1850
- buttonVariant: je.Plain
1851
- },
1852
- rejectRequest: {
1853
- translationKey: "inventory.transfer.receiveRequest.actions.rejectRequest",
1854
- color: "system-error-300",
1855
- buttonVariant: je.Destructive
1856
- },
1857
- closeRequest: {
1858
- translationKey: "inventory.transfer.receiveRequest.actions.closeRequest",
1859
- color: "system-error-300",
1860
- buttonVariant: je.Destructive,
1861
- available: !1
1862
- },
1863
- returnStock: {
1864
- translationKey: "inventory.transfer.receiveRequest.actions.returnStock",
1865
- color: "primary",
1866
- buttonVariant: je.Primary,
1867
- available: !1
1868
- }
1869
- }, $r = { class: "flex flex-row-reverse" }, Cr = /* @__PURE__ */ Ve({
1870
- __name: "NetSuiteSync",
1871
- props: {
1872
- poRequest: {},
1873
- purchaseOrder: {},
1874
- isTransferBetweenOutlets: { type: Boolean },
1875
- scope: {}
1876
- },
1877
- setup(c) {
1878
- const t = c, s = _t(), n = Ze(), m = bt(), u = re(!1);
1879
- H(() => {
1880
- var f, N, R, F;
1881
- let r = !0;
1882
- s.isEnabled || (r = !1);
1883
- const a = t.purchaseOrder, O = t.poRequest;
1884
- return a && ((f = a == null ? void 0 : a.supplier) != null && f.internal ? (!O && a.status == be.enum.DRAFT && (r = !1), O && !((N = O == null ? void 0 : O.netSuite) != null && N.id) && (r = !1), t.isTransferBetweenOutlets && (r = !1)) : ((a == null ? void 0 : a.status) !== be.enum.REQUESTING && a.supplier.internal && (r = !1), !O && !((R = a == null ? void 0 : a.netSuite) != null && R.id) && (r = !1), !O && ((F = a == null ? void 0 : a.netSuite) != null && F.id) && (a == null ? void 0 : a.status) == be.enum.REQUESTING && (r = !1))), r;
1885
- });
1886
- async function d() {
1887
- u.value || m.open({
1888
- title: "Sync with NetSuite",
1889
- contentComponent: oe("div", [
1890
- oe("p", "Are you sure you want to sync now?"),
1891
- oe("br"),
1892
- oe(
1893
- "p",
1894
- { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" },
1895
- "Please wait a moment before syncing manually to avoid unnecessary actions."
1896
- )
1897
- ]),
1898
- primaryActions: {
1899
- text: "Sync",
1900
- close: !0,
1901
- variant: "destructive"
1902
- },
1903
- secondaryActions: { text: "Not now", close: !0 }
1904
- }).onPrimary(async () => {
1905
- var r, a, O, f, N, R, F;
1906
- try {
1907
- u.value = !0;
1908
- const _ = ((r = t.purchaseOrder) == null ? void 0 : r._id) || ((a = t.poRequest) == null ? void 0 : a.purchaseOrderId) || "", B = (O = t.poRequest) == null ? void 0 : O.to.dbName;
1909
- await s.syncPurchaseOrder({
1910
- purchaseOrderId: _,
1911
- locationId: t.scope === "approval" ? B : void 0,
1912
- netsuiteId: ((N = (f = t.purchaseOrder) == null ? void 0 : f.netSuite) == null ? void 0 : N.id) || ((F = (R = t.poRequest) == null ? void 0 : R.netSuite) == null ? void 0 : F.id)
1913
- }), n.open({
1914
- title: "Sync with NetSuite",
1915
- message: "Requested to sync with NetSuite. Please wait a moment.",
1916
- type: "success"
1917
- }), await new Promise((E) => setTimeout(E, 5e3)), u.value = !1;
1918
- } catch (_) {
1919
- console.log("Failed to sync with NetSuite", _), n.open({
1920
- title: "Error",
1921
- message: "Failed to sync with NetSuite",
1922
- type: "error"
1923
- }), u.value = !1;
1924
- }
1925
- });
1926
- }
1927
- return (r, a) => {
1928
- const O = ne("FmButton");
1929
- return i(), h("div", $r, [
1930
- T(O, {
1931
- "prepend-icon": "sync",
1932
- variant: "secondary",
1933
- label: "Sync",
1934
- loading: u.value,
1935
- onClick: d,
1936
- "text-color": "primary",
1937
- "bg-color": "transparent",
1938
- "border-color": "primary"
1939
- }, null, 8, ["loading"])
1940
- ]);
1941
- };
1942
- }
1943
- }), Ar = {
1944
- key: 0,
1945
- class: "flex flex-col gap-8"
1946
- }, Dr = { class: "flex flex-col gap-4" }, Nr = { class: "fm-typo-en-body-lg-600" }, Rr = {
1947
- key: 0,
1948
- class: "flex flex-col gap-4"
1949
- }, Pr = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Fr = { class: "fm-typo-en-body-lg-600" }, Ir = { key: 0 }, Tr = { key: 1 }, Er = {
1950
- key: 1,
1951
- class: "flex flex-col gap-4"
1952
- }, qr = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Vr = { class: "fm-typo-en-body-lg-600" }, Lr = { key: 0 }, jr = { key: 1 }, Ur = {
1953
- key: 2,
1954
- class: "flex flex-col gap-4"
1955
- }, Mr = { class: "fm-typo-en-body-lg-600" }, Br = {
1956
- key: 3,
1957
- class: "flex flex-col gap-4"
1958
- }, zr = { class: "fm-typo-en-body-lg-600" }, Kr = /* @__PURE__ */ Ve({
1959
- __name: "NetSuiteInfo",
1960
- props: {
1961
- transferType: {},
1962
- transferToDbName: {},
1963
- poRequest: {},
1964
- purchaseOrder: {},
1965
- isTransferBetweenOutlets: { type: Boolean },
1966
- scope: {}
1967
- },
1968
- setup(c) {
1969
- const t = c, s = _t(), n = Xe(), m = re(t.poRequest);
1970
- ns(async () => {
1971
- var a;
1972
- if (!t.poRequest && ((a = t.purchaseOrder) != null && a._id)) {
1973
- const O = await n.getLatestPurchaseOrderRequest(t.purchaseOrder._id);
1974
- m.value = O;
1975
- }
1976
- });
1977
- const u = H(
1978
- () => {
1979
- var a, O, f, N, R, F;
1980
- return s.getSubsidiaryFullName(
1981
- ((f = (O = (a = t.purchaseOrder) == null ? void 0 : a.netSuite) == null ? void 0 : O.subsidiary) == null ? void 0 : f.id) || ((F = (R = (N = t.poRequest) == null ? void 0 : N.netSuite) == null ? void 0 : R.subsidiary) == null ? void 0 : F.id)
1982
- ).fullName;
1983
- }
1984
- ), d = H(() => {
1985
- var a, O, f, N, R, F, _, B, E, te, se, Q;
1986
- return (f = (O = (a = t.purchaseOrder) == null ? void 0 : a.netSuite) == null ? void 0 : O.additionalInfo) != null && f.transactionnumber ? (F = (R = (N = t.purchaseOrder) == null ? void 0 : N.netSuite) == null ? void 0 : R.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;
1987
- }), r = H(() => {
1988
- var a, O, f, N, R, F;
1989
- return (O = (a = t.purchaseOrder) == null ? void 0 : a.deliveryFullfillment) != null && O.length && ((N = (f = t.purchaseOrder) == null ? void 0 : f.deliveryFullfillment) == null ? void 0 : N.length) > 0 ? (F = (R = t.purchaseOrder) == null ? void 0 : R.deliveryFullfillment) == null ? void 0 : F.map((_) => {
1990
- var B;
1991
- return (B = _.netSuite) == null ? void 0 : B.refNo;
1992
- }).join(", ") : "N/A";
1993
- });
1994
- return (a, O) => {
1995
- var f, N, R, F, _, B, E, te, se, Q, de, Oe, ae, Se, Ae, K;
1996
- return y(s).isEnabled ? (i(), h("div", Ar, [
1997
- e("div", Dr, [
1998
- O[0] || (O[0] = e("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, "NetSuite subsidiary", -1)),
1999
- e("div", Nr, k(u.value || "N/A"), 1)
2000
- ]),
2001
- !a.isTransferBetweenOutlets && a.scope === y(At).RECEIVE_REQUEST ? (i(), h("div", Rr, [
2002
- e("div", Pr, " NetSuite " + k((N = (f = a.purchaseOrder) == null ? void 0 : f.netSuite) != null && N.recordType ? y(ls)((F = (R = a.purchaseOrder) == null ? void 0 : R.netSuite) == null ? void 0 : F.recordType) : a.transferType === y(at).enum.purchase ? "Purchase Order" : "Transfer Order") + " (ID) ", 1),
2003
- e("div", Fr, [
2004
- (B = (_ = a.purchaseOrder) == null ? void 0 : _.netSuite) != null && B.id ? (i(), h("span", Ir, 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(), h("span", Tr, "N/A"))
2005
- ])
2006
- ])) : V("", !0),
2007
- !a.isTransferBetweenOutlets && m.value || a.scope === y(At).APPROVAL ? (i(), h("div", Er, [
2008
- e("div", qr, " (Request) NetSuite " + k(a.transferType === y(at).enum.purchase ? "Purchase Order" : "Transfer Order") + " (ID) ", 1),
2009
- e("div", Vr, [
2010
- (Oe = (de = m.value) == null ? void 0 : de.netSuite) != null && Oe.id ? (i(), h("span", Lr, k((Se = (ae = m.value) == null ? void 0 : ae.netSuite) == null ? void 0 : Se.refNo) + " (" + k((K = (Ae = m.value) == null ? void 0 : Ae.netSuite) == null ? void 0 : K.id) + ") ", 1)) : (i(), h("span", jr, "N/A"))
2011
- ])
2012
- ])) : V("", !0),
2013
- d.value ? (i(), h("div", Ur, [
2014
- O[1] || (O[1] = e("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " NetSuite Transaction Number ", -1)),
2015
- e("div", Mr, k(d.value), 1)
2016
- ])) : V("", !0),
2017
- y(s).isEnabled && a.transferType === y(at).enum.transfer && !a.isTransferBetweenOutlets ? (i(), h("div", Br, [
2018
- O[2] || (O[2] = e("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " NetSuite fulfillment IDs ", -1)),
2019
- e("div", zr, k(r.value), 1)
2020
- ])) : V("", !0)
2021
- ])) : V("", !0);
2022
- };
2023
- }
2024
- }), Hr = { class: "flex flex-row-reverse" }, Gr = /* @__PURE__ */ Ve({
2025
- __name: "NetSuiteLog",
2026
- props: {
2027
- netsuiteId: {},
2028
- purchaseOrderId: {}
2029
- },
2030
- setup(c) {
2031
- const t = Ze(), s = Ft();
2032
- async function n(m, u) {
2033
- const d = [];
2034
- if (m && d.push(`body.message:*${m}*`), u) {
2035
- const f = u.replace(/:/g, "\\:");
2036
- d.push(`${f}`);
2037
- }
2038
- if (d.length === 0) {
2039
- t.open({
2040
- message: "Cannot open logs without valid filters.",
2041
- type: "error"
2042
- });
2043
- return;
2044
- }
2045
- const a = `attributes.pod:netsuite* AND (${d.join(" OR ")})`, { url: O } = await s.getSyncLogs(a);
2046
- t.open(
2047
- {
2048
- message: "Opening NetSuite logs...",
2049
- type: "info"
2050
- },
2051
- 800
2052
- ), await new Promise((f) => setTimeout(f, 800)), window.open(O, "_blank");
2053
- }
2054
- return (m, u) => {
2055
- const d = ne("FmButton");
2056
- return i(), h("div", Hr, [
2057
- T(d, {
2058
- "prepend-icon": "history",
2059
- variant: "secondary",
2060
- label: "Logs",
2061
- onClick: u[0] || (u[0] = (r) => n(m.netsuiteId, m.purchaseOrderId)),
2062
- "text-color": "primary",
2063
- "bg-color": "transparent",
2064
- "border-color": "primary"
2065
- })
2066
- ]);
2067
- };
2068
- }
2069
- }), Wr = { class: "flex flex-row-reverse" }, Qr = { key: 0 }, Yr = { key: 1 }, Jr = { class: "mb-6" }, Zr = { class: "fm-typo-en-body-md-400" }, Xr = { key: 0 }, eo = { key: 1 }, to = {
2070
- key: 0,
2071
- class: "flex"
2072
- }, so = {
2073
- key: 1,
2074
- class: "border-t pt-6"
2075
- }, ro = { class: "fm-typo-en-body-lg-600 mb-4 flex items-center gap-2" }, oo = { class: "border border-fm-color-neutral-gray-200 fm-corner-radius-lg overflow-y-auto" }, no = { class: "w-full" }, ao = {
2076
- class: "p-3 fm-typo-en-body-sm-600",
2077
- style: { "min-width": "130px" }
2078
- }, 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-400 text-fm-color-typo-secondary" }, fo = { class: "p-3 fm-typo-en-body-sm-600" }, vo = { key: 2 }, yo = { key: 1 }, ho = /* @__PURE__ */ Ve({
2079
- __name: "NetSuiteLatestInfo",
2080
- props: {
2081
- netsuiteId: {},
2082
- purchaseOrderId: {}
2083
- },
2084
- setup(c) {
2085
- const t = c, s = Ft(), n = re(!1), m = ze(), u = re(!0), d = re(!1), r = re(!1), a = re(!1), O = re(null), f = re([]);
2086
- async function N() {
2087
- if (!O.value) {
2088
- n.value = !0;
2089
- try {
2090
- u.value = !0;
2091
- const B = await s.getMoreInfo(
2092
- m.currentLocation.dbName,
2093
- t.purchaseOrderId
2094
- );
2095
- O.value = B, d.value = !1;
2096
- } catch {
2097
- d.value = !0;
2098
- } finally {
2099
- u.value = !1;
2100
- }
2101
- await R();
2102
- }
2103
- }
2104
- async function R() {
2105
- if (!(f.value.length > 0))
2106
- try {
2107
- r.value = !0;
2108
- const B = await s.getChangeLogs(t.netsuiteId);
2109
- f.value = B, a.value = !1;
2110
- } catch {
2111
- a.value = !0;
2112
- } finally {
2113
- r.value = !1;
2114
- }
2115
- }
2116
- function F(B) {
2117
- switch (B) {
2118
- case Me.Create:
2119
- return "text-green-600 bg-green-100";
2120
- case Me.Set:
2121
- return "text-blue-600 bg-blue-100";
2122
- case Me.Change:
2123
- return "text-yellow-600 bg-yellow-100";
2124
- case Me.Unset:
2125
- return "text-red-600 bg-red-100";
2126
- default:
2127
- return "text-gray-600 bg-gray-100";
2128
- }
2129
- }
2130
- function _(B) {
2131
- return new Date(B).toLocaleDateString("en-US", {
2132
- year: "numeric",
2133
- month: "short",
2134
- day: "numeric",
2135
- hour: "2-digit",
2136
- minute: "2-digit"
2137
- });
2138
- }
2139
- return (B, E) => {
2140
- const te = ne("FmButton"), se = ne("FmLabel"), Q = ne("FmCircularProgress"), de = ne("FmIcon"), Oe = ne("FmDialog");
2141
- return i(), h("div", Wr, [
2142
- T(Oe, {
2143
- modelValue: n.value,
2144
- "onUpdate:modelValue": E[2] || (E[2] = (ae) => n.value = ae),
2145
- overlay: !0,
2146
- "max-width": 800
2147
- }, {
2148
- "dialog-button": ue(() => [
2149
- T(te, {
2150
- "prepend-icon": "info",
2151
- variant: "secondary",
2152
- label: "Latest Info",
2153
- onClick: E[0] || (E[0] = (ae) => N()),
2154
- "text-color": "primary",
2155
- "bg-color": "transparent",
2156
- "border-color": "primary"
2157
- })
2158
- ]),
2159
- "dialog-header": ue(() => E[3] || (E[3] = [
2160
- e("div", null, "NetSuite latest info", -1)
2161
- ])),
2162
- default: ue(() => [
2163
- u.value ? (i(), h("div", Qr, "Loading...")) : (i(), h("div", Yr, [
2164
- d.value ? (i(), h("p", yo, "Something went wrong.")) : (i(), h(Ne, { key: 0 }, [
2165
- e("div", Jr, [
2166
- E[4] || (E[4] = e("h3", { class: "fm-typo-en-body-lg-600 mb-4" }, "NetSuite Order Details", -1)),
2167
- (i(!0), h(Ne, null, Te(O.value, (ae, Se) => (i(), h("div", {
2168
- key: Se,
2169
- class: "mb-2"
2170
- }, [
2171
- e("div", null, [
2172
- T(se, {
2173
- label: y(Rt)(Se)
2174
- }, null, 8, ["label"]),
2175
- e("div", Zr, [
2176
- Array.isArray(ae) ? (i(), h("span", Xr, k(ae.length > 0 ? ae.join(", ") : "N/A"), 1)) : (i(), h("span", eo, k(ae), 1))
2177
- ])
2178
- ])
2179
- ]))), 128))
2180
- ]),
2181
- r.value ? (i(), h("div", to, [
2182
- E[5] || (E[5] = e("span", null, "Change Log Loading...", -1)),
2183
- T(Q, { size: "md" })
2184
- ])) : V("", !0),
2185
- !r.value && f.value.length > 0 ? (i(), h("div", so, [
2186
- e("h3", ro, [
2187
- T(de, {
2188
- name: "error",
2189
- color: "#ff9500",
2190
- size: "sm"
2191
- }),
2192
- E[6] || (E[6] = Ge(" Change Logs "))
2193
- ]),
2194
- e("div", oo, [
2195
- e("table", no, [
2196
- E[7] || (E[7] = e("thead", { class: "bg-fm-color-neutral-gray-50" }, [
2197
- e("tr", { class: "border-b border-fm-color-neutral-gray-200" }, [
2198
- e("th", {
2199
- class: "text-left p-3 fm-typo-en-body-md-600",
2200
- style: { "min-width": "130px" }
2201
- }, " Date "),
2202
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Role"),
2203
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Name"),
2204
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Context"),
2205
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Type"),
2206
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Line ID"),
2207
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Field"),
2208
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Old Value"),
2209
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "New Value")
2210
- ])
2211
- ], -1)),
2212
- e("tbody", null, [
2213
- (i(!0), h(Ne, null, Te(f.value, (ae, Se) => (i(), h("tr", {
2214
- key: Se,
2215
- class: "border-b border-fm-color-neutral-gray-200 last:border-b-0"
2216
- }, [
2217
- e("td", ao, k(_(ae._dateiso8601)), 1),
2218
- e("td", lo, k(ae._rolename), 1),
2219
- e("td", io, k(ae._employeename), 1),
2220
- e("td", uo, k(ae._contextname), 1),
2221
- e("td", {
2222
- class: We(`p-3 fm-typo-en-body-sm-600 ${F(Number(ae.type) - 1)}`)
2223
- }, k(y(Me)[Number(ae.type) - 1]), 3),
2224
- e("td", co, k(ae.lineid || ""), 1),
2225
- e("td", mo, k(ae._fieldname), 1),
2226
- e("td", po, k(ae.oldvalue || ""), 1),
2227
- e("td", fo, k(ae.newvalue || ""), 1)
2228
- ]))), 128))
2229
- ])
2230
- ])
2231
- ])
2232
- ])) : (i(), h("div", vo, E[8] || (E[8] = [
2233
- e("p", null, "No change logs available.", -1)
2234
- ])))
2235
- ], 64))
2236
- ]))
2237
- ]),
2238
- "dialog-footer": ue(() => [
2239
- T(te, {
2240
- class: "ml-auto sm:w-full xs:w-full",
2241
- label: "Close",
2242
- size: "md",
2243
- variant: "primary",
2244
- onClick: E[1] || (E[1] = (ae) => n.value = !1)
2245
- })
2246
- ]),
2247
- _: 1
2248
- }, 8, ["modelValue"])
2249
- ]);
2250
- };
2251
- }
2252
- }), go = {
2253
- key: 0,
2254
- class: "border border-fm-color-neutral-gray-200 fm-corner-radius-lg p-16 flex flex-col gap-8"
2255
- }, bo = { class: "flex gap-8 items-center" }, _o = { class: "ml-auto" }, So = { class: "flex gap-3" }, ko = /* @__PURE__ */ Ve({
2256
- __name: "NetSuitePanel",
2257
- props: {
2258
- poRequest: {},
2259
- purchaseOrder: {},
2260
- transferType: {},
2261
- transferToDbName: {},
2262
- scope: {}
2263
- },
2264
- setup(c) {
2265
- const t = c, s = Js(), n = H(() => s.isNetSuiteEnabled);
2266
- return (m, u) => {
2267
- var r, a;
2268
- const d = ne("FmMenuDivider");
2269
- return n.value ? (i(), h("div", go, [
2270
- e("div", bo, [
2271
- u[0] || (u[0] = e("span", { class: "flex-1 fm-typo-en-body-lg-600" }, "NetSuite Info", -1)),
2272
- e("div", _o, [
2273
- e("div", So, [
2274
- (a = (r = t.purchaseOrder) == null ? void 0 : r.netSuite) != null && a.id ? (i(), fe(tt, { key: 0 }, {
2275
- default: ue(() => {
2276
- var O, f, N;
2277
- return [
2278
- T(ho, {
2279
- "netsuite-id": (f = (O = m.purchaseOrder) == null ? void 0 : O.netSuite) == null ? void 0 : f.id,
2280
- "purchase-order-id": (N = m.purchaseOrder) == null ? void 0 : N._id
2281
- }, null, 8, ["netsuite-id", "purchase-order-id"])
2282
- ];
2283
- }),
2284
- _: 1
2285
- })) : V("", !0),
2286
- T(tt, null, {
2287
- default: ue(() => {
2288
- var O, f, N;
2289
- return [
2290
- T(Gr, {
2291
- "netsuite-id": (f = (O = m.purchaseOrder) == null ? void 0 : O.netSuite) == null ? void 0 : f.id,
2292
- "purchase-order-id": (N = m.purchaseOrder) == null ? void 0 : N._id
2293
- }, null, 8, ["netsuite-id", "purchase-order-id"])
2294
- ];
2295
- }),
2296
- _: 1
2297
- }),
2298
- T(Cr, {
2299
- "po-request": m.poRequest,
2300
- "purchase-order": m.purchaseOrder,
2301
- "is-transfer-between-outlets": !n.value,
2302
- scope: m.scope
2303
- }, null, 8, ["po-request", "purchase-order", "is-transfer-between-outlets", "scope"])
2304
- ])
2305
- ])
2306
- ]),
2307
- T(d),
2308
- T(Kr, {
2309
- "po-request": m.poRequest,
2310
- "purchase-order": m.purchaseOrder,
2311
- "transfer-type": m.transferType,
2312
- "transfer-to-db-name": m.transferToDbName,
2313
- "is-transfer-between-outlets": !n.value,
2314
- scope: m.scope
2315
- }, null, 8, ["po-request", "purchase-order", "transfer-type", "transfer-to-db-name", "is-transfer-between-outlets", "scope"])
2316
- ])) : V("", !0);
2317
- };
2318
- }
2319
- }), Oo = ["open"], xo = { class: "fm-typo-en-body-sm-600 cursor-pointer select-none" }, ss = /* @__PURE__ */ Ve({
2320
- __name: "FmAdminCollapsiblePanel",
2321
- props: {
2322
- title: { default: "Admin" },
2323
- open: { type: Boolean, default: !1 },
2324
- selectable: { type: Boolean, default: !0 },
2325
- class: { default: void 0 },
2326
- contentClass: { default: void 0 }
2327
- },
2328
- setup(c) {
2329
- const t = c;
2330
- return (s, n) => (i(), fe(tt, {
2331
- selectable: t.selectable,
2332
- class: We(t.class)
2333
- }, {
2334
- default: ue(() => [
2335
- e("details", {
2336
- open: t.open,
2337
- class: "w-full"
2338
- }, [
2339
- e("summary", xo, k(t.title), 1),
2340
- e("div", {
2341
- class: We(["mt-4 flex flex-col gap-2", t.contentClass])
2342
- }, [
2343
- Ns(s.$slots, "default")
2344
- ], 2)
2345
- ], 8, Oo)
2346
- ]),
2347
- _: 3
2348
- }, 8, ["selectable", "class"]));
2349
- }
2350
- });
2351
- function Ss(c) {
2352
- if (!(c != null && c.itemsAtSubmission)) return [];
2353
- const t = new Set(c.itemsAtSubmission.map((m) => m.sku._id)), s = /* @__PURE__ */ new Set(), n = [];
2354
- for (const m of c.items) {
2355
- const u = m.sku._id;
2356
- t.has(u) || s.has(u) || (s.add(u), n.push(m));
2357
- }
2358
- return n;
2359
- }
2360
- function ks(c, t) {
2361
- var m;
2362
- if (!c || t.length === 0) return {};
2363
- const s = new Set(t.map((u) => u.sku._id)), n = {};
2364
- for (const u of c.deliveryOrder ?? [])
2365
- for (const d of u.received ?? []) {
2366
- const r = d.sku._id;
2367
- r && s.has(r) && (n[r] = (n[r] ?? 0) + (((m = d.amount) == null ? void 0 : m.amount) ?? 0));
2368
- }
2369
- return t.reduce(
2370
- (u, d) => {
2371
- var N, R;
2372
- const r = d.sku._id ?? "", a = ((N = d.quantity) == null ? void 0 : N.amount) ?? 0, O = n[r] ?? 0, f = ((R = d.quantity) == null ? void 0 : R.precision) ?? 0;
2373
- return u[r] = {
2374
- key: r,
2375
- total: { amount: a, precision: f },
2376
- received: { amount: O, precision: f },
2377
- remaining: { amount: a - O, precision: f }
2378
- }, u;
2379
- },
2380
- {}
2381
- );
2382
- }
2383
- const wo = { class: "flex flex-col gap-3" }, $o = { class: "flex flex-col gap-4" }, Co = { class: "flex flex-col gap-4 fm-typo-en-body-lg-600" }, Ao = { class: "flex flex-col gap-4" }, Do = { class: "flex justify-between items-start py-1 gap-4" }, No = { class: "flex flex-col flex-1 min-w-0" }, Ro = { class: "fm-typo-en-body-lg-600 truncate" }, Po = { class: "fm-typo-en-body-md-400 truncate" }, Fo = { class: "flex flex-col gap-2 items-end w-52 shrink-0" }, Io = {
2384
- key: 0,
2385
- class: "flex items-center gap-2"
2386
- }, To = {
2387
- key: 0,
2388
- class: "border-b border-fm-color-stroke-secondary"
2389
- }, Eo = { class: "flex flex-col gap-4" }, qo = { class: "flex items-center justify-between" }, Vo = {
2390
- key: 0,
2391
- class: "fm-typo-en-body-md-400 text-fm-color-typo-tertiary"
2392
- }, Lo = { class: "flex justify-between items-start py-1 gap-4" }, jo = { class: "flex-1 min-w-0 flex flex-col gap-2" }, Uo = { class: "flex flex-col gap-2 items-end w-52 shrink-0" }, Mo = {
2393
- key: 0,
2394
- class: "flex items-center gap-2"
2395
- }, Bo = {
2396
- key: 0,
2397
- class: "border-b border-fm-color-stroke-secondary"
2398
- }, zo = { class: "flex flex-col gap-4" }, Ko = { class: "flex flex-col gap-4" }, Ho = { class: "flex flex-col gap-4" }, Go = { class: "flex flex-col gap-4 fm-typo-en-body-lg-600" }, Wo = {
2399
- key: 1,
2400
- class: "flex flex-col gap-4"
2401
- }, Qo = { class: "flex flex-col gap-4 fm-typo-en-body-lg-600" }, ct = "Will be ignored on save (zero or negative quantity)", Yo = /* @__PURE__ */ Ve({
2402
- __name: "EditForm",
2403
- props: {
2404
- purchaseOrder: {},
2405
- deliveryOrder: {},
2406
- receivedInfoMap: {}
2407
- },
2408
- emits: ["submitted"],
2409
- setup(c, { emit: t }) {
2410
- var ee;
2411
- const { t: s } = nr(), n = Je(), m = Ze(), u = re(!1), d = Nt(), r = c, a = (((ee = r.purchaseOrder) == null ? void 0 : ee.version) ?? Ue.enum[1]) === Ue.enum[2], O = t, f = us("deliveryOrder"), N = Xe(), {
2412
- controller: R,
2413
- state: F,
2414
- reset: _
2415
- } = Tt({
2416
- currency: Ce(),
2417
- adjustments: r.deliveryOrder.priceAdjustments
2418
- }), B = H(
2419
- () => {
2420
- var L;
2421
- return ((L = r.purchaseOrder.deliveryFullfillment) == null ? void 0 : L.findIndex(
2422
- (b) => r.deliveryOrder.fullfillmentId && b.id === r.deliveryOrder.fullfillmentId
2423
- )) ?? -1;
2424
- }
2425
- ), E = n.enablePurchaseOrderReceiveWithCustomCost, te = n.enablePortalDeliveryOrderWrite, se = re({}), Q = H(
2426
- () => (r.purchaseOrder.itemsAtSubmission ?? r.purchaseOrder.items).length
2427
- ), de = H(() => Ss(r.purchaseOrder)), Oe = H(
2428
- () => ks(r.purchaseOrder, de.value)
2429
- ), ae = H(
2430
- () => r.purchaseOrder.items.map(
2431
- (L, b) => H({
2432
- get: () => {
2433
- var J;
2434
- const j = (J = f.received[b]) == null ? void 0 : J.amount;
2435
- return j ? +$e(j) : 0;
2436
- },
2437
- set: (j) => {
2438
- f.received[b].amount = Qe(j, L.sku.unit.precision);
2439
- }
2440
- })
2441
- )
2442
- ), Se = H(
2443
- () => r.purchaseOrder.items.map(
2444
- (L, b) => H({
2445
- get: () => {
2446
- var J;
2447
- const j = (J = f.received[b]) == null ? void 0 : J.cost;
2448
- return j ? +$e(j) : 0;
2449
- },
2450
- set: (j) => {
2451
- f.received[b].cost = {
2452
- currency: Ce(),
2453
- ...Qe(j, 4)
2454
- };
2455
- }
2456
- })
2457
- )
2458
- );
2459
- function Ae(L) {
2460
- var j;
2461
- const b = !se.value[L];
2462
- if (se.value[L] = b, b) {
2463
- const J = (j = f.received[L]) == null ? void 0 : j.cost;
2464
- f.received[L].cost = J ? { ...J, precision: 4 } : { currency: Ce(), amount: 0, precision: 4 };
2465
- } else
2466
- delete f.received[L].cost;
2467
- }
2468
- const K = re([]), ve = H(
2469
- () => d.skus.filter((L) => !L.isInactive).map((L) => ({ label: `${L.name} (${L.code})`, value: L._id }))
2470
- );
2471
- function P() {
2472
- K.value.push({ skuId: null, costEnabled: !1 }), f.received.push({
2473
- sku: null,
2474
- amount: Fe.fromNumber(0),
2475
- measurement: null
2476
- });
2477
- }
2478
- function x(L) {
2479
- K.value.splice(L, 1), f.received.splice(Q.value + L, 1);
2480
- }
2481
- function w(L, b) {
2482
- K.value[L].skuId = b;
2483
- const j = b ? d.skuById[b] : null;
2484
- f.received[Q.value + L].sku = j;
2485
- }
2486
- function A(L, b) {
2487
- var ke, we;
2488
- const j = (ke = r.receivedInfoMap) == null ? void 0 : ke[b.sku._id], J = j ? `${s("inventory.transfer.receiveRequest.details.received")} ${Fe.toFormatString({ value: j.received })} / ${ft(b.quantity, b.sku.unit, b.measurement)}` : void 0;
2489
- return (((we = ae.value[L]) == null ? void 0 : we.value) ?? 0) > 0 ? J : J ? `${J} · ${ct}` : ct;
2490
- }
2491
- function G(L, b) {
2492
- var ke;
2493
- const J = (((ke = X.value[b]) == null ? void 0 : ke.value) ?? 0) <= 0;
2494
- let me;
2495
- if (L.skuId && Oe.value[L.skuId]) {
2496
- const we = Oe.value[L.skuId], o = Fe.toFormatString({ value: we.received });
2497
- me = `${s("inventory.transfer.receiveRequest.details.received")} ${o}`;
2498
- }
2499
- return J ? me ? `${me} · ${ct}` : ct : me;
2500
- }
2501
- const X = H(
2502
- () => K.value.map((L, b) => {
2503
- const j = Q.value + b;
2504
- return H({
2505
- get: () => {
2506
- var me;
2507
- const J = (me = f.received[j]) == null ? void 0 : me.amount;
2508
- return J ? +$e(J) : 0;
2509
- },
2510
- set: (J) => {
2511
- var ke, we, o;
2512
- const me = ((ke = L.historyItem) == null ? void 0 : ke.sku.unit.precision) ?? (L.skuId ? (o = (we = d.skuById[L.skuId]) == null ? void 0 : we.unit) == null ? void 0 : o.precision : void 0) ?? 2;
2513
- f.received[j].amount = Qe(J, me);
2514
- }
2515
- });
2516
- })
2517
- ), le = H(
2518
- () => K.value.map((L, b) => {
2519
- const j = Q.value + b;
2520
- return H({
2521
- get: () => {
2522
- var me;
2523
- const J = (me = f.received[j]) == null ? void 0 : me.cost;
2524
- return J ? +$e(J) : 0;
2525
- },
2526
- set: (J) => {
2527
- f.received[j].cost = {
2528
- currency: Ce(),
2529
- ...Qe(J, 4)
2530
- };
2531
- }
2532
- });
2533
- })
2534
- );
2535
- function g(L) {
2536
- const b = K.value[L], j = Q.value + L;
2537
- b.costEnabled = !b.costEnabled, b.costEnabled ? f.received[j].cost = { currency: Ce(), amount: 0, precision: 4 } : delete f.received[j].cost;
2538
- }
2539
- Ye(
2540
- () => u.value,
2541
- (L) => {
2542
- var o, l, $;
2543
- if (!L) {
2544
- K.value = [], se.value = {};
2545
- return;
2546
- }
2547
- _(r.deliveryOrder.priceAdjustments);
2548
- const b = r.purchaseOrder.itemsAtSubmission ?? r.purchaseOrder.items, j = new Set(b.map((C) => C.sku._id)), J = {}, me = [];
2549
- for (const C of r.deliveryOrder.received ?? []) {
2550
- const q = (o = C.sku) == null ? void 0 : o._id;
2551
- q && (j.has(q) ? J[q] = C : me.push(C));
2552
- }
2553
- f.received = b.map((C) => {
2554
- const q = J[C.sku._id];
2555
- return q ? { ...q } : {
2556
- // Propagate the stable id so V2 submissions match this existing PO line
2557
- // instead of the backend treating it as a new extra item (see CreateForm.vue).
2558
- ...a && C.id ? { id: C.id } : {},
2559
- sku: C.sku,
2560
- amount: Fe.fromNumber(0),
2561
- measurement: C.measurement ?? null
2562
- };
2563
- });
2564
- const ke = {};
2565
- for (let C = 0; C < b.length; C++)
2566
- (l = J[b[C].sku._id]) != null && l.cost && (ke[C] = !0);
2567
- se.value = ke, K.value = [];
2568
- const we = de.value;
2569
- for (const C of me) {
2570
- const q = we.find((Y) => {
2571
- var ye;
2572
- return Y.sku._id === ((ye = C.sku) == null ? void 0 : ye._id);
2573
- });
2574
- K.value.push({
2575
- skuId: (($ = C.sku) == null ? void 0 : $._id) ?? null,
2576
- costEnabled: !!C.cost,
2577
- locked: !0,
2578
- quantityLocked: !0,
2579
- historyItem: q
2580
- }), f.received.push({ ...C });
2581
- }
2582
- if (we.length) {
2583
- const C = new Set(me.map((q) => {
2584
- var Y;
2585
- return (Y = q.sku) == null ? void 0 : Y._id;
2586
- }));
2587
- for (const q of we)
2588
- C.has(q.sku._id) || (K.value.push({
2589
- skuId: q.sku._id,
2590
- costEnabled: !1,
2591
- locked: !0,
2592
- historyItem: q
2593
- }), f.received.push({
2594
- ...a && q.id ? { id: q.id } : {},
2595
- sku: q.sku,
2596
- amount: Fe.fromNumber(0),
2597
- measurement: q.measurement ?? null
2598
- }));
2599
- }
2600
- }
2601
- );
2602
- const D = re(!1);
2603
- function ie() {
2604
- D.value = !0, N.updateDeliveryOrder({
2605
- deliveryOrder: {
2606
- ...r.deliveryOrder,
2607
- ...f,
2608
- priceAdjustments: R.value.state().adjustments
2609
- },
2610
- purchaseOrderId: r.purchaseOrder._id,
2611
- purchaseOrderRev: r.purchaseOrder._rev
2612
- }).then(() => {
2613
- m.open(
2614
- {
2615
- title: "Success",
2616
- message: `PO# ${r.purchaseOrder.seqNumber} Changes have been saved`,
2617
- type: "success"
2618
- },
2619
- 1e4
2620
- ), u.value = !1, O("submitted");
2621
- }).finally(() => {
2622
- D.value = !1;
2623
- });
2624
- }
2625
- return (L, b) => {
2626
- const j = ne("FmButton"), J = ne("FmStepperField"), me = ne("FmSwitch"), ke = ne("FmSelect"), we = ne("FmTextField"), o = ne("FmDialog");
2627
- return i(), fe(o, {
2628
- modelValue: u.value,
2629
- "onUpdate:modelValue": b[1] || (b[1] = (l) => u.value = l),
2630
- overlay: !0,
2631
- "min-width": 800
2632
- }, {
2633
- "dialog-button": ue(() => [
2634
- y(te) ? (i(), fe(j, {
2635
- key: 0,
2636
- variant: "plain",
2637
- label: "Edit",
2638
- size: "md",
2639
- "prepend-icon": "edit"
2640
- })) : V("", !0)
2641
- ]),
2642
- "dialog-header": ue(() => [
2643
- e("div", null, "Received on " + k(y(et)(r.deliveryOrder.createdAt)), 1)
2644
- ]),
2645
- "dialog-footer": ue(() => [
2646
- T(j, {
2647
- class: "ml-auto",
2648
- label: "Apply changes",
2649
- size: "md",
2650
- variant: "destructive",
2651
- disabled: D.value,
2652
- loading: D.value,
2653
- onClick: ie
2654
- }, null, 8, ["disabled", "loading"])
2655
- ]),
2656
- default: ue(() => [
2657
- e("div", wo, [
2658
- e("div", $o, [
2659
- b[2] || (b[2] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Adjustment date", -1)),
2660
- e("div", Co, k(r.deliveryOrder.adjustment ? y(et)(new Date(y(mt)(r.deliveryOrder.adjustment))) : "-"), 1)
2661
- ]),
2662
- e("div", Ao, [
2663
- b[4] || (b[4] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, " Items going to receive ", -1)),
2664
- (i(!0), h(Ne, null, Te(r.purchaseOrder.items, (l, $) => {
2665
- var C;
2666
- return i(), h("div", { key: $ }, [
2667
- e("div", Do, [
2668
- e("div", No, [
2669
- e("span", Ro, k(l.sku.name), 1),
2670
- e("span", Po, k(l.sku.code), 1)
2671
- ]),
2672
- e("div", Fo, [
2673
- T(J, {
2674
- label: "Receive Quantity",
2675
- modelValue: ae.value[$].value,
2676
- "onUpdate:modelValue": (q) => ae.value[$].value = q,
2677
- "append-text": ((C = l.measurement) == null ? void 0 : C.abbrev) ?? l.sku.unit.abbrev,
2678
- "helper-text": A($, l)
2679
- }, null, 8, ["modelValue", "onUpdate:modelValue", "append-text", "helper-text"]),
2680
- y(E) ? (i(), h("div", Io, [
2681
- T(me, {
2682
- "model-value": se.value[$],
2683
- "onUpdate:modelValue": (q) => Ae($),
2684
- size: "sm"
2685
- }, null, 8, ["model-value", "onUpdate:modelValue"]),
2686
- b[3] || (b[3] = e("span", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " Override cost ", -1))
2687
- ])) : V("", !0),
2688
- y(E) && se.value[$] ? (i(), fe(J, {
2689
- key: 1,
2690
- modelValue: Se.value[$].value,
2691
- "onUpdate:modelValue": (q) => Se.value[$].value = q,
2692
- label: "Total Cost",
2693
- step: 1e-4,
2694
- min: 0,
2695
- placeholder: "0.0000",
2696
- size: "sm",
2697
- "append-text": y(Ce)()
2698
- }, null, 8, ["modelValue", "onUpdate:modelValue", "append-text"])) : V("", !0)
2699
- ])
2700
- ]),
2701
- $ < r.purchaseOrder.items.length - 1 ? (i(), h("div", To)) : V("", !0)
2702
- ]);
2703
- }), 128))
2704
- ]),
2705
- e("div", Eo, [
2706
- e("div", qo, [
2707
- b[5] || (b[5] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Extra items", -1)),
2708
- T(j, {
2709
- variant: "tertiary",
2710
- label: "Add item",
2711
- "prepend-icon": "add",
2712
- size: "md",
2713
- onClick: P
2714
- })
2715
- ]),
2716
- K.value.length === 0 ? (i(), h("div", Vo, " No extra items added ")) : V("", !0),
2717
- (i(!0), h(Ne, null, Te(K.value, (l, $) => {
2718
- var C, q;
2719
- return i(), h("div", { key: $ }, [
2720
- e("div", Lo, [
2721
- e("div", jo, [
2722
- T(ke, {
2723
- "model-value": l.skuId,
2724
- "onUpdate:modelValue": (Y) => w($, Y),
2725
- label: "Ingredient",
2726
- items: ve.value,
2727
- searchable: "",
2728
- searchTarget: "label",
2729
- placeholder: "Select ingredient",
2730
- disabled: l.locked
2731
- }, null, 8, ["model-value", "onUpdate:modelValue", "items", "disabled"])
2732
- ]),
2733
- e("div", Uo, [
2734
- T(J, {
2735
- label: "Receive Quantity",
2736
- modelValue: X.value[$].value,
2737
- "onUpdate:modelValue": (Y) => X.value[$].value = Y,
2738
- "append-text": l.skuId ? ((q = (C = y(d).skuById[l.skuId]) == null ? void 0 : C.unit) == null ? void 0 : q.abbrev) ?? "" : "",
2739
- "helper-text": G(l, $),
2740
- disabled: l.quantityLocked || !l.skuId
2741
- }, null, 8, ["modelValue", "onUpdate:modelValue", "append-text", "helper-text", "disabled"]),
2742
- y(E) ? (i(), h("div", Mo, [
2743
- T(me, {
2744
- "model-value": l.costEnabled,
2745
- "onUpdate:modelValue": (Y) => g($),
2746
- size: "sm"
2747
- }, null, 8, ["model-value", "onUpdate:modelValue"]),
2748
- b[6] || (b[6] = e("span", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " Override cost ", -1))
2749
- ])) : V("", !0),
2750
- y(E) && l.costEnabled ? (i(), fe(J, {
2751
- key: 1,
2752
- modelValue: le.value[$].value,
2753
- "onUpdate:modelValue": (Y) => le.value[$].value = Y,
2754
- label: "Total Cost",
2755
- step: 1e-4,
2756
- min: 0,
2757
- placeholder: "0.0000",
2758
- size: "sm",
2759
- "append-text": y(Ce)()
2760
- }, null, 8, ["modelValue", "onUpdate:modelValue", "append-text"])) : V("", !0)
2761
- ]),
2762
- l.locked ? V("", !0) : (i(), fe(j, {
2763
- key: 0,
2764
- variant: "tertiary",
2765
- "prepend-icon": "delete",
2766
- size: "md",
2767
- class: "mt-6",
2768
- onClick: (Y) => x($)
2769
- }, null, 8, ["onClick"]))
2770
- ]),
2771
- $ < K.value.length - 1 ? (i(), h("div", Bo)) : V("", !0)
2772
- ]);
2773
- }), 128))
2774
- ]),
2775
- e("div", zo, [
2776
- b[7] || (b[7] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Delivery order no.", -1)),
2777
- e("div", Ko, [
2778
- T(we, {
2779
- modelValue: y(f).deliveryOrderNumber,
2780
- "onUpdate:modelValue": b[0] || (b[0] = (l) => y(f).deliveryOrderNumber = l),
2781
- size: "md",
2782
- placeholder: r.deliveryOrder.deliveryOrderNumber
2783
- }, null, 8, ["modelValue", "placeholder"])
2784
- ])
2785
- ]),
2786
- e("div", Ho, [
2787
- b[8] || (b[8] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Remark", -1)),
2788
- e("div", Go, k(r.deliveryOrder.remark || "N/A"), 1)
2789
- ]),
2790
- y(n).enablePurchaseOrderPriceAdjustment ? (i(), fe(It, {
2791
- key: 0,
2792
- controller: y(R),
2793
- state: y(F)
2794
- }, null, 8, ["controller", "state"])) : V("", !0),
2795
- B.value >= 0 ? (i(), h("div", Wo, [
2796
- b[9] || (b[9] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Fulfilment's sequence", -1)),
2797
- e("div", Qo, k(B.value + 1), 1)
2798
- ])) : V("", !0)
2799
- ])
2800
- ]),
2801
- _: 1
2802
- }, 8, ["modelValue"]);
2803
- };
2804
- }
2805
- }), Jo = { class: "flex flex-col gap-3" }, Zo = { class: "flex flex-col gap-4" }, Xo = { class: "flex flex-col gap-4 fm-typo-en-body-lg-600" }, en = {
2806
- key: 0,
2807
- class: "flex flex-col gap-4"
2808
- }, tn = { class: "flex items-center justify-between" }, sn = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, rn = {
2809
- key: 0,
2810
- class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
2811
- }, on = { class: "flex gap-4" }, nn = { class: "flex-1" }, an = { class: "flex-1" }, ln = {
2812
- key: 0,
2813
- class: "flex items-center text-fm-color-system-error-300"
2814
- }, un = { class: "fm-typo-en-body-md-400" }, cn = { class: "flex flex-col gap-4" }, dn = { class: "flex justify-between items-start py-1 gap-4" }, mn = { class: "flex flex-col flex-1 min-w-0" }, pn = { class: "fm-typo-en-body-lg-600 truncate" }, fn = { class: "fm-typo-en-body-md-400 truncate" }, vn = { class: "flex flex-col gap-2 items-end w-52 shrink-0" }, yn = {
2815
- key: 0,
2816
- class: "fm-typo-en-body-sm-400 text-fm-color-system-error-300 self-end text-right"
2817
- }, hn = {
2818
- key: 1,
2819
- class: "flex items-center gap-2"
2820
- }, gn = {
2821
- key: 0,
2822
- class: "border-b border-fm-color-stroke-secondary"
2823
- }, bn = { class: "flex flex-col gap-4" }, _n = { class: "flex items-center justify-between" }, Sn = {
2824
- key: 0,
2825
- class: "fm-typo-en-body-md-400 text-fm-color-typo-tertiary"
2826
- }, kn = { class: "flex justify-between items-start py-1 gap-4" }, On = { class: "flex-1 min-w-0 flex flex-col gap-2" }, xn = { class: "flex flex-col gap-2 items-end w-52 shrink-0" }, wn = {
2827
- key: 0,
2828
- class: "fm-typo-en-body-sm-400 text-fm-color-system-error-300 self-end text-right"
2829
- }, $n = {
2830
- key: 1,
2831
- class: "flex items-center gap-2"
2832
- }, Cn = {
2833
- key: 0,
2834
- class: "border-b border-fm-color-stroke-secondary"
2835
- }, An = { class: "flex flex-col gap-4" }, Dn = { class: "flex flex-col gap-4" }, Nn = { class: "flex flex-col gap-4" }, Rn = { class: "flex flex-col gap-4 fm-typo-en-body-lg-600" }, rs = "Will be ignored on save (zero or negative quantity)", Pn = /* @__PURE__ */ Ve({
2836
- __name: "CreateForm",
2837
- props: {
2838
- purchaseOrder: {},
2839
- receivedInfoMap: {},
2840
- receivedMap: {}
2841
- },
2842
- emits: ["submitted"],
2843
- setup(c, { emit: t }) {
2844
- var ye, I, pe;
2845
- const { t: s } = ht(), n = re(!1), m = gt(), u = c, d = t, r = us("", {
2846
- default: {
2847
- deliveryOrderNumber: "",
2848
- remark: "",
2849
- received: (u.purchaseOrder.itemsAtSubmission ?? u.purchaseOrder.items).map((v) => {
2850
- var p;
2851
- return {
2852
- // Propagate the stable id so V2 submissions match this existing PO line instead
2853
- // of the backend's classify-received.ts treating it as a new extra item (which
2854
- // appends a duplicate item record with quantity = this delivery's amount, on
2855
- // every single delivery — inflating the PO's total ordered quantity forever).
2856
- ...(((p = u.purchaseOrder) == null ? void 0 : p.version) ?? Ue.enum[1]) === Ue.enum[2] && v.id ? { id: v.id } : {},
2857
- sku: v.sku,
2858
- amount: Fe.fromNumber(0),
2859
- measurement: v.measurement
2860
- };
2861
- }),
2862
- createdBy: {
2863
- id: ((ye = m.sessionUser.value) == null ? void 0 : ye.id) || "",
2864
- name: ((I = m.sessionUser.value) == null ? void 0 : I.displayName) || ""
2865
- },
2866
- createdAt: ""
2867
- }
2868
- }), a = Xe(), O = bt(), f = Je(), N = Nt(), {
2869
- controller: R,
2870
- state: F,
2871
- reset: _
2872
- } = Tt({ currency: Ce() }), B = H(
2873
- () => u.purchaseOrder.deliveryFullfillment != null
2874
- ), E = H(
2875
- () => f.enablePortalDeliveryOrderWrite && (u.purchaseOrder.status === be.Enum.RECEIVING || u.purchaseOrder.status === be.Enum.COMPLETE) && !B.value
2876
- ), te = f.enablePurchaseOrderReceiveWithCustomCost, se = f.enableBackdateReceive, Q = re({}), de = H(
2877
- () => u.purchaseOrder.itemsAtSubmission ?? u.purchaseOrder.items
2878
- ), Oe = H(() => Ss(u.purchaseOrder)), ae = H(
2879
- () => ks(u.purchaseOrder, Oe.value)
2880
- );
2881
- function Se(v) {
2882
- return v.sku._id ?? null;
2883
- }
2884
- const Ae = (((pe = u.purchaseOrder) == null ? void 0 : pe.version) ?? Ue.enum[1]) === Ue.enum[2], K = Ze(), ve = H({
2885
- get() {
2886
- if (!r.createdAt) return "";
2887
- const v = new Date(r.createdAt), p = v.getFullYear(), S = String(v.getMonth() + 1).padStart(2, "0"), U = String(v.getDate()).padStart(2, "0");
2888
- return `${p}-${S}-${U}`;
2889
- },
2890
- set(v) {
2891
- if (v) {
2892
- const p = r.createdAt ? new Date(r.createdAt) : /* @__PURE__ */ new Date(), [S, U, M] = v.split("-");
2893
- p.setFullYear(parseInt(S)), p.setMonth(parseInt(U) - 1), p.setDate(parseInt(M)), r.createdAt = p.toISOString();
2894
- }
2895
- }
2896
- }), P = H({
2897
- get() {
2898
- if (!r.createdAt) return "";
2899
- const v = new Date(r.createdAt), p = String(v.getHours()).padStart(2, "0"), S = String(v.getMinutes()).padStart(2, "0");
2900
- return `${p}:${S}`;
2901
- },
2902
- set(v) {
2903
- if (v) {
2904
- const p = r.createdAt ? new Date(r.createdAt) : /* @__PURE__ */ new Date(), [S, U] = v.split(":");
2905
- p.setHours(parseInt(S)), p.setMinutes(parseInt(U)), r.createdAt = p.toISOString();
2906
- }
2907
- }
2908
- }), x = H(() => {
2909
- const v = mt(u.purchaseOrder._id);
2910
- if (!v) return "";
2911
- const p = new Date(v), S = p.getFullYear(), U = String(p.getMonth() + 1).padStart(2, "0"), M = String(p.getDate()).padStart(2, "0");
2912
- return `${S}-${U}-${M}`;
2913
- }), w = H(() => {
2914
- const v = mt(u.purchaseOrder._id);
2915
- return v ? new Date(v) : null;
2916
- }), A = H(() => {
2917
- if (!ve.value || !P.value || !w.value) return null;
2918
- if (/* @__PURE__ */ new Date(`${ve.value}T${P.value}:00`) < w.value) {
2919
- 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}`;
2920
- return `Delivery date & time cannot be earlier than order creation (${p} ${xe})`;
2921
- }
2922
- return null;
2923
- }), G = H(() => A.value || ee.value.some((p) => !p.skuId) ? !1 : r.received.some((p) => {
2924
- const S = p.amount;
2925
- return S ? +$e(S) > 0 : !1;
2926
- }));
2927
- function X(v) {
2928
- var U;
2929
- const p = (U = u.receivedInfoMap[v.sku._id]) == null ? void 0 : U.received, S = p != null ? Fe.toFormatString({ value: p }) : "0";
2930
- return `${s("inventory.transfer.receiveRequest.details.received")} ${S} / ${ft(v.quantity, v.sku.unit, v.measurement)}`;
2931
- }
2932
- function le() {
2933
- r.createdAt = "";
2934
- }
2935
- const g = H(() => de.value.map((v, p) => H({
2936
- get: () => {
2937
- var U;
2938
- const S = (U = r.received[p]) == null ? void 0 : U.amount;
2939
- return S ? +$e(S) : 0;
2940
- },
2941
- set: (S) => {
2942
- var M;
2943
- const U = ((M = de.value[p]) == null ? void 0 : M.sku.unit.precision) ?? 2;
2944
- r.received[p].amount = Qe(S, U);
2945
- }
2946
- })));
2947
- function D(v) {
2948
- const p = !Q.value[v];
2949
- if (Q.value[v] = p, p) {
2950
- const S = de.value[v];
2951
- S.totalCost ? r.received[v].cost = {
2952
- currency: S.totalCost.currency,
2953
- amount: S.totalCost.amount,
2954
- precision: 4
2955
- // Standardize to 4 decimals
2956
- } : r.received[v].cost = {
2957
- currency: Ce(),
2958
- amount: 0,
2959
- precision: 4
2960
- };
2961
- } else
2962
- delete r.received[v].cost;
2963
- }
2964
- const ie = H(() => de.value.map((v, p) => H({
2965
- get: () => {
2966
- var U;
2967
- const S = (U = r.received[p]) == null ? void 0 : U.cost;
2968
- return S ? +$e(S) : 0;
2969
- },
2970
- set: (S) => {
2971
- r.received[p].cost = {
2972
- currency: Ce(),
2973
- ...Qe(S, 4)
2974
- };
2975
- }
2976
- }))), ee = re([]), L = H(
2977
- () => N.skus.filter((v) => !v.isInactive).map((v) => ({ label: `${v.name} (${v.code})`, value: v._id }))
2978
- ), b = H(() => de.value.length);
2979
- function j() {
2980
- ee.value.push({ skuId: null, stableKey: null, costEnabled: !1 }), r.received.push({
2981
- sku: null,
2982
- amount: Fe.fromNumber(0),
2983
- measurement: null
2984
- });
2985
- }
2986
- function J(v) {
2987
- ee.value.splice(v, 1), r.received.splice(b.value + v, 1);
2988
- }
2989
- function me(v, p) {
2990
- ee.value[v].skuId = p;
2991
- const S = p ? N.skuById[p] : null;
2992
- r.received[b.value + v].sku = S;
2993
- }
2994
- function ke(v) {
2995
- const p = v.stableKey;
2996
- if (p && ae.value[p]) {
2997
- const S = ae.value[p], U = Fe.toFormatString({ value: S.received });
2998
- return `${s("inventory.transfer.receiveRequest.details.received")} ${U}`;
2999
- }
3000
- }
3001
- const we = H(
3002
- () => ee.value.map((v, p) => {
3003
- const S = b.value + p;
3004
- return H({
3005
- get: () => {
3006
- var M;
3007
- const U = (M = r.received[S]) == null ? void 0 : M.amount;
3008
- return U ? +$e(U) : 0;
3009
- },
3010
- set: (U) => {
3011
- var xe, W, Z;
3012
- 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 = N.skuById[M.skuId]) == null ? void 0 : W.unit) == null ? void 0 : Z.precision : void 0) ?? 2;
3013
- r.received[S].amount = Qe(U, _e);
3014
- }
3015
- });
3016
- })
3017
- ), o = H(
3018
- () => ee.value.map((v, p) => {
3019
- const S = b.value + p;
3020
- return H({
3021
- get: () => {
3022
- var M;
3023
- const U = (M = r.received[S]) == null ? void 0 : M.cost;
3024
- return U ? +$e(U) : 0;
3025
- },
3026
- set: (U) => {
3027
- r.received[S].cost = {
3028
- currency: Ce(),
3029
- ...Qe(U, 4)
3030
- };
3031
- }
3032
- });
3033
- })
3034
- );
3035
- function l(v) {
3036
- const p = ee.value[v], S = b.value + v;
3037
- p.costEnabled = !p.costEnabled, p.costEnabled ? r.received[S].cost = { currency: Ce(), amount: 0, precision: 4 } : delete r.received[S].cost;
3038
- }
3039
- function $() {
3040
- Y() && O.open({
3041
- title: "Confirm Create Delivery Order",
3042
- message: `Are you sure you want to create delivery order for PO# ${u.purchaseOrder.seqNumber}?`,
3043
- primaryActions: {
3044
- text: "Create",
3045
- close: !0,
3046
- variant: "primary"
3047
- },
3048
- secondaryActions: {
3049
- text: "Cancel",
3050
- close: !0
3051
- }
3052
- }).onPrimary(() => q());
3053
- }
3054
- const C = re(!1);
3055
- function q() {
3056
- Y() && (C.value = !0, a.createDeliveryOrder({
3057
- deliveryOrder: {
3058
- ...r,
3059
- priceAdjustments: R.value.state().adjustments
3060
- },
3061
- purchaseOrderId: u.purchaseOrder._id,
3062
- purchaseOrderRev: u.purchaseOrder._rev,
3063
- currency: Ce()
3064
- }).then(() => {
3065
- K.open(
3066
- {
3067
- title: "Success",
3068
- message: `New delivery order created for PO# ${u.purchaseOrder.seqNumber}`,
3069
- type: "success"
3070
- },
3071
- 1e4
3072
- ), n.value = !1, d("submitted");
3073
- }).finally(() => {
3074
- C.value = !1;
3075
- }));
3076
- }
3077
- function Y() {
3078
- return B.value ? (n.value = !1, K.open(
3079
- {
3080
- title: "Purchase order updated",
3081
- message: "This purchase order now uses fulfillment receiving. Refresh and receive stock from the fulfillment section.",
3082
- type: "error"
3083
- },
3084
- 1e4
3085
- ), !1) : !0;
3086
- }
3087
- return Ye(B, (v) => {
3088
- !v || !n.value || Y();
3089
- }), Ye(
3090
- () => n.value,
3091
- (v) => {
3092
- var U;
3093
- if (!v) {
3094
- ee.value = [], _([]), r.received = de.value.map((M) => ({
3095
- ...Ae && M.id ? { id: M.id } : {},
3096
- sku: M.sku,
3097
- amount: Fe.fromNumber(0),
3098
- measurement: M.measurement
3099
- }));
3100
- return;
3101
- }
3102
- const p = de.value;
3103
- for (let M = 0; M < p.length; M++) {
3104
- 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], ge = +$e(_e.quantity), Pe = Z ? +$e(Z.received) : 0;
3105
- g.value[M].value = Math.max(0, ge - Pe);
3106
- }
3107
- const S = Oe.value;
3108
- if (S.length) {
3109
- for (const M of S) {
3110
- const _e = Se(M);
3111
- ee.value.push({
3112
- skuId: M.sku._id,
3113
- stableKey: _e,
3114
- costEnabled: !1,
3115
- historyItem: M
3116
- }), r.received.push({
3117
- // Propagate the stable id so V2 submissions align with the existing PO line.
3118
- ...Ae && M.id ? { id: M.id } : {},
3119
- sku: M.sku,
3120
- amount: Fe.fromNumber(0),
3121
- measurement: M.measurement ?? null
3122
- });
3123
- }
3124
- for (let M = 0; M < S.length; M++) {
3125
- const _e = Se(S[M]), xe = _e ? ae.value[_e] : void 0;
3126
- if (xe) {
3127
- const W = Math.pow(10, xe.remaining.precision ?? 2);
3128
- we.value[M].value = Math.max(0, xe.remaining.amount / W);
3129
- }
3130
- }
3131
- }
3132
- }
3133
- ), (v, p) => {
3134
- const S = ne("FmButton"), U = ne("FmDatePicker"), M = ne("FmTimePicker"), _e = ne("FmIcon"), xe = ne("FmStepperField"), W = ne("FmSwitch"), Z = ne("FmSelect"), ge = ne("FmTextField"), Pe = ne("FmDialog");
3135
- return i(), fe(Pe, {
3136
- modelValue: n.value,
3137
- "onUpdate:modelValue": p[4] || (p[4] = (Ie) => n.value = Ie),
3138
- overlay: !0,
3139
- "min-width": 800
3140
- }, {
3141
- "dialog-button": ue(() => [
3142
- E.value ? (i(), fe(S, {
3143
- key: 0,
3144
- variant: "primary",
3145
- label: "Create",
3146
- size: "md",
3147
- "prepend-icon": "add",
3148
- class: "w-full"
3149
- })) : V("", !0)
3150
- ]),
3151
- "dialog-header": ue(() => [
3152
- e("div", null, "Order #" + k(u.purchaseOrder.seqNumber) + " (New Delivery Order)", 1)
3153
- ]),
3154
- "dialog-footer": ue(() => [
3155
- T(S, {
3156
- class: "ml-auto",
3157
- label: "Create",
3158
- size: "md",
3159
- variant: "destructive",
3160
- disabled: !G.value || C.value,
3161
- loading: C.value,
3162
- onClick: $
3163
- }, null, 8, ["disabled", "loading"])
3164
- ]),
3165
- default: ue(() => {
3166
- var Ie;
3167
- return [
3168
- e("div", Jo, [
3169
- e("div", Zo, [
3170
- p[5] || (p[5] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Received by", -1)),
3171
- e("div", Xo, k((Ie = y(m).sessionUser.value) == null ? void 0 : Ie.displayName), 1)
3172
- ]),
3173
- y(se) ? (i(), h("div", en, [
3174
- e("div", tn, [
3175
- e("div", sn, [
3176
- p[6] || (p[6] = Ge(" Delivery Date & Time ")),
3177
- !ve.value && !P.value ? (i(), h("div", rn, " Leave blank to use current date & time ")) : V("", !0)
3178
- ]),
3179
- ve.value || P.value ? (i(), fe(S, {
3180
- key: 0,
3181
- variant: "tertiary",
3182
- label: "Clear",
3183
- "prepend-icon": "close",
3184
- onClick: le
3185
- })) : V("", !0)
3186
- ]),
3187
- e("div", on, [
3188
- e("div", nn, [
3189
- T(U, {
3190
- modelValue: ve.value,
3191
- "onUpdate:modelValue": p[0] || (p[0] = (he) => ve.value = he)
3192
- }, null, 8, ["modelValue"])
3193
- ]),
3194
- e("div", an, [
3195
- T(M, {
3196
- modelValue: P.value,
3197
- "onUpdate:modelValue": p[1] || (p[1] = (he) => P.value = he)
3198
- }, null, 8, ["modelValue"])
3199
- ])
3200
- ]),
3201
- A.value ? (i(), h("div", ln, [
3202
- T(_e, {
3203
- name: "error",
3204
- class: "inline-block mr-1",
3205
- size: "sm"
3206
- }),
3207
- e("div", un, k(A.value), 1)
3208
- ])) : V("", !0)
3209
- ])) : V("", !0),
3210
- e("div", cn, [
3211
- p[8] || (p[8] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, " Items going to receive ", -1)),
3212
- (i(!0), h(Ne, null, Te(de.value, (he, ce) => {
3213
- var Re;
3214
- return i(), h("div", { key: ce }, [
3215
- e("div", dn, [
3216
- e("div", mn, [
3217
- e("span", pn, k(he.sku.name), 1),
3218
- e("span", fn, k(he.sku.code), 1)
3219
- ]),
3220
- e("div", vn, [
3221
- T(xe, {
3222
- label: "Receive Quantity",
3223
- modelValue: g.value[ce].value,
3224
- "onUpdate:modelValue": (Ee) => g.value[ce].value = Ee,
3225
- "helper-text": X(he),
3226
- "append-text": ((Re = he.measurement) == null ? void 0 : Re.abbrev) ?? he.sku.unit.abbrev
3227
- }, null, 8, ["modelValue", "onUpdate:modelValue", "helper-text", "append-text"]),
3228
- g.value[ce].value <= 0 ? (i(), h("div", yn, k(rs))) : V("", !0),
3229
- y(te) ? (i(), h("div", hn, [
3230
- T(W, {
3231
- "model-value": Q.value[ce],
3232
- "onUpdate:modelValue": (Ee) => D(ce),
3233
- size: "sm"
3234
- }, null, 8, ["model-value", "onUpdate:modelValue"]),
3235
- p[7] || (p[7] = e("span", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " Override cost ", -1))
3236
- ])) : V("", !0),
3237
- y(te) && Q.value[ce] ? (i(), fe(xe, {
3238
- key: 2,
3239
- modelValue: ie.value[ce].value,
3240
- "onUpdate:modelValue": (Ee) => ie.value[ce].value = Ee,
3241
- label: "Total Cost",
3242
- step: 1e-4,
3243
- min: 0,
3244
- placeholder: "0.0000",
3245
- size: "sm",
3246
- "append-text": y(Ce)()
3247
- }, null, 8, ["modelValue", "onUpdate:modelValue", "append-text"])) : V("", !0)
3248
- ])
3249
- ]),
3250
- ce < de.value.length - 1 ? (i(), h("div", gn)) : V("", !0)
3251
- ]);
3252
- }), 128))
3253
- ]),
3254
- e("div", bn, [
3255
- e("div", _n, [
3256
- p[9] || (p[9] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Extra items", -1)),
3257
- T(S, {
3258
- variant: "tertiary",
3259
- label: "Add item",
3260
- "prepend-icon": "add",
3261
- size: "md",
3262
- onClick: j
3263
- })
3264
- ]),
3265
- ee.value.length === 0 ? (i(), h("div", Sn, " No extra items added ")) : V("", !0),
3266
- (i(!0), h(Ne, null, Te(ee.value, (he, ce) => {
3267
- var Re, Ee;
3268
- return i(), h("div", { key: ce }, [
3269
- e("div", kn, [
3270
- e("div", On, [
3271
- T(Z, {
3272
- "model-value": he.skuId,
3273
- "onUpdate:modelValue": (Le) => me(ce, Le),
3274
- label: "Ingredient",
3275
- items: L.value,
3276
- searchable: "",
3277
- searchTarget: "label",
3278
- placeholder: "Select ingredient",
3279
- disabled: !!he.historyItem
3280
- }, null, 8, ["model-value", "onUpdate:modelValue", "items", "disabled"])
3281
- ]),
3282
- e("div", xn, [
3283
- T(xe, {
3284
- label: "Receive Quantity",
3285
- modelValue: we.value[ce].value,
3286
- "onUpdate:modelValue": (Le) => we.value[ce].value = Le,
3287
- "append-text": he.skuId ? ((Ee = (Re = y(N).skuById[he.skuId]) == null ? void 0 : Re.unit) == null ? void 0 : Ee.abbrev) ?? "" : "",
3288
- "helper-text": ke(he)
3289
- }, null, 8, ["modelValue", "onUpdate:modelValue", "append-text", "helper-text"]),
3290
- we.value[ce].value <= 0 ? (i(), h("div", wn, k(rs))) : V("", !0),
3291
- y(te) ? (i(), h("div", $n, [
3292
- T(W, {
3293
- "model-value": he.costEnabled,
3294
- "onUpdate:modelValue": (Le) => l(ce),
3295
- size: "sm"
3296
- }, null, 8, ["model-value", "onUpdate:modelValue"]),
3297
- p[10] || (p[10] = e("span", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " Override cost ", -1))
3298
- ])) : V("", !0),
3299
- y(te) && he.costEnabled ? (i(), fe(xe, {
3300
- key: 2,
3301
- modelValue: o.value[ce].value,
3302
- "onUpdate:modelValue": (Le) => o.value[ce].value = Le,
3303
- label: "Total Cost",
3304
- step: 1e-4,
3305
- min: 0,
3306
- placeholder: "0.0000",
3307
- size: "sm",
3308
- "append-text": y(Ce)()
3309
- }, null, 8, ["modelValue", "onUpdate:modelValue", "append-text"])) : V("", !0)
3310
- ]),
3311
- he.historyItem ? V("", !0) : (i(), fe(S, {
3312
- key: 0,
3313
- variant: "tertiary",
3314
- "prepend-icon": "delete",
3315
- size: "md",
3316
- class: "mt-6",
3317
- onClick: (Le) => J(ce)
3318
- }, null, 8, ["onClick"]))
3319
- ]),
3320
- ce < ee.value.length - 1 ? (i(), h("div", Cn)) : V("", !0)
3321
- ]);
3322
- }), 128))
3323
- ]),
3324
- e("div", An, [
3325
- p[11] || (p[11] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Delivery order no.", -1)),
3326
- e("div", Dn, [
3327
- T(ge, {
3328
- modelValue: y(r).deliveryOrderNumber,
3329
- "onUpdate:modelValue": p[2] || (p[2] = (he) => y(r).deliveryOrderNumber = he),
3330
- size: "md"
3331
- }, null, 8, ["modelValue"])
3332
- ])
3333
- ]),
3334
- e("div", Nn, [
3335
- p[12] || (p[12] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Remark", -1)),
3336
- e("div", Rn, [
3337
- T(ge, {
3338
- modelValue: y(r).remark,
3339
- "onUpdate:modelValue": p[3] || (p[3] = (he) => y(r).remark = he),
3340
- size: "md"
3341
- }, null, 8, ["modelValue"])
3342
- ])
3343
- ]),
3344
- y(f).enablePurchaseOrderPriceAdjustment ? (i(), fe(It, {
3345
- key: 1,
3346
- controller: y(R),
3347
- state: y(F)
3348
- }, null, 8, ["controller", "state"])) : V("", !0)
3349
- ])
3350
- ];
3351
- }),
3352
- _: 1
3353
- }, 8, ["modelValue"]);
3354
- };
3355
- }
3356
- }), Fn = {
3357
- key: 0,
3358
- class: "flex flex-col gap-1"
3359
- }, In = { class: "truncate" }, Tn = { class: "shrink-0" }, En = /* @__PURE__ */ Ve({
3360
- __name: "PriceAdjustmentList",
3361
- props: {
3362
- adjustments: {}
3363
- },
3364
- setup(c) {
3365
- const t = c, s = H(() => t.adjustments ?? []);
3366
- function n(m) {
3367
- const u = m.amount < 0 ? "-" : "+", d = $e({ ...m, amount: Math.abs(m.amount) });
3368
- return `${u}${m.currency} ${d}`;
3369
- }
3370
- return (m, u) => s.value.length ? (i(), h("div", Fn, [
3371
- (i(!0), h(Ne, null, Te(s.value, (d) => (i(), h("div", {
3372
- key: d.id,
3373
- class: "flex justify-between gap-4 fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
3374
- }, [
3375
- e("span", In, k(d.name), 1),
3376
- e("span", Tn, k(n(d.dinero)), 1)
3377
- ]))), 128))
3378
- ])) : V("", !0);
3379
- }
3380
- }), qn = { class: "flex flex-col gap-3" }, Vn = /* @__PURE__ */ Ve({
3381
- __name: "PriceAdjustmentEditForm",
3382
- props: {
3383
- purchaseOrder: {}
3384
- },
3385
- emits: ["submitted"],
3386
- setup(c, { emit: t }) {
3387
- const s = c, n = t, m = Xe(), u = Ze(), d = re(!1), r = re(!1), { controller: a, state: O, reset: f } = Tt({
3388
- currency: Ce(),
3389
- adjustments: s.purchaseOrder.priceAdjustments
3390
- });
3391
- Ye(
3392
- () => d.value,
3393
- (R) => {
3394
- R && f(s.purchaseOrder.priceAdjustments);
3395
- }
3396
- );
3397
- function N() {
3398
- r.value = !0, m.updatePurchaseOrder({
3399
- ...s.purchaseOrder,
3400
- priceAdjustments: a.value.state().adjustments
3401
- }).then(() => {
3402
- u.open(
3403
- {
3404
- title: "Success",
3405
- message: `PO# ${s.purchaseOrder.seqNumber} price adjustments saved`,
3406
- type: "success"
3407
- },
3408
- 1e4
3409
- ), d.value = !1, n("submitted");
3410
- }).finally(() => {
3411
- r.value = !1;
3412
- });
3413
- }
3414
- return (R, F) => {
3415
- const _ = ne("FmButton"), B = ne("FmDialog");
3416
- return i(), fe(B, {
3417
- modelValue: d.value,
3418
- "onUpdate:modelValue": F[0] || (F[0] = (E) => d.value = E),
3419
- overlay: !0,
3420
- "min-width": 600
3421
- }, {
3422
- "dialog-button": ue(() => [
3423
- T(_, {
3424
- variant: "plain",
3425
- label: "Edit price adjustments",
3426
- size: "md",
3427
- "prepend-icon": "edit"
3428
- })
3429
- ]),
3430
- "dialog-header": ue(() => [
3431
- e("div", null, "Price adjustments — PO# " + k(s.purchaseOrder.seqNumber), 1)
3432
- ]),
3433
- "dialog-footer": ue(() => [
3434
- T(_, {
3435
- class: "ml-auto",
3436
- label: "Apply changes",
3437
- size: "md",
3438
- variant: "destructive",
3439
- disabled: r.value,
3440
- loading: r.value,
3441
- onClick: N
3442
- }, null, 8, ["disabled", "loading"])
3443
- ]),
3444
- default: ue(() => [
3445
- e("div", qn, [
3446
- T(It, {
3447
- controller: y(a),
3448
- state: y(O)
3449
- }, null, 8, ["controller", "state"])
3450
- ])
3451
- ]),
3452
- _: 1
3453
- }, 8, ["modelValue"]);
3454
- };
3455
- }
3456
- }), Ln = { class: "flex flex-row-reverse" }, jn = {
3457
- key: 0,
3458
- class: "flex"
3459
- }, Un = {
3460
- key: 1,
3461
- class: "border-t pt-6"
3462
- }, Mn = { class: "fm-typo-en-body-lg-600 mb-4 flex items-center gap-2" }, Bn = { class: "border border-fm-color-neutral-gray-200 fm-corner-radius-lg overflow-y-auto" }, zn = { class: "w-full" }, Kn = {
3463
- class: "p-3 fm-typo-en-body-sm-600",
3464
- style: { "min-width": "130px" }
3465
- }, 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-400 text-fm-color-typo-secondary" }, Zn = { class: "p-3 fm-typo-en-body-sm-600" }, Xn = { key: 2 }, ea = /* @__PURE__ */ Ve({
3466
- __name: "NetSuiteTransactionChangeLog",
3467
- props: {
3468
- netsuiteId: {}
3469
- },
3470
- setup(c) {
3471
- const t = c, s = Ft(), n = re(!1), m = re(!1), u = re(!1), d = re([]);
3472
- async function r() {
3473
- if (!(d.value.length > 0))
3474
- try {
3475
- m.value = !0;
3476
- const f = await s.getChangeLogs(t.netsuiteId);
3477
- d.value = f, u.value = !1;
3478
- } catch {
3479
- u.value = !0;
3480
- } finally {
3481
- m.value = !1;
3482
- }
3483
- }
3484
- function a(f) {
3485
- switch (f) {
3486
- case Me.Create:
3487
- return "text-green-600 bg-green-100";
3488
- case Me.Set:
3489
- return "text-blue-600 bg-blue-100";
3490
- case Me.Change:
3491
- return "text-yellow-600 bg-yellow-100";
3492
- case Me.Unset:
3493
- return "text-red-600 bg-red-100";
3494
- default:
3495
- return "text-gray-600 bg-gray-100";
3496
- }
3497
- }
3498
- function O(f) {
3499
- return new Date(f).toLocaleDateString("en-US", {
3500
- year: "numeric",
3501
- month: "short",
3502
- day: "numeric",
3503
- hour: "2-digit",
3504
- minute: "2-digit"
3505
- });
3506
- }
3507
- return (f, N) => {
3508
- const R = ne("FmButton"), F = ne("FmCircularProgress"), _ = ne("FmIcon"), B = ne("FmDialog");
3509
- return i(), h("div", Ln, [
3510
- T(B, {
3511
- modelValue: n.value,
3512
- "onUpdate:modelValue": N[2] || (N[2] = (E) => n.value = E),
3513
- overlay: !0,
3514
- "max-width": 800
3515
- }, {
3516
- "dialog-button": ue(() => [
3517
- T(R, {
3518
- "prepend-icon": "info",
3519
- variant: "secondary",
3520
- label: "NetSuite",
3521
- onClick: N[0] || (N[0] = (E) => r()),
3522
- "text-color": "primary",
3523
- "bg-color": "transparent",
3524
- "border-color": "primary"
3525
- })
3526
- ]),
3527
- "dialog-header": ue(() => N[3] || (N[3] = [
3528
- e("div", null, "NetSuite info", -1)
3529
- ])),
3530
- default: ue(() => [
3531
- m.value ? (i(), h("div", jn, [
3532
- N[4] || (N[4] = e("span", null, "Change Log Loading...", -1)),
3533
- T(F, { size: "md" })
3534
- ])) : V("", !0),
3535
- !m.value && d.value.length > 0 ? (i(), h("div", Un, [
3536
- e("h3", Mn, [
3537
- T(_, {
3538
- name: "error",
3539
- color: "#ff9500",
3540
- size: "sm"
3541
- }),
3542
- N[5] || (N[5] = Ge(" Change Logs "))
3543
- ]),
3544
- e("div", Bn, [
3545
- e("table", zn, [
3546
- N[6] || (N[6] = e("thead", { class: "bg-fm-color-neutral-gray-50" }, [
3547
- e("tr", { class: "border-b border-fm-color-neutral-gray-200" }, [
3548
- e("th", {
3549
- class: "text-left p-3 fm-typo-en-body-md-600",
3550
- style: { "min-width": "130px" }
3551
- }, " Date "),
3552
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Role"),
3553
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Name"),
3554
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Context"),
3555
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Type"),
3556
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Line ID"),
3557
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Field"),
3558
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Old Value"),
3559
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "New Value")
3560
- ])
3561
- ], -1)),
3562
- e("tbody", null, [
3563
- (i(!0), h(Ne, null, Te(d.value, (E, te) => (i(), h("tr", {
3564
- key: te,
3565
- class: "border-b border-fm-color-neutral-gray-200 last:border-b-0"
3566
- }, [
3567
- e("td", Kn, k(O(E._dateiso8601)), 1),
3568
- e("td", Hn, k(E._rolename), 1),
3569
- e("td", Gn, k(E._employeename), 1),
3570
- e("td", Wn, k(E._contextname), 1),
3571
- e("td", {
3572
- class: We(`p-3 fm-typo-en-body-sm-600 ${a(Number(E.type) - 1)}`)
3573
- }, k(y(Me)[Number(E.type) - 1]), 3),
3574
- e("td", Qn, k(E.lineid || ""), 1),
3575
- e("td", Yn, k(E._fieldname), 1),
3576
- e("td", Jn, k(E.oldvalue || ""), 1),
3577
- e("td", Zn, k(E.newvalue || ""), 1)
3578
- ]))), 128))
3579
- ])
3580
- ])
3581
- ])
3582
- ])) : (i(), h("div", Xn, N[7] || (N[7] = [
3583
- e("p", null, "No change logs available.", -1)
3584
- ])))
3585
- ]),
3586
- "dialog-footer": ue(() => [
3587
- T(R, {
3588
- class: "ml-auto sm:w-full xs:w-full",
3589
- label: "Close",
3590
- size: "md",
3591
- variant: "primary",
3592
- onClick: N[1] || (N[1] = (E) => n.value = !1)
3593
- })
3594
- ]),
3595
- _: 1
3596
- }, 8, ["modelValue"])
3597
- ]);
3598
- };
3599
- }
3600
- }), ta = { class: "flex flex-col w-full gap-3" }, sa = { class: "flex" }, ra = { class: "fm-typo-en-title-md-600 text-fm-color-typo-primary" }, oa = { class: "flex flex-col gap-16 w-full h-full" }, na = { class: "flex justify-between" }, aa = { class: "fm-typo-en-body-lg-600" }, la = { class: "flex gap-2" }, ia = {
3601
- key: 0,
3602
- class: "flex items-center gap-1"
3603
- }, ua = { class: "fm-typo-en-body-md-400" }, ca = { class: "flex flex-col gap-8" }, da = {
3604
- key: 0,
3605
- class: "flex items-start justify-between gap-6"
3606
- }, ma = { class: "text-xs font-mono text-right break-all" }, pa = {
3607
- key: 1,
3608
- class: "flex items-start justify-between gap-6"
3609
- }, fa = { class: "fm-typo-en-body-sm-600" }, va = {
3610
- key: 2,
3611
- class: "flex items-start justify-between gap-6"
3612
- }, ya = { class: "text-xs font-mono text-right break-all" }, ha = {
3613
- key: 3,
3614
- class: "flex items-start justify-between gap-6"
3615
- }, ga = { class: "text-xs font-mono text-right break-all" }, ba = { class: "flex flex-col gap-4" }, _a = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Sa = { class: "flex gap-1" }, ka = { class: "fm-typo-en-body-lg-600" }, Oa = {
3616
- key: 0,
3617
- class: "flex flex-col gap-4"
3618
- }, xa = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, wa = { class: "fm-typo-en-body-lg-600" }, $a = { class: "flex flex-col gap-4" }, Ca = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Aa = { class: "fm-typo-en-body-lg-600" }, Da = {
3619
- key: 1,
3620
- class: "flex flex-col gap-4"
3621
- }, Na = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Ra = { class: "fm-typo-en-body-lg-600" }, Pa = {
3622
- key: 2,
3623
- class: "flex flex-col gap-4"
3624
- }, Fa = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Ia = { class: "fm-typo-en-body-lg-600" }, Ta = {
3625
- key: 3,
3626
- class: "flex flex-col gap-4"
3627
- }, Ea = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, qa = { class: "fm-typo-en-body-lg-600" }, Va = {
3628
- key: 4,
3629
- class: "flex flex-col gap-4"
3630
- }, La = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, ja = { class: "fm-typo-en-body-lg-600" }, Ua = {
3631
- key: 5,
3632
- class: "flex flex-col gap-4"
3633
- }, Ma = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Ba = { class: "fm-typo-en-body-lg-600" }, za = { class: "border border-fm-color-neutral-gray-200 fm-corner-radius-lg p-16" }, Ka = { class: "flex flex-col gap-8" }, Ha = { class: "flex gap-8 items-center" }, Ga = { class: "flex-1 fm-typo-en-body-lg-600" }, Wa = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary flex flex-col gap-4" }, Qa = { class: "flex w-full gap-4" }, Ya = { class: "basis-1/2 shrink-0 grow fm-typo-en-body-lg-400 line-clamp-2 flex items-center gap-2" }, Ja = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary flex flex-col gap-2" }, Za = { class: "fm-typo-en-body-lg-400 line-clamp-2" }, Xa = ["innerHTML"], el = { class: "flex w-full gap-4 fm-typo-en-body-sm-400" }, tl = { class: "grow fm-typo-en-body-lg-400 text-fm-color-typo-secondary line-clamp-1" }, sl = { class: "flex items-center gap-4" }, rl = { class: "line-clamp-1 fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, ol = {
3634
- key: 0,
3635
- class: "inline-flex items-center gap-1 text-xs font-medium text-gray-500 bg-gray-100 px-2 py-0.5 rounded-full"
3636
- }, nl = { class: "py-8" }, al = { class: "flex justify-end gap-4 items-center" }, ll = { class: "fm-typo-en-body-lg-600" }, il = {
3637
- key: 0,
3638
- class: "flex justify-end"
3639
- }, ul = {
3640
- key: 1,
3641
- class: "flex-1 xs:w-screen xs:max-w-full"
3642
- }, cl = {
3643
- key: 0,
3644
- class: "flex flex-col items-center gap-8 h-full"
3645
- }, dl = ["src"], ml = { class: "fm-typo-en-body-lg-600" }, pl = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary px-16" }, fl = {
3646
- key: 1,
3647
- class: "px-4 flex flex-col"
3648
- }, vl = { class: "flex gap-12 content-stretch" }, yl = {
3649
- class: "flex flex-col w-40",
3650
- name: "circles"
3651
- }, hl = { class: "flex-1 flex flex-col items-center" }, gl = { 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" }, _l = { class: "flex w-full items-center gap-4" }, Sl = {
3652
- class: "py-12 flex flex-col gap-4",
3653
- name: "received-at header"
3654
- }, kl = { class: "fm-typo-en-body-lg-400" }, Ol = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, xl = { class: "ml-auto flex gap-1" }, wl = { class: "flex gap-12 content-stretch" }, $l = {
3655
- class: "flex flex-col w-40",
3656
- name: "circles"
3657
- }, Cl = { class: "flex-1 flex flex-col items-center" }, Al = {
3658
- class: "py-12 flex flex-col gap-4 flex-1",
3659
- name: "delivery details"
3660
- }, Dl = { class: "flex flex-col gap-8" }, Nl = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, Rl = { class: "flex flex-col gap-4" }, Pl = {
3661
- key: 2,
3662
- class: "flex-1 xs:w-screen xs:max-w-full"
3663
- }, Fl = {
3664
- key: 0,
3665
- class: "flex flex-col items-center gap-8 h-full"
3666
- }, Il = ["src"], Tl = { class: "fm-typo-en-body-lg-600" }, El = {
3667
- key: 1,
3668
- class: "px-4 flex flex-col gap-12"
3669
- }, ql = { class: "flex flex-col gap-4" }, Vl = { class: "flex justify-between gap-8" }, Ll = { class: "fm-typo-en-body-lg-600" }, jl = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary whitespace-nowrap" }, Ul = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Ml = {
3670
- key: 0,
3671
- class: "fm-typo-en-body-md-400"
3672
- }, Bl = { class: "flex gap-8 xs:flex-col" }, _i = /* @__PURE__ */ Ve({
3673
- __name: "TransferDetails",
3674
- props: {
3675
- poRequest: {},
3676
- purchaseOrder: {},
3677
- transferTo: {},
3678
- transferToDbName: {},
3679
- show: { type: Boolean },
3680
- canResubmit: { type: Boolean },
3681
- canApprove: { type: Boolean },
3682
- scope: {},
3683
- receivedMap: {},
3684
- shipments: {}
3685
- },
3686
- emits: ["update:show", "submitted"],
3687
- setup(c, { emit: t }) {
3688
- const s = c, n = t, m = bt(), u = Ze(), d = Je(), r = ze(), a = gt(), { hasOrderDraftPermission: O } = _s(), f = gs();
3689
- function N(o) {
3690
- const l = o.isCustomCost, $ = o.totalCost;
3691
- return l != null ? l === !0 : $ != null;
3692
- }
3693
- Ye(
3694
- () => s.purchaseOrder,
3695
- (o) => {
3696
- f.init(o);
3697
- },
3698
- { immediate: !0 }
3699
- );
3700
- const R = H(
3701
- () => {
3702
- var o, l;
3703
- return {
3704
- id: ((o = a.sessionUser.value) == null ? void 0 : o.id) ?? "",
3705
- name: ((l = a.sessionUser.value) == null ? void 0 : l.displayName) ?? ""
3706
- };
3707
- }
3708
- ), F = bs(), { t: _ } = ht(), B = H(
3709
- () => {
3710
- var o, l, $, C;
3711
- return ((l = (o = s.purchaseOrder) == null ? void 0 : o.supplier) == null ? void 0 : l.internal) === "restaurant" || ((C = ($ = s.purchaseOrder) == null ? void 0 : $.supplier) == null ? void 0 : C.internal) === "warehouse" ? at.enum.transfer : at.enum.purchase;
3712
- }
3713
- ), E = H(() => {
3714
- var $;
3715
- const o = ($ = s.shipments) == null ? void 0 : $.find((C) => {
3716
- var q;
3717
- return C.ref === ((q = s.purchaseOrder) == null ? void 0 : q._id);
3718
- });
3719
- let l = null;
3720
- if (o != null && o.milestones && o.milestones.length > 0) {
3721
- const C = o.milestones[o.milestones.length - 1];
3722
- if (C.estimatedTime) {
3723
- const q = new Date(C.estimatedTime), Y = q.getDate().toString().padStart(2, "0");
3724
- l = `${q.toLocaleString("en-US", { month: "short" })} ${Y}`;
3725
- }
3726
- }
3727
- return l;
3728
- }), te = re(!1), se = re(""), Q = re(!0), de = Xe(), Oe = wr(de.getWorkflowConfig), ae = vs(), Se = [
3729
- z.enum.receiveStock,
3730
- z.enum.processRequest,
3731
- z.enum.closeRequest
3732
- ], Ae = H(() => {
3733
- var pe, v, p, S, U, M, _e, xe, W;
3734
- if (!s.purchaseOrder)
3735
- return [];
3736
- const o = Oe.result.value;
3737
- if (o.state === Dt.loading)
3738
- return [];
3739
- let l;
3740
- const $ = as.safeParse(s.purchaseOrder);
3741
- if ($.success)
3742
- l = $.data;
3743
- else {
3744
- const Z = /* @__PURE__ */ new Set(["1", "2"]), ge = { line1: "", state: "", city: "", postcode: "", country: "" };
3745
- l = {
3746
- _id: ((pe = s.purchaseOrder) == null ? void 0 : pe._id) ?? "",
3747
- status: ((v = s.purchaseOrder) == null ? void 0 : v.status) ?? be.enum.DRAFT,
3748
- version: Z.has((p = s.purchaseOrder) == null ? void 0 : p.version) ? (S = s.purchaseOrder) == null ? void 0 : S.version : null,
3749
- seqNumber: typeof ((U = s.purchaseOrder) == null ? void 0 : U.seqNumber) == "number" ? s.purchaseOrder.seqNumber : 0,
3750
- supplier: {
3751
- _id: ((_e = (M = s.purchaseOrder) == null ? void 0 : M.supplier) == null ? void 0 : _e._id) ?? "",
3752
- name: ((W = (xe = s.purchaseOrder) == null ? void 0 : xe.supplier) == null ? void 0 : W.name) ?? "",
3753
- address: ge
3754
- },
3755
- items: [],
3756
- deliveryOrder: []
3757
- };
3758
- }
3759
- const C = {
3760
- user: R.value,
3761
- executedAt: r.locations.computeFirst(
3762
- (Z) => {
3763
- var ge;
3764
- return Z.dbName === ((ge = r._currentLocation) == null ? void 0 : ge.dbName) ? Z : null;
3765
- }
3766
- ),
3767
- // Strip purchaseOrder and netSuite from the POR before passing to the Dart
3768
- // bridge — both can carry legacy PO snapshots with "" fields that fail the
3769
- // bridge's unguarded `as Map<String,dynamic>` casts. Also validate the POR
3770
- // itself through Zod first: legacy PORs can have null required string fields
3771
- // (e.g. purchaseOrderId, from.dbName) that cause Dart's _asString to throw.
3772
- // The workflow engine only needs from/to/processedAt/rejectedAt — passing
3773
- // null for an unvalidatable POR yields the same available actions.
3774
- purchaseOrderRequest: (() => {
3775
- if (s.poRequest == null) return s.poRequest;
3776
- const Z = qs.safeParse(s.poRequest);
3777
- return Z.success ? { ...Z.data, purchaseOrder: null, netSuite: null } : null;
3778
- })(),
3779
- purchaseOrder: l
3780
- }, q = d.useOperatePurchaseOrderV2, Y = d.poWorkflowAllowToMarkCompleted, ye = [...Se];
3781
- q && !Y && ye.push(z.enum.completeReceive);
3782
- let I = [];
3783
- try {
3784
- o.state === Dt.error ? (console.error("Error fetching workflow config:", o.error), I = St.getAvailableActions({
3785
- ...C,
3786
- orderConfig: St.getDefaultConfig()
3787
- }).actions.filter((Z) => !ye.includes(Z))) : I = St.getAvailableActions({
3788
- ...C,
3789
- orderConfig: o.data
3790
- }).actions.filter((Z) => !ye.includes(Z));
3791
- } catch (Z) {
3792
- console.error("Error getting available actions:", Z);
3793
- }
3794
- return s.scope === "approval" && (I = I.filter((Z) => Z !== z.enum.completeReceive)), O.value || (I = I.filter(
3795
- (Z) => Z !== z.enum.approveDraft && Z !== z.enum.rejectDraft
3796
- )), I;
3797
- }), K = zs(s, "show"), ve = H(() => [
3798
- {
3799
- label: _("inventory.transfer.receiveRequest.details.overview"),
3800
- value: "overview"
3801
- },
3802
- {
3803
- label: _("inventory.transfer.receiveRequest.details.deliveryHistory"),
3804
- value: "deliveryHistory"
3805
- },
3806
- {
3807
- label: _("inventory.transfer.receiveRequest.details.actionLogs"),
3808
- value: "actionLogs"
3809
- }
3810
- ]), P = re(ve.value[0]);
3811
- Ye(
3812
- () => s.show,
3813
- (o) => {
3814
- o && (P.value = ve.value[0]);
3815
- }
3816
- );
3817
- function x(o) {
3818
- return o.map((l) => ({
3819
- ...l,
3820
- amount: {
3821
- ...l.amount,
3822
- amount: -Math.abs(l.amount.amount)
3823
- }
3824
- }));
3825
- }
3826
- async function w(o, l, $, C, q) {
3827
- return new Promise((Y, ye) => {
3828
- const I = {
3829
- closeButton: !1,
3830
- title: C.title,
3831
- message: C.message,
3832
- primaryActions: C.primaryActions,
3833
- secondaryActions: { text: "No", close: !1 }
3834
- };
3835
- let pe = l.rejectReason ?? "";
3836
- $ === z.enum.rejectDraft && (I.contentComponent = fs, I.contentComponentProps = {
3837
- message: C.message,
3838
- onChange: (v) => {
3839
- pe = v ?? "";
3840
- }
3841
- }), m.open(I).onPrimary(async () => {
3842
- var p, S, U, M;
3843
- const v = [];
3844
- $ === z.enum.confirmDraft || $ === z.enum.submitRequest ? v.push({
3845
- action: "confirmDraft",
3846
- payload: f.controller.value.toConfirmDraftData(Ce())
3847
- }) : $ === z.enum.approveRequest ? (v.push({
3848
- action: "approveRequest",
3849
- payload: null
3850
- }), l.fulfillment && v.push({
3851
- action: "processRequest",
3852
- payload: {
3853
- fulfillmentId: "",
3854
- deliveryOrderNumber: "",
3855
- deliveryRemark: null,
3856
- items: x(l.fulfillment.items),
3857
- createdBy: R.value
3858
- }
3859
- })) : $ === z.enum.processRequest ? l.fulfillment && v.push({
3860
- action: "processRequest",
3861
- payload: {
3862
- fulfillmentId: "",
3863
- deliveryOrderNumber: "",
3864
- deliveryRemark: null,
3865
- items: x(l.fulfillment.items),
3866
- createdBy: R.value
3867
- }
3868
- }) : $ === z.enum.rejectRequest ? v.push({
3869
- action: "rejectRequest",
3870
- payload: null
3871
- }) : $ === z.enum.closeRequest ? v.push({
3872
- action: "closeRequest",
3873
- payload: null
3874
- }) : $ === z.enum.rejectDraft && v.push({
3875
- action: "rejectDraft",
3876
- payload: {
3877
- rejectReason: pe ?? ""
3878
- }
3879
- });
3880
- try {
3881
- await ae({
3882
- operate: {
3883
- operation: $,
3884
- doc: o,
3885
- options: l
3886
- },
3887
- operateV2: {
3888
- _id: ((p = s.purchaseOrder) == null ? void 0 : p._id) ?? "",
3889
- _rev: ((S = s.purchaseOrder) == null ? void 0 : S._rev) ?? "",
3890
- action: $ === z.enum.submitRequest ? z.enum.confirmDraft : $,
3891
- payloads: v
3892
- // add payload if action is receiveStock or processRequest
3893
- },
3894
- transferTo: (M = (U = s.poRequest) == null ? void 0 : U.to) == null ? void 0 : M.dbName
3895
- }).delayed(1e3), Y("submitted");
3896
- } catch (_e) {
3897
- ye(_e);
3898
- }
3899
- }).onSecondary(() => {
3900
- Y("cancelled");
3901
- for (let v = 0; v < q + 2; v++)
3902
- m.close();
3903
- }).onClose(() => {
3904
- });
3905
- });
3906
- }
3907
- async function A(o) {
3908
- var q, Y, ye, I;
3909
- if (o === z.enum.receiveStock)
3910
- return;
3911
- const l = ps[o];
3912
- if (!l) {
3913
- u.open({
3914
- title: "Something went wrong",
3915
- message: `Cannot process order: ${Rt(o)}`,
3916
- type: "error"
3917
- });
3918
- return;
3919
- }
3920
- const { successMessage: $, ...C } = l;
3921
- if (s.purchaseOrder) {
3922
- se.value = `${o}`, te.value = !0, Q.value = !1;
3923
- const pe = {};
3924
- let v = 0;
3925
- if ((o === z.enum.confirmDraft || // auto receive for warehouse to warehouse
3926
- o === z.enum.completeReceive) && d.autoReceiveWarehouse)
3927
- pe.autoReceive = !0;
3928
- else if ((o === z.enum.approveRequest || o === z.enum.processRequest) && d.acceptRequireFulfillment) {
3929
- const p = (Y = (q = s.poRequest) == null ? void 0 : q.from) == null ? void 0 : Y.dbName, S = (I = (ye = s.poRequest) == null ? void 0 : ye.to) == null ? void 0 : I.dbName;
3930
- if (p && S && (p.startsWith("warehouse_") || S.startsWith("warehouse_"))) {
3931
- const U = await new Promise((M, _e) => {
3932
- m.open({
3933
- closeButton: !1,
3934
- title: "Confirm transfer amount",
3935
- dialogComponent: xr,
3936
- dialogComponentProps: {
3937
- purchaseOrder: s.purchaseOrder,
3938
- confirm: M,
3939
- "onUpdate:show": (xe) => {
3940
- xe || (se.value = "", te.value = !1, Q.value = !0, v++, m.close()), _e("cancelled");
3941
- }
3942
- }
3943
- });
3944
- });
3945
- pe.fulfillment = U;
3946
- }
3947
- }
3948
- try {
3949
- await w(
3950
- s.purchaseOrder,
3951
- pe,
3952
- o,
3953
- l,
3954
- v
3955
- ) === "submitted" && (u.open({
3956
- title: "Success",
3957
- message: $,
3958
- type: "success"
3959
- }), n("update:show", !1), n("submitted"));
3960
- } catch (p) {
3961
- u.open({
3962
- title: "Something went wrong",
3963
- message: p instanceof Error ? p.message : "Please try again.",
3964
- type: "error"
3965
- }), console.error("Error when submitting PO operation", o, s.purchaseOrder, p);
3966
- } finally {
3967
- se.value = "", te.value = !1, Q.value = !0;
3968
- }
3969
- }
3970
- }
3971
- const G = H(() => {
3972
- var o, l;
3973
- return ((o = s.purchaseOrder) == null ? void 0 : o.status) === be.enum.RECEIVING || ((l = s.purchaseOrder) == null ? void 0 : l.status) === be.enum.COMPLETE;
3974
- }), X = H(() => s.purchaseOrder ? vt(s.purchaseOrder) : {}), le = H(() => {
3975
- const o = s.purchaseOrder;
3976
- if (!o) return { status: "", statusClass: "" };
3977
- const { partial: l, over: $ } = $t(X.value), C = Ct(o.status, l, $);
3978
- let q = _(`inventory.transfer.status.${C}`), Y = `${o.status}`.toLocaleLowerCase("en-us");
3979
- return C === be.enum.CLOSE && (q = `${_(`inventory.transfer.status.${be.enum.COMPLETE}`)}`), C === "PARTIAL_RECEIVED" && Y === be.enum.PROCESSING.toLocaleLowerCase("en-us") && (Y = be.enum.RECEIVING.toLocaleLowerCase("en-us")), {
3980
- status: q,
3981
- statusClass: `fm-status-badge fm-status-badge-${Y}`
3982
- };
3983
- }), g = H(() => {
3984
- var Y, ye;
3985
- const o = ((Y = s.purchaseOrder) == null ? void 0 : Y.deliveryOrder) ?? [], l = ((ye = s.purchaseOrder) == null ? void 0 : ye.deliveryFullfillment) ?? [], $ = [
3986
- ...o.map((I) => ({
3987
- createdAt: I.createdAt,
3988
- type: "grn",
3989
- doc: I
3990
- })),
3991
- ...l.map((I) => ({
3992
- createdAt: I.createdAt,
3993
- type: "fulfillment",
3994
- doc: I
3995
- }))
3996
- ];
3997
- $.reverse().sort((I, pe) => I.createdAt.localeCompare(pe.createdAt));
3998
- function C(I) {
3999
- var p, S, U, M, _e, xe, W, Z, ge, Pe, Ie, he;
4000
- const pe = l.findIndex((ce) => ce.id === I.fullfillmentId), v = [
4001
- (S = (p = l[pe]) == null ? void 0 : p.netSuite) != null && S.id ? {
4002
- label: "Fulfillment's ref no. (Netsuite)",
4003
- values: [
4004
- `${((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) ?? "-"})`
4005
- ]
4006
- } : null,
4007
- (W = I == null ? void 0 : I.netSuite) != null && W.id ? {
4008
- label: "Netsuite ref no.",
4009
- values: [`${((Z = I == null ? void 0 : I.netSuite) == null ? void 0 : Z.refNo) ?? "N/A"} (${((ge = I == null ? void 0 : I.netSuite) == null ? void 0 : ge.id) ?? "-"})`]
4010
- } : null,
4011
- (Pe = I == null ? void 0 : I.netSuite) != null && Pe.recordType ? {
4012
- label: "Netsuite Type",
4013
- values: [ls((Ie = I == null ? void 0 : I.netSuite) == null ? void 0 : Ie.recordType)]
4014
- } : null
4015
- ];
4016
- return {
4017
- header: "Received",
4018
- deliveryOrder: I,
4019
- date: et(new Date(I.createdAt)),
4020
- info: [
4021
- {
4022
- label: "Adjustment date",
4023
- values: [
4024
- I.adjustment ? et(new Date(mt(I.adjustment))) : "-"
4025
- ]
4026
- },
4027
- {
4028
- label: "Received by",
4029
- values: [(he = I.createdBy) == null ? void 0 : he.name]
4030
- },
4031
- {
4032
- label: "Received items",
4033
- values: I.received.map((ce) => {
4034
- var Re;
4035
- return oe("div", [
4036
- oe(
4037
- "div",
4038
- {
4039
- class: "flex gap-4"
4040
- },
4041
- [
4042
- oe(
4043
- "div",
4044
- {
4045
- class: "flex flex-col"
4046
- },
4047
- [
4048
- oe(
4049
- "span",
4050
- {
4051
- class: "fm-typo-en-body-lg-800 basis-1/2 shrink-0 grow"
4052
- },
4053
- `${ce.sku.name}`
4054
- ),
4055
- oe(
4056
- "span",
4057
- {
4058
- class: "fm-typo-en-body-md-400"
4059
- },
4060
- `${ce.sku.code} `
4061
- )
4062
- ]
4063
- ),
4064
- oe(
4065
- "div",
4066
- {
4067
- class: "ml-auto flex flex-col"
4068
- },
4069
- [
4070
- oe(
4071
- "div",
4072
- {
4073
- class: "ml-auto flex gap-1"
4074
- },
4075
- [
4076
- oe(
4077
- "span",
4078
- {
4079
- class: "fm-typo-en-body-lg-600 self-end"
4080
- },
4081
- $e(ce.amount, !1)
4082
- ),
4083
- oe(
4084
- "span",
4085
- {
4086
- class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary"
4087
- },
4088
- ((Re = ce.measurement) == null ? void 0 : Re.abbrev) ?? ce.sku.unit.abbrev
4089
- )
4090
- ]
4091
- ),
4092
- oe(
4093
- "div",
4094
- {
4095
- class: "flex self-end fm-typo-en-body-md-400 text-fm-color-typo-secondary"
4096
- },
4097
- `${ce.cost ? `(${ut(ce.cost)})` : ""}`
4098
- )
4099
- ]
4100
- )
4101
- ]
4102
- )
4103
- ]);
4104
- })
4105
- },
4106
- {
4107
- label: "Delivery order no.",
4108
- values: [I.deliveryOrderNumber || "N/A"]
4109
- },
4110
- {
4111
- label: "Remark",
4112
- values: [I.remark || "N/A"]
4113
- },
4114
- pe > -1 ? {
4115
- label: "Fulfilment's sequence",
4116
- values: [`${pe + 1}`]
4117
- } : null,
4118
- ...v
4119
- ].filter((ce) => !!ce)
4120
- };
4121
- }
4122
- function q(I) {
4123
- var v, p, S;
4124
- const pe = l.findIndex((U) => U.id === I.id);
4125
- return {
4126
- header: "Fulfillment",
4127
- date: et(new Date(I.createdAt)),
4128
- info: [
4129
- {
4130
- label: "Sequence",
4131
- values: [String(pe + 1)]
4132
- },
4133
- {
4134
- label: "Receiveable items",
4135
- values: I.items.map((U) => {
4136
- var M;
4137
- return oe("div", [
4138
- oe(
4139
- "div",
4140
- {
4141
- class: "flex gap-4"
4142
- },
4143
- [
4144
- oe(
4145
- "div",
4146
- {
4147
- class: "flex flex-col"
4148
- },
4149
- [
4150
- oe(
4151
- "span",
4152
- {
4153
- class: "fm-typo-en-body-lg-800 basis-1/2 shrink-0 grow"
4154
- },
4155
- `${U.sku.name}`
4156
- ),
4157
- oe(
4158
- "span",
4159
- {
4160
- class: "fm-typo-en-body-md-400"
4161
- },
4162
- `${U.sku.code} `
4163
- )
4164
- ]
4165
- ),
4166
- oe(
4167
- "div",
4168
- {
4169
- class: "ml-auto flex flex-col"
4170
- },
4171
- [
4172
- oe(
4173
- "div",
4174
- {
4175
- class: "ml-auto flex gap-1"
4176
- },
4177
- [
4178
- oe(
4179
- "span",
4180
- {
4181
- class: "fm-typo-en-body-lg-600 self-end"
4182
- },
4183
- $e(U.amount, !1)
4184
- ),
4185
- oe(
4186
- "span",
4187
- {
4188
- class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary"
4189
- },
4190
- ((M = U.measurement) == null ? void 0 : M.abbrev) ?? U.sku.unit.abbrev
4191
- )
4192
- ]
4193
- ),
4194
- oe(
4195
- "div",
4196
- {
4197
- class: "flex self-end fm-typo-en-body-md-400 text-fm-color-typo-secondary"
4198
- },
4199
- `${U.cost ? `(${ut(U.cost)})` : ""}`
4200
- )
4201
- ]
4202
- )
4203
- ]
4204
- )
4205
- ]);
4206
- })
4207
- },
4208
- (v = I.netSuite) != null && v.refNo ? {
4209
- label: "Netsuite Ref no. (ID)",
4210
- values: [`${(p = I.netSuite) == null ? void 0 : p.refNo} (${((S = I.netSuite) == null ? void 0 : S.id) ?? "-"})`]
4211
- } : null
4212
- ].filter((U) => !!U)
4213
- };
4214
- }
4215
- return $.map(
4216
- (I) => I.type === "grn" ? C(I.doc) : q(I.doc)
4217
- );
4218
- }), D = H(() => {
4219
- const o = s.purchaseOrder;
4220
- if (!o) return [];
4221
- if (!o.itemsAtSubmission) return o.items ?? [];
4222
- const l = new Set(o.itemsAtSubmission.map((C) => C.sku._id)), $ = [];
4223
- for (const C of o.items ?? [])
4224
- l.has(C.sku._id) || (l.add(C.sku._id), $.push(C));
4225
- return [...o.itemsAtSubmission, ...$];
4226
- }), ie = H(() => {
4227
- const o = s.purchaseOrder;
4228
- if (!o || o.version !== Ue.enum[2]) return s.receivedMap;
4229
- const l = {}, $ = {};
4230
- for (const q of o.items ?? [])
4231
- l[q.sku._id] || (l[q.sku._id] = []), $[q.sku._id] = q.sku.unit.precision, q.id && l[q.sku._id].push(q.id);
4232
- const C = {};
4233
- for (const [q, Y] of Object.entries(l)) {
4234
- const ye = Y.map((p) => s.receivedMap[p]).filter(Boolean);
4235
- if (ye.length === 0) continue;
4236
- const I = { amount: 0, precision: $[q] ?? 0 }, pe = ye.reduce((p, S) => Fe.add([p, S.total]), I), v = ye.reduce((p, S) => Fe.add([p, S.received]), I);
4237
- C[q] = {
4238
- key: q,
4239
- total: pe,
4240
- received: v,
4241
- remaining: Fe.subtract([pe, v])
4242
- };
4243
- }
4244
- return C;
4245
- });
4246
- function ee(o) {
4247
- const l = ie.value[o.sku._id], $ = b(o);
4248
- return l ? `<span class="${$} fm-typo-en-body-lg-600">${Fe.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)}`;
4249
- }
4250
- function L(o) {
4251
- const l = s.purchaseOrder;
4252
- return l != null && l.itemsAtSubmission ? !l.itemsAtSubmission.some(($) => $.sku._id === o.sku._id) : !1;
4253
- }
4254
- function b(o) {
4255
- const l = ie.value[o.sku._id];
4256
- if (!l)
4257
- return "text-fm-color-typo-tertiary";
4258
- const { isPartialReceive: $, isNoReceive: C, isOverReceive: q, isFullReceive: Y } = mr(l);
4259
- 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" : "";
4260
- }
4261
- const j = H(() => {
4262
- var o, l, $;
4263
- return (o = s.purchaseOrder) != null && o.itemsAtSubmission ? ((l = s.purchaseOrder) == null ? void 0 : l.version) === Ue.enum[2] ? s.purchaseOrder.items.reduce((C, q) => {
4264
- var ye, I;
4265
- const Y = (I = (ye = s.purchaseOrder) == null ? void 0 : ye.itemsAtSubmission) == null ? void 0 : I.find(
4266
- (pe) => pe.id === q.id
4267
- );
4268
- return Y && Y.quantity !== q.quantity && C.set(q.sku.code, {
4269
- originalAmount: Number(Fe.toFormatString({ value: Y.quantity })),
4270
- newAmount: Number(Fe.toFormatString({ value: q.quantity }))
4271
- }), C;
4272
- }, /* @__PURE__ */ new Map()) : ($ = s.purchaseOrder) == null ? void 0 : $.items.reduce((C, q) => {
4273
- var pe, v;
4274
- const Y = (v = (pe = s.purchaseOrder) == null ? void 0 : pe.itemsAtSubmission) == null ? void 0 : v.find(
4275
- (p) => p.sku._id === q.sku._id
4276
- ), ye = Y ? Number(Fe.toFormatString({ value: Y.quantity })) : 0, I = Number(Fe.toFormatString({ value: q.quantity }));
4277
- return Y && ye !== I && C.set(q.sku.code, {
4278
- originalAmount: ye,
4279
- newAmount: I
4280
- }), C;
4281
- }, /* @__PURE__ */ new Map()) : /* @__PURE__ */ new Map();
4282
- }), J = (o) => {
4283
- var $, C;
4284
- const l = j.value;
4285
- return (($ = s.purchaseOrder) == null ? void 0 : $.version) === Ue.enum[2] ? l.has(o.id) : l.has((C = o.sku) == null ? void 0 : C.code);
4286
- }, me = (o) => {
4287
- var $, C;
4288
- const l = j.value;
4289
- return (($ = s.purchaseOrder) == null ? void 0 : $.version) === Ue.enum[2] ? l.get(o.id) : l.get((C = o.sku) == null ? void 0 : C.code);
4290
- }, ke = H(() => {
4291
- const o = s.purchaseOrder;
4292
- if (!o) return "";
4293
- const l = o.actionChangelogs ?? [], $ = l.length ? l[l.length - 1] : null;
4294
- if ($ && $.action === "rejectDraft") {
4295
- const C = $.remarks ?? "";
4296
- return C && C.toString().trim() !== "" ? C.toString() : "-";
4297
- }
4298
- return "";
4299
- }), we = H(() => {
4300
- const o = s.purchaseOrder;
4301
- return o ? [...o.actionChangelogs ?? []].reverse() : [];
4302
- });
4303
- return (o, l) => {
4304
- const $ = ne("FmButton"), C = ne("FmButtonGroup"), q = ne("FmChip"), Y = ne("FmIcon"), ye = ne("FmMenuDivider"), I = ne("FmCard"), pe = ne("FmTooltip"), v = ne("FmSpacer"), p = ne("FmSideSheet");
4305
- return i(), fe(p, {
4306
- modelValue: y(K),
4307
- "onUpdate:modelValue": l[9] || (l[9] = (S) => Rs(K) ? K.value = S : null),
4308
- "dismiss-away": Q.value,
4309
- "max-width": 600,
4310
- "close-button": !1
4311
- }, {
4312
- "side-sheet-header": ue(() => {
4313
- var S, U;
4314
- return [
4315
- e("div", ta, [
4316
- e("div", sa, [
4317
- e("div", ra, k(y(_)("inventory.transfer.receiveRequest.details.title") + ((S = o.purchaseOrder) != null && S.seqNumber ? ` #${(U = o.purchaseOrder) == null ? void 0 : U.seqNumber}` : "")), 1),
4318
- T($, {
4319
- class: "ml-auto -m-2",
4320
- variant: "tertiary",
4321
- "prepend-icon": "close",
4322
- onClick: l[0] || (l[0] = (M) => n("update:show", !1))
4323
- })
4324
- ]),
4325
- T(C, {
4326
- items: ve.value,
4327
- modelValue: P.value,
4328
- "onUpdate:modelValue": l[1] || (l[1] = (M) => P.value = M)
4329
- }, null, 8, ["items", "modelValue"]),
4330
- o.purchaseOrder && P.value.value === "deliveryHistory" ? (i(), fe(Pn, {
4331
- key: 0,
4332
- "purchase-order": o.purchaseOrder,
4333
- "received-info-map": X.value,
4334
- "received-map": o.receivedMap,
4335
- onSubmitted: l[2] || (l[2] = () => {
4336
- n("update:show", !1), n("submitted");
4337
- })
4338
- }, null, 8, ["purchase-order", "received-info-map", "received-map"])) : V("", !0)
4339
- ])
4340
- ];
4341
- }),
4342
- default: ue(() => {
4343
- var S, U, M, _e, xe;
4344
- return [
4345
- e("div", oa, [
4346
- P.value.value === "overview" ? (i(), h(Ne, { key: 0 }, [
4347
- e("div", null, [
4348
- T(I, {
4349
- variant: "outlined",
4350
- class: "flex flex-col gap-8 px-12 py-16"
4351
- }, {
4352
- default: ue(() => {
4353
- var W, Z, ge, Pe, Ie, he, ce, Re, Ee, Le;
4354
- return [
4355
- e("div", na, [
4356
- e("div", aa, k(y(_)("inventory.transfer.receiveRequest.details.requestSummary")), 1),
4357
- e("div", la, [
4358
- T(q, {
4359
- label: le.value.status,
4360
- class: We(le.value.statusClass),
4361
- compact: ""
4362
- }, null, 8, ["label", "class"]),
4363
- E.value ? (i(), h("div", ia, [
4364
- T(Y, {
4365
- name: "local_shipping",
4366
- color: "#666666"
4367
- }),
4368
- e("span", ua, k(E.value), 1)
4369
- ])) : V("", !0)
4370
- ])
4371
- ]),
4372
- T(ye),
4373
- e("div", ca, [
4374
- T(ss, { title: "Debug Info" }, {
4375
- default: ue(() => {
4376
- var it, Et, qt, Vt, Lt, jt, Ut, Mt, Bt, zt, Kt, Ht;
4377
- return [
4378
- (it = o.purchaseOrder) != null && it._id ? (i(), h("div", da, [
4379
- l[10] || (l[10] = e("span", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " Purchase Order ID ", -1)),
4380
- e("span", ma, k((Et = o.purchaseOrder) == null ? void 0 : Et._id), 1)
4381
- ])) : V("", !0),
4382
- (qt = o.purchaseOrder) != null && qt.status ? (i(), h("div", pa, [
4383
- l[11] || (l[11] = e("span", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " Purchase Order Status ", -1)),
4384
- e("span", fa, k((Vt = o.purchaseOrder) == null ? void 0 : Vt.status), 1)
4385
- ])) : V("", !0),
4386
- (jt = (Lt = o.purchaseOrder) == null ? void 0 : Lt.supplier) != null && jt._id ? (i(), h("div", va, [
4387
- l[12] || (l[12] = e("span", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " Source Location ID ", -1)),
4388
- e("span", ya, k(((Mt = (Ut = o.purchaseOrder) == null ? void 0 : Ut.supplier) == null ? void 0 : Mt.internal) != null ? `${(zt = (Bt = o.purchaseOrder) == null ? void 0 : Bt.supplier) == null ? void 0 : zt.internal}_` : "") + k((Ht = (Kt = o.purchaseOrder) == null ? void 0 : Kt.supplier) == null ? void 0 : Ht._id), 1)
4389
- ])) : V("", !0),
4390
- o.transferToDbName ? (i(), h("div", ha, [
4391
- l[13] || (l[13] = e("span", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " Destination Location ID ", -1)),
4392
- e("span", ga, k(o.transferToDbName), 1)
4393
- ])) : V("", !0)
4394
- ];
4395
- }),
4396
- _: 1
4397
- }),
4398
- e("div", ba, [
4399
- e("div", _a, [
4400
- e("div", Sa, k(y(_)("inventory.transfer.receiveRequest.details.createdAt")), 1)
4401
- ]),
4402
- e("div", ka, k(y(lt)(((W = o.purchaseOrder) == null ? void 0 : W._id) ?? "")), 1)
4403
- ]),
4404
- (Z = o.purchaseOrder) != null && Z.effectiveAt ? (i(), h("div", Oa, [
4405
- e("div", xa, k(y(_)("inventory.transfer.receiveRequest.details.date")), 1),
4406
- e("div", wa, k(y(Pt)(new Date((ge = o.purchaseOrder) == null ? void 0 : ge.effectiveAt))), 1)
4407
- ])) : V("", !0),
4408
- e("div", $a, [
4409
- e("div", Ca, k(y(_)("inventory.transfer.receiveRequest.details.type.title")), 1),
4410
- e("div", Aa, k(y(_)(
4411
- `inventory.transfer.receiveRequest.details.type.${B.value.toLocaleLowerCase("en-US")}`
4412
- )), 1)
4413
- ]),
4414
- (Ie = (Pe = o.purchaseOrder) == null ? void 0 : Pe.supplier) != null && Ie.name ? (i(), h("div", Da, [
4415
- e("div", Na, k(y(_)("inventory.transfer.receiveRequest.details.from")), 1),
4416
- e("div", Ra, k((ce = (he = o.purchaseOrder) == null ? void 0 : he.supplier) == null ? void 0 : ce.name), 1)
4417
- ])) : V("", !0),
4418
- o.transferTo ? (i(), h("div", Pa, [
4419
- e("div", Fa, k(y(_)("inventory.transfer.receiveRequest.details.to")), 1),
4420
- e("div", Ia, k(o.transferTo), 1)
4421
- ])) : V("", !0),
4422
- (Re = o.purchaseOrder) != null && Re.ref ? (i(), h("div", Ta, [
4423
- e("div", Ea, k(y(_)("inventory.transfer.receiveRequest.details.reference")), 1),
4424
- e("div", qa, k(o.purchaseOrder.ref), 1)
4425
- ])) : V("", !0),
4426
- (Ee = o.purchaseOrder) != null && Ee.remark ? (i(), h("div", Va, [
4427
- e("div", La, k(y(_)("inventory.transfer.receiveRequest.details.remark")), 1),
4428
- e("div", ja, k(o.purchaseOrder.remark), 1)
4429
- ])) : V("", !0),
4430
- ((Le = o.purchaseOrder) == null ? void 0 : Le.status) === y(be).enum.DRAFT && ke.value ? (i(), h("div", Ua, [
4431
- e("div", Ma, k(y(_)("inventory.transfer.receiveRequest.details.rejectionReason")), 1),
4432
- e("div", Ba, k(ke.value !== "" ? ke.value : "-"), 1)
4433
- ])) : V("", !0)
4434
- ])
4435
- ];
4436
- }),
4437
- _: 1
4438
- })
4439
- ]),
4440
- T(ko, {
4441
- "po-request": o.poRequest,
4442
- purchaseOrder: o.purchaseOrder,
4443
- transferType: B.value,
4444
- transferToDbName: o.transferToDbName,
4445
- scope: o.scope
4446
- }, null, 8, ["po-request", "purchaseOrder", "transferType", "transferToDbName", "scope"]),
4447
- e("div", za, [
4448
- e("div", Ka, [
4449
- e("div", Ha, [
4450
- e("span", Ga, [
4451
- Ge(k(G.value ? y(_)("inventory.transfer.receiveRequest.details.receivedItems") : y(_)("inventory.transfer.receiveRequest.details.requestedItems")) + " ", 1),
4452
- (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(), fe(pe, {
4453
- key: 0,
4454
- variant: "rich",
4455
- placement: "top",
4456
- "z-index": 51
4457
- }, {
4458
- content: ue(() => {
4459
- var W, Z;
4460
- return [
4461
- e("div", Wa, [
4462
- (i(!0), h(Ne, null, Te((Z = (W = o.purchaseOrder) == null ? void 0 : W.netSuite) == null ? void 0 : Z.missingItems, (ge, Pe) => (i(), h("div", {
4463
- class: "flex justify-center align-middle",
4464
- key: Pe
4465
- }, [
4466
- T(Y, {
4467
- name: "arrow_right",
4468
- size: "sm"
4469
- }),
4470
- Ge(" " + k(`(${ge.netSuiteId}) ${ge.name}: ${ge.reason}`), 1)
4471
- ]))), 128))
4472
- ])
4473
- ];
4474
- }),
4475
- default: ue(() => [
4476
- T(Y, {
4477
- name: "error",
4478
- color: "#ff2c2c",
4479
- size: "sm"
4480
- })
4481
- ]),
4482
- _: 1
4483
- })) : V("", !0)
4484
- ])
4485
- ]),
4486
- T(ye),
4487
- (i(!0), h(Ne, null, Te(D.value, (W, Z) => {
4488
- var ge;
4489
- return i(), h("div", {
4490
- key: Z,
4491
- class: "flex flex-col"
4492
- }, [
4493
- e("div", Qa, [
4494
- e("div", Ya, [
4495
- Ge(k(W.name) + " ", 1),
4496
- L(W) ? (i(), fe(pe, {
4497
- key: 0,
4498
- variant: "rich",
4499
- placement: "top",
4500
- "z-index": 51
4501
- }, {
4502
- content: ue(() => l[14] || (l[14] = [
4503
- e("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " Extra item (added during delivery) ", -1)
4504
- ])),
4505
- default: ue(() => [
4506
- T(Y, {
4507
- name: "add_circle",
4508
- color: "#6b7280",
4509
- size: "sm"
4510
- })
4511
- ]),
4512
- _: 1
4513
- })) : V("", !0),
4514
- J(W) ? (i(), fe(pe, {
4515
- key: 1,
4516
- variant: "rich",
4517
- placement: "top",
4518
- "z-index": 51
4519
- }, {
4520
- content: ue(() => {
4521
- var Pe, Ie;
4522
- return [
4523
- e("div", Ja, [
4524
- l[15] || (l[15] = e("div", { class: "font-semibold" }, "Submission changes", -1)),
4525
- e("div", null, "Original Amount: " + k((Pe = me(W)) == null ? void 0 : Pe.originalAmount), 1),
4526
- e("div", null, " New Amount: " + k((Ie = me(W)) == null ? void 0 : Ie.newAmount), 1)
4527
- ])
4528
- ];
4529
- }),
4530
- default: ue(() => [
4531
- T(Y, {
4532
- name: "error",
4533
- color: "#ff9500",
4534
- size: "sm"
4535
- })
4536
- ]),
4537
- _: 2
4538
- }, 1024)) : V("", !0)
4539
- ]),
4540
- e("div", Za, [
4541
- e("span", {
4542
- innerHTML: ee(W)
4543
- }, null, 8, Xa)
4544
- ])
4545
- ]),
4546
- e("div", el, [
4547
- e("div", tl, k(W.code), 1),
4548
- (ge = W.totalCost) != null && ge.amount || typeof W.sku == "object" && W.sku != null ? (i(), fe(Zt, {
4549
- key: 0,
4550
- "feature-key": "total-cost",
4551
- compact: ""
4552
- }, {
4553
- default: ue(() => {
4554
- var Pe;
4555
- return [
4556
- e("div", sl, [
4557
- e("span", rl, k(y(ut)(
4558
- (Pe = W.totalCost) != null && Pe.amount ? W.totalCost : y(f).controller.value.getItemCost(W, y(Ce)()).cost
4559
- )), 1),
4560
- N(W) ? V("", !0) : (i(), h("span", ol, [
4561
- l[16] || (l[16] = e("span", { class: "w-1.5 h-1.5 rounded-full bg-gray-400" }, null, -1)),
4562
- Ge(" " + k(y(_)("inventory.transfer.form.items.autoCalculated")), 1)
4563
- ]))
4564
- ])
4565
- ];
4566
- }),
4567
- _: 2
4568
- }, 1024)) : V("", !0)
4569
- ])
4570
- ]);
4571
- }), 128)),
4572
- !y(d).enableTotalCost || +y($e)(y(f).controller.value.getTotalCosts()) ? (i(), fe(Zt, {
4573
- key: 0,
4574
- "feature-key": "total-cost"
4575
- }, {
4576
- default: ue(() => [
4577
- e("div", nl, [
4578
- T(ye)
4579
- ]),
4580
- e("div", al, [
4581
- l[17] || (l[17] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Total:", -1)),
4582
- e("div", ll, k(y(Ce)()) + " " + k(y(ut)({
4583
- ...y(f).controller.value.getTotalCosts(),
4584
- currency: y(Ce)()
4585
- }).replace(/[^0-9.,]/g, "")), 1)
4586
- ])
4587
- ]),
4588
- _: 1
4589
- })) : V("", !0),
4590
- y(d).enablePurchaseOrderPriceAdjustment ? (i(), h(Ne, { key: 1 }, [
4591
- T(En, {
4592
- adjustments: (xe = o.purchaseOrder) == null ? void 0 : xe.priceAdjustments
4593
- }, null, 8, ["adjustments"]),
4594
- o.purchaseOrder ? (i(), h("div", il, [
4595
- T(Vn, {
4596
- "purchase-order": o.purchaseOrder,
4597
- onSubmitted: l[3] || (l[3] = () => {
4598
- n("update:show", !1), n("submitted");
4599
- })
4600
- }, null, 8, ["purchase-order"])
4601
- ])) : V("", !0)
4602
- ], 64)) : V("", !0)
4603
- ])
4604
- ])
4605
- ], 64)) : P.value.value === "deliveryHistory" ? (i(), h("div", ul, [
4606
- g.value.length ? (i(), h("div", fl, [
4607
- (i(!0), h(Ne, null, Te(g.value, (W, Z) => {
4608
- var ge, Pe, Ie, he, ce;
4609
- return i(), h(Ne, { key: Z }, [
4610
- e("div", vl, [
4611
- e("div", yl, [
4612
- e("div", hl, [
4613
- e("div", {
4614
- class: We([
4615
- {
4616
- "bg-fm-color-primary": Z !== 0,
4617
- "bg-white": Z === 0
4618
- },
4619
- "w-[2px] h-full"
4620
- ])
4621
- }, null, 2)
4622
- ]),
4623
- e("div", gl, [
4624
- W.header === "Received" ? (i(), fe(Y, {
4625
- key: 0,
4626
- name: "local_shipping",
4627
- outline: "",
4628
- color: "#ffffff"
4629
- })) : V("", !0)
4630
- ]),
4631
- e("div", bl, [
4632
- e("div", {
4633
- class: We([
4634
- {
4635
- "bg-fm-color-primary": Z < g.value.length - 1,
4636
- "bg-white": Z >= g.value.length - 1
4637
- },
4638
- "w-[2px] h-full"
4639
- ])
4640
- }, null, 2)
4641
- ])
4642
- ]),
4643
- e("div", _l, [
4644
- e("div", Sl, [
4645
- e("div", kl, k(W.header), 1),
4646
- e("div", Ol, k(W.date), 1)
4647
- ]),
4648
- e("div", xl, [
4649
- W.header === "Received" && W.deliveryOrder && o.purchaseOrder ? (i(), fe(Yo, {
4650
- key: 0,
4651
- deliveryOrder: W.deliveryOrder,
4652
- purchaseOrder: o.purchaseOrder,
4653
- "received-info-map": X.value,
4654
- onSubmitted: l[4] || (l[4] = () => {
4655
- n("update:show", !1), n("submitted");
4656
- })
4657
- }, null, 8, ["deliveryOrder", "purchaseOrder", "received-info-map"])) : V("", !0),
4658
- (Pe = (ge = W.deliveryOrder) == null ? void 0 : ge.netSuite) != null && Pe.id ? (i(), fe(ss, {
4659
- key: 1,
4660
- title: "Admin",
4661
- class: "min-w-[140px]"
4662
- }, {
4663
- default: ue(() => {
4664
- var Re, Ee;
4665
- return [
4666
- T(ea, {
4667
- "netsuite-id": (Ee = (Re = W.deliveryOrder) == null ? void 0 : Re.netSuite) == null ? void 0 : Ee.id
4668
- }, null, 8, ["netsuite-id"])
4669
- ];
4670
- }),
4671
- _: 2
4672
- }, 1024)) : V("", !0),
4673
- o.purchaseOrder && ((Ie = W.deliveryOrder) != null && Ie.id) ? (i(), fe(Gs, {
4674
- key: 2,
4675
- "purchase-order-id": (he = o.purchaseOrder) == null ? void 0 : he._id,
4676
- "delivery-order-id": (ce = W.deliveryOrder) == null ? void 0 : ce.id
4677
- }, null, 8, ["purchase-order-id", "delivery-order-id"])) : V("", !0)
4678
- ])
4679
- ])
4680
- ]),
4681
- e("div", wl, [
4682
- e("div", $l, [
4683
- e("div", Cl, [
4684
- e("div", {
4685
- class: We([
4686
- {
4687
- "bg-fm-color-primary": Z < g.value.length - 1,
4688
- "bg-white": Z >= g.value.length - 1
4689
- },
4690
- "w-[2px] h-full"
4691
- ])
4692
- }, null, 2)
4693
- ])
4694
- ]),
4695
- e("div", Al, [
4696
- T(I, {
4697
- variant: "outlined",
4698
- class: "py-12 px-16"
4699
- }, {
4700
- default: ue(() => [
4701
- e("div", Dl, [
4702
- (i(!0), h(Ne, null, Te(W.info, (Re, Ee) => (i(), h("div", {
4703
- key: Ee,
4704
- class: "flex flex-col gap-4"
4705
- }, [
4706
- e("div", Nl, k(Re == null ? void 0 : Re.label), 1),
4707
- e("div", Rl, [
4708
- (i(!0), h(Ne, null, Te(Re == null ? void 0 : Re.values, (Le, it) => (i(), h("div", {
4709
- key: it,
4710
- class: "fm-typo-en-body-lg-600"
4711
- }, [
4712
- typeof Le == "string" ? (i(), h(Ne, { key: 0 }, [
4713
- Ge(k(Le), 1)
4714
- ], 64)) : (i(), fe(Ps(Le), { key: 1 }))
4715
- ]))), 128))
4716
- ])
4717
- ]))), 128))
4718
- ])
4719
- ]),
4720
- _: 2
4721
- }, 1024)
4722
- ])
4723
- ])
4724
- ], 64);
4725
- }), 128))
4726
- ])) : (i(), h("div", cl, [
4727
- T(v),
4728
- e("div", null, [
4729
- e("img", {
4730
- src: y(Jt),
4731
- alt: "List is empty"
4732
- }, null, 8, dl)
4733
- ]),
4734
- e("div", ml, k(y(_)("inventory.transfer.receiveRequest.details.noRecordsFound")), 1),
4735
- e("div", pl, k(y(_)("inventory.transfer.receiveRequest.details.trackDeliveryMessage")), 1),
4736
- T(v),
4737
- T(v)
4738
- ]))
4739
- ])) : P.value.value === "actionLogs" ? (i(), h("div", Pl, [
4740
- we.value.length ? (i(), h("div", El, [
4741
- (i(!0), h(Ne, null, Te(we.value, (W, Z) => (i(), fe(I, {
4742
- key: Z,
4743
- variant: "outlined",
4744
- class: "py-12 px-16"
4745
- }, {
4746
- default: ue(() => {
4747
- var ge;
4748
- return [
4749
- e("div", ql, [
4750
- e("div", Vl, [
4751
- e("div", Ll, k(y(nt)[W.action] ? y(_)(y(nt)[W.action].translationKey) : W.action), 1),
4752
- e("div", jl, k(y(et)(W.changedAt)), 1)
4753
- ]),
4754
- e("div", Ul, k((ge = W.changedBy) == null ? void 0 : ge.name), 1),
4755
- W.remarks ? (i(), h("div", Ml, k(W.remarks), 1)) : V("", !0)
4756
- ])
4757
- ];
4758
- }),
4759
- _: 2
4760
- }, 1024))), 128))
4761
- ])) : (i(), h("div", Fl, [
4762
- T(v),
4763
- e("div", null, [
4764
- e("img", {
4765
- src: y(Jt),
4766
- alt: "List is empty"
4767
- }, null, 8, Il)
4768
- ]),
4769
- e("div", Tl, k(y(_)("inventory.transfer.receiveRequest.details.noActionLogs")), 1),
4770
- T(v),
4771
- T(v)
4772
- ]))
4773
- ])) : V("", !0)
4774
- ])
4775
- ];
4776
- }),
4777
- "side-sheet-footer": ue(() => [
4778
- e("div", Bl, [
4779
- (i(!0), h(Ne, null, Te(Ae.value, (S) => (i(), h(Ne, null, [
4780
- y(nt)[S].available != !1 ? (i(), fe($, {
4781
- key: S,
4782
- label: y(_)(y(nt)[S].translationKey),
4783
- onClick: (U) => A(S),
4784
- loading: se.value === S,
4785
- disabled: se.value !== S && te.value,
4786
- variant: y(nt)[S].buttonVariant
4787
- }, null, 8, ["label", "onClick", "loading", "disabled", "variant"])) : V("", !0)
4788
- ], 64))), 256)),
4789
- y(F).ableToMarkReceived(o.purchaseOrder) && !Ae.value.includes("completeReceive") ? (i(), fe($, {
4790
- key: 0,
4791
- label: y(_)("inventory.transfer.receiveRequest.actions.completeReceive"),
4792
- onClick: l[5] || (l[5] = (S) => A("completeReceive")),
4793
- loading: se.value === "completeReceive",
4794
- disabled: se.value !== "completeReceive" && te.value
4795
- }, null, 8, ["label", "loading", "disabled"])) : V("", !0),
4796
- y(F).ableToMarkApproved(o.purchaseOrder) && o.canApprove && !Ae.value.includes("approveRequest") ? (i(), fe($, {
4797
- key: 1,
4798
- label: y(_)("inventory.transfer.approval.actions.approveRequest"),
4799
- onClick: l[6] || (l[6] = (S) => A("approveRequest")),
4800
- loading: se.value === "approveRequest",
4801
- disabled: se.value !== "approveRequest" && te.value
4802
- }, null, 8, ["label", "loading", "disabled"])) : V("", !0),
4803
- y(F).ableToCreateFulfillment(o.purchaseOrder, o.poRequest) && s.scope === "approval" ? (i(), fe($, {
4804
- key: 2,
4805
- label: y(_)("inventory.transfer.receiveRequest.actions.processRequest"),
4806
- onClick: l[7] || (l[7] = (S) => A("processRequest")),
4807
- loading: se.value === "processRequest",
4808
- disabled: se.value !== "processRequest" && te.value
4809
- }, null, 8, ["label", "loading", "disabled"])) : V("", !0),
4810
- T($, {
4811
- label: y(_)("common.close"),
4812
- variant: "tertiary",
4813
- onClick: l[8] || (l[8] = (S) => n("update:show", !1))
4814
- }, null, 8, ["label"])
4815
- ])
4816
- ]),
4817
- _: 1
4818
- }, 8, ["modelValue", "dismiss-away"]);
4819
- };
4820
- }
4821
- });
4822
- export {
4823
- At as P,
4824
- _i as _,
4825
- bi as a,
4826
- ir as b,
4827
- fs as c,
4828
- ps as d,
4829
- gs as e,
4830
- vt as f,
4831
- cs as g,
4832
- vs as h,
4833
- Tt as i,
4834
- It as j,
4835
- gi as u
4836
- };