@feedmepos/mf-inventory-portal 1.2.42-dev.1 → 1.2.42-dev.2

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