@feedmepos/mf-inventory-portal 1.7.0-dev.3 → 1.7.0-dev.5

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