@feedmepos/mf-inventory-portal 1.3.7 → 1.3.8-dev.1

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 (132) hide show
  1. package/dist/{App-D1-fT3jF.js → App-Dl97lAmD.js} +3 -3
  2. package/dist/ApprovalView-RePEhbhl.js +241 -0
  3. package/dist/{BindingsDialog-DeavyPY-.js → BindingsDialog-8QVbtnnq.js} +5 -5
  4. package/dist/{BindingsPicker-BGzhKq8G.js → BindingsPicker-D9yuDGcq.js} +3 -3
  5. package/dist/{BindingsTable-Dr9hWkE1.js → BindingsTable-DAYhI-6V.js} +5 -5
  6. package/dist/{ClosingDraftView-6gwWEWWB.js → ClosingDraftView-D_VtBfFG.js} +57 -57
  7. package/dist/{ClosingHistoryView-D4rNnlsq.js → ClosingHistoryView-ClUnxQS2.js} +4 -4
  8. package/dist/{ClosingTemplateView-DxCLH1GH.js → ClosingTemplateView-0a_isyyx.js} +16 -16
  9. package/dist/{DeliveryOrderPrintPreview-D-XeZX-z.js → DeliveryOrderPrintPreview-DovAi6j-.js} +17 -17
  10. package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-DeoaPLQm.js → FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-DjNZ0m13.js} +14 -14
  11. package/dist/{FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-BMhSHZ3Z.js → FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-4vZH2hLF.js} +2 -2
  12. package/dist/{FmMultiselectDialog-DJFi54mG.js → FmMultiselectDialog-B5-aK-b2.js} +1 -1
  13. package/dist/{FmMultiselectDialog-BQZmTWDb.js → FmMultiselectDialog-Z49kK96R.js} +2 -2
  14. package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-DAivpdPp.js → FmUnitInput.vue_vue_type_script_setup_true_lang-zP1nS7bp.js} +4 -4
  15. package/dist/{ImportView-DPQY0ELT.js → ImportView-Dba8fJry.js} +6 -6
  16. package/dist/{IngredientBindedItem.vue_vue_type_script_setup_true_lang-DeVYXEzb.js → IngredientBindedItem.vue_vue_type_script_setup_true_lang-DHITBIhp.js} +1 -1
  17. package/dist/{IngredientGroupView-5AuPbMDz.js → IngredientGroupView-CHi5_A4T.js} +7 -7
  18. package/dist/{IngredientsView-qMotWYnL.js → IngredientsView-DWk27PJg.js} +17 -17
  19. package/dist/IntegrationExplorerView-CixgHWVb.js +22254 -0
  20. package/dist/{IntegrationView-CVdwhNTA.js → IntegrationView-fttszvyC.js} +13 -13
  21. package/dist/{InventoryBindingForm-B5KUYKIu.js → InventoryBindingForm-DDcM2paa.js} +1 -1
  22. package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-pbyMU879.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-DOHrtdbl.js} +5 -5
  23. package/dist/{InventoryBindingSummary-Bm3A2kmC.js → InventoryBindingSummary-BERshnpd.js} +1 -1
  24. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-NnoVkA8W.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-D4u0MM_k.js} +1 -1
  25. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-Dp4gFbs5.js → PremiumBadge.vue_vue_type_script_setup_true_lang-eFb-84g2.js} +1 -1
  26. package/dist/{PublishView-DOIiAeDK.js → PublishView-COGdnDHP.js} +3 -3
  27. package/dist/{PurchaseOrderPrintPreview-BE-8EJFv.js → PurchaseOrderPrintPreview-COJVgeTm.js} +12 -12
  28. package/dist/ReceiveRequestView-DvC12_QK.js +2817 -0
  29. package/dist/{RecipeView-CM-BrVSe.js → RecipeView-BKlVCFPR.js} +22 -21
  30. package/dist/SettingsView-DbXva8_D.js +695 -0
  31. package/dist/{StockView-DDqlms0m.js → StockView-Hri6SSjn.js} +21 -20
  32. package/dist/{SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-CcQ6bBWG.js → SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-DiRfjFmz.js} +1 -1
  33. package/dist/{SupplierView-CM2PrtHi.js → SupplierView-DCMW5muk.js} +14 -14
  34. package/dist/{SurchargeView-q2NfASMH.js → SurchargeView-DRh5EAi8.js} +8 -8
  35. package/dist/{SystemTrailDialog.vue_vue_type_script_setup_true_lang-BbZQZQTQ.js → SystemTrailDialog.vue_vue_type_script_setup_true_lang-BHNIS7Pp.js} +2 -2
  36. package/dist/{TemplatePublishDialog.vue_vue_type_script_setup_true_lang-Bp3joqMK.js → TemplatePublishDialog.vue_vue_type_script_setup_true_lang-BVyoZ2a4.js} +1 -1
  37. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-CMSKhz6_.js +3790 -0
  38. package/dist/{TransferTemplateView-B26H_T9Q.js → TransferTemplateView-71XY525Q.js} +20 -19
  39. package/dist/{UnitCostHistoryView-BzumRVdx.js → UnitCostHistoryView-CjEaekfJ.js} +4 -4
  40. package/dist/{UnitDisplayControl.vue_vue_type_script_setup_true_lang-CfWpv2Mv.js → UnitDisplayControl.vue_vue_type_script_setup_true_lang-B8dRQhZi.js} +4 -4
  41. package/dist/{UnitView-Cxfg--TU.js → UnitView-D06txpBT.js} +9 -9
  42. package/dist/{WarehouseView-CvoafTrd.js → WarehouseView-DQluGq0D.js} +7 -7
  43. package/dist/{WastageTemplateView-Bqd4Wp3d.js → WastageTemplateView-Bqmd_r_Y.js} +16 -16
  44. package/dist/api/integration-sync-log.d.ts +47 -0
  45. package/dist/api/netsuite-explorer.d.ts +51 -0
  46. package/dist/{app-CrrDFeMj.js → app-B5-QVzib.js} +4711 -4557
  47. package/dist/app.d.ts +32 -0
  48. package/dist/app.js +2 -2
  49. package/dist/{closing-template-Ew74NLQj.js → closing-template-C3ClR8Pj.js} +1 -1
  50. package/dist/{component-DpCUABT3.js → component-kqxARxvM.js} +30 -21
  51. package/dist/components/row-action.enum.d.ts +3 -0
  52. package/dist/{date2-Bklbk2g-.js → date2-CQCX7jCE.js} +4 -4
  53. package/dist/{dayjs.min-B463GIlc.js → dayjs.min-Dhp0BWSV.js} +1 -1
  54. package/dist/{decimal-Dm2vbfDq.js → decimal-98G--u_X.js} +2 -2
  55. package/dist/defineDeepModel-BmHs4vdS.js +19 -0
  56. package/dist/{duplicate-template-CR79OmLy.js → duplicate-template-UzmArmcM.js} +1 -1
  57. package/dist/{export-CQJcxfPC.js → export-Bdxro0GT.js} +1 -1
  58. package/dist/feature-DyfUPR3b.js +1081 -0
  59. package/dist/{format-time-from-id-61ydd8RS.js → format-time-from-id-uRCD3JxF.js} +1 -1
  60. package/dist/{format-unit-display-BLtW28yU.js → format-unit-display-C-_85vuL.js} +13 -13
  61. package/dist/{import-export.helper-uhFwjH6X.js → import-export.helper-N1BqiTub.js} +6 -6
  62. package/dist/{index-Dx5HvWR_.js → index-B1RZtqz-.js} +1 -1
  63. package/dist/{index-uA6bkf1x.js → index-CaREZ_vQ.js} +3 -3
  64. package/dist/{index-CouegIcG.js → index-CwqHa5AY.js} +1 -1
  65. package/dist/{feature-CZHvliez.js → inventory-core-dart.default-BK8f9n8e.js} +322 -1395
  66. package/dist/{lodash-CjyamSgJ.js → lodash-B9tHF9A4.js} +1 -1
  67. package/dist/{lz-string-BbZdMrTL.js → lz-string-BSMjlcH9.js} +1 -1
  68. package/dist/modules/print-template/api/print-template.d.ts +29 -0
  69. package/dist/modules/print-template/components/BlockConfigPanel.vue.d.ts +19 -0
  70. package/dist/modules/print-template/components/CustomPrintTemplatePreview.vue.d.ts +25 -0
  71. package/dist/modules/print-template/components/PrintTemplateEditorDialog.vue.d.ts +45 -0
  72. package/dist/modules/print-template/components/TemplatePreview.vue.d.ts +22 -0
  73. package/dist/modules/print-template/composables/print-po-with-template.d.ts +25 -0
  74. package/dist/modules/print-template/definitions/block-definitions.d.ts +88 -0
  75. package/dist/modules/print-template/definitions/predefined-templates.d.ts +22 -0
  76. package/dist/modules/print-template/definitions/template-renderer.d.ts +17 -0
  77. package/dist/modules/print-template/index.d.ts +11 -0
  78. package/dist/modules/print-template/store/print-template.d.ts +170 -0
  79. package/dist/modules/print-template/types/print-data.d.ts +52 -0
  80. package/dist/modules/print-template/utils/sanitize-html.d.ts +32 -0
  81. package/dist/{netsuite-2v3F8ILe.js → netsuite-D4KHhWWu.js} +60 -9
  82. package/dist/{number-BYbxsJHr.js → number-DmqVo28f.js} +3 -3
  83. package/dist/predefined-templates-Dy5hYXMM.js +4542 -0
  84. package/dist/{purchase-order-template-s1AiueV_.js → purchase-order-template-BT3tF_gn.js} +1 -1
  85. package/dist/router/name.d.ts +2 -0
  86. package/dist/{row-action.enum-BcW_L_nE.js → row-action.enum-Co_O4qD9.js} +11 -3
  87. package/dist/{rules-C7L-LFOd.js → rules-CbJ7idQa.js} +2 -2
  88. package/dist/{stock-D2s88pz1.js → stock-C9RXv-3_.js} +1 -1
  89. package/dist/{stock-CvYOcgWb.js → stock-YXoLCE8o.js} +3 -3
  90. package/dist/stores/feature.d.ts +2 -0
  91. package/dist/stores/integration/netsuite.d.ts +1 -1
  92. package/dist/style.css +1 -1
  93. package/dist/{supplier-DmobM7mD.js → supplier-Duiacdig.js} +2 -2
  94. package/dist/{surcharge-BdZOVfi0.js → surcharge-CkDK4P_6.js} +1 -1
  95. package/dist/tsconfig.app.tsbuildinfo +1 -1
  96. package/dist/{use-ingredient-select-dialog-BUCJBHjV.js → use-ingredient-select-dialog-C7uVeT1M.js} +2 -2
  97. package/dist/{use-inventory-binding-dialog-DiN1hBIm.js → use-inventory-binding-dialog-BIo9Fi-9.js} +2 -2
  98. package/dist/{use-template-enabled-locations-CmH6I2cy.js → use-template-enabled-locations-BtbfLc0y.js} +2 -2
  99. package/dist/views/integration/components/IntegrationSyncLogTab.vue.d.ts +15 -0
  100. package/dist/views/integration/composables/use-integration-sync-log.d.ts +45 -0
  101. package/dist/views/integration-explorer/IntegrationExplorerView.vue.d.ts +2 -0
  102. package/dist/views/integration-explorer/composables/use-explorer-tab.d.ts +126 -0
  103. package/dist/views/integration-explorer/netsuite/ExplorerRecordSyncLog.vue.d.ts +17 -0
  104. package/dist/views/integration-explorer/netsuite/ExplorerRecordToolbar.vue.d.ts +201 -0
  105. package/dist/views/integration-explorer/netsuite/ExplorerSystemNote.vue.d.ts +15 -0
  106. package/dist/views/integration-explorer/netsuite/JsonViewer.vue.d.ts +15 -0
  107. package/dist/views/integration-explorer/netsuite/NetSuiteExplorerView.vue.d.ts +2 -0
  108. package/dist/views/integration-explorer/netsuite/inventoryTransfer/InventoryTransferSideSheet.vue.d.ts +7 -0
  109. package/dist/views/integration-explorer/netsuite/inventoryTransfer/InventoryTransferView.vue.d.ts +39 -0
  110. package/dist/views/integration-explorer/netsuite/items/AssemblyItemSideSheet.vue.d.ts +7 -0
  111. package/dist/views/integration-explorer/netsuite/items/InventoryItemSideSheet.vue.d.ts +7 -0
  112. package/dist/views/integration-explorer/netsuite/items/ItemsView.vue.d.ts +2 -0
  113. package/dist/views/integration-explorer/netsuite/items/ServiceItemSideSheet.vue.d.ts +7 -0
  114. package/dist/views/integration-explorer/netsuite/orders/ExplorerOrderDetailSideSheet.vue.d.ts +7 -0
  115. package/dist/views/integration-explorer/netsuite/orders/OrdersView.vue.d.ts +39 -0
  116. package/dist/views/integration-explorer/netsuite/orders/PurchaseOrderSideSheet.vue.d.ts +7 -0
  117. package/dist/views/integration-explorer/netsuite/orders/SyncNetsuiteButton.vue.d.ts +29 -0
  118. package/dist/views/integration-explorer/netsuite/orders/TransferOrderSideSheet.vue.d.ts +7 -0
  119. package/dist/views/receive-request/components/transfer-form/TransferFormWithController.vue.d.ts +21 -21
  120. package/dist/views/receive-request/composables/use-process-purchase-order.d.ts +21 -21
  121. package/dist/views/receive-request/composables/use-receive-request-form.d.ts +129 -129
  122. package/dist/views/receive-request/composables/use-receive-request-table.d.ts +154 -150
  123. package/dist/views/settings/SettingsView.vue.d.ts +2 -0
  124. package/dist/vue-i18n-D1JHIbLE.js +2365 -0
  125. package/dist/{xlsx-D4PML26z.js → xlsx-BEbkruI_.js} +398 -398
  126. package/dist/{xlsx.util-BWLcCmO_.js → xlsx.util-BMTXqfxw.js} +1 -1
  127. package/package.json +9 -4
  128. package/dist/ApprovalView-0FbsslVD.js +0 -226
  129. package/dist/ReceiveRequestView-ur3OeHuv.js +0 -2802
  130. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-GhRFdMoW.js +0 -3521
  131. package/dist/defineDeepModel-SD5OUepJ.js +0 -19
  132. package/dist/vue-i18n-D0Q6LFcu.js +0 -2365
