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