@feedmepos/mf-inventory-portal 1.2.51-dev.1 → 1.2.51

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 (96) hide show
  1. package/dist/{App-bY_YcLwH.js → App-BJ_vKOR1.js} +70 -75
  2. package/dist/{ApprovalView-vzIiBqt2.js → ApprovalView-B_prTTtl.js} +34 -34
  3. package/dist/{BindingsDialog-DCh2ORem.js → BindingsDialog-BPuKgJIk.js} +2 -2
  4. package/dist/{BindingsPicker-DcNG03p-.js → BindingsPicker-Dv_cmEil.js} +2 -2
  5. package/dist/{BindingsTable-B_Yaq-z3.js → BindingsTable-BNSfYRfq.js} +4 -4
  6. package/dist/{ClosingDraftView-C0T8cWEB.js → ClosingDraftView-C78tcaJ3.js} +399 -413
  7. package/dist/{ClosingHistoryView-DkKAjh7T.js → ClosingHistoryView-DY8liEk3.js} +27 -27
  8. package/dist/{ClosingTemplateView-DpH1EyW5.js → ClosingTemplateView-pJXEcrjO.js} +17 -18
  9. package/dist/{DeliveryOrderPrintPreview-B2ecLaLu.js → DeliveryOrderPrintPreview-Bu_l-kxu.js} +1 -1
  10. package/dist/FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-Dgibb-Fh.js +231 -0
  11. package/dist/{FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-kVpsL4cx.js → FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-DHe5G3kX.js} +12 -12
  12. package/dist/{FmMultiselectDialog-DGUwruxs.js → FmMultiselectDialog-C3iCMK5I.js} +1 -1
  13. package/dist/FmMultiselectDialog-CDONDKxE.js +598 -0
  14. package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-CRTG3VFo.js → FmUnitInput.vue_vue_type_script_setup_true_lang-CefvebOx.js} +3 -3
  15. package/dist/{ImportView-Bk4Z7nGh.js → ImportView-JrenRgiI.js} +7 -7
  16. package/dist/{IngredientBindedItem.vue_vue_type_script_setup_true_lang-BEJ19Uej.js → IngredientBindedItem.vue_vue_type_script_setup_true_lang-CSdxodp6.js} +1 -1
  17. package/dist/{IngredientGroupView-8GHMMOux.js → IngredientGroupView-aDFq_ZDh.js} +107 -108
  18. package/dist/{IngredientsView-DbmODx-v.js → IngredientsView-DSh3UqDg.js} +125 -126
  19. package/dist/{IntegrationView-DC0O_Lk4.js → IntegrationView-KhZ78uxM.js} +80 -80
  20. package/dist/{InventoryBindingForm-ln0q25n_.js → InventoryBindingForm-DZu0CZYh.js} +1 -1
  21. package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-CFgk9rSe.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-YuCn0irA.js} +21 -21
  22. package/dist/{InventoryBindingSummary-BlNXhS4v.js → InventoryBindingSummary-DZxLhZ_-.js} +1 -1
  23. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-BY_mXqPr.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-DAwpZY3n.js} +1 -1
  24. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-BhNjwE3X.js → PremiumBadge.vue_vue_type_script_setup_true_lang-CPDxwz-V.js} +2 -2
  25. package/dist/{PublishView-5GkTzxbi.js → PublishView-CLnQ7NBN.js} +3 -3
  26. package/dist/{PurchaseOrderPrintPreview-Dj5lJ5Ou.js → PurchaseOrderPrintPreview-DiBztBma.js} +1 -1
  27. package/dist/ReceiveRequestView-_TOSnDGJ.js +2913 -0
  28. package/dist/{RecipeView-OLPRwnVx.js → RecipeView-BPIMvoTw.js} +82 -83
  29. package/dist/{StockView-TcA5zJqr.js → StockView-CI8MUJay.js} +112 -113
  30. package/dist/{SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-DZ6TDkKR.js → SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-DEBHEMkh.js} +1 -1
  31. package/dist/{SupplierView-77qI9YCg.js → SupplierView-COihDMNY.js} +27 -28
  32. package/dist/{SystemTrailDialog.vue_vue_type_script_setup_true_lang-_8YeihNH.js → SystemTrailDialog.vue_vue_type_script_setup_true_lang-D-c0Ayis.js} +2 -2
  33. package/dist/TableActionableRow.vue_vue_type_script_setup_true_lang-cfFHDIwQ.js +162 -0
  34. package/dist/{TemplatePublishDialog.vue_vue_type_script_setup_true_lang-ByPIjcED.js → TemplatePublishDialog.vue_vue_type_script_setup_true_lang-D8vbPlie.js} +13 -13
  35. package/dist/{TransferDetails.vue_vue_type_script_setup_true_lang-7BoFD5wV.js → TransferDetails.vue_vue_type_script_setup_true_lang-BVuuw11z.js} +659 -658
  36. package/dist/{TransferTemplateView-CI0U36Tr.js → TransferTemplateView-B2NNfrEq.js} +81 -82
  37. package/dist/{UnitView-fNFFUNlb.js → UnitView-ZsbM07hw.js} +19 -20
  38. package/dist/{WarehouseView-BAXgnZnO.js → WarehouseView-Cd5RFu5v.js} +20 -21
  39. package/dist/{WastageTemplateView-C5qCXWqZ.js → WastageTemplateView-DpikyyZW.js} +164 -165
  40. package/dist/api/netsuite.d.ts +0 -8
  41. package/dist/{app-CddcvygU.js → app-CySQTQxj.js} +4410 -4513
  42. package/dist/app-uBuHtW8m.js +8127 -0
  43. package/dist/app.d.ts +0 -52
  44. package/dist/app.js +1 -1
  45. package/dist/{closing-template-DxdLqlb1.js → closing-template-DXGjC5AG.js} +1 -1
  46. package/dist/components/FmInventoryTableToolbar.vue.d.ts +0 -8
  47. package/dist/components/FmMultiselectDialogProps.d.ts +0 -5
  48. package/dist/cypress/component/receive-request/KDI-15-total-price-currency.cy.d.ts +2 -0
  49. package/dist/{date2-CVZy20Q_.js → date2-BWoUn1K_.js} +1 -1
  50. package/dist/{dayjs.min-NrRtjg32.js → dayjs.min-cMW8olEu.js} +26 -26
  51. package/dist/{decimal-Du3Grkk9.js → decimal-8BRzZQU6.js} +2 -2
  52. package/dist/{defineDeepModel-DgRoiQBp.js → defineDeepModel-AsUZ-DyW.js} +1 -1
  53. package/dist/{duplicate-template-DvnZ4BW6.js → duplicate-template-CyHfZR3S.js} +1 -1
  54. package/dist/{feature-CTA18HlL.js → feature-Dm0FnWf9.js} +6178 -8906
  55. package/dist/{format-time-from-id-6kt1RMWs.js → format-time-from-id-C9lmv5BP.js} +1 -1
  56. package/dist/{format-unit-display-mVJ-nuJe.js → format-unit-display-BV8pJisO.js} +11 -11
  57. package/dist/{import-export.helper-DWwlJy7N.js → import-export.helper-Djxw_H5S.js} +5 -5
  58. package/dist/{index-By-jyWOP.js → index-8hCa5_Gb.js} +1 -1
  59. package/dist/{index-BfcdagSF.js → index-D6u3kywf.js} +1 -1
  60. package/dist/{index-BEcj1jGd.js → index-DidYtgNc.js} +3 -3
  61. package/dist/{lodash-D0COOw3m.js → lodash-CW_Ea6mA.js} +1 -1
  62. package/dist/netsuite-BEto-z0v.js +5131 -0
  63. package/dist/{purchase-order-template-CJCmABzP.js → purchase-order-template-BTzjcgrO.js} +1 -1
  64. package/dist/router/name.d.ts +0 -1
  65. package/dist/{rules-hQBVd1Mn.js → rules-DkVWS5mF.js} +9 -9
  66. package/dist/{stock-4xGaezEy.js → stock-CHw8pI8V.js} +3 -3
  67. package/dist/{stock-B6QW-S14.js → stock-D8hLHgeN.js} +1 -1
  68. package/dist/stores/feature.d.ts +2 -4
  69. package/dist/stores/integration/netsuite.d.ts +0 -5
  70. package/dist/style.css +1 -1
  71. package/dist/{supplier-C-dmFnqw.js → supplier-Dv83IfQr.js} +2 -2
  72. package/dist/tsconfig.app.tsbuildinfo +1 -1
  73. package/dist/{use-ingredient-select-dialog-DgYSZDN8.js → use-ingredient-select-dialog-CJjd4g-6.js} +2 -2
  74. package/dist/{use-inventory-binding-dialog-CnYcA_Fo.js → use-inventory-binding-dialog-D4g79p5S.js} +2 -2
  75. package/dist/{use-template-enabled-locations-2-B_aZrMUU.js → use-template-enabled-locations-2-Cg2iqQdq.js} +2 -2
  76. package/dist/views/ingredients/helper/calculate-default-cost.d.ts +9 -0
  77. package/dist/views/receive-request/components/transfer-form/TransferForm2.vue.d.ts +22 -0
  78. package/dist/views/receive-request/components/transfer-form/TransferFormWithController.vue.d.ts +0 -714
  79. package/dist/views/receive-request/components/transfer-form/composables/use-transfer-items.d.ts +1 -8
  80. package/dist/views/stock/components/StockRecordCard.vue.d.ts +1 -1
  81. package/dist/{vue-i18n-BCEDBY4T.js → vue-i18n-kUcLfpvT.js} +563 -563
  82. package/dist/{xlsx-CJsXiiEq.js → xlsx-BjeMbhDF.js} +398 -398
  83. package/dist/{xlsx.util-CSudzOii.js → xlsx.util-9eMlJfd9.js} +1 -1
  84. package/package.json +5 -5
  85. package/dist/FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-CI4z5XYQ.js +0 -188
  86. package/dist/FmMultiselectDialog-BviFuAM5.js +0 -618
  87. package/dist/ReceiveRequestView-BAYczSpW.js +0 -2913
  88. package/dist/SurchargeView-CxW2ZZ8a.js +0 -460
  89. package/dist/TableActionableRow.vue_vue_type_script_setup_true_lang-Ca_eYa8-.js +0 -84
  90. package/dist/api/surcharge.d.ts +0 -31
  91. package/dist/app-DiX-EfV6.js +0 -8167
  92. package/dist/component-DpCUABT3.js +0 -82
  93. package/dist/netsuite-3LgQ5ztL.js +0 -5402
  94. package/dist/stores/surcharge.d.ts +0 -18
  95. package/dist/surcharge-Db4IiSEQ.js +0 -71
  96. package/dist/views/surcharge/SurchargeView.vue.d.ts +0 -2
