@feedmepos/mf-inventory-portal 0.0.25-dev.35 → 0.0.25-dev.37

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 (60) hide show
  1. package/dist/App-C0_9-oDP.js +277 -0
  2. package/dist/{ApprovalView-lHxxupqD.js → ApprovalView-BDUbQAH0.js} +12 -18
  3. package/dist/{BindingsDialog-BYXxxF3D.js → BindingsDialog-BvKDyWAP.js} +4 -4
  4. package/dist/{BindingsPicker-BiOmhG63.js → BindingsPicker-zAexcP3H.js} +5 -5
  5. package/dist/{BindingsTable-C2CG0Wzx.js → BindingsTable-6dPndhbk.js} +5 -5
  6. package/dist/{ClosingDraftView-BO8Fg9uW.js → ClosingDraftView-NwwxcHA-.js} +2 -2
  7. package/dist/{ClosingTemplateView-DmBvstOM.js → ClosingTemplateView-Cfh0BZXH.js} +2 -2
  8. package/dist/FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-DKxW0e2c.js +211 -0
  9. package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-CQB9QYnf.js → FmUnitInput.vue_vue_type_script_setup_true_lang-CD0p0eOE.js} +1 -1
  10. package/dist/{IngredientBindedItem.vue_vue_type_script_setup_true_lang-DditohRx.js → IngredientBindedItem.vue_vue_type_script_setup_true_lang-eGofs51J.js} +1 -1
  11. package/dist/{IngredientGroupView-D5SpwtqP.js → IngredientGroupView-Cz4zcWgF.js} +1 -1
  12. package/dist/{IngredientsView-Dgw0nCeT.js → IngredientsView-Ctmor1Ds.js} +622 -605
  13. package/dist/{IntegrationView-BPkBh8lR.js → IntegrationView-DYV2ISmc.js} +23 -23
  14. package/dist/{InventoryBindingForm-COpLVAaA.js → InventoryBindingForm-Be75Cpzd.js} +1 -1
  15. package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-BkyQOb8e.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-D8dK7h0Z.js} +11 -11
  16. package/dist/{InventoryBindingSummary-D6lmFeFs.js → InventoryBindingSummary-Cw1Woc3L.js} +1 -1
  17. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-BKzL_obr.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-BhKk5nMz.js} +1 -1
  18. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-CRrDyI6N.js → PremiumBadge.vue_vue_type_script_setup_true_lang-DECtXs-3.js} +1 -1
  19. package/dist/{PublishView-DRLVREhD.js → PublishView-D9mnP1d8.js} +11 -11
  20. package/dist/{PurchaseOrderPrintPreview-DvaJAeNk.js → PurchaseOrderPrintPreview-2DOgQczG.js} +1 -1
  21. package/dist/ReceiveRequestView-Ss803mII.js +2547 -0
  22. package/dist/{RecipeView-BFVpv5zA.js → RecipeView-DTwkk7M_.js} +3 -3
  23. package/dist/{StockView-BOzx7POz.js → StockView-cd047f5L.js} +7 -7
  24. package/dist/{SupplierView-DA3-b1sK.js → SupplierView-CkYiC3sV.js} +4 -4
  25. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-CE3vSlpG.js +1540 -0
  26. package/dist/{TransferTemplateView-V4C_flzB.js → TransferTemplateView-C6-6Db2r.js} +7 -7
  27. package/dist/{UnitView-CfQSRLN9.js → UnitView-C-1I-kVv.js} +3 -3
  28. package/dist/{WarehouseView-B5mEXts4.js → WarehouseView-CJTtNzco.js} +1 -1
  29. package/dist/api/purchase-order.d.ts +2 -2
  30. package/dist/{app-tDCjbNqA.js → app-C720GM9g.js} +6632 -6672
  31. package/dist/app.js +1 -1
  32. package/dist/components/FmMultiselectDialog.d.ts +1 -24
  33. package/dist/{decimal-BXNZd-qR.js → decimal-BCdHyq3s.js} +1 -1
  34. package/dist/{feature-RoIIaF13.js → feature-Df0TfAlQ.js} +227 -231
  35. package/dist/{format-unit-display-B2P_1U8-.js → format-unit-display-DhVGfJ3A.js} +2 -2
  36. package/dist/{index-0DbWAreR.js → index-BcO0U3XD.js} +2 -2
  37. package/dist/{stock-BkYwqicV.js → stock-AgQ9Kd12.js} +1 -1
  38. package/dist/stores/feature.d.ts +2 -3
  39. package/dist/{supplier-2qlZME6l.js → supplier-y6wN-U1P.js} +1 -1
  40. package/dist/tsconfig.app.tsbuildinfo +1 -1
  41. package/dist/{use-ingredient-select-dialog-D9bLhIPr.js → use-ingredient-select-dialog-DedAlRiZ.js} +1 -1
  42. package/dist/{use-inventory-binding-dialog-FprlSH51.js → use-inventory-binding-dialog-D6ESCCxB.js} +1 -1
  43. package/dist/views/receive-request/components/transfer-details/TransferDetails.vue.d.ts +0 -1375
  44. package/dist/views/receive-request/components/transfer-details/TransferDetailsProps.d.ts +1 -3
  45. package/dist/views/receive-request/components/transfer-dialog/TransferDialogProps.d.ts +0 -3
  46. package/dist/views/receive-request/components/transfer-form/TransferForm.vue.d.ts +3022 -0
  47. package/dist/views/receive-request/components/transfer-form/TransferFormProps.d.ts +2 -1
  48. package/dist/views/receive-request/components/transfer-form/composables/use-transfer-items.d.ts +1 -0
  49. package/dist/views/receive-request/composables/use-receive-request-form.d.ts +9 -27
  50. package/dist/views/receive-request/composables/use-receive-request-table.d.ts +9 -22
  51. package/dist/views/receive-request/helper/print-po.d.ts +2 -9
  52. package/dist/{vue-i18n-C2CwX0tc.js → vue-i18n-C4yPgaCz.js} +397 -397
  53. package/package.json +1 -1
  54. package/dist/App-DPw6U_NJ.js +0 -280
  55. package/dist/FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-CJ7BgFh6.js +0 -215
  56. package/dist/ReceiveRequestView-C9Hqtit6.js +0 -2661
  57. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-DRUroMZS.js +0 -1843
  58. package/dist/components/MountListener.vue.d.ts +0 -15
  59. package/dist/views/receive-request/helper/po-to-po-template.util.d.ts +0 -1
  60. package/dist/views/transfer-template/helpers/location-to-po-supplier.util.d.ts +0 -75