@@ -0,0 +1,3790 @@
1
+ import { defineComponent as De, ref as G, watch as Ke, nextTick as Ut, openBlock as i, createBlock as ie, Teleport as jt, createElementBlock as b, withModifiers as Bt, createElementVNode as e, normalizeClass as je, toDisplayString as p, createCommentVNode as U, unref as d, withDirectives as zt, vModelText as Kt, toRaw as Ht, shallowRef as St, onUnmounted as Wt, triggerRef as Gt, computed as Z, readonly as Yt, h as z, reactive as Qt, onMounted as Nt, resolveComponent as X, withCtx as oe, createVNode as L, Fragment as fe, renderList as ke, createTextVNode as Pe, isRef as Jt, resolveDynamicComponent as Xt } from "vue";
2
+ import { f as Zt, h as er, r as tr, s as rr } from "./predefined-templates-Dy5hYXMM.js";
3
+ import { f as tt, p as sr } from "./format-time-from-id-uRCD3JxF.js";
4
+ import { c as Ot } from "./component-kqxARxvM.js";
5
+ import { D as xe, R as ue } from "./row-action.enum-Co_O4qD9.js";
6
+ import { I as Ye, o as or, u as Te, W as q, X as lt, Q as ae, a as nr, Y as wt, Z as ar, _ as lr, H as ir, c as At, v as ht, s as Ce, $ as Pt, t as Ze, D as st, y as Ue, E as Me } from "./app-B5-QVzib.js";
7
+ import { j as cr, c as ur, a as be, t as ot, d as Je } from "./number-DmqVo28f.js";
8
+ import { F as dr } from "./decimal-98G--u_X.js";
9
+ import { h as _t, t as mr, d as pr, a as et } from "./date2-CQCX7jCE.js";
10
+ import { F as Xe, c as fr, a as mt } from "./inventory-core-dart.default-BK8f9n8e.js";
11
+ import { L as yr } from "./lz-string-BSMjlcH9.js";
12
+ import { useI18n as it, useCoreStore as ct, validatePermission as vr, Permission as Ct } from "@feedmepos/mf-common";
13
+ import { u as ut, a as xt, S as Ne } from "./netsuite-D4KHhWWu.js";
14
+ import { useDialog as dt, useSnackbar as He, components as nt, FmButtonVariant as we, useProxiedModel as br } from "@feedmepos/ui-library";
15
+ import { F as Be } from "./FmAdminBadge-BOEV93D3.js";
16
+ import { u as Ee } from "./feature-DyfUPR3b.js";
17
+ import { E as gr } from "./empty-placeholder-wf6-BWE8.js";
18
+ import { u as hr, a as _r, f as xr } from "./format-unit-display-C-_85vuL.js";
19
+ import { u as We, _ as Sr } from "./SystemTrailDialog.vue_vue_type_script_setup_true_lang-BHNIS7Pp.js";
20
+ import { _ as Or, a as wr, b as Cr } from "./FmUnitInput.vue_vue_type_script_setup_true_lang-zP1nS7bp.js";
21
+ import { u as Dr, R as Dt } from "./usePromise-CbVUCxhj.js";
22
+ import { c as $r } from "./index-CaREZ_vQ.js";
23
+ import { i as kr } from "./FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-4vZH2hLF.js";
24
+ import { F as $t } from "./form-mode.enum-BKiNVH6A.js";
25
+ import { u as Rr } from "./supplier-Duiacdig.js";
26
+ import { u as Nr } from "./surcharge-CkDK4P_6.js";
27
+ import { d as Tt } from "./defineDeepModel-BmHs4vdS.js";
28
+ import { u as Ar } from "./vue-i18n-D1JHIbLE.js";
29
+ function Ft(f, r) {
30
+ return r.reduce(
31
+ (l, c) => {
32
+ const o = c.received.find((m) => m.sku._id === f._id);
33
+ return o && (l = cr(l, o.amount)), l;
34
+ },
35
+ dr.toPrecision(ur(0), f.unit.precision)
36
+ );
37
+ }
38
+ function Pr(f) {
39
+ const { po: r, currentLocation: s, business: l, fulfilling: c, por: o } = f, { name: m, address: t, regNo: n, legalName: v } = s.doc.profile, y = {
40
+ name: m,
41
+ legalName: v || void 0,
42
+ registrationNumber: n || void 0,
43
+ line1: (t == null ? void 0 : t.line1) || "",
44
+ line2: (t == null ? void 0 : t.line2) || void 0,
45
+ postcode: (t == null ? void 0 : t.postcode) || "",
46
+ city: (t == null ? void 0 : t.city) || "",
47
+ state: (t == null ? void 0 : t.state) || "",
48
+ country: (t == null ? void 0 : t.country) || ""
49
+ }, _ = {
50
+ name: r.supplier.name,
51
+ phoneNumber: r.supplier.phoneNumber || void 0,
52
+ registrationNumber: r.supplier.registrationNumber || void 0,
53
+ line1: r.supplier.address.line1,
54
+ line2: r.supplier.address.line2 || void 0,
55
+ postcode: r.supplier.address.postcode,
56
+ city: r.supplier.address.city,
57
+ state: r.supplier.address.state,
58
+ country: r.supplier.address.country
59
+ }, h = r.items.map((k) => {
60
+ const { sku: Y, measurement: N } = k, P = be(
61
+ Ft(k.sku, r.deliveryOrder || []),
62
+ !1
63
+ );
64
+ return {
65
+ code: Y.code,
66
+ description: Y.name,
67
+ quantity: be(k.quantity, !1),
68
+ unit: (N == null ? void 0 : N.abbrev) || Y.unit.abbrev,
69
+ received: P,
70
+ unitCost: k.totalCost ? `${k.totalCost.currency} ${Xe.toFormatString({
71
+ value: k.quantity.amount === 0 ? Xe.fromNumber(0) : Xe.divide([k.totalCost, k.quantity])
72
+ })}` : void 0,
73
+ cost: k.totalCost ? `${k.totalCost.currency} ${Xe.toFormatString({
74
+ value: k.totalCost
75
+ })}` : void 0
76
+ };
77
+ }), D = r.deliveryOrder.map((k) => ({
78
+ createdAt: _t(new Date(k.createdAt)),
79
+ ref: k.deliveryOrderNumber,
80
+ remark: k.remark || "",
81
+ items: k.received.map((Y) => {
82
+ var N;
83
+ return {
84
+ code: Y.sku.code,
85
+ description: Y.sku.name,
86
+ quantity: be(Y.amount),
87
+ unit: ((N = Y.measurement) == null ? void 0 : N.abbrev) || Y.sku.unit.abbrev
88
+ };
89
+ })
90
+ }));
91
+ let x = Ye.Enum.purchaseOrder, M = "Inventory Receive Note";
92
+ if (r.supplier.internal ? (M = "Inventory Transfer Note", x = Ye.Enum.transferOrder) : (M = "Purchase Order", x = Ye.Enum.purchaseOrder), o) {
93
+ const k = o.from.dbName;
94
+ s.dbName === k || (M = "Inventory Receive Note", x = Ye.Enum.goodsReceivedNote);
95
+ }
96
+ const j = {
97
+ title: M,
98
+ businessName: l == null ? void 0 : l.name,
99
+ logo: l == null ? void 0 : l.thumbnail,
100
+ orderNumber: r.seqNumber.toString(),
101
+ createdAt: tt(r._id),
102
+ ref: r.ref || "",
103
+ remark: r.remark || "",
104
+ buyer: y,
105
+ supplier: _,
106
+ items: h,
107
+ status: r.status,
108
+ deliveryOrders: D
109
+ }, O = c && (r.deliveryFullfillment || []).length > 0;
110
+ return O && (x = Ye.Enum.deliveryOrder), { printData: j, templateType: x, isDeliveryPrint: O };
111
+ }
112
+ function Tr(f) {
113
+ var y;
114
+ const { printData: r, templateType: s } = Pr(f), c = Zt().getTemplateByType(s), o = !!((y = c == null ? void 0 : c.blocks) != null && y.length), m = er(s), t = o ? c.blocks : m.blocks, n = o ? c.name : m.name, v = !o;
115
+ try {
116
+ const _ = tr(t, r), h = _.match(/<style>([\s\S]*?)<\/style>/), D = h ? `<style>${h[1]}</style>` : "", x = _.replace(/<style>[\s\S]*?<\/style>/, "");
117
+ return {
118
+ html: `<!DOCTYPE html>
119
+ <html>
120
+ <head>
121
+ <meta charset="utf-8">
122
+ <title>Print Preview</title>
123
+ <style>
124
+ @page { margin: 0; }
125
+ @media print {
126
+ body { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
127
+ }
128
+ * { box-sizing: border-box; margin: 0; padding: 0; }
129
+ </style>
130
+ ${D}
131
+ </head>
132
+ <body>${x}</body>
133
+ </html>`,
134
+ templateName: n,
135
+ isDefault: v
136
+ };
137
+ } catch {
138
+ return alert("Failed to render print template. Please try recreating the template."), null;
139
+ }
140
+ }
141
+ const Fr = { class: "w-[95vw] h-[95vh] bg-white rounded-lg flex flex-col shadow-2xl overflow-hidden" }, Ir = { class: "flex justify-between items-center px-16 py-3 border-b border-gray-200 bg-gray-50" }, qr = { class: "flex items-center gap-2.5" }, Er = {
142
+ key: 1,
143
+ class: "text-xs text-gray-100 bg-gray-500 px-2 py-0.5 rounded font-medium"
144
+ }, Vr = { class: "flex-1 overflow-auto bg-gray-100" }, Qa = /* @__PURE__ */ De({
145
+ __name: "CustomPrintTemplatePreview",
146
+ props: {
147
+ html: {},
148
+ modelValue: { type: Boolean },
149
+ templateName: {},
150
+ isDefault: { type: Boolean }
151
+ },
152
+ emits: ["update:modelValue"],
153
+ setup(f, { emit: r }) {
154
+ const s = f, l = r, c = G(null);
155
+ function o() {
156
+ l("update:modelValue", !1);
157
+ }
158
+ function m() {
159
+ var n, v;
160
+ try {
161
+ (v = (n = c.value) == null ? void 0 : n.contentWindow) == null || v.print();
162
+ } catch {
163
+ alert("Failed to trigger print.");
164
+ }
165
+ }
166
+ Ke(
167
+ () => s.modelValue,
168
+ async (n) => {
169
+ n && (await Ut(), t(), setTimeout(() => {
170
+ m();
171
+ }, 300));
172
+ }
173
+ );
174
+ function t() {
175
+ var _;
176
+ const n = c.value;
177
+ if (!n) return;
178
+ const v = rr(s.html), y = n.contentDocument || ((_ = n.contentWindow) == null ? void 0 : _.document);
179
+ y && (y.open(), y.write(`
180
+ <!DOCTYPE html>
181
+ <html>
182
+ <head>
183
+ <meta charset="utf-8">
184
+ <meta http-equiv="Content-Security-Policy" content="
185
+ default-src 'none';
186
+ style-src 'unsafe-inline';
187
+ img-src 'self' data: https:;
188
+ font-src 'self' data:;
189
+ script-src 'none';
190
+ object-src 'none';
191
+ frame-src 'none';
192
+ base-uri 'none';
193
+ form-action 'none';
194
+ ">
195
+ <style>
196
+ * {
197
+ box-sizing: border-box;
198
+ }
199
+ body {
200
+ margin: 0;
201
+ padding: 40px 20px;
202
+ background: #f0f0f0;
203
+ min-height: 100vh;
204
+ }
205
+ .print-container {
206
+ max-width: 800px;
207
+ margin: 0 auto;
208
+ padding: 30px;
209
+ border: 1px solid #ddd;
210
+ box-shadow: 0 0 10px rgba(0, 0, 0, 0.15);
211
+ background: #ffffff;
212
+ font-size: 16px;
213
+ line-height: 1.5;
214
+ font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif;
215
+ color: #555;
216
+ }
217
+ @media print {
218
+ body {
219
+ background: white !important;
220
+ padding: 0 !important;
221
+ margin: 0 !important;
222
+ }
223
+ .print-container {
224
+ border: none !important;
225
+ box-shadow: none !important;
226
+ padding: 0 !important;
227
+ margin: 0 !important;
228
+ max-width: none !important;
229
+ }
230
+ }
231
+ </style>
232
+ </head>
233
+ <body>
234
+ <div class="print-container">
235
+ ${v}
236
+ </div>
237
+ </body>
238
+ </html>
239
+ `), y.close());
240
+ }
241
+ return (n, v) => (i(), ie(jt, { to: "body" }, [
242
+ n.modelValue ? (i(), b("div", {
243
+ key: 0,
244
+ class: "fixed inset-0 z-[9999] bg-black/50 flex justify-center items-center",
245
+ onClick: Bt(o, ["self"])
246
+ }, [
247
+ e("div", Fr, [
248
+ e("div", Ir, [
249
+ e("div", qr, [
250
+ v[0] || (v[0] = e("span", { class: "text-base font-semibold text-gray-700" }, "Print Preview", -1)),
251
+ n.templateName ? (i(), b("span", {
252
+ key: 0,
253
+ class: je(["text-xs font-medium px-2 py-0.5 rounded", n.isDefault ? "text-gray-500 bg-gray-100" : "text-blue-700 bg-blue-50"])
254
+ }, p(n.templateName), 3)) : U("", !0),
255
+ n.isDefault ? (i(), b("span", Er, "Default")) : U("", !0)
256
+ ]),
257
+ e("div", { class: "flex gap-2 items-center" }, [
258
+ e("button", {
259
+ class: "px-8 py-1.5 bg-blue-500 text-white border-none rounded text-sm cursor-pointer hover:bg-blue-700",
260
+ onClick: m
261
+ }, " Print "),
262
+ e("button", {
263
+ class: "px-2.5 py-1 bg-transparent border border-gray-300 rounded text-xl leading-none cursor-pointer text-gray-500 hover:bg-gray-100",
264
+ onClick: o
265
+ }, " × ")
266
+ ])
267
+ ]),
268
+ e("div", Vr, [
269
+ e("iframe", {
270
+ ref_key: "iframeRef",
271
+ ref: c,
272
+ class: "w-full h-full border-none",
273
+ sandbox: "allow-same-origin allow-modals"
274
+ }, null, 512)
275
+ ])
276
+ ])
277
+ ])) : U("", !0)
278
+ ]));
279
+ }
280
+ }), Lr = or((f, r) => {
281
+ const s = Te();
282
+ return {
283
+ async getShipments({
284
+ start: l,
285
+ end: c
286
+ }) {
287
+ const o = s.currentLocationDBName, m = `${f.inventoryBackendUrl}/${o}/shipments`;
288
+ return await r.get(`${m}?start=${l}&end=${c}`);
289
+ },
290
+ async getShipmentsByIds(l) {
291
+ if (l.length === 0)
292
+ return [];
293
+ const c = s.currentLocationDBName, o = `${f.inventoryBackendUrl}/${c}/shipments/get`;
294
+ return await r.post(o, { shipmentIds: l });
295
+ }
296
+ };
297
+ }), It = {
298
+ [q.enum.confirmDraft]: {
299
+ primaryActions: {
300
+ text: "Confirm draft",
301
+ close: !0
302
+ },
303
+ title: "Confirm draft?",
304
+ message: "Purchase order cannot be changed after confirm draft.",
305
+ successMessage: "Purchase order draft has been confirmed"
306
+ },
307
+ [q.enum.cancelDraft]: {
308
+ primaryActions: {
309
+ text: "Cancel draft",
310
+ close: !0,
311
+ variant: "destructive"
312
+ },
313
+ title: "Cancel draft?",
314
+ message: "Purchase order cannot be changed after cancelled draft.",
315
+ successMessage: "Purchase order draft has been cancelled"
316
+ },
317
+ [q.enum.approveDraft]: {
318
+ primaryActions: {
319
+ text: "Approve draft",
320
+ close: !0
321
+ },
322
+ title: "Approve draft?",
323
+ message: "Purchase order request will be accepted.",
324
+ successMessage: "Purchase order has been approved"
325
+ },
326
+ [q.enum.rejectDraft]: {
327
+ primaryActions: {
328
+ text: "Reject draft",
329
+ close: !0
330
+ },
331
+ title: "Reject draft?",
332
+ message: "Purchase order request will be rejected. You may provide an optional reason for rejection.",
333
+ successMessage: "Purchase order has been rejected"
334
+ },
335
+ [q.enum.submitRequest]: {
336
+ primaryActions: {
337
+ text: "Submit request",
338
+ close: !0
339
+ },
340
+ title: "Confirm draft?",
341
+ message: "Purchase order cannot be changed after confirm draft.",
342
+ successMessage: "Purchase order draft has been submitted"
343
+ },
344
+ [q.enum.completeReceive]: {
345
+ primaryActions: {
346
+ text: "Mark received",
347
+ close: !0
348
+ },
349
+ title: "Mark as received",
350
+ message: "Purchase order cannot be changed after it has complete receiving.",
351
+ successMessage: "Purchase order has been marked as received"
352
+ },
353
+ [q.enum.approveRequest]: {
354
+ primaryActions: {
355
+ text: "Accept request",
356
+ close: !0
357
+ },
358
+ title: "Accept request?",
359
+ message: "Transfer out request will be accepted.",
360
+ successMessage: "Transfer out request has been approved"
361
+ },
362
+ [q.enum.rejectRequest]: {
363
+ primaryActions: {
364
+ text: "Reject request",
365
+ close: !0,
366
+ variant: "destructive"
367
+ },
368
+ title: "Reject request?",
369
+ message: "Purchase order will be rejected.",
370
+ successMessage: "Purchase order has been rejected"
371
+ },
372
+ [q.enum.processRequest]: {
373
+ primaryActions: {
374
+ text: "Process request",
375
+ close: !0,
376
+ variant: "destructive"
377
+ },
378
+ title: "Process request?",
379
+ message: "Purchase order will be processed.",
380
+ successMessage: "Purchase order has been processed"
381
+ }
382
+ }, Mr = { class: "p-4" }, Ur = {
383
+ key: 0,
384
+ class: "fm-typo-en-body-md-400 mb-3"
385
+ }, jr = { class: "fm-typo-en-body-md-400" }, qt = /* @__PURE__ */ De({
386
+ __name: "RejectDraftForm",
387
+ props: {
388
+ message: {},
389
+ confirm: { type: Function },
390
+ onChange: { type: Function }
391
+ },
392
+ setup(f) {
393
+ const r = f, { t: s } = it(), l = G("");
394
+ Ke(l, (o) => {
395
+ var m;
396
+ (m = r.onChange) == null || m.call(r, o ?? "");
397
+ });
398
+ function c() {
399
+ l.value = "";
400
+ }
401
+ return (o, m) => (i(), b("div", Mr, [
402
+ r.message ? (i(), b("div", Ur, p(r.message), 1)) : U("", !0),
403
+ e("label", jr, p(d(s)("inventory.transfer.receiveRequest.details.rejectionReason")) + " (" + p(d(s)("inventory.common.optional")) + ")", 1),
404
+ zt(e("textarea", {
405
+ "onUpdate:modelValue": m[0] || (m[0] = (t) => l.value = t),
406
+ rows: "4",
407
+ class: "w-full mt-2 p-2 border rounded"
408
+ }, null, 512), [
409
+ [Kt, l.value]
410
+ ]),
411
+ e("div", { class: "mt-3 flex gap-2" }, [
412
+ e("button", {
413
+ type: "button",
414
+ class: "fm-btn fm-btn-tertiary",
415
+ onClick: c
416
+ }, "Clear")
417
+ ])
418
+ ]));
419
+ }
420
+ });
421
+ function at(f) {
422
+ return lt.generatedPOReceivedMap({
423
+ purchaseOrder: f
424
+ });
425
+ }
426
+ function Br(f) {
427
+ return lt.validatePOItemReceivedStatus({
428
+ dto: f
429
+ });
430
+ }
431
+ function vt(f) {
432
+ return lt.validatePOReceivedStatus({
433
+ receivedMap: f
434
+ });
435
+ }
436
+ function bt(f, r, s) {
437
+ if (!ae.safeParse(f).success)
438
+ throw new Error(`Invalid purchase order status: ${f}`);
439
+ const l = ae.parse(f);
440
+ return lt.orderStatusCombination({
441
+ status: l,
442
+ isPOPartialReceive: r,
443
+ isPOOverReceive: s
444
+ });
445
+ }
446
+ function Et() {
447
+ const f = Te(), r = We(), s = Ee();
448
+ async function l(o, m) {
449
+ const t = f.currentLocationDBName;
450
+ return o.doc.supplier.internal && o.operation === q.enum.confirmDraft && (o.operation = q.enum.submitRequest), await r.processPurchaseOrder(o, m || t);
451
+ }
452
+ async function c(o, m) {
453
+ const t = f.currentLocationDBName;
454
+ return await r.processPurchaseOrderV2(o, m || t);
455
+ }
456
+ return (o) => s.useOperatePurchaseOrderV2 ? c(o.operateV2, o.transferTo) : l(o.operate, o.transferTo);
457
+ }
458
+ function qe(f) {
459
+ const r = Ht(f);
460
+ if (Array.isArray(r))
461
+ return r.map(qe);
462
+ if (r !== null && typeof r == "object") {
463
+ const s = {};
464
+ for (const l in r)
465
+ Object.prototype.hasOwnProperty.call(r, l) && (s[l] = qe(r[l]));
466
+ return s;
467
+ }
468
+ return r;
469
+ }
470
+ const pt = {
471
+ set: "set",
472
+ add: "add",
473
+ delete: "delete"
474
+ };
475
+ function kt(f) {
476
+ return {
477
+ dbName: f.dbName,
478
+ type: f.type,
479
+ name: f.name,
480
+ acceptRequest: f.acceptRequest ?? !1,
481
+ doc: f.doc
482
+ };
483
+ }
484
+ function Rt(f, r, s, l, c) {
485
+ const o = qe(f.suppliers ?? []), m = qe(r.allLocations ?? []).map(kt), t = r._currentLocation ? kt(qe(r._currentLocation)) : null, n = s.inventory ? [qe(s.inventory)] : [], v = l.state.setting ? qe(l.state.setting) : null, y = qe(c.surcharges ?? []);
486
+ return {
487
+ suppliers: o,
488
+ locations: m,
489
+ currentLocation: t,
490
+ inventoryDoc: n,
491
+ netSuiteSetting: v,
492
+ surcharges: y
493
+ };
494
+ }
495
+ function Vt() {
496
+ const f = Rr(), r = Te(), s = nr(), l = ut(), c = Nr(), o = Rt(
497
+ f,
498
+ r,
499
+ s,
500
+ l,
501
+ c
502
+ ), m = St(fr({ env: o }));
503
+ m.value.setUsePartialUpdates(!0);
504
+ const t = St(m.value.state()), n = (h) => {
505
+ t.value = h;
506
+ };
507
+ m.value.addListener(n);
508
+ const v = (h, D, x) => {
509
+ switch (h) {
510
+ case pt.set:
511
+ wt(t.value, D, x);
512
+ break;
513
+ case pt.add:
514
+ lr(t.value, D, x);
515
+ break;
516
+ case pt.delete:
517
+ ar(t.value, D);
518
+ break;
519
+ default:
520
+ console.warn(`Unknown partial update operation: ${h}, falling back to 'set'`), wt(t.value, D, x);
521
+ }
522
+ D !== "remark" && D !== "ref" && Gt(t);
523
+ };
524
+ m.value.addPartialListener(v);
525
+ function y() {
526
+ const h = Rt(
527
+ f,
528
+ r,
529
+ s,
530
+ l,
531
+ c
532
+ );
533
+ m.value.updateFullEnv(h), t.value = m.value.state();
534
+ }
535
+ Ke(
536
+ [
537
+ () => f.suppliers,
538
+ () => r.allLocations,
539
+ () => r._currentLocation,
540
+ () => s.inventory,
541
+ () => l.state.setting,
542
+ () => c.surcharges
543
+ ],
544
+ () => {
545
+ y();
546
+ },
547
+ { deep: !0 }
548
+ ), Wt(() => {
549
+ m.value.removeListener(n), m.value.removePartialListener(v);
550
+ });
551
+ function _(h) {
552
+ var D;
553
+ if (h != null && h._id) {
554
+ m.value.loadPurchaseOrder(h);
555
+ return;
556
+ }
557
+ if (!Ee().mustUsePoTemplate) {
558
+ m.value.init();
559
+ return;
560
+ }
561
+ h != null && h.template && ((D = h.templateDoc) != null && D.purchaseOrder) ? (h.items = h.templateDoc.purchaseOrder.items, m.value.initFromTemplate(h)) : m.value.initOutletToOutlet();
562
+ }
563
+ return {
564
+ controller: m,
565
+ state: t,
566
+ init: _
567
+ };
568
+ }
569
+ var gt = /* @__PURE__ */ ((f) => (f.RECEIVE_REQUEST = "receive/request", f.APPROVAL = "approval", f))(gt || {});
570
+ const Qe = G(), ft = G();
571
+ function Ja(f, r) {
572
+ const s = dt(), l = Te(), c = Ee(), o = hr(), m = _r(), t = G(!1), n = He(), v = We(), y = Lr(), _ = G(new Array()), h = G(new Array()), D = G(
573
+ r != null && r.startDate && (r != null && r.endDate) ? r : kr()
574
+ ), x = Z(() => {
575
+ const F = new Date(D.value.startDate), I = new Date(D.value.endDate);
576
+ return {
577
+ start: mr(F).toISOString(),
578
+ end: pr(I).toISOString()
579
+ };
580
+ }), M = G(new Array()), R = ir(), j = G(null);
581
+ async function O(F) {
582
+ function I(w) {
583
+ const g = {
584
+ mode: $t.CREATE,
585
+ modelValue: F || void 0,
586
+ show: !0,
587
+ "onUpdate:show"(V) {
588
+ Qe.value.show = V;
589
+ },
590
+ templateId: w,
591
+ lastClosingDate: j.value
592
+ };
593
+ Qe.value = g;
594
+ }
595
+ let ee;
596
+ c.mustUsePoTemplate && !(F != null && F.template) ? s.open({
597
+ title: "Create transfer",
598
+ message: "",
599
+ primaryActions: {
600
+ text: "Select a template",
601
+ close: !0
602
+ },
603
+ secondaryActions: {
604
+ text: "Outlet to Outlet",
605
+ variant: "secondary",
606
+ close: !0
607
+ }
608
+ }).onPrimary(async () => {
609
+ ee = await o.getTemplateId(), ee && I(ee);
610
+ }).onSecondary(() => {
611
+ I(void 0);
612
+ }) : I(ee);
613
+ }
614
+ function k(F) {
615
+ const I = {
616
+ mode: $t.UPDATE,
617
+ modelValue: At(F),
618
+ show: !0,
619
+ "onUpdate:show"(ee) {
620
+ Qe.value.show = ee;
621
+ },
622
+ lastClosingDate: j.value
623
+ };
624
+ Qe.value = I;
625
+ }
626
+ async function Y() {
627
+ _.value = [], h.value = [], t.value = !0;
628
+ try {
629
+ const F = await v.getPurchaseOrders(x.value);
630
+ _.value = F.sort((H, ce) => ce._id.localeCompare(H._id));
631
+ const I = F.flatMap((H) => H.shipmentIds || []).filter(Boolean), ee = I.length > 0 ? await y.getShipmentsByIds(I) : [];
632
+ h.value = ee;
633
+ const w = await R.readCurrentLocationLastClosing(!0), g = w == null ? void 0 : w._id;
634
+ g && (j.value = sr(g)), await c.awaitFeatureLoaded(() => c.mustUsePoTemplate) && await m.fetchTemplates();
635
+ const V = _.value.map((H) => {
636
+ var ce;
637
+ return ((ce = H.request) == null ? void 0 : ce.id) ?? "";
638
+ }).filter((H) => H);
639
+ M.value = await v.readRequestByIds(V);
640
+ } catch {
641
+ n.open({
642
+ title: "Something went wrong",
643
+ message: "Error at fetching purchase orders",
644
+ type: "error"
645
+ });
646
+ } finally {
647
+ t.value = !1;
648
+ }
649
+ }
650
+ async function N() {
651
+ M.value = [], t.value = !0;
652
+ try {
653
+ M.value = await v.readRequests(
654
+ void 0,
655
+ x.value.start,
656
+ x.value.end
657
+ ).then((F) => F.reverse());
658
+ } catch {
659
+ n.open({
660
+ title: "Something went wrong",
661
+ message: "Error at fetching purchase requests",
662
+ type: "error"
663
+ });
664
+ } finally {
665
+ t.value = !1;
666
+ }
667
+ }
668
+ function P() {
669
+ switch (f) {
670
+ case "receive/request":
671
+ return Y();
672
+ case "approval":
673
+ return N();
674
+ }
675
+ }
676
+ function $(F, I) {
677
+ D.value = {
678
+ startDate: F,
679
+ endDate: I
680
+ }, P();
681
+ }
682
+ l.watchLocation(async (F) => {
683
+ if (!F) {
684
+ _.value = [];
685
+ return;
686
+ }
687
+ await P();
688
+ });
689
+ const S = G(), T = G(Math.random().toString());
690
+ async function W(F, I) {
691
+ const ee = Math.random().toString();
692
+ T.value = ee, I ?? (I = M.value.computeFirst(
693
+ (H) => H.purchaseOrderId === F._id ? H : null
694
+ ) ?? void 0);
695
+ const w = f === "receive/request" ? l.currentLocation : I == null ? void 0 : I.to, g = f === "approval", V = {
696
+ poRequest: I,
697
+ purchaseOrder: {
698
+ ...F,
699
+ status: g && (I != null && I.rejectedAt) ? ae.Enum.REJECT : F.status
700
+ },
701
+ transferTo: w == null ? void 0 : w.name,
702
+ transferToDbName: w == null ? void 0 : w.dbName,
703
+ show: !0,
704
+ canResubmit: !1,
705
+ canApprove: g,
706
+ "onUpdate:show"(H) {
707
+ S.value.show = H;
708
+ },
709
+ scope: f,
710
+ receivedMap: at(F) ?? {},
711
+ shipments: h.value
712
+ };
713
+ S.value = V;
714
+ }
715
+ async function Q(F, I, ee, w, g) {
716
+ const V = Et();
717
+ t.value = !0;
718
+ try {
719
+ await V({
720
+ operate: {
721
+ operation: I,
722
+ doc: F,
723
+ options: (
724
+ // auto receive for supplier to warehouse
725
+ (I === q.enum.confirmDraft || // auto receive for warehouse to warehouse
726
+ I === q.enum.completeReceive) && c.autoReceiveWarehouse ? {
727
+ autoReceive: !0
728
+ } : void 0
729
+ )
730
+ },
731
+ operateV2: {
732
+ _id: F._id,
733
+ _rev: F._rev ?? "",
734
+ action: I,
735
+ payloads: g ?? []
736
+ },
737
+ transferTo: w
738
+ }), await new Promise((Re) => setTimeout(Re, 1e3));
739
+ const ce = Te().currentLocationDBName.startsWith("restaurant_");
740
+ I === q.enum.confirmDraft && F.effectiveAt && ce ? n.open({
741
+ title: "Success",
742
+ message: `${ee}. The backdate will be reflected once your POS has received this change.`,
743
+ type: "success"
744
+ }) : n.open({
745
+ title: "Success",
746
+ message: ee,
747
+ type: "success"
748
+ });
749
+ } catch (H) {
750
+ n.open({
751
+ title: "Something went wrong",
752
+ message: "Please try again.",
753
+ type: "error"
754
+ }), console.error("Error when submitting PO operation", I, F, H);
755
+ } finally {
756
+ t.value = !1, P();
757
+ }
758
+ }
759
+ async function ye(F, I, ee) {
760
+ const w = It[I];
761
+ if (!w) {
762
+ n.open({
763
+ title: "Something went wrong",
764
+ message: `Cannot process order: ${ht(I)}`,
765
+ type: "error"
766
+ });
767
+ return;
768
+ }
769
+ const { successMessage: g, ...V } = w;
770
+ if (I === q.enum.rejectDraft) {
771
+ let Re = "";
772
+ s.open({
773
+ title: V.title,
774
+ message: V.message,
775
+ primaryActions: V.primaryActions,
776
+ contentComponent: qt,
777
+ contentComponentProps: {
778
+ message: V.message,
779
+ onChange: (Oe) => Re = Oe
780
+ }
781
+ }).onPrimary(() => {
782
+ const Oe = [];
783
+ Oe.push({
784
+ action: "rejectDraft",
785
+ payload: {
786
+ rejectReason: Re
787
+ }
788
+ }), Q(F, I, g, ee, Oe);
789
+ });
790
+ return;
791
+ }
792
+ const H = [], ce = Vt();
793
+ ce.init(F), I === q.enum.confirmDraft && H.push({
794
+ action: "confirmDraft",
795
+ payload: ce.controller.value.toConfirmDraftData(Ce())
796
+ }), s.open({
797
+ title: V.title,
798
+ message: V.message,
799
+ primaryActions: V.primaryActions
800
+ }).onPrimary(() => {
801
+ Q(F, I, g, ee, H);
802
+ });
803
+ }
804
+ async function ge() {
805
+ s.open({
806
+ title: "Upload Transfer",
807
+ primaryActions: {
808
+ text: "Xilnex transfer note",
809
+ close: !0
810
+ },
811
+ secondaryActions: {
812
+ text: "Cancel",
813
+ close: !0
814
+ }
815
+ }).onPrimary(() => {
816
+ const F = {
817
+ show: !0,
818
+ "onUpdate:show"(I) {
819
+ ft.value.show = I;
820
+ }
821
+ };
822
+ ft.value = F;
823
+ });
824
+ }
825
+ return {
826
+ purchaseOrders: _,
827
+ shipments: h,
828
+ purchaseRequests: M,
829
+ updateDateRange: $,
830
+ fetchData: P,
831
+ loading: t,
832
+ transferDialogProps: Qe,
833
+ promptCreateTransferDialog: O,
834
+ promptUpdateTransferDialog: k,
835
+ transferDetailsProps: S,
836
+ promptShowTransferDetails: W,
837
+ submitAction: ye,
838
+ xilnexImportDialogProps: ft,
839
+ promptUploadTransferDialog: ge
840
+ };
841
+ }
842
+ function zr(f) {
843
+ const { po: r, currentLocation: s, business: l, fulfilling: c, por: o } = f, { name: m, address: t, regNo: n, legalName: v } = s.doc.profile, y = {
844
+ name: m,
845
+ legalName: v,
846
+ registrationNumber: n,
847
+ line1: t == null ? void 0 : t.line1,
848
+ line2: t == null ? void 0 : t.line2,
849
+ postcode: t == null ? void 0 : t.postcode,
850
+ city: t == null ? void 0 : t.city,
851
+ state: t == null ? void 0 : t.state,
852
+ country: t == null ? void 0 : t.country
853
+ }, _ = {
854
+ name: r.supplier.name,
855
+ phoneNumber: r.supplier.phoneNumber,
856
+ registrationNumber: r.supplier.registrationNumber,
857
+ line1: r.supplier.address.line1,
858
+ line2: r.supplier.address.line2,
859
+ postcode: r.supplier.address.postcode,
860
+ city: r.supplier.address.city,
861
+ state: r.supplier.address.state,
862
+ country: r.supplier.address.country
863
+ }, h = r.items.map((N) => {
864
+ const { sku: P, measurement: $ } = N, S = be(
865
+ Ft(N.sku, r.deliveryOrder || []),
866
+ !1
867
+ );
868
+ return {
869
+ code: P.code,
870
+ description: P.name,
871
+ quantity: be(N.quantity, !1),
872
+ unit: ($ == null ? void 0 : $.abbrev) || P.unit.abbrev,
873
+ received: S,
874
+ cost: N.totalCost ? `${N.totalCost.currency} ${Xe.toFormatString({
875
+ value: N.totalCost
876
+ })}` : void 0
877
+ };
878
+ }), D = r.deliveryOrder.map((N) => ({
879
+ createdAt: _t(new Date(N.createdAt)),
880
+ ref: N.deliveryOrderNumber,
881
+ remark: N.remark || "",
882
+ items: N.received.map((P) => {
883
+ var $;
884
+ return {
885
+ code: P.sku.code,
886
+ description: P.sku.name,
887
+ quantity: be(P.amount),
888
+ unit: (($ = P.measurement) == null ? void 0 : $.abbrev) || P.sku.unit.abbrev
889
+ };
890
+ })
891
+ })), x = [
892
+ // Production
893
+ "67ca5d2c80bd0e001c5bf5bc",
894
+ // Dev
895
+ "6880b36a3054c5001db19218"
896
+ ];
897
+ let M = "Inventory Receive Note";
898
+ if (r.supplier.internal ? (M = "Inventory Transfer Note", x.includes((l == null ? void 0 : l._id) || "") && (M = "Stock Request")) : M = "Purchase Order", o) {
899
+ const N = o.from.dbName;
900
+ s.dbName === N || (M = "Inventory Receive Note");
901
+ }
902
+ const j = {
903
+ title: M,
904
+ businessName: l == null ? void 0 : l.name,
905
+ logo: l == null ? void 0 : l.thumbnail,
906
+ orderNumber: r.seqNumber.toString(),
907
+ createdAt: tt(r._id),
908
+ ref: r.ref || "",
909
+ remark: r.remark || "",
910
+ buyer: y,
911
+ supplier: _,
912
+ items: h,
913
+ status: r.status,
914
+ deliveryOrders: D
915
+ }, O = new URL(window.location.href), k = c && (r.deliveryFullfillment || []).length > 0 ? "receive-request/delivery-print-preview" : "receive-request/print-preview";
916
+ O.pathname = O.hostname.includes("portal.feedme") ? `/inventory/${k}` : `/${k}`;
917
+ const Y = yr.compressToEncodedURIComponent(JSON.stringify(j));
918
+ O.searchParams.append("data", Y), window.open(O.href, "_blank", "noreferrer");
919
+ }
920
+ const Ie = {
921
+ submitRequest: {
922
+ translationKey: "inventory.transfer.receiveRequest.actions.submitRequest",
923
+ color: "text-fm-color-typo-primary",
924
+ value: q.enum.submitRequest
925
+ },
926
+ confirmDraft: {
927
+ translationKey: "inventory.transfer.receiveRequest.actions.confirmDraft",
928
+ color: "text-fm-color-typo-primary",
929
+ value: q.enum.confirmDraft
930
+ },
931
+ cancelDraft: {
932
+ translationKey: "inventory.transfer.receiveRequest.actions.cancelDraft",
933
+ color: "text-fm-color-typo-error",
934
+ value: q.enum.cancelDraft
935
+ },
936
+ approveRequest: {
937
+ translationKey: "inventory.transfer.receiveRequest.actions.approveRequest",
938
+ color: "text-fm-color-typo-primary",
939
+ value: q.enum.approveRequest
940
+ },
941
+ rejectRequest: {
942
+ translationKey: "inventory.transfer.receiveRequest.actions.rejectRequest",
943
+ color: "text-fm-color-typo-error",
944
+ value: q.enum.rejectRequest
945
+ },
946
+ processRequest: {
947
+ translationKey: "inventory.transfer.receiveRequest.actions.processRequest",
948
+ color: "text-fm-color-typo-primary",
949
+ value: q.enum.processRequest
950
+ },
951
+ receiveStock: {
952
+ translationKey: "inventory.transfer.receiveRequest.actions.receiveStock",
953
+ color: "text-fm-color-typo-primary",
954
+ value: q.enum.receiveStock
955
+ },
956
+ completeReceive: {
957
+ translationKey: "inventory.transfer.receiveRequest.actions.completeReceive",
958
+ color: "text-fm-color-typo-primary",
959
+ value: q.enum.completeReceive
960
+ },
961
+ closeRequest: {
962
+ translationKey: "inventory.transfer.receiveRequest.actions.closeRequest",
963
+ color: "system-error-300",
964
+ value: q.enum.closeRequest
965
+ },
966
+ approveDraft: {
967
+ translationKey: "inventory.transfer.receiveRequest.actions.approveDraft",
968
+ color: "text-fm-color-typo-primary",
969
+ value: q.enum.approveDraft
970
+ },
971
+ rejectDraft: {
972
+ translationKey: "inventory.transfer.receiveRequest.actions.rejectDraft",
973
+ color: "text-fm-color-typo-error",
974
+ value: q.enum.rejectDraft
975
+ },
976
+ returnStock: {
977
+ translationKey: "inventory.transfer.receiveRequest.actions.returnStock",
978
+ color: "text-fm-color-typo-primary",
979
+ value: q.enum.returnStock
980
+ }
981
+ };
982
+ function Lt() {
983
+ const f = Ee();
984
+ return {
985
+ ableToMarkReceived(r) {
986
+ if (!r || r.status !== ae.enum.RECEIVING || f.useOperatePurchaseOrderV2) return !1;
987
+ const l = Te().currentLocationDBName;
988
+ return `${r.supplier.internal}_${r.supplier._id}` !== l;
989
+ },
990
+ ableToMarkApproved(r) {
991
+ return !(!r || (r == null ? void 0 : r.status) !== ae.enum.REQUESTING);
992
+ },
993
+ ableToCreateFulfillment(r, s) {
994
+ var o, m;
995
+ if (!f.acceptRequireFulfillment || !r || !s || r.status !== ae.enum.PROCESSING || !s.processedAt)
996
+ return !1;
997
+ const l = (o = s == null ? void 0 : s.from) == null ? void 0 : o.dbName, c = (m = s == null ? void 0 : s.to) == null ? void 0 : m.dbName;
998
+ return !(l.startsWith("restaurant_") && c.startsWith("restaurant_"));
999
+ }
1000
+ };
1001
+ }
1002
+ function Mt() {
1003
+ const f = ct(), r = G(!1);
1004
+ return Ke(() => f.sessionUser.value, async () => {
1005
+ try {
1006
+ const l = await vr({
1007
+ sessionUser: f.sessionUser.value,
1008
+ validationManifest: {
1009
+ requiredCaslPermissions: [
1010
+ {
1011
+ action: Ct.Action.manage,
1012
+ subject: Ct.Subject.Business.orderDraft
1013
+ }
1014
+ ]
1015
+ }
1016
+ });
1017
+ r.value = (l == null ? void 0 : l.canAccess) ?? !1;
1018
+ } catch (l) {
1019
+ console.error("Permission validation failed:", l), r.value = !1;
1020
+ }
1021
+ }, { immediate: !0 }), {
1022
+ hasOrderDraftPermission: Yt(r)
1023
+ };
1024
+ }
1025
+ function Xa(f, r, s) {
1026
+ const l = Te(), c = ut(), o = ct(), m = Lt(), { t } = it(), { hasOrderDraftPermission: n } = Mt(), v = Ee(), y = Z(
1027
+ () => v.enablePrintTemplate ? [xe[ue.PrintCustom]] : []
1028
+ );
1029
+ function _(N) {
1030
+ switch (N.status) {
1031
+ case "DRAFT":
1032
+ return [
1033
+ xe[ue.Update],
1034
+ xe[ue.Details],
1035
+ N.supplier.internal === "restaurant" || N.supplier.internal === "warehouse" ? Ie[q.enum.submitRequest] : Ie[q.enum.confirmDraft],
1036
+ Ie[q.enum.cancelDraft]
1037
+ ];
1038
+ case "RECEIVING":
1039
+ return [
1040
+ ...m.ableToMarkReceived(N) ? [Ie[q.enum.completeReceive]] : [],
1041
+ xe[ue.Details],
1042
+ xe[ue.Print],
1043
+ ...y.value
1044
+ ];
1045
+ case "PENDING_APPROVAL": {
1046
+ const $ = [xe[ue.Details]];
1047
+ return n.value && $.push(
1048
+ xe[ue.Update],
1049
+ Ie[q.enum.approveDraft],
1050
+ Ie[q.enum.rejectDraft]
1051
+ ), $;
1052
+ }
1053
+ case "REQUESTING":
1054
+ return f === "receive/request" ? [
1055
+ xe[ue.Details],
1056
+ xe[ue.Print],
1057
+ ...y.value
1058
+ ] : [
1059
+ Ie[q.enum.approveRequest],
1060
+ Ie[q.enum.rejectRequest],
1061
+ xe[ue.Details]
1062
+ // DefaultRowActions[RowActionEnum.Print]
1063
+ ];
1064
+ case "PROCESSING":
1065
+ return [
1066
+ xe[ue.Details],
1067
+ xe[ue.Print],
1068
+ ...y.value
1069
+ ];
1070
+ case "COMPLETE":
1071
+ case "CANCEL":
1072
+ default:
1073
+ return [
1074
+ xe[ue.Details],
1075
+ xe[ue.Print],
1076
+ ...y.value
1077
+ ];
1078
+ }
1079
+ }
1080
+ function h(N) {
1081
+ return Object.values(q.enum).includes(N);
1082
+ }
1083
+ async function D(N, P, $) {
1084
+ var T, W, Q, ye, ge, F;
1085
+ const S = At(P);
1086
+ if (N === ue.Print || N === ue.PrintCustom) {
1087
+ const I = ($ == null ? void 0 : $.toInventoryLocation) ?? l.currentLocation;
1088
+ if (I.type === "restaurant") {
1089
+ const w = l.locationRestaurantFromCore(I.doc._id);
1090
+ w !== null && (I.doc = w);
1091
+ }
1092
+ ((T = $ == null ? void 0 : $.netSuite) != null && T.refNo || (W = S.netSuite) != null && W.refNo) && (S.ref = [((Q = $ == null ? void 0 : $.netSuite) == null ? void 0 : Q.refNo) || ((ye = S.netSuite) == null ? void 0 : ye.refNo)].filter((w) => w).join(" "));
1093
+ const ee = {
1094
+ po: S,
1095
+ currentLocation: I,
1096
+ business: o.currentBusiness.value,
1097
+ fulfilling: f === "approval",
1098
+ por: $
1099
+ };
1100
+ if (N === ue.PrintCustom) {
1101
+ const w = Tr(ee);
1102
+ w && (O.value = w.html, k.value = w.templateName, Y.value = w.isDefault, j.value = !0);
1103
+ } else
1104
+ zr(ee);
1105
+ return;
1106
+ }
1107
+ if (N === ue.Details) {
1108
+ r.promptShowTransferDetails(S, $);
1109
+ return;
1110
+ }
1111
+ if (N === ue.Update) {
1112
+ (ge = r.promptUpdateTransferDialog) == null || ge.call(r, S);
1113
+ return;
1114
+ }
1115
+ if (h(N)) {
1116
+ r.submitAction(P, N, (F = $ == null ? void 0 : $.to) == null ? void 0 : F.dbName);
1117
+ return;
1118
+ }
1119
+ }
1120
+ function x() {
1121
+ var P;
1122
+ const N = [
1123
+ {
1124
+ accessorKey: "seqNumber",
1125
+ header: () => t("inventory.transfer.table.seqNo"),
1126
+ enableSorting: !0,
1127
+ size: 80,
1128
+ sortUndefined: "last"
1129
+ },
1130
+ {
1131
+ accessorKey: "_id",
1132
+ header: () => t("inventory.transfer.table.createdAt"),
1133
+ cell($) {
1134
+ return tt(`${$.getValue()}`);
1135
+ },
1136
+ enableSorting: !0
1137
+ },
1138
+ {
1139
+ accessorKey: "supplier.name",
1140
+ header: () => t("inventory.transfer.table.transferFrom"),
1141
+ enableSorting: !0,
1142
+ size: 200
1143
+ },
1144
+ {
1145
+ accessorKey: "items.length",
1146
+ header: () => t("inventory.transfer.table.noOfItems"),
1147
+ cell: ($) => {
1148
+ const S = $.row.original.version || "1", T = $.getValue();
1149
+ return z("div", { class: "flex items-center gap-2" }, [
1150
+ T,
1151
+ S !== "1" ? z(
1152
+ "div",
1153
+ { class: "py-3" },
1154
+ z(
1155
+ Be,
1156
+ z(
1157
+ "div",
1158
+ {
1159
+ class: ["fm-status-badge", "fm-status-badge-draft"].join(" ")
1160
+ },
1161
+ `v${S}`
1162
+ )
1163
+ )
1164
+ ) : null
1165
+ ]);
1166
+ },
1167
+ enableSorting: !1,
1168
+ meta: {
1169
+ width: "10rem"
1170
+ }
1171
+ },
1172
+ {
1173
+ accessorKey: "ref",
1174
+ header: () => t("inventory.transfer.table.reference"),
1175
+ enableSorting: !1,
1176
+ size: "auto"
1177
+ },
1178
+ ...(P = o.sessionUser.value) != null && P.role.isAdmin ? [
1179
+ {
1180
+ id: "statusForAdmin",
1181
+ header: () => z(Be, {}, () => `${t("inventory.transfer.table.status")}`),
1182
+ cell($) {
1183
+ return $.row.original.status;
1184
+ },
1185
+ enableSorting: !0,
1186
+ size: 200
1187
+ }
1188
+ ] : [],
1189
+ {
1190
+ accessorKey: "status",
1191
+ header: () => t("inventory.transfer.table.status"),
1192
+ cell($) {
1193
+ const S = $.getValue(), T = at($.row.original), { partial: W, over: Q } = vt(T), ye = bt(S ?? "", W, Q);
1194
+ let ge = t(`inventory.transfer.status.${ye}`), F = `${S ?? ""}`.toLocaleLowerCase("en-us");
1195
+ ye === ae.enum.CLOSE && (ge = `${t(`inventory.transfer.status.${ae.enum.COMPLETE}`)}`), ye === "PARTIAL_RECEIVED" && F === ae.enum.PROCESSING.toLocaleLowerCase("en-us") && (F = ae.enum.RECEIVING.toLocaleLowerCase("en-us"));
1196
+ let I = null;
1197
+ const ee = s.value.find((w) => w.ref === $.row.original._id);
1198
+ if (ee != null && ee.milestones && ee.milestones.length > 0) {
1199
+ const w = ee.milestones[ee.milestones.length - 1];
1200
+ if (w.estimatedTime) {
1201
+ const g = new Date(w.estimatedTime), V = g.getDate().toString().padStart(2, "0");
1202
+ I = `${g.toLocaleString("en-US", { month: "short" })} ${V}`;
1203
+ }
1204
+ }
1205
+ return z(
1206
+ "div",
1207
+ {
1208
+ class: "flex"
1209
+ },
1210
+ [
1211
+ z(
1212
+ "div",
1213
+ { class: "flex items-center" },
1214
+ z(
1215
+ "div",
1216
+ {
1217
+ class: [
1218
+ "fm-status-badge",
1219
+ `fm-status-badge-${F}`,
1220
+ Q && "fm-status-badge-error"
1221
+ ].filter(Boolean).join(" ")
1222
+ },
1223
+ `${ge}`
1224
+ )
1225
+ ),
1226
+ ...I ? [
1227
+ z(
1228
+ "div",
1229
+ {
1230
+ class: "flex items-center gap-1 ml-2"
1231
+ },
1232
+ [
1233
+ z(nt.FmIcon, {
1234
+ name: "local_shipping",
1235
+ size: "md",
1236
+ color: "neutral-gray-400"
1237
+ }),
1238
+ z(
1239
+ "span",
1240
+ { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" },
1241
+ I
1242
+ )
1243
+ ]
1244
+ )
1245
+ ] : []
1246
+ ]
1247
+ );
1248
+ },
1249
+ enableSorting: !0,
1250
+ size: 150
1251
+ },
1252
+ {
1253
+ id: "action",
1254
+ cell($) {
1255
+ const S = $.row.original, T = _(S);
1256
+ return Ot(T, (W) => D(W, S));
1257
+ },
1258
+ enableSorting: !1,
1259
+ size: 40,
1260
+ meta: {
1261
+ cellClass: "",
1262
+ headerClass: ""
1263
+ }
1264
+ }
1265
+ ];
1266
+ if (c.isEnabled) {
1267
+ const $ = [
1268
+ {
1269
+ id: "netsuiteTransferOrder",
1270
+ accessorFn: (S) => {
1271
+ var T;
1272
+ return (T = S.netSuite) != null && T.id ? `${S.netSuite.refNo} (${S.netSuite.id})` : "N/A";
1273
+ },
1274
+ header: () => "NetSuite Order (ID)",
1275
+ cell(S) {
1276
+ var W;
1277
+ const T = S.row.original;
1278
+ return (W = T.netSuite) != null && W.id ? `${T.netSuite.refNo} (${T.netSuite.id})` : "N/A";
1279
+ },
1280
+ enableSorting: !1,
1281
+ size: 200,
1282
+ meta: {
1283
+ cellClass: "",
1284
+ headerClass: ""
1285
+ }
1286
+ },
1287
+ {
1288
+ id: "netsuiteTransactionNumber",
1289
+ accessorFn: (S) => {
1290
+ var T, W;
1291
+ return ((W = (T = S.netSuite) == null ? void 0 : T.additionalInfo) == null ? void 0 : W.transactionnumber) ?? "N/A";
1292
+ },
1293
+ header: () => "NetSuite Transaction No.",
1294
+ cell(S) {
1295
+ var W, Q;
1296
+ return ((Q = (W = S.row.original.netSuite) == null ? void 0 : W.additionalInfo) == null ? void 0 : Q.transactionnumber) ?? "N/A";
1297
+ },
1298
+ enableSorting: !1,
1299
+ size: 200,
1300
+ meta: {
1301
+ cellClass: "",
1302
+ headerClass: ""
1303
+ }
1304
+ }
1305
+ ];
1306
+ N.splice(N.length - 1, 0, ...$);
1307
+ }
1308
+ return N;
1309
+ }
1310
+ function M() {
1311
+ var P;
1312
+ const N = [
1313
+ {
1314
+ accessorKey: "purchaseOrder.seqNumber",
1315
+ header: () => t("inventory.transfer.table.seqNo"),
1316
+ enableSorting: !0,
1317
+ size: 80,
1318
+ sortUndefined: "last"
1319
+ },
1320
+ {
1321
+ accessorKey: "purchaseOrder._id",
1322
+ header: () => t("inventory.transfer.table.createdAt"),
1323
+ cell($) {
1324
+ return tt(`${$.getValue()}`);
1325
+ },
1326
+ enableSorting: !0
1327
+ },
1328
+ {
1329
+ accessorKey: "to.name",
1330
+ header: () => t("inventory.transfer.table.transferTo"),
1331
+ enableSorting: !1,
1332
+ size: 200
1333
+ },
1334
+ {
1335
+ accessorKey: "purchaseOrder.items.length",
1336
+ header: () => t("inventory.transfer.table.noOfItems"),
1337
+ enableSorting: !1
1338
+ },
1339
+ {
1340
+ accessorKey: "purchaseOrder.ref",
1341
+ header: () => t("inventory.transfer.table.reference"),
1342
+ enableSorting: !1,
1343
+ size: "auto"
1344
+ },
1345
+ ...(P = o.sessionUser.value) != null && P.role.isAdmin ? [
1346
+ {
1347
+ id: "statusForAdmin",
1348
+ header: () => z(Be, {}, () => `${t("inventory.transfer.table.status")}`),
1349
+ cell($) {
1350
+ return $.row.original.status;
1351
+ },
1352
+ enableSorting: !0,
1353
+ size: 200
1354
+ }
1355
+ ] : [],
1356
+ {
1357
+ accessorKey: "purchaseOrder.status",
1358
+ header: () => t("inventory.transfer.table.status"),
1359
+ cell($) {
1360
+ const S = $.row.original, T = $.getValue();
1361
+ if (!S.purchaseOrder)
1362
+ return z(nt.FmChip, {
1363
+ label: "N/A",
1364
+ compact: !0
1365
+ });
1366
+ const W = at(S.purchaseOrder), { partial: Q, over: ye } = vt(W), ge = bt(T ?? "", Q, ye);
1367
+ let F = t(`inventory.transfer.status.${ge}`), I = `${T ?? ""}`.toLocaleLowerCase("en-us");
1368
+ return ge === ae.enum.CLOSE && (F = `${t(`inventory.transfer.status.${ae.enum.COMPLETE}`)}`), ge === "PARTIAL_RECEIVED" && I === ae.enum.PROCESSING.toLocaleLowerCase("en-us") && (I = ae.enum.RECEIVING.toLocaleLowerCase("en-us")), S.rejectedAt && (F = t("inventory.transfer.status.REJECT"), I = ae.enum.REJECT.toLocaleLowerCase("en-us")), z(
1369
+ "div",
1370
+ {
1371
+ class: "flex"
1372
+ },
1373
+ z(
1374
+ "div",
1375
+ {
1376
+ class: [
1377
+ "fm-status-badge",
1378
+ `fm-status-badge-${I}`,
1379
+ ye && "fm-status-badge-error"
1380
+ ].filter(Boolean).join(" ")
1381
+ },
1382
+ `${F}`
1383
+ )
1384
+ );
1385
+ },
1386
+ enableSorting: !0
1387
+ },
1388
+ {
1389
+ id: "action",
1390
+ cell($) {
1391
+ const S = $.row.original, W = (S.purchaseOrder ? _(S.purchaseOrder) : []).map((Q) => Q.value === ue.Print ? {
1392
+ ...Q,
1393
+ translationKey: "inventory.transfer.receiveRequest.details.printDeliveryOrder"
1394
+ } : Q);
1395
+ return Ot(
1396
+ W,
1397
+ (Q) => S.purchaseOrder ? D(Q, S.purchaseOrder, S) : void 0
1398
+ );
1399
+ },
1400
+ enableSorting: !1,
1401
+ size: 40,
1402
+ meta: {
1403
+ cellClass: "",
1404
+ headerClass: ""
1405
+ }
1406
+ }
1407
+ ];
1408
+ if (c.isEnabled) {
1409
+ const $ = [
1410
+ {
1411
+ id: "netsuiteTransferOrder",
1412
+ accessorFn: (S) => {
1413
+ var T;
1414
+ return (T = S.netSuite) != null && T.id ? `${S.netSuite.refNo} (${S.netSuite.id})` : "N/A";
1415
+ },
1416
+ header: () => "NetSuite Order (ID)",
1417
+ cell(S) {
1418
+ var W;
1419
+ const T = S.row.original;
1420
+ return (W = T.netSuite) != null && W.id ? `${T.netSuite.refNo} (${T.netSuite.id})` : "N/A";
1421
+ },
1422
+ enableSorting: !1,
1423
+ size: 200,
1424
+ meta: {
1425
+ cellClass: "",
1426
+ headerClass: ""
1427
+ }
1428
+ },
1429
+ {
1430
+ id: "netsuiteTransactionNumber",
1431
+ accessorFn: (S) => {
1432
+ var T, W;
1433
+ return ((W = (T = S.netSuite) == null ? void 0 : T.additionalInfo) == null ? void 0 : W.transactionnumber) ?? "N/A";
1434
+ },
1435
+ header: () => "NetSuite Transaction No.",
1436
+ cell(S) {
1437
+ var W, Q;
1438
+ return ((Q = (W = S.row.original.netSuite) == null ? void 0 : W.additionalInfo) == null ? void 0 : Q.transactionnumber) ?? "N/A";
1439
+ },
1440
+ enableSorting: !1,
1441
+ size: 200,
1442
+ meta: {
1443
+ cellClass: "",
1444
+ headerClass: ""
1445
+ }
1446
+ }
1447
+ ];
1448
+ N.splice(N.length - 2, 0, ...$);
1449
+ }
1450
+ return N;
1451
+ }
1452
+ const R = Z(() => f === "receive/request" ? x() : M()), j = G(!1), O = G(""), k = G(""), Y = G(!1);
1453
+ return {
1454
+ columnDefs: R,
1455
+ showCustomPrintDialog: j,
1456
+ customPrintHtml: O,
1457
+ customPrintTemplateName: k,
1458
+ customPrintIsDefault: Y
1459
+ };
1460
+ }
1461
+ const Kr = { class: "border border-fm-color-neutral-gray-200 fm-corner-radius-lg p-16" }, Hr = { class: "flex flex-col gap-8" }, Wr = { class: "flex w-full justify-end gap-16" }, Gr = /* @__PURE__ */ De({
1462
+ __name: "FulfillmentForm",
1463
+ props: {
1464
+ purchaseOrder: {},
1465
+ confirm: { type: Function }
1466
+ },
1467
+ emits: ["update:show"],
1468
+ setup(f, { emit: r }) {
1469
+ const s = f, l = Qt({
1470
+ id: "",
1471
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
1472
+ items: []
1473
+ }), c = G(), o = r;
1474
+ Nt(() => {
1475
+ s.purchaseOrder && (l.items = s.purchaseOrder.items.map((t) => ({
1476
+ id: t.id,
1477
+ sku: t.sku,
1478
+ measurement: t.measurement,
1479
+ amount: t.quantity ?? { amount: 1, precision: 0 }
1480
+ })));
1481
+ });
1482
+ const m = Z(() => l.items.length <= 10);
1483
+ return (t, n) => {
1484
+ const v = X("FmTable"), y = X("FmButton"), _ = X("FmForm");
1485
+ return i(), ie(_, {
1486
+ ref_key: "formRef",
1487
+ ref: c,
1488
+ class: "bg-white flex flex-col gap-32 rounded-3xl p-24 w-[800px]",
1489
+ onValidationFailed: console.log,
1490
+ onValidationSuccess: n[1] || (n[1] = () => s.confirm(l))
1491
+ }, {
1492
+ default: oe(() => [
1493
+ n[2] || (n[2] = e("div", { class: "fm-typo-en-title-sm-600" }, "Confirm the transfer amount", -1)),
1494
+ e("div", Kr, [
1495
+ e("div", Hr, [
1496
+ L(v, {
1497
+ "column-defs": [
1498
+ {
1499
+ header: "Code",
1500
+ cell: (h) => {
1501
+ const D = s.purchaseOrder.items.find((x) => x.id === h.row.original.id || x.sku._id === h.row.original.sku._id);
1502
+ return z(
1503
+ d(nt).FmTooltip,
1504
+ {
1505
+ content: D.code,
1506
+ placement: "top",
1507
+ variant: "plain",
1508
+ zIndex: 50
1509
+ },
1510
+ z(
1511
+ "span",
1512
+ {
1513
+ class: "flex-auto line-clamp-2 text-ellipsis break-all"
1514
+ },
1515
+ D.code
1516
+ )
1517
+ );
1518
+ }
1519
+ },
1520
+ {
1521
+ header: "Name",
1522
+ cell: (h) => {
1523
+ const D = s.purchaseOrder.items.find((x) => x.id === h.row.original.id || x.sku._id === h.row.original.sku._id);
1524
+ return z(
1525
+ d(nt).FmTooltip,
1526
+ {
1527
+ content: D.name,
1528
+ placement: "top",
1529
+ variant: "plain",
1530
+ zIndex: 50
1531
+ },
1532
+ z(
1533
+ "span",
1534
+ {
1535
+ class: "flex-auto line-clamp-2 text-ellipsis break-all"
1536
+ },
1537
+ D.name
1538
+ )
1539
+ );
1540
+ }
1541
+ },
1542
+ {
1543
+ header: "Amount",
1544
+ cell: (h) => {
1545
+ const D = h.row.original, x = s.purchaseOrder.items.find((R) => R.id === D.id || R.sku._id === D.sku._id), M = D.amount ?? {
1546
+ amount: 1,
1547
+ precision: 0
1548
+ };
1549
+ return z(Or, {
1550
+ style: {
1551
+ flex: "1 1 0%"
1552
+ },
1553
+ modelValue: {
1554
+ amount: M,
1555
+ measurement: D.measurement ?? null
1556
+ },
1557
+ key: D.id ?? D.sku._id,
1558
+ unit: D.sku.unit,
1559
+ "onUpdate:modelValue": (R) => {
1560
+ if (!R) return;
1561
+ const j = l.items.find((O) => O.id === D.id || O.sku._id === D.sku._id);
1562
+ j && (j.amount = R.amount);
1563
+ },
1564
+ disableUnit: !0,
1565
+ rules: [
1566
+ d(wr)(
1567
+ +d(be)({ amount: 0, precision: 0 })
1568
+ ),
1569
+ d(Cr)(+d(be)(x.quantity))
1570
+ ],
1571
+ applyDefaultRules: !0
1572
+ });
1573
+ }
1574
+ }
1575
+ ],
1576
+ "row-data": l.items,
1577
+ "hide-footer": m.value
1578
+ }, null, 8, ["column-defs", "row-data", "hide-footer"])
1579
+ ])
1580
+ ]),
1581
+ e("div", Wr, [
1582
+ L(y, {
1583
+ class: "px-16",
1584
+ label: "Confirm",
1585
+ size: "md",
1586
+ variant: "primary",
1587
+ type: "submit"
1588
+ }),
1589
+ L(y, {
1590
+ class: "px-16",
1591
+ label: "Cancel",
1592
+ size: "md",
1593
+ variant: "secondary",
1594
+ onClick: n[0] || (n[0] = () => o("update:show", !1))
1595
+ })
1596
+ ])
1597
+ ]),
1598
+ _: 1
1599
+ }, 8, ["onValidationFailed"]);
1600
+ };
1601
+ }
1602
+ }), yt = {
1603
+ submitRequest: {
1604
+ translationKey: "inventory.transfer.receiveRequest.actions.submitRequest",
1605
+ color: "primary",
1606
+ buttonVariant: we.Primary
1607
+ },
1608
+ confirmDraft: {
1609
+ translationKey: "inventory.transfer.receiveRequest.actions.confirmDraft",
1610
+ color: "primary",
1611
+ buttonVariant: we.Primary
1612
+ },
1613
+ cancelDraft: {
1614
+ translationKey: "inventory.transfer.receiveRequest.actions.cancelDraft",
1615
+ color: "system-error-300",
1616
+ buttonVariant: we.Destructive
1617
+ },
1618
+ approveDraft: {
1619
+ translationKey: "inventory.transfer.receiveRequest.actions.approveDraft",
1620
+ color: "primary",
1621
+ buttonVariant: we.Primary
1622
+ },
1623
+ rejectDraft: {
1624
+ translationKey: "inventory.transfer.receiveRequest.actions.rejectDraft",
1625
+ color: "system-error-300",
1626
+ buttonVariant: we.Destructive
1627
+ },
1628
+ approveRequest: {
1629
+ translationKey: "inventory.transfer.receiveRequest.actions.approveRequest",
1630
+ color: "primary",
1631
+ buttonVariant: we.Primary
1632
+ },
1633
+ processRequest: {
1634
+ translationKey: "inventory.transfer.receiveRequest.actions.processRequest",
1635
+ color: "primary",
1636
+ buttonVariant: we.Primary
1637
+ },
1638
+ receiveStock: {
1639
+ translationKey: "inventory.transfer.receiveRequest.actions.receiveStock",
1640
+ color: "primary",
1641
+ buttonVariant: we.Primary,
1642
+ available: !1
1643
+ },
1644
+ completeReceive: {
1645
+ translationKey: "inventory.transfer.receiveRequest.actions.completeReceive",
1646
+ color: "primary",
1647
+ buttonVariant: we.Plain
1648
+ },
1649
+ rejectRequest: {
1650
+ translationKey: "inventory.transfer.receiveRequest.actions.rejectRequest",
1651
+ color: "system-error-300",
1652
+ buttonVariant: we.Destructive
1653
+ },
1654
+ closeRequest: {
1655
+ translationKey: "inventory.transfer.receiveRequest.actions.closeRequest",
1656
+ color: "system-error-300",
1657
+ buttonVariant: we.Destructive,
1658
+ available: !1
1659
+ },
1660
+ returnStock: {
1661
+ translationKey: "inventory.transfer.receiveRequest.actions.returnStock",
1662
+ color: "primary",
1663
+ buttonVariant: we.Primary,
1664
+ available: !1
1665
+ }
1666
+ }, Yr = { class: "flex flex-row-reverse" }, Qr = /* @__PURE__ */ De({
1667
+ __name: "NetSuiteSync",
1668
+ props: {
1669
+ poRequest: {},
1670
+ purchaseOrder: {},
1671
+ isTransferBetweenOutlets: { type: Boolean },
1672
+ scope: {}
1673
+ },
1674
+ setup(f) {
1675
+ const r = f, s = ut(), l = He(), c = dt(), o = G(!1);
1676
+ Z(() => {
1677
+ var y, _, h, D;
1678
+ let t = !0;
1679
+ s.isEnabled || (t = !1);
1680
+ const n = r.purchaseOrder, v = r.poRequest;
1681
+ return n && ((y = n == null ? void 0 : n.supplier) != null && y.internal ? (!v && n.status == ae.enum.DRAFT && (t = !1), v && !((_ = v == null ? void 0 : v.netSuite) != null && _.id) && (t = !1), r.isTransferBetweenOutlets && (t = !1)) : ((n == null ? void 0 : n.status) !== ae.enum.REQUESTING && n.supplier.internal && (t = !1), !v && !((h = n == null ? void 0 : n.netSuite) != null && h.id) && (t = !1), !v && ((D = n == null ? void 0 : n.netSuite) != null && D.id) && (n == null ? void 0 : n.status) == ae.enum.REQUESTING && (t = !1))), t;
1682
+ });
1683
+ async function m() {
1684
+ o.value || c.open({
1685
+ title: "Sync with NetSuite",
1686
+ contentComponent: z("div", [
1687
+ z("p", "Are you sure you want to sync now?"),
1688
+ z("br"),
1689
+ z(
1690
+ "p",
1691
+ { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" },
1692
+ "Please wait a moment before syncing manually to avoid unnecessary actions."
1693
+ )
1694
+ ]),
1695
+ primaryActions: {
1696
+ text: "Sync",
1697
+ close: !0,
1698
+ variant: "destructive"
1699
+ },
1700
+ secondaryActions: { text: "Not now", close: !0 }
1701
+ }).onPrimary(async () => {
1702
+ var t, n, v;
1703
+ try {
1704
+ o.value = !0;
1705
+ const y = ((t = r.purchaseOrder) == null ? void 0 : t._id) || ((n = r.poRequest) == null ? void 0 : n.purchaseOrderId) || "", _ = (v = r.poRequest) == null ? void 0 : v.to.dbName;
1706
+ await s.syncPurchaseOrder(
1707
+ y,
1708
+ r.scope === "approval" ? _ : void 0
1709
+ ), l.open({
1710
+ title: "Sync with NetSuite",
1711
+ message: "Requested to sync with NetSuite. Please wait a moment.",
1712
+ type: "success"
1713
+ }), await new Promise((h) => setTimeout(h, 5e3)), o.value = !1;
1714
+ } catch {
1715
+ l.open({
1716
+ title: "Error",
1717
+ message: "Failed to sync with NetSuite",
1718
+ type: "error"
1719
+ }), o.value = !1;
1720
+ }
1721
+ });
1722
+ }
1723
+ return (t, n) => {
1724
+ const v = X("FmButton");
1725
+ return i(), b("div", Yr, [
1726
+ L(v, {
1727
+ "prepend-icon": "sync",
1728
+ variant: "secondary",
1729
+ label: "Sync",
1730
+ loading: o.value,
1731
+ onClick: m,
1732
+ "text-color": "primary",
1733
+ "bg-color": "transparent",
1734
+ "border-color": "primary"
1735
+ }, null, 8, ["loading"])
1736
+ ]);
1737
+ };
1738
+ }
1739
+ }), Jr = {
1740
+ key: 0,
1741
+ class: "flex flex-col gap-8"
1742
+ }, Xr = { class: "flex flex-col gap-4" }, Zr = { class: "fm-typo-en-body-lg-600" }, es = {
1743
+ key: 0,
1744
+ class: "flex flex-col gap-4"
1745
+ }, ts = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, rs = { class: "fm-typo-en-body-lg-600" }, ss = { key: 0 }, os = { key: 1 }, ns = {
1746
+ key: 1,
1747
+ class: "flex flex-col gap-4"
1748
+ }, as = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, ls = { class: "fm-typo-en-body-lg-600" }, is = { key: 0 }, cs = { key: 1 }, us = {
1749
+ key: 2,
1750
+ class: "flex flex-col gap-4"
1751
+ }, ds = { class: "fm-typo-en-body-lg-600" }, ms = {
1752
+ key: 3,
1753
+ class: "flex flex-col gap-4"
1754
+ }, ps = { class: "fm-typo-en-body-lg-600" }, fs = /* @__PURE__ */ De({
1755
+ __name: "NetSuiteInfo",
1756
+ props: {
1757
+ transferType: {},
1758
+ transferToDbName: {},
1759
+ poRequest: {},
1760
+ purchaseOrder: {},
1761
+ isTransferBetweenOutlets: { type: Boolean },
1762
+ scope: {}
1763
+ },
1764
+ setup(f) {
1765
+ const r = f, s = ut(), l = We(), c = G(r.poRequest);
1766
+ Nt(async () => {
1767
+ var n;
1768
+ if (!r.poRequest && ((n = r.purchaseOrder) != null && n._id)) {
1769
+ const v = await l.getLatestPurchaseOrderRequest(r.purchaseOrder._id);
1770
+ c.value = v;
1771
+ }
1772
+ });
1773
+ const o = Z(
1774
+ () => {
1775
+ var n, v, y, _, h, D;
1776
+ return s.getSubsidiaryFullName(
1777
+ ((y = (v = (n = r.purchaseOrder) == null ? void 0 : n.netSuite) == null ? void 0 : v.subsidiary) == null ? void 0 : y.id) || ((D = (h = (_ = r.poRequest) == null ? void 0 : _.netSuite) == null ? void 0 : h.subsidiary) == null ? void 0 : D.id)
1778
+ ).fullName;
1779
+ }
1780
+ ), m = Z(() => {
1781
+ var n, v, y, _, h, D, x, M, R, j, O, k;
1782
+ return (y = (v = (n = r.purchaseOrder) == null ? void 0 : n.netSuite) == null ? void 0 : v.additionalInfo) != null && y.transactionnumber ? (D = (h = (_ = r.purchaseOrder) == null ? void 0 : _.netSuite) == null ? void 0 : h.additionalInfo) == null ? void 0 : D.transactionnumber : (R = (M = (x = c.value) == null ? void 0 : x.netSuite) == null ? void 0 : M.additionalInfo) != null && R.transactionnumber ? (k = (O = (j = c.value) == null ? void 0 : j.netSuite) == null ? void 0 : O.additionalInfo) == null ? void 0 : k.transactionnumber : null;
1783
+ }), t = Z(() => {
1784
+ var n, v, y, _, h, D;
1785
+ return (v = (n = r.purchaseOrder) == null ? void 0 : n.deliveryFullfillment) != null && v.length && ((_ = (y = r.purchaseOrder) == null ? void 0 : y.deliveryFullfillment) == null ? void 0 : _.length) > 0 ? (D = (h = r.purchaseOrder) == null ? void 0 : h.deliveryFullfillment) == null ? void 0 : D.map((x) => {
1786
+ var M;
1787
+ return (M = x.netSuite) == null ? void 0 : M.refNo;
1788
+ }).join(", ") : "N/A";
1789
+ });
1790
+ return (n, v) => {
1791
+ var y, _, h, D, x, M, R, j, O, k, Y, N, P, $, S, T;
1792
+ return d(s).isEnabled ? (i(), b("div", Jr, [
1793
+ e("div", Xr, [
1794
+ v[0] || (v[0] = e("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, "NetSuite subsidiary", -1)),
1795
+ e("div", Zr, p(o.value || "N/A"), 1)
1796
+ ]),
1797
+ !n.isTransferBetweenOutlets && n.scope === d(gt).RECEIVE_REQUEST ? (i(), b("div", es, [
1798
+ e("div", ts, " NetSuite " + p((_ = (y = n.purchaseOrder) == null ? void 0 : y.netSuite) != null && _.recordType ? d(Pt)((D = (h = n.purchaseOrder) == null ? void 0 : h.netSuite) == null ? void 0 : D.recordType) : n.transferType === d(Ze).enum.purchase ? "Purchase Order" : "Transfer Order") + " (ID) ", 1),
1799
+ e("div", rs, [
1800
+ (M = (x = n.purchaseOrder) == null ? void 0 : x.netSuite) != null && M.id ? (i(), b("span", ss, p((j = (R = n.purchaseOrder) == null ? void 0 : R.netSuite) == null ? void 0 : j.refNo) + " (" + p((k = (O = n.purchaseOrder) == null ? void 0 : O.netSuite) == null ? void 0 : k.id) + ") ", 1)) : (i(), b("span", os, "N/A"))
1801
+ ])
1802
+ ])) : U("", !0),
1803
+ !n.isTransferBetweenOutlets && c.value || n.scope === d(gt).APPROVAL ? (i(), b("div", ns, [
1804
+ e("div", as, " (Request) NetSuite " + p(n.transferType === d(Ze).enum.purchase ? "Purchase Order" : "Transfer Order") + " (ID) ", 1),
1805
+ e("div", ls, [
1806
+ (N = (Y = c.value) == null ? void 0 : Y.netSuite) != null && N.id ? (i(), b("span", is, p(($ = (P = c.value) == null ? void 0 : P.netSuite) == null ? void 0 : $.refNo) + " (" + p((T = (S = c.value) == null ? void 0 : S.netSuite) == null ? void 0 : T.id) + ") ", 1)) : (i(), b("span", cs, "N/A"))
1807
+ ])
1808
+ ])) : U("", !0),
1809
+ m.value ? (i(), b("div", us, [
1810
+ v[1] || (v[1] = e("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " NetSuite Transaction Number ", -1)),
1811
+ e("div", ds, p(m.value), 1)
1812
+ ])) : U("", !0),
1813
+ d(s).isEnabled && n.transferType === d(Ze).enum.transfer && !n.isTransferBetweenOutlets ? (i(), b("div", ms, [
1814
+ v[2] || (v[2] = e("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " NetSuite fulfillment IDs ", -1)),
1815
+ e("div", ps, p(t.value), 1)
1816
+ ])) : U("", !0)
1817
+ ])) : U("", !0);
1818
+ };
1819
+ }
1820
+ }), ys = { class: "flex flex-row-reverse" }, vs = /* @__PURE__ */ De({
1821
+ __name: "NetSuiteLog",
1822
+ props: {
1823
+ netsuiteId: {},
1824
+ purchaseOrderId: {}
1825
+ },
1826
+ setup(f) {
1827
+ const r = He(), s = xt();
1828
+ async function l(c, o) {
1829
+ const m = [];
1830
+ if (c && m.push(`body.message:*${c}*`), o) {
1831
+ const y = o.replace(/:/g, "\\:");
1832
+ m.push(`${y}`);
1833
+ }
1834
+ if (m.length === 0) {
1835
+ r.open({
1836
+ message: "Cannot open logs without valid filters.",
1837
+ type: "error"
1838
+ });
1839
+ return;
1840
+ }
1841
+ const n = `attributes.pod:netsuite* AND (${m.join(" OR ")})`, { url: v } = await s.getSyncLogs(n);
1842
+ r.open(
1843
+ {
1844
+ message: "Opening NetSuite logs...",
1845
+ type: "info"
1846
+ },
1847
+ 800
1848
+ ), await new Promise((y) => setTimeout(y, 800)), window.open(v, "_blank");
1849
+ }
1850
+ return (c, o) => {
1851
+ const m = X("FmButton");
1852
+ return i(), b("div", ys, [
1853
+ L(m, {
1854
+ "prepend-icon": "history",
1855
+ variant: "secondary",
1856
+ label: "Logs",
1857
+ onClick: o[0] || (o[0] = (t) => l(c.netsuiteId, c.purchaseOrderId)),
1858
+ "text-color": "primary",
1859
+ "bg-color": "transparent",
1860
+ "border-color": "primary"
1861
+ })
1862
+ ]);
1863
+ };
1864
+ }
1865
+ }), bs = { class: "flex flex-row-reverse" }, gs = { key: 0 }, hs = { key: 1 }, _s = { class: "mb-6" }, xs = { class: "fm-typo-en-body-md-400" }, Ss = { key: 0 }, Os = { key: 1 }, ws = {
1866
+ key: 0,
1867
+ class: "flex"
1868
+ }, Cs = {
1869
+ key: 1,
1870
+ class: "border-t pt-6"
1871
+ }, Ds = { class: "fm-typo-en-body-lg-600 mb-4 flex items-center gap-2" }, $s = { class: "border border-fm-color-neutral-gray-200 fm-corner-radius-lg overflow-y-auto" }, ks = { class: "w-full" }, Rs = {
1872
+ class: "p-3 fm-typo-en-body-sm-600",
1873
+ style: { "min-width": "130px" }
1874
+ }, Ns = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, As = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Ps = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Ts = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Fs = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Is = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, qs = { class: "p-3 fm-typo-en-body-sm-600" }, Es = { key: 2 }, Vs = { key: 1 }, Ls = /* @__PURE__ */ De({
1875
+ __name: "NetSuiteLatestInfo",
1876
+ props: {
1877
+ netsuiteId: {},
1878
+ purchaseOrderId: {}
1879
+ },
1880
+ setup(f) {
1881
+ const r = f, s = xt(), l = G(!1), c = Te(), o = G(!0), m = G(!1), t = G(!1), n = G(!1), v = G(null), y = G([]);
1882
+ async function _() {
1883
+ if (!v.value) {
1884
+ l.value = !0;
1885
+ try {
1886
+ o.value = !0;
1887
+ const M = await s.getMoreInfo(
1888
+ c.currentLocation.dbName,
1889
+ r.purchaseOrderId
1890
+ );
1891
+ v.value = M, m.value = !1;
1892
+ } catch {
1893
+ m.value = !0;
1894
+ } finally {
1895
+ o.value = !1;
1896
+ }
1897
+ await h();
1898
+ }
1899
+ }
1900
+ async function h() {
1901
+ if (!(y.value.length > 0))
1902
+ try {
1903
+ t.value = !0;
1904
+ const M = await s.getChangeLogs(r.netsuiteId);
1905
+ y.value = M, n.value = !1;
1906
+ } catch {
1907
+ n.value = !0;
1908
+ } finally {
1909
+ t.value = !1;
1910
+ }
1911
+ }
1912
+ function D(M) {
1913
+ switch (M) {
1914
+ case Ne.Create:
1915
+ return "text-green-600 bg-green-100";
1916
+ case Ne.Set:
1917
+ return "text-blue-600 bg-blue-100";
1918
+ case Ne.Change:
1919
+ return "text-yellow-600 bg-yellow-100";
1920
+ case Ne.Unset:
1921
+ return "text-red-600 bg-red-100";
1922
+ default:
1923
+ return "text-gray-600 bg-gray-100";
1924
+ }
1925
+ }
1926
+ function x(M) {
1927
+ return new Date(M).toLocaleDateString("en-US", {
1928
+ year: "numeric",
1929
+ month: "short",
1930
+ day: "numeric",
1931
+ hour: "2-digit",
1932
+ minute: "2-digit"
1933
+ });
1934
+ }
1935
+ return (M, R) => {
1936
+ const j = X("FmButton"), O = X("FmLabel"), k = X("FmCircularProgress"), Y = X("FmIcon"), N = X("FmDialog");
1937
+ return i(), b("div", bs, [
1938
+ L(N, {
1939
+ modelValue: l.value,
1940
+ "onUpdate:modelValue": R[2] || (R[2] = (P) => l.value = P),
1941
+ overlay: !0,
1942
+ "max-width": 800
1943
+ }, {
1944
+ "dialog-button": oe(() => [
1945
+ L(j, {
1946
+ "prepend-icon": "info",
1947
+ variant: "secondary",
1948
+ label: "Latest Info",
1949
+ onClick: R[0] || (R[0] = (P) => _()),
1950
+ "text-color": "primary",
1951
+ "bg-color": "transparent",
1952
+ "border-color": "primary"
1953
+ })
1954
+ ]),
1955
+ "dialog-header": oe(() => R[3] || (R[3] = [
1956
+ e("div", null, "NetSuite latest info", -1)
1957
+ ])),
1958
+ default: oe(() => [
1959
+ o.value ? (i(), b("div", gs, "Loading...")) : (i(), b("div", hs, [
1960
+ m.value ? (i(), b("p", Vs, "Something went wrong.")) : (i(), b(fe, { key: 0 }, [
1961
+ e("div", _s, [
1962
+ R[4] || (R[4] = e("h3", { class: "fm-typo-en-body-lg-600 mb-4" }, "NetSuite Order Details", -1)),
1963
+ (i(!0), b(fe, null, ke(v.value, (P, $) => (i(), b("div", {
1964
+ key: $,
1965
+ class: "mb-2"
1966
+ }, [
1967
+ e("div", null, [
1968
+ L(O, {
1969
+ label: d(ht)($)
1970
+ }, null, 8, ["label"]),
1971
+ e("div", xs, [
1972
+ Array.isArray(P) ? (i(), b("span", Ss, p(P.length > 0 ? P.join(", ") : "N/A"), 1)) : (i(), b("span", Os, p(P), 1))
1973
+ ])
1974
+ ])
1975
+ ]))), 128))
1976
+ ]),
1977
+ t.value ? (i(), b("div", ws, [
1978
+ R[5] || (R[5] = e("span", null, "Change Log Loading...", -1)),
1979
+ L(k, { size: "md" })
1980
+ ])) : U("", !0),
1981
+ !t.value && y.value.length > 0 ? (i(), b("div", Cs, [
1982
+ e("h3", Ds, [
1983
+ L(Y, {
1984
+ name: "error",
1985
+ color: "#ff9500",
1986
+ size: "sm"
1987
+ }),
1988
+ R[6] || (R[6] = Pe(" Change Logs "))
1989
+ ]),
1990
+ e("div", $s, [
1991
+ e("table", ks, [
1992
+ R[7] || (R[7] = e("thead", { class: "bg-fm-color-neutral-gray-50" }, [
1993
+ e("tr", { class: "border-b border-fm-color-neutral-gray-200" }, [
1994
+ e("th", {
1995
+ class: "text-left p-3 fm-typo-en-body-md-600",
1996
+ style: { "min-width": "130px" }
1997
+ }, " Date "),
1998
+ e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Role"),
1999
+ e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Name"),
2000
+ e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Context"),
2001
+ e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Type"),
2002
+ e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Line ID"),
2003
+ e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Field"),
2004
+ e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Old Value"),
2005
+ e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "New Value")
2006
+ ])
2007
+ ], -1)),
2008
+ e("tbody", null, [
2009
+ (i(!0), b(fe, null, ke(y.value, (P, $) => (i(), b("tr", {
2010
+ key: $,
2011
+ class: "border-b border-fm-color-neutral-gray-200 last:border-b-0"
2012
+ }, [
2013
+ e("td", Rs, p(x(P._dateiso8601)), 1),
2014
+ e("td", Ns, p(P._rolename), 1),
2015
+ e("td", As, p(P._employeename), 1),
2016
+ e("td", Ps, p(P._contextname), 1),
2017
+ e("td", {
2018
+ class: je(`p-3 fm-typo-en-body-sm-600 ${D(Number(P.type) - 1)}`)
2019
+ }, p(d(Ne)[Number(P.type) - 1]), 3),
2020
+ e("td", Ts, p(P.lineid || ""), 1),
2021
+ e("td", Fs, p(P._fieldname), 1),
2022
+ e("td", Is, p(P.oldvalue || ""), 1),
2023
+ e("td", qs, p(P.newvalue || ""), 1)
2024
+ ]))), 128))
2025
+ ])
2026
+ ])
2027
+ ])
2028
+ ])) : (i(), b("div", Es, R[8] || (R[8] = [
2029
+ e("p", null, "No change logs available.", -1)
2030
+ ])))
2031
+ ], 64))
2032
+ ]))
2033
+ ]),
2034
+ "dialog-footer": oe(() => [
2035
+ L(j, {
2036
+ class: "ml-auto sm:w-full xs:w-full",
2037
+ label: "Close",
2038
+ size: "md",
2039
+ variant: "primary",
2040
+ onClick: R[1] || (R[1] = (P) => l.value = !1)
2041
+ })
2042
+ ]),
2043
+ _: 1
2044
+ }, 8, ["modelValue"])
2045
+ ]);
2046
+ };
2047
+ }
2048
+ }), Ms = {
2049
+ key: 0,
2050
+ class: "border border-fm-color-neutral-gray-200 fm-corner-radius-lg p-16 flex flex-col gap-8"
2051
+ }, Us = { class: "flex gap-8 items-center" }, js = { class: "ml-auto" }, Bs = { class: "flex gap-3" }, zs = /* @__PURE__ */ De({
2052
+ __name: "NetSuitePanel",
2053
+ props: {
2054
+ poRequest: {},
2055
+ purchaseOrder: {},
2056
+ transferType: {},
2057
+ transferToDbName: {},
2058
+ scope: {}
2059
+ },
2060
+ setup(f) {
2061
+ const r = f, s = $r(), l = Z(() => s.isNetSuiteEnabled);
2062
+ return (c, o) => {
2063
+ var t, n;
2064
+ const m = X("FmMenuDivider");
2065
+ return l.value ? (i(), b("div", Ms, [
2066
+ e("div", Us, [
2067
+ o[0] || (o[0] = e("span", { class: "flex-1 fm-typo-en-body-lg-600" }, "NetSuite Info", -1)),
2068
+ e("div", js, [
2069
+ e("div", Bs, [
2070
+ (n = (t = r.purchaseOrder) == null ? void 0 : t.netSuite) != null && n.id ? (i(), ie(Be, { key: 0 }, {
2071
+ default: oe(() => {
2072
+ var v, y, _;
2073
+ return [
2074
+ L(Ls, {
2075
+ "netsuite-id": (y = (v = c.purchaseOrder) == null ? void 0 : v.netSuite) == null ? void 0 : y.id,
2076
+ "purchase-order-id": (_ = c.purchaseOrder) == null ? void 0 : _._id
2077
+ }, null, 8, ["netsuite-id", "purchase-order-id"])
2078
+ ];
2079
+ }),
2080
+ _: 1
2081
+ })) : U("", !0),
2082
+ L(Be, null, {
2083
+ default: oe(() => {
2084
+ var v, y, _;
2085
+ return [
2086
+ L(vs, {
2087
+ "netsuite-id": (y = (v = c.purchaseOrder) == null ? void 0 : v.netSuite) == null ? void 0 : y.id,
2088
+ "purchase-order-id": (_ = c.purchaseOrder) == null ? void 0 : _._id
2089
+ }, null, 8, ["netsuite-id", "purchase-order-id"])
2090
+ ];
2091
+ }),
2092
+ _: 1
2093
+ }),
2094
+ L(Qr, {
2095
+ "po-request": c.poRequest,
2096
+ "purchase-order": c.purchaseOrder,
2097
+ "is-transfer-between-outlets": !l.value,
2098
+ scope: c.scope
2099
+ }, null, 8, ["po-request", "purchase-order", "is-transfer-between-outlets", "scope"])
2100
+ ])
2101
+ ])
2102
+ ]),
2103
+ L(m),
2104
+ L(fs, {
2105
+ "po-request": c.poRequest,
2106
+ "purchase-order": c.purchaseOrder,
2107
+ "transfer-type": c.transferType,
2108
+ "transfer-to-db-name": c.transferToDbName,
2109
+ "is-transfer-between-outlets": !l.value,
2110
+ scope: c.scope
2111
+ }, null, 8, ["po-request", "purchase-order", "transfer-type", "transfer-to-db-name", "is-transfer-between-outlets", "scope"])
2112
+ ])) : U("", !0);
2113
+ };
2114
+ }
2115
+ }), Ks = { class: "flex flex-col gap-3" }, Hs = { class: "flex flex-col gap-4" }, Ws = { class: "flex flex-col gap-4 fm-typo-en-body-lg-600" }, Gs = { class: "flex flex-col gap-4" }, Ys = { class: "flex justify-between items-center py-1 gap-4" }, Qs = { class: "flex flex-col" }, Js = { class: "fm-typo-en-body-lg-600" }, Xs = { class: "fm-typo-en-body-md-400" }, Zs = { class: "flex flex-col gap-2 items-end" }, eo = { class: "flex self-end fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, to = {
2116
+ key: 0,
2117
+ class: "flex items-center gap-2"
2118
+ }, ro = {
2119
+ key: 0,
2120
+ class: "border-b border-fm-color-stroke-secondary"
2121
+ }, so = { class: "flex flex-col gap-4" }, oo = { class: "flex flex-col gap-4" }, no = { class: "flex flex-col gap-4" }, ao = { class: "flex flex-col gap-4 fm-typo-en-body-lg-600" }, lo = {
2122
+ key: 0,
2123
+ class: "flex flex-col gap-4"
2124
+ }, io = { class: "flex flex-col gap-4 fm-typo-en-body-lg-600" }, co = /* @__PURE__ */ De({
2125
+ __name: "EditForm",
2126
+ props: {
2127
+ purchaseOrder: {},
2128
+ deliveryOrder: {}
2129
+ },
2130
+ emits: ["submitted"],
2131
+ setup(f, { emit: r }) {
2132
+ Ar();
2133
+ const s = Ee(), l = He(), c = G(!1), o = f, m = r, t = Tt("deliveryOrder"), n = We(), v = Z(
2134
+ () => {
2135
+ var j;
2136
+ return ((j = o.purchaseOrder.deliveryFullfillment) == null ? void 0 : j.findIndex(
2137
+ (O) => o.deliveryOrder.fullfillmentId && O.id === o.deliveryOrder.fullfillmentId
2138
+ )) ?? -1;
2139
+ }
2140
+ ), y = s.enablePurchaseOrderReceiveWithCustomCost, _ = s.enablePortalDeliveryOrderWrite, h = G({}), D = Z(() => o.purchaseOrder.items.map((j, O) => Z({
2141
+ get: () => {
2142
+ var Y;
2143
+ const k = (Y = t.received[O]) == null ? void 0 : Y.cost;
2144
+ return k ? +be(k) : 0;
2145
+ },
2146
+ set: (k) => {
2147
+ t.received[O].cost = {
2148
+ currency: Ce(),
2149
+ ...ot(k, 4)
2150
+ };
2151
+ }
2152
+ }))), x = Z(() => o.deliveryOrder.received.map((j, O) => Z({
2153
+ get: () => {
2154
+ var Y;
2155
+ const k = (Y = t.received[O]) == null ? void 0 : Y.amount;
2156
+ return k ? +be(k) : 0;
2157
+ },
2158
+ set: (k) => {
2159
+ t.received[O].amount = ot(k, 2);
2160
+ }
2161
+ })));
2162
+ function M(j) {
2163
+ const O = !h.value[j];
2164
+ if (h.value[j] = O, O) {
2165
+ const k = o.deliveryOrder.received[j];
2166
+ k.cost ? t.received[j].cost = {
2167
+ currency: k.cost.currency,
2168
+ amount: k.cost.amount,
2169
+ precision: k.cost.precision
2170
+ } : t.received[j].cost = {
2171
+ currency: Ce(),
2172
+ amount: 0,
2173
+ precision: 4
2174
+ };
2175
+ } else
2176
+ delete t.received[j].cost;
2177
+ }
2178
+ function R() {
2179
+ n.updateDeliveryOrder({
2180
+ deliveryOrder: {
2181
+ ...o.deliveryOrder,
2182
+ ...t
2183
+ },
2184
+ purchaseOrderId: o.purchaseOrder._id,
2185
+ purchaseOrderRev: o.purchaseOrder._rev
2186
+ }).then(() => {
2187
+ l.open(
2188
+ {
2189
+ title: "Success",
2190
+ message: `PO# ${o.purchaseOrder.seqNumber} Changes have been saved`,
2191
+ type: "success"
2192
+ },
2193
+ 1e4
2194
+ ), c.value = !1, m("submitted");
2195
+ });
2196
+ }
2197
+ return (j, O) => {
2198
+ const k = X("FmButton"), Y = X("FmStepperField"), N = X("FmSwitch"), P = X("FmTextField"), $ = X("FmDialog");
2199
+ return i(), ie($, {
2200
+ modelValue: c.value,
2201
+ "onUpdate:modelValue": O[1] || (O[1] = (S) => c.value = S),
2202
+ overlay: !0
2203
+ }, {
2204
+ "dialog-button": oe(() => [
2205
+ d(_) ? (i(), ie(k, {
2206
+ key: 0,
2207
+ variant: "plain",
2208
+ label: "Edit",
2209
+ size: "md",
2210
+ "prepend-icon": "edit"
2211
+ })) : U("", !0)
2212
+ ]),
2213
+ "dialog-header": oe(() => [
2214
+ e("div", null, "Received on " + p(d(et)(o.deliveryOrder.createdAt)), 1)
2215
+ ]),
2216
+ "dialog-footer": oe(() => [
2217
+ L(k, {
2218
+ class: "ml-auto",
2219
+ label: "Apply changes",
2220
+ size: "md",
2221
+ variant: "destructive",
2222
+ onClick: R
2223
+ })
2224
+ ]),
2225
+ default: oe(() => [
2226
+ e("div", null, [
2227
+ e("div", Ks, [
2228
+ e("div", Hs, [
2229
+ O[2] || (O[2] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Adjustment date", -1)),
2230
+ e("div", Ws, p(o.deliveryOrder.adjustment ? d(et)(new Date(d(st)(o.deliveryOrder.adjustment))) : "-"), 1)
2231
+ ]),
2232
+ e("div", Gs, [
2233
+ O[4] || (O[4] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Received items", -1)),
2234
+ (i(!0), b(fe, null, ke(o.deliveryOrder.received, (S, T) => {
2235
+ var W;
2236
+ return i(), b("div", { key: T }, [
2237
+ e("div", Ys, [
2238
+ e("div", Qs, [
2239
+ e("span", Js, p(S.sku.name), 1),
2240
+ e("span", Xs, p(S.sku.code), 1)
2241
+ ]),
2242
+ e("div", Zs, [
2243
+ L(Y, {
2244
+ label: "Receive Quantity",
2245
+ modelValue: x.value[T].value,
2246
+ "onUpdate:modelValue": (Q) => x.value[T].value = Q,
2247
+ min: 0,
2248
+ "append-text": ((W = S.measurement) == null ? void 0 : W.abbrev) ?? S.sku.unit.abbrev
2249
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "append-text"]),
2250
+ e("div", eo, p(`${S.cost ? `${d(Je)(S.cost)}` : ""}`), 1),
2251
+ d(y) ? (i(), b("div", to, [
2252
+ L(N, {
2253
+ "model-value": h.value[T],
2254
+ "onUpdate:modelValue": (Q) => M(T),
2255
+ size: "sm"
2256
+ }, null, 8, ["model-value", "onUpdate:modelValue"]),
2257
+ O[3] || (O[3] = e("span", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " Override cost ", -1))
2258
+ ])) : U("", !0),
2259
+ d(y) && h.value[T] ? (i(), ie(Y, {
2260
+ key: 1,
2261
+ modelValue: D.value[T].value,
2262
+ "onUpdate:modelValue": (Q) => D.value[T].value = Q,
2263
+ label: "Total Cost",
2264
+ step: 1e-4,
2265
+ min: 0,
2266
+ placeholder: "0.0000",
2267
+ size: "sm",
2268
+ "append-text": d(Ce)()
2269
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "append-text"])) : U("", !0)
2270
+ ])
2271
+ ]),
2272
+ T < o.purchaseOrder.items.length - 1 ? (i(), b("div", ro)) : U("", !0)
2273
+ ]);
2274
+ }), 128))
2275
+ ]),
2276
+ e("div", so, [
2277
+ O[5] || (O[5] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Delivery order no.", -1)),
2278
+ e("div", oo, [
2279
+ L(P, {
2280
+ modelValue: d(t).deliveryOrderNumber,
2281
+ "onUpdate:modelValue": O[0] || (O[0] = (S) => d(t).deliveryOrderNumber = S),
2282
+ size: "md",
2283
+ placeholder: o.deliveryOrder.deliveryOrderNumber
2284
+ }, null, 8, ["modelValue", "placeholder"])
2285
+ ])
2286
+ ]),
2287
+ e("div", no, [
2288
+ O[6] || (O[6] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Remark", -1)),
2289
+ e("div", ao, p(o.deliveryOrder.remark || "N/A"), 1)
2290
+ ]),
2291
+ v.value >= 0 ? (i(), b("div", lo, [
2292
+ O[7] || (O[7] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, " Fulfilment's sequence ", -1)),
2293
+ e("div", io, p(v.value + 1), 1)
2294
+ ])) : U("", !0)
2295
+ ])
2296
+ ])
2297
+ ]),
2298
+ _: 1
2299
+ }, 8, ["modelValue"]);
2300
+ };
2301
+ }
2302
+ }), uo = { class: "flex flex-col gap-3" }, mo = { class: "flex flex-col gap-4" }, po = { class: "flex flex-col gap-4 fm-typo-en-body-lg-600" }, fo = {
2303
+ key: 0,
2304
+ class: "flex flex-col gap-4"
2305
+ }, yo = { class: "flex items-center justify-between" }, vo = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, bo = {
2306
+ key: 0,
2307
+ class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
2308
+ }, go = { class: "flex gap-4" }, ho = { class: "flex-1" }, _o = { class: "flex-1" }, xo = {
2309
+ key: 0,
2310
+ class: "flex items-center text-fm-color-system-error-300"
2311
+ }, So = { class: "fm-typo-en-body-md-400" }, Oo = { class: "flex flex-col gap-4" }, wo = { class: "flex justify-between items-center py-1 gap-4" }, Co = { class: "flex flex-col" }, Do = { class: "fm-typo-en-body-lg-600" }, $o = { class: "fm-typo-en-body-md-400" }, ko = { class: "flex flex-col gap-2 items-end" }, Ro = {
2312
+ key: 0,
2313
+ class: "flex items-center gap-2"
2314
+ }, No = {
2315
+ key: 0,
2316
+ class: "border-b border-fm-color-stroke-secondary"
2317
+ }, Ao = { class: "flex flex-col gap-4" }, Po = { class: "flex flex-col gap-4" }, To = { class: "flex flex-col gap-4" }, Fo = { class: "flex flex-col gap-4 fm-typo-en-body-lg-600" }, Io = /* @__PURE__ */ De({
2318
+ __name: "CreateForm",
2319
+ props: {
2320
+ purchaseOrder: {},
2321
+ receivedInfoMap: {}
2322
+ },
2323
+ emits: ["submitted"],
2324
+ setup(f, { emit: r }) {
2325
+ var F, I, ee;
2326
+ const { t: s } = it(), l = G(!1), c = ct(), o = f, m = r, t = Tt("", {
2327
+ default: {
2328
+ deliveryOrderNumber: "",
2329
+ remark: "",
2330
+ received: o.purchaseOrder.items.map((w) => ({
2331
+ sku: w.sku,
2332
+ amount: Ue.fromNumber(0),
2333
+ measurement: w.measurement
2334
+ })),
2335
+ createdBy: {
2336
+ id: ((F = c.sessionUser.value) == null ? void 0 : F.id) || "",
2337
+ name: ((I = c.sessionUser.value) == null ? void 0 : I.displayName) || ""
2338
+ },
2339
+ createdAt: ""
2340
+ }
2341
+ }), n = We(), v = dt(), y = Ee(), _ = ((ee = o.purchaseOrder) == null ? void 0 : ee.supplier.internal) != null, h = _ && y.enablePOSTransferRequireFulfillment, D = y.enablePortalDeliveryOrderWrite && (o.purchaseOrder.status === ae.Enum.RECEIVING || o.purchaseOrder.status === ae.Enum.COMPLETE) && (_ ? !h : !0), x = y.enablePurchaseOrderReceiveWithCustomCost, M = y.enableBackdateReceive, R = G({}), j = He(), O = Z({
2342
+ get() {
2343
+ if (!t.createdAt) return "";
2344
+ const w = new Date(t.createdAt), g = w.getFullYear(), V = String(w.getMonth() + 1).padStart(2, "0"), H = String(w.getDate()).padStart(2, "0");
2345
+ return `${g}-${V}-${H}`;
2346
+ },
2347
+ set(w) {
2348
+ if (w) {
2349
+ const g = t.createdAt ? new Date(t.createdAt) : /* @__PURE__ */ new Date(), [V, H, ce] = w.split("-");
2350
+ g.setFullYear(parseInt(V)), g.setMonth(parseInt(H) - 1), g.setDate(parseInt(ce)), t.createdAt = g.toISOString();
2351
+ }
2352
+ }
2353
+ }), k = Z({
2354
+ get() {
2355
+ if (!t.createdAt) return "";
2356
+ const w = new Date(t.createdAt), g = String(w.getHours()).padStart(2, "0"), V = String(w.getMinutes()).padStart(2, "0");
2357
+ return `${g}:${V}`;
2358
+ },
2359
+ set(w) {
2360
+ if (w) {
2361
+ const g = t.createdAt ? new Date(t.createdAt) : /* @__PURE__ */ new Date(), [V, H] = w.split(":");
2362
+ g.setHours(parseInt(V)), g.setMinutes(parseInt(H)), t.createdAt = g.toISOString();
2363
+ }
2364
+ }
2365
+ }), Y = Z(() => {
2366
+ const w = st(o.purchaseOrder._id);
2367
+ if (!w) return "";
2368
+ const g = new Date(w), V = g.getFullYear(), H = String(g.getMonth() + 1).padStart(2, "0"), ce = String(g.getDate()).padStart(2, "0");
2369
+ return `${V}-${H}-${ce}`;
2370
+ }), N = Z(() => {
2371
+ const w = st(o.purchaseOrder._id);
2372
+ return w ? new Date(w) : null;
2373
+ }), P = Z(() => {
2374
+ if (!O.value || !k.value || !N.value) return null;
2375
+ if (/* @__PURE__ */ new Date(`${O.value}T${k.value}:00`) < N.value) {
2376
+ const g = Y.value, V = N.value.getHours(), H = N.value.getMinutes(), ce = V >= 12 ? "PM" : "AM", Re = V % 12 || 12, Oe = `${String(Re).padStart(2, "0")}:${String(H).padStart(2, "0")} ${ce}`;
2377
+ return `Delivery date & time cannot be earlier than order creation (${g} ${Oe})`;
2378
+ }
2379
+ return null;
2380
+ }), $ = Z(() => P.value ? !1 : t.received.some((g) => {
2381
+ const V = g.amount;
2382
+ return V ? +be(V) > 0 : !1;
2383
+ }));
2384
+ function S() {
2385
+ t.createdAt = "";
2386
+ }
2387
+ const T = Z(() => o.purchaseOrder.items.map((w, g) => Z({
2388
+ get: () => {
2389
+ var H;
2390
+ const V = (H = t.received[g]) == null ? void 0 : H.amount;
2391
+ return V ? +be(V) : 0;
2392
+ },
2393
+ set: (V) => {
2394
+ t.received[g].amount = ot(V, 2);
2395
+ }
2396
+ })));
2397
+ function W(w) {
2398
+ const g = !R.value[w];
2399
+ if (R.value[w] = g, g) {
2400
+ const V = o.purchaseOrder.items[w];
2401
+ V.totalCost ? t.received[w].cost = {
2402
+ currency: V.totalCost.currency,
2403
+ amount: V.totalCost.amount,
2404
+ precision: 4
2405
+ // Standardize to 4 decimals
2406
+ } : t.received[w].cost = {
2407
+ currency: Ce(),
2408
+ amount: 0,
2409
+ precision: 4
2410
+ };
2411
+ } else
2412
+ delete t.received[w].cost;
2413
+ }
2414
+ const Q = Z(() => o.purchaseOrder.items.map((w, g) => Z({
2415
+ get: () => {
2416
+ var H;
2417
+ const V = (H = t.received[g]) == null ? void 0 : H.cost;
2418
+ return V ? +be(V) : 0;
2419
+ },
2420
+ set: (V) => {
2421
+ t.received[g].cost = {
2422
+ currency: Ce(),
2423
+ ...ot(V, 4)
2424
+ };
2425
+ }
2426
+ })));
2427
+ function ye() {
2428
+ v.open({
2429
+ title: "Confirm Create Delivery Order",
2430
+ message: `Are you sure you want to create delivery order for PO# ${o.purchaseOrder.seqNumber}?`,
2431
+ primaryActions: {
2432
+ text: "Create",
2433
+ close: !0,
2434
+ variant: "primary"
2435
+ },
2436
+ secondaryActions: {
2437
+ text: "Cancel",
2438
+ close: !0
2439
+ }
2440
+ }).onPrimary(() => ge());
2441
+ }
2442
+ function ge() {
2443
+ n.createDeliveryOrder({
2444
+ deliveryOrder: t,
2445
+ purchaseOrderId: o.purchaseOrder._id,
2446
+ purchaseOrderRev: o.purchaseOrder._rev,
2447
+ currency: Ce()
2448
+ }).then(() => {
2449
+ j.open(
2450
+ {
2451
+ title: "Success",
2452
+ message: `New delivery order created for PO# ${o.purchaseOrder.seqNumber}`,
2453
+ type: "success"
2454
+ },
2455
+ 1e4
2456
+ ), l.value = !1, m("submitted");
2457
+ });
2458
+ }
2459
+ return (w, g) => {
2460
+ const V = X("FmButton"), H = X("FmDatePicker"), ce = X("FmTimePicker"), Re = X("FmIcon"), Oe = X("FmStepperField"), Ge = X("FmSwitch"), a = X("FmTextField"), u = X("FmDialog");
2461
+ return i(), ie(u, {
2462
+ modelValue: l.value,
2463
+ "onUpdate:modelValue": g[4] || (g[4] = (E) => l.value = E),
2464
+ overlay: !0,
2465
+ "min-width": 800
2466
+ }, {
2467
+ "dialog-button": oe(() => [
2468
+ d(D) ? (i(), ie(V, {
2469
+ key: 0,
2470
+ variant: "primary",
2471
+ label: "Create",
2472
+ size: "md",
2473
+ "prepend-icon": "add",
2474
+ class: "w-full"
2475
+ })) : U("", !0)
2476
+ ]),
2477
+ "dialog-header": oe(() => [
2478
+ e("div", null, "Order #" + p(o.purchaseOrder.seqNumber) + " (New Delivery Order)", 1)
2479
+ ]),
2480
+ "dialog-footer": oe(() => [
2481
+ L(V, {
2482
+ class: "ml-auto",
2483
+ label: "Create",
2484
+ size: "md",
2485
+ variant: "destructive",
2486
+ disabled: !$.value,
2487
+ onClick: ye
2488
+ }, null, 8, ["disabled"])
2489
+ ]),
2490
+ default: oe(() => {
2491
+ var E;
2492
+ return [
2493
+ e("div", uo, [
2494
+ e("div", mo, [
2495
+ g[5] || (g[5] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Received by", -1)),
2496
+ e("div", po, p((E = d(c).sessionUser.value) == null ? void 0 : E.displayName), 1)
2497
+ ]),
2498
+ d(M) ? (i(), b("div", fo, [
2499
+ e("div", yo, [
2500
+ e("div", vo, [
2501
+ g[6] || (g[6] = Pe(" Delivery Date & Time ")),
2502
+ !O.value && !k.value ? (i(), b("div", bo, " Leave blank to use current date & time ")) : U("", !0)
2503
+ ]),
2504
+ O.value || k.value ? (i(), ie(V, {
2505
+ key: 0,
2506
+ variant: "tertiary",
2507
+ label: "Clear",
2508
+ "prepend-icon": "close",
2509
+ onClick: S
2510
+ })) : U("", !0)
2511
+ ]),
2512
+ e("div", go, [
2513
+ e("div", ho, [
2514
+ L(H, {
2515
+ modelValue: O.value,
2516
+ "onUpdate:modelValue": g[0] || (g[0] = (A) => O.value = A)
2517
+ }, null, 8, ["modelValue"])
2518
+ ]),
2519
+ e("div", _o, [
2520
+ L(ce, {
2521
+ modelValue: k.value,
2522
+ "onUpdate:modelValue": g[1] || (g[1] = (A) => k.value = A)
2523
+ }, null, 8, ["modelValue"])
2524
+ ])
2525
+ ]),
2526
+ P.value ? (i(), b("div", xo, [
2527
+ L(Re, {
2528
+ name: "error",
2529
+ class: "inline-block mr-1",
2530
+ size: "sm"
2531
+ }),
2532
+ e("div", So, p(P.value), 1)
2533
+ ])) : U("", !0)
2534
+ ])) : U("", !0),
2535
+ e("div", Oo, [
2536
+ g[8] || (g[8] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, " Items going to receive ", -1)),
2537
+ (i(!0), b(fe, null, ke(o.purchaseOrder.items, (A, K) => {
2538
+ var B, J, C;
2539
+ return i(), b("div", { key: K }, [
2540
+ e("div", wo, [
2541
+ e("div", Co, [
2542
+ e("span", Do, p(A.sku.name), 1),
2543
+ e("span", $o, p(A.sku.code), 1)
2544
+ ]),
2545
+ e("div", ko, [
2546
+ L(Oe, {
2547
+ label: "Receive Quantity",
2548
+ modelValue: T.value[K].value,
2549
+ "onUpdate:modelValue": (te) => T.value[K].value = te,
2550
+ "helper-text": `${d(s)("inventory.transfer.receiveRequest.details.received")} ${d(Ue).toFormatString(
2551
+ {
2552
+ value: (B = w.receivedInfoMap[A.sku._id]) == null ? void 0 : B.received
2553
+ }
2554
+ )} ${((J = A.measurement) == null ? void 0 : J.abbrev) ?? A.sku.unit.abbrev}`,
2555
+ min: 0,
2556
+ "append-text": ((C = A.measurement) == null ? void 0 : C.abbrev) ?? A.sku.unit.abbrev
2557
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "helper-text", "append-text"]),
2558
+ d(x) ? (i(), b("div", Ro, [
2559
+ L(Ge, {
2560
+ "model-value": R.value[K],
2561
+ "onUpdate:modelValue": (te) => W(K),
2562
+ size: "sm"
2563
+ }, null, 8, ["model-value", "onUpdate:modelValue"]),
2564
+ g[7] || (g[7] = e("span", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " Override cost ", -1))
2565
+ ])) : U("", !0),
2566
+ d(x) && R.value[K] ? (i(), ie(Oe, {
2567
+ key: 1,
2568
+ modelValue: Q.value[K].value,
2569
+ "onUpdate:modelValue": (te) => Q.value[K].value = te,
2570
+ label: "Total Cost",
2571
+ step: 1e-4,
2572
+ min: 0,
2573
+ placeholder: "0.0000",
2574
+ size: "sm",
2575
+ "append-text": d(Ce)()
2576
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "append-text"])) : U("", !0)
2577
+ ])
2578
+ ]),
2579
+ K < o.purchaseOrder.items.length - 1 ? (i(), b("div", No)) : U("", !0)
2580
+ ]);
2581
+ }), 128))
2582
+ ]),
2583
+ e("div", Ao, [
2584
+ g[9] || (g[9] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Delivery order no.", -1)),
2585
+ e("div", Po, [
2586
+ L(a, {
2587
+ modelValue: d(t).deliveryOrderNumber,
2588
+ "onUpdate:modelValue": g[2] || (g[2] = (A) => d(t).deliveryOrderNumber = A),
2589
+ size: "md"
2590
+ }, null, 8, ["modelValue"])
2591
+ ])
2592
+ ]),
2593
+ e("div", To, [
2594
+ g[10] || (g[10] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Remark", -1)),
2595
+ e("div", Fo, [
2596
+ L(a, {
2597
+ modelValue: d(t).remark,
2598
+ "onUpdate:modelValue": g[3] || (g[3] = (A) => d(t).remark = A),
2599
+ size: "md"
2600
+ }, null, 8, ["modelValue"])
2601
+ ])
2602
+ ])
2603
+ ])
2604
+ ];
2605
+ }),
2606
+ _: 1
2607
+ }, 8, ["modelValue"]);
2608
+ };
2609
+ }
2610
+ }), qo = { class: "flex flex-row-reverse" }, Eo = {
2611
+ key: 0,
2612
+ class: "flex"
2613
+ }, Vo = {
2614
+ key: 1,
2615
+ class: "border-t pt-6"
2616
+ }, Lo = { class: "fm-typo-en-body-lg-600 mb-4 flex items-center gap-2" }, Mo = { class: "border border-fm-color-neutral-gray-200 fm-corner-radius-lg overflow-y-auto" }, Uo = { class: "w-full" }, jo = {
2617
+ class: "p-3 fm-typo-en-body-sm-600",
2618
+ style: { "min-width": "130px" }
2619
+ }, Bo = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, zo = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Ko = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Ho = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Wo = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Go = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Yo = { class: "p-3 fm-typo-en-body-sm-600" }, Qo = { key: 2 }, Jo = /* @__PURE__ */ De({
2620
+ __name: "NetSuiteTransactionChangeLog",
2621
+ props: {
2622
+ netsuiteId: {}
2623
+ },
2624
+ setup(f) {
2625
+ const r = f, s = xt(), l = G(!1), c = G(!1), o = G(!1), m = G([]);
2626
+ async function t() {
2627
+ if (!(m.value.length > 0))
2628
+ try {
2629
+ c.value = !0;
2630
+ const y = await s.getChangeLogs(r.netsuiteId);
2631
+ m.value = y, o.value = !1;
2632
+ } catch {
2633
+ o.value = !0;
2634
+ } finally {
2635
+ c.value = !1;
2636
+ }
2637
+ }
2638
+ function n(y) {
2639
+ switch (y) {
2640
+ case Ne.Create:
2641
+ return "text-green-600 bg-green-100";
2642
+ case Ne.Set:
2643
+ return "text-blue-600 bg-blue-100";
2644
+ case Ne.Change:
2645
+ return "text-yellow-600 bg-yellow-100";
2646
+ case Ne.Unset:
2647
+ return "text-red-600 bg-red-100";
2648
+ default:
2649
+ return "text-gray-600 bg-gray-100";
2650
+ }
2651
+ }
2652
+ function v(y) {
2653
+ return new Date(y).toLocaleDateString("en-US", {
2654
+ year: "numeric",
2655
+ month: "short",
2656
+ day: "numeric",
2657
+ hour: "2-digit",
2658
+ minute: "2-digit"
2659
+ });
2660
+ }
2661
+ return (y, _) => {
2662
+ const h = X("FmButton"), D = X("FmCircularProgress"), x = X("FmIcon"), M = X("FmDialog");
2663
+ return i(), b("div", qo, [
2664
+ L(M, {
2665
+ modelValue: l.value,
2666
+ "onUpdate:modelValue": _[2] || (_[2] = (R) => l.value = R),
2667
+ overlay: !0,
2668
+ "max-width": 800
2669
+ }, {
2670
+ "dialog-button": oe(() => [
2671
+ L(h, {
2672
+ "prepend-icon": "info",
2673
+ variant: "secondary",
2674
+ label: "NetSuite",
2675
+ onClick: _[0] || (_[0] = (R) => t()),
2676
+ "text-color": "primary",
2677
+ "bg-color": "transparent",
2678
+ "border-color": "primary"
2679
+ })
2680
+ ]),
2681
+ "dialog-header": oe(() => _[3] || (_[3] = [
2682
+ e("div", null, "NetSuite info", -1)
2683
+ ])),
2684
+ default: oe(() => [
2685
+ c.value ? (i(), b("div", Eo, [
2686
+ _[4] || (_[4] = e("span", null, "Change Log Loading...", -1)),
2687
+ L(D, { size: "md" })
2688
+ ])) : U("", !0),
2689
+ !c.value && m.value.length > 0 ? (i(), b("div", Vo, [
2690
+ e("h3", Lo, [
2691
+ L(x, {
2692
+ name: "error",
2693
+ color: "#ff9500",
2694
+ size: "sm"
2695
+ }),
2696
+ _[5] || (_[5] = Pe(" Change Logs "))
2697
+ ]),
2698
+ e("div", Mo, [
2699
+ e("table", Uo, [
2700
+ _[6] || (_[6] = e("thead", { class: "bg-fm-color-neutral-gray-50" }, [
2701
+ e("tr", { class: "border-b border-fm-color-neutral-gray-200" }, [
2702
+ e("th", {
2703
+ class: "text-left p-3 fm-typo-en-body-md-600",
2704
+ style: { "min-width": "130px" }
2705
+ }, " Date "),
2706
+ e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Role"),
2707
+ e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Name"),
2708
+ e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Context"),
2709
+ e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Type"),
2710
+ e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Line ID"),
2711
+ e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Field"),
2712
+ e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Old Value"),
2713
+ e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "New Value")
2714
+ ])
2715
+ ], -1)),
2716
+ e("tbody", null, [
2717
+ (i(!0), b(fe, null, ke(m.value, (R, j) => (i(), b("tr", {
2718
+ key: j,
2719
+ class: "border-b border-fm-color-neutral-gray-200 last:border-b-0"
2720
+ }, [
2721
+ e("td", jo, p(v(R._dateiso8601)), 1),
2722
+ e("td", Bo, p(R._rolename), 1),
2723
+ e("td", zo, p(R._employeename), 1),
2724
+ e("td", Ko, p(R._contextname), 1),
2725
+ e("td", {
2726
+ class: je(`p-3 fm-typo-en-body-sm-600 ${n(Number(R.type) - 1)}`)
2727
+ }, p(d(Ne)[Number(R.type) - 1]), 3),
2728
+ e("td", Ho, p(R.lineid || ""), 1),
2729
+ e("td", Wo, p(R._fieldname), 1),
2730
+ e("td", Go, p(R.oldvalue || ""), 1),
2731
+ e("td", Yo, p(R.newvalue || ""), 1)
2732
+ ]))), 128))
2733
+ ])
2734
+ ])
2735
+ ])
2736
+ ])) : (i(), b("div", Qo, _[7] || (_[7] = [
2737
+ e("p", null, "No change logs available.", -1)
2738
+ ])))
2739
+ ]),
2740
+ "dialog-footer": oe(() => [
2741
+ L(h, {
2742
+ class: "ml-auto sm:w-full xs:w-full",
2743
+ label: "Close",
2744
+ size: "md",
2745
+ variant: "primary",
2746
+ onClick: _[1] || (_[1] = (R) => l.value = !1)
2747
+ })
2748
+ ]),
2749
+ _: 1
2750
+ }, 8, ["modelValue"])
2751
+ ]);
2752
+ };
2753
+ }
2754
+ }), Xo = { class: "flex flex-col w-full gap-3" }, Zo = { class: "flex" }, en = { class: "fm-typo-en-title-md-600 text-fm-color-typo-primary" }, tn = { class: "flex flex-col gap-16 w-full h-full" }, rn = { class: "flex justify-between" }, sn = { class: "fm-typo-en-body-lg-600" }, on = { class: "flex gap-2" }, nn = {
2755
+ key: 0,
2756
+ class: "flex items-center gap-1"
2757
+ }, an = { class: "fm-typo-en-body-md-400" }, ln = { class: "flex flex-col gap-8" }, cn = { class: "flex flex-col gap-4" }, un = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, dn = { class: "flex gap-1" }, mn = { class: "fm-typo-en-body-lg-600" }, pn = {
2758
+ key: 0,
2759
+ class: "flex flex-col gap-4"
2760
+ }, fn = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, yn = { class: "fm-typo-en-body-lg-600" }, vn = { class: "flex flex-col gap-4" }, bn = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, gn = { class: "fm-typo-en-body-lg-600" }, hn = {
2761
+ key: 1,
2762
+ class: "flex flex-col gap-4"
2763
+ }, _n = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, xn = { class: "fm-typo-en-body-lg-600" }, Sn = {
2764
+ key: 2,
2765
+ class: "flex flex-col gap-4"
2766
+ }, On = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, wn = { class: "fm-typo-en-body-lg-600" }, Cn = {
2767
+ key: 3,
2768
+ class: "flex flex-col gap-4"
2769
+ }, Dn = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, $n = { class: "fm-typo-en-body-lg-600" }, kn = {
2770
+ key: 4,
2771
+ class: "flex flex-col gap-4"
2772
+ }, Rn = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Nn = { class: "fm-typo-en-body-lg-600" }, An = {
2773
+ key: 5,
2774
+ class: "flex flex-col gap-4"
2775
+ }, Pn = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Tn = { class: "fm-typo-en-body-lg-600" }, Fn = { class: "border border-fm-color-neutral-gray-200 fm-corner-radius-lg p-16" }, In = { class: "flex flex-col gap-8" }, qn = { class: "flex gap-8 items-center" }, En = { class: "flex-1 fm-typo-en-body-lg-600" }, Vn = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary flex flex-col gap-4" }, Ln = { class: "flex w-full gap-4" }, Mn = { class: "basis-1/2 shrink-0 grow fm-typo-en-body-lg-400 line-clamp-2 flex items-center gap-2" }, Un = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary flex flex-col gap-2" }, jn = { class: "fm-typo-en-body-lg-400 line-clamp-2" }, Bn = ["innerHTML"], zn = { class: "flex w-full gap-4 fm-typo-en-body-sm-400" }, Kn = { class: "grow fm-typo-en-body-lg-400 text-fm-color-typo-secondary line-clamp-1" }, Hn = {
2776
+ key: 0,
2777
+ class: "flex items-center gap-4"
2778
+ }, Wn = { class: "line-clamp-1 fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, Gn = {
2779
+ key: 0,
2780
+ class: "inline-flex items-center gap-1 text-xs font-medium text-gray-500 bg-gray-100 px-2 py-0.5 rounded-full"
2781
+ }, Yn = { class: "py-8" }, Qn = { class: "flex justify-end gap-4 items-center" }, Jn = { class: "fm-typo-en-body-lg-600" }, Xn = {
2782
+ key: 1,
2783
+ class: "flex-1 xs:w-screen xs:max-w-full"
2784
+ }, Zn = {
2785
+ key: 0,
2786
+ class: "flex flex-col items-center gap-8 h-full"
2787
+ }, ea = ["src"], ta = { class: "fm-typo-en-body-lg-600" }, ra = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary px-16" }, sa = {
2788
+ key: 1,
2789
+ class: "px-4 flex flex-col"
2790
+ }, oa = { class: "flex gap-12 content-stretch" }, na = {
2791
+ class: "flex flex-col w-40",
2792
+ name: "circles"
2793
+ }, aa = { class: "flex-1 flex flex-col items-center" }, la = { class: "h-40 w-40 bg-fm-color-primary rounded-full flex items-center justify-center" }, ia = { class: "flex-1 flex flex-col items-center" }, ca = { class: "flex w-full items-center gap-4" }, ua = {
2794
+ class: "py-12 flex flex-col gap-4",
2795
+ name: "received-at header"
2796
+ }, da = { class: "fm-typo-en-body-lg-400" }, ma = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, pa = { class: "ml-auto flex gap-1" }, fa = { class: "flex gap-12 content-stretch" }, ya = {
2797
+ class: "flex flex-col w-40",
2798
+ name: "circles"
2799
+ }, va = { class: "flex-1 flex flex-col items-center" }, ba = {
2800
+ class: "py-12 flex flex-col gap-4 flex-1",
2801
+ name: "delivery details"
2802
+ }, ga = { class: "flex flex-col gap-8" }, ha = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, _a = { class: "flex flex-col gap-4" }, xa = { class: "flex gap-8 xs:flex-col" }, Za = /* @__PURE__ */ De({
2803
+ __name: "TransferDetails",
2804
+ props: {
2805
+ poRequest: {},
2806
+ purchaseOrder: {},
2807
+ transferTo: {},
2808
+ transferToDbName: {},
2809
+ show: { type: Boolean },
2810
+ canResubmit: { type: Boolean },
2811
+ canApprove: { type: Boolean },
2812
+ scope: {},
2813
+ receivedMap: {},
2814
+ shipments: {}
2815
+ },
2816
+ emits: ["update:show", "submitted"],
2817
+ setup(f, { emit: r }) {
2818
+ const s = f, l = r, c = dt(), o = He(), m = Ee(), t = Te(), n = ct(), { hasOrderDraftPermission: v } = Mt(), y = Vt();
2819
+ function _(a) {
2820
+ const u = a.isCustomCost, E = a.totalCost;
2821
+ return u != null ? u === !0 : E != null;
2822
+ }
2823
+ Ke(
2824
+ () => s.purchaseOrder,
2825
+ (a) => {
2826
+ y.init(a);
2827
+ },
2828
+ { immediate: !0 }
2829
+ );
2830
+ const h = Z(
2831
+ () => {
2832
+ var a, u;
2833
+ return {
2834
+ id: ((a = n.sessionUser.value) == null ? void 0 : a.id) ?? "",
2835
+ name: ((u = n.sessionUser.value) == null ? void 0 : u.displayName) ?? ""
2836
+ };
2837
+ }
2838
+ ), D = Lt(), { t: x } = it(), M = Z(
2839
+ () => {
2840
+ var a, u, E, A;
2841
+ return ((u = (a = s.purchaseOrder) == null ? void 0 : a.supplier) == null ? void 0 : u.internal) === "restaurant" || ((A = (E = s.purchaseOrder) == null ? void 0 : E.supplier) == null ? void 0 : A.internal) === "warehouse" ? Ze.enum.transfer : Ze.enum.purchase;
2842
+ }
2843
+ ), R = Z(() => {
2844
+ var E;
2845
+ const a = (E = s.shipments) == null ? void 0 : E.find((A) => {
2846
+ var K;
2847
+ return A.ref === ((K = s.purchaseOrder) == null ? void 0 : K._id);
2848
+ });
2849
+ let u = null;
2850
+ if (a != null && a.milestones && a.milestones.length > 0) {
2851
+ const A = a.milestones[a.milestones.length - 1];
2852
+ if (A.estimatedTime) {
2853
+ const K = new Date(A.estimatedTime), B = K.getDate().toString().padStart(2, "0");
2854
+ u = `${K.toLocaleString("en-US", { month: "short" })} ${B}`;
2855
+ }
2856
+ }
2857
+ return u;
2858
+ }), j = G(!1), O = G(""), k = G(!0), Y = We(), N = Dr(Y.getWorkflowConfig), P = Et(), $ = [
2859
+ q.enum.receiveStock,
2860
+ q.enum.processRequest,
2861
+ q.enum.closeRequest
2862
+ ], S = Z(() => {
2863
+ if (!s.purchaseOrder)
2864
+ return [];
2865
+ const a = N.result.value;
2866
+ if (a.state === Dt.loading)
2867
+ return [];
2868
+ const u = {
2869
+ user: h.value,
2870
+ executedAt: t.locations.computeFirst(
2871
+ (J) => {
2872
+ var C;
2873
+ return J.dbName === ((C = t._currentLocation) == null ? void 0 : C.dbName) ? J : null;
2874
+ }
2875
+ ),
2876
+ purchaseOrderRequest: s.poRequest,
2877
+ purchaseOrder: s.purchaseOrder
2878
+ }, E = m.useOperatePurchaseOrderV2, A = m.poWorkflowAllowToMarkCompleted, K = [...$];
2879
+ E && !A && K.push(q.enum.completeReceive);
2880
+ let B = [];
2881
+ try {
2882
+ a.state === Dt.error ? (console.error("Error fetching workflow config:", a.error), B = mt.getAvailableActions({
2883
+ ...u,
2884
+ orderConfig: mt.getDefaultConfig()
2885
+ }).actions.filter((J) => !K.includes(J))) : B = mt.getAvailableActions({
2886
+ ...u,
2887
+ orderConfig: a.data
2888
+ }).actions.filter((J) => !K.includes(J));
2889
+ } catch (J) {
2890
+ console.error("Error getting available actions:", J);
2891
+ }
2892
+ return s.scope === "approval" && (B = B.filter((J) => J !== q.enum.completeReceive)), v.value || (B = B.filter(
2893
+ (J) => J !== q.enum.approveDraft && J !== q.enum.rejectDraft
2894
+ )), B;
2895
+ }), T = br(s, "show"), W = Z(() => [
2896
+ {
2897
+ label: x("inventory.transfer.receiveRequest.details.overview"),
2898
+ value: "overview"
2899
+ },
2900
+ {
2901
+ label: x("inventory.transfer.receiveRequest.details.deliveryHistory"),
2902
+ value: "deliveryHistory"
2903
+ }
2904
+ ]), Q = G(W.value[0]);
2905
+ Ke(
2906
+ () => s.show,
2907
+ (a) => {
2908
+ a && (Q.value = W.value[0]);
2909
+ }
2910
+ );
2911
+ function ye(a) {
2912
+ return a.map((u) => ({
2913
+ ...u,
2914
+ amount: {
2915
+ ...u.amount,
2916
+ amount: -Math.abs(u.amount.amount)
2917
+ }
2918
+ }));
2919
+ }
2920
+ async function ge(a, u, E, A, K) {
2921
+ return new Promise((B, J) => {
2922
+ const C = {
2923
+ closeButton: !1,
2924
+ title: A.title,
2925
+ message: A.message,
2926
+ primaryActions: A.primaryActions,
2927
+ secondaryActions: { text: "No", close: !1 }
2928
+ };
2929
+ let te = u.rejectReason ?? "";
2930
+ E === q.enum.rejectDraft && (C.contentComponent = qt, C.contentComponentProps = {
2931
+ message: A.message,
2932
+ onChange: (ne) => {
2933
+ te = ne ?? "";
2934
+ }
2935
+ }), c.open(C).onPrimary(async () => {
2936
+ var de, re, le, ve;
2937
+ const ne = [];
2938
+ E === q.enum.confirmDraft ? ne.push({
2939
+ action: "confirmDraft",
2940
+ payload: y.controller.value.toConfirmDraftData(Ce())
2941
+ }) : E === q.enum.approveRequest ? (ne.push({
2942
+ action: "approveRequest",
2943
+ payload: null
2944
+ }), u.fulfillment && ne.push({
2945
+ action: "processRequest",
2946
+ payload: {
2947
+ fulfillmentId: "",
2948
+ deliveryOrderNumber: "",
2949
+ deliveryRemark: null,
2950
+ items: ye(u.fulfillment.items),
2951
+ createdBy: h.value
2952
+ }
2953
+ })) : E === q.enum.processRequest ? u.fulfillment && ne.push({
2954
+ action: "processRequest",
2955
+ payload: {
2956
+ fulfillmentId: "",
2957
+ deliveryOrderNumber: "",
2958
+ deliveryRemark: null,
2959
+ items: ye(u.fulfillment.items),
2960
+ createdBy: h.value
2961
+ }
2962
+ }) : E === q.enum.rejectRequest ? ne.push({
2963
+ action: "rejectRequest",
2964
+ payload: null
2965
+ }) : E === q.enum.closeRequest ? ne.push({
2966
+ action: "closeRequest",
2967
+ payload: null
2968
+ }) : E === q.enum.rejectDraft && ne.push({
2969
+ action: "rejectDraft",
2970
+ payload: {
2971
+ rejectReason: te ?? ""
2972
+ }
2973
+ });
2974
+ try {
2975
+ await P({
2976
+ operate: {
2977
+ operation: E,
2978
+ doc: a,
2979
+ options: u
2980
+ },
2981
+ operateV2: {
2982
+ _id: ((de = s.purchaseOrder) == null ? void 0 : de._id) ?? "",
2983
+ _rev: ((re = s.purchaseOrder) == null ? void 0 : re._rev) ?? "",
2984
+ action: E,
2985
+ payloads: ne
2986
+ // add payload if action is receiveStock or processRequest
2987
+ },
2988
+ transferTo: (ve = (le = s.poRequest) == null ? void 0 : le.to) == null ? void 0 : ve.dbName
2989
+ }).delayed(1e3), B("submitted");
2990
+ } catch (Ae) {
2991
+ J(Ae);
2992
+ }
2993
+ }).onSecondary(() => {
2994
+ B("cancelled");
2995
+ for (let ne = 0; ne < K + 2; ne++)
2996
+ c.close();
2997
+ }).onClose(() => {
2998
+ });
2999
+ });
3000
+ }
3001
+ async function F(a) {
3002
+ var K, B, J, C;
3003
+ if (a === q.enum.receiveStock)
3004
+ return;
3005
+ const u = It[a];
3006
+ if (!u) {
3007
+ o.open({
3008
+ title: "Something went wrong",
3009
+ message: `Cannot process order: ${ht(a)}`,
3010
+ type: "error"
3011
+ });
3012
+ return;
3013
+ }
3014
+ const { successMessage: E, ...A } = u;
3015
+ if (s.purchaseOrder) {
3016
+ O.value = `${a}`, j.value = !0, k.value = !1;
3017
+ const te = {};
3018
+ let ne = 0;
3019
+ if ((a === q.enum.confirmDraft || // auto receive for warehouse to warehouse
3020
+ a === q.enum.completeReceive) && m.autoReceiveWarehouse)
3021
+ te.autoReceive = !0;
3022
+ else if ((a === q.enum.approveRequest || a === q.enum.processRequest) && m.acceptRequireFulfillment) {
3023
+ const de = (B = (K = s.poRequest) == null ? void 0 : K.from) == null ? void 0 : B.dbName, re = (C = (J = s.poRequest) == null ? void 0 : J.to) == null ? void 0 : C.dbName;
3024
+ if (de && re && (de.startsWith("warehouse_") || re.startsWith("warehouse_"))) {
3025
+ const le = await new Promise((ve, Ae) => {
3026
+ c.open({
3027
+ closeButton: !1,
3028
+ title: "Confirm transfer amount",
3029
+ dialogComponent: Gr,
3030
+ dialogComponentProps: {
3031
+ purchaseOrder: s.purchaseOrder,
3032
+ confirm: ve,
3033
+ "onUpdate:show": (Ve) => {
3034
+ Ve || (O.value = "", j.value = !1, k.value = !0, ne++, c.close()), Ae("cancelled");
3035
+ }
3036
+ }
3037
+ });
3038
+ });
3039
+ te.fulfillment = le;
3040
+ }
3041
+ }
3042
+ try {
3043
+ await ge(
3044
+ s.purchaseOrder,
3045
+ te,
3046
+ a,
3047
+ u,
3048
+ ne
3049
+ ) === "submitted" && (o.open({
3050
+ title: "Success",
3051
+ message: E,
3052
+ type: "success"
3053
+ }), l("update:show", !1), l("submitted"));
3054
+ } catch (de) {
3055
+ o.open({
3056
+ title: "Something went wrong",
3057
+ message: "Please try again.",
3058
+ type: "error"
3059
+ }), console.error("Error when submitting PO operation", a, s.purchaseOrder, de);
3060
+ } finally {
3061
+ O.value = "", j.value = !1, k.value = !0;
3062
+ }
3063
+ }
3064
+ }
3065
+ const I = Z(() => {
3066
+ var a, u;
3067
+ return ((a = s.purchaseOrder) == null ? void 0 : a.status) === ae.enum.RECEIVING || ((u = s.purchaseOrder) == null ? void 0 : u.status) === ae.enum.COMPLETE;
3068
+ }), ee = Z(() => s.purchaseOrder ? at(s.purchaseOrder) : {}), w = Z(() => {
3069
+ const a = s.purchaseOrder;
3070
+ if (!a) return { status: "", statusClass: "" };
3071
+ const { partial: u, over: E } = vt(ee.value), A = bt(a.status, u, E);
3072
+ let K = x(`inventory.transfer.status.${A}`), B = `${a.status}`.toLocaleLowerCase("en-us");
3073
+ return A === ae.enum.CLOSE && (K = `${x(`inventory.transfer.status.${ae.enum.COMPLETE}`)}`), A === "PARTIAL_RECEIVED" && B === ae.enum.PROCESSING.toLocaleLowerCase("en-us") && (B = ae.enum.RECEIVING.toLocaleLowerCase("en-us")), {
3074
+ status: K,
3075
+ statusClass: `fm-status-badge fm-status-badge-${B}`
3076
+ };
3077
+ }), g = Z(() => {
3078
+ var B, J;
3079
+ const a = ((B = s.purchaseOrder) == null ? void 0 : B.deliveryOrder) ?? [], u = ((J = s.purchaseOrder) == null ? void 0 : J.deliveryFullfillment) ?? [], E = [
3080
+ ...a.map((C) => ({
3081
+ createdAt: C.createdAt,
3082
+ type: "grn",
3083
+ doc: C
3084
+ })),
3085
+ ...u.map((C) => ({
3086
+ createdAt: C.createdAt,
3087
+ type: "fulfillment",
3088
+ doc: C
3089
+ }))
3090
+ ];
3091
+ E.reverse().sort((C, te) => C.createdAt.localeCompare(te.createdAt));
3092
+ function A(C) {
3093
+ var de, re, le, ve, Ae, Ve, se, me, he, Se, $e, Fe;
3094
+ const te = u.findIndex((pe) => pe.id === C.fullfillmentId), ne = [
3095
+ (re = (de = u[te]) == null ? void 0 : de.netSuite) != null && re.id ? {
3096
+ label: "Fulfillment's ref no. (Netsuite)",
3097
+ values: [
3098
+ `${((ve = (le = u[te]) == null ? void 0 : le.netSuite) == null ? void 0 : ve.refNo) ?? "N/A"} (${((Ve = (Ae = u[te]) == null ? void 0 : Ae.netSuite) == null ? void 0 : Ve.id) ?? "-"})`
3099
+ ]
3100
+ } : null,
3101
+ (se = C == null ? void 0 : C.netSuite) != null && se.id ? {
3102
+ label: "Netsuite ref no.",
3103
+ values: [`${((me = C == null ? void 0 : C.netSuite) == null ? void 0 : me.refNo) ?? "N/A"} (${((he = C == null ? void 0 : C.netSuite) == null ? void 0 : he.id) ?? "-"})`]
3104
+ } : null,
3105
+ (Se = C == null ? void 0 : C.netSuite) != null && Se.recordType ? {
3106
+ label: "Netsuite Type",
3107
+ values: [Pt(($e = C == null ? void 0 : C.netSuite) == null ? void 0 : $e.recordType)]
3108
+ } : null
3109
+ ];
3110
+ return {
3111
+ header: "Received",
3112
+ deliveryOrder: C,
3113
+ date: et(new Date(C.createdAt)),
3114
+ info: [
3115
+ {
3116
+ label: "Adjustment date",
3117
+ values: [
3118
+ C.adjustment ? et(new Date(st(C.adjustment))) : "-"
3119
+ ]
3120
+ },
3121
+ {
3122
+ label: "Received by",
3123
+ values: [(Fe = C.createdBy) == null ? void 0 : Fe.name]
3124
+ },
3125
+ {
3126
+ label: "Received items",
3127
+ values: C.received.map((pe) => {
3128
+ var _e;
3129
+ return z("div", [
3130
+ z(
3131
+ "div",
3132
+ {
3133
+ class: "flex gap-4"
3134
+ },
3135
+ [
3136
+ z(
3137
+ "div",
3138
+ {
3139
+ class: "flex flex-col"
3140
+ },
3141
+ [
3142
+ z(
3143
+ "span",
3144
+ {
3145
+ class: "fm-typo-en-body-lg-800 basis-1/2 shrink-0 grow"
3146
+ },
3147
+ `${pe.sku.name}`
3148
+ ),
3149
+ z(
3150
+ "span",
3151
+ {
3152
+ class: "fm-typo-en-body-md-400"
3153
+ },
3154
+ `${pe.sku.code} `
3155
+ )
3156
+ ]
3157
+ ),
3158
+ z(
3159
+ "div",
3160
+ {
3161
+ class: "ml-auto flex flex-col"
3162
+ },
3163
+ [
3164
+ z(
3165
+ "div",
3166
+ {
3167
+ class: "ml-auto flex gap-1"
3168
+ },
3169
+ [
3170
+ z(
3171
+ "span",
3172
+ {
3173
+ class: "fm-typo-en-body-lg-600 self-end"
3174
+ },
3175
+ be(pe.amount, !1)
3176
+ ),
3177
+ z(
3178
+ "span",
3179
+ {
3180
+ class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary"
3181
+ },
3182
+ ((_e = pe.measurement) == null ? void 0 : _e.abbrev) ?? pe.sku.unit.abbrev
3183
+ )
3184
+ ]
3185
+ ),
3186
+ z(
3187
+ "div",
3188
+ {
3189
+ class: "flex self-end fm-typo-en-body-md-400 text-fm-color-typo-secondary"
3190
+ },
3191
+ `${pe.cost ? `(${Je(pe.cost)})` : ""}`
3192
+ )
3193
+ ]
3194
+ )
3195
+ ]
3196
+ )
3197
+ ]);
3198
+ })
3199
+ },
3200
+ {
3201
+ label: "Delivery order no.",
3202
+ values: [C.deliveryOrderNumber || "N/A"]
3203
+ },
3204
+ {
3205
+ label: "Remark",
3206
+ values: [C.remark || "N/A"]
3207
+ },
3208
+ te > -1 ? {
3209
+ label: "Fulfilment's sequence",
3210
+ values: [`${te + 1}`]
3211
+ } : null,
3212
+ ...ne
3213
+ ].filter((pe) => !!pe)
3214
+ };
3215
+ }
3216
+ function K(C) {
3217
+ var ne, de, re;
3218
+ const te = u.findIndex((le) => le.id === C.id);
3219
+ return {
3220
+ header: "Fulfillment",
3221
+ date: et(new Date(C.createdAt)),
3222
+ info: [
3223
+ {
3224
+ label: "Sequence",
3225
+ values: [String(te + 1)]
3226
+ },
3227
+ {
3228
+ label: "Receiveable items",
3229
+ values: C.items.map((le) => {
3230
+ var ve;
3231
+ return z("div", [
3232
+ z(
3233
+ "div",
3234
+ {
3235
+ class: "flex gap-4"
3236
+ },
3237
+ [
3238
+ z(
3239
+ "div",
3240
+ {
3241
+ class: "flex flex-col"
3242
+ },
3243
+ [
3244
+ z(
3245
+ "span",
3246
+ {
3247
+ class: "fm-typo-en-body-lg-800 basis-1/2 shrink-0 grow"
3248
+ },
3249
+ `${le.sku.name}`
3250
+ ),
3251
+ z(
3252
+ "span",
3253
+ {
3254
+ class: "fm-typo-en-body-md-400"
3255
+ },
3256
+ `${le.sku.code} `
3257
+ )
3258
+ ]
3259
+ ),
3260
+ z(
3261
+ "div",
3262
+ {
3263
+ class: "ml-auto flex flex-col"
3264
+ },
3265
+ [
3266
+ z(
3267
+ "div",
3268
+ {
3269
+ class: "ml-auto flex gap-1"
3270
+ },
3271
+ [
3272
+ z(
3273
+ "span",
3274
+ {
3275
+ class: "fm-typo-en-body-lg-600 self-end"
3276
+ },
3277
+ be(le.amount, !1)
3278
+ ),
3279
+ z(
3280
+ "span",
3281
+ {
3282
+ class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary"
3283
+ },
3284
+ ((ve = le.measurement) == null ? void 0 : ve.abbrev) ?? le.sku.unit.abbrev
3285
+ )
3286
+ ]
3287
+ ),
3288
+ z(
3289
+ "div",
3290
+ {
3291
+ class: "flex self-end fm-typo-en-body-md-400 text-fm-color-typo-secondary"
3292
+ },
3293
+ `${le.cost ? `(${Je(le.cost)})` : ""}`
3294
+ )
3295
+ ]
3296
+ )
3297
+ ]
3298
+ )
3299
+ ]);
3300
+ })
3301
+ },
3302
+ (ne = C.netSuite) != null && ne.refNo ? {
3303
+ label: "Netsuite Ref no. (ID)",
3304
+ values: [`${(de = C.netSuite) == null ? void 0 : de.refNo} (${((re = C.netSuite) == null ? void 0 : re.id) ?? "-"})`]
3305
+ } : null
3306
+ ].filter((le) => !!le)
3307
+ };
3308
+ }
3309
+ return E.map((C) => {
3310
+ switch (C.type) {
3311
+ case "grn":
3312
+ return A(C.doc);
3313
+ case "fulfillment":
3314
+ return K(C.doc);
3315
+ }
3316
+ });
3317
+ });
3318
+ function V(a) {
3319
+ var B;
3320
+ const E = (((B = s.purchaseOrder) == null ? void 0 : B.version) ?? Me.enum[1]) === Me.enum[2] ? a.id : a.sku._id, A = s.receivedMap[E];
3321
+ return `<span class="${H(a)} fm-typo-en-body-lg-600">${Ue.toFormatString({ value: A.received })}</span>/${xr(a.quantity, a.sku.unit, a.measurement)}`;
3322
+ }
3323
+ function H(a) {
3324
+ var te;
3325
+ const E = (((te = s.purchaseOrder) == null ? void 0 : te.version) ?? Me.enum[1]) === Me.enum[2] ? a.id : a.sku._id, A = s.receivedMap[E], { isPartialReceive: K, isNoReceive: B, isOverReceive: J, isFullReceive: C } = Br(A);
3326
+ return B ? "text-fm-color-typo-tertiary" : K ? "text-fm-color-system-warning-300" : J ? "text-fm-color-system-error-300" : C ? "text-fm-color-system-success-300" : "";
3327
+ }
3328
+ const ce = Z(() => {
3329
+ var a, u, E;
3330
+ return (a = s.purchaseOrder) != null && a.itemsAtSubmission ? ((u = s.purchaseOrder) == null ? void 0 : u.version) === Me.enum[2] ? s.purchaseOrder.items.reduce((A, K) => {
3331
+ var J, C;
3332
+ const B = (C = (J = s.purchaseOrder) == null ? void 0 : J.itemsAtSubmission) == null ? void 0 : C.find(
3333
+ (te) => te.id === K.id
3334
+ );
3335
+ return B && B.quantity !== K.quantity && A.set(K.sku.code, {
3336
+ originalAmount: Number(Ue.toFormatString({ value: B.quantity })),
3337
+ newAmount: Number(Ue.toFormatString({ value: K.quantity }))
3338
+ }), A;
3339
+ }, /* @__PURE__ */ new Map()) : (E = s.purchaseOrder) == null ? void 0 : E.items.reduce((A, K) => {
3340
+ var te, ne;
3341
+ const B = (ne = (te = s.purchaseOrder) == null ? void 0 : te.itemsAtSubmission) == null ? void 0 : ne.find(
3342
+ (de) => de.sku._id === K.sku._id
3343
+ ), J = B ? Number(Ue.toFormatString({ value: B.quantity })) : 0, C = Number(Ue.toFormatString({ value: K.quantity }));
3344
+ return B && J !== C && A.set(K.sku.code, {
3345
+ originalAmount: J,
3346
+ newAmount: C
3347
+ }), A;
3348
+ }, /* @__PURE__ */ new Map()) : /* @__PURE__ */ new Map();
3349
+ }), Re = (a) => {
3350
+ var E, A;
3351
+ const u = ce.value;
3352
+ return ((E = s.purchaseOrder) == null ? void 0 : E.version) === Me.enum[2] ? u.has(a.id) : u.has((A = a.sku) == null ? void 0 : A.code);
3353
+ }, Oe = (a) => {
3354
+ var E, A;
3355
+ const u = ce.value;
3356
+ return ((E = s.purchaseOrder) == null ? void 0 : E.version) === Me.enum[2] ? u.get(a.id) : u.get((A = a.sku) == null ? void 0 : A.code);
3357
+ }, Ge = Z(() => {
3358
+ const a = s.purchaseOrder;
3359
+ if (!a) return "";
3360
+ const u = a.actionChangelogs ?? [], E = u.length ? u[u.length - 1] : null;
3361
+ if (E && E.action === "rejectDraft") {
3362
+ const A = E.remarks ?? "";
3363
+ return A && A.toString().trim() !== "" ? A.toString() : "-";
3364
+ }
3365
+ return "";
3366
+ });
3367
+ return (a, u) => {
3368
+ const E = X("FmButton"), A = X("FmButtonGroup"), K = X("FmChip"), B = X("FmIcon"), J = X("FmMenuDivider"), C = X("FmCard"), te = X("FmTooltip"), ne = X("FmSpacer"), de = X("FmSideSheet");
3369
+ return i(), ie(de, {
3370
+ modelValue: d(T),
3371
+ "onUpdate:modelValue": u[8] || (u[8] = (re) => Jt(T) ? T.value = re : null),
3372
+ "dismiss-away": k.value,
3373
+ "max-width": 600,
3374
+ "close-button": !1
3375
+ }, {
3376
+ "side-sheet-header": oe(() => {
3377
+ var re, le;
3378
+ return [
3379
+ e("div", Xo, [
3380
+ e("div", Zo, [
3381
+ e("div", en, p(d(x)("inventory.transfer.receiveRequest.details.title") + ((re = a.purchaseOrder) != null && re.seqNumber ? ` #${(le = a.purchaseOrder) == null ? void 0 : le.seqNumber}` : "")), 1),
3382
+ L(E, {
3383
+ class: "ml-auto -m-2",
3384
+ variant: "tertiary",
3385
+ "prepend-icon": "close",
3386
+ onClick: u[0] || (u[0] = (ve) => l("update:show", !1))
3387
+ })
3388
+ ]),
3389
+ L(A, {
3390
+ items: W.value,
3391
+ modelValue: Q.value,
3392
+ "onUpdate:modelValue": u[1] || (u[1] = (ve) => Q.value = ve)
3393
+ }, null, 8, ["items", "modelValue"]),
3394
+ a.purchaseOrder && Q.value.value === "deliveryHistory" ? (i(), ie(Io, {
3395
+ key: 0,
3396
+ "purchase-order": a.purchaseOrder,
3397
+ "received-info-map": ee.value,
3398
+ onSubmitted: u[2] || (u[2] = () => {
3399
+ l("update:show", !1), l("submitted");
3400
+ })
3401
+ }, null, 8, ["purchase-order", "received-info-map"])) : U("", !0)
3402
+ ])
3403
+ ];
3404
+ }),
3405
+ default: oe(() => {
3406
+ var re, le, ve, Ae, Ve;
3407
+ return [
3408
+ e("div", tn, [
3409
+ Q.value.value === "overview" ? (i(), b(fe, { key: 0 }, [
3410
+ e("div", null, [
3411
+ L(C, {
3412
+ variant: "outlined",
3413
+ class: "flex flex-col gap-8 px-12 py-16"
3414
+ }, {
3415
+ default: oe(() => {
3416
+ var se, me, he, Se, $e, Fe, pe, _e, Le, ze;
3417
+ return [
3418
+ e("div", rn, [
3419
+ e("div", sn, p(d(x)("inventory.transfer.receiveRequest.details.requestSummary")), 1),
3420
+ e("div", on, [
3421
+ L(Be, null, {
3422
+ default: oe(() => {
3423
+ var rt;
3424
+ return [
3425
+ Pe(p((rt = s.purchaseOrder) == null ? void 0 : rt.status), 1)
3426
+ ];
3427
+ }),
3428
+ _: 1
3429
+ }),
3430
+ L(K, {
3431
+ label: w.value.status,
3432
+ class: je(w.value.statusClass),
3433
+ compact: ""
3434
+ }, null, 8, ["label", "class"]),
3435
+ R.value ? (i(), b("div", nn, [
3436
+ L(B, {
3437
+ name: "local_shipping",
3438
+ color: "#666666"
3439
+ }),
3440
+ e("span", an, p(R.value), 1)
3441
+ ])) : U("", !0)
3442
+ ])
3443
+ ]),
3444
+ L(J),
3445
+ e("div", ln, [
3446
+ e("div", cn, [
3447
+ e("div", un, [
3448
+ e("div", dn, p(d(x)("inventory.transfer.receiveRequest.details.createdAt")), 1)
3449
+ ]),
3450
+ e("div", mn, p(d(tt)(((se = a.purchaseOrder) == null ? void 0 : se._id) ?? "")), 1)
3451
+ ]),
3452
+ (me = a.purchaseOrder) != null && me.effectiveAt ? (i(), b("div", pn, [
3453
+ e("div", fn, p(d(x)("inventory.transfer.receiveRequest.details.backdatedTo")), 1),
3454
+ e("div", yn, p(d(_t)(new Date((he = a.purchaseOrder) == null ? void 0 : he.effectiveAt))), 1)
3455
+ ])) : U("", !0),
3456
+ e("div", vn, [
3457
+ e("div", bn, p(d(x)("inventory.transfer.receiveRequest.details.type.title")), 1),
3458
+ e("div", gn, p(d(x)(
3459
+ `inventory.transfer.receiveRequest.details.type.${M.value.toLocaleLowerCase("en-US")}`
3460
+ )), 1)
3461
+ ]),
3462
+ ($e = (Se = a.purchaseOrder) == null ? void 0 : Se.supplier) != null && $e.name ? (i(), b("div", hn, [
3463
+ e("div", _n, p(d(x)("inventory.transfer.receiveRequest.details.from")), 1),
3464
+ e("div", xn, p((pe = (Fe = a.purchaseOrder) == null ? void 0 : Fe.supplier) == null ? void 0 : pe.name), 1)
3465
+ ])) : U("", !0),
3466
+ a.transferTo ? (i(), b("div", Sn, [
3467
+ e("div", On, p(d(x)("inventory.transfer.receiveRequest.details.to")), 1),
3468
+ e("div", wn, p(a.transferTo), 1)
3469
+ ])) : U("", !0),
3470
+ (_e = a.purchaseOrder) != null && _e.ref ? (i(), b("div", Cn, [
3471
+ e("div", Dn, p(d(x)("inventory.transfer.receiveRequest.details.reference")), 1),
3472
+ e("div", $n, p(a.purchaseOrder.ref), 1)
3473
+ ])) : U("", !0),
3474
+ (Le = a.purchaseOrder) != null && Le.remark ? (i(), b("div", kn, [
3475
+ e("div", Rn, p(d(x)("inventory.transfer.receiveRequest.details.remark")), 1),
3476
+ e("div", Nn, p(a.purchaseOrder.remark), 1)
3477
+ ])) : U("", !0),
3478
+ ((ze = a.purchaseOrder) == null ? void 0 : ze.status) === d(ae).enum.DRAFT && Ge.value ? (i(), b("div", An, [
3479
+ e("div", Pn, p(d(x)("inventory.transfer.receiveRequest.details.rejectionReason")), 1),
3480
+ e("div", Tn, p(Ge.value !== "" ? Ge.value : "-"), 1)
3481
+ ])) : U("", !0)
3482
+ ])
3483
+ ];
3484
+ }),
3485
+ _: 1
3486
+ })
3487
+ ]),
3488
+ L(zs, {
3489
+ "po-request": a.poRequest,
3490
+ purchaseOrder: a.purchaseOrder,
3491
+ transferType: M.value,
3492
+ transferToDbName: a.transferToDbName,
3493
+ scope: a.scope
3494
+ }, null, 8, ["po-request", "purchaseOrder", "transferType", "transferToDbName", "scope"]),
3495
+ e("div", Fn, [
3496
+ e("div", In, [
3497
+ e("div", qn, [
3498
+ e("span", En, [
3499
+ Pe(p(I.value ? d(x)("inventory.transfer.receiveRequest.details.receivedItems") : d(x)("inventory.transfer.receiveRequest.details.requestedItems")) + " ", 1),
3500
+ (le = (re = a.purchaseOrder) == null ? void 0 : re.netSuite) != null && le.missingItems && ((Ae = (ve = a.purchaseOrder) == null ? void 0 : ve.netSuite) == null ? void 0 : Ae.missingItems.length) > 0 ? (i(), ie(te, {
3501
+ key: 0,
3502
+ variant: "rich",
3503
+ placement: "top",
3504
+ "z-index": 51
3505
+ }, {
3506
+ content: oe(() => {
3507
+ var se, me;
3508
+ return [
3509
+ e("div", Vn, [
3510
+ (i(!0), b(fe, null, ke((me = (se = a.purchaseOrder) == null ? void 0 : se.netSuite) == null ? void 0 : me.missingItems, (he, Se) => (i(), b("div", {
3511
+ class: "flex justify-center align-middle",
3512
+ key: Se
3513
+ }, [
3514
+ L(B, {
3515
+ name: "arrow_right",
3516
+ size: "sm"
3517
+ }),
3518
+ Pe(" " + p(`(${he.netSuiteId}) ${he.name}: ${he.reason}`), 1)
3519
+ ]))), 128))
3520
+ ])
3521
+ ];
3522
+ }),
3523
+ default: oe(() => [
3524
+ L(B, {
3525
+ name: "error",
3526
+ color: "#ff2c2c",
3527
+ size: "sm"
3528
+ })
3529
+ ]),
3530
+ _: 1
3531
+ })) : U("", !0)
3532
+ ])
3533
+ ]),
3534
+ L(J),
3535
+ (i(!0), b(fe, null, ke(((Ve = a.purchaseOrder) == null ? void 0 : Ve.items) ?? [], (se, me) => {
3536
+ var he;
3537
+ return i(), b("div", {
3538
+ key: me,
3539
+ class: "flex flex-col"
3540
+ }, [
3541
+ e("div", Ln, [
3542
+ e("div", Mn, [
3543
+ Pe(p(se.name) + " ", 1),
3544
+ Re(se) ? (i(), ie(te, {
3545
+ key: 0,
3546
+ variant: "rich",
3547
+ placement: "top",
3548
+ "z-index": 51
3549
+ }, {
3550
+ content: oe(() => {
3551
+ var Se, $e;
3552
+ return [
3553
+ e("div", Un, [
3554
+ u[9] || (u[9] = e("div", { class: "font-semibold" }, "Submission changes", -1)),
3555
+ e("div", null, "Original Amount: " + p((Se = Oe(se)) == null ? void 0 : Se.originalAmount), 1),
3556
+ e("div", null, " New Amount: " + p(($e = Oe(se)) == null ? void 0 : $e.newAmount), 1)
3557
+ ])
3558
+ ];
3559
+ }),
3560
+ default: oe(() => [
3561
+ L(B, {
3562
+ name: "error",
3563
+ color: "#ff9500",
3564
+ size: "sm"
3565
+ })
3566
+ ]),
3567
+ _: 2
3568
+ }, 1024)) : U("", !0)
3569
+ ]),
3570
+ e("div", jn, [
3571
+ e("span", {
3572
+ innerHTML: V(se)
3573
+ }, null, 8, Bn)
3574
+ ])
3575
+ ]),
3576
+ e("div", zn, [
3577
+ e("div", Kn, p(se.code), 1),
3578
+ d(m).enableTotalCost ? (i(), b("div", Hn, [
3579
+ e("span", Wn, p(d(Je)(
3580
+ (he = se.totalCost) != null && he.amount ? se.totalCost : d(y).controller.value.getItemCost(se, d(Ce)()).cost
3581
+ )), 1),
3582
+ _(se) ? U("", !0) : (i(), b("span", Gn, [
3583
+ u[10] || (u[10] = e("span", { class: "w-1.5 h-1.5 rounded-full bg-gray-400" }, null, -1)),
3584
+ Pe(" " + p(d(x)("inventory.transfer.form.items.autoCalculated")), 1)
3585
+ ]))
3586
+ ])) : U("", !0)
3587
+ ])
3588
+ ]);
3589
+ }), 128)),
3590
+ +d(be)(d(y).controller.value.getTotalCosts()) ? (i(), b(fe, { key: 0 }, [
3591
+ e("div", Yn, [
3592
+ L(J)
3593
+ ]),
3594
+ e("div", Qn, [
3595
+ u[11] || (u[11] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Total:", -1)),
3596
+ e("div", Jn, p(d(Ce)()) + " " + p(d(Je)({
3597
+ ...d(y).controller.value.getTotalCosts(),
3598
+ currency: d(Ce)()
3599
+ }).replace(/[^0-9.,]/g, "")), 1)
3600
+ ])
3601
+ ], 64)) : U("", !0)
3602
+ ])
3603
+ ])
3604
+ ], 64)) : Q.value.value === "deliveryHistory" ? (i(), b("div", Xn, [
3605
+ g.value.length ? (i(), b("div", sa, [
3606
+ (i(!0), b(fe, null, ke(g.value, (se, me) => {
3607
+ var he, Se, $e, Fe, pe;
3608
+ return i(), b(fe, { key: me }, [
3609
+ e("div", oa, [
3610
+ e("div", na, [
3611
+ e("div", aa, [
3612
+ e("div", {
3613
+ class: je([
3614
+ {
3615
+ "bg-fm-color-primary": me !== 0,
3616
+ "bg-white": me === 0
3617
+ },
3618
+ "w-[2px] h-full"
3619
+ ])
3620
+ }, null, 2)
3621
+ ]),
3622
+ e("div", la, [
3623
+ se.header === "Received" ? (i(), ie(B, {
3624
+ key: 0,
3625
+ name: "local_shipping",
3626
+ outline: "",
3627
+ color: "#ffffff"
3628
+ })) : U("", !0)
3629
+ ]),
3630
+ e("div", ia, [
3631
+ e("div", {
3632
+ class: je([
3633
+ {
3634
+ "bg-fm-color-primary": me < g.value.length - 1,
3635
+ "bg-white": me >= g.value.length - 1
3636
+ },
3637
+ "w-[2px] h-full"
3638
+ ])
3639
+ }, null, 2)
3640
+ ])
3641
+ ]),
3642
+ e("div", ca, [
3643
+ e("div", ua, [
3644
+ e("div", da, p(se.header), 1),
3645
+ e("div", ma, p(se.date), 1)
3646
+ ]),
3647
+ e("div", pa, [
3648
+ se.header === "Received" && se.deliveryOrder && a.purchaseOrder ? (i(), ie(co, {
3649
+ key: 0,
3650
+ deliveryOrder: se.deliveryOrder,
3651
+ purchaseOrder: a.purchaseOrder,
3652
+ onSubmitted: u[3] || (u[3] = () => {
3653
+ l("update:show", !1), l("submitted");
3654
+ })
3655
+ }, null, 8, ["deliveryOrder", "purchaseOrder"])) : U("", !0),
3656
+ (Se = (he = se.deliveryOrder) == null ? void 0 : he.netSuite) != null && Se.id ? (i(), ie(Be, { key: 1 }, {
3657
+ default: oe(() => {
3658
+ var _e, Le;
3659
+ return [
3660
+ L(Jo, {
3661
+ "netsuite-id": (Le = (_e = se.deliveryOrder) == null ? void 0 : _e.netSuite) == null ? void 0 : Le.id
3662
+ }, null, 8, ["netsuite-id"])
3663
+ ];
3664
+ }),
3665
+ _: 2
3666
+ }, 1024)) : U("", !0),
3667
+ a.purchaseOrder && (($e = se.deliveryOrder) != null && $e.id) ? (i(), ie(Sr, {
3668
+ key: 2,
3669
+ "purchase-order-id": (Fe = a.purchaseOrder) == null ? void 0 : Fe._id,
3670
+ "delivery-order-id": (pe = se.deliveryOrder) == null ? void 0 : pe.id
3671
+ }, null, 8, ["purchase-order-id", "delivery-order-id"])) : U("", !0)
3672
+ ])
3673
+ ])
3674
+ ]),
3675
+ e("div", fa, [
3676
+ e("div", ya, [
3677
+ e("div", va, [
3678
+ e("div", {
3679
+ class: je([
3680
+ {
3681
+ "bg-fm-color-primary": me < g.value.length - 1,
3682
+ "bg-white": me >= g.value.length - 1
3683
+ },
3684
+ "w-[2px] h-full"
3685
+ ])
3686
+ }, null, 2)
3687
+ ])
3688
+ ]),
3689
+ e("div", ba, [
3690
+ L(C, {
3691
+ variant: "outlined",
3692
+ class: "py-12 px-16"
3693
+ }, {
3694
+ default: oe(() => [
3695
+ e("div", ga, [
3696
+ (i(!0), b(fe, null, ke(se.info, (_e, Le) => (i(), b("div", {
3697
+ key: Le,
3698
+ class: "flex flex-col gap-4"
3699
+ }, [
3700
+ e("div", ha, p(_e == null ? void 0 : _e.label), 1),
3701
+ e("div", _a, [
3702
+ (i(!0), b(fe, null, ke(_e == null ? void 0 : _e.values, (ze, rt) => (i(), b("div", {
3703
+ key: rt,
3704
+ class: "fm-typo-en-body-lg-600"
3705
+ }, [
3706
+ typeof ze == "string" ? (i(), b(fe, { key: 0 }, [
3707
+ Pe(p(ze), 1)
3708
+ ], 64)) : (i(), ie(Xt(ze), { key: 1 }))
3709
+ ]))), 128))
3710
+ ])
3711
+ ]))), 128))
3712
+ ])
3713
+ ]),
3714
+ _: 2
3715
+ }, 1024)
3716
+ ])
3717
+ ])
3718
+ ], 64);
3719
+ }), 128))
3720
+ ])) : (i(), b("div", Zn, [
3721
+ L(ne),
3722
+ e("div", null, [
3723
+ e("img", {
3724
+ src: d(gr),
3725
+ alt: "List is empty"
3726
+ }, null, 8, ea)
3727
+ ]),
3728
+ e("div", ta, p(d(x)("inventory.transfer.receiveRequest.details.noRecordsFound")), 1),
3729
+ e("div", ra, p(d(x)("inventory.transfer.receiveRequest.details.trackDeliveryMessage")), 1),
3730
+ L(ne),
3731
+ L(ne)
3732
+ ]))
3733
+ ])) : U("", !0)
3734
+ ])
3735
+ ];
3736
+ }),
3737
+ "side-sheet-footer": oe(() => [
3738
+ e("div", xa, [
3739
+ (i(!0), b(fe, null, ke(S.value, (re) => (i(), b(fe, null, [
3740
+ d(yt)[re].available != !1 ? (i(), ie(E, {
3741
+ key: re,
3742
+ label: d(x)(d(yt)[re].translationKey),
3743
+ onClick: (le) => F(re),
3744
+ loading: O.value === re,
3745
+ disabled: O.value !== re && j.value,
3746
+ variant: d(yt)[re].buttonVariant
3747
+ }, null, 8, ["label", "onClick", "loading", "disabled", "variant"])) : U("", !0)
3748
+ ], 64))), 256)),
3749
+ d(D).ableToMarkReceived(a.purchaseOrder) && !S.value.includes("completeReceive") ? (i(), ie(E, {
3750
+ key: 0,
3751
+ label: d(x)("inventory.transfer.receiveRequest.actions.completeReceive"),
3752
+ onClick: u[4] || (u[4] = (re) => F("completeReceive")),
3753
+ loading: O.value === "completeReceive",
3754
+ disabled: O.value !== "completeReceive" && j.value
3755
+ }, null, 8, ["label", "loading", "disabled"])) : U("", !0),
3756
+ d(D).ableToMarkApproved(a.purchaseOrder) && a.canApprove && !S.value.includes("approveRequest") ? (i(), ie(E, {
3757
+ key: 1,
3758
+ label: d(x)("inventory.transfer.approval.actions.approveRequest"),
3759
+ onClick: u[5] || (u[5] = (re) => F("approveRequest")),
3760
+ loading: O.value === "approveRequest",
3761
+ disabled: O.value !== "approveRequest" && j.value
3762
+ }, null, 8, ["label", "loading", "disabled"])) : U("", !0),
3763
+ d(D).ableToCreateFulfillment(a.purchaseOrder, a.poRequest) && s.scope === "approval" ? (i(), ie(E, {
3764
+ key: 2,
3765
+ label: d(x)("inventory.transfer.receiveRequest.actions.processRequest"),
3766
+ onClick: u[6] || (u[6] = (re) => F("processRequest")),
3767
+ loading: O.value === "processRequest",
3768
+ disabled: O.value !== "processRequest" && j.value
3769
+ }, null, 8, ["label", "loading", "disabled"])) : U("", !0),
3770
+ L(E, {
3771
+ label: d(x)("common.close"),
3772
+ variant: "tertiary",
3773
+ onClick: u[7] || (u[7] = (re) => l("update:show", !1))
3774
+ }, null, 8, ["label"])
3775
+ ])
3776
+ ]),
3777
+ _: 1
3778
+ }, 8, ["modelValue", "dismiss-away"]);
3779
+ };
3780
+ }
3781
+ });
3782
+ export {
3783
+ gt as P,
3784
+ Za as _,
3785
+ Ja as a,
3786
+ Xa as b,
3787
+ Qa as c,
3788
+ Ft as g,
3789
+ Vt as u
3790
+ };