@@ -0,0 +1,2913 @@
1
+ import { reactive as It, onMounted as We, watch as _e, computed as M, h as Q, defineComponent as de, openBlock as k, createElementBlock as T, Fragment as re, renderList as xe, createElementVNode as l, toDisplayString as E, unref as t, resolveComponent as V, createVNode as v, withCtx as A, createCommentVNode as K, ref as U, createBlock as se, normalizeClass as J, normalizeStyle as $t, createTextVNode as Pe, toRaw as At, shallowRef as _t, onUnmounted as Et, triggerRef as Mt, mergeProps as nt, isRef as Se, createSlots as qt, Teleport as Ut, normalizeProps as Nt, guardReactiveProps as Bt } from "vue";
2
+ import { s as rt, t as pe, J as zt, f as Dt, M as Lt, A as Ht, u as Je, a as Ge, O as ht, P as jt, Q as Qt, T as Yt, U as Kt, v as Xt, m as Ke } from "./app-CySQTQxj.js";
3
+ import { i as kt, _ as Zt } from "./FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-DHe5G3kX.js";
4
+ import { u as Wt, P as at, a as Jt, _ as Gt, g as es } from "./TransferDetails.vue_vue_type_script_setup_true_lang-BVuuw11z.js";
5
+ import { R as Ue, a as we, e as Ze, d as ts, A as Xe, M as ss, B as lt } from "./rules-DkVWS5mF.js";
6
+ import { _ as Tt, u as as, i as os, e as ns } from "./PremiumBadge.vue_vue_type_script_setup_true_lang-CPDxwz-V.js";
7
+ import { d as xt } from "./dayjs.min-cMW8olEu.js";
8
+ import { u as ls } from "./useTabStorage-BkIVScW_.js";
9
+ import { u as rs, _ as is } from "./SingleColumnLayout.vue_vue_type_script_setup_true_lang-CWZkVCAj.js";
10
+ import { useBreakpoints as it, components as ge, FmButtonVariant as us, useSnackbar as Re, useDialog as ds, useProxiedModel as Vt } from "@feedmepos/ui-library";
11
+ import { F as qe } from "./form-mode.enum-BKiNVH6A.js";
12
+ import { _ as cs, a as ms, b as ps, F as fs } from "./FmUnitInput.vue_vue_type_script_setup_true_lang-CefvebOx.js";
13
+ import { u as et, c as vs, P as ys } from "./feature-Dm0FnWf9.js";
14
+ import { u as Ne } from "./netsuite-BEto-z0v.js";
15
+ import { c as Te, u as bs, _ as gs } from "./FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-Dgibb-Fh.js";
16
+ import { useI18n as he } from "@feedmepos/mf-common";
17
+ import { a as _s } from "./FmMultiselectDialog-CDONDKxE.js";
18
+ import { F as ve, _ as Pt } from "./TableActionableRow.vue_vue_type_script_setup_true_lang-cfFHDIwQ.js";
19
+ import { u as ut } from "./supplier-Dv83IfQr.js";
20
+ import { d as dt, e as hs, g as ks, b as xs } from "./date2-BWoUn1K_.js";
21
+ import { _ as Cs } from "./PreviewBadge.vue_vue_type_script_setup_true_lang-CRZiQHjx.js";
22
+ import { a as Rt } from "./format-unit-display-BV8pJisO.js";
23
+ import { u as ct } from "./SystemTrailDialog.vue_vue_type_script_setup_true_lang-D-c0Ayis.js";
24
+ import { u as Ss } from "./vue-i18n-kUcLfpvT.js";
25
+ import { s as ws, r as Fs } from "./xlsx.util-9eMlJfd9.js";
26
+ import { F as Is } from "./FmDroppableField-J0xUsOTV.js";
27
+ import { d as $s } from "./defineDeepModel-AsUZ-DyW.js";
28
+ import { N as Ds, H as Ts } from "./app-uBuHtW8m.js";
29
+ var te = /* @__PURE__ */ ((p) => (p.Code = "Code", p.Name = "Name", p.TemplateName = "TemplateName", p.Amount = "Amount", p.Cost = "Cost", p.TotalCost = "TotalCost", p.Delete = "Delete", p))(te || {});
30
+ const Vs = () => (he(), Q(
31
+ Tt,
32
+ {
33
+ zIndex: 50,
34
+ class: "whitespace-nowrap"
35
+ },
36
+ `Total (${Dt()})`
37
+ ));
38
+ function Ps(p) {
39
+ const { t: g } = he(), i = It({}), { breakpoints: d } = it(), b = et(), o = Ne();
40
+ We(() => {
41
+ for (const m of p.items) {
42
+ if (!m.totalCost)
43
+ continue;
44
+ const { cost: e } = Te(
45
+ m.sku,
46
+ m.quantity,
47
+ m.measurement,
48
+ {
49
+ supplier: p.supplier
50
+ }
51
+ ), n = m.totalCost ?? rt.reset();
52
+ e ? i[m.sku._id] = e.amount !== n.amount || e.precision !== n.precision : i[m.sku._id] = !0;
53
+ }
54
+ }), _e(
55
+ () => {
56
+ var m;
57
+ return (m = p.supplier) == null ? void 0 : m._id;
58
+ },
59
+ () => {
60
+ const m = p.supplier;
61
+ for (const e of p.items) {
62
+ if (!e.totalCost || i[e.sku._id] || !h(e.sku))
63
+ continue;
64
+ const { cost: n } = Te(
65
+ e.sku,
66
+ e.quantity,
67
+ e.measurement,
68
+ {
69
+ supplier: m
70
+ }
71
+ );
72
+ p.updateItem({ ...e, totalCost: n });
73
+ }
74
+ }
75
+ );
76
+ function h(m) {
77
+ var n, f, s, r, u, w, $;
78
+ return !!(((f = (n = m.defaultCost) == null ? void 0 : n.costPerUnit) == null ? void 0 : f.amount) ?? (($ = (w = (u = (r = (s = p.supplier) == null ? void 0 : s.supplyItems) == null ? void 0 : r.find((c) => c.skuId === m._id)) == null ? void 0 : u.defaultCost) == null ? void 0 : w.costPerUnit) == null ? void 0 : $.amount));
79
+ }
80
+ const x = [
81
+ {
82
+ id: "Code",
83
+ header: () => g("inventory.transfer.form.items.table.Code"),
84
+ accessorKey: "code",
85
+ size: 200,
86
+ cell(m) {
87
+ const e = m.row.original;
88
+ return o.isEnabled ? Q(
89
+ ge.FmTooltip,
90
+ {
91
+ content: e.code,
92
+ placement: "top",
93
+ variant: "plain",
94
+ zIndex: 50
95
+ },
96
+ Q(
97
+ "span",
98
+ {
99
+ class: "flex-auto line-clamp-2 text-ellipsis break-all"
100
+ },
101
+ e.code
102
+ )
103
+ ) : Q(ge.FmTextField, {
104
+ modelValue: e.code,
105
+ "onUpdate:modelValue": (n) => {
106
+ p.updateItem({
107
+ ...e,
108
+ code: n
109
+ });
110
+ },
111
+ key: e.sku._id,
112
+ rules: [Ue()],
113
+ labelMark: "required"
114
+ });
115
+ },
116
+ enableSorting: !1
117
+ },
118
+ {
119
+ id: "Name",
120
+ header: () => g("inventory.transfer.form.items.table.Name"),
121
+ minSize: 300,
122
+ cell(m) {
123
+ const e = m.row.original;
124
+ return o.isEnabled ? Q(
125
+ ge.FmTooltip,
126
+ {
127
+ content: e.name,
128
+ placement: "top",
129
+ variant: "plain",
130
+ zIndex: 50
131
+ },
132
+ Q(
133
+ "span",
134
+ {
135
+ class: "flex-auto line-clamp-2 text-ellipsis break-all"
136
+ },
137
+ e.name
138
+ )
139
+ ) : Q(ge.FmTextField, {
140
+ modelValue: e.name,
141
+ "onUpdate:modelValue": (n) => {
142
+ p.updateItem({
143
+ ...e,
144
+ name: n
145
+ });
146
+ },
147
+ key: e.sku._id,
148
+ rules: [Ue()],
149
+ labelMark: "required"
150
+ });
151
+ },
152
+ enableSorting: !1
153
+ },
154
+ {
155
+ id: "TemplateName",
156
+ header: () => g("inventory.transfer.form.items.table.Name"),
157
+ minSize: 300,
158
+ enableSorting: !1,
159
+ cell(m) {
160
+ const e = m.row.original, n = e.code, f = e.name;
161
+ return Q(
162
+ ge.FmTooltip,
163
+ { zIndex: 50 },
164
+ {
165
+ default() {
166
+ return Q("div", { class: "flex flex-col w-full" }, [
167
+ Q(
168
+ "div",
169
+ { class: "line-clamp-1 fm-typo-en-body-lg-400 text-fm-color-typo-primary" },
170
+ f
171
+ ),
172
+ Q(
173
+ "div",
174
+ {
175
+ class: "line-clamp-1 fm-typo-en-body-md-400 text-fm-color-typo-secondary"
176
+ },
177
+ n
178
+ )
179
+ ]);
180
+ },
181
+ content() {
182
+ return f;
183
+ }
184
+ }
185
+ );
186
+ }
187
+ },
188
+ {
189
+ id: "Amount",
190
+ header: () => g("inventory.transfer.form.items.table.Amount"),
191
+ minSize: 200,
192
+ cell(m) {
193
+ var r, u, w, $, c;
194
+ const e = m.row.original, n = (r = p.forecastAmounts) == null ? void 0 : r.find((y) => y.skuId === e.sku._id), f = n ? n.helperState === "error" ? `Predicted: ${n.amount} (out of range)` : `Predicted: ${n.amount}` : void 0, s = ($ = (w = (u = p.template) == null ? void 0 : u.purchaseOrder) == null ? void 0 : w.items) == null ? void 0 : $.find(
195
+ (y) => y.sku._id === e.sku._id
196
+ );
197
+ return Q(cs, {
198
+ style: {
199
+ flex: "1 1 0%"
200
+ },
201
+ modelValue: {
202
+ amount: e.quantity ?? { amount: 1, precision: 0 },
203
+ measurement: e.measurement ?? null
204
+ },
205
+ key: e.sku._id,
206
+ unit: e.sku.unit,
207
+ helperText: f,
208
+ helperState: n == null ? void 0 : n.helperState,
209
+ "onUpdate:modelValue": (y) => {
210
+ if (!y) return;
211
+ const F = {
212
+ ...e,
213
+ quantity: y.amount,
214
+ measurement: y.measurement
215
+ };
216
+ if (b.enableTotalCost) {
217
+ const { cost: B } = Te(
218
+ F.sku,
219
+ F.quantity,
220
+ F.measurement,
221
+ {
222
+ supplier: p.supplier,
223
+ // NOTE: set undefined here if `manualTotalCost[updatedRow.sku._id] = false`, so that the function
224
+ // will return the auto calculated default cost instead of the manual total cost
225
+ manualTotalCost: i[F.sku._id] ? F.totalCost : void 0
226
+ }
227
+ );
228
+ F.totalCost = B;
229
+ }
230
+ p.updateItem(F);
231
+ },
232
+ stepper: s == null ? void 0 : s.quantityStep,
233
+ disableUnit: !!s,
234
+ disabled: p.disabled,
235
+ rules: [
236
+ ms(
237
+ +we(
238
+ ((c = e.quantity) == null ? void 0 : c.amount) === 0 ? { amount: 0, precision: 0 } : (s == null ? void 0 : s.minimumQuantity) ?? { amount: 0, precision: 0 }
239
+ )
240
+ ),
241
+ ps(
242
+ s != null && s.maximumQuantity ? +we(s == null ? void 0 : s.maximumQuantity) : 1 / 0
243
+ ),
244
+ ...s != null && s.quantityStep ? [fs(s.quantityStep)] : []
245
+ ],
246
+ applyDefaultRules: !0
247
+ });
248
+ },
249
+ enableSorting: !1
250
+ },
251
+ {
252
+ id: "Cost",
253
+ header: Vs,
254
+ size: 180,
255
+ cell(m) {
256
+ const e = m.row.original, n = h(e.sku), f = d.value.xs || d.value.sm;
257
+ if (!i[e.sku._id] && n) {
258
+ const { cost: s, supplierOverrideCost: r } = Te(
259
+ e.sku,
260
+ e.quantity,
261
+ e.measurement,
262
+ {
263
+ supplier: p.supplier
264
+ }
265
+ );
266
+ return Q(
267
+ "div",
268
+ {
269
+ class: [
270
+ "flex gap-4 fm-typo-en-body-md-400 items-center",
271
+ p.disabled ? "text-fm-color-typo-disabled" : ""
272
+ ],
273
+ key: e.sku._id
274
+ },
275
+ [
276
+ Q(ge.FmButton, {
277
+ prependIcon: "edit",
278
+ variant: us.Tertiary,
279
+ disabled: p.disabled,
280
+ onClick() {
281
+ p.updateItem({
282
+ ...e,
283
+ totalCost: s
284
+ }), i[e.sku._id] = !0;
285
+ }
286
+ }),
287
+ Q(
288
+ "div",
289
+ {
290
+ class: "flex flex-col"
291
+ },
292
+ [
293
+ Q(
294
+ "span",
295
+ f ? Ze(s) : we(s)
296
+ ),
297
+ Q(
298
+ "span",
299
+ {
300
+ class: [
301
+ "fm-typo-en-body-sm-400",
302
+ p.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-neutral-gray-400"
303
+ ]
304
+ },
305
+ g("inventory.transfer.form.items.autoCalculated")
306
+ ),
307
+ r ? Q(
308
+ "span",
309
+ {
310
+ class: [
311
+ "fm-typo-en-body-sm-400",
312
+ p.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-neutral-gray-400"
313
+ ]
314
+ },
315
+ [
316
+ Ze(r.costPerUnit),
317
+ "/",
318
+ r.measurement ? Q(
319
+ "span",
320
+ { class: "text-blue-500 font-semibold" },
321
+ r.measurement.abbrev
322
+ ) : Q("span", { class: "text-green-500 font-bold" }, e.sku.unit.abbrev)
323
+ // base unit style
324
+ ]
325
+ ) : null
326
+ ]
327
+ )
328
+ ]
329
+ );
330
+ }
331
+ return Q(
332
+ ge.FmTextField,
333
+ {
334
+ modelValue: we(e.totalCost ?? { amount: 0, precision: 0 }),
335
+ key: e.sku._id,
336
+ "onUpdate:modelValue": (s) => {
337
+ p.updateItem({
338
+ ...e,
339
+ totalCost: {
340
+ ...ts(+s),
341
+ currency: zt()
342
+ }
343
+ });
344
+ },
345
+ rules: [Xe(0), ss(2)]
346
+ },
347
+ {
348
+ prepend() {
349
+ return f ? Q(
350
+ "div",
351
+ {
352
+ class: [
353
+ "text-fm-typo-en-body-lg-400",
354
+ p.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-typo-primary"
355
+ ]
356
+ },
357
+ Dt()
358
+ ) : null;
359
+ },
360
+ append() {
361
+ return n ? Q(ge.FmButton, {
362
+ prependIcon: "close",
363
+ variant: "tertiary",
364
+ disabled: p.disabled,
365
+ onClick() {
366
+ const { cost: s } = Te(
367
+ e.sku,
368
+ e.quantity,
369
+ e.measurement,
370
+ {
371
+ supplier: p.supplier
372
+ }
373
+ );
374
+ p.updateItem({
375
+ ...e,
376
+ // NOTE: different from PO template, if a default cost is reenabled,
377
+ // the total cost will automatically assigned
378
+ totalCost: s
379
+ }), i[e.sku._id] = !1;
380
+ }
381
+ }) : null;
382
+ }
383
+ }
384
+ );
385
+ },
386
+ enableSorting: !1
387
+ },
388
+ {
389
+ id: "Delete",
390
+ header: "",
391
+ cell(m) {
392
+ const e = m.row.original;
393
+ return Q("div", { class: "flex justify-end" }, [
394
+ Q(ge.FmButton, {
395
+ key: e.sku._id,
396
+ class: "delete-button",
397
+ type: "button",
398
+ icon: "delete",
399
+ variant: "tertiary",
400
+ size: "md",
401
+ disabled: p.disabled,
402
+ onClick: () => {
403
+ p.deleteItem(e);
404
+ }
405
+ })
406
+ ]);
407
+ },
408
+ enableSorting: !1,
409
+ size: 40,
410
+ meta: {
411
+ cellClass: "",
412
+ headerClass: ""
413
+ }
414
+ }
415
+ ];
416
+ return {
417
+ columnDefs: M(() => b.enableTotalCost && p.transferType === pe.enum.purchase ? x : x.filter(
418
+ (m) => m.id !== "Cost"
419
+ /* Cost */
420
+ ))
421
+ };
422
+ }
423
+ const Rs = { class: "flex flex-col gap-8 px-16 xs:px-4 sm:px-4 py-4 items-center" }, Os = { class: "fm-typo-en-body-lg-600 xs:fm-typo-en-body-md-600 mr-auto xs:w-full" }, As = { class: "w-[450px] xs:w-full flex" }, Es = { class: "fm-typo-en-body-md-400 whitespace-nowrap" }, Ms = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Ot = /* @__PURE__ */ de({
424
+ __name: "SupplierPriceHistory",
425
+ props: {
426
+ prices: {}
427
+ },
428
+ setup(p) {
429
+ const g = ut();
430
+ function i(d) {
431
+ return g.suppliers.find((b) => b._id === d);
432
+ }
433
+ return (d, b) => (k(), T("div", Rs, [
434
+ (k(!0), T(re, null, xe(Object.keys(d.prices), (o) => {
435
+ var h;
436
+ return k(), T("div", {
437
+ key: o,
438
+ class: "flex items-center gap-12 xs:gap-4 xs:flex-wrap w-full"
439
+ }, [
440
+ l("div", Os, E((h = i(o)) == null ? void 0 : h.name), 1),
441
+ l("div", As, [
442
+ (k(!0), T(re, null, xe(d.prices[o].slice(0, 3), (x) => {
443
+ var I;
444
+ return k(), T("div", {
445
+ key: x.date,
446
+ class: "flex flex-col w-[150px] xs:flex-1 text-ellipsis cursor-pointer"
447
+ }, [
448
+ l("div", Es, [
449
+ l("span", null, E(x.totalCost ? t(Ze)(x.totalCost) : "No data"), 1),
450
+ b[0] || (b[0] = l("span", { class: "text-fm-color-typo-secondary" }, "/", -1)),
451
+ l("span", null, E(t(we)(x.totalUnit, !1)), 1),
452
+ l("span", null, E(((I = x.measurement) == null ? void 0 : I.abbrev) ?? x.unit.abbrev), 1)
453
+ ]),
454
+ l("div", Ms, [
455
+ l("span", null, "(#" + E(x.seqNumber) + ")", 1),
456
+ b[1] || (b[1] = l("span", null, E(" "), -1)),
457
+ l("span", null, E(t(dt)(new Date(x.date))), 1)
458
+ ])
459
+ ]);
460
+ }), 128))
461
+ ])
462
+ ]);
463
+ }), 128))
464
+ ]));
465
+ }
466
+ }), qs = { class: "flex flex-col gap-8 py-16" }, Us = { class: "flex items-center" }, Ns = { class: "flex-1 flex gap-1 items-center" }, Bs = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, zs = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, Ls = { class: "flex gap-8 w-full" }, Hs = { class: "flex-1 flex flex-col gap-4" }, js = { class: "flex-1 flex flex-col gap-4" }, Qs = { class: "flex gap-8 w-full" }, Ys = { class: "flex-1 flex flex-col gap-4" }, Ks = {
467
+ key: 0,
468
+ class: "flex-1 flex flex-col gap-4"
469
+ }, Xs = /* @__PURE__ */ de({
470
+ __name: "TransferItem",
471
+ props: {
472
+ cellByColId: {},
473
+ comparePriceBySku: {},
474
+ showComparePrice: { type: Boolean },
475
+ row: {}
476
+ },
477
+ setup(p) {
478
+ const { t: g } = he();
479
+ return (i, d) => {
480
+ var h, x, I, m, e, n, f, s, r, u, w, $, c, y, F, B, z, Z, X, N, P, R, D, q, L, W, ae;
481
+ const b = V("FmLabel"), o = V("FmSpacer");
482
+ return k(), T("div", qs, [
483
+ l("div", Us, [
484
+ l("div", Ns, [
485
+ l("span", Bs, " (" + E(i.row.original.sku.code) + ") ", 1),
486
+ l("span", zs, E(i.row.original.sku.name), 1)
487
+ ]),
488
+ l("div", null, [
489
+ v(t(ve), {
490
+ render: (I = (x = (h = i.cellByColId.Delete) == null ? void 0 : h.column) == null ? void 0 : x.columnDef) == null ? void 0 : I.cell,
491
+ props: (e = (m = i.cellByColId.Delete) == null ? void 0 : m.getContext) == null ? void 0 : e.call(m)
492
+ }, null, 8, ["render", "props"])
493
+ ])
494
+ ]),
495
+ l("div", Ls, [
496
+ l("div", Hs, [
497
+ v(b, {
498
+ label: t(g)(`inventory.transfer.form.items.table.${t(te).Code}`)
499
+ }, null, 8, ["label"]),
500
+ v(t(ve), {
501
+ render: (s = (f = (n = i.cellByColId[t(te).Code]) == null ? void 0 : n.column) == null ? void 0 : f.columnDef) == null ? void 0 : s.cell,
502
+ props: (u = (r = i.cellByColId[t(te).Code]) == null ? void 0 : r.getContext) == null ? void 0 : u.call(r)
503
+ }, null, 8, ["render", "props"]),
504
+ d[0] || (d[0] = l("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
505
+ ]),
506
+ l("div", js, [
507
+ v(b, {
508
+ label: t(g)(`inventory.transfer.form.items.table.${t(te).Name}`)
509
+ }, null, 8, ["label"]),
510
+ v(t(ve), {
511
+ render: (c = ($ = (w = i.cellByColId[t(te).Name]) == null ? void 0 : w.column) == null ? void 0 : $.columnDef) == null ? void 0 : c.cell,
512
+ props: (F = (y = i.cellByColId[t(te).Name]) == null ? void 0 : y.getContext) == null ? void 0 : F.call(y)
513
+ }, null, 8, ["render", "props"]),
514
+ d[1] || (d[1] = l("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
515
+ ])
516
+ ]),
517
+ l("div", Qs, [
518
+ l("div", Ys, [
519
+ v(b, {
520
+ label: t(g)(`inventory.transfer.form.items.table.${t(te).Amount}`)
521
+ }, null, 8, ["label"]),
522
+ v(t(ve), {
523
+ render: (Z = (z = (B = i.cellByColId[t(te).Amount]) == null ? void 0 : B.column) == null ? void 0 : z.columnDef) == null ? void 0 : Z.cell,
524
+ props: (N = (X = i.cellByColId[t(te).Amount]) == null ? void 0 : X.getContext) == null ? void 0 : N.call(X)
525
+ }, null, 8, ["render", "props"]),
526
+ d[2] || (d[2] = l("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
527
+ ]),
528
+ i.cellByColId[t(te).Cost] ? (k(), T("div", Ks, [
529
+ v(Tt, { "z-index": 50 }, {
530
+ default: A(() => [
531
+ v(b, {
532
+ label: t(g)(`inventory.transfer.form.items.table.${t(te).Cost}2`)
533
+ }, null, 8, ["label"])
534
+ ]),
535
+ _: 1
536
+ }),
537
+ v(t(ve), {
538
+ render: (D = (R = (P = i.cellByColId[t(te).Cost]) == null ? void 0 : P.column) == null ? void 0 : R.columnDef) == null ? void 0 : D.cell,
539
+ props: (L = (q = i.cellByColId[t(te).Cost]) == null ? void 0 : q.getContext) == null ? void 0 : L.call(q)
540
+ }, null, 8, ["render", "props"]),
541
+ d[3] || (d[3] = l("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
542
+ ])) : K("", !0)
543
+ ]),
544
+ i.showComparePrice && Object.keys(i.comparePriceBySku[(W = i.row.original.sku) == null ? void 0 : W._id] ?? {}).length > 0 ? (k(), T(re, { key: 0 }, [
545
+ v(o, { class: "h-8" }),
546
+ v(Ot, {
547
+ prices: i.comparePriceBySku[(ae = i.row.original.sku) == null ? void 0 : ae._id]
548
+ }, null, 8, ["prices"])
549
+ ], 64)) : K("", !0)
550
+ ]);
551
+ };
552
+ }
553
+ });
554
+ function Zs(p) {
555
+ const g = M({
556
+ get() {
557
+ const o = p.getEffectiveAt();
558
+ return o ? new Date(o) : null;
559
+ },
560
+ set(o) {
561
+ p.setEffectiveAt((o == null ? void 0 : o.toISOString()) ?? null);
562
+ }
563
+ }), i = M({
564
+ get() {
565
+ return !!g.value;
566
+ },
567
+ set(o) {
568
+ o ? g.value = /* @__PURE__ */ new Date() : g.value = null;
569
+ }
570
+ }), d = M({
571
+ get() {
572
+ return g.value === null ? "" : dt(g.value);
573
+ },
574
+ set(o) {
575
+ o ? g.value = /* @__PURE__ */ new Date(`${o} ${b.value}`) : g.value = null;
576
+ }
577
+ }), b = M({
578
+ get() {
579
+ return g.value === null ? "" : hs(g.value);
580
+ },
581
+ set(o) {
582
+ o ? g.value = /* @__PURE__ */ new Date(`${d.value} ${o}`) : g.value = null;
583
+ }
584
+ });
585
+ return {
586
+ backdatePo: g,
587
+ backdateSwitch: i,
588
+ backdateModel: d,
589
+ backdateTimeModel: b
590
+ };
591
+ }
592
+ const Ws = {
593
+ width: "24",
594
+ height: "24",
595
+ viewBox: "0 0 24 24",
596
+ fill: "none",
597
+ xmlns: "http://www.w3.org/2000/svg"
598
+ }, Js = ["fill"], Gs = ["fill"], ea = ["stroke"], ta = ["stroke"], sa = /* @__PURE__ */ de({
599
+ __name: "SparkIcon",
600
+ props: {
601
+ size: {
602
+ type: Number,
603
+ default: 24
604
+ },
605
+ color: {
606
+ type: String,
607
+ default: "#c7c7cc"
608
+ }
609
+ },
610
+ setup(p) {
611
+ return (g, i) => (k(), T("svg", Ws, [
612
+ l("path", {
613
+ d: "M7.6 7.6C8.17076 6.94229 8.5 5.5 8.5 5.5C8.5 5.5 8.81356 6.87361 9.35714 7.5C9.92948 8.15953 11.5 8.5 11.5 8.5C11.5 8.5 9.92948 8.69761 9.35714 9.35714C8.81356 9.98354 8.5 11.5 8.5 11.5C8.5 11.5 8.32076 10.1888 7.75 9.59091C7.14905 8.96136 5.5 8.5 5.5 8.5C5.5 8.5 6.99905 8.29251 7.6 7.6Z",
614
+ fill: p.color
615
+ }, null, 8, Js),
616
+ l("path", {
617
+ d: "M12.2 12.2C13.3415 10.8846 14 8 14 8C14 8 14.6271 10.7472 15.7143 12C16.859 13.3191 20 14 20 14C20 14 16.859 14.3952 15.7143 15.7143C14.6271 16.9671 14 20 14 20C14 20 13.6415 17.3777 12.5 16.1818C11.2981 14.9227 8 14 8 14C8 14 10.9981 13.585 12.2 12.2Z",
618
+ fill: p.color
619
+ }, null, 8, Gs),
620
+ l("path", {
621
+ d: "M7.6 7.6C8.17076 6.94229 8.5 5.5 8.5 5.5C8.5 5.5 8.81356 6.87361 9.35714 7.5C9.92948 8.15953 11.5 8.5 11.5 8.5C11.5 8.5 9.92948 8.69761 9.35714 9.35714C8.81356 9.98354 8.5 11.5 8.5 11.5C8.5 11.5 8.32076 10.1888 7.75 9.59091C7.14905 8.96136 5.5 8.5 5.5 8.5C5.5 8.5 6.99905 8.29251 7.6 7.6Z",
622
+ stroke: p.color,
623
+ "stroke-width": "1.5",
624
+ "stroke-linecap": "round",
625
+ "stroke-linejoin": "round"
626
+ }, null, 8, ea),
627
+ l("path", {
628
+ d: "M12.2 12.2C13.3415 10.8846 14 8 14 8C14 8 14.6271 10.7472 15.7143 12C16.859 13.3191 20 14 20 14C20 14 16.859 14.3952 15.7143 15.7143C14.6271 16.9671 14 20 14 20C14 20 13.6415 17.3777 12.5 16.1818C11.2981 14.9227 8 14 8 14C8 14 10.9981 13.585 12.2 12.2Z",
629
+ stroke: p.color,
630
+ "stroke-width": "1.5",
631
+ "stroke-linecap": "round",
632
+ "stroke-linejoin": "round"
633
+ }, null, 8, ta)
634
+ ]));
635
+ }
636
+ }), aa = { class: "flex gap-8 items-center" }, oa = { class: "fm-typo-en-body-lg-600 line-clamp-1" }, na = { class: "w-[343px] px-24 py-16 rounded-lg shadow-light-300 flex flex-col gap-[20px]" }, la = { class: "flex items-center w-full" }, ra = { class: "flex-1" }, ia = { class: "fm-typo-en-title-sm-800" }, ua = { class: "flex items-start gap-8" }, da = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, ca = { class: "flex gap-1" }, ma = /* @__PURE__ */ de({
637
+ __name: "ForecastStock",
638
+ props: {
639
+ templateId: {},
640
+ disabled: { type: Boolean },
641
+ poItems: {},
642
+ templateItems: {}
643
+ },
644
+ emits: ["update:poItems", "update:forecastAmounts"],
645
+ setup(p, { emit: g }) {
646
+ const i = p, d = g, b = U(!1), o = U(7), h = as(), x = Re(), { t: I } = he();
647
+ function m(s, r, u) {
648
+ return r != null && s < r && (s = r), u != null && s > u && (s = u), s;
649
+ }
650
+ function e(s) {
651
+ if (!((s == null ? void 0 : s.amount) == null || (s == null ? void 0 : s.precision) == null))
652
+ return s.amount / Math.pow(10, s.precision);
653
+ }
654
+ function n({
655
+ sku: s,
656
+ code: r,
657
+ name: u,
658
+ baseAmount: w,
659
+ measurement: $,
660
+ min: c,
661
+ max: y
662
+ }) {
663
+ if ($) {
664
+ const F = $.conversion.amount;
665
+ let B = Math.ceil(w / F);
666
+ return B = m(B, c, y), {
667
+ sku: s,
668
+ code: r,
669
+ name: u,
670
+ quantity: { amount: B, precision: 0 },
671
+ measurement: $
672
+ };
673
+ } else {
674
+ const F = Math.ceil(m(w, c, y));
675
+ return {
676
+ sku: s,
677
+ code: r,
678
+ name: u,
679
+ quantity: { amount: F, precision: 0 },
680
+ measurement: null
681
+ };
682
+ }
683
+ }
684
+ async function f() {
685
+ const s = lt(1, 8)(String(o.value));
686
+ if (typeof s == "string") {
687
+ x.open({
688
+ message: s,
689
+ type: "error"
690
+ });
691
+ return;
692
+ }
693
+ b.value = !1, await h.readPurchaseOrder(o.value, i.templateId);
694
+ const r = h.purchaseOrderForecast.skus;
695
+ if (r.length === 0) {
696
+ x.open({
697
+ message: I("inventory.transfer.form.items.forecastStock.notAvailable"),
698
+ type: "info"
699
+ });
700
+ return;
701
+ }
702
+ const u = i.templateItems.reduce(($, c) => {
703
+ var z;
704
+ const y = (z = i.poItems) == null ? void 0 : z.find((Z) => Z.sku._id === c.sku._id), F = r.find((Z) => Z.id === c.sku._id);
705
+ if (!F)
706
+ return y && $.push(y), $;
707
+ if (!i.templateId && F.amount <= 0) return $;
708
+ const B = F.amount ?? e(y == null ? void 0 : y.quantity) ?? 0;
709
+ return $.push(
710
+ n({
711
+ sku: c.sku,
712
+ code: c.code,
713
+ name: c.name,
714
+ baseAmount: B,
715
+ measurement: c.measurement || null,
716
+ min: e(c.minimumQuantity),
717
+ max: e(c.maximumQuantity)
718
+ })
719
+ ), $;
720
+ }, []), w = r.map(($) => {
721
+ const c = i.templateItems.find((X) => X.sku._id === $.id);
722
+ let y = $.amount, F = 0;
723
+ if (c != null && c.measurement) {
724
+ const X = e(c.measurement.conversion) ?? 1;
725
+ y = Math.ceil($.amount / X);
726
+ } else
727
+ y = Math.ceil($.amount);
728
+ const B = e(c == null ? void 0 : c.minimumQuantity) ?? 0, z = e(c == null ? void 0 : c.maximumQuantity) ?? 1 / 0, Z = y < B || y > z ? "error" : "success";
729
+ return { skuId: $.id, amount: y, precision: F, helperState: Z };
730
+ });
731
+ d("update:poItems", u), d("update:forecastAmounts", w);
732
+ }
733
+ return (s, r) => {
734
+ const u = V("FmButton"), w = V("FmIcon"), $ = V("FmStepperField"), c = V("FmPopover");
735
+ return k(), se(c, {
736
+ disabled: s.disabled,
737
+ class: "flex",
738
+ "show-popover": b.value,
739
+ onPopoverChanged: r[3] || (r[3] = (y) => b.value = y)
740
+ }, {
741
+ "popover-button": A(() => [
742
+ v(u, {
743
+ label: "unused",
744
+ variant: "secondary",
745
+ "text-color": s.disabled ? "disabled" : "primary",
746
+ "bg-color": "transparent",
747
+ "border-color": s.disabled ? "disabled" : "primary",
748
+ disabled: s.disabled
749
+ }, {
750
+ default: A(() => [
751
+ l("div", aa, [
752
+ v(sa, {
753
+ size: 24,
754
+ color: s.disabled ? "#c7c7cc" : "#ff7823"
755
+ }, null, 8, ["color"]),
756
+ l("div", oa, E(t(I)("inventory.transfer.form.items.forecastStock.title")), 1)
757
+ ])
758
+ ]),
759
+ _: 1
760
+ }, 8, ["text-color", "border-color", "disabled"])
761
+ ]),
762
+ default: A(() => [
763
+ l("div", na, [
764
+ l("div", la, [
765
+ l("div", ra, [
766
+ v(Cs, { "z-index": 99 }, {
767
+ default: A(() => [
768
+ l("p", ia, E(t(I)("inventory.transfer.form.items.forecastStock.title")), 1)
769
+ ]),
770
+ _: 1
771
+ })
772
+ ]),
773
+ v(u, {
774
+ icon: "close",
775
+ size: "md",
776
+ variant: "tertiary",
777
+ onClick: r[0] || (r[0] = (y) => b.value = !1)
778
+ })
779
+ ]),
780
+ v($, {
781
+ modelValue: o.value,
782
+ "onUpdate:modelValue": r[1] || (r[1] = (y) => o.value = y),
783
+ label: t(I)("inventory.transfer.form.items.forecastStock.days"),
784
+ rules: [t(lt)(1, 8)]
785
+ }, {
786
+ "helper-text": A(() => [
787
+ l("div", ua, [
788
+ v(w, {
789
+ name: "warning",
790
+ size: "sm",
791
+ class: "text-fm-color-system-warning-300"
792
+ }),
793
+ l("div", da, E(t(I)("inventory.transfer.form.items.forecastStock.replace")), 1)
794
+ ])
795
+ ]),
796
+ _: 1
797
+ }, 8, ["modelValue", "label", "rules"]),
798
+ l("div", ca, [
799
+ r[4] || (r[4] = l("div", { class: "grow" }, null, -1)),
800
+ v(u, {
801
+ label: t(I)("common.cancel"),
802
+ variant: "tertiary",
803
+ onClick: r[2] || (r[2] = (y) => b.value = !1)
804
+ }, null, 8, ["label"]),
805
+ v(u, {
806
+ label: t(I)("inventory.transfer.form.items.forecastStock.generate"),
807
+ onClick: f
808
+ }, null, 8, ["label"])
809
+ ])
810
+ ])
811
+ ]),
812
+ _: 1
813
+ }, 8, ["disabled", "show-popover"]);
814
+ };
815
+ }
816
+ });
817
+ function pa() {
818
+ const p = Re(), g = ct(), i = U(!1);
819
+ _e(i, (h) => {
820
+ h && (b.value = !0, d().finally(() => {
821
+ b.value = !1;
822
+ }));
823
+ });
824
+ async function d() {
825
+ try {
826
+ const { startDate: h, endDate: x } = ks(6), e = (await g.getPurchaseOrders({ start: h, end: x })).filter(
827
+ (n) => {
828
+ var f, s;
829
+ return n.status === Lt.enum.COMPLETE && ((f = n.supplier) == null ? void 0 : f.internal) !== "warehouse" && ((s = n.supplier) == null ? void 0 : s.internal) !== "restaurant";
830
+ }
831
+ ).reduce((n, f) => {
832
+ const s = new Date(Ht(f._id)), r = f.supplier._id;
833
+ for (const u of f.items) {
834
+ if (!u.totalCost) continue;
835
+ const w = n[u.sku._id] ?? {}, $ = w[r] ?? [];
836
+ $.push({
837
+ date: s.toISOString(),
838
+ totalUnit: u.quantity,
839
+ totalCost: u.totalCost,
840
+ unit: u.sku.unit,
841
+ measurement: u.measurement,
842
+ seqNumber: f.seqNumber
843
+ }), w[r] = $, n[u.sku._id] = w;
844
+ }
845
+ return n;
846
+ }, {});
847
+ o.value = e;
848
+ } catch {
849
+ p.open({
850
+ title: "Something went wrong",
851
+ message: "Cannot retrieve supplier purchase history. Please try again."
852
+ }), i.value = !1;
853
+ }
854
+ }
855
+ const b = U(!1), o = U({});
856
+ return {
857
+ comparePricesToggle: i,
858
+ comparePriceFetching: b,
859
+ comparePriceBySku: o
860
+ };
861
+ }
862
+ const fa = { class: "fm-typo-body-md-400 line-clamp-2 w-full" }, va = { key: 0 }, ya = ["colspan"], ba = /* @__PURE__ */ de({
863
+ __name: "TransferItemTable",
864
+ props: {
865
+ templateItem: {},
866
+ row: {},
867
+ comparePriceBySku: {},
868
+ showComparePrice: { type: Boolean },
869
+ disabled: { type: Boolean }
870
+ },
871
+ emits: ["update:item"],
872
+ setup(p) {
873
+ function g(i) {
874
+ return i.column.columnDef.meta;
875
+ }
876
+ return (i, d) => {
877
+ var b, o;
878
+ return k(), T(re, null, [
879
+ l("tr", {
880
+ class: J(["border-b border-fm-color-neutral-gray-100 hover:bg-fm-color-opacity-sm", {
881
+ "bg-fm-color-neutral-gray-100": i.row.getIsSelected()
882
+ }])
883
+ }, [
884
+ (k(!0), T(re, null, xe(i.row.getVisibleCells(), (h) => {
885
+ var x, I, m, e;
886
+ return k(), T("td", {
887
+ key: h.id,
888
+ class: J(["h-[56px] text-fm-color-typo-primary", ((x = g(h)) == null ? void 0 : x.cellClass) ?? "px-16"]),
889
+ style: $t({
890
+ width: (I = g(h)) == null ? void 0 : I.width,
891
+ maxWidth: (m = g(h)) == null ? void 0 : m.maxWidth,
892
+ textAlign: ((e = g(h)) == null ? void 0 : e.textAlign) ?? "left"
893
+ })
894
+ }, [
895
+ l("span", fa, [
896
+ v(t(ve), {
897
+ render: h.column.columnDef.cell,
898
+ props: h.getContext()
899
+ }, null, 8, ["render", "props"])
900
+ ])
901
+ ], 6);
902
+ }), 128))
903
+ ], 2),
904
+ i.showComparePrice && Object.keys(i.comparePriceBySku[(b = i.row.original.sku) == null ? void 0 : b._id] ?? {}).length > 0 ? (k(), T("tr", va, [
905
+ l("td", {
906
+ colspan: i.row.getVisibleCells().length
907
+ }, [
908
+ v(Ot, {
909
+ prices: i.comparePriceBySku[(o = i.row.original.sku) == null ? void 0 : o._id]
910
+ }, null, 8, ["prices"])
911
+ ], 8, ya)
912
+ ])) : K("", !0)
913
+ ], 64);
914
+ };
915
+ }
916
+ }), ga = {
917
+ key: 0,
918
+ class: "flex flex-col gap-8"
919
+ }, _a = { class: "flex flex-col gap-4" }, ha = { class: "flex items-center gap-4" }, ka = {
920
+ key: 0,
921
+ class: "fm-typo-en-body-sm-400 text-fm-color-typo-error"
922
+ }, xa = /* @__PURE__ */ de({
923
+ __name: "NetSuiteField",
924
+ props: {
925
+ required: { type: Boolean },
926
+ disabled: { type: Boolean },
927
+ subsidiaryOptional: { type: Boolean },
928
+ supplier: {},
929
+ setting: {},
930
+ items: {},
931
+ onChange: { type: Function }
932
+ },
933
+ emits: ["netsuite:ready"],
934
+ setup(p, { emit: g }) {
935
+ const i = Ne(), d = p, b = g, { t: o } = Ss(), h = U(!1), x = U();
936
+ function I() {
937
+ var s, r, u, w;
938
+ if (!d.supplier) return;
939
+ d.supplier.internal ? x.value = i.getNetSuiteLocation(
940
+ `${d.supplier.internal}_${d.supplier._id}`
941
+ ) : x.value = i.getNetSuiteVendor(d.supplier._id);
942
+ const n = d.supplier.internal ? i.getLocationSubsidiary((s = x.value) == null ? void 0 : s.netSuiteId).id : (r = x.value) == null ? void 0 : r.subsidiaryId, f = d.supplier.internal ? (u = i.currentLocationSubsidiary()) == null ? void 0 : u.id : (w = i.currentVendorSubsidiary(d.supplier._id)) == null ? void 0 : w.id;
943
+ h.value = !(!i.isEnabled || n && i.isEnabled && n == f);
944
+ }
945
+ _e(
946
+ () => d.supplier,
947
+ () => {
948
+ d.subsidiaryOptional && I();
949
+ },
950
+ { deep: !0 }
951
+ ), We(() => {
952
+ let n = {
953
+ id: "",
954
+ subsidiary: { id: "", name: "" },
955
+ errors: []
956
+ };
957
+ if (i.isReady) {
958
+ if (!i.isEnabled || !d.required) {
959
+ b("netsuite:ready", n);
960
+ return;
961
+ }
962
+ try {
963
+ const f = i.currentLocationSubsidiary();
964
+ d.setting ? n = {
965
+ ...d.setting,
966
+ subsidiary: {
967
+ id: f.id || "",
968
+ name: f.name
969
+ }
970
+ } : n = {
971
+ ...n,
972
+ subsidiary: {
973
+ id: f.id || "",
974
+ name: f.name
975
+ }
976
+ };
977
+ const s = i.getAvailableItems(f.id), r = d.items.filter((u) => {
978
+ if (u.measurement != null) {
979
+ const w = i.getAvailableMeasurements(
980
+ u.sku._id,
981
+ f.id
982
+ );
983
+ return s.includes(u.sku._id) && w.includes(u.measurement.id);
984
+ }
985
+ return s.includes(u.sku._id);
986
+ }).map((u) => u.sku._id);
987
+ d.onChange(
988
+ d.items.filter((u) => r.includes(u.sku._id)),
989
+ n
990
+ );
991
+ } finally {
992
+ I(), h.value ? d.subsidiaryOptional && b("netsuite:ready", n) : b("netsuite:ready", n);
993
+ }
994
+ }
995
+ });
996
+ const m = M(
997
+ () => d.supplier.internal ? i.currentLocationSubsidiary() : i.currentVendorSubsidiary(d.supplier._id)
998
+ ), e = M(() => {
999
+ var n, f;
1000
+ return x.value == null ? `Cannot find the NetSuite location for "${d.supplier.name}"` : `The subsidiary of the request
1001
+ location is ${(f = i.getLocationSubsidiary((n = x.value) == null ? void 0 : n.netSuiteId)) == null ? void 0 : f.fullName}`;
1002
+ });
1003
+ return (n, f) => {
1004
+ const s = V("FmLabel"), r = V("FmIcon"), u = V("FmField"), w = V("FmTooltip");
1005
+ return t(i).isEnabled && d.required ? (k(), T("div", ga, [
1006
+ v(s, {
1007
+ label: `NetSuite ${t(o)("inventory.transfer.form.netsuite.subsidiary")}`
1008
+ }, null, 8, ["label"]),
1009
+ l("div", _a, [
1010
+ v(w, {
1011
+ "z-index": 51,
1012
+ placement: "left",
1013
+ disabled: n.disabled
1014
+ }, {
1015
+ content: A(() => f[0] || (f[0] = [
1016
+ Pe("This field is locked and based on the location of the request.")
1017
+ ])),
1018
+ default: A(() => [
1019
+ v(u, null, {
1020
+ default: A(() => {
1021
+ var $;
1022
+ return [
1023
+ l("div", ha, [
1024
+ v(r, {
1025
+ name: "lock_outline",
1026
+ size: "sm",
1027
+ color: n.disabled ? "neutral-gray-200" : "neutral-gray-400"
1028
+ }, null, 8, ["color"]),
1029
+ l("div", {
1030
+ class: J([n.disabled ? "text-fm-color-typo-disabled" : ""])
1031
+ }, E(($ = m.value) == null ? void 0 : $.fullName), 3)
1032
+ ])
1033
+ ];
1034
+ }),
1035
+ _: 1
1036
+ })
1037
+ ]),
1038
+ _: 1
1039
+ }, 8, ["disabled"]),
1040
+ h.value ? (k(), T("div", ka, E(e.value), 1)) : K("", !0)
1041
+ ])
1042
+ ])) : K("", !0);
1043
+ };
1044
+ }
1045
+ });
1046
+ function Ve(p) {
1047
+ const g = At(p);
1048
+ if (Array.isArray(g))
1049
+ return g.map(Ve);
1050
+ if (g !== null && typeof g == "object") {
1051
+ const i = {};
1052
+ for (const d in g)
1053
+ Object.prototype.hasOwnProperty.call(g, d) && (i[d] = Ve(g[d]));
1054
+ return i;
1055
+ }
1056
+ return g;
1057
+ }
1058
+ const ot = {
1059
+ set: "set",
1060
+ add: "add",
1061
+ delete: "delete"
1062
+ };
1063
+ function Ct(p) {
1064
+ return {
1065
+ dbName: p.dbName,
1066
+ type: p.type,
1067
+ name: p.name,
1068
+ acceptRequest: p.acceptRequest ?? !1,
1069
+ doc: p.doc
1070
+ };
1071
+ }
1072
+ function St(p, g, i) {
1073
+ const d = Ve(p.suppliers ?? []), b = Ve(g.allLocations ?? []).map(Ct), o = g._currentLocation ? Ct(Ve(g._currentLocation)) : null, h = i.inventory ? [Ve(i.inventory)] : [];
1074
+ return {
1075
+ suppliers: d,
1076
+ locations: b,
1077
+ currentLocation: o,
1078
+ inventoryDoc: h
1079
+ };
1080
+ }
1081
+ function Ca() {
1082
+ const p = ut(), g = Je(), i = Ge(), d = St(p, g, i), b = _t(vs({ env: d }));
1083
+ b.value.setUsePartialUpdates(!0);
1084
+ const o = _t(b.value.state()), h = (e) => {
1085
+ o.value = e;
1086
+ };
1087
+ b.value.addListener(h);
1088
+ const x = (e, n, f) => {
1089
+ switch (e) {
1090
+ case ot.set:
1091
+ ht(o.value, n, f);
1092
+ break;
1093
+ case ot.add:
1094
+ Qt(o.value, n, f);
1095
+ break;
1096
+ case ot.delete:
1097
+ jt(o.value, n);
1098
+ break;
1099
+ default:
1100
+ console.warn(`Unknown partial update operation: ${e}, falling back to 'set'`), ht(o.value, n, f);
1101
+ }
1102
+ n !== "remark" && n !== "ref" && Mt(o);
1103
+ };
1104
+ b.value.addPartialListener(x);
1105
+ function I() {
1106
+ const e = St(p, g, i);
1107
+ b.value.updateFullEnv(e), o.value = b.value.state();
1108
+ }
1109
+ _e(
1110
+ [
1111
+ () => p.suppliers,
1112
+ () => g.allLocations,
1113
+ () => g._currentLocation,
1114
+ () => i.inventory
1115
+ ],
1116
+ () => {
1117
+ I();
1118
+ },
1119
+ { deep: !0 }
1120
+ ), Et(() => {
1121
+ b.value.removeListener(h), b.value.removePartialListener(x);
1122
+ });
1123
+ function m(e) {
1124
+ var n;
1125
+ if (e != null && e._id) {
1126
+ b.value.loadPurchaseOrder(e);
1127
+ return;
1128
+ }
1129
+ if (!et().mustUsePoTemplate) {
1130
+ b.value.init();
1131
+ return;
1132
+ }
1133
+ e != null && e.template && ((n = e.templateDoc) != null && n.purchaseOrder) ? (e.items = e.templateDoc.purchaseOrder.items, b.value.initFromTemplate(e)) : b.value.initOutletToOutlet();
1134
+ }
1135
+ return {
1136
+ controller: b,
1137
+ state: o,
1138
+ init: m
1139
+ };
1140
+ }
1141
+ const Sa = { class: "flex flex-col gap-4" }, wa = { class: "flex items-center gap-8 overflow-x-auto pb-12" }, Fa = { class: "flex flex-col gap-16" }, Ia = { class: "flex flex-col gap-24" }, $a = { class: "flex flex-col gap-8" }, Da = { class: "flex flex-col gap-4" }, Ta = { class: "flex items-center gap-4" }, Va = { class: "flex flex-col gap-8" }, Pa = { class: "flex flex-col gap-4" }, Ra = { class: "flex items-center gap-4" }, Oa = {
1142
+ key: 3,
1143
+ class: "p-16 border border-fm-color-neutral-gray-300 fm-corner-radius-md flex flex-col"
1144
+ }, Aa = {
1145
+ key: 0,
1146
+ class: "flex-1 flex gap-8 h-48 xs:flex-col xs:pt-16 sm:flex-col sm:pt-16"
1147
+ }, Ea = { class: "flex-1" }, Ma = { class: "flex-1" }, qa = {
1148
+ key: 1,
1149
+ class: "flex items-center gap-4"
1150
+ }, Ua = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary translate-y-[1px]" }, Na = { class: "flex flex-col gap-16" }, Ba = { class: "flex-1 gap-8 fm-typo-en-title-sm-600" }, za = { class: "flex gap-8" }, La = { key: 0 }, Ha = /* @__PURE__ */ de({
1151
+ __name: "TransferFormWithController",
1152
+ props: {
1153
+ modelValue: {},
1154
+ request: {},
1155
+ disabled: { type: Boolean },
1156
+ suppliers: {},
1157
+ skus: {},
1158
+ lastClosingDate: {}
1159
+ },
1160
+ emits: ["validation-success", "form:ready"],
1161
+ setup(p, { expose: g, emit: i }) {
1162
+ const d = p, b = i, { t: o } = he(), h = Je(), x = Ge(), I = Ne(), m = et(), e = Rt(), { breakpoints: n } = it(), f = M(() => n.value.xs || n.value.sm), s = Ca();
1163
+ s.init(d.modelValue);
1164
+ const { controller: r, state: u } = s, w = It({
1165
+ value: !1
1166
+ }), $ = U(!1), c = U(0), y = U([]), F = M(
1167
+ () => {
1168
+ var a;
1169
+ return ((a = d.modelValue) == null ? void 0 : a.templateDoc) ?? e.templates.find((_) => {
1170
+ var Y;
1171
+ return _._id === ((Y = d.modelValue) == null ? void 0 : Y.template);
1172
+ });
1173
+ }
1174
+ ), B = M(() => u.value.status === "DRAFT" || !u.value.rev), z = M(
1175
+ () => {
1176
+ var a;
1177
+ return ((a = u.value.items) == null ? void 0 : a.map((_) => _.item)) || [];
1178
+ }
1179
+ );
1180
+ We(() => {
1181
+ var a, _, Y, le;
1182
+ try {
1183
+ I.isEnabled && I.businessSubsidiaryId && !((_ = (a = u.value.netSuite) == null ? void 0 : a.subsidiary) != null && _.id) && r.value.setNetSuiteSetting({
1184
+ ...u.value.netSuite,
1185
+ id: ((Y = u.value.netSuite) == null ? void 0 : Y.id) ?? "",
1186
+ subsidiary: {
1187
+ id: I.businessSubsidiaryId,
1188
+ name: I.businessSubsidiaryName ?? ""
1189
+ },
1190
+ errors: ((le = u.value.netSuite) == null ? void 0 : le.errors) ?? []
1191
+ });
1192
+ } finally {
1193
+ $.value = !0;
1194
+ }
1195
+ }), _e([$, w], ([a, _], [Y, le]) => {
1196
+ _.value && le.value && b("form:ready");
1197
+ });
1198
+ const Z = M(
1199
+ () => h.currentLocation.type === Yt.restaurant
1200
+ ), X = ds(), N = bs(
1201
+ () => u.value,
1202
+ (a) => {
1203
+ r.value.setSupplier(a.supplier);
1204
+ },
1205
+ !0,
1206
+ !m.businessSupplierOnly
1207
+ ), P = M({
1208
+ get() {
1209
+ var a;
1210
+ return typeof ((a = u.value.supplier) == null ? void 0 : a.internal) == "string" ? pe.enum.transfer : pe.enum.purchase;
1211
+ },
1212
+ set(a) {
1213
+ r.value.selectType(a);
1214
+ }
1215
+ }), R = M(() => {
1216
+ let a = N.transferLocationOptions.value;
1217
+ return m.mustUsePoTemplate && !u.value.template && (a = a.filter((_) => {
1218
+ var Y;
1219
+ return (Y = _.sublabel) == null ? void 0 : Y.startsWith("restaurant");
1220
+ })), a;
1221
+ }), D = M({
1222
+ get() {
1223
+ var a;
1224
+ return (a = u.value.supplier) == null ? void 0 : a._id;
1225
+ },
1226
+ set(a) {
1227
+ N.transferLocationModel.value = a;
1228
+ }
1229
+ }), q = M({
1230
+ get() {
1231
+ return u.value.remark ?? "";
1232
+ },
1233
+ set(a) {
1234
+ r.value.addRemark(a ?? "");
1235
+ }
1236
+ }), L = M({
1237
+ get() {
1238
+ return u.value.ref ?? "";
1239
+ },
1240
+ set(a) {
1241
+ r.value.addReference(a ?? "");
1242
+ }
1243
+ }), { backdatePo: W, backdateSwitch: ae, backdateModel: S, backdateTimeModel: C } = Zs({
1244
+ getEffectiveAt() {
1245
+ return u.value.effectiveAt;
1246
+ },
1247
+ setEffectiveAt(a) {
1248
+ r.value.setEffectiveAt(a);
1249
+ }
1250
+ }), { comparePricesToggle: H, comparePriceFetching: fe, comparePriceBySku: ce } = pa(), G = U();
1251
+ g({
1252
+ validateInputs: () => {
1253
+ var a, _;
1254
+ (_ = (a = G.value) == null ? void 0 : a.validateInputs) == null || _.call(a);
1255
+ },
1256
+ resetInputsValidation: () => {
1257
+ var a, _;
1258
+ (_ = (a = G.value) == null ? void 0 : a.resetInputsValidation) == null || _.call(a);
1259
+ },
1260
+ resetInputs: () => {
1261
+ var a, _;
1262
+ (_ = (a = G.value) == null ? void 0 : a.resetInputs) == null || _.call(a);
1263
+ },
1264
+ getFormData: () => u.value.id && u.value.rev ? r.value.toUpdateData() : r.value.toCreateData()
1265
+ });
1266
+ const Fe = M(() => ({
1267
+ updateItem: (a) => {
1268
+ const _ = Kt.parse(a), Y = r.value.toFdtoPOItem(_);
1269
+ r.value.updateSkuInfo(Y);
1270
+ },
1271
+ deleteItem: (a) => {
1272
+ r.value.removeSku(a.sku);
1273
+ }
1274
+ })), Ie = Ps({
1275
+ updateItem: (a) => Fe.value.updateItem(a),
1276
+ deleteItem: (a) => Fe.value.deleteItem(a),
1277
+ get supplier() {
1278
+ return u.value.supplier;
1279
+ },
1280
+ get items() {
1281
+ return z.value;
1282
+ },
1283
+ get transferType() {
1284
+ return P.value;
1285
+ },
1286
+ get template() {
1287
+ return F.value;
1288
+ },
1289
+ get disabled() {
1290
+ return d.disabled;
1291
+ },
1292
+ get forecastAmounts() {
1293
+ return y.value;
1294
+ }
1295
+ }), Be = M(() => Ie.columnDefs.value);
1296
+ function ze() {
1297
+ var Ae, je, Qe, Ee, Ye;
1298
+ const a = (Qe = (je = (Ae = F.value) == null ? void 0 : Ae.purchaseOrder) == null ? void 0 : je.items) == null ? void 0 : Qe.groupBy((j) => j.sku._id), _ = I.isEnabled ? I.getAvailableItems((Ye = (Ee = u.value.netSuite) == null ? void 0 : Ee.subsidiary) == null ? void 0 : Ye.id) : [], Y = a != null && a.size ? x.skus.filter((j) => a.has(j._id)) : x.skus, le = I.isEnabled ? Y.filter((j) => {
1299
+ var ie, oe, ue, me;
1300
+ const ee = (oe = (ie = F.value) == null ? void 0 : ie.purchaseOrder) == null ? void 0 : oe.items.find(
1301
+ (be) => be.sku._id === j._id
1302
+ );
1303
+ if (ee != null && ee.measurement != null) {
1304
+ const be = I.getAvailableMeasurements(
1305
+ ee.sku._id,
1306
+ (me = (ue = u.value.netSuite) == null ? void 0 : ue.subsidiary) == null ? void 0 : me.id
1307
+ );
1308
+ return _.includes(ee.sku._id) && be.includes(ee.measurement.id);
1309
+ }
1310
+ return _.includes(j._id);
1311
+ }).map((j) => j._id) : Y.map((j) => j._id), ye = Y.map(
1312
+ (j) => {
1313
+ var ee, ie, oe, ue;
1314
+ return {
1315
+ label: ((ie = (ee = a == null ? void 0 : a.get(j._id)) == null ? void 0 : ee[0]) == null ? void 0 : ie.name) ?? j.name,
1316
+ sublabel: ((ue = (oe = a == null ? void 0 : a.get(j._id)) == null ? void 0 : oe[0]) == null ? void 0 : ue.code) ?? j.code,
1317
+ value: j,
1318
+ disabled: !!(!le.includes(j._id) || j.isInactive),
1319
+ tags: j.isInactive ? ["Inactive"] : ["Active"]
1320
+ };
1321
+ }
1322
+ ), $e = ye.filter((j) => {
1323
+ var ee;
1324
+ return (ee = z.value) == null ? void 0 : ee.find((ie) => ie.sku._id === j.value._id);
1325
+ }).map((j) => j.value), He = [
1326
+ {
1327
+ type: "string",
1328
+ key: "tags",
1329
+ entity: "item",
1330
+ values: ["Inactive", "Active"]
1331
+ }
1332
+ ];
1333
+ X.open({
1334
+ title: o("inventory.transfer.form.items.selectItem"),
1335
+ closeButton: !0,
1336
+ contentComponent: _s,
1337
+ contentComponentProps: {
1338
+ modelValue: $e,
1339
+ items: ye,
1340
+ virtualScroll: !0,
1341
+ filterAttributes: He
1342
+ },
1343
+ primaryActions: {
1344
+ text: o("common.confirm"),
1345
+ close: !0
1346
+ },
1347
+ secondaryActions: {
1348
+ text: o("common.close"),
1349
+ close: !0,
1350
+ variant: "tertiary"
1351
+ }
1352
+ }).onPrimary((j) => {
1353
+ const ee = z.value ?? [], ie = j.map((oe) => {
1354
+ var be, De;
1355
+ const ue = ee.find((ke) => ke.sku._id === oe._id);
1356
+ if (ue)
1357
+ return ue;
1358
+ const me = ((De = (be = F.value) == null ? void 0 : be.purchaseOrder.items) == null ? void 0 : De.find(
1359
+ (ke) => ke.sku._id === oe._id
1360
+ )) ?? {
1361
+ sku: oe,
1362
+ code: oe.code,
1363
+ name: oe.name,
1364
+ quantity: {
1365
+ amount: 1,
1366
+ precision: 0
1367
+ }
1368
+ };
1369
+ if (P.value == pe.enum.purchase) {
1370
+ const { cost: ke } = Te(
1371
+ me.sku,
1372
+ me.quantity,
1373
+ me.measurement,
1374
+ {
1375
+ supplier: u.value.supplier
1376
+ }
1377
+ );
1378
+ me.totalCost = ke;
1379
+ }
1380
+ return me;
1381
+ });
1382
+ ie.sort((oe, ue) => oe.sku.code.localeCompare(ue.sku.code)), r.value.updateItems(ie);
1383
+ });
1384
+ }
1385
+ function tt(a) {
1386
+ return a;
1387
+ }
1388
+ const Le = M(() => {
1389
+ var a;
1390
+ return F.value ? ((a = F.value) == null ? void 0 : a.purchaseOrder.items) || [] : x.skus.map((_) => ({
1391
+ quantity: {
1392
+ amount: 0,
1393
+ precision: 0
1394
+ },
1395
+ name: _.name,
1396
+ code: _.code,
1397
+ sku: _,
1398
+ quantityStep: {
1399
+ amount: 0,
1400
+ precision: 0
1401
+ },
1402
+ measurement: _.trackingMeasurement ? _.unit.measurements.find((Y) => Y.id === _.trackingMeasurement) : null
1403
+ }));
1404
+ }), Ce = M(() => {
1405
+ const a = [];
1406
+ return (!m.mustUsePoTemplate || m.mustUsePoTemplate && u.value.template) && a.push({
1407
+ label: o("inventory.transfer.form.type.purchase"),
1408
+ value: pe.enum.purchase
1409
+ }), a.push({
1410
+ label: o("inventory.transfer.form.type.transfer"),
1411
+ value: pe.enum.transfer
1412
+ }), a;
1413
+ }), Oe = M(
1414
+ () => {
1415
+ var a;
1416
+ return ((a = u.value.items) == null ? void 0 : a.every((_) => _.item.quantity.amount <= 0)) ?? !0;
1417
+ }
1418
+ );
1419
+ return (a, _) => {
1420
+ var me, be;
1421
+ const Y = V("FmChip"), le = V("FmLabel"), ye = V("FmIcon"), $e = V("FmField"), He = V("FmTooltip"), Ae = V("FmSelect"), je = V("FmTextField"), Qe = V("FmTextarea"), Ee = V("FmSwitch"), Ye = V("FmDatePicker"), j = V("FmTimePicker"), ee = V("FmFormGroup"), ie = V("FmButton"), oe = V("FmTable"), ue = V("FmForm");
1422
+ return k(), T("div", Sa, [
1423
+ l("div", wa, [
1424
+ (me = d.modelValue) != null && me.template ? (k(), se(Y, {
1425
+ key: 0,
1426
+ variant: a.disabled ? "warning" : void 0,
1427
+ label: `${t(o)("inventory.transfer.template.title")}: ${((be = F.value) == null ? void 0 : be.name) ?? t(o)("inventory.transfer.form.loading")}`,
1428
+ icon: "summarize",
1429
+ compact: ""
1430
+ }, null, 8, ["variant", "label"])) : K("", !0),
1431
+ v(Y, {
1432
+ label: t(h).currentLocation.name,
1433
+ icon: "storefront",
1434
+ compact: ""
1435
+ }, null, 8, ["label"]),
1436
+ a.lastClosingDate ? (k(), se(Y, {
1437
+ key: 1,
1438
+ label: `${t(o)("inventory.transfer.form.lastClosing")}: ${t(dt)(a.lastClosingDate)} ${t(xs)(a.lastClosingDate)}`,
1439
+ icon: "calendar_month",
1440
+ compact: ""
1441
+ }, null, 8, ["label"])) : K("", !0)
1442
+ ]),
1443
+ v(ue, {
1444
+ ref_key: "formRef",
1445
+ ref: G,
1446
+ class: "flex flex-col gap-32",
1447
+ disabled: a.disabled,
1448
+ onValidationFailed: console.log,
1449
+ onValidationSuccess: _[14] || (_[14] = (De) => b("validation-success"))
1450
+ }, {
1451
+ default: A(() => {
1452
+ var De, ke, mt, pt, ft, vt, yt;
1453
+ return [
1454
+ l("div", Fa, [
1455
+ l("div", Ia, [
1456
+ (De = d.modelValue) != null && De.template ? (k(), T(re, { key: 0 }, [
1457
+ l("div", $a, [
1458
+ v(le, {
1459
+ label: t(o)("inventory.transfer.form.type.title")
1460
+ }, null, 8, ["label"]),
1461
+ l("div", Da, [
1462
+ v(He, {
1463
+ "z-index": 51,
1464
+ placement: "left",
1465
+ disabled: a.disabled
1466
+ }, {
1467
+ content: A(() => _[15] || (_[15] = [
1468
+ Pe("This field is locked from template.")
1469
+ ])),
1470
+ default: A(() => [
1471
+ v($e, null, {
1472
+ default: A(() => [
1473
+ l("div", Ta, [
1474
+ v(ye, {
1475
+ name: "lock_outline",
1476
+ size: "sm",
1477
+ color: a.disabled ? "neutral-gray-200" : "neutral-gray-400"
1478
+ }, null, 8, ["color"]),
1479
+ l("div", {
1480
+ class: J({ "text-fm-color-typo-disabled": a.disabled })
1481
+ }, E(t(o)(`inventory.transfer.form.type.${P.value.toLocaleLowerCase("en-us")}`)), 3)
1482
+ ])
1483
+ ]),
1484
+ _: 1
1485
+ })
1486
+ ]),
1487
+ _: 1
1488
+ }, 8, ["disabled"]),
1489
+ l("div", {
1490
+ class: J([
1491
+ "fm-typo-en-body-sm-400",
1492
+ a.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-typo-secondary"
1493
+ ])
1494
+ }, null, 2)
1495
+ ])
1496
+ ]),
1497
+ l("div", Va, [
1498
+ v(le, {
1499
+ label: P.value === t(pe).enum.purchase ? t(o)("inventory.transfer.form.purchaseFrom") : t(o)("inventory.transfer.form.transferFrom")
1500
+ }, null, 8, ["label"]),
1501
+ l("div", Pa, [
1502
+ v(He, {
1503
+ "z-index": 51,
1504
+ placement: "left",
1505
+ disabled: a.disabled
1506
+ }, {
1507
+ content: A(() => _[16] || (_[16] = [
1508
+ Pe("This field is locked from template.")
1509
+ ])),
1510
+ default: A(() => [
1511
+ v($e, null, {
1512
+ default: A(() => {
1513
+ var O;
1514
+ return [
1515
+ l("div", Ra, [
1516
+ v(ye, {
1517
+ name: "lock_outline",
1518
+ size: "sm",
1519
+ color: a.disabled ? "neutral-gray-200" : "neutral-gray-400"
1520
+ }, null, 8, ["color"]),
1521
+ l("div", {
1522
+ class: J({ "text-fm-color-typo-disabled": a.disabled })
1523
+ }, E((O = R.value.find((ne) => ne.value === D.value)) == null ? void 0 : O.label), 3)
1524
+ ])
1525
+ ];
1526
+ }),
1527
+ _: 1
1528
+ })
1529
+ ]),
1530
+ _: 1
1531
+ }, 8, ["disabled"])
1532
+ ])
1533
+ ])
1534
+ ], 64)) : (k(), T(re, { key: 1 }, [
1535
+ v(Ae, {
1536
+ label: t(o)("inventory.transfer.form.type.title"),
1537
+ "label-mark": "required",
1538
+ modelValue: P.value,
1539
+ "onUpdate:modelValue": _[0] || (_[0] = (O) => P.value = O),
1540
+ items: Ce.value,
1541
+ rules: [t(Xe)(1)(Ce.value)]
1542
+ }, {
1543
+ default: A(() => [
1544
+ l("span", {
1545
+ class: J([
1546
+ "line-clamp-1 fm-typo-en-body-lg-400",
1547
+ a.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-typo-primary"
1548
+ ])
1549
+ }, E(t(Xt)(P.value)), 3)
1550
+ ]),
1551
+ _: 1
1552
+ }, 8, ["label", "modelValue", "items", "rules"]),
1553
+ v(Ae, {
1554
+ label: P.value === t(pe).enum.purchase ? t(o)("inventory.transfer.form.purchaseFrom") : t(o)("inventory.transfer.form.transferFrom"),
1555
+ "label-mark": "required",
1556
+ modelValue: D.value,
1557
+ "onUpdate:modelValue": _[1] || (_[1] = (O) => D.value = O),
1558
+ items: R.value,
1559
+ rules: [t(Xe)(1)(R.value)]
1560
+ }, {
1561
+ "menu-wrapper": A((O) => {
1562
+ var ne, Me;
1563
+ return [
1564
+ v(gs, nt(O, {
1565
+ items: R.value,
1566
+ "model-value": (Me = (ne = a.modelValue) == null ? void 0 : ne.supplier) == null ? void 0 : Me._id
1567
+ }), null, 16, ["items", "model-value"])
1568
+ ];
1569
+ }),
1570
+ default: A(() => {
1571
+ var O;
1572
+ return [
1573
+ l("span", {
1574
+ class: J([
1575
+ "line-clamp-1 fm-typo-en-body-lg-400",
1576
+ a.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-typo-primary"
1577
+ ])
1578
+ }, E((O = R.value.find((ne) => ne.value === D.value)) == null ? void 0 : O.label), 3)
1579
+ ];
1580
+ }),
1581
+ _: 1
1582
+ }, 8, ["label", "modelValue", "items", "rules"])
1583
+ ], 64)),
1584
+ v(je, {
1585
+ label: t(o)("inventory.transfer.form.reference"),
1586
+ "label-mark": "optional",
1587
+ modelValue: L.value,
1588
+ "onUpdate:modelValue": _[2] || (_[2] = (O) => L.value = O)
1589
+ }, null, 8, ["label", "modelValue"]),
1590
+ v(Qe, {
1591
+ label: t(o)("inventory.transfer.form.remark"),
1592
+ "label-mark": "optional",
1593
+ "max-length": 240,
1594
+ modelValue: q.value,
1595
+ "onUpdate:modelValue": _[3] || (_[3] = (O) => q.value = O),
1596
+ class: J([a.disabled ? "text-fm-color-typo-disabled " : ""])
1597
+ }, null, 8, ["label", "modelValue", "class"]),
1598
+ $.value ? (k(), se(xa, {
1599
+ key: 2,
1600
+ required: t(u).template != null || t(u).netSuite != null,
1601
+ subsidiaryOptional: t(u).template == null,
1602
+ disabled: a.disabled,
1603
+ supplier: t(u).supplier,
1604
+ setting: t(u).netSuite,
1605
+ items: z.value,
1606
+ onChange: (O, ne) => {
1607
+ t(r).updateItems(O), t(r).setNetSuiteSetting(ne);
1608
+ },
1609
+ "onNetsuite:ready": _[4] || (_[4] = (O) => {
1610
+ w.value = !0;
1611
+ })
1612
+ }, null, 8, ["required", "subsidiaryOptional", "disabled", "supplier", "setting", "items", "onChange"])) : K("", !0),
1613
+ t(m).enableBackdatePo ? (k(), T("div", Oa, [
1614
+ l("div", {
1615
+ class: J([
1616
+ "flex",
1617
+ {
1618
+ "flex-col": f.value
1619
+ }
1620
+ ])
1621
+ }, [
1622
+ v(Ee, {
1623
+ modelValue: t(ae),
1624
+ "onUpdate:modelValue": _[5] || (_[5] = (O) => Se(ae) ? ae.value = O : null),
1625
+ label: t(o)("inventory.transfer.form.backdate.title"),
1626
+ sublabel: t(o)("inventory.transfer.form.backdate.subtitle"),
1627
+ "label-placement": "right",
1628
+ disabled: Z.value && !a.lastClosingDate || a.disabled
1629
+ }, null, 8, ["modelValue", "label", "sublabel", "disabled"]),
1630
+ l("div", {
1631
+ class: J({ hidden: f.value, "w-16": !f.value })
1632
+ }, null, 2),
1633
+ t(ae) ? (k(), T("div", Aa, [
1634
+ l("div", Ea, [
1635
+ v(Ye, {
1636
+ modelValue: t(S),
1637
+ "onUpdate:modelValue": _[6] || (_[6] = (O) => Se(S) ? S.value = O : null)
1638
+ }, null, 8, ["modelValue"])
1639
+ ]),
1640
+ l("div", Ma, [
1641
+ v(j, {
1642
+ modelValue: t(C),
1643
+ "onUpdate:modelValue": _[7] || (_[7] = (O) => Se(C) ? C.value = O : null)
1644
+ }, null, 8, ["modelValue"])
1645
+ ])
1646
+ ])) : K("", !0)
1647
+ ], 2),
1648
+ t(W) ? (k(), se(ee, {
1649
+ key: 0,
1650
+ modelValue: t(W),
1651
+ "onUpdate:modelValue": _[8] || (_[8] = (O) => Se(W) ? W.value = O : null),
1652
+ rules: [t(lt)(new Date(a.lastClosingDate), /* @__PURE__ */ new Date())]
1653
+ }, null, 8, ["modelValue", "rules"])) : K("", !0),
1654
+ Z.value && !a.lastClosingDate ? (k(), T("div", qa, [
1655
+ v(ye, {
1656
+ name: "error",
1657
+ size: "sm",
1658
+ class: "text-fm-color-typo-warning"
1659
+ }),
1660
+ l("span", Ua, E(t(o)("inventory.transfer.form.backdate.error")), 1)
1661
+ ])) : K("", !0)
1662
+ ])) : K("", !0)
1663
+ ])
1664
+ ]),
1665
+ l("div", Na, [
1666
+ v(ee, {
1667
+ "model-value": z.value,
1668
+ rules: [t(Xe)(1)]
1669
+ }, null, 8, ["model-value", "rules"]),
1670
+ l("div", {
1671
+ class: J([
1672
+ "flex gap-16",
1673
+ {
1674
+ "flex-col items-start": f.value,
1675
+ "items-center": !f.value
1676
+ }
1677
+ ])
1678
+ }, [
1679
+ l("div", Ba, E(t(o)("inventory.transfer.form.items.title")), 1),
1680
+ l("div", za, [
1681
+ v(ie, {
1682
+ disabled: a.disabled,
1683
+ label: t(o)("inventory.transfer.form.items.addItem"),
1684
+ "prepend-icon": "add",
1685
+ variant: "secondary",
1686
+ "text-color": "primary",
1687
+ "bg-color": "transparent",
1688
+ "border-color": "primary",
1689
+ onClick: _[9] || (_[9] = (O) => ze()),
1690
+ size: "md"
1691
+ }, null, 8, ["disabled", "label"]),
1692
+ v(ma, {
1693
+ "template-id": t(u).template || void 0,
1694
+ "template-items": Le.value,
1695
+ "po-items": z.value,
1696
+ "onUpdate:forecastAmounts": _[10] || (_[10] = (O) => {
1697
+ y.value = O;
1698
+ }),
1699
+ "onUpdate:poItems": _[11] || (_[11] = (O) => {
1700
+ t(r).updateItems(O), c.value++;
1701
+ })
1702
+ }, null, 8, ["template-id", "template-items", "po-items"])
1703
+ ])
1704
+ ], 2),
1705
+ P.value === t(pe).enum.purchase && B.value && t(m).enableTotalCost && z.value.length ? (k(), T("div", La, [
1706
+ v(Ee, {
1707
+ label: t(fe) ? t(o)("inventory.transfer.form.items.fetchingData") : t(o)("inventory.transfer.form.items.comparePriceHistory"),
1708
+ "prepend-icon": "compare_arrows",
1709
+ "label-placement": "right",
1710
+ "model-value": t(H),
1711
+ "onUpdate:modelValue": _[12] || (_[12] = (O) => Se(H) ? H.value = O : null),
1712
+ disabled: t(fe) || a.disabled
1713
+ }, null, 8, ["label", "model-value", "disabled"])
1714
+ ])) : K("", !0),
1715
+ v(ee, {
1716
+ "model-value": Oe.value,
1717
+ rules: [() => Oe.value ? "Must have at least one non-zero item" : !0]
1718
+ }, null, 8, ["model-value", "rules"]),
1719
+ (k(), se(oe, {
1720
+ "column-defs": Be.value,
1721
+ "column-visibility": {
1722
+ [t(te).Code]: !(((ke = a.modelValue) == null ? void 0 : ke.template) ?? ((mt = a.modelValue) == null ? void 0 : mt.templateDoc)),
1723
+ [t(te).Name]: !(((pt = a.modelValue) == null ? void 0 : pt.template) ?? ((ft = a.modelValue) == null ? void 0 : ft.templateDoc)),
1724
+ [t(te).TemplateName]: !!(((vt = a.modelValue) == null ? void 0 : vt.template) ?? ((yt = a.modelValue) == null ? void 0 : yt.templateDoc))
1725
+ },
1726
+ "row-data": z.value,
1727
+ key: c.value,
1728
+ "hide-footer": "",
1729
+ "page-size": z.value.length
1730
+ }, {
1731
+ "table-row": A((O) => {
1732
+ var ne, Me, bt, gt;
1733
+ return [
1734
+ v(ba, {
1735
+ "compare-price-by-sku": t(ce),
1736
+ "show-compare-price": P.value === t(pe).enum.purchase && t(H),
1737
+ row: O,
1738
+ "template-item": (gt = (bt = (Me = (ne = a.modelValue) == null ? void 0 : ne.templateDoc) == null ? void 0 : Me.purchaseOrder) == null ? void 0 : bt.items) == null ? void 0 : gt.find(
1739
+ (st) => st.sku._id === O.original.sku._id
1740
+ ),
1741
+ "onUpdate:item": _[13] || (_[13] = (st) => Fe.value.updateItem(st)),
1742
+ disabled: a.disabled
1743
+ }, null, 8, ["compare-price-by-sku", "show-compare-price", "row", "template-item", "disabled"])
1744
+ ];
1745
+ }),
1746
+ "list-row": A((O) => [
1747
+ (k(), se(Pt, {
1748
+ row: O,
1749
+ key: z.value.map((ne) => ne.sku._id).join(".")
1750
+ }, {
1751
+ default: A((ne) => [
1752
+ v(Xs, {
1753
+ "compare-price-by-sku": t(ce),
1754
+ "show-compare-price": P.value === t(pe).enum.purchase && t(H),
1755
+ row: O,
1756
+ "cell-by-col-id": ne
1757
+ }, null, 8, ["compare-price-by-sku", "show-compare-price", "row", "cell-by-col-id"])
1758
+ ]),
1759
+ _: 2
1760
+ }, 1032, ["row"]))
1761
+ ]),
1762
+ _: 1
1763
+ }, 8, ["column-defs", "column-visibility", "row-data", "page-size"]))
1764
+ ])
1765
+ ];
1766
+ }),
1767
+ _: 1
1768
+ }, 8, ["disabled", "onValidationFailed"])
1769
+ ]);
1770
+ };
1771
+ }
1772
+ }), ja = { class: "flex items-center" }, Qa = { class: "fm-typo-en-title-md-800" }, Ya = { class: "flex gap-4" }, Ka = { class: "fm-typo-en-title-md-600" }, Xa = { class: "flex flex-col gap-16" }, Za = { class: "fm-typo-en-body-md-400" }, Wa = { class: "max-h-[300px] overflow-y-auto" }, Ja = { class: "list-disc pl-16" }, Ga = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, eo = { class: "flex w-full gap-8 justify-end" }, to = /* @__PURE__ */ de({
1773
+ __name: "TransferDialog",
1774
+ props: {
1775
+ mode: {},
1776
+ modelValue: {},
1777
+ templateId: {},
1778
+ show: { type: Boolean },
1779
+ lastClosingDate: {}
1780
+ },
1781
+ emits: ["update:show", "submitted"],
1782
+ setup(p, { expose: g, emit: i }) {
1783
+ var ae;
1784
+ const d = p, b = i, o = ct(), h = Rt(), x = Re(), I = ut(), m = Ge(), e = Je(), { t: n } = he(), f = U(!1), s = U(!1), r = U(!1), u = U(!1), w = M(() => {
1785
+ var S;
1786
+ return ((S = F.value.items) == null ? void 0 : S.filter((C) => C.quantity.amount === 0)) ?? [];
1787
+ });
1788
+ async function $(S) {
1789
+ if (S) {
1790
+ s.value = !1;
1791
+ try {
1792
+ await I.readSuppliers(), s.value = !0;
1793
+ } catch {
1794
+ x.open({
1795
+ title: n("inventory.transfer.form.unableToFetchListOfSuppliers.title"),
1796
+ message: n("inventory.transfer.form.unableToFetchListOfSuppliers.message"),
1797
+ type: "error"
1798
+ });
1799
+ }
1800
+ }
1801
+ }
1802
+ e.watchLocation($);
1803
+ function c() {
1804
+ return {
1805
+ remark: void 0,
1806
+ ref: void 0,
1807
+ stockSnapshotId: void 0,
1808
+ effectiveAt: void 0,
1809
+ items: [],
1810
+ supplier: {
1811
+ _rev: void 0,
1812
+ email: void 0,
1813
+ internal: void 0,
1814
+ contactName: void 0,
1815
+ phoneNumber: void 0,
1816
+ registrationNumber: void 0,
1817
+ supplyItems: void 0,
1818
+ _id: "",
1819
+ name: "",
1820
+ address: {
1821
+ line2: void 0,
1822
+ line1: "",
1823
+ state: "",
1824
+ city: "",
1825
+ postcode: "",
1826
+ country: ""
1827
+ }
1828
+ },
1829
+ status: "DRAFT",
1830
+ _id: "",
1831
+ seqNumber: 0,
1832
+ deliveryOrder: [],
1833
+ template: d.templateId,
1834
+ templateDoc: h.templates.find((C) => C._id === d.templateId)
1835
+ };
1836
+ }
1837
+ const y = Vt(d, "show"), F = U(d.modelValue ?? c()), B = U(((ae = d.modelValue) == null ? void 0 : ae._id) ?? `${Math.random()}`);
1838
+ _e(
1839
+ () => d.show,
1840
+ (S) => {
1841
+ var C;
1842
+ S && (r.value = !1, F.value = d.modelValue ?? c(), B.value = ((C = d.modelValue) == null ? void 0 : C._id) ?? `${Math.random()}`);
1843
+ }
1844
+ );
1845
+ const z = M(() => !s.value || !r.value), Z = M(() => {
1846
+ switch (d.mode) {
1847
+ case qe.READ:
1848
+ return "View transfer";
1849
+ case qe.CREATE:
1850
+ return n("inventory.transfer.receiveRequest.create.title");
1851
+ case qe.UPDATE:
1852
+ return n("inventory.transfer.receiveRequest.update.title");
1853
+ }
1854
+ return "";
1855
+ }), X = U();
1856
+ g({
1857
+ validateInputs: () => {
1858
+ var S, C;
1859
+ (C = (S = X.value) == null ? void 0 : S.validateInputs) == null || C.call(S);
1860
+ },
1861
+ resetInputsValidation: () => {
1862
+ var S, C;
1863
+ (C = (S = X.value) == null ? void 0 : S.resetInputsValidation) == null || C.call(S);
1864
+ },
1865
+ resetInputs: () => {
1866
+ var S, C;
1867
+ (C = (S = X.value) == null ? void 0 : S.resetInputs) == null || C.call(S);
1868
+ }
1869
+ });
1870
+ async function N() {
1871
+ const S = F.value;
1872
+ if (f.value = !0, S.items = S.items.filter((C) => C.quantity.amount > 0), !S.items.length) {
1873
+ x.open({
1874
+ title: "Cannot create order",
1875
+ message: "There are no items with non-zero amount in your request.",
1876
+ type: "error"
1877
+ });
1878
+ return;
1879
+ }
1880
+ (S.supplier.internal === "warehouse" || S.supplier.internal === "restaurant") && (S.items = S.items.map(({ totalCost: C, ...H }) => H));
1881
+ try {
1882
+ await o.createPurchaseOrder(S), await new Promise((C) => setTimeout(C, 1e3)), x.open({
1883
+ title: n("inventory.transfer.receiveRequest.create.success"),
1884
+ message: n("inventory.transfer.receiveRequest.create.successMessage"),
1885
+ type: "success"
1886
+ }), b("update:show", !1), b("submitted");
1887
+ } catch (C) {
1888
+ x.open({
1889
+ title: n("inventory.transfer.receiveRequest.create.error.title"),
1890
+ message: n("inventory.transfer.receiveRequest.create.error.message"),
1891
+ type: "error"
1892
+ }), console.error("Error in creating purchase order", C);
1893
+ } finally {
1894
+ f.value = !1;
1895
+ }
1896
+ }
1897
+ async function P() {
1898
+ const S = F.value;
1899
+ if (f.value = !0, S.items = S.items.filter((C) => C.quantity.amount > 0), !S.items.length) {
1900
+ x.open({
1901
+ title: "Cannot create order",
1902
+ message: "There are no items with non-zero amount in your request.",
1903
+ type: "error"
1904
+ });
1905
+ return;
1906
+ }
1907
+ (S.supplier.internal === "warehouse" || S.supplier.internal === "restaurant") && (S.items = S.items.map(({ totalCost: C, ...H }) => H));
1908
+ try {
1909
+ await o.updatePurchaseOrder(S), await new Promise((C) => setTimeout(C, 1e3)), x.open({
1910
+ title: n("inventory.transfer.receiveRequest.update.success"),
1911
+ message: n("inventory.transfer.receiveRequest.update.successMessage"),
1912
+ type: "success"
1913
+ }), b("update:show", !1), b("submitted");
1914
+ } catch (C) {
1915
+ x.open({
1916
+ title: n("inventory.transfer.receiveRequest.update.error.title"),
1917
+ message: n("inventory.transfer.receiveRequest.update.error.message"),
1918
+ type: "error"
1919
+ }), console.error("Error in updating purchase order", C);
1920
+ } finally {
1921
+ f.value = !1;
1922
+ }
1923
+ }
1924
+ function R() {
1925
+ switch (d.mode) {
1926
+ case qe.CREATE:
1927
+ return N();
1928
+ case qe.UPDATE:
1929
+ return P();
1930
+ }
1931
+ }
1932
+ function D() {
1933
+ var S;
1934
+ F.value.items = ((S = F.value.items) == null ? void 0 : S.filter((C) => C.quantity.amount > 0)) ?? [], u.value = !1, L();
1935
+ }
1936
+ function q() {
1937
+ X.value.getFormData && (F.value = {
1938
+ ...F.value,
1939
+ ...X.value.getFormData()
1940
+ });
1941
+ }
1942
+ function L() {
1943
+ var H, fe;
1944
+ const S = ys.validatePurchaseOrderItems({
1945
+ skusById: m.skuById ?? {},
1946
+ items: F.value.items ?? []
1947
+ }), C = Object.values(S).flat();
1948
+ if (C.length > 0) {
1949
+ const ce = C[0];
1950
+ x.open({
1951
+ title: `[Row ${ce.index + 1}] "${ce.poItem.sku.name}"`,
1952
+ message: `${ce.message}`,
1953
+ type: "error"
1954
+ });
1955
+ return;
1956
+ }
1957
+ (fe = (H = X.value) == null ? void 0 : H.validateInputs) == null || fe.call(H);
1958
+ }
1959
+ function W() {
1960
+ if (q(), w.value.length > 0) {
1961
+ u.value = !0;
1962
+ return;
1963
+ }
1964
+ L();
1965
+ }
1966
+ return (S, C) => {
1967
+ const H = V("FmButton"), fe = V("FmSideSheet"), ce = V("FmDialog");
1968
+ return k(), T(re, null, [
1969
+ v(fe, {
1970
+ modelValue: t(y),
1971
+ "onUpdate:modelValue": C[3] || (C[3] = (G) => Se(y) ? y.value = G : null),
1972
+ "dismiss-away": "",
1973
+ "close-button": "",
1974
+ "max-width": 900
1975
+ }, {
1976
+ "side-sheet-header": A(() => [
1977
+ l("div", ja, [
1978
+ l("div", Qa, E(Z.value), 1)
1979
+ ])
1980
+ ]),
1981
+ default: A(() => [
1982
+ (k(), se(Ha, {
1983
+ class: "w-full",
1984
+ ref_key: "formRef",
1985
+ ref: X,
1986
+ "onForm:ready": C[0] || (C[0] = () => r.value = !0),
1987
+ onValidationSuccess: R,
1988
+ modelValue: F.value,
1989
+ "onUpdate:modelValue": C[1] || (C[1] = (G) => F.value = G),
1990
+ disabled: f.value || z.value,
1991
+ suppliers: t(I).suppliers,
1992
+ skus: t(m).skus,
1993
+ key: B.value,
1994
+ "last-closing-date": S.lastClosingDate
1995
+ }, null, 8, ["modelValue", "disabled", "suppliers", "skus", "last-closing-date"]))
1996
+ ]),
1997
+ "side-sheet-footer": A(() => [
1998
+ l("div", Ya, [
1999
+ v(H, {
2000
+ loading: f.value,
2001
+ disabled: z.value,
2002
+ label: t(n)("common.save"),
2003
+ onClick: W
2004
+ }, null, 8, ["loading", "disabled", "label"]),
2005
+ v(H, {
2006
+ disabled: z.value,
2007
+ variant: "tertiary",
2008
+ label: t(n)("common.close"),
2009
+ onClick: C[2] || (C[2] = (G) => b("update:show", !1))
2010
+ }, null, 8, ["disabled", "label"])
2011
+ ])
2012
+ ]),
2013
+ _: 1
2014
+ }, 8, ["modelValue"]),
2015
+ v(ce, {
2016
+ modelValue: u.value,
2017
+ "onUpdate:modelValue": C[5] || (C[5] = (G) => u.value = G),
2018
+ overlay: !0
2019
+ }, {
2020
+ "dialog-header": A(() => [
2021
+ l("div", Ka, E(t(n)("inventory.transfer.template.zeroQuantity.title")), 1)
2022
+ ]),
2023
+ "dialog-footer": A(() => [
2024
+ l("div", eo, [
2025
+ v(H, {
2026
+ label: t(n)("common.cancel"),
2027
+ variant: "tertiary",
2028
+ onClick: C[4] || (C[4] = (G) => u.value = !1)
2029
+ }, null, 8, ["label"]),
2030
+ v(H, {
2031
+ label: t(n)("inventory.transfer.template.zeroQuantity.removeAll"),
2032
+ variant: "primary",
2033
+ "prepend-icon": "delete",
2034
+ onClick: D
2035
+ }, null, 8, ["label"])
2036
+ ])
2037
+ ]),
2038
+ default: A(() => [
2039
+ l("div", Xa, [
2040
+ l("div", Za, E(t(n)("inventory.transfer.template.zeroQuantity.message", { count: w.value.length })), 1),
2041
+ l("div", Wa, [
2042
+ l("ul", Ja, [
2043
+ (k(!0), T(re, null, xe(w.value, (G) => (k(), T("li", {
2044
+ key: G.sku._id,
2045
+ class: "fm-typo-en-body-md-400"
2046
+ }, E(G.sku.name) + " (" + E(G.sku.code) + ") ", 1))), 128))
2047
+ ])
2048
+ ]),
2049
+ l("div", Ga, E(t(n)("inventory.transfer.template.zeroQuantity.prompt")), 1)
2050
+ ])
2051
+ ]),
2052
+ _: 1
2053
+ }, 8, ["modelValue"])
2054
+ ], 64);
2055
+ };
2056
+ }
2057
+ });
2058
+ function so(p) {
2059
+ const [g, i, d, ...b] = ws(p), o = d.map((m) => m.toLowerCase().trim().replace(/ /g, "_")), x = ["item_name", "transfer_quantity(uom)", "uom", "scanned_code"].filter((m) => !o.includes(m));
2060
+ if (x.length)
2061
+ throw new Error(
2062
+ `Missing headers (${x.join()}). Excel file does not come from the template.`
2063
+ );
2064
+ return b.map((m, e) => {
2065
+ const n = {};
2066
+ for (const f in o) {
2067
+ const s = o[f];
2068
+ Object.assign(n, { [s]: m[f] });
2069
+ }
2070
+ return {
2071
+ index: e,
2072
+ data: n
2073
+ };
2074
+ });
2075
+ }
2076
+ function ao(p) {
2077
+ const g = p.SheetNames;
2078
+ try {
2079
+ return g.reduce(
2080
+ (d, b) => {
2081
+ const o = new Array(), h = p.Sheets[b], x = Ge(), I = so(h), m = [];
2082
+ for (const { index: n, data: f } of I) {
2083
+ f.scanned_code === "" && o.push(`Row ${n + 1}: Scanned code is empty`), f.item_name === "" && o.push(`Row ${n + 1}: Item name is empty`), f.uom === "" && o.push(`Row ${n + 1}: UOM is empty`), f["transfer_quantity(uom)"] === "" && o.push(`Row ${n + 1}: Transfer quantity is empty`);
2084
+ const s = x.skus.find((w) => w.code === f.scanned_code);
2085
+ if (!s) {
2086
+ o.push(`Row ${n + 1}: SKU not found`);
2087
+ continue;
2088
+ }
2089
+ const r = s.unit.abbrev === f.uom;
2090
+ let u = null;
2091
+ if (!r) {
2092
+ const w = s.unit.measurements.find(($) => $.abbrev === f.uom);
2093
+ if (!w) {
2094
+ o.push(`Row ${n + 1}: Measurement not found`);
2095
+ continue;
2096
+ }
2097
+ u = w;
2098
+ }
2099
+ m.push({
2100
+ sku: s,
2101
+ code: f.scanned_code,
2102
+ name: f.item_name,
2103
+ quantity: rt.fromNumber(Number(f["transfer_quantity(uom)"])),
2104
+ measurement: u
2105
+ });
2106
+ }
2107
+ const e = {
2108
+ type: "create",
2109
+ poItems: m,
2110
+ excelSheetName: b,
2111
+ errors: o
2112
+ };
2113
+ return d.importCreateResult.push(e), d;
2114
+ },
2115
+ {
2116
+ invalidExcel: !1,
2117
+ importCreateResult: new Array()
2118
+ }
2119
+ );
2120
+ } catch (i) {
2121
+ return {
2122
+ invalidExcel: !0,
2123
+ invalidExcelMessage: (i == null ? void 0 : i.message) ?? "Invalid excel",
2124
+ importCreateResult: []
2125
+ };
2126
+ }
2127
+ }
2128
+ const oo = { class: "flex flex-col flex-1" }, no = { class: "flex flex-col" }, lo = { class: "fm-typo-en-body-md-400 text-fm-color-typo-primary flex items-center gap-4" }, ro = {
2129
+ key: 0,
2130
+ class: "text-fm-color-typo-secondary fm-typo-en-body-sm-400"
2131
+ }, io = { key: 0 }, uo = {
2132
+ class: /* @__PURE__ */ J(["fm-typo-en-body-lg-600"])
2133
+ }, co = { class: "flex-1" }, mo = { class: "flex-auto line-clamp-2 text-ellipsis break-all fm-typo-en-body-sm-400" }, po = { class: "flex-auto line-clamp-2 text-ellipsis break-all" }, fo = { class: "text-fm-color-typo-primary" }, vo = { class: "ml-auto" }, yo = { key: 0 }, bo = /* @__PURE__ */ de({
2134
+ __name: "XilnexResult",
2135
+ props: {
2136
+ type: {},
2137
+ name: {},
2138
+ items: {},
2139
+ errors: {}
2140
+ },
2141
+ setup(p) {
2142
+ const g = p, { t: i } = he(), d = U(!1), b = () => {
2143
+ g.errors.length && (d.value = !d.value);
2144
+ };
2145
+ return (o, h) => {
2146
+ var m;
2147
+ const x = V("FmIcon"), I = V("FmTooltip");
2148
+ return k(), T("div", oo, [
2149
+ l("div", {
2150
+ onClick: b,
2151
+ class: J({
2152
+ "cursor-pointer": o.errors.length
2153
+ })
2154
+ }, [
2155
+ l("div", no, [
2156
+ l("div", lo, [
2157
+ l("div", {
2158
+ class: J({
2159
+ "text-fm-color-system-error-300": o.errors.length
2160
+ })
2161
+ }, [
2162
+ Pe(E(o.name) + " ", 1),
2163
+ o.type === "create" ? (k(), T("span", ro, "(" + E(t(i)("inventory.closing.template.import.new")) + ")", 1)) : K("", !0)
2164
+ ], 2),
2165
+ o.errors.length ? (k(), T("div", io, [
2166
+ v(x, {
2167
+ name: "error",
2168
+ size: "sm",
2169
+ color: "system-error-300"
2170
+ })
2171
+ ])) : K("", !0)
2172
+ ]),
2173
+ h[0] || (h[0] = l("hr", { class: "my-2" }, null, -1)),
2174
+ l("div", uo, [
2175
+ (m = o.items) != null && m.length ? (k(!0), T(re, { key: 0 }, xe(o.items, (e, n) => (k(), T("div", {
2176
+ key: n,
2177
+ class: "flex gap-4 mt-2 items-center"
2178
+ }, [
2179
+ l("div", co, [
2180
+ v(I, {
2181
+ content: e.code,
2182
+ placement: "top",
2183
+ "z-index": 51
2184
+ }, {
2185
+ default: A(() => [
2186
+ l("span", mo, E(e.code), 1)
2187
+ ]),
2188
+ _: 2
2189
+ }, 1032, ["content"]),
2190
+ v(I, {
2191
+ content: e.name,
2192
+ placement: "top",
2193
+ "z-index": 51
2194
+ }, {
2195
+ default: A(() => [
2196
+ l("span", po, E(e.name), 1)
2197
+ ]),
2198
+ _: 2
2199
+ }, 1032, ["content"])
2200
+ ]),
2201
+ l("div", null, [
2202
+ l("span", fo, E(t(rt).toFormatString({
2203
+ value: e.quantity
2204
+ })), 1),
2205
+ Pe(" " + E(e.measurement ? e.measurement.abbrev : e.sku.unit.abbrev), 1)
2206
+ ])
2207
+ ]))), 128)) : K("", !0)
2208
+ ])
2209
+ ]),
2210
+ l("div", vo, [
2211
+ o.errors.length ? (k(), se(x, {
2212
+ key: 0,
2213
+ name: d.value ? "keyboard_arrow_up" : "keyboard_arrow_down",
2214
+ size: "md"
2215
+ }, null, 8, ["name"])) : K("", !0)
2216
+ ])
2217
+ ], 2),
2218
+ d.value ? (k(), T("div", {
2219
+ key: 0,
2220
+ class: J(["flex flex-col gap-4 pl-8 fm-typo-en-body-sm-400", {
2221
+ "text-fm-color-typo-secondary": !o.errors.length,
2222
+ "text-fm-color-system-error-300": o.errors.length
2223
+ }])
2224
+ }, [
2225
+ o.errors.length ? (k(), T("div", yo, [
2226
+ l("ol", null, [
2227
+ (k(!0), T(re, null, xe(o.errors, (e, n) => (k(), T("li", { key: n }, E(e), 1))), 128))
2228
+ ])
2229
+ ])) : K("", !0)
2230
+ ], 2)) : K("", !0)
2231
+ ]);
2232
+ };
2233
+ }
2234
+ }), go = { class: "flex flex-col gap-24" }, _o = {
2235
+ key: 0,
2236
+ class: "flex items-center gap-8"
2237
+ }, ho = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, ko = { class: "flex flex-col gap-8" }, xo = { class: "line-clamp-2 text-ellipsis break-all" }, Co = {
2238
+ key: 2,
2239
+ class: "shrink-0"
2240
+ }, So = {
2241
+ key: 0,
2242
+ class: "flex flex-col"
2243
+ }, wo = { class: "text-fm-color-system-error-300 fm-typo-en-body-sm-400" }, Fo = {
2244
+ key: 0,
2245
+ class: "max-h-[200px] overflow-y-auto flex flex-col gap-8"
2246
+ }, Io = { class: "fm-typo-en-body-lg-600" }, wt = "Transfer note", $o = /* @__PURE__ */ de({
2247
+ __name: "XilnexImportForm",
2248
+ setup(p, { expose: g }) {
2249
+ const i = U(null), d = Re(), b = U(!1), o = U(!1), h = $s(), x = U(!1), I = Ne();
2250
+ U([]);
2251
+ const m = M({
2252
+ get() {
2253
+ var c;
2254
+ return ((c = h.supplier) == null ? void 0 : c.name) ?? "";
2255
+ },
2256
+ set(c) {
2257
+ c && (h.supplier = {
2258
+ name: c,
2259
+ registrationNumber: "",
2260
+ _id: "xilnex",
2261
+ internal: "restaurant",
2262
+ address: {
2263
+ line1: "",
2264
+ line2: "",
2265
+ city: "",
2266
+ state: "",
2267
+ country: "",
2268
+ postcode: ""
2269
+ }
2270
+ });
2271
+ }
2272
+ });
2273
+ We(async () => {
2274
+ const c = await I.getNetSuiteLocations();
2275
+ console.log(c), x.value = !0;
2276
+ });
2277
+ const e = M({
2278
+ get() {
2279
+ return "";
2280
+ },
2281
+ set(c) {
2282
+ if (c) {
2283
+ const y = h.effectiveAt ? new Date(h.effectiveAt) : /* @__PURE__ */ new Date(), [F, B, z] = c.split("-");
2284
+ y.setFullYear(parseInt(F)), y.setMonth(parseInt(B) - 1), y.setDate(parseInt(z)), h.effectiveAt = y.toISOString();
2285
+ }
2286
+ }
2287
+ }), n = M({
2288
+ get() {
2289
+ return null;
2290
+ },
2291
+ set(c) {
2292
+ if (c) {
2293
+ const y = h.effectiveAt ? new Date(h.effectiveAt) : /* @__PURE__ */ new Date(), [F, B] = c.split(":");
2294
+ y.setMinutes(parseInt(F)), y.setSeconds(parseInt(B)), h.effectiveAt = y.toISOString();
2295
+ }
2296
+ }
2297
+ }), f = U(new Array()), s = U([]), r = M(
2298
+ () => !!f.value.length || s.value.some((c) => c.errors.length)
2299
+ ), u = U();
2300
+ g({
2301
+ validateInputs: () => {
2302
+ var c, y;
2303
+ (y = (c = u.value) == null ? void 0 : c.validateInputs) == null || y.call(c);
2304
+ },
2305
+ resetInputsValidation: () => {
2306
+ var c, y;
2307
+ (y = (c = u.value) == null ? void 0 : c.resetInputsValidation) == null || y.call(c);
2308
+ },
2309
+ resetInputs: () => {
2310
+ var c, y;
2311
+ (y = (c = u.value) == null ? void 0 : c.resetInputs) == null || y.call(c);
2312
+ }
2313
+ });
2314
+ const { t: w } = he();
2315
+ async function $(c) {
2316
+ f.value = [], s.value = [];
2317
+ try {
2318
+ b.value = !0;
2319
+ const [y] = await Promise.all([
2320
+ Fs(c),
2321
+ // fake buffer
2322
+ new Promise((B) => setTimeout(B, 1e3))
2323
+ ]), F = ao(y);
2324
+ if (F.invalidExcel) {
2325
+ f.value.push(
2326
+ F.invalidExcelMessage ?? w("inventory.ingredient.import.fileError.invalidExcel")
2327
+ );
2328
+ return;
2329
+ }
2330
+ if (s.value = F.importCreateResult, !s.value.length) {
2331
+ f.value.push(w("inventory.ingredient.import.fileError.noData"));
2332
+ return;
2333
+ }
2334
+ h.items = s.value.map((B) => B.poItems).flat();
2335
+ } catch (y) {
2336
+ d.open({
2337
+ title: w("inventory.ingredient.import.fileError.unableToRead"),
2338
+ message: y == null ? void 0 : y.message,
2339
+ type: "error"
2340
+ }), console.error("Error in reading file", y);
2341
+ } finally {
2342
+ f.value.length && d.open({
2343
+ title: w("inventory.ingredient.import.fileError.invalidExcel"),
2344
+ type: "error"
2345
+ }), b.value = !1;
2346
+ }
2347
+ }
2348
+ return _e(i, (c) => {
2349
+ c && $(c);
2350
+ }), (c, y) => {
2351
+ const F = V("FmSelect"), B = V("FmDatePicker"), z = V("FmTimePicker"), Z = V("FmCircularProgress"), X = V("FmLabel"), N = V("FmIcon"), P = V("FmButton"), R = V("FmForm");
2352
+ return k(), se(R, {
2353
+ ref_key: "formRef",
2354
+ ref: u
2355
+ }, {
2356
+ default: A(() => [
2357
+ l("div", go, [
2358
+ v(F, {
2359
+ modelValue: m.value,
2360
+ "onUpdate:modelValue": y[0] || (y[0] = (D) => m.value = D),
2361
+ label: "Transfer from",
2362
+ searchable: "",
2363
+ searchTarget: "label",
2364
+ items: [
2365
+ { label: "Object", value: null },
2366
+ { label: "Array", value: ["array", "1"] },
2367
+ { label: "Number", value: 3 },
2368
+ { label: "String", value: "4" },
2369
+ { label: "1", value: "5" },
2370
+ { label: "2", value: "6" }
2371
+ ],
2372
+ "helper-text": "Helper",
2373
+ rules: [t(Ue)()]
2374
+ }, null, 8, ["modelValue", "rules"]),
2375
+ v(B, {
2376
+ modelValue: e.value,
2377
+ "onUpdate:modelValue": y[1] || (y[1] = (D) => e.value = D),
2378
+ label: "Transfer date",
2379
+ rules: [t(Ue)()]
2380
+ }, null, 8, ["modelValue", "rules"]),
2381
+ v(z, {
2382
+ modelValue: n.value,
2383
+ "onUpdate:modelValue": y[2] || (y[2] = (D) => n.value = D),
2384
+ label: "Transfer time",
2385
+ rules: [t(Ue)()]
2386
+ }, null, 8, ["modelValue", "rules"]),
2387
+ o.value ? (k(), T("div", _o, [
2388
+ l("div", null, [
2389
+ v(Z, {
2390
+ size: "md",
2391
+ color: "neutral-gray-200"
2392
+ })
2393
+ ]),
2394
+ l("div", ho, E(t(w)("inventory.formField.loading")), 1)
2395
+ ])) : (k(), T(re, { key: 1 }, [
2396
+ v(Is, {
2397
+ "max-file-size": 5,
2398
+ class: J({
2399
+ "w-full": !0,
2400
+ "h-[200px]": !i.value
2401
+ }),
2402
+ accept: ".xlsx,.xls",
2403
+ label: wt,
2404
+ onFileUpload: y[3] || (y[3] = (D) => i.value = D),
2405
+ "button-label": t(w)("inventory.ingredient.import.selectFile")
2406
+ }, qt({ _: 2 }, [
2407
+ i.value ? {
2408
+ name: "default",
2409
+ fn: A(({ openFileDialog: D }) => [
2410
+ v(X, null, {
2411
+ default: A(() => [
2412
+ Pe(E(wt))
2413
+ ]),
2414
+ _: 1
2415
+ }),
2416
+ l("div", ko, [
2417
+ l("div", {
2418
+ class: J([
2419
+ "fm-corner-radius-md p-16 flex items-center gap-16",
2420
+ {
2421
+ "border border-fm-color-neutral-gray-100": b.value,
2422
+ "border border-fm-color-neutral-gray-200": !b.value && !r.value,
2423
+ "border border-fm-color-system-error-200": r.value
2424
+ }
2425
+ ])
2426
+ }, [
2427
+ b.value ? (k(), se(Z, {
2428
+ key: 0,
2429
+ size: "md",
2430
+ color: "neutral-gray-200"
2431
+ })) : (k(), se(N, {
2432
+ key: 1,
2433
+ name: r.value ? "error" : "attach_file",
2434
+ outline: "",
2435
+ color: r.value ? "system-error-300" : void 0
2436
+ }, null, 8, ["name", "color"])),
2437
+ l("div", {
2438
+ class: J([
2439
+ "fm-typo-en-body-md-400 flex-1 h-[36px] flex items-center",
2440
+ {
2441
+ "text-fm-color-typo-disabled": b.value,
2442
+ "text-fm-color-typo-primary": !b.value
2443
+ }
2444
+ ])
2445
+ }, [
2446
+ l("div", xo, E(i.value.name), 1)
2447
+ ], 2),
2448
+ b.value ? K("", !0) : (k(), T("div", Co, [
2449
+ v(P, {
2450
+ label: t(w)("inventory.ingredient.import.replaceFile"),
2451
+ variant: r.value ? "destructive" : "secondary",
2452
+ "prepend-icon": r.value ? void 0 : "autorenew",
2453
+ onClick: D
2454
+ }, null, 8, ["label", "variant", "prepend-icon", "onClick"])
2455
+ ]))
2456
+ ], 2),
2457
+ f.value.length ? (k(), T("div", So, [
2458
+ (k(!0), T(re, null, xe(f.value, (q, L) => (k(), T("div", {
2459
+ key: L,
2460
+ class: "flex gap-8 items-center"
2461
+ }, [
2462
+ v(N, {
2463
+ name: "error",
2464
+ size: "sm",
2465
+ color: "system-error-300"
2466
+ }),
2467
+ l("div", wo, E(q), 1)
2468
+ ]))), 128))
2469
+ ])) : K("", !0)
2470
+ ])
2471
+ ]),
2472
+ key: "0"
2473
+ } : void 0
2474
+ ]), 1032, ["class", "button-label"]),
2475
+ i.value ? (k(), T("div", Fo, [
2476
+ l("div", Io, E(t(w)("inventory.ingredient.import.summary")), 1),
2477
+ (k(!0), T(re, null, xe(s.value, (D, q) => (k(), se(bo, {
2478
+ key: q,
2479
+ name: `Transfer Note ${q + 1}`,
2480
+ items: D.poItems,
2481
+ errors: D.errors,
2482
+ type: "create"
2483
+ }, null, 8, ["name", "items", "errors"]))), 128))
2484
+ ])) : K("", !0)
2485
+ ], 64))
2486
+ ])
2487
+ ]),
2488
+ _: 1
2489
+ }, 512);
2490
+ };
2491
+ }
2492
+ }), Do = { class: "w-[480px]" }, To = /* @__PURE__ */ de({
2493
+ __name: "XilnexImportDialog",
2494
+ props: {
2495
+ show: { type: Boolean }
2496
+ },
2497
+ emits: ["update:show", "submitted"],
2498
+ setup(p, { expose: g, emit: i }) {
2499
+ const d = i, o = Vt(p, "show"), h = Re(), x = ct(), I = U(!1), m = U(), e = U();
2500
+ g({
2501
+ validateInputs: () => {
2502
+ var s, r;
2503
+ (r = (s = m.value) == null ? void 0 : s.validateInputs) == null || r.call(s);
2504
+ },
2505
+ resetInputsValidation: () => {
2506
+ var s, r;
2507
+ (r = (s = m.value) == null ? void 0 : s.resetInputsValidation) == null || r.call(s);
2508
+ },
2509
+ resetInputs: () => {
2510
+ var s, r;
2511
+ (r = (s = m.value) == null ? void 0 : s.resetInputs) == null || r.call(s);
2512
+ }
2513
+ });
2514
+ function n() {
2515
+ var s, r;
2516
+ (r = (s = m.value) == null ? void 0 : s.validateInputs) == null || r.call(s);
2517
+ }
2518
+ async function f() {
2519
+ var r, u, w, $, c;
2520
+ if (!((u = (r = e.value) == null ? void 0 : r.supplier) != null && u.name)) {
2521
+ h.open({
2522
+ title: "Upload failed",
2523
+ message: "Location is required",
2524
+ type: "error"
2525
+ });
2526
+ return;
2527
+ }
2528
+ if (!((w = e.value) != null && w.items) || ((c = ($ = e.value) == null ? void 0 : $.items) == null ? void 0 : c.length) === 0) {
2529
+ h.open({
2530
+ title: "Upload failed",
2531
+ message: "No data to upload",
2532
+ type: "error"
2533
+ });
2534
+ return;
2535
+ }
2536
+ const s = e.value.effectiveAt ? new Date(e.value.effectiveAt) : null;
2537
+ if (!s) {
2538
+ h.open({
2539
+ title: "Invalid date",
2540
+ message: "Transfer date is required",
2541
+ type: "error"
2542
+ });
2543
+ return;
2544
+ }
2545
+ if (s.getTime() > (/* @__PURE__ */ new Date()).getTime()) {
2546
+ h.open({
2547
+ title: "Invalid date",
2548
+ message: "Transfer date cannot be in the future",
2549
+ type: "error"
2550
+ });
2551
+ return;
2552
+ }
2553
+ I.value = !0;
2554
+ try {
2555
+ await x.importFromXilnex(e.value), d("update:show", !1);
2556
+ } catch (y) {
2557
+ await new Promise((F) => setTimeout(F, 1e3)), h.open({
2558
+ title: "Upload failed",
2559
+ message: y == null ? void 0 : y.message,
2560
+ type: "error"
2561
+ });
2562
+ } finally {
2563
+ I.value = !1;
2564
+ }
2565
+ }
2566
+ return (s, r) => {
2567
+ const u = V("FmSpacer"), w = V("FmButton"), $ = V("FmDialog");
2568
+ return k(), se($, {
2569
+ modelValue: t(o),
2570
+ "onUpdate:modelValue": r[2] || (r[2] = (c) => Se(o) ? o.value = c : null),
2571
+ overlay: !0,
2572
+ "close-button": !1
2573
+ }, {
2574
+ "dialog-header": A(() => r[3] || (r[3] = [
2575
+ l("div", null, "Xilnex transfer order", -1)
2576
+ ])),
2577
+ "dialog-footer": A(() => [
2578
+ v(u, { class: "sm:hidden xs:hidden" }),
2579
+ v(w, {
2580
+ disabled: I.value,
2581
+ class: "sm:w-full xs:w-full",
2582
+ label: "Cancel",
2583
+ size: "md",
2584
+ variant: "tertiary",
2585
+ onClick: r[1] || (r[1] = (c) => d("update:show", !1))
2586
+ }, null, 8, ["disabled"]),
2587
+ v(w, {
2588
+ disabled: I.value,
2589
+ loading: I.value,
2590
+ class: "sm:w-full xs:w-full",
2591
+ label: "Upload",
2592
+ size: "md",
2593
+ variant: "primary",
2594
+ onClick: n
2595
+ }, null, 8, ["disabled", "loading"])
2596
+ ]),
2597
+ default: A(() => [
2598
+ l("div", Do, [
2599
+ v($o, {
2600
+ ref_key: "formRef",
2601
+ ref: m,
2602
+ onValidationSuccess: f,
2603
+ modelValue: e.value,
2604
+ "onUpdate:modelValue": r[0] || (r[0] = (c) => e.value = c)
2605
+ }, null, 8, ["modelValue"])
2606
+ ])
2607
+ ]),
2608
+ _: 1
2609
+ }, 8, ["modelValue"]);
2610
+ };
2611
+ }
2612
+ }), Vo = { class: "flex flex-col py-8" }, Po = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Ro = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary line-clamp-1" }, Oo = { class: "fm-typo-en-body-md-400 text-fm-color-typo-primary line-clamp-1" }, Ao = {
2613
+ key: 0,
2614
+ class: "fm-typo-en-body-md-400 text-fm-color-typo-primary line-clamp-1"
2615
+ }, Eo = { class: "pt-8" }, Ft = "ReceiveRequestViewSearchCriteria", mn = /* @__PURE__ */ de({
2616
+ __name: "ReceiveRequestView",
2617
+ setup(p) {
2618
+ const { t: g } = he(), i = Re();
2619
+ Ke.object({
2620
+ name: Ke.string().optional().nullable(),
2621
+ startDate: Ke.string().optional().nullable(),
2622
+ endDate: Ke.string().optional().nullable()
2623
+ });
2624
+ const d = M(
2625
+ () => !f._currentLocation || e.loading.value
2626
+ ), b = ls(), o = et(), h = Ne();
2627
+ function x() {
2628
+ const N = {
2629
+ name: "",
2630
+ ...kt()
2631
+ }, P = b.getItem(Ft);
2632
+ if (!P)
2633
+ return N;
2634
+ try {
2635
+ return JSON.parse(P);
2636
+ } catch {
2637
+ return N;
2638
+ }
2639
+ }
2640
+ function I() {
2641
+ b.setItem(Ft, JSON.stringify(m.value));
2642
+ }
2643
+ const m = U(x()), e = Wt(
2644
+ at.RECEIVE_REQUEST,
2645
+ m.value
2646
+ ), { columnDefs: n } = Jt(
2647
+ at.RECEIVE_REQUEST,
2648
+ e,
2649
+ e.shipments
2650
+ ), f = Je();
2651
+ async function s() {
2652
+ const N = `inventory-record_${xt(m.value.startDate).format("DD-MM-YYYY_HH-mm")}-${xt(m.value.endDate).format("DD-MM-YYYY_HH-mm")}.xlsx`, P = e.purchaseOrders.value.flatMap(
2653
+ (D) => D.items.map((q) => {
2654
+ var H;
2655
+ const L = new Date(os(D._id) ?? ""), W = D.effectiveAt ? new Date(D.effectiveAt) : void 0, ae = we(
2656
+ es(q.sku, D.deliveryOrder || [])
2657
+ ), S = we(q.quantity), C = ((H = q == null ? void 0 : q.measurement) == null ? void 0 : H.abbrev) || q.sku.unit.abbrev;
2658
+ return {
2659
+ "SKU code": q.code,
2660
+ "SKU name": q.name,
2661
+ "PO #": D.seqNumber,
2662
+ "Effective at": W,
2663
+ Date: L,
2664
+ Status: D.status,
2665
+ Reference: D.ref ?? "",
2666
+ "Received quantity": ae,
2667
+ "Ordered quantity": S,
2668
+ Unit: C,
2669
+ "Total cost": q.totalCost ? Ze(q.totalCost) : null
2670
+ };
2671
+ })
2672
+ ), R = [
2673
+ "SKU code",
2674
+ "SKU name",
2675
+ "PO #",
2676
+ "Date",
2677
+ "Status",
2678
+ "Reference",
2679
+ "Received quantity",
2680
+ "Ordered quantity",
2681
+ "Unit"
2682
+ ];
2683
+ o.enableBackdatePo && R.insert("Effective at", 4), o.enableTotalCost && R.push("Total cost"), await ns(
2684
+ [
2685
+ {
2686
+ name: "purchases",
2687
+ data: P,
2688
+ columns: R
2689
+ }
2690
+ ],
2691
+ N
2692
+ ), i.open({
2693
+ title: g("inventory.transfer.receiveRequest.export.success"),
2694
+ message: g("inventory.transfer.receiveRequest.export.message", [N]),
2695
+ type: "success"
2696
+ });
2697
+ }
2698
+ const r = U(kt()), u = U("");
2699
+ _e([() => r.value], ([N]) => {
2700
+ !N.startDate || !N.endDate || (m.value.startDate = N.startDate, m.value.endDate = N.endDate, e.updateDateRange(
2701
+ m.value.startDate,
2702
+ m.value.endDate
2703
+ ), I());
2704
+ }), _e([() => u.value], () => {
2705
+ I();
2706
+ });
2707
+ function w(N) {
2708
+ if (N === "create") {
2709
+ if (d.value) {
2710
+ i.open({
2711
+ title: "Loading data...",
2712
+ message: "Please wait.",
2713
+ type: "info"
2714
+ });
2715
+ return;
2716
+ }
2717
+ return e.promptCreateTransferDialog();
2718
+ }
2719
+ if (N === "upload" && o.enableXilnexTransferNote)
2720
+ return e.promptUploadTransferDialog();
2721
+ if (N === "refresh")
2722
+ return e.fetchData();
2723
+ if (N === "export")
2724
+ return s();
2725
+ }
2726
+ const { breakpoints: $ } = it(), c = M(() => $.value.xs || $.value.sm), y = M(() => c.value ? 10 : 20), F = rs(), B = M(() => [
2727
+ {
2728
+ label: g("inventory.transfer.receiveRequest.actions.create"),
2729
+ value: "create",
2730
+ isPrimary: !0,
2731
+ prependIcon: "add"
2732
+ },
2733
+ ...o.enableXilnexTransferNote ? [
2734
+ {
2735
+ label: g("inventory.common.upload"),
2736
+ value: "upload"
2737
+ }
2738
+ ] : [],
2739
+ {
2740
+ label: g("inventory.common.refresh"),
2741
+ value: "refresh"
2742
+ },
2743
+ {
2744
+ label: g("inventory.common.export"),
2745
+ value: "export"
2746
+ }
2747
+ ]), z = M(() => {
2748
+ const N = [
2749
+ {
2750
+ type: "string",
2751
+ key: "status",
2752
+ entity: "purchaseOrder",
2753
+ values: Array.from(
2754
+ new Set(e.purchaseOrders.value.map((R) => R.status))
2755
+ )
2756
+ }
2757
+ ], P = [
2758
+ {
2759
+ type: "string",
2760
+ key: "netsuiteTransactionNumber",
2761
+ entity: "purchaseOrder",
2762
+ values: e.purchaseOrders.value.map((R) => {
2763
+ var D, q;
2764
+ return (q = (D = R.netSuite) == null ? void 0 : D.additionalInfo) == null ? void 0 : q.transactionnumber;
2765
+ }).filter((R) => R != null)
2766
+ },
2767
+ {
2768
+ type: "string",
2769
+ key: "netsuiteOrderNo",
2770
+ entity: "purchaseOrder",
2771
+ values: e.purchaseOrders.value.map((R) => {
2772
+ var D;
2773
+ return (D = R.netSuite) == null ? void 0 : D.refNo;
2774
+ }).filter((R) => R != null)
2775
+ },
2776
+ {
2777
+ type: "string",
2778
+ key: "netsuiteOrderId",
2779
+ entity: "purchaseOrder",
2780
+ values: e.purchaseOrders.value.map((R) => {
2781
+ var D;
2782
+ return (D = R.netSuite) == null ? void 0 : D.id;
2783
+ }).filter((R) => R != null)
2784
+ }
2785
+ ];
2786
+ return [...N, ...h.isEnabled ? P : []];
2787
+ }), Z = U(null), X = M(() => {
2788
+ if (!Z.value)
2789
+ return e.purchaseOrders.value;
2790
+ const N = Ds.build(Z.value);
2791
+ return e.purchaseOrders.value.filter((P) => {
2792
+ var R, D, q, L;
2793
+ return Ts(
2794
+ {
2795
+ netsuiteTransactionNumber: (D = (R = P.netSuite) == null ? void 0 : R.additionalInfo) == null ? void 0 : D.transactionnumber,
2796
+ netsuiteOrderNo: (q = P.netSuite) == null ? void 0 : q.refNo,
2797
+ netsuiteOrderId: (L = P.netSuite) == null ? void 0 : L.id,
2798
+ status: P.status
2799
+ },
2800
+ N
2801
+ );
2802
+ });
2803
+ });
2804
+ return (N, P) => {
2805
+ const R = V("FmTable");
2806
+ return k(), se(is, {
2807
+ title: t(g)("inventory.transfer.receiveRequest.title2"),
2808
+ actions: B.value,
2809
+ "onClick:action": w
2810
+ }, {
2811
+ default: A(() => {
2812
+ var D, q;
2813
+ return [
2814
+ l("div", {
2815
+ class: J([
2816
+ "flex flex-col gap-8 max-h-full",
2817
+ {
2818
+ "p-0": c.value,
2819
+ "px-24 ": !c.value
2820
+ }
2821
+ ])
2822
+ }, [
2823
+ v(Zt, {
2824
+ "date-range-query": "",
2825
+ "date-range": r.value,
2826
+ "onUpdate:dateRange": P[0] || (P[0] = (L) => r.value = L),
2827
+ searchable: "",
2828
+ "change-location": "",
2829
+ search: u.value,
2830
+ "onUpdate:search": P[1] || (P[1] = (L) => u.value = L),
2831
+ filterable: "",
2832
+ "filter-attributes": z.value,
2833
+ filter: Z.value,
2834
+ "onUpdate:filter": P[2] || (P[2] = (L) => Z.value = L)
2835
+ }, null, 8, ["date-range", "search", "filter-attributes", "filter"]),
2836
+ (k(), se(R, {
2837
+ style: $t(t(F).tableHeight),
2838
+ "column-defs": t(n),
2839
+ "row-data": X.value,
2840
+ "search-value": u.value,
2841
+ loading: d.value,
2842
+ onRowClick: P[3] || (P[3] = (L) => t(e).promptShowTransferDetails(L.original)),
2843
+ key: (D = t(f)._currentLocation) == null ? void 0 : D.dbName,
2844
+ "page-size": y.value
2845
+ }, {
2846
+ "list-row": A((L) => [
2847
+ v(Pt, {
2848
+ row: L,
2849
+ onRowClick: t(e).promptShowTransferDetails
2850
+ }, {
2851
+ default: A((W) => {
2852
+ var ae, S, C, H, fe, ce, G, Fe, Ie, Be, ze, tt, Le, Ce, Oe, a, _, Y, le, ye;
2853
+ return [
2854
+ l("div", Vo, [
2855
+ l("div", Po, [
2856
+ v(t(ve), {
2857
+ render: (C = (S = (ae = W._id) == null ? void 0 : ae.column) == null ? void 0 : S.columnDef) == null ? void 0 : C.cell,
2858
+ props: (fe = (H = W._id) == null ? void 0 : H.getContext) == null ? void 0 : fe.call(H)
2859
+ }, null, 8, ["render", "props"])
2860
+ ]),
2861
+ l("div", Ro, [
2862
+ v(t(ve), {
2863
+ render: (Fe = (G = (ce = W.supplier_name) == null ? void 0 : ce.column) == null ? void 0 : G.columnDef) == null ? void 0 : Fe.cell,
2864
+ props: (Be = (Ie = W.supplier_name) == null ? void 0 : Ie.getContext) == null ? void 0 : Be.call(Ie)
2865
+ }, null, 8, ["render", "props"])
2866
+ ]),
2867
+ l("div", Oo, E(L.original.items.map(($e) => `${$e.name}`).join(", ")), 1),
2868
+ L.original.ref ? (k(), T("div", Ao, [
2869
+ v(t(ve), {
2870
+ render: (Le = (tt = (ze = W.ref) == null ? void 0 : ze.column) == null ? void 0 : tt.columnDef) == null ? void 0 : Le.cell,
2871
+ props: (Oe = (Ce = W.ref) == null ? void 0 : Ce.getContext) == null ? void 0 : Oe.call(Ce)
2872
+ }, null, 8, ["render", "props"])
2873
+ ])) : K("", !0),
2874
+ l("div", Eo, [
2875
+ v(t(ve), {
2876
+ render: (Y = (_ = (a = W.status) == null ? void 0 : a.column) == null ? void 0 : _.columnDef) == null ? void 0 : Y.cell,
2877
+ props: (ye = (le = W.status) == null ? void 0 : le.getContext) == null ? void 0 : ye.call(le)
2878
+ }, null, 8, ["render", "props"])
2879
+ ])
2880
+ ])
2881
+ ];
2882
+ }),
2883
+ _: 2
2884
+ }, 1032, ["row", "onRowClick"])
2885
+ ]),
2886
+ _: 1
2887
+ }, 8, ["style", "column-defs", "row-data", "search-value", "loading", "page-size"]))
2888
+ ], 2),
2889
+ (k(), se(Ut, { to: "body" }, [
2890
+ v(to, nt(t(e).transferDialogProps.value, {
2891
+ onSubmitted: t(e).fetchData
2892
+ }), null, 16, ["onSubmitted"]),
2893
+ v(Gt, nt({
2894
+ scope: t(at).RECEIVE_REQUEST
2895
+ }, {
2896
+ ...t(e).transferDetailsProps.value,
2897
+ receivedMap: ((q = t(e).transferDetailsProps.value) == null ? void 0 : q.receivedMap) ?? {},
2898
+ shipments: t(e).shipments.value ?? []
2899
+ }, {
2900
+ onSubmitted: t(e).fetchData
2901
+ }), null, 16, ["scope", "onSubmitted"]),
2902
+ v(To, Nt(Bt(t(e).xilnexImportDialogProps.value)), null, 16)
2903
+ ]))
2904
+ ];
2905
+ }),
2906
+ _: 1
2907
+ }, 8, ["title", "actions"]);
2908
+ };
2909
+ }
2910
+ });
2911
+ export {
2912
+ mn as default
2913
+ };