@@ -0,0 +1,2547 @@
1
+ import { reactive as yt, onMounted as Qe, computed as E, h as j, defineComponent as le, openBlock as x, createElementBlock as D, Fragment as ae, renderList as Ce, createElementVNode as l, toDisplayString as P, unref as t, resolveComponent as I, createVNode as c, withCtx as T, createCommentVNode as L, ref as A, createBlock as Q, watch as ve, normalizeClass as K, normalizeStyle as bt, createTextVNode as Fe, nextTick as $t, mergeProps as Ye, isRef as xe, createSlots as It, Teleport as Dt, normalizeProps as Tt, guardReactiveProps as Vt } from "vue";
2
+ import { H as Ke, b as Be, Z as gt, l as Re, i as ke, a0 as Xe, K as Pt, as as Rt, A as Ne, M as At, m as _t, ab as Ze, E as de, at as Et, a as Le, au as Mt, av as Ut, aw as qt, G as ht, u as Ge, ax as Ot, ay as Nt, $ as Bt, T as Lt, az as zt, B as xt, d as Pe, v as Ht, w as jt, x as Yt, aA as Oe, a5 as ct, y as Kt, _ as Qt, z as Xt, N as mt } from "./app-C720GM9g.js";
3
+ import { u as We, a as Zt, P as je, b as Gt, _ as Wt, g as Jt } from "./TransferDetails.vue_vue_type_script_setup_true_lang-CE3vSlpG.js";
4
+ import { _ as kt, u as es, i as ts, e as ss } from "./PremiumBadge.vue_vue_type_script_setup_true_lang-DECtXs-3.js";
5
+ import { u as os } from "./useTabStorage-BkIVScW_.js";
6
+ import { useDialog as Ct, useBreakpoints as Je, components as pe, FmButtonVariant as as, useSnackbar as $e, useProxiedModel as St } from "@feedmepos/ui-library";
7
+ import { P as ee, u as wt } from "./format-unit-display-DhVGfJ3A.js";
8
+ import { _ as ls, F as ns, a as rs, b as is } from "./FmUnitInput.vue_vue_type_script_setup_true_lang-CD0p0eOE.js";
9
+ import { u as et } from "./feature-Df0TfAlQ.js";
10
+ import { c as he, u as us, _ as ds } from "./FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-DKxW0e2c.js";
11
+ import { useI18n as ce } from "@feedmepos/mf-common";
12
+ import { defineStore as cs } from "pinia";
13
+ import { u as tt } from "./supplier-y6wN-U1P.js";
14
+ import { _ as ms } from "./PreviewBadge.vue_vue_type_script_setup_true_lang-CRZiQHjx.js";
15
+ import { u as ps } from "./vue-i18n-C4yPgaCz.js";
16
+ import "./array-hChJVZLE.js";
17
+ const fs = cs("inventoryMultiSelectDialog", () => {
18
+ const y = Ct(), { t: _ } = ce();
19
+ return { multiSelect: async (g, e, u) => {
20
+ const h = u ?? ((s) => s), { promise: k, resolve: i } = Promise.withResolvers();
21
+ return y.open({
22
+ title: "Select items",
23
+ closeButton: !0,
24
+ contentComponent: Ke,
25
+ contentComponentProps: {
26
+ modelValue: e ?? [],
27
+ items: g,
28
+ virtualScroll: !0,
29
+ onClose: () => i(null)
30
+ },
31
+ primaryActions: {
32
+ text: _("common.confirm"),
33
+ close: !0
34
+ },
35
+ secondaryActions: {
36
+ text: _("common.close"),
37
+ close: !0,
38
+ variant: "tertiary"
39
+ }
40
+ }).onPrimary((s) => {
41
+ const a = s.map((b) => h(b));
42
+ i(a);
43
+ }), k;
44
+ }, singleSelect: async (g, e, u) => {
45
+ const h = u ?? ((s) => s), { promise: k, resolve: i } = Promise.withResolvers();
46
+ return y.open({
47
+ title: "Select items",
48
+ closeButton: !0,
49
+ contentComponent: Ke,
50
+ contentComponentProps: {
51
+ modelValue: e ? [e] : [],
52
+ items: g,
53
+ virtualScroll: !0,
54
+ onClose: () => i(void 0),
55
+ singleSelect: !0
56
+ },
57
+ primaryActions: {
58
+ text: _("common.confirm"),
59
+ close: !0
60
+ },
61
+ secondaryActions: {
62
+ text: _("common.close"),
63
+ close: !0,
64
+ variant: "tertiary"
65
+ }
66
+ }).onPrimary((s) => {
67
+ if (!s.length)
68
+ return i(null);
69
+ const a = h(s[0]);
70
+ i(a);
71
+ }), k;
72
+ } };
73
+ });
74
+ var Z = /* @__PURE__ */ ((y) => (y.Code = "Code", y.Name = "Name", y.TemplateName = "TemplateName", y.Amount = "Amount", y.Cost = "Cost", y.TotalCost = "TotalCost", y.Delete = "Delete", y))(Z || {});
75
+ const vs = () => (ce(), j(
76
+ kt,
77
+ {
78
+ zIndex: 50,
79
+ class: "whitespace-nowrap"
80
+ },
81
+ `Total (${_t()})`
82
+ ));
83
+ function ys(y) {
84
+ const { t: _ } = ce(), n = yt({}), { breakpoints: r } = Je(), g = et(), e = Be();
85
+ fs(), Qe(() => {
86
+ for (const i of y.items) {
87
+ if (!i.totalCost)
88
+ continue;
89
+ const s = he(i.sku, i.quantity, i.measurement, {
90
+ supplier: y.supplier
91
+ }), a = i.totalCost ?? gt.reset();
92
+ s ? n[i.sku._id] = s.amount !== a.amount || s.precision !== a.precision : n[i.sku._id] = !0;
93
+ }
94
+ });
95
+ function u(i) {
96
+ var a, b, m, p, S, F, d;
97
+ return !!(((b = (a = i.defaultCost) == null ? void 0 : a.costPerUnit) == null ? void 0 : b.amount) ?? ((d = (F = (S = (p = (m = y.supplier) == null ? void 0 : m.supplyItems) == null ? void 0 : p.find((f) => f.skuId === i._id)) == null ? void 0 : S.defaultCost) == null ? void 0 : F.costPerUnit) == null ? void 0 : d.amount));
98
+ }
99
+ const h = [
100
+ {
101
+ id: "Code",
102
+ header: () => _("inventory.transfer.form.items.table.Code"),
103
+ accessorKey: "code",
104
+ size: 200,
105
+ cell(i) {
106
+ const s = i.row.original;
107
+ return e.isEnabled ? j(
108
+ pe.FmTooltip,
109
+ {
110
+ content: s.code,
111
+ placement: "top",
112
+ variant: "plain",
113
+ zIndex: 50
114
+ },
115
+ j(
116
+ "span",
117
+ {
118
+ class: "flex-auto line-clamp-2 text-ellipsis break-all"
119
+ },
120
+ s.code
121
+ )
122
+ ) : j(pe.FmTextField, {
123
+ modelValue: s.code,
124
+ "onUpdate:modelValue": (a) => {
125
+ y.updateItem({
126
+ ...s,
127
+ code: a
128
+ });
129
+ },
130
+ key: s.sku._id,
131
+ rules: [Re()],
132
+ labelMark: "required"
133
+ });
134
+ },
135
+ enableSorting: !1
136
+ },
137
+ {
138
+ id: "Name",
139
+ header: () => _("inventory.transfer.form.items.table.Name"),
140
+ minSize: 300,
141
+ cell(i) {
142
+ const s = i.row.original;
143
+ return e.isEnabled ? j(
144
+ pe.FmTooltip,
145
+ {
146
+ content: s.name,
147
+ placement: "top",
148
+ variant: "plain",
149
+ zIndex: 50
150
+ },
151
+ j(
152
+ "span",
153
+ {
154
+ class: "flex-auto line-clamp-2 text-ellipsis break-all"
155
+ },
156
+ s.name
157
+ )
158
+ ) : j(pe.FmTextField, {
159
+ modelValue: s.name,
160
+ "onUpdate:modelValue": (a) => {
161
+ y.updateItem({
162
+ ...s,
163
+ name: a
164
+ });
165
+ },
166
+ key: s.sku._id,
167
+ rules: [Re()],
168
+ labelMark: "required"
169
+ });
170
+ },
171
+ enableSorting: !1
172
+ },
173
+ {
174
+ id: "TemplateName",
175
+ header: () => _("inventory.transfer.form.items.table.Name"),
176
+ minSize: 300,
177
+ enableSorting: !1,
178
+ cell(i) {
179
+ const s = i.row.original, a = s.code, b = s.name;
180
+ return j(
181
+ pe.FmTooltip,
182
+ { zIndex: 50 },
183
+ {
184
+ default() {
185
+ return j("div", { class: "flex flex-col w-full" }, [
186
+ j(
187
+ "div",
188
+ { class: "line-clamp-1 fm-typo-en-body-lg-400 text-fm-color-typo-primary" },
189
+ b
190
+ ),
191
+ j(
192
+ "div",
193
+ {
194
+ class: "line-clamp-1 fm-typo-en-body-md-400 text-fm-color-typo-secondary"
195
+ },
196
+ a
197
+ )
198
+ ]);
199
+ },
200
+ content() {
201
+ return b;
202
+ }
203
+ }
204
+ );
205
+ }
206
+ },
207
+ {
208
+ id: "Amount",
209
+ header: () => _("inventory.transfer.form.items.table.Amount"),
210
+ minSize: 200,
211
+ cell(i) {
212
+ var b, m, p, S;
213
+ const s = i.row.original, a = (p = (m = (b = y.template) == null ? void 0 : b.purchaseOrder) == null ? void 0 : m.items) == null ? void 0 : p.find(
214
+ (F) => F.sku._id === s.sku._id
215
+ );
216
+ return j(ls, {
217
+ style: {
218
+ flex: "1 1 0%"
219
+ },
220
+ modelValue: {
221
+ amount: s.quantity ?? { amount: 1, precision: 0 },
222
+ measurement: s.measurement ?? null
223
+ },
224
+ key: s.sku._id,
225
+ unit: s.sku.unit,
226
+ "onUpdate:modelValue": (F) => {
227
+ if (!F) return;
228
+ const d = {
229
+ ...s,
230
+ quantity: F.amount,
231
+ measurement: F.measurement
232
+ };
233
+ g.enableTotalCost && (d.totalCost = he(
234
+ d.sku,
235
+ d.quantity,
236
+ d.measurement,
237
+ {
238
+ supplier: y.supplier,
239
+ // NOTE: set undefined here if `manualTotalCost[updatedRow.sku._id] = false`, so that the function
240
+ // will return the auto calculated default cost instead of the manual total cost
241
+ manualTotalCost: n[d.sku._id] ? d.totalCost : void 0
242
+ }
243
+ )), y.updateItem(d);
244
+ },
245
+ stepper: a == null ? void 0 : a.quantityStep,
246
+ disableUnit: !!a,
247
+ disabled: y.disabled,
248
+ rules: [
249
+ ns(
250
+ +ke(
251
+ ((S = s.quantity) == null ? void 0 : S.amount) === 0 ? { amount: 0, precision: 0 } : (a == null ? void 0 : a.minimumQuantity) ?? { amount: 0, precision: 0 }
252
+ )
253
+ ),
254
+ rs(
255
+ a != null && a.maximumQuantity ? +ke(a == null ? void 0 : a.maximumQuantity) : 1 / 0
256
+ ),
257
+ ...a != null && a.quantityStep ? [is(a.quantityStep)] : []
258
+ ],
259
+ applyDefaultRules: !0
260
+ });
261
+ },
262
+ enableSorting: !1
263
+ },
264
+ {
265
+ id: "Cost",
266
+ header: vs,
267
+ size: 180,
268
+ cell(i) {
269
+ const s = i.row.original, a = u(s.sku), b = r.value.xs || r.value.sm;
270
+ return !n[s.sku._id] && a ? j(
271
+ "div",
272
+ {
273
+ class: [
274
+ "flex gap-4 fm-typo-en-body-md-400 items-center",
275
+ y.disabled ? "text-fm-color-typo-disabled" : ""
276
+ ],
277
+ key: s.sku._id
278
+ },
279
+ [
280
+ j(pe.FmButton, {
281
+ prependIcon: "edit",
282
+ variant: as.Tertiary,
283
+ disabled: y.disabled,
284
+ onClick() {
285
+ y.updateItem({
286
+ ...s,
287
+ totalCost: he(s.sku, s.quantity, s.measurement, {
288
+ supplier: y.supplier
289
+ })
290
+ }), n[s.sku._id] = !0;
291
+ }
292
+ }),
293
+ j(
294
+ "div",
295
+ {
296
+ class: "flex flex-col"
297
+ },
298
+ [
299
+ j(
300
+ "span",
301
+ b ? Xe(
302
+ he(s.sku, s.quantity, s.measurement, {
303
+ supplier: y.supplier
304
+ })
305
+ ) : ke(
306
+ he(s.sku, s.quantity, s.measurement, {
307
+ supplier: y.supplier
308
+ })
309
+ )
310
+ ),
311
+ j(
312
+ "span",
313
+ {
314
+ class: [
315
+ "fm-typo-en-body-sm-400",
316
+ y.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-neutral-gray-400"
317
+ ]
318
+ },
319
+ _("inventory.transfer.form.items.autoCalculated")
320
+ )
321
+ ]
322
+ )
323
+ ]
324
+ ) : j(
325
+ pe.FmTextField,
326
+ {
327
+ modelValue: ke(s.totalCost ?? { amount: 0, precision: 0 }),
328
+ key: s.sku._id,
329
+ "onUpdate:modelValue": (m) => {
330
+ y.updateItem({
331
+ ...s,
332
+ totalCost: {
333
+ ...Pt(+m),
334
+ currency: Rt()
335
+ }
336
+ });
337
+ },
338
+ rules: [Ne(0), At(2)]
339
+ },
340
+ {
341
+ prepend() {
342
+ return b ? j(
343
+ "div",
344
+ {
345
+ class: [
346
+ "text-fm-typo-en-body-lg-400",
347
+ y.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-typo-primary"
348
+ ]
349
+ },
350
+ _t()
351
+ ) : null;
352
+ },
353
+ append() {
354
+ return a ? j(pe.FmButton, {
355
+ prependIcon: "close",
356
+ variant: "tertiary",
357
+ disabled: y.disabled,
358
+ onClick() {
359
+ y.updateItem({
360
+ ...s,
361
+ // NOTE: different from PO template, if a default cost is reenabled,
362
+ // the total cost will automatically assigned
363
+ totalCost: he(s.sku, s.quantity, s.measurement, {
364
+ supplier: y.supplier
365
+ })
366
+ }), n[s.sku._id] = !1;
367
+ }
368
+ }) : null;
369
+ }
370
+ }
371
+ );
372
+ },
373
+ enableSorting: !1
374
+ },
375
+ {
376
+ id: "Delete",
377
+ header: "",
378
+ cell(i) {
379
+ const s = i.row.original;
380
+ return j("div", { class: "flex justify-end" }, [
381
+ j(pe.FmButton, {
382
+ key: s.sku._id,
383
+ class: "delete-button",
384
+ type: "button",
385
+ icon: "delete",
386
+ variant: "tertiary",
387
+ size: "md",
388
+ disabled: y.disabled,
389
+ onClick: () => {
390
+ y.deleteItem(s);
391
+ }
392
+ })
393
+ ]);
394
+ },
395
+ enableSorting: !1,
396
+ size: 40,
397
+ meta: {
398
+ cellClass: "",
399
+ headerClass: ""
400
+ }
401
+ }
402
+ ];
403
+ return {
404
+ columnDefs: E(() => g.enableTotalCost && y.transferType === ee.PURCHASE ? h : h.filter(
405
+ (i) => i.id !== "Cost"
406
+ /* Cost */
407
+ ))
408
+ };
409
+ }
410
+ const bs = { class: "flex flex-col gap-8 px-16 xs:px-4 sm:px-4 py-4 items-center" }, gs = { class: "fm-typo-en-body-lg-600 xs:fm-typo-en-body-md-600 mr-auto xs:w-full" }, _s = { class: "w-[450px] xs:w-full flex" }, hs = { class: "fm-typo-en-body-md-400 whitespace-nowrap" }, xs = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Ft = /* @__PURE__ */ le({
411
+ __name: "SupplierPriceHistory",
412
+ props: {
413
+ prices: {}
414
+ },
415
+ setup(y) {
416
+ const _ = tt();
417
+ function n(r) {
418
+ return _.suppliers.find((g) => g._id === r);
419
+ }
420
+ return (r, g) => (x(), D("div", bs, [
421
+ (x(!0), D(ae, null, Ce(Object.keys(r.prices), (e) => {
422
+ var u;
423
+ return x(), D("div", {
424
+ key: e,
425
+ class: "flex items-center gap-12 xs:gap-4 xs:flex-wrap w-full"
426
+ }, [
427
+ l("div", gs, P((u = n(e)) == null ? void 0 : u.name), 1),
428
+ l("div", _s, [
429
+ (x(!0), D(ae, null, Ce(r.prices[e].slice(0, 3), (h) => {
430
+ var k;
431
+ return x(), D("div", {
432
+ key: h.date,
433
+ class: "flex flex-col w-[150px] xs:flex-1 text-ellipsis cursor-pointer"
434
+ }, [
435
+ l("div", hs, [
436
+ l("span", null, P(h.totalCost ? t(Xe)(h.totalCost) : "No data"), 1),
437
+ g[0] || (g[0] = l("span", { class: "text-fm-color-typo-secondary" }, "/", -1)),
438
+ l("span", null, P(t(ke)(h.totalUnit, !1)), 1),
439
+ l("span", null, P(((k = h.measurement) == null ? void 0 : k.abbrev) ?? h.unit.abbrev), 1)
440
+ ]),
441
+ l("div", xs, [
442
+ l("span", null, "(#" + P(h.seqNumber) + ")", 1),
443
+ g[1] || (g[1] = l("span", null, P(" "), -1)),
444
+ l("span", null, P(t(Ze)(new Date(h.date))), 1)
445
+ ])
446
+ ]);
447
+ }), 128))
448
+ ])
449
+ ]);
450
+ }), 128))
451
+ ]));
452
+ }
453
+ }), ks = { class: "flex flex-col gap-8 py-16" }, Cs = { class: "flex items-center" }, Ss = { class: "flex-1 flex gap-1 items-center" }, ws = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, Fs = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, $s = { class: "flex gap-8 w-full" }, Is = { class: "flex-1 flex flex-col gap-4" }, Ds = { class: "flex-1 flex flex-col gap-4" }, Ts = { class: "flex gap-8 w-full" }, Vs = { class: "flex-1 flex flex-col gap-4" }, Ps = {
454
+ key: 0,
455
+ class: "flex-1 flex flex-col gap-4"
456
+ }, Rs = /* @__PURE__ */ le({
457
+ __name: "TransferItem",
458
+ props: {
459
+ cellByColId: {},
460
+ comparePriceBySku: {},
461
+ showComparePrice: { type: Boolean },
462
+ row: {}
463
+ },
464
+ setup(y) {
465
+ const { t: _ } = ce();
466
+ return (n, r) => {
467
+ var u, h, k, i, s, a, b, m, p, S, F, d, f, M, z, R, V, X, O, q, H, U, C, w, Y, ie, se;
468
+ const g = I("FmLabel"), e = I("FmSpacer");
469
+ return x(), D("div", ks, [
470
+ l("div", Cs, [
471
+ l("div", Ss, [
472
+ l("span", ws, " (" + P(n.row.original.sku.code) + ") ", 1),
473
+ l("span", Fs, P(n.row.original.sku.name), 1)
474
+ ]),
475
+ l("div", null, [
476
+ c(t(de), {
477
+ render: (k = (h = (u = n.cellByColId.Delete) == null ? void 0 : u.column) == null ? void 0 : h.columnDef) == null ? void 0 : k.cell,
478
+ props: (s = (i = n.cellByColId.Delete) == null ? void 0 : i.getContext) == null ? void 0 : s.call(i)
479
+ }, null, 8, ["render", "props"])
480
+ ])
481
+ ]),
482
+ l("div", $s, [
483
+ l("div", Is, [
484
+ c(g, {
485
+ label: t(_)(`inventory.transfer.form.items.table.${t(Z).Code}`)
486
+ }, null, 8, ["label"]),
487
+ c(t(de), {
488
+ render: (m = (b = (a = n.cellByColId[t(Z).Code]) == null ? void 0 : a.column) == null ? void 0 : b.columnDef) == null ? void 0 : m.cell,
489
+ props: (S = (p = n.cellByColId[t(Z).Code]) == null ? void 0 : p.getContext) == null ? void 0 : S.call(p)
490
+ }, null, 8, ["render", "props"]),
491
+ r[0] || (r[0] = l("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
492
+ ]),
493
+ l("div", Ds, [
494
+ c(g, {
495
+ label: t(_)(`inventory.transfer.form.items.table.${t(Z).Name}`)
496
+ }, null, 8, ["label"]),
497
+ c(t(de), {
498
+ render: (f = (d = (F = n.cellByColId[t(Z).Name]) == null ? void 0 : F.column) == null ? void 0 : d.columnDef) == null ? void 0 : f.cell,
499
+ props: (z = (M = n.cellByColId[t(Z).Name]) == null ? void 0 : M.getContext) == null ? void 0 : z.call(M)
500
+ }, null, 8, ["render", "props"]),
501
+ r[1] || (r[1] = l("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
502
+ ])
503
+ ]),
504
+ l("div", Ts, [
505
+ l("div", Vs, [
506
+ c(g, {
507
+ label: t(_)(`inventory.transfer.form.items.table.${t(Z).Amount}`)
508
+ }, null, 8, ["label"]),
509
+ c(t(de), {
510
+ render: (X = (V = (R = n.cellByColId[t(Z).Amount]) == null ? void 0 : R.column) == null ? void 0 : V.columnDef) == null ? void 0 : X.cell,
511
+ props: (q = (O = n.cellByColId[t(Z).Amount]) == null ? void 0 : O.getContext) == null ? void 0 : q.call(O)
512
+ }, null, 8, ["render", "props"]),
513
+ r[2] || (r[2] = l("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
514
+ ]),
515
+ n.cellByColId[t(Z).Cost] ? (x(), D("div", Ps, [
516
+ c(kt, { "z-index": 50 }, {
517
+ default: T(() => [
518
+ c(g, {
519
+ label: t(_)(`inventory.transfer.form.items.table.${t(Z).Cost}2`)
520
+ }, null, 8, ["label"])
521
+ ]),
522
+ _: 1
523
+ }),
524
+ c(t(de), {
525
+ render: (C = (U = (H = n.cellByColId[t(Z).Cost]) == null ? void 0 : H.column) == null ? void 0 : U.columnDef) == null ? void 0 : C.cell,
526
+ props: (Y = (w = n.cellByColId[t(Z).Cost]) == null ? void 0 : w.getContext) == null ? void 0 : Y.call(w)
527
+ }, null, 8, ["render", "props"]),
528
+ r[3] || (r[3] = l("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
529
+ ])) : L("", !0)
530
+ ]),
531
+ n.showComparePrice && Object.keys(n.comparePriceBySku[(ie = n.row.original.sku) == null ? void 0 : ie._id] ?? {}).length > 0 ? (x(), D(ae, { key: 0 }, [
532
+ c(e, { class: "h-8" }),
533
+ c(Ft, {
534
+ prices: n.comparePriceBySku[(se = n.row.original.sku) == null ? void 0 : se._id]
535
+ }, null, 8, ["prices"])
536
+ ], 64)) : L("", !0)
537
+ ]);
538
+ };
539
+ }
540
+ });
541
+ function As(y) {
542
+ const _ = E({
543
+ get() {
544
+ const e = y.getEffectiveAt();
545
+ return e ? new Date(e) : null;
546
+ },
547
+ set(e) {
548
+ y.setEffectiveAt((e == null ? void 0 : e.toISOString()) ?? null);
549
+ }
550
+ }), n = E({
551
+ get() {
552
+ return !!_.value;
553
+ },
554
+ set(e) {
555
+ e ? _.value = /* @__PURE__ */ new Date() : _.value = null;
556
+ }
557
+ }), r = E({
558
+ get() {
559
+ return _.value === null ? "" : Ze(_.value);
560
+ },
561
+ set(e) {
562
+ e ? _.value = /* @__PURE__ */ new Date(`${e} ${g.value}`) : _.value = null;
563
+ }
564
+ }), g = E({
565
+ get() {
566
+ return _.value === null ? "" : Et(_.value);
567
+ },
568
+ set(e) {
569
+ e ? _.value = /* @__PURE__ */ new Date(`${r.value} ${e}`) : _.value = null;
570
+ }
571
+ });
572
+ return {
573
+ backdatePo: _,
574
+ backdateSwitch: n,
575
+ backdateModel: r,
576
+ backdateTimeModel: g
577
+ };
578
+ }
579
+ const Es = {
580
+ width: "24",
581
+ height: "24",
582
+ viewBox: "0 0 24 24",
583
+ fill: "none",
584
+ xmlns: "http://www.w3.org/2000/svg"
585
+ }, Ms = ["fill"], Us = ["fill"], qs = ["stroke"], Os = ["stroke"], Ns = /* @__PURE__ */ le({
586
+ __name: "SparkIcon",
587
+ props: {
588
+ size: {
589
+ type: Number,
590
+ default: 24
591
+ },
592
+ color: {
593
+ type: String,
594
+ default: "#c7c7cc"
595
+ }
596
+ },
597
+ setup(y) {
598
+ return (_, n) => (x(), D("svg", Es, [
599
+ l("path", {
600
+ 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",
601
+ fill: y.color
602
+ }, null, 8, Ms),
603
+ l("path", {
604
+ 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",
605
+ fill: y.color
606
+ }, null, 8, Us),
607
+ l("path", {
608
+ 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",
609
+ stroke: y.color,
610
+ "stroke-width": "1.5",
611
+ "stroke-linecap": "round",
612
+ "stroke-linejoin": "round"
613
+ }, null, 8, qs),
614
+ l("path", {
615
+ 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",
616
+ stroke: y.color,
617
+ "stroke-width": "1.5",
618
+ "stroke-linecap": "round",
619
+ "stroke-linejoin": "round"
620
+ }, null, 8, Os)
621
+ ]));
622
+ }
623
+ }), Bs = { class: "flex gap-8 items-center" }, Ls = { class: "fm-typo-en-body-lg-600 line-clamp-1" }, zs = { class: "w-[343px] px-24 py-16 rounded-lg shadow-light-300 flex flex-col gap-[20px]" }, Hs = { class: "flex items-center w-full" }, js = { class: "flex-1" }, Ys = { class: "fm-typo-en-title-sm-800" }, Ks = { class: "flex items-start gap-8" }, Qs = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Xs = { class: "flex gap-1" }, pt = /* @__PURE__ */ le({
624
+ __name: "ForecastStock",
625
+ props: {
626
+ disabled: { type: Boolean }
627
+ },
628
+ emits: ["update:poItems"],
629
+ setup(y, { emit: _ }) {
630
+ const n = _, r = A(!1), g = A(7), e = es(), u = $e(), h = Le(), { t: k } = ce();
631
+ async function i() {
632
+ if (g.value < 1)
633
+ return;
634
+ r.value = !1, await e.readPurchaseOrder(g.value);
635
+ const s = [];
636
+ if (e.purchaseOrderForecast.skus.length <= 0) {
637
+ u.open({
638
+ message: k("inventory.transfer.form.items.forecastStock.notAvailable"),
639
+ type: "info"
640
+ });
641
+ return;
642
+ }
643
+ const a = e.purchaseOrderForecast.skus.reduce((b, m) => {
644
+ const p = h.skus.find((d) => d._id === m.id);
645
+ if (b.find((d) => d.sku._id === m.id) || !p)
646
+ return b;
647
+ const F = {
648
+ sku: p,
649
+ code: p.code,
650
+ name: p.name,
651
+ quantity: {
652
+ amount: m.amount,
653
+ precision: 0
654
+ }
655
+ };
656
+ return b.push(F), b;
657
+ }, s);
658
+ n("update:poItems", a);
659
+ }
660
+ return (s, a) => {
661
+ const b = I("FmButton"), m = I("FmIcon"), p = I("FmStepperField"), S = I("FmPopover");
662
+ return x(), Q(S, {
663
+ disabled: s.disabled,
664
+ class: "flex",
665
+ "show-popover": r.value,
666
+ onPopoverChanged: a[3] || (a[3] = (F) => r.value = F)
667
+ }, {
668
+ "popover-button": T(() => [
669
+ c(b, {
670
+ label: "unused",
671
+ variant: "secondary",
672
+ "text-color": s.disabled ? "disabled" : "primary",
673
+ "bg-color": "transparent",
674
+ "border-color": s.disabled ? "disabled" : "primary",
675
+ disabled: s.disabled
676
+ }, {
677
+ default: T(() => [
678
+ l("div", Bs, [
679
+ c(Ns, {
680
+ size: 24,
681
+ color: s.disabled ? "#c7c7cc" : "#ff7823"
682
+ }, null, 8, ["color"]),
683
+ l("div", Ls, P(t(k)("inventory.transfer.form.items.forecastStock.title")), 1)
684
+ ])
685
+ ]),
686
+ _: 1
687
+ }, 8, ["text-color", "border-color", "disabled"])
688
+ ]),
689
+ default: T(() => [
690
+ l("div", zs, [
691
+ l("div", Hs, [
692
+ l("div", js, [
693
+ c(ms, { "z-index": 99 }, {
694
+ default: T(() => [
695
+ l("p", Ys, P(t(k)("inventory.transfer.form.items.forecastStock.title")), 1)
696
+ ]),
697
+ _: 1
698
+ })
699
+ ]),
700
+ c(b, {
701
+ icon: "close",
702
+ size: "md",
703
+ variant: "tertiary",
704
+ onClick: a[0] || (a[0] = (F) => r.value = !1)
705
+ })
706
+ ]),
707
+ c(p, {
708
+ modelValue: g.value,
709
+ "onUpdate:modelValue": a[1] || (a[1] = (F) => g.value = F),
710
+ label: t(k)("inventory.transfer.form.items.forecastStock.days"),
711
+ rules: [t(Ne)(1)]
712
+ }, {
713
+ "helper-text": T(() => [
714
+ l("div", Ks, [
715
+ c(m, {
716
+ name: "warning",
717
+ size: "sm",
718
+ class: "text-fm-color-system-warning-300"
719
+ }),
720
+ l("div", Qs, P(t(k)("inventory.transfer.form.items.forecastStock.replace")), 1)
721
+ ])
722
+ ]),
723
+ _: 1
724
+ }, 8, ["modelValue", "label", "rules"]),
725
+ l("div", Xs, [
726
+ a[4] || (a[4] = l("div", { class: "grow" }, null, -1)),
727
+ c(b, {
728
+ label: t(k)("common.cancel"),
729
+ variant: "tertiary",
730
+ onClick: a[2] || (a[2] = (F) => r.value = !1)
731
+ }, null, 8, ["label"]),
732
+ c(b, {
733
+ label: t(k)("inventory.transfer.form.items.forecastStock.generate"),
734
+ onClick: i
735
+ }, null, 8, ["label"])
736
+ ])
737
+ ])
738
+ ]),
739
+ _: 1
740
+ }, 8, ["disabled", "show-popover"]);
741
+ };
742
+ }
743
+ });
744
+ function Zs() {
745
+ const y = $e(), _ = We(), n = A(!1);
746
+ ve(n, (u) => {
747
+ u && (g.value = !0, r().finally(() => {
748
+ g.value = !1;
749
+ }));
750
+ });
751
+ async function r() {
752
+ try {
753
+ const { startDate: u, endDate: h } = Mt(6), s = (await _.getPurchaseOrders({ start: u, end: h })).filter(
754
+ (a) => {
755
+ var b, m;
756
+ return a.status === Ut.enum.COMPLETE && ((b = a.supplier) == null ? void 0 : b.internal) !== "warehouse" && ((m = a.supplier) == null ? void 0 : m.internal) !== "restaurant";
757
+ }
758
+ ).reduce((a, b) => {
759
+ const m = new Date(qt(b._id)), p = b.supplier._id;
760
+ for (const S of b.items) {
761
+ if (!S.totalCost) continue;
762
+ const F = a[S.sku._id] ?? {}, d = F[p] ?? [];
763
+ d.push({
764
+ date: m.toISOString(),
765
+ totalUnit: S.quantity,
766
+ totalCost: S.totalCost,
767
+ unit: S.sku.unit,
768
+ measurement: S.measurement,
769
+ seqNumber: b.seqNumber
770
+ }), F[p] = d, a[S.sku._id] = F;
771
+ }
772
+ return a;
773
+ }, {});
774
+ e.value = s;
775
+ } catch {
776
+ y.open({
777
+ title: "Something went wrong",
778
+ message: "Cannot retrieve supplier purchase history. Please try again."
779
+ }), n.value = !1;
780
+ }
781
+ }
782
+ const g = A(!1), e = A({});
783
+ return {
784
+ comparePricesToggle: n,
785
+ comparePriceFetching: g,
786
+ comparePriceBySku: e
787
+ };
788
+ }
789
+ const Gs = { class: "fm-typo-body-md-400 line-clamp-2 w-full" }, Ws = { key: 0 }, Js = ["colspan"], eo = /* @__PURE__ */ le({
790
+ __name: "TransferItemTable",
791
+ props: {
792
+ templateItem: {},
793
+ row: {},
794
+ comparePriceBySku: {},
795
+ showComparePrice: { type: Boolean },
796
+ disabled: { type: Boolean }
797
+ },
798
+ emits: ["update:item"],
799
+ setup(y) {
800
+ function _(n) {
801
+ return n.column.columnDef.meta;
802
+ }
803
+ return (n, r) => {
804
+ var g, e;
805
+ return x(), D(ae, null, [
806
+ l("tr", {
807
+ class: K(["border-b border-fm-color-neutral-gray-100 hover:bg-fm-color-opacity-sm", {
808
+ "bg-fm-color-neutral-gray-100": n.row.getIsSelected()
809
+ }])
810
+ }, [
811
+ (x(!0), D(ae, null, Ce(n.row.getVisibleCells(), (u) => {
812
+ var h, k, i, s;
813
+ return x(), D("td", {
814
+ key: u.id,
815
+ class: K(["h-[56px] text-fm-color-typo-primary", ((h = _(u)) == null ? void 0 : h.cellClass) ?? "px-16"]),
816
+ style: bt({
817
+ width: (k = _(u)) == null ? void 0 : k.width,
818
+ maxWidth: (i = _(u)) == null ? void 0 : i.maxWidth,
819
+ textAlign: ((s = _(u)) == null ? void 0 : s.textAlign) ?? "left"
820
+ })
821
+ }, [
822
+ l("span", Gs, [
823
+ c(t(de), {
824
+ render: u.column.columnDef.cell,
825
+ props: u.getContext()
826
+ }, null, 8, ["render", "props"])
827
+ ])
828
+ ], 6);
829
+ }), 128))
830
+ ], 2),
831
+ n.showComparePrice && Object.keys(n.comparePriceBySku[(g = n.row.original.sku) == null ? void 0 : g._id] ?? {}).length > 0 ? (x(), D("tr", Ws, [
832
+ l("td", {
833
+ colspan: n.row.getVisibleCells().length
834
+ }, [
835
+ c(Ft, {
836
+ prices: n.comparePriceBySku[(e = n.row.original.sku) == null ? void 0 : e._id]
837
+ }, null, 8, ["prices"])
838
+ ], 8, Js)
839
+ ])) : L("", !0)
840
+ ], 64);
841
+ };
842
+ }
843
+ }), to = {
844
+ key: 0,
845
+ class: "flex flex-col gap-8"
846
+ }, so = { class: "flex flex-col gap-4" }, oo = { class: "flex items-center gap-4" }, ao = {
847
+ key: 0,
848
+ class: "fm-typo-en-body-sm-400 text-fm-color-typo-error"
849
+ }, lo = /* @__PURE__ */ le({
850
+ __name: "NetSuiteField",
851
+ props: {
852
+ required: { type: Boolean },
853
+ disabled: { type: Boolean },
854
+ supplier: {},
855
+ setting: {},
856
+ items: {},
857
+ onChange: { type: Function }
858
+ },
859
+ emits: ["netsuite:ready"],
860
+ setup(y, { emit: _ }) {
861
+ const n = Be(), r = y, g = _, { t: e } = ps(), u = A(!1), h = A();
862
+ Qe(() => {
863
+ var a, b, m, p;
864
+ let s = {
865
+ id: "",
866
+ subsidiary: { id: "", name: "" },
867
+ errors: []
868
+ };
869
+ if (!n.isEnabled || !r.required) {
870
+ g("netsuite:ready", s);
871
+ return;
872
+ }
873
+ try {
874
+ const S = n.currentLocationSubsidiary();
875
+ r.setting ? s = {
876
+ ...r.setting,
877
+ subsidiary: {
878
+ id: S.id || "",
879
+ name: S.name
880
+ }
881
+ } : s = {
882
+ ...s,
883
+ subsidiary: {
884
+ id: S.id || "",
885
+ name: S.name
886
+ }
887
+ };
888
+ const F = n.getAvailableItems(S.id), d = r.items.filter((f) => {
889
+ if (f.measurement != null) {
890
+ const M = n.getAvailableMeasurements(
891
+ f.sku._id,
892
+ S.id
893
+ );
894
+ return F.includes(f.sku._id) && M.includes(f.measurement.id);
895
+ }
896
+ return F.includes(f.sku._id);
897
+ }).map((f) => f.sku._id);
898
+ r.onChange(
899
+ r.items.filter((f) => d.includes(f.sku._id)),
900
+ s
901
+ );
902
+ } finally {
903
+ r.supplier.internal ? h.value = n.getNetSuiteLocation(
904
+ `${r.supplier.internal}_${r.supplier._id}`
905
+ ) : h.value = n.getNetSuiteVendor(r.supplier._id);
906
+ const S = r.supplier.internal ? n.getLocationSubsidiary((a = h.value) == null ? void 0 : a.netSuiteId).id : (b = h.value) == null ? void 0 : b.subsidiaryId, F = r.supplier.internal ? (m = n.currentLocationSubsidiary()) == null ? void 0 : m.id : (p = n.currentVendorSubsidiary(r.supplier._id)) == null ? void 0 : p.id;
907
+ !n.isEnabled || S && n.isEnabled && S == F ? g("netsuite:ready", s) : u.value = !0;
908
+ }
909
+ });
910
+ const k = E(
911
+ () => r.supplier.internal ? n.currentLocationSubsidiary() : n.currentVendorSubsidiary(r.supplier._id)
912
+ ), i = E(() => {
913
+ var s, a;
914
+ return h.value == null ? `Cannot find the NetSuite location for "${r.supplier.name}"` : `The subsidiary of the request
915
+ location is ${(a = n.getLocationSubsidiary((s = h.value) == null ? void 0 : s.netSuiteId)) == null ? void 0 : a.fullName}`;
916
+ });
917
+ return (s, a) => {
918
+ const b = I("FmLabel"), m = I("FmIcon"), p = I("FmField"), S = I("FmTooltip");
919
+ return t(n).isEnabled && r.required ? (x(), D("div", to, [
920
+ c(b, {
921
+ label: `NetSuite ${t(e)("inventory.transfer.form.netsuite.subsidiary")}`
922
+ }, null, 8, ["label"]),
923
+ l("div", so, [
924
+ c(S, {
925
+ "z-index": 51,
926
+ placement: "left",
927
+ disabled: s.disabled
928
+ }, {
929
+ content: T(() => a[0] || (a[0] = [
930
+ Fe("This field is locked and based on the location of the request.")
931
+ ])),
932
+ default: T(() => [
933
+ c(p, null, {
934
+ default: T(() => {
935
+ var F;
936
+ return [
937
+ l("div", oo, [
938
+ c(m, {
939
+ name: "lock_outline",
940
+ size: "sm",
941
+ color: s.disabled ? "neutral-gray-200" : "neutral-gray-400"
942
+ }, null, 8, ["color"]),
943
+ l("div", {
944
+ class: K([s.disabled ? "text-fm-color-typo-disabled" : ""])
945
+ }, P((F = k.value) == null ? void 0 : F.fullName), 3)
946
+ ])
947
+ ];
948
+ }),
949
+ _: 1
950
+ })
951
+ ]),
952
+ _: 1
953
+ }, 8, ["disabled"]),
954
+ u.value ? (x(), D("div", ao, P(i.value), 1)) : L("", !0)
955
+ ])
956
+ ])) : L("", !0);
957
+ };
958
+ }
959
+ }), no = { class: "flex flex-col gap-4" }, ro = { class: "flex items-center gap-8 overflow-x-auto pb-12" }, io = { class: "flex flex-col gap-16" }, uo = { class: "flex flex-col gap-24" }, co = { class: "flex flex-col gap-8" }, mo = { class: "flex flex-col gap-4" }, po = { class: "flex items-center gap-4" }, fo = { class: "flex flex-col gap-8" }, vo = { class: "flex flex-col gap-4" }, yo = { class: "flex items-center gap-4" }, bo = {
960
+ key: 3,
961
+ class: "p-16 border border-fm-color-neutral-gray-300 fm-corner-radius-md flex flex-col"
962
+ }, go = {
963
+ key: 0,
964
+ class: "flex-1 flex gap-8 h-48 xs:flex-col xs:pt-16 sm:flex-col sm:pt-16"
965
+ }, _o = { class: "flex-1" }, ho = { class: "flex-1" }, xo = {
966
+ key: 1,
967
+ class: "flex items-center gap-4"
968
+ }, ko = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary translate-y-[1px]" }, Co = { class: "flex flex-col gap-16" }, So = { class: "flex-1 gap-8 fm-typo-en-title-sm-600" }, wo = { class: "flex gap-8" }, Fo = { key: 0 }, $o = /* @__PURE__ */ le({
969
+ __name: "TransferForm2",
970
+ props: {
971
+ modelValue: {},
972
+ request: {},
973
+ disabled: { type: Boolean },
974
+ suppliers: {},
975
+ skus: {},
976
+ lastClosingDate: {}
977
+ },
978
+ emits: ["validation-success", "form:ready"],
979
+ setup(y, { expose: _, emit: n }) {
980
+ const r = y, g = n, e = ht(), { t: u } = ce(), h = Ge(), k = Le(), i = Be(), s = tt(), a = et(), b = wt(), { breakpoints: m } = Je(), p = E(() => m.value.xs || m.value.sm), S = yt({
981
+ value: !1
982
+ }), F = A(!1), d = E(
983
+ () => {
984
+ var o;
985
+ return ((o = r.modelValue) == null ? void 0 : o.templateDoc) ?? b.templates.find((v) => v._id === e.template);
986
+ }
987
+ ), f = E(() => e.status === "DRAFT" || !e._rev);
988
+ ve(d, (o) => {
989
+ o && f.value && (e.supplier = (o == null ? void 0 : o.purchaseOrder.supplier) ?? e.supplier);
990
+ }), Qe(() => {
991
+ var o;
992
+ try {
993
+ if (!e.template) return;
994
+ e.items.length || (e.items = ((o = d.value) == null ? void 0 : o.purchaseOrder.items) ?? []);
995
+ } finally {
996
+ F.value = !0;
997
+ }
998
+ }), ve([F, S], ([o, v], [B, ne]) => {
999
+ v.value && ne.value && g("form:ready");
1000
+ });
1001
+ const M = E(
1002
+ () => h.currentLocation.type === Ot.restaurant
1003
+ );
1004
+ h.watchLocation(async () => {
1005
+ location && (e.supplier || (e.supplier = s.suppliers.find((o) => o) ?? e.supplier));
1006
+ });
1007
+ const z = Ct(), R = us(
1008
+ () => e,
1009
+ (o) => {
1010
+ Object.assign(e, o);
1011
+ },
1012
+ !0,
1013
+ !0
1014
+ ), V = E({
1015
+ get() {
1016
+ var o;
1017
+ return typeof ((o = e == null ? void 0 : e.supplier) == null ? void 0 : o.internal) == "string" ? ee.TRANSFER : ee.PURCHASE;
1018
+ },
1019
+ set(o) {
1020
+ var B;
1021
+ const v = typeof ((B = e == null ? void 0 : e.supplier) == null ? void 0 : B.internal) == "string" ? ee.TRANSFER : ee.PURCHASE;
1022
+ o !== v && (e.supplier = o === ee.PURCHASE ? R.locationOptionsTypePurchase.value[0] : R.locationOptionsTypeTransfer.value[0]);
1023
+ }
1024
+ });
1025
+ ve(
1026
+ () => {
1027
+ var o;
1028
+ return (o = r.modelValue) == null ? void 0 : o.template;
1029
+ },
1030
+ (o) => {
1031
+ a.mustUsePoTemplate && !o && $t(() => {
1032
+ var v, B;
1033
+ e.supplier = ((B = (v = R.locationOptionsTypeTransfer.value) == null ? void 0 : v.filter(
1034
+ (ne) => ne.internal === "restaurant"
1035
+ )) == null ? void 0 : B[0]) ?? e.supplier;
1036
+ });
1037
+ },
1038
+ { immediate: !0 }
1039
+ );
1040
+ const X = E(() => {
1041
+ let o = R.transferLocationOptions.value;
1042
+ return a.mustUsePoTemplate && !e.template && (o = o.filter((v) => {
1043
+ var B;
1044
+ return (B = v.sublabel) == null ? void 0 : B.startsWith("restaurant");
1045
+ })), o;
1046
+ }), O = E({
1047
+ get() {
1048
+ return e.supplier._id;
1049
+ },
1050
+ set(o) {
1051
+ R.transferLocationModel.value = o;
1052
+ }
1053
+ }), q = E({
1054
+ get() {
1055
+ return e.remark ?? void 0;
1056
+ },
1057
+ set(o) {
1058
+ e.remark = o;
1059
+ }
1060
+ }), { backdatePo: H, backdateSwitch: U, backdateModel: C, backdateTimeModel: w } = As({
1061
+ getEffectiveAt() {
1062
+ return e.effectiveAt;
1063
+ },
1064
+ setEffectiveAt(o) {
1065
+ e.effectiveAt = o;
1066
+ }
1067
+ }), { comparePricesToggle: Y, comparePriceFetching: ie, comparePriceBySku: se } = Zs(), ye = A();
1068
+ _({
1069
+ validateInputs: () => {
1070
+ var o, v;
1071
+ (v = (o = ye.value) == null ? void 0 : o.validateInputs) == null || v.call(o);
1072
+ },
1073
+ resetInputsValidation: () => {
1074
+ var o, v;
1075
+ (v = (o = ye.value) == null ? void 0 : o.resetInputsValidation) == null || v.call(o);
1076
+ },
1077
+ resetInputs: () => {
1078
+ var o, v;
1079
+ (v = (o = ye.value) == null ? void 0 : o.resetInputs) == null || v.call(o);
1080
+ }
1081
+ });
1082
+ const Se = E(() => ({
1083
+ updateItem: (o) => {
1084
+ const v = Nt.parse(o);
1085
+ e.items = e.items.map((B) => B.sku._id !== o.sku._id ? B : v);
1086
+ },
1087
+ deleteItem: (o) => {
1088
+ e.items = e.items.filter((v) => v.sku._id !== o.sku._id);
1089
+ }
1090
+ })), we = ys({
1091
+ updateItem: (o) => Se.value.updateItem(o),
1092
+ deleteItem: (o) => Se.value.deleteItem(o),
1093
+ get supplier() {
1094
+ return e.supplier;
1095
+ },
1096
+ get items() {
1097
+ return e.items;
1098
+ },
1099
+ get transferType() {
1100
+ return V.value;
1101
+ },
1102
+ get template() {
1103
+ return d.value;
1104
+ },
1105
+ get disabled() {
1106
+ return r.disabled;
1107
+ }
1108
+ }), Ae = E(() => {
1109
+ let o = we.columnDefs.value;
1110
+ return i.isEnabled && V.value === ee.TRANSFER && (o = o.filter((v) => v.id !== Z.TotalCost)), o;
1111
+ });
1112
+ function Ee() {
1113
+ var fe, Ie, Ue, qe, De;
1114
+ const o = (Ue = (Ie = (fe = d.value) == null ? void 0 : fe.purchaseOrder) == null ? void 0 : Ie.items) == null ? void 0 : Ue.groupBy((N) => N.sku._id), v = i.isEnabled ? i.getAvailableItems((De = (qe = e.netSuite) == null ? void 0 : qe.subsidiary) == null ? void 0 : De.id) : [], B = o != null && o.size ? k.skus.filter((N) => o.has(N._id)) : k.skus, ne = i.isEnabled ? B.filter((N) => {
1115
+ var te, W, oe, ue;
1116
+ const G = (W = (te = d.value) == null ? void 0 : te.purchaseOrder) == null ? void 0 : W.items.find(
1117
+ (me) => me.sku._id === N._id
1118
+ );
1119
+ if (G != null && G.measurement != null) {
1120
+ const me = i.getAvailableMeasurements(
1121
+ G.sku._id,
1122
+ (ue = (oe = e.netSuite) == null ? void 0 : oe.subsidiary) == null ? void 0 : ue.id
1123
+ );
1124
+ return v.includes(G.sku._id) && me.includes(G.measurement.id);
1125
+ }
1126
+ return v.includes(N._id);
1127
+ }).map((N) => N._id) : B.map((N) => N._id), re = B.map(
1128
+ (N) => {
1129
+ var G, te, W, oe;
1130
+ return {
1131
+ label: ((te = (G = o == null ? void 0 : o.get(N._id)) == null ? void 0 : G[0]) == null ? void 0 : te.name) ?? N.name,
1132
+ sublabel: ((oe = (W = o == null ? void 0 : o.get(N._id)) == null ? void 0 : W[0]) == null ? void 0 : oe.code) ?? N.code,
1133
+ value: N,
1134
+ disabled: !ne.includes(N._id)
1135
+ };
1136
+ }
1137
+ ), ge = re.filter((N) => {
1138
+ var G;
1139
+ return (G = e.items) == null ? void 0 : G.find((te) => te.sku._id === N.value._id);
1140
+ }).map((N) => N.value);
1141
+ z.open({
1142
+ title: u("inventory.transfer.form.items.selectItem"),
1143
+ closeButton: !0,
1144
+ contentComponent: Ke,
1145
+ contentComponentProps: {
1146
+ modelValue: ge,
1147
+ items: re,
1148
+ virtualScroll: !0
1149
+ },
1150
+ primaryActions: {
1151
+ text: u("common.confirm"),
1152
+ close: !0
1153
+ },
1154
+ secondaryActions: {
1155
+ text: u("common.close"),
1156
+ close: !0,
1157
+ variant: "tertiary"
1158
+ }
1159
+ }).onPrimary((N) => {
1160
+ const G = e.items ?? [], te = N.map((W) => {
1161
+ var me, Te;
1162
+ const oe = G.find((_e) => _e.sku._id === W._id);
1163
+ if (oe)
1164
+ return oe;
1165
+ const ue = ((Te = (me = d.value) == null ? void 0 : me.purchaseOrder.items) == null ? void 0 : Te.find(
1166
+ (_e) => _e.sku._id === W._id
1167
+ )) ?? {
1168
+ sku: W,
1169
+ code: W.code,
1170
+ name: W.name,
1171
+ quantity: {
1172
+ amount: 1,
1173
+ precision: 0
1174
+ }
1175
+ };
1176
+ return V.value == ee.PURCHASE && (ue.totalCost = he(
1177
+ ue.sku,
1178
+ ue.quantity,
1179
+ ue.measurement,
1180
+ {
1181
+ supplier: e.supplier
1182
+ }
1183
+ )), ue;
1184
+ });
1185
+ te.sort((W, oe) => W.sku.code.localeCompare(oe.sku.code)), e.items = te;
1186
+ });
1187
+ }
1188
+ function ze(o) {
1189
+ return o;
1190
+ }
1191
+ const Me = E(() => {
1192
+ const o = [];
1193
+ return (!a.mustUsePoTemplate || a.mustUsePoTemplate && e.template) && o.push({
1194
+ label: u("inventory.transfer.form.type.purchase"),
1195
+ value: ee.PURCHASE
1196
+ }), o.push({
1197
+ label: u("inventory.transfer.form.type.transfer"),
1198
+ value: ee.TRANSFER
1199
+ }), o;
1200
+ }), be = E(() => {
1201
+ var o;
1202
+ return (o = r.modelValue) == null ? void 0 : o.items.every((v) => v.quantity.amount <= 0);
1203
+ });
1204
+ return (o, v) => {
1205
+ var me, Te;
1206
+ const B = I("FmChip"), ne = I("FmLabel"), re = I("FmIcon"), ge = I("FmField"), fe = I("FmTooltip"), Ie = I("FmSelect"), Ue = I("FmTextField"), qe = I("FmTextarea"), De = I("FmSwitch"), N = I("FmDatePicker"), G = I("FmTimePicker"), te = I("FmFormGroup"), W = I("FmButton"), oe = I("FmTable"), ue = I("FmForm");
1207
+ return x(), D("div", no, [
1208
+ l("div", ro, [
1209
+ (me = r.modelValue) != null && me.template ? (x(), Q(B, {
1210
+ key: 0,
1211
+ variant: o.disabled ? "warning" : void 0,
1212
+ label: `${t(u)("inventory.transfer.template.title")}: ${((Te = d.value) == null ? void 0 : Te.name) ?? t(u)("inventory.transfer.form.loading")}`,
1213
+ icon: "summarize",
1214
+ compact: ""
1215
+ }, null, 8, ["variant", "label"])) : L("", !0),
1216
+ c(B, {
1217
+ label: t(h).currentLocation.name,
1218
+ icon: "storefront",
1219
+ compact: ""
1220
+ }, null, 8, ["label"]),
1221
+ o.lastClosingDate ? (x(), Q(B, {
1222
+ key: 1,
1223
+ label: `${t(u)("inventory.transfer.form.lastClosing")}: ${t(Ze)(o.lastClosingDate)} ${t(Bt)(o.lastClosingDate)}`,
1224
+ icon: "calendar_month",
1225
+ compact: ""
1226
+ }, null, 8, ["label"])) : L("", !0)
1227
+ ]),
1228
+ c(ue, {
1229
+ ref_key: "formRef",
1230
+ ref: ye,
1231
+ class: "flex flex-col gap-32",
1232
+ disabled: o.disabled,
1233
+ onValidationFailed: console.log,
1234
+ onValidationSuccess: v[14] || (v[14] = (_e) => g("validation-success"))
1235
+ }, {
1236
+ default: T(() => {
1237
+ var _e, st, ot, at, lt, nt, rt, it;
1238
+ return [
1239
+ l("div", io, [
1240
+ l("div", uo, [
1241
+ (_e = r.modelValue) != null && _e.template ? (x(), D(ae, { key: 0 }, [
1242
+ l("div", co, [
1243
+ c(ne, {
1244
+ label: t(u)("inventory.transfer.form.type.title")
1245
+ }, null, 8, ["label"]),
1246
+ l("div", mo, [
1247
+ c(fe, {
1248
+ "z-index": 51,
1249
+ placement: "left",
1250
+ disabled: o.disabled
1251
+ }, {
1252
+ content: T(() => v[15] || (v[15] = [
1253
+ Fe("This field is locked from template.")
1254
+ ])),
1255
+ default: T(() => [
1256
+ c(ge, null, {
1257
+ default: T(() => [
1258
+ l("div", po, [
1259
+ c(re, {
1260
+ name: "lock_outline",
1261
+ size: "sm",
1262
+ color: o.disabled ? "neutral-gray-200" : "neutral-gray-400"
1263
+ }, null, 8, ["color"]),
1264
+ l("div", {
1265
+ class: K({ "text-fm-color-typo-disabled": o.disabled })
1266
+ }, P(t(u)(`inventory.transfer.form.type.${V.value.toLocaleLowerCase("en-us")}`)), 3)
1267
+ ])
1268
+ ]),
1269
+ _: 1
1270
+ })
1271
+ ]),
1272
+ _: 1
1273
+ }, 8, ["disabled"]),
1274
+ l("div", {
1275
+ class: K([
1276
+ "fm-typo-en-body-sm-400",
1277
+ o.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-typo-secondary"
1278
+ ])
1279
+ }, null, 2)
1280
+ ])
1281
+ ]),
1282
+ l("div", fo, [
1283
+ c(ne, {
1284
+ label: V.value === t(ee).PURCHASE ? t(u)("inventory.transfer.form.purchaseFrom") : t(u)("inventory.transfer.form.transferFrom")
1285
+ }, null, 8, ["label"]),
1286
+ l("div", vo, [
1287
+ c(fe, {
1288
+ "z-index": 51,
1289
+ placement: "left",
1290
+ disabled: o.disabled
1291
+ }, {
1292
+ content: T(() => v[16] || (v[16] = [
1293
+ Fe("This field is locked from template.")
1294
+ ])),
1295
+ default: T(() => [
1296
+ c(ge, null, {
1297
+ default: T(() => {
1298
+ var $;
1299
+ return [
1300
+ l("div", yo, [
1301
+ c(re, {
1302
+ name: "lock_outline",
1303
+ size: "sm",
1304
+ color: o.disabled ? "neutral-gray-200" : "neutral-gray-400"
1305
+ }, null, 8, ["color"]),
1306
+ l("div", {
1307
+ class: K({ "text-fm-color-typo-disabled": o.disabled })
1308
+ }, P(($ = X.value.find((J) => J.value === O.value)) == null ? void 0 : $.label), 3)
1309
+ ])
1310
+ ];
1311
+ }),
1312
+ _: 1
1313
+ })
1314
+ ]),
1315
+ _: 1
1316
+ }, 8, ["disabled"])
1317
+ ])
1318
+ ])
1319
+ ], 64)) : (x(), D(ae, { key: 1 }, [
1320
+ c(Ie, {
1321
+ label: t(u)("inventory.transfer.form.type.title"),
1322
+ "label-mark": "required",
1323
+ modelValue: V.value,
1324
+ "onUpdate:modelValue": v[0] || (v[0] = ($) => V.value = $),
1325
+ items: Me.value,
1326
+ rules: [t(Ne)(1)(X.value)]
1327
+ }, {
1328
+ default: T(() => [
1329
+ l("span", {
1330
+ class: K([
1331
+ "line-clamp-1 fm-typo-en-body-lg-400",
1332
+ o.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-typo-primary"
1333
+ ])
1334
+ }, P(t(Lt)(V.value)), 3)
1335
+ ]),
1336
+ _: 1
1337
+ }, 8, ["label", "modelValue", "items", "rules"]),
1338
+ c(Ie, {
1339
+ label: V.value === t(ee).PURCHASE ? t(u)("inventory.transfer.form.purchaseFrom") : t(u)("inventory.transfer.form.transferFrom"),
1340
+ "label-mark": "required",
1341
+ modelValue: O.value,
1342
+ "onUpdate:modelValue": v[1] || (v[1] = ($) => O.value = $),
1343
+ items: X.value
1344
+ }, {
1345
+ "menu-wrapper": T(($) => {
1346
+ var J, Ve;
1347
+ return [
1348
+ c(ds, Ye($, {
1349
+ items: X.value,
1350
+ "model-value": (Ve = (J = o.modelValue) == null ? void 0 : J.supplier) == null ? void 0 : Ve._id
1351
+ }), null, 16, ["items", "model-value"])
1352
+ ];
1353
+ }),
1354
+ default: T(() => {
1355
+ var $;
1356
+ return [
1357
+ l("span", {
1358
+ class: K([
1359
+ "line-clamp-1 fm-typo-en-body-lg-400",
1360
+ o.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-typo-primary"
1361
+ ])
1362
+ }, P(($ = X.value.find((J) => J.value === O.value)) == null ? void 0 : $.label), 3)
1363
+ ];
1364
+ }),
1365
+ _: 1
1366
+ }, 8, ["label", "modelValue", "items"])
1367
+ ], 64)),
1368
+ c(Ue, {
1369
+ label: t(u)("inventory.transfer.form.reference"),
1370
+ "label-mark": "optional",
1371
+ modelValue: t(e).ref,
1372
+ "onUpdate:modelValue": v[2] || (v[2] = ($) => t(e).ref = $)
1373
+ }, null, 8, ["label", "modelValue"]),
1374
+ c(qe, {
1375
+ label: t(u)("inventory.transfer.form.remark"),
1376
+ "label-mark": "optional",
1377
+ "max-length": 240,
1378
+ modelValue: q.value,
1379
+ "onUpdate:modelValue": v[3] || (v[3] = ($) => q.value = $),
1380
+ class: K([o.disabled ? "text-fm-color-typo-disabled " : ""])
1381
+ }, null, 8, ["label", "modelValue", "class"]),
1382
+ F.value ? (x(), Q(lo, {
1383
+ key: 2,
1384
+ required: t(e).template != null,
1385
+ disabled: o.disabled,
1386
+ supplier: t(e).supplier,
1387
+ setting: t(e).netSuite,
1388
+ items: t(e).items,
1389
+ onChange: ($, J) => {
1390
+ t(e).items = $, t(e).netSuite = J;
1391
+ },
1392
+ "onNetsuite:ready": v[4] || (v[4] = ($) => {
1393
+ S.value = !0;
1394
+ })
1395
+ }, null, 8, ["required", "disabled", "supplier", "setting", "items", "onChange"])) : L("", !0),
1396
+ t(a).enableBackdatePo ? (x(), D("div", bo, [
1397
+ l("div", {
1398
+ class: K([
1399
+ "flex",
1400
+ {
1401
+ "flex-col": p.value
1402
+ }
1403
+ ])
1404
+ }, [
1405
+ c(De, {
1406
+ modelValue: t(U),
1407
+ "onUpdate:modelValue": v[5] || (v[5] = ($) => xe(U) ? U.value = $ : null),
1408
+ label: t(u)("inventory.transfer.form.backdate.title"),
1409
+ sublabel: t(u)("inventory.transfer.form.backdate.subtitle"),
1410
+ "label-placement": "right",
1411
+ disabled: M.value && !o.lastClosingDate || o.disabled
1412
+ }, null, 8, ["modelValue", "label", "sublabel", "disabled"]),
1413
+ l("div", {
1414
+ class: K({ hidden: p.value, "w-16": !p.value })
1415
+ }, null, 2),
1416
+ t(U) ? (x(), D("div", go, [
1417
+ l("div", _o, [
1418
+ c(N, {
1419
+ modelValue: t(C),
1420
+ "onUpdate:modelValue": v[6] || (v[6] = ($) => xe(C) ? C.value = $ : null)
1421
+ }, null, 8, ["modelValue"])
1422
+ ]),
1423
+ l("div", ho, [
1424
+ c(G, {
1425
+ modelValue: t(w),
1426
+ "onUpdate:modelValue": v[7] || (v[7] = ($) => xe(w) ? w.value = $ : null)
1427
+ }, null, 8, ["modelValue"])
1428
+ ])
1429
+ ])) : L("", !0)
1430
+ ], 2),
1431
+ t(H) ? (x(), Q(te, {
1432
+ key: 0,
1433
+ modelValue: t(H),
1434
+ "onUpdate:modelValue": v[8] || (v[8] = ($) => xe(H) ? H.value = $ : null),
1435
+ rules: [t(zt)(new Date(o.lastClosingDate), /* @__PURE__ */ new Date())]
1436
+ }, null, 8, ["modelValue", "rules"])) : L("", !0),
1437
+ M.value && !o.lastClosingDate ? (x(), D("div", xo, [
1438
+ c(re, {
1439
+ name: "error",
1440
+ size: "sm",
1441
+ class: "text-fm-color-typo-warning"
1442
+ }),
1443
+ l("span", ko, P(t(u)("inventory.transfer.form.backdate.error")), 1)
1444
+ ])) : L("", !0)
1445
+ ])) : L("", !0)
1446
+ ])
1447
+ ]),
1448
+ l("div", Co, [
1449
+ c(te, {
1450
+ "model-value": t(e).items,
1451
+ rules: [t(Ne)(1)]
1452
+ }, null, 8, ["model-value", "rules"]),
1453
+ l("div", {
1454
+ class: K([
1455
+ "flex gap-16",
1456
+ {
1457
+ "flex-col items-start": p.value,
1458
+ "items-center": !p.value
1459
+ }
1460
+ ])
1461
+ }, [
1462
+ l("div", So, P(t(u)("inventory.transfer.form.items.title")), 1),
1463
+ l("div", wo, [
1464
+ c(W, {
1465
+ disabled: o.disabled,
1466
+ label: t(u)("inventory.transfer.form.items.addItem"),
1467
+ "prepend-icon": "add",
1468
+ variant: "secondary",
1469
+ "text-color": "primary",
1470
+ "bg-color": "transparent",
1471
+ "border-color": "primary",
1472
+ onClick: v[9] || (v[9] = ($) => Ee()),
1473
+ size: "md"
1474
+ }, null, 8, ["disabled", "label"]),
1475
+ t(e).template ? (x(), Q(fe, {
1476
+ key: 0,
1477
+ "z-index": 50
1478
+ }, {
1479
+ content: T(() => [
1480
+ l("div", null, P(t(u)("inventory.transfer.form.items.forecastStock.notAvailable")), 1)
1481
+ ]),
1482
+ default: T(() => [
1483
+ c(pt, {
1484
+ "onUpdate:poItems": v[10] || (v[10] = ($) => t(e).items = $),
1485
+ disabled: ""
1486
+ })
1487
+ ]),
1488
+ _: 1
1489
+ })) : (x(), Q(pt, {
1490
+ key: 1,
1491
+ "onUpdate:poItems": v[11] || (v[11] = ($) => t(e).items = $),
1492
+ disabled: o.disabled || !!t(e).template
1493
+ }, null, 8, ["disabled"]))
1494
+ ])
1495
+ ], 2),
1496
+ V.value === t(ee).PURCHASE && f.value && t(a).enableTotalCost && ((st = o.modelValue) != null && st.items.length) ? (x(), D("div", Fo, [
1497
+ c(De, {
1498
+ label: t(ie) ? t(u)("inventory.transfer.form.items.fetchingData") : t(u)("inventory.transfer.form.items.comparePriceHistory"),
1499
+ "prepend-icon": "compare_arrows",
1500
+ "label-placement": "right",
1501
+ "model-value": t(Y),
1502
+ "onUpdate:modelValue": v[12] || (v[12] = ($) => xe(Y) ? Y.value = $ : null),
1503
+ disabled: t(ie) || o.disabled
1504
+ }, null, 8, ["label", "model-value", "disabled"])
1505
+ ])) : L("", !0),
1506
+ c(te, {
1507
+ "model-value": be.value,
1508
+ rules: [() => be.value ? "Must have at least one non-zero item" : !0]
1509
+ }, null, 8, ["model-value", "rules"]),
1510
+ (x(), Q(oe, {
1511
+ "column-defs": Ae.value,
1512
+ "column-visibility": {
1513
+ [t(Z).Code]: !(((ot = o.modelValue) == null ? void 0 : ot.template) ?? ((at = o.modelValue) == null ? void 0 : at.templateDoc)),
1514
+ [t(Z).Name]: !(((lt = o.modelValue) == null ? void 0 : lt.template) ?? ((nt = o.modelValue) == null ? void 0 : nt.templateDoc)),
1515
+ [t(Z).TemplateName]: !!(((rt = o.modelValue) == null ? void 0 : rt.template) ?? ((it = o.modelValue) == null ? void 0 : it.templateDoc))
1516
+ },
1517
+ "row-data": t(e).items,
1518
+ key: t(e).items.map(($) => $.sku._id).join("."),
1519
+ "hide-footer": "",
1520
+ "page-size": t(e).items.length
1521
+ }, {
1522
+ "table-row": T(($) => {
1523
+ var J, Ve, ut, dt;
1524
+ return [
1525
+ c(eo, {
1526
+ "compare-price-by-sku": t(se),
1527
+ "show-compare-price": V.value === t(ee).PURCHASE && t(Y),
1528
+ row: $,
1529
+ "template-item": (dt = (ut = (Ve = (J = o.modelValue) == null ? void 0 : J.templateDoc) == null ? void 0 : Ve.purchaseOrder) == null ? void 0 : ut.items) == null ? void 0 : dt.find(
1530
+ (He) => He.sku._id === $.original.sku._id
1531
+ ),
1532
+ "onUpdate:item": v[13] || (v[13] = (He) => Se.value.updateItem(He)),
1533
+ disabled: o.disabled
1534
+ }, null, 8, ["compare-price-by-sku", "show-compare-price", "row", "template-item", "disabled"])
1535
+ ];
1536
+ }),
1537
+ "list-row": T(($) => [
1538
+ (x(), Q(xt, {
1539
+ row: $,
1540
+ key: t(e).items.map((J) => J.sku._id).join(".")
1541
+ }, {
1542
+ default: T((J) => [
1543
+ c(Rs, {
1544
+ "compare-price-by-sku": t(se),
1545
+ "show-compare-price": V.value === t(ee).PURCHASE && t(Y),
1546
+ row: $,
1547
+ "cell-by-col-id": J
1548
+ }, null, 8, ["compare-price-by-sku", "show-compare-price", "row", "cell-by-col-id"])
1549
+ ]),
1550
+ _: 2
1551
+ }, 1032, ["row"]))
1552
+ ]),
1553
+ _: 1
1554
+ }, 8, ["column-defs", "column-visibility", "row-data", "page-size"]))
1555
+ ])
1556
+ ];
1557
+ }),
1558
+ _: 1
1559
+ }, 8, ["disabled", "onValidationFailed"])
1560
+ ]);
1561
+ };
1562
+ }
1563
+ }), Io = { class: "flex items-center" }, Do = { class: "fm-typo-en-title-md-800" }, To = { class: "flex gap-4" }, Vo = /* @__PURE__ */ le({
1564
+ __name: "TransferDialog",
1565
+ props: {
1566
+ mode: {},
1567
+ modelValue: {},
1568
+ templateId: {},
1569
+ show: { type: Boolean },
1570
+ lastClosingDate: {}
1571
+ },
1572
+ emits: ["update:show", "submitted"],
1573
+ setup(y, { expose: _, emit: n }) {
1574
+ var U;
1575
+ const r = y, g = n, e = We(), u = wt(), h = $e(), k = tt(), i = Le(), s = Ge(), { t: a } = ce(), b = A(!1), m = A(!1), p = A(!1);
1576
+ async function S(C) {
1577
+ if (C) {
1578
+ m.value = !1;
1579
+ try {
1580
+ await k.readSuppliers(), m.value = !0;
1581
+ } catch {
1582
+ h.open({
1583
+ title: a("inventory.transfer.form.unableToFetchListOfSuppliers.title"),
1584
+ message: a("inventory.transfer.form.unableToFetchListOfSuppliers.message"),
1585
+ type: "error"
1586
+ });
1587
+ }
1588
+ }
1589
+ }
1590
+ s.watchLocation(S);
1591
+ function F() {
1592
+ return {
1593
+ remark: void 0,
1594
+ ref: void 0,
1595
+ stockSnapshotId: void 0,
1596
+ effectiveAt: void 0,
1597
+ items: [],
1598
+ supplier: {
1599
+ _rev: void 0,
1600
+ email: void 0,
1601
+ internal: void 0,
1602
+ contactName: void 0,
1603
+ phoneNumber: void 0,
1604
+ registrationNumber: void 0,
1605
+ supplyItems: void 0,
1606
+ _id: "",
1607
+ name: "",
1608
+ address: {
1609
+ line2: void 0,
1610
+ line1: "",
1611
+ state: "",
1612
+ city: "",
1613
+ postcode: "",
1614
+ country: ""
1615
+ }
1616
+ },
1617
+ status: "DRAFT",
1618
+ _id: "",
1619
+ seqNumber: 0,
1620
+ deliveryOrder: [],
1621
+ template: r.templateId,
1622
+ templateDoc: u.templates.find((w) => w._id === r.templateId)
1623
+ };
1624
+ }
1625
+ const d = St(r, "show"), f = A(r.modelValue ?? F()), M = A(((U = r.modelValue) == null ? void 0 : U._id) ?? `${Math.random()}`);
1626
+ ve(
1627
+ () => r.show,
1628
+ (C) => {
1629
+ var w;
1630
+ C && (p.value = !1, f.value = r.modelValue ?? F(), M.value = ((w = r.modelValue) == null ? void 0 : w._id) ?? `${Math.random()}`);
1631
+ }
1632
+ );
1633
+ const z = E(() => !m.value || !p.value), R = E(() => {
1634
+ switch (r.mode) {
1635
+ case Pe.READ:
1636
+ return "View transfer";
1637
+ case Pe.CREATE:
1638
+ return a("inventory.transfer.receiveRequest.create.title");
1639
+ case Pe.UPDATE:
1640
+ return a("inventory.transfer.receiveRequest.update.title");
1641
+ }
1642
+ return "";
1643
+ }), V = A();
1644
+ _({
1645
+ validateInputs: () => {
1646
+ var C, w;
1647
+ (w = (C = V.value) == null ? void 0 : C.validateInputs) == null || w.call(C);
1648
+ },
1649
+ resetInputsValidation: () => {
1650
+ var C, w;
1651
+ (w = (C = V.value) == null ? void 0 : C.resetInputsValidation) == null || w.call(C);
1652
+ },
1653
+ resetInputs: () => {
1654
+ var C, w;
1655
+ (w = (C = V.value) == null ? void 0 : C.resetInputs) == null || w.call(C);
1656
+ }
1657
+ });
1658
+ async function X() {
1659
+ const C = f.value;
1660
+ b.value = !0, (C.supplier.internal === "warehouse" || C.supplier.internal === "restaurant") && (C.items = C.items.map(({ totalCost: w, ...Y }) => Y));
1661
+ try {
1662
+ await e.createPurchaseOrder(C), await new Promise((w) => setTimeout(w, 1e3)), h.open({
1663
+ title: a("inventory.transfer.receiveRequest.create.success"),
1664
+ message: a("inventory.transfer.receiveRequest.create.successMessage"),
1665
+ type: "success"
1666
+ }), g("update:show", !1), g("submitted");
1667
+ } catch (w) {
1668
+ h.open({
1669
+ title: a("inventory.transfer.receiveRequest.create.error.title"),
1670
+ message: a("inventory.transfer.receiveRequest.create.error.message"),
1671
+ type: "error"
1672
+ }), console.error("Error in creating purchase order", w);
1673
+ } finally {
1674
+ b.value = !1;
1675
+ }
1676
+ }
1677
+ async function O() {
1678
+ const C = f.value;
1679
+ b.value = !0, (C.supplier.internal === "warehouse" || C.supplier.internal === "restaurant") && (C.items = C.items.map(({ totalCost: w, ...Y }) => Y));
1680
+ try {
1681
+ await e.updatePurchaseOrder(C), await new Promise((w) => setTimeout(w, 1e3)), h.open({
1682
+ title: a("inventory.transfer.receiveRequest.update.success"),
1683
+ message: a("inventory.transfer.receiveRequest.update.successMessage"),
1684
+ type: "success"
1685
+ }), g("update:show", !1), g("submitted");
1686
+ } catch (w) {
1687
+ h.open({
1688
+ title: a("inventory.transfer.receiveRequest.update.error.title"),
1689
+ message: a("inventory.transfer.receiveRequest.update.error.message"),
1690
+ type: "error"
1691
+ }), console.error("Error in updating purchase order", w);
1692
+ } finally {
1693
+ b.value = !1;
1694
+ }
1695
+ }
1696
+ function q() {
1697
+ switch (r.mode) {
1698
+ case Pe.CREATE:
1699
+ return X();
1700
+ case Pe.UPDATE:
1701
+ return O();
1702
+ }
1703
+ }
1704
+ function H() {
1705
+ var C, w;
1706
+ (w = (C = V.value) == null ? void 0 : C.validateInputs) == null || w.call(C);
1707
+ }
1708
+ return (C, w) => {
1709
+ const Y = I("FmButton"), ie = I("FmSideSheet");
1710
+ return x(), Q(ie, {
1711
+ modelValue: t(d),
1712
+ "onUpdate:modelValue": w[3] || (w[3] = (se) => xe(d) ? d.value = se : null),
1713
+ "dismiss-away": "",
1714
+ "close-button": "",
1715
+ "max-width": 900
1716
+ }, {
1717
+ "side-sheet-header": T(() => [
1718
+ l("div", Io, [
1719
+ l("div", Do, P(R.value), 1)
1720
+ ])
1721
+ ]),
1722
+ default: T(() => [
1723
+ (x(), Q($o, {
1724
+ class: "w-full",
1725
+ ref_key: "formRef",
1726
+ ref: V,
1727
+ "onForm:ready": w[0] || (w[0] = () => p.value = !0),
1728
+ onValidationSuccess: q,
1729
+ modelValue: f.value,
1730
+ "onUpdate:modelValue": w[1] || (w[1] = (se) => f.value = se),
1731
+ disabled: b.value || z.value,
1732
+ suppliers: t(k).suppliers,
1733
+ skus: t(i).skus,
1734
+ key: M.value,
1735
+ "last-closing-date": C.lastClosingDate
1736
+ }, null, 8, ["modelValue", "disabled", "suppliers", "skus", "last-closing-date"]))
1737
+ ]),
1738
+ "side-sheet-footer": T(() => [
1739
+ l("div", To, [
1740
+ c(Y, {
1741
+ loading: b.value,
1742
+ disabled: z.value,
1743
+ label: t(a)("common.save"),
1744
+ onClick: H
1745
+ }, null, 8, ["loading", "disabled", "label"]),
1746
+ c(Y, {
1747
+ disabled: z.value,
1748
+ variant: "tertiary",
1749
+ label: t(a)("common.close"),
1750
+ onClick: w[2] || (w[2] = (se) => g("update:show", !1))
1751
+ }, null, 8, ["disabled", "label"])
1752
+ ])
1753
+ ]),
1754
+ _: 1
1755
+ }, 8, ["modelValue"]);
1756
+ };
1757
+ }
1758
+ });
1759
+ function Po(y) {
1760
+ const [_, ...n] = Ht(y), r = _.map((h) => h.toLowerCase().trim().replace(/ /g, "_")), e = ["item_code", "quantity"].filter((h) => !r.includes(h));
1761
+ if (e.length)
1762
+ throw new Error(
1763
+ `Missing headers (${e.join()}). Excel file does not come from the template.`
1764
+ );
1765
+ return n.map((h, k) => {
1766
+ const i = {};
1767
+ for (const s in r) {
1768
+ const a = r[s];
1769
+ Object.assign(i, { [a]: h[s] });
1770
+ }
1771
+ return {
1772
+ index: k,
1773
+ data: i
1774
+ };
1775
+ });
1776
+ }
1777
+ function Ro(y) {
1778
+ const _ = y.SheetNames;
1779
+ try {
1780
+ return _.reduce(
1781
+ (r, g) => {
1782
+ const e = new Array(), u = y.Sheets[g], h = Le(), k = Po(u), i = [];
1783
+ for (const { index: a, data: b } of k) {
1784
+ b.item_code === "" && e.push(`Row ${a + 1}: Item code is empty`), b.quantity === "" && e.push(`Row ${a + 1}: Quantity is empty`);
1785
+ const m = h.skus.find((S) => S.code === b.item_code);
1786
+ if (!m) {
1787
+ e.push(`Row ${a + 1}: SKU not found`);
1788
+ continue;
1789
+ }
1790
+ i.push({
1791
+ sku: m,
1792
+ code: b.item_code,
1793
+ name: m.name,
1794
+ quantity: gt.fromNumber(Number(b.quantity)),
1795
+ measurement: null
1796
+ });
1797
+ }
1798
+ const s = {
1799
+ type: "create",
1800
+ poItems: i,
1801
+ excelSheetName: g,
1802
+ errors: e
1803
+ };
1804
+ return r.importCreateResult.push(s), r;
1805
+ },
1806
+ {
1807
+ invalidExcel: !1,
1808
+ importCreateResult: new Array()
1809
+ }
1810
+ );
1811
+ } catch (n) {
1812
+ return {
1813
+ invalidExcel: !0,
1814
+ invalidExcelMessage: (n == null ? void 0 : n.message) ?? "Invalid excel",
1815
+ importCreateResult: []
1816
+ };
1817
+ }
1818
+ }
1819
+ const Ao = exports.FfCalculator, Eo = { class: "flex flex-col flex-1" }, Mo = { class: "flex flex-col" }, Uo = { class: "fm-typo-en-body-md-400 text-fm-color-typo-primary flex items-center gap-4" }, qo = {
1820
+ key: 0,
1821
+ class: "text-fm-color-typo-secondary fm-typo-en-body-sm-400"
1822
+ }, Oo = { key: 0 }, No = {
1823
+ class: /* @__PURE__ */ K(["fm-typo-en-body-lg-600"])
1824
+ }, Bo = { class: "flex-1" }, Lo = { class: "flex-auto line-clamp-2 text-ellipsis break-all fm-typo-en-body-sm-400" }, zo = { class: "flex-auto line-clamp-2 text-ellipsis break-all" }, Ho = { class: "text-fm-color-typo-primary" }, jo = { class: "ml-auto" }, Yo = { key: 0 }, Ko = /* @__PURE__ */ le({
1825
+ __name: "XilnexResult",
1826
+ props: {
1827
+ type: {},
1828
+ name: {},
1829
+ items: {},
1830
+ errors: {}
1831
+ },
1832
+ setup(y) {
1833
+ const _ = y, { t: n } = ce(), r = A(!1), g = () => {
1834
+ _.errors.length && (r.value = !r.value);
1835
+ };
1836
+ return (e, u) => {
1837
+ var i;
1838
+ const h = I("FmIcon"), k = I("FmTooltip");
1839
+ return x(), D("div", Eo, [
1840
+ l("div", {
1841
+ onClick: g,
1842
+ class: K({
1843
+ "cursor-pointer": e.errors.length
1844
+ })
1845
+ }, [
1846
+ l("div", Mo, [
1847
+ l("div", Uo, [
1848
+ l("div", {
1849
+ class: K({
1850
+ "text-fm-color-system-error-300": e.errors.length
1851
+ })
1852
+ }, [
1853
+ Fe(P(e.name) + " ", 1),
1854
+ e.type === "create" ? (x(), D("span", qo, "(" + P(t(n)("inventory.closing.template.import.new")) + ")", 1)) : L("", !0)
1855
+ ], 2),
1856
+ e.errors.length ? (x(), D("div", Oo, [
1857
+ c(h, {
1858
+ name: "error",
1859
+ size: "sm",
1860
+ color: "system-error-300"
1861
+ })
1862
+ ])) : L("", !0)
1863
+ ]),
1864
+ u[0] || (u[0] = l("hr", { class: "my-2" }, null, -1)),
1865
+ l("div", No, [
1866
+ (i = e.items) != null && i.length ? (x(!0), D(ae, { key: 0 }, Ce(e.items, (s, a) => (x(), D("div", {
1867
+ key: a,
1868
+ class: "flex gap-4 mt-2 items-center"
1869
+ }, [
1870
+ l("div", Bo, [
1871
+ c(k, {
1872
+ content: s.code,
1873
+ placement: "top",
1874
+ "z-index": 51
1875
+ }, {
1876
+ default: T(() => [
1877
+ l("span", Lo, P(s.code), 1)
1878
+ ]),
1879
+ _: 2
1880
+ }, 1032, ["content"]),
1881
+ c(k, {
1882
+ content: s.name,
1883
+ placement: "top",
1884
+ "z-index": 51
1885
+ }, {
1886
+ default: T(() => [
1887
+ l("span", zo, P(s.name), 1)
1888
+ ]),
1889
+ _: 2
1890
+ }, 1032, ["content"])
1891
+ ]),
1892
+ l("div", null, [
1893
+ l("span", Ho, P(t(Ao).toFormatString({
1894
+ value: s.quantity
1895
+ })), 1),
1896
+ Fe(" " + P(s.measurement ? s.measurement.abbrev : s.sku.unit.abbrev), 1)
1897
+ ])
1898
+ ]))), 128)) : L("", !0)
1899
+ ])
1900
+ ]),
1901
+ l("div", jo, [
1902
+ e.errors.length ? (x(), Q(h, {
1903
+ key: 0,
1904
+ name: r.value ? "keyboard_arrow_up" : "keyboard_arrow_down",
1905
+ size: "md"
1906
+ }, null, 8, ["name"])) : L("", !0)
1907
+ ])
1908
+ ], 2),
1909
+ r.value ? (x(), D("div", {
1910
+ key: 0,
1911
+ class: K(["flex flex-col gap-4 pl-8 fm-typo-en-body-sm-400", {
1912
+ "text-fm-color-typo-secondary": !e.errors.length,
1913
+ "text-fm-color-system-error-300": e.errors.length
1914
+ }])
1915
+ }, [
1916
+ e.errors.length ? (x(), D("div", Yo, [
1917
+ l("ol", null, [
1918
+ (x(!0), D(ae, null, Ce(e.errors, (s, a) => (x(), D("li", { key: a }, P(s), 1))), 128))
1919
+ ])
1920
+ ])) : L("", !0)
1921
+ ], 2)) : L("", !0)
1922
+ ]);
1923
+ };
1924
+ }
1925
+ }), Qo = { class: "flex flex-col gap-24" }, Xo = {
1926
+ key: 0,
1927
+ class: "flex items-center gap-8"
1928
+ }, Zo = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Go = { class: "flex flex-col gap-8" }, Wo = { class: "line-clamp-2 text-ellipsis break-all" }, Jo = {
1929
+ key: 2,
1930
+ class: "shrink-0"
1931
+ }, ea = {
1932
+ key: 0,
1933
+ class: "flex flex-col"
1934
+ }, ta = { class: "text-fm-color-system-error-300 fm-typo-en-body-sm-400" }, sa = {
1935
+ key: 0,
1936
+ class: "max-h-[200px] overflow-y-auto flex flex-col gap-8"
1937
+ }, oa = { class: "fm-typo-en-body-lg-600" }, ft = "Transfer note", aa = /* @__PURE__ */ le({
1938
+ __name: "XilnexImportForm",
1939
+ setup(y, { expose: _ }) {
1940
+ const n = A(null), r = $e(), g = A(!1), e = A(!1), u = ht();
1941
+ A(!1), Be();
1942
+ const h = A([
1943
+ {
1944
+ label: "LMSL389 MSU Medical Centre",
1945
+ value: {
1946
+ netsuiteId: "1279",
1947
+ name: "LMSL389 MSU Medical Centre"
1948
+ }
1949
+ },
1950
+ {
1951
+ label: "LMSL540 Central I-City",
1952
+ value: {
1953
+ netsuiteId: "1463",
1954
+ name: "LMSL540 Central I-City"
1955
+ }
1956
+ },
1957
+ {
1958
+ label: "LMSL572 Giant Shah Alam Stadium",
1959
+ value: {
1960
+ netsuiteId: "1521",
1961
+ name: "LMSL572 Giant Shah Alam Stadium"
1962
+ }
1963
+ }
1964
+ ]), k = E({
1965
+ get() {
1966
+ var d;
1967
+ return ((d = u.supplier) == null ? void 0 : d.name) ?? "";
1968
+ },
1969
+ set(d) {
1970
+ d && (u.supplier = {
1971
+ name: d.name,
1972
+ registrationNumber: "",
1973
+ _id: d.netsuiteId,
1974
+ internal: "restaurant",
1975
+ address: {
1976
+ line1: "",
1977
+ line2: "",
1978
+ city: "",
1979
+ state: "",
1980
+ country: "",
1981
+ postcode: ""
1982
+ }
1983
+ });
1984
+ }
1985
+ }), i = E({
1986
+ get() {
1987
+ return "";
1988
+ },
1989
+ set(d) {
1990
+ if (d) {
1991
+ const f = u.effectiveAt ? new Date(u.effectiveAt) : /* @__PURE__ */ new Date(), [M, z, R] = d.split("-");
1992
+ f.setFullYear(parseInt(M)), f.setMonth(parseInt(z) - 1), f.setDate(parseInt(R)), u.effectiveAt = f.toISOString();
1993
+ }
1994
+ }
1995
+ }), s = E({
1996
+ get() {
1997
+ return null;
1998
+ },
1999
+ set(d) {
2000
+ if (d) {
2001
+ const f = u.effectiveAt ? new Date(u.effectiveAt) : /* @__PURE__ */ new Date(), [M, z] = d.split(":");
2002
+ f.setHours(parseInt(M)), f.setMinutes(parseInt(z)), f.setSeconds(0), f.setMilliseconds(0), u.effectiveAt = f.toISOString();
2003
+ }
2004
+ }
2005
+ }), a = A(new Array()), b = A([]), m = E(
2006
+ () => !!a.value.length || b.value.some((d) => d.errors.length)
2007
+ ), p = A();
2008
+ _({
2009
+ validateInputs: () => {
2010
+ var d, f;
2011
+ (f = (d = p.value) == null ? void 0 : d.validateInputs) == null || f.call(d);
2012
+ },
2013
+ resetInputsValidation: () => {
2014
+ var d, f;
2015
+ (f = (d = p.value) == null ? void 0 : d.resetInputsValidation) == null || f.call(d);
2016
+ },
2017
+ resetInputs: () => {
2018
+ var d, f;
2019
+ (f = (d = p.value) == null ? void 0 : d.resetInputs) == null || f.call(d);
2020
+ }
2021
+ });
2022
+ const { t: S } = ce();
2023
+ async function F(d) {
2024
+ a.value = [], b.value = [];
2025
+ try {
2026
+ g.value = !0;
2027
+ const [f] = await Promise.all([
2028
+ Yt(d),
2029
+ // fake buffer
2030
+ new Promise((z) => setTimeout(z, 1e3))
2031
+ ]), M = Ro(f);
2032
+ if (M.invalidExcel) {
2033
+ a.value.push(
2034
+ M.invalidExcelMessage ?? S("inventory.ingredient.import.fileError.invalidExcel")
2035
+ );
2036
+ return;
2037
+ }
2038
+ if (b.value = M.importCreateResult, !b.value.length) {
2039
+ a.value.push(S("inventory.ingredient.import.fileError.noData"));
2040
+ return;
2041
+ }
2042
+ u.items = b.value.map((z) => z.poItems).flat();
2043
+ } catch (f) {
2044
+ r.open({
2045
+ title: S("inventory.ingredient.import.fileError.unableToRead"),
2046
+ message: f == null ? void 0 : f.message,
2047
+ type: "error"
2048
+ }), console.error("Error in reading file", f);
2049
+ } finally {
2050
+ a.value.length && r.open({
2051
+ title: S("inventory.ingredient.import.fileError.invalidExcel"),
2052
+ type: "error"
2053
+ }), g.value = !1;
2054
+ }
2055
+ }
2056
+ return ve(n, (d) => {
2057
+ d && F(d);
2058
+ }), (d, f) => {
2059
+ const M = I("FmSelect"), z = I("FmDatePicker"), R = I("FmTimePicker"), V = I("FmCircularProgress"), X = I("FmLabel"), O = I("FmIcon"), q = I("FmButton"), H = I("FmForm");
2060
+ return x(), Q(H, {
2061
+ ref_key: "formRef",
2062
+ ref: p
2063
+ }, {
2064
+ default: T(() => [
2065
+ l("div", Qo, [
2066
+ c(M, {
2067
+ modelValue: k.value,
2068
+ "onUpdate:modelValue": f[0] || (f[0] = (U) => k.value = U),
2069
+ label: "Transfer from",
2070
+ searchable: "",
2071
+ searchTarget: "label",
2072
+ items: h.value,
2073
+ rules: [t(Re)()]
2074
+ }, null, 8, ["modelValue", "items", "rules"]),
2075
+ c(z, {
2076
+ modelValue: i.value,
2077
+ "onUpdate:modelValue": f[1] || (f[1] = (U) => i.value = U),
2078
+ label: "Transfer date",
2079
+ rules: [t(Re)()]
2080
+ }, null, 8, ["modelValue", "rules"]),
2081
+ c(R, {
2082
+ modelValue: s.value,
2083
+ "onUpdate:modelValue": f[2] || (f[2] = (U) => s.value = U),
2084
+ label: "Transfer time",
2085
+ rules: [t(Re)()]
2086
+ }, null, 8, ["modelValue", "rules"]),
2087
+ e.value ? (x(), D("div", Xo, [
2088
+ l("div", null, [
2089
+ c(V, {
2090
+ size: "md",
2091
+ color: "neutral-gray-200"
2092
+ })
2093
+ ]),
2094
+ l("div", Zo, P(t(S)("inventory.formField.loading")), 1)
2095
+ ])) : (x(), D(ae, { key: 1 }, [
2096
+ c(jt, {
2097
+ "max-file-size": 5,
2098
+ class: K({
2099
+ "w-full": !0,
2100
+ "h-[200px]": !n.value
2101
+ }),
2102
+ accept: ".xlsx,.xls,.csv",
2103
+ label: ft,
2104
+ onFileUpload: f[3] || (f[3] = (U) => n.value = U),
2105
+ "button-label": t(S)("inventory.ingredient.import.selectFile")
2106
+ }, It({ _: 2 }, [
2107
+ n.value ? {
2108
+ name: "default",
2109
+ fn: T(({ openFileDialog: U }) => [
2110
+ c(X, null, {
2111
+ default: T(() => [
2112
+ Fe(P(ft))
2113
+ ]),
2114
+ _: 1
2115
+ }),
2116
+ l("div", Go, [
2117
+ l("div", {
2118
+ class: K([
2119
+ "fm-corner-radius-md p-16 flex items-center gap-16",
2120
+ {
2121
+ "border border-fm-color-neutral-gray-100": g.value,
2122
+ "border border-fm-color-neutral-gray-200": !g.value && !m.value,
2123
+ "border border-fm-color-system-error-200": m.value
2124
+ }
2125
+ ])
2126
+ }, [
2127
+ g.value ? (x(), Q(V, {
2128
+ key: 0,
2129
+ size: "md",
2130
+ color: "neutral-gray-200"
2131
+ })) : (x(), Q(O, {
2132
+ key: 1,
2133
+ name: m.value ? "error" : "attach_file",
2134
+ outline: "",
2135
+ color: m.value ? "system-error-300" : void 0
2136
+ }, null, 8, ["name", "color"])),
2137
+ l("div", {
2138
+ class: K([
2139
+ "fm-typo-en-body-md-400 flex-1 h-[36px] flex items-center",
2140
+ {
2141
+ "text-fm-color-typo-disabled": g.value,
2142
+ "text-fm-color-typo-primary": !g.value
2143
+ }
2144
+ ])
2145
+ }, [
2146
+ l("div", Wo, P(n.value.name), 1)
2147
+ ], 2),
2148
+ g.value ? L("", !0) : (x(), D("div", Jo, [
2149
+ c(q, {
2150
+ label: t(S)("inventory.ingredient.import.replaceFile"),
2151
+ variant: m.value ? "destructive" : "secondary",
2152
+ "prepend-icon": m.value ? void 0 : "autorenew",
2153
+ onClick: U
2154
+ }, null, 8, ["label", "variant", "prepend-icon", "onClick"])
2155
+ ]))
2156
+ ], 2),
2157
+ a.value.length ? (x(), D("div", ea, [
2158
+ (x(!0), D(ae, null, Ce(a.value, (C, w) => (x(), D("div", {
2159
+ key: w,
2160
+ class: "flex gap-8 items-center"
2161
+ }, [
2162
+ c(O, {
2163
+ name: "error",
2164
+ size: "sm",
2165
+ color: "system-error-300"
2166
+ }),
2167
+ l("div", ta, P(C), 1)
2168
+ ]))), 128))
2169
+ ])) : L("", !0)
2170
+ ])
2171
+ ]),
2172
+ key: "0"
2173
+ } : void 0
2174
+ ]), 1032, ["class", "button-label"]),
2175
+ n.value ? (x(), D("div", sa, [
2176
+ l("div", oa, P(t(S)("inventory.ingredient.import.summary")), 1),
2177
+ (x(!0), D(ae, null, Ce(b.value, (U, C) => (x(), Q(Ko, {
2178
+ key: C,
2179
+ name: `Transfer Note ${C + 1}`,
2180
+ items: U.poItems,
2181
+ errors: U.errors,
2182
+ type: "create"
2183
+ }, null, 8, ["name", "items", "errors"]))), 128))
2184
+ ])) : L("", !0)
2185
+ ], 64))
2186
+ ])
2187
+ ]),
2188
+ _: 1
2189
+ }, 512);
2190
+ };
2191
+ }
2192
+ }), la = { class: "w-[480px]" }, na = /* @__PURE__ */ le({
2193
+ __name: "XilnexImportDialog",
2194
+ props: {
2195
+ show: { type: Boolean }
2196
+ },
2197
+ emits: ["update:show", "submitted"],
2198
+ setup(y, { expose: _, emit: n }) {
2199
+ const r = n, e = St(y, "show"), u = $e(), h = We(), k = A(!1), i = A(), s = A();
2200
+ _({
2201
+ validateInputs: () => {
2202
+ var m, p;
2203
+ (p = (m = i.value) == null ? void 0 : m.validateInputs) == null || p.call(m);
2204
+ },
2205
+ resetInputsValidation: () => {
2206
+ var m, p;
2207
+ (p = (m = i.value) == null ? void 0 : m.resetInputsValidation) == null || p.call(m);
2208
+ },
2209
+ resetInputs: () => {
2210
+ var m, p;
2211
+ (p = (m = i.value) == null ? void 0 : m.resetInputs) == null || p.call(m);
2212
+ }
2213
+ });
2214
+ function a() {
2215
+ var m, p;
2216
+ (p = (m = i.value) == null ? void 0 : m.validateInputs) == null || p.call(m);
2217
+ }
2218
+ async function b() {
2219
+ var p, S, F, d, f;
2220
+ if (!((S = (p = s.value) == null ? void 0 : p.supplier) != null && S.name)) {
2221
+ u.open({
2222
+ title: "Upload failed",
2223
+ message: "Location is required",
2224
+ type: "error"
2225
+ });
2226
+ return;
2227
+ }
2228
+ if (!((F = s.value) != null && F.items) || ((f = (d = s.value) == null ? void 0 : d.items) == null ? void 0 : f.length) === 0) {
2229
+ u.open({
2230
+ title: "Upload failed",
2231
+ message: "No data to upload",
2232
+ type: "error"
2233
+ });
2234
+ return;
2235
+ }
2236
+ const m = s.value.effectiveAt ? new Date(s.value.effectiveAt) : null;
2237
+ if (!m) {
2238
+ u.open({
2239
+ title: "Invalid date",
2240
+ message: "Transfer date is required",
2241
+ type: "error"
2242
+ });
2243
+ return;
2244
+ }
2245
+ if (m.getTime() > (/* @__PURE__ */ new Date()).getTime()) {
2246
+ u.open({
2247
+ title: "Invalid date",
2248
+ message: "Transfer date cannot be in the future",
2249
+ type: "error"
2250
+ });
2251
+ return;
2252
+ }
2253
+ k.value = !0;
2254
+ try {
2255
+ await h.importFromXilnex(s.value), r("update:show", !1);
2256
+ } catch (M) {
2257
+ await new Promise((z) => setTimeout(z, 1e3)), u.open({
2258
+ title: "Upload failed",
2259
+ message: M == null ? void 0 : M.message,
2260
+ type: "error"
2261
+ });
2262
+ } finally {
2263
+ k.value = !1;
2264
+ }
2265
+ }
2266
+ return (m, p) => {
2267
+ const S = I("FmSpacer"), F = I("FmButton"), d = I("FmDialog");
2268
+ return x(), Q(d, {
2269
+ modelValue: t(e),
2270
+ "onUpdate:modelValue": p[2] || (p[2] = (f) => xe(e) ? e.value = f : null),
2271
+ overlay: !0,
2272
+ "close-button": !1
2273
+ }, {
2274
+ "dialog-header": T(() => p[3] || (p[3] = [
2275
+ l("div", null, "Xilnex transfer order", -1)
2276
+ ])),
2277
+ "dialog-footer": T(() => [
2278
+ c(S, { class: "sm:hidden xs:hidden" }),
2279
+ c(F, {
2280
+ disabled: k.value,
2281
+ class: "sm:w-full xs:w-full",
2282
+ label: "Cancel",
2283
+ size: "md",
2284
+ variant: "tertiary",
2285
+ onClick: p[1] || (p[1] = (f) => r("update:show", !1))
2286
+ }, null, 8, ["disabled"]),
2287
+ c(F, {
2288
+ disabled: k.value,
2289
+ loading: k.value,
2290
+ class: "sm:w-full xs:w-full",
2291
+ label: "Upload",
2292
+ size: "md",
2293
+ variant: "primary",
2294
+ onClick: a
2295
+ }, null, 8, ["disabled", "loading"])
2296
+ ]),
2297
+ default: T(() => [
2298
+ l("div", la, [
2299
+ c(aa, {
2300
+ ref_key: "formRef",
2301
+ ref: i,
2302
+ onValidationSuccess: b,
2303
+ modelValue: s.value,
2304
+ "onUpdate:modelValue": p[0] || (p[0] = (f) => s.value = f)
2305
+ }, null, 8, ["modelValue"])
2306
+ ])
2307
+ ]),
2308
+ _: 1
2309
+ }, 8, ["modelValue"]);
2310
+ };
2311
+ }
2312
+ }), ra = { class: "flex flex-col py-8" }, ia = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, ua = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary line-clamp-1" }, da = { class: "fm-typo-en-body-md-400 text-fm-color-typo-primary line-clamp-1" }, ca = {
2313
+ key: 0,
2314
+ class: "fm-typo-en-body-md-400 text-fm-color-typo-primary line-clamp-1"
2315
+ }, ma = { class: "pt-8" }, vt = "ReceiveRequestViewSearchCriteria", Da = /* @__PURE__ */ le({
2316
+ __name: "ReceiveRequestView",
2317
+ setup(y) {
2318
+ const { t: _ } = ce(), n = $e();
2319
+ Oe.object({
2320
+ name: Oe.string().optional().nullable(),
2321
+ startDate: Oe.string().optional().nullable(),
2322
+ endDate: Oe.string().optional().nullable()
2323
+ });
2324
+ const r = E(
2325
+ () => !a._currentLocation || i.loading.value
2326
+ ), g = os(), e = et();
2327
+ function u() {
2328
+ const R = {
2329
+ name: "",
2330
+ ...ct()
2331
+ }, V = g.getItem(vt);
2332
+ if (!V)
2333
+ return R;
2334
+ try {
2335
+ return JSON.parse(V);
2336
+ } catch {
2337
+ return R;
2338
+ }
2339
+ }
2340
+ function h() {
2341
+ g.setItem(vt, JSON.stringify(k.value));
2342
+ }
2343
+ const k = A(u()), i = Zt(
2344
+ je.RECEIVE_REQUEST,
2345
+ k.value
2346
+ ), { columnDefs: s } = Gt(
2347
+ je.RECEIVE_REQUEST,
2348
+ i
2349
+ ), a = Ge();
2350
+ async function b() {
2351
+ const R = `inventory-record_${mt(k.value.startDate).format("DD-MM-YYYY_HH-mm")}-${mt(k.value.endDate).format("DD-MM-YYYY_HH-mm")}.xlsx`, V = i.purchaseOrders.value.flatMap(
2352
+ (O) => O.items.map((q) => {
2353
+ const H = new Date(ts(O._id) ?? ""), U = O.effectiveAt ? new Date(O.effectiveAt) : void 0, C = ke(
2354
+ Jt(q.sku, O.deliveryOrder || [])
2355
+ ), w = ke(q.quantity);
2356
+ return {
2357
+ "SKU code": q.code,
2358
+ "SKU name": q.name,
2359
+ "PO #": O.seqNumber,
2360
+ "Effective at": U,
2361
+ Date: H,
2362
+ Status: O.status,
2363
+ Reference: O.ref ?? "",
2364
+ "Received quantity": C,
2365
+ "Ordered quantity": w,
2366
+ Unit: q.sku.unit.abbrev,
2367
+ "Total cost": q.totalCost ? Xe(q.totalCost) : null
2368
+ };
2369
+ })
2370
+ ), X = [
2371
+ "SKU code",
2372
+ "SKU name",
2373
+ "PO #",
2374
+ "Date",
2375
+ "Status",
2376
+ "Reference",
2377
+ "Received quantity",
2378
+ "Ordered quantity",
2379
+ "Unit"
2380
+ ];
2381
+ e.enableBackdatePo && X.insert("Effective at", 4), e.enableTotalCost && X.push("Total cost"), await ss(
2382
+ [
2383
+ {
2384
+ name: "purchases",
2385
+ data: V,
2386
+ columns: X
2387
+ }
2388
+ ],
2389
+ R
2390
+ ), n.open({
2391
+ title: _("inventory.transfer.receiveRequest.export.success"),
2392
+ message: _("inventory.transfer.receiveRequest.export.message", [R]),
2393
+ type: "success"
2394
+ });
2395
+ }
2396
+ const m = A(ct()), p = A("");
2397
+ ve([() => m.value], ([R]) => {
2398
+ !R.startDate || !R.endDate || (k.value.startDate = R.startDate, k.value.endDate = R.endDate, i.updateDateRange(
2399
+ k.value.startDate,
2400
+ k.value.endDate
2401
+ ), h());
2402
+ }), ve([() => p.value], () => {
2403
+ h();
2404
+ });
2405
+ function S(R) {
2406
+ if (R === "create") {
2407
+ if (r.value) {
2408
+ n.open({
2409
+ title: "Loading data...",
2410
+ message: "Please wait.",
2411
+ type: "info"
2412
+ });
2413
+ return;
2414
+ }
2415
+ return i.promptCreateTransferDialog();
2416
+ }
2417
+ if (R === "upload" && e.enableXilnexTransferNote)
2418
+ return i.promptUploadTransferDialog();
2419
+ if (R === "refresh")
2420
+ return i.fetchData();
2421
+ if (R === "export")
2422
+ return b();
2423
+ }
2424
+ const { breakpoints: F } = Je(), d = E(() => F.value.xs || F.value.sm), f = E(() => d.value ? 10 : 20), M = Kt(), z = E(() => [
2425
+ {
2426
+ label: _("inventory.transfer.receiveRequest.actions.create"),
2427
+ value: "create",
2428
+ isPrimary: !0,
2429
+ prependIcon: "add"
2430
+ },
2431
+ ...e.enableXilnexTransferNote ? [
2432
+ {
2433
+ label: "Upload",
2434
+ value: "upload"
2435
+ }
2436
+ ] : [],
2437
+ {
2438
+ label: _("common.refresh"),
2439
+ value: "refresh"
2440
+ },
2441
+ {
2442
+ label: _("common.export"),
2443
+ value: "export"
2444
+ }
2445
+ ]);
2446
+ return (R, V) => {
2447
+ const X = I("FmTable");
2448
+ return x(), Q(Qt, {
2449
+ title: t(_)("inventory.transfer.receiveRequest.title2"),
2450
+ actions: z.value,
2451
+ "onClick:action": S
2452
+ }, {
2453
+ default: T(() => {
2454
+ var O;
2455
+ return [
2456
+ l("div", {
2457
+ class: K([
2458
+ "flex flex-col gap-8 max-h-full",
2459
+ {
2460
+ "p-0": d.value,
2461
+ "px-24 ": !d.value
2462
+ }
2463
+ ])
2464
+ }, [
2465
+ c(Xt, {
2466
+ "date-range-query": "",
2467
+ "date-range": m.value,
2468
+ "onUpdate:dateRange": V[0] || (V[0] = (q) => m.value = q),
2469
+ searchable: "",
2470
+ "change-location": "",
2471
+ search: p.value,
2472
+ "onUpdate:search": V[1] || (V[1] = (q) => p.value = q)
2473
+ }, null, 8, ["date-range", "search"]),
2474
+ (x(), Q(X, {
2475
+ style: bt(t(M).tableHeight),
2476
+ "column-defs": t(s),
2477
+ "row-data": t(i).purchaseOrders.value,
2478
+ "search-value": p.value,
2479
+ loading: r.value,
2480
+ onRowClick: V[2] || (V[2] = (q) => t(i).promptShowTransferDetails(q.original)),
2481
+ key: (O = t(a)._currentLocation) == null ? void 0 : O.dbName,
2482
+ "page-size": f.value
2483
+ }, {
2484
+ "list-row": T((q) => [
2485
+ c(xt, {
2486
+ row: q,
2487
+ onRowClick: t(i).promptShowTransferDetails
2488
+ }, {
2489
+ default: T((H) => {
2490
+ var U, C, w, Y, ie, se, ye, Se, we, Ae, Ee, ze, Me, be, o, v, B, ne, re, ge;
2491
+ return [
2492
+ l("div", ra, [
2493
+ l("div", ia, [
2494
+ c(t(de), {
2495
+ render: (w = (C = (U = H._id) == null ? void 0 : U.column) == null ? void 0 : C.columnDef) == null ? void 0 : w.cell,
2496
+ props: (ie = (Y = H._id) == null ? void 0 : Y.getContext) == null ? void 0 : ie.call(Y)
2497
+ }, null, 8, ["render", "props"])
2498
+ ]),
2499
+ l("div", ua, [
2500
+ c(t(de), {
2501
+ render: (Se = (ye = (se = H.supplier_name) == null ? void 0 : se.column) == null ? void 0 : ye.columnDef) == null ? void 0 : Se.cell,
2502
+ props: (Ae = (we = H.supplier_name) == null ? void 0 : we.getContext) == null ? void 0 : Ae.call(we)
2503
+ }, null, 8, ["render", "props"])
2504
+ ]),
2505
+ l("div", da, P(q.original.items.map((fe) => `${fe.name}`).join(", ")), 1),
2506
+ q.original.ref ? (x(), D("div", ca, [
2507
+ c(t(de), {
2508
+ render: (Me = (ze = (Ee = H.ref) == null ? void 0 : Ee.column) == null ? void 0 : ze.columnDef) == null ? void 0 : Me.cell,
2509
+ props: (o = (be = H.ref) == null ? void 0 : be.getContext) == null ? void 0 : o.call(be)
2510
+ }, null, 8, ["render", "props"])
2511
+ ])) : L("", !0),
2512
+ l("div", ma, [
2513
+ c(t(de), {
2514
+ render: (ne = (B = (v = H.status) == null ? void 0 : v.column) == null ? void 0 : B.columnDef) == null ? void 0 : ne.cell,
2515
+ props: (ge = (re = H.status) == null ? void 0 : re.getContext) == null ? void 0 : ge.call(re)
2516
+ }, null, 8, ["render", "props"])
2517
+ ])
2518
+ ])
2519
+ ];
2520
+ }),
2521
+ _: 2
2522
+ }, 1032, ["row", "onRowClick"])
2523
+ ]),
2524
+ _: 1
2525
+ }, 8, ["style", "column-defs", "row-data", "search-value", "loading", "page-size"]))
2526
+ ], 2),
2527
+ (x(), Q(Dt, { to: "body" }, [
2528
+ c(Vo, Ye(t(i).transferDialogProps.value, {
2529
+ onSubmitted: t(i).fetchData
2530
+ }), null, 16, ["onSubmitted"]),
2531
+ c(Wt, Ye({
2532
+ scope: t(je).RECEIVE_REQUEST
2533
+ }, t(i).transferDetailsProps.value, {
2534
+ onSubmitted: t(i).fetchData
2535
+ }), null, 16, ["scope", "onSubmitted"]),
2536
+ c(na, Tt(Vt(t(i).xilnexImportDialogProps.value)), null, 16)
2537
+ ]))
2538
+ ];
2539
+ }),
2540
+ _: 1
2541
+ }, 8, ["title", "actions"]);
2542
+ };
2543
+ }
2544
+ });
2545
+ export {
2546
+ Da as default
2547
+ };