@feedmepos/mf-inventory-portal 0.0.22-dev.23 → 0.0.22-dev.25

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 (34) hide show
  1. package/dist/{ApprovalView-C5jr9Rv7.js → ApprovalView-CUG3A6eh.js} +4 -4
  2. package/dist/{BindingsDialog-DwQ2FG0q.js → BindingsDialog-C8VW5zTP.js} +1 -1
  3. package/dist/{BindingsPicker-DHzbaxZA.js → BindingsPicker-CmavNRBv.js} +1 -1
  4. package/dist/{BindingsTable-Cdl38M5V.js → BindingsTable-Ds7xU6eW.js} +1 -1
  5. package/dist/{ClosingTemplateView-CNI2s4p9.js → ClosingTemplateView-YLxmMOOb.js} +5 -5
  6. package/dist/{FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-BKvEBn1i.js → FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-Cs0N0_Eh.js} +1 -1
  7. package/dist/{IngredientsView-DS_l9O8H.js → IngredientsView-5VHrzfPZ.js} +3 -3
  8. package/dist/{IntegrationView-PxEi1K-z.js → IntegrationView-DGJQOKKQ.js} +2 -2
  9. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-DIOR3LyW.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-rntSnKF6.js} +1 -1
  10. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-CGUFCqIs.js → PremiumBadge.vue_vue_type_script_setup_true_lang-Fb96tdM4.js} +1 -1
  11. package/dist/{PurchaseOrderPrintPreview-Bkt9dkCI.js → PurchaseOrderPrintPreview-B4gVABOa.js} +1 -1
  12. package/dist/{ReceiveRequestView-BpKYdSAx.js → ReceiveRequestView-Dp3_jzUb.js} +6 -6
  13. package/dist/{RecipeView-DwMVz69Y.js → RecipeView-CD0g929Y.js} +3 -3
  14. package/dist/{StockView-DyLe5KUJ.js → StockView-JN120j0d.js} +6 -6
  15. package/dist/{SupplierView-CtlZH86C.js → SupplierView-C1O3gUXq.js} +3 -3
  16. package/dist/{TransferDetails.vue_vue_type_script_setup_true_lang-Cbq-C-lN.js → TransferDetails.vue_vue_type_script_setup_true_lang-By87tbHu.js} +4 -4
  17. package/dist/TransferDialog.vue_vue_type_script_setup_true_lang-hH7RapBS.js +1519 -0
  18. package/dist/{TransferTemplateView-Bn-h0lIx.js → TransferTemplateView-C780LnMc.js} +8 -8
  19. package/dist/{UnitView-BZKRc5bQ.js → UnitView-Cey0qpZj.js} +4 -4
  20. package/dist/{WarehouseView-heXatxJN.js → WarehouseView-B1CpNmgb.js} +2 -2
  21. package/dist/{app-BcRtBju3.js → app-Dxlsq-63.js} +5 -5
  22. package/dist/app.js +1 -1
  23. package/dist/{decimal-BW4-dJkS.js → decimal-BKt0urvU.js} +1 -1
  24. package/dist/{defineDeepModel-uuiMt6SI.js → defineDeepModel-CmsZ7uDL.js} +1 -1
  25. package/dist/{format-time-from-id-CFFnB2Xm.js → format-time-from-id-D1MP796l.js} +1 -1
  26. package/dist/{id-to-date-Eq_Y7TFp.js → id-to-date-Dgx5-GaK.js} +1 -1
  27. package/dist/{purchase-order-transaction-type-BeETndfM.js → purchase-order-transaction-type-BEVZywc0.js} +3 -3
  28. package/dist/{supplier-BWqPgsDR.js → supplier-DNgf0T_t.js} +1 -1
  29. package/dist/{use-template-enabled-locations-2-L61HiXQo.js → use-template-enabled-locations-2-F6vEnwMK.js} +1 -1
  30. package/dist/views/transfer-template/components/transfer-template-form/composables/use-transfer-locations.d.ts +38 -1
  31. package/dist/{xlsx-DnAptFFG.js → xlsx-Dz8oAq7m.js} +1 -1
  32. package/dist/{xlsx.util-CwrbPSsY.js → xlsx.util-BpLmwWed.js} +2 -2
  33. package/package.json +1 -1
  34. package/dist/TransferDialog.vue_vue_type_script_setup_true_lang-BI6GT9hU.js +0 -1502
@@ -1,1502 +0,0 @@
1
- import { reactive as Ge, onMounted as qe, computed as P, h as M, defineComponent as ie, openBlock as F, createElementBlock as $, Fragment as re, renderList as $e, createElementVNode as r, toDisplayString as D, unref as e, resolveComponent as I, createVNode as k, withCtx as O, createCommentVNode as z, ref as q, createBlock as j, watch as De, normalizeClass as Y, normalizeStyle as et, isRef as me } from "vue";
2
- import { useBreakpoints as Ne, components as pe, FmButtonVariant as tt, useSnackbar as Re, useDialog as st, useProxiedModel as ot } from "@feedmepos/ui-library";
3
- import { F as ke } from "./row-action.enum-PMKMRrZR.js";
4
- import { P as V, d as He, c as nt } from "./purchase-order-transaction-type-BeETndfM.js";
5
- import { a as Z, t as lt, ab as Ae, E as at, b as ze, R as Ve, a5 as rt, a7 as it, s as ut, a8 as Ee, a6 as dt, H as je, m as ct, A as Pe, M as pt, ac as Qe, P as Oe, Q as We, ad as mt, j as Ue, ae as ft, u as Be, af as yt, ag as vt, ah as bt, G as _t, ai as gt, aj as kt, z as Ct } from "./app-BcRtBju3.js";
6
- import { _ as Ye, u as ht } from "./PremiumBadge.vue_vue_type_script_setup_true_lang-CGUFCqIs.js";
7
- import { useI18n as ye } from "@feedmepos/mf-common";
8
- import "vue-router";
9
- import { u as Ie } from "./supplier-BWqPgsDR.js";
10
- import { d as wt } from "./defineDeepModel-uuiMt6SI.js";
11
- import { F as fe, _ as St } from "./TableActionableRow.vue_vue_type_script_setup_true_lang-DlNJ6kRg.js";
12
- import { _ as xt } from "./PreviewBadge.vue_vue_type_script_setup_true_lang-CRZiQHjx.js";
13
- function ae(n, v, u, i) {
14
- var c, p, g;
15
- if (i != null && i.manualTotalCost)
16
- return i == null ? void 0 : i.manualTotalCost;
17
- const d = (g = (p = (c = i == null ? void 0 : i.supplier) == null ? void 0 : c.supplyItems) == null ? void 0 : p.find(
18
- (y) => y.skuId === n._id
19
- )) == null ? void 0 : g.defaultCost, t = n.defaultCost, l = d ?? t, w = l == null ? void 0 : l.costPerUnit, m = w ? l != null && l.measurement ? +Z(w) / +Z(l == null ? void 0 : l.measurement.conversion) : +Z(w) : void 0, s = m ? u ? m * +Z(u.conversion) : m : void 0, a = s ? +Z(v) * s : void 0;
20
- return a ? {
21
- ...lt(a ?? 0, 2),
22
- currency: Ae()
23
- } : {
24
- amount: 0,
25
- precision: 0,
26
- currency: Ae()
27
- };
28
- }
29
- var B = /* @__PURE__ */ ((n) => (n.Code = "Code", n.Name = "Name", n.Amount = "Amount", n.Cost = "Cost", n.Delete = "Delete", n))(B || {});
30
- const Ft = () => {
31
- const { t: n } = ye();
32
- return M(
33
- Ye,
34
- {
35
- zIndex: 50,
36
- class: "whitespace-nowrap"
37
- },
38
- n("inventory.transfer.form.items.table.Cost", [Qe()])
39
- );
40
- };
41
- function Pt(n) {
42
- const { t: v } = ye(), u = Ge({}), { breakpoints: i } = Ne(), d = ze();
43
- qe(() => {
44
- for (const m of n.items) {
45
- if (!m.totalCost)
46
- continue;
47
- const s = ae(m.sku, m.quantity, m.measurement, {
48
- supplier: n.supplier
49
- }), a = m.totalCost ?? at.reset();
50
- s ? u[m.sku._id] = s.amount !== a.amount || s.precision !== a.precision : u[m.sku._id] = !0;
51
- }
52
- });
53
- function t(m) {
54
- var a, b, c, p, g, y, S;
55
- return !!(((b = (a = m.defaultCost) == null ? void 0 : a.costPerUnit) == null ? void 0 : b.amount) ?? ((S = (y = (g = (p = (c = n.supplier) == null ? void 0 : c.supplyItems) == null ? void 0 : p.find((x) => x.skuId === m._id)) == null ? void 0 : g.defaultCost) == null ? void 0 : y.costPerUnit) == null ? void 0 : S.amount));
56
- }
57
- const l = [
58
- {
59
- id: "Code",
60
- header: () => v("inventory.transfer.form.items.table.Code"),
61
- accessorKey: "code",
62
- size: 96,
63
- cell(m) {
64
- const s = m.row.original;
65
- return M(pe.FmTextField, {
66
- modelValue: s.code,
67
- "onUpdate:modelValue": (a) => {
68
- n.updateItem({
69
- ...s,
70
- code: a
71
- });
72
- },
73
- key: s.sku._id,
74
- rules: [Ve()],
75
- labelMark: "required"
76
- });
77
- },
78
- enableSorting: !1
79
- },
80
- {
81
- id: "Name",
82
- header: () => v("inventory.transfer.form.items.table.Name"),
83
- minSize: 300,
84
- cell(m) {
85
- const s = m.row.original;
86
- return M(pe.FmTextField, {
87
- modelValue: s.name,
88
- "onUpdate:modelValue": (a) => {
89
- n.updateItem({
90
- ...s,
91
- name: a
92
- });
93
- },
94
- key: s.sku._id,
95
- rules: [Ve()],
96
- labelMark: "required"
97
- });
98
- },
99
- enableSorting: !1
100
- },
101
- {
102
- id: "Amount",
103
- header: () => v("inventory.transfer.form.items.table.Amount"),
104
- minSize: 200,
105
- cell(m) {
106
- var b, c, p;
107
- const s = m.row.original, a = (p = (c = (b = n.template) == null ? void 0 : b.purchaseOrder) == null ? void 0 : c.items) == null ? void 0 : p.find(
108
- (g) => g.sku._id === s.sku._id
109
- );
110
- return M(rt, {
111
- style: {
112
- flex: "1 1 0%"
113
- },
114
- modelValue: {
115
- amount: s.quantity ?? { amount: 1, precision: 0 },
116
- measurement: s.measurement ?? null
117
- },
118
- key: s.sku._id,
119
- unit: s.sku.unit,
120
- "onUpdate:modelValue": (g) => {
121
- const y = {
122
- ...s,
123
- quantity: g.amount,
124
- measurement: g.measurement
125
- };
126
- d.enableTotalCost && (y.totalCost = ae(s.sku, s.quantity, s.measurement, {
127
- supplier: n.supplier,
128
- // NOTE: set undefined here if `manualTotalCost[row.sku._id] = false`, so that the function
129
- // will return the auto calculated default cost instead of the manual total cost
130
- manualTotalCost: u[s.sku._id] ? y.totalCost : void 0
131
- })), n.updateItem(y);
132
- },
133
- stepper: a == null ? void 0 : a.quantityStep,
134
- disableUnit: !!a,
135
- disabled: n.disabled,
136
- rules: [
137
- it(
138
- +Z(
139
- (a == null ? void 0 : a.minimumQuantity) ?? {
140
- amount: 1,
141
- precision: ut(s.sku.unit, s.measurement)
142
- }
143
- )
144
- ),
145
- a != null && a.maximumQuantity ? Ee(
146
- +Z(a == null ? void 0 : a.maximumQuantity)
147
- ) : Ee(1 / 0),
148
- ...a != null && a.quantityStep ? [dt(a.quantityStep)] : []
149
- ],
150
- applyDefaultRules: !0
151
- });
152
- },
153
- enableSorting: !1
154
- },
155
- {
156
- id: "Cost",
157
- header: Ft,
158
- size: 180,
159
- cell(m) {
160
- const s = m.row.original, a = t(s.sku), b = i.value.xs || i.value.sm;
161
- return !u[s.sku._id] && a ? M(
162
- "div",
163
- {
164
- class: [
165
- "flex gap-4 fm-typo-en-body-md-400 items-center",
166
- n.disabled ? "text-fm-color-typo-disabled" : ""
167
- ],
168
- key: s.sku._id
169
- },
170
- [
171
- M(pe.FmButton, {
172
- prependIcon: "edit",
173
- variant: tt.Tertiary,
174
- disabled: n.disabled,
175
- onClick() {
176
- n.updateItem({
177
- ...s,
178
- totalCost: ae(s.sku, s.quantity, s.measurement, {
179
- supplier: n.supplier
180
- })
181
- }), u[s.sku._id] = !0;
182
- }
183
- }),
184
- M(
185
- "div",
186
- {
187
- class: "flex flex-col"
188
- },
189
- [
190
- M(
191
- "span",
192
- b ? je(
193
- ae(s.sku, s.quantity, s.measurement, {
194
- supplier: n.supplier
195
- })
196
- ) : Z(
197
- ae(s.sku, s.quantity, s.measurement, {
198
- supplier: n.supplier
199
- })
200
- )
201
- ),
202
- M(
203
- "span",
204
- {
205
- class: [
206
- "fm-typo-en-body-sm-400",
207
- n.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-neutral-gray-400"
208
- ]
209
- },
210
- v("inventory.transfer.form.items.autoCalculated")
211
- )
212
- ]
213
- )
214
- ]
215
- ) : M(
216
- pe.FmTextField,
217
- {
218
- modelValue: Z(s.totalCost ?? { amount: 0, precision: 0 }),
219
- key: s.sku._id,
220
- "onUpdate:modelValue": (c) => {
221
- n.updateItem({
222
- ...s,
223
- totalCost: {
224
- ...ct(+c),
225
- currency: Ae()
226
- }
227
- });
228
- },
229
- rules: [Pe(0), pt(2)]
230
- },
231
- {
232
- prepend() {
233
- return b ? M(
234
- "div",
235
- {
236
- class: [
237
- "text-fm-typo-en-body-lg-400",
238
- n.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-typo-primary"
239
- ]
240
- },
241
- Qe()
242
- ) : null;
243
- },
244
- append() {
245
- return a ? M(pe.FmButton, {
246
- prependIcon: "close",
247
- variant: "tertiary",
248
- disabled: n.disabled,
249
- onClick() {
250
- n.updateItem({
251
- ...s,
252
- // NOTE: different from PO template, if a default cost is reenabled,
253
- // the total cost will automatically assigned
254
- totalCost: ae(s.sku, s.quantity, s.measurement, {
255
- supplier: n.supplier
256
- })
257
- }), u[s.sku._id] = !1;
258
- }
259
- }) : null;
260
- }
261
- }
262
- );
263
- },
264
- enableSorting: !1
265
- },
266
- {
267
- id: "Delete",
268
- header: "",
269
- cell(m) {
270
- const s = m.row.original;
271
- return M(pe.FmButton, {
272
- key: s.sku._id,
273
- class: "delete-button",
274
- type: "button",
275
- icon: "delete",
276
- variant: "tertiary",
277
- size: "md",
278
- disabled: n.disabled,
279
- onClick: () => {
280
- n.deleteItem(s);
281
- }
282
- });
283
- },
284
- enableSorting: !1,
285
- size: 40,
286
- meta: {
287
- cellClass: "",
288
- headerClass: ""
289
- }
290
- }
291
- ];
292
- return {
293
- columnDefs: P(() => d.enableTotalCost && n.transferType === V.PURCHASE ? l : l.filter(
294
- (m) => m.id !== "Cost"
295
- /* Cost */
296
- ))
297
- };
298
- }
299
- const It = { class: "flex flex-col gap-8 px-16 xs:px-4 sm:px-4 py-4 items-center" }, Tt = { class: "fm-typo-en-body-lg-600 xs:fm-typo-en-body-md-600 mr-auto xs:w-full" }, $t = { class: "w-[450px] xs:w-full flex" }, At = { class: "fm-typo-en-body-md-400 whitespace-nowrap" }, Vt = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Ze = /* @__PURE__ */ ie({
300
- __name: "SupplierPriceHistory",
301
- props: {
302
- prices: {}
303
- },
304
- setup(n) {
305
- const v = Ie();
306
- function u(i) {
307
- return v.suppliers.find((d) => d._id === i);
308
- }
309
- return (i, d) => (F(), $("div", It, [
310
- (F(!0), $(re, null, $e(Object.keys(i.prices), (t) => {
311
- var l;
312
- return F(), $("div", {
313
- key: t,
314
- class: "flex items-center gap-12 xs:gap-4 xs:flex-wrap w-full"
315
- }, [
316
- r("div", Tt, D((l = u(t)) == null ? void 0 : l.name), 1),
317
- r("div", $t, [
318
- (F(!0), $(re, null, $e(i.prices[t].slice(0, 3), (w) => {
319
- var m;
320
- return F(), $("div", {
321
- key: w.date,
322
- class: "flex flex-col w-[150px] xs:flex-1 text-ellipsis cursor-pointer"
323
- }, [
324
- r("div", At, [
325
- r("span", null, D(w.totalCost ? e(je)(w.totalCost) : "No data"), 1),
326
- d[0] || (d[0] = r("span", { class: "text-fm-color-typo-secondary" }, "/", -1)),
327
- r("span", null, D(e(Z)(w.totalUnit, !1)), 1),
328
- r("span", null, D(((m = w.measurement) == null ? void 0 : m.abbrev) ?? w.unit.abbrev), 1)
329
- ]),
330
- r("div", Vt, [
331
- r("span", null, "(#" + D(w.seqNumber) + ")", 1),
332
- d[1] || (d[1] = r("span", null, D(" "), -1)),
333
- r("span", null, D(e(Oe)(new Date(w.date))), 1)
334
- ])
335
- ]);
336
- }), 128))
337
- ])
338
- ]);
339
- }), 128))
340
- ]));
341
- }
342
- }), Dt = { class: "flex flex-col gap-8 py-16" }, Rt = { class: "flex items-center" }, Ot = { class: "flex-1 flex gap-1 items-center" }, Ut = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, Bt = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, Mt = { class: "flex gap-8 w-full" }, Et = { class: "flex-1 flex flex-col gap-4" }, Lt = { class: "flex-1 flex flex-col gap-4" }, qt = { class: "flex gap-8 w-full" }, Nt = { class: "flex-1 flex flex-col gap-4" }, Ht = {
343
- key: 0,
344
- class: "flex-1 flex flex-col gap-4"
345
- }, zt = /* @__PURE__ */ ie({
346
- __name: "TransferItem",
347
- props: {
348
- cellByColId: {},
349
- comparePriceBySku: {},
350
- showComparePrice: { type: Boolean },
351
- row: {}
352
- },
353
- setup(n) {
354
- const { t: v } = ye();
355
- return (u, i) => {
356
- var l, w, m, s, a, b, c, p, g, y, S, x, E, A, U, L, G, ee, K, J, Q, _, C, R, te, W, se;
357
- const d = I("FmLabel"), t = I("FmSpacer");
358
- return F(), $("div", Dt, [
359
- r("div", Rt, [
360
- r("div", Ot, [
361
- r("span", Ut, " (" + D(u.row.original.sku.code) + ") ", 1),
362
- r("span", Bt, D(u.row.original.sku.name), 1)
363
- ]),
364
- r("div", null, [
365
- k(e(fe), {
366
- render: (m = (w = (l = u.cellByColId.Delete) == null ? void 0 : l.column) == null ? void 0 : w.columnDef) == null ? void 0 : m.cell,
367
- props: (a = (s = u.cellByColId.Delete) == null ? void 0 : s.getContext) == null ? void 0 : a.call(s)
368
- }, null, 8, ["render", "props"])
369
- ])
370
- ]),
371
- r("div", Mt, [
372
- r("div", Et, [
373
- k(d, {
374
- label: e(v)(`inventory.transfer.form.items.table.${e(B).Code}`)
375
- }, null, 8, ["label"]),
376
- k(e(fe), {
377
- render: (p = (c = (b = u.cellByColId[e(B).Code]) == null ? void 0 : b.column) == null ? void 0 : c.columnDef) == null ? void 0 : p.cell,
378
- props: (y = (g = u.cellByColId[e(B).Code]) == null ? void 0 : g.getContext) == null ? void 0 : y.call(g)
379
- }, null, 8, ["render", "props"]),
380
- i[0] || (i[0] = r("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
381
- ]),
382
- r("div", Lt, [
383
- k(d, {
384
- label: e(v)(`inventory.transfer.form.items.table.${e(B).Name}`)
385
- }, null, 8, ["label"]),
386
- k(e(fe), {
387
- render: (E = (x = (S = u.cellByColId[e(B).Name]) == null ? void 0 : S.column) == null ? void 0 : x.columnDef) == null ? void 0 : E.cell,
388
- props: (U = (A = u.cellByColId[e(B).Name]) == null ? void 0 : A.getContext) == null ? void 0 : U.call(A)
389
- }, null, 8, ["render", "props"]),
390
- i[1] || (i[1] = r("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
391
- ])
392
- ]),
393
- r("div", qt, [
394
- r("div", Nt, [
395
- k(d, {
396
- label: e(v)(`inventory.transfer.form.items.table.${e(B).Amount}`)
397
- }, null, 8, ["label"]),
398
- k(e(fe), {
399
- render: (ee = (G = (L = u.cellByColId[e(B).Amount]) == null ? void 0 : L.column) == null ? void 0 : G.columnDef) == null ? void 0 : ee.cell,
400
- props: (J = (K = u.cellByColId[e(B).Amount]) == null ? void 0 : K.getContext) == null ? void 0 : J.call(K)
401
- }, null, 8, ["render", "props"]),
402
- i[2] || (i[2] = r("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
403
- ]),
404
- u.cellByColId[e(B).Cost] ? (F(), $("div", Ht, [
405
- k(Ye, { "z-index": 50 }, {
406
- default: O(() => [
407
- k(d, {
408
- label: e(v)(`inventory.transfer.form.items.table.${e(B).Cost}2`)
409
- }, null, 8, ["label"])
410
- ]),
411
- _: 1
412
- }),
413
- k(e(fe), {
414
- render: (C = (_ = (Q = u.cellByColId[e(B).Cost]) == null ? void 0 : Q.column) == null ? void 0 : _.columnDef) == null ? void 0 : C.cell,
415
- props: (te = (R = u.cellByColId[e(B).Cost]) == null ? void 0 : R.getContext) == null ? void 0 : te.call(R)
416
- }, null, 8, ["render", "props"]),
417
- i[3] || (i[3] = r("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
418
- ])) : z("", !0)
419
- ]),
420
- u.showComparePrice && Object.keys(u.comparePriceBySku[(W = u.row.original.sku) == null ? void 0 : W._id] ?? {}).length > 0 ? (F(), $(re, { key: 0 }, [
421
- k(t, { class: "h-8" }),
422
- k(Ze, {
423
- prices: u.comparePriceBySku[(se = u.row.original.sku) == null ? void 0 : se._id]
424
- }, null, 8, ["prices"])
425
- ], 64)) : z("", !0)
426
- ]);
427
- };
428
- }
429
- });
430
- function Ce(n) {
431
- return mt.parse(n);
432
- }
433
- function Fe(n) {
434
- return {
435
- _id: n.doc._id,
436
- internal: n.type,
437
- contactName: n.doc.profile.name,
438
- name: n.doc.profile.name,
439
- email: n.doc.profile.email,
440
- phoneNumber: n.doc.profile.phoneNo,
441
- registrationNumber: n.doc.profile.regNo,
442
- address: n.doc.profile.address
443
- };
444
- }
445
- function jt(n, v, u = !1) {
446
- const i = Ie(), d = Ue();
447
- d.watchLocation(async () => {
448
- var S;
449
- await i.readSuppliers();
450
- const c = n();
451
- if ((S = c.supplier) != null && S._id) return;
452
- const p = d.businessLevel ? i.businessSuppliers[0] : i.suppliers[0], y = (u ? d.locations.filter((x) => x.doc._id !== d.currentLocation.doc._id) : d.locations)[0];
453
- v({
454
- ...c,
455
- supplier: p ? Ce(p) : y ? Fe(y) : c.supplier
456
- });
457
- });
458
- const t = P(
459
- () => {
460
- var c, p;
461
- return typeof ((p = (c = n()) == null ? void 0 : c.supplier) == null ? void 0 : p.internal) == "string" ? V.TRANSFER : V.PURCHASE;
462
- }
463
- ), l = P({
464
- get() {
465
- var c, p;
466
- return (p = (c = n()) == null ? void 0 : c.supplier) == null ? void 0 : p._id;
467
- },
468
- set(c) {
469
- const p = n() ?? {};
470
- if (t.value === V.PURCHASE) {
471
- const E = (d.businessLevel ? i.businessSuppliers : i.suppliers).find((A) => A._id === c);
472
- v({
473
- ...p,
474
- supplier: E ? Ce(E) : p.supplier
475
- });
476
- return;
477
- }
478
- const S = (u ? d.locations.filter((x) => x.doc._id !== d.currentLocation.doc._id) : d.locations).find((x) => x.doc._id === c);
479
- v({
480
- ...p,
481
- supplier: S ? Fe(S) : p.supplier
482
- });
483
- }
484
- }), w = P(() => i.locationSuppliers.map(Ce)), m = P(() => i.businessSuppliers.map(Ce)), s = P(() => {
485
- var g;
486
- const c = ((g = d._currentLocation) == null ? void 0 : g.type) === We.warehouse;
487
- return (u ? d.locations.filter((y) => y.doc._id !== d.currentLocation.doc._id) : d.locations).filter((y) => c || y.acceptRequest).map(Fe);
488
- }), a = P(() => {
489
- if (t.value === V.PURCHASE) {
490
- const p = w.value.map((y) => ({
491
- label: y.name,
492
- value: y._id
493
- })), g = m.value.map((y) => ({
494
- label: y.name,
495
- sublabel: "Business supplier",
496
- value: y._id
497
- }));
498
- return d.businessLevel ? g : [...p, ...g];
499
- }
500
- return s.value.map((p) => ({
501
- label: p.name,
502
- sublabel: p.internal ? `${p.internal}` : void 0,
503
- value: p._id
504
- }));
505
- }), b = P(() => {
506
- var y, S;
507
- const c = (S = (y = n()) == null ? void 0 : y.supplier) == null ? void 0 : S._id;
508
- if (t.value === V.PURCHASE) {
509
- const x = i.suppliers.find((E) => E._id === c);
510
- return x ? Ce(x) : null;
511
- }
512
- const g = d.locations.find((x) => x.doc._id);
513
- return g ? Fe(g) : null;
514
- });
515
- return {
516
- transferLocationModel: l,
517
- transferLocationOptions: a,
518
- locationOptionsTypePurchase: w,
519
- locationOptionsTypeTransfer: s,
520
- selectedLocation: b
521
- };
522
- }
523
- function Qt(n) {
524
- const v = P({
525
- get() {
526
- const t = n.getEffectiveAt();
527
- return t ? new Date(t) : null;
528
- },
529
- set(t) {
530
- n.setEffectiveAt((t == null ? void 0 : t.toISOString()) ?? null);
531
- }
532
- }), u = P({
533
- get() {
534
- return !!v.value;
535
- },
536
- set(t) {
537
- t ? v.value = /* @__PURE__ */ new Date() : v.value = null;
538
- }
539
- }), i = P({
540
- get() {
541
- return v.value === null ? "" : Oe(v.value);
542
- },
543
- set(t) {
544
- t ? v.value = /* @__PURE__ */ new Date(`${t} ${d.value}`) : v.value = null;
545
- }
546
- }), d = P({
547
- get() {
548
- return v.value === null ? "" : ft(v.value);
549
- },
550
- set(t) {
551
- t ? v.value = /* @__PURE__ */ new Date(`${i.value} ${t}`) : v.value = null;
552
- }
553
- });
554
- return {
555
- backdatePo: v,
556
- backdateSwitch: u,
557
- backdateModel: i,
558
- backdateTimeModel: d
559
- };
560
- }
561
- const Wt = {
562
- width: "24",
563
- height: "24",
564
- viewBox: "0 0 24 24",
565
- fill: "none",
566
- xmlns: "http://www.w3.org/2000/svg"
567
- }, Yt = ["fill"], Zt = ["fill"], Kt = ["stroke"], Jt = ["stroke"], Xt = /* @__PURE__ */ ie({
568
- __name: "SparkIcon",
569
- props: {
570
- size: {
571
- type: Number,
572
- default: 24
573
- },
574
- color: {
575
- type: String,
576
- default: "#c7c7cc"
577
- }
578
- },
579
- setup(n) {
580
- return (v, u) => (F(), $("svg", Wt, [
581
- r("path", {
582
- 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",
583
- fill: n.color
584
- }, null, 8, Yt),
585
- r("path", {
586
- 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",
587
- fill: n.color
588
- }, null, 8, Zt),
589
- r("path", {
590
- 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",
591
- stroke: n.color,
592
- "stroke-width": "1.5",
593
- "stroke-linecap": "round",
594
- "stroke-linejoin": "round"
595
- }, null, 8, Kt),
596
- r("path", {
597
- 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",
598
- stroke: n.color,
599
- "stroke-width": "1.5",
600
- "stroke-linecap": "round",
601
- "stroke-linejoin": "round"
602
- }, null, 8, Jt)
603
- ]));
604
- }
605
- }), Gt = { class: "flex gap-8 items-center" }, es = { class: "fm-typo-en-body-lg-600 line-clamp-1" }, ts = { class: "w-[343px] px-24 py-16 rounded-lg shadow-light-300 flex flex-col gap-[20px]" }, ss = { class: "flex items-center w-full" }, os = { class: "flex-1" }, ns = { class: "fm-typo-en-title-sm-800" }, ls = { class: "flex items-start gap-8" }, as = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, rs = { class: "flex gap-1" }, Le = /* @__PURE__ */ ie({
606
- __name: "ForecastStock",
607
- props: {
608
- disabled: { type: Boolean }
609
- },
610
- emits: ["update:poItems"],
611
- setup(n, { emit: v }) {
612
- const u = v, i = q(!1), d = q(7), t = ht(), l = Re(), w = Be(), { t: m } = ye();
613
- async function s() {
614
- if (d.value < 1)
615
- return;
616
- i.value = !1, await t.readPurchaseOrder(d.value);
617
- const a = [];
618
- if (t.purchaseOrderForecast.skus.length <= 0) {
619
- l.open({
620
- message: m("inventory.transfer.form.items.forecastStock.notAvailable"),
621
- type: "info"
622
- });
623
- return;
624
- }
625
- const b = t.purchaseOrderForecast.skus.reduce((c, p) => {
626
- const g = w.skus.find((x) => x._id === p.id);
627
- if (c.find((x) => x.sku._id === p.id) || !g)
628
- return c;
629
- const S = {
630
- sku: g,
631
- code: g.code,
632
- name: g.name,
633
- quantity: {
634
- amount: p.amount,
635
- precision: 0
636
- }
637
- };
638
- return c.push(S), c;
639
- }, a);
640
- u("update:poItems", b);
641
- }
642
- return (a, b) => {
643
- const c = I("FmButton"), p = I("FmIcon"), g = I("FmStepperField"), y = I("FmPopover");
644
- return F(), j(y, {
645
- disabled: a.disabled,
646
- class: "flex",
647
- "show-popover": i.value,
648
- onPopoverChanged: b[3] || (b[3] = (S) => i.value = S)
649
- }, {
650
- "popover-button": O(() => [
651
- k(c, {
652
- label: "unused",
653
- variant: "secondary",
654
- "text-color": a.disabled ? "disabled" : "primary",
655
- "bg-color": "transparent",
656
- "border-color": a.disabled ? "disabled" : "primary",
657
- disabled: a.disabled
658
- }, {
659
- default: O(() => [
660
- r("div", Gt, [
661
- k(Xt, {
662
- size: 24,
663
- color: a.disabled ? "#c7c7cc" : "#ff7823"
664
- }, null, 8, ["color"]),
665
- r("div", es, D(e(m)("inventory.transfer.form.items.forecastStock.title")), 1)
666
- ])
667
- ]),
668
- _: 1
669
- }, 8, ["text-color", "border-color", "disabled"])
670
- ]),
671
- default: O(() => [
672
- r("div", ts, [
673
- r("div", ss, [
674
- r("div", os, [
675
- k(xt, { "z-index": 99 }, {
676
- default: O(() => [
677
- r("p", ns, D(e(m)("inventory.transfer.form.items.forecastStock.title")), 1)
678
- ]),
679
- _: 1
680
- })
681
- ]),
682
- k(c, {
683
- icon: "close",
684
- size: "md",
685
- variant: "tertiary",
686
- onClick: b[0] || (b[0] = (S) => i.value = !1)
687
- })
688
- ]),
689
- k(g, {
690
- modelValue: d.value,
691
- "onUpdate:modelValue": b[1] || (b[1] = (S) => d.value = S),
692
- label: e(m)("inventory.transfer.form.items.forecastStock.days"),
693
- rules: [e(Pe)(1)]
694
- }, {
695
- "helper-text": O(() => [
696
- r("div", ls, [
697
- k(p, {
698
- name: "warning",
699
- size: "sm",
700
- class: "text-fm-color-system-warning-300"
701
- }),
702
- r("div", as, D(e(m)("inventory.transfer.form.items.forecastStock.replace")), 1)
703
- ])
704
- ]),
705
- _: 1
706
- }, 8, ["modelValue", "label", "rules"]),
707
- r("div", rs, [
708
- b[4] || (b[4] = r("div", { class: "grow" }, null, -1)),
709
- k(c, {
710
- label: e(m)("common.cancel"),
711
- variant: "tertiary",
712
- onClick: b[2] || (b[2] = (S) => i.value = !1)
713
- }, null, 8, ["label"]),
714
- k(c, {
715
- label: e(m)("inventory.transfer.form.items.forecastStock.generate"),
716
- onClick: s
717
- }, null, 8, ["label"])
718
- ])
719
- ])
720
- ]),
721
- _: 1
722
- }, 8, ["disabled", "show-popover"]);
723
- };
724
- }
725
- });
726
- function is() {
727
- const n = Re(), v = He(), u = q(!1);
728
- De(u, (l) => {
729
- l && (d.value = !0, i().finally(() => {
730
- d.value = !1;
731
- }));
732
- });
733
- async function i() {
734
- try {
735
- const { startDate: l, endDate: w } = yt(6), a = (await v.getPurchaseOrders({ start: l, end: w })).filter(
736
- (b) => {
737
- var c, p;
738
- return b.status === vt.enum.COMPLETE && ((c = b.supplier) == null ? void 0 : c.internal) !== "warehouse" && ((p = b.supplier) == null ? void 0 : p.internal) !== "restaurant";
739
- }
740
- ).reduce((b, c) => {
741
- const p = new Date(bt(c._id)), g = c.supplier._id;
742
- for (const y of c.items) {
743
- if (!y.totalCost) continue;
744
- const S = b[y.sku._id] ?? {}, x = S[g] ?? [];
745
- x.push({
746
- date: p.toISOString(),
747
- totalUnit: y.quantity,
748
- totalCost: y.totalCost,
749
- unit: y.sku.unit,
750
- measurement: y.measurement,
751
- seqNumber: c.seqNumber
752
- }), S[g] = x, b[y.sku._id] = S;
753
- }
754
- return b;
755
- }, {});
756
- t.value = a;
757
- } catch {
758
- n.open({
759
- title: "Something went wrong",
760
- message: "Cannot retrieve supplier purchase history. Please try again."
761
- }), u.value = !1;
762
- }
763
- }
764
- const d = q(!1), t = q({});
765
- return {
766
- comparePricesToggle: u,
767
- comparePriceFetching: d,
768
- comparePriceBySku: t
769
- };
770
- }
771
- const us = { class: "fm-typo-body-md-400 line-clamp-2 w-full" }, ds = { key: 0 }, cs = ["colspan"], ps = /* @__PURE__ */ ie({
772
- __name: "TransferItemTable",
773
- props: {
774
- row: {},
775
- comparePriceBySku: {},
776
- showComparePrice: { type: Boolean }
777
- },
778
- setup(n) {
779
- function v(u) {
780
- return u.column.columnDef.meta;
781
- }
782
- return (u, i) => {
783
- var d, t;
784
- return F(), $(re, null, [
785
- r("tr", {
786
- class: Y(["border-b border-fm-color-neutral-gray-100 hover:bg-fm-color-opacity-sm", {
787
- "bg-fm-color-neutral-gray-100": u.row.getIsSelected()
788
- }])
789
- }, [
790
- (F(!0), $(re, null, $e(u.row.getVisibleCells(), (l) => {
791
- var w, m, s, a;
792
- return F(), $("td", {
793
- key: l.id,
794
- class: Y([
795
- "h-[52px] px-16 text-fm-color-typo-primary",
796
- ((w = v(l)) == null ? void 0 : w.cellClass) ?? "px-16"
797
- ]),
798
- style: et({
799
- width: (m = v(l)) == null ? void 0 : m.width,
800
- maxWidth: (s = v(l)) == null ? void 0 : s.maxWidth,
801
- textAlign: ((a = v(l)) == null ? void 0 : a.textAlign) ?? "left"
802
- })
803
- }, [
804
- r("span", us, [
805
- k(e(fe), {
806
- render: l.column.columnDef.cell,
807
- props: l.getContext()
808
- }, null, 8, ["render", "props"])
809
- ])
810
- ], 6);
811
- }), 128))
812
- ], 2),
813
- u.showComparePrice && Object.keys(u.comparePriceBySku[(d = u.row.original.sku) == null ? void 0 : d._id] ?? {}).length > 0 ? (F(), $("tr", ds, [
814
- r("td", {
815
- colspan: u.row.getVisibleCells().length
816
- }, [
817
- k(Ze, {
818
- prices: u.comparePriceBySku[(t = u.row.original.sku) == null ? void 0 : t._id]
819
- }, null, 8, ["prices"])
820
- ], 8, cs)
821
- ])) : z("", !0)
822
- ], 64);
823
- };
824
- }
825
- }), ms = { class: "flex flex-col gap-4" }, fs = { class: "flex items-center gap-8 overflow-x-auto pb-12" }, ys = { class: "flex flex-col gap-16" }, vs = { class: "flex flex-col gap-24" }, bs = { class: "flex flex-col gap-8" }, _s = { class: "flex flex-col gap-4" }, gs = { class: "flex flex-col gap-8" }, ks = { class: "flex flex-col gap-4" }, Cs = {
826
- key: 3,
827
- class: "p-16 border border-fm-color-neutral-gray-300 fm-corner-radius-md flex flex-col"
828
- }, hs = {
829
- key: 0,
830
- class: "flex-1 flex gap-8 h-48 xs:flex-col xs:pt-16 sm:flex-col sm:pt-16"
831
- }, ws = { class: "flex-1" }, Ss = { class: "flex-1" }, xs = {
832
- key: 1,
833
- class: "flex items-center gap-4"
834
- }, Fs = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary translate-y-[1px]" }, Ps = { class: "flex flex-col gap-16" }, Is = { class: "flex-1 gap-8 fm-typo-en-title-sm-600" }, Ts = { class: "flex gap-8" }, $s = { key: 0 }, As = /* @__PURE__ */ ie({
835
- __name: "TransferForm2",
836
- props: {
837
- modelValue: {},
838
- request: {},
839
- disabled: { type: Boolean },
840
- suppliers: {},
841
- skus: {},
842
- lastClosingDate: {}
843
- },
844
- emits: ["validation-success", "form:ready"],
845
- setup(n, { expose: v, emit: u }) {
846
- const i = n, d = u, t = wt(), { t: l } = ye(), w = Ue(), m = Be(), s = kt(), a = Ie(), b = ze(), c = nt(), { breakpoints: p } = Ne(), g = P(() => p.value.xs || p.value.sm), y = P(
847
- () => c.templates.value.find((o) => o._id === t.template)
848
- ), S = P(() => t.status === "DRAFT" || !t._rev);
849
- De(y, (o) => {
850
- var f;
851
- o && ((f = t.supplier) != null && f._id || (t.supplier = (o == null ? void 0 : o.purchaseOrder.supplier) ?? t.supplier));
852
- }), qe(async () => {
853
- var o;
854
- try {
855
- if (!t.template) return;
856
- await c.loadTemplate(t.template), t.items.length || (t.items = ((o = y.value) == null ? void 0 : o.purchaseOrder.items) ?? []);
857
- } finally {
858
- d("form:ready");
859
- }
860
- });
861
- const x = P(
862
- () => w.currentLocation.type === We.restaurant
863
- );
864
- w.watchLocation(async () => {
865
- location && (t.supplier || (t.supplier = a.suppliers.find((o) => o) ?? t.supplier));
866
- });
867
- const E = st(), A = jt(
868
- () => t,
869
- (o) => {
870
- Object.assign(t, o);
871
- },
872
- !0
873
- ), U = P({
874
- get() {
875
- var o;
876
- return typeof ((o = t == null ? void 0 : t.supplier) == null ? void 0 : o.internal) == "string" ? V.TRANSFER : V.PURCHASE;
877
- },
878
- set(o) {
879
- var N;
880
- const f = typeof ((N = t == null ? void 0 : t.supplier) == null ? void 0 : N.internal) == "string" ? V.TRANSFER : V.PURCHASE;
881
- o !== f && (t.supplier = o === V.PURCHASE ? A.locationOptionsTypePurchase.value[0] : A.locationOptionsTypeTransfer.value[0]);
882
- }
883
- }), L = P(() => A.transferLocationOptions.value), G = P({
884
- get() {
885
- return t.supplier._id;
886
- },
887
- set(o) {
888
- A.transferLocationModel.value = o;
889
- }
890
- }), ee = P({
891
- get() {
892
- return t.remark ?? void 0;
893
- },
894
- set(o) {
895
- t.remark = o;
896
- }
897
- }), K = P({
898
- get() {
899
- var o;
900
- return ((o = t.netSuite) == null ? void 0 : o.subsidiary) ?? null;
901
- },
902
- set(o) {
903
- var oe;
904
- t.netSuite = {
905
- ...t.netSuite,
906
- subsidiary: o
907
- };
908
- const f = s.getAvailableItems((oe = t.netSuite) == null ? void 0 : oe.subsidiary.id), N = t.items.map((H) => H.sku._id).filter((H) => f.includes(H));
909
- t.items = t.items.filter((H) => N.includes(H.sku._id));
910
- }
911
- }), { backdatePo: J, backdateSwitch: Q, backdateModel: _, backdateTimeModel: C } = Qt({
912
- getEffectiveAt() {
913
- return t.effectiveAt;
914
- },
915
- setEffectiveAt(o) {
916
- t.effectiveAt = o;
917
- }
918
- }), { comparePricesToggle: R, comparePriceFetching: te, comparePriceBySku: W } = is(), se = q();
919
- v({
920
- validateInputs: () => {
921
- var o, f;
922
- (f = (o = se.value) == null ? void 0 : o.validateInputs) == null || f.call(o);
923
- },
924
- resetInputsValidation: () => {
925
- var o, f;
926
- (f = (o = se.value) == null ? void 0 : o.resetInputsValidation) == null || f.call(o);
927
- },
928
- resetInputs: () => {
929
- var o, f;
930
- (f = (o = se.value) == null ? void 0 : o.resetInputs) == null || f.call(o);
931
- }
932
- });
933
- const Ke = Pt({
934
- updateItem: (o) => {
935
- t.items = t.items.map((f) => f.sku._id !== o.sku._id ? f : o);
936
- },
937
- deleteItem: (o) => {
938
- t.items = t.items.filter((f) => f.sku._id !== o.sku._id);
939
- },
940
- get supplier() {
941
- return t.supplier;
942
- },
943
- get items() {
944
- return t.items;
945
- },
946
- get transferType() {
947
- return U.value;
948
- },
949
- get template() {
950
- return y.value;
951
- },
952
- get disabled() {
953
- return i.disabled;
954
- }
955
- }), Je = P(() => Ke.columnDefs.value);
956
- function Xe() {
957
- var he, we, be, Se;
958
- const o = new Set((be = (we = (he = y.value) == null ? void 0 : he.purchaseOrder) == null ? void 0 : we.items) == null ? void 0 : be.map((T) => T.sku._id)), f = s.getAvailableItems((Se = t.netSuite) == null ? void 0 : Se.subsidiary.id), N = o.size ? m.skus.filter((T) => o.has(T._id)) : m.skus, oe = N.map((T) => T._id).filter((T) => f.includes(T)), H = N.map(
959
- (T) => ({
960
- label: T.name,
961
- sublabel: T.code,
962
- value: T,
963
- disabled: !oe.includes(T._id)
964
- })
965
- ), ve = H.filter((T) => {
966
- var ne;
967
- return (ne = t.items) == null ? void 0 : ne.find((ue) => ue.sku._id === T.value._id);
968
- }).map((T) => T.value);
969
- E.open({
970
- title: l("inventory.transfer.form.items.selectItem"),
971
- closeButton: !0,
972
- contentComponent: Ct,
973
- contentComponentProps: {
974
- modelValue: ve,
975
- items: H,
976
- virtualScroll: !0
977
- },
978
- primaryActions: {
979
- text: l("common.confirm"),
980
- close: !0
981
- },
982
- secondaryActions: {
983
- text: l("common.close"),
984
- close: !0,
985
- variant: "tertiary"
986
- }
987
- }).onPrimary((T) => {
988
- const ne = t.items ?? [], ue = T.map((X) => {
989
- var xe, _e;
990
- const de = ne.find((ce) => ce.sku._id === X._id);
991
- if (de)
992
- return de;
993
- const le = ((_e = (xe = y.value) == null ? void 0 : xe.purchaseOrder.items) == null ? void 0 : _e.find(
994
- (ce) => ce.sku._id === X._id
995
- )) ?? {
996
- sku: X,
997
- code: X.code,
998
- name: X.name,
999
- quantity: {
1000
- amount: 1,
1001
- precision: 0
1002
- }
1003
- };
1004
- return U.value == V.PURCHASE && (le.totalCost = ae(
1005
- le.sku,
1006
- le.quantity,
1007
- le.measurement,
1008
- {
1009
- supplier: t.supplier
1010
- }
1011
- )), le;
1012
- });
1013
- ue.sort((X, de) => X.sku.code.localeCompare(de.sku.code)), t.items = ue;
1014
- });
1015
- }
1016
- function Os(o) {
1017
- return o;
1018
- }
1019
- return (o, f) => {
1020
- var _e, ce;
1021
- const N = I("FmChip"), oe = I("FmLabel"), H = I("FmField"), ve = I("FmSelect"), he = I("FmTextField"), we = I("FmTextarea"), be = I("FmSwitch"), Se = I("FmDatePicker"), T = I("FmTimePicker"), ne = I("FmFormGroup"), ue = I("FmIcon"), X = I("FmButton"), de = I("FmTooltip"), le = I("FmTable"), xe = I("FmForm");
1022
- return F(), $("div", ms, [
1023
- r("div", fs, [
1024
- (_e = i.modelValue) != null && _e.template ? (F(), j(N, {
1025
- key: 0,
1026
- variant: o.disabled ? "warning" : void 0,
1027
- label: `${e(l)("inventory.transfer.template.title")}: ${((ce = y.value) == null ? void 0 : ce.name) ?? e(l)("inventory.transfer.form.loading")}`,
1028
- icon: "summarize",
1029
- compact: ""
1030
- }, null, 8, ["variant", "label"])) : z("", !0),
1031
- k(N, {
1032
- label: e(w).currentLocation.name,
1033
- icon: "storefront",
1034
- compact: ""
1035
- }, null, 8, ["label"]),
1036
- o.lastClosingDate ? (F(), j(N, {
1037
- key: 1,
1038
- label: `${e(l)("inventory.transfer.form.lastClosing")}: ${e(Oe)(o.lastClosingDate)} ${e(_t)(o.lastClosingDate)}`,
1039
- icon: "calendar_month",
1040
- compact: ""
1041
- }, null, 8, ["label"])) : z("", !0)
1042
- ]),
1043
- k(xe, {
1044
- ref_key: "formRef",
1045
- ref: se,
1046
- class: "flex flex-col gap-32",
1047
- disabled: o.disabled,
1048
- onValidationFailed: console.log,
1049
- onValidationSuccess: f[13] || (f[13] = (Te) => d("validation-success"))
1050
- }, {
1051
- default: O(() => {
1052
- var Te, Me;
1053
- return [
1054
- r("div", ys, [
1055
- r("div", vs, [
1056
- (Te = i.modelValue) != null && Te.template ? (F(), $(re, { key: 0 }, [
1057
- r("div", bs, [
1058
- k(oe, {
1059
- label: e(l)("inventory.transfer.form.type.title")
1060
- }, null, 8, ["label"]),
1061
- r("div", _s, [
1062
- k(H, null, {
1063
- default: O(() => [
1064
- r("span", {
1065
- class: Y({ "text-fm-color-typo-disabled": o.disabled })
1066
- }, D(e(l)(`inventory.transfer.form.type.${U.value.toLocaleLowerCase("en-us")}`)), 3)
1067
- ]),
1068
- _: 1
1069
- }),
1070
- r("div", {
1071
- class: Y([
1072
- "fm-typo-en-body-sm-400",
1073
- o.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-typo-secondary"
1074
- ])
1075
- }, " This field is locked from template. ", 2)
1076
- ])
1077
- ]),
1078
- r("div", gs, [
1079
- k(oe, {
1080
- label: U.value === e(V).PURCHASE ? e(l)("inventory.transfer.form.purchaseFrom") : e(l)("inventory.transfer.form.transferFrom")
1081
- }, null, 8, ["label"]),
1082
- r("div", ks, [
1083
- k(H, null, {
1084
- default: O(() => {
1085
- var h;
1086
- return [
1087
- r("span", {
1088
- class: Y({ "text-fm-color-typo-disabled": o.disabled })
1089
- }, D((h = L.value.find((ge) => ge.value === G.value)) == null ? void 0 : h.label), 3)
1090
- ];
1091
- }),
1092
- _: 1
1093
- }),
1094
- r("div", {
1095
- class: Y([
1096
- "fm-typo-en-body-sm-400",
1097
- o.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-typo-secondary"
1098
- ])
1099
- }, " This field is locked from template. ", 2)
1100
- ])
1101
- ])
1102
- ], 64)) : (F(), $(re, { key: 1 }, [
1103
- k(ve, {
1104
- label: e(l)("inventory.transfer.form.type.title"),
1105
- "model-value": U.value,
1106
- "onUpdate:modelValue": f[0] || (f[0] = (h) => U.value = h),
1107
- items: [
1108
- {
1109
- label: e(l)("inventory.transfer.form.type.purchase"),
1110
- value: e(V).PURCHASE,
1111
- disabled: !e(A).locationOptionsTypePurchase.value.length,
1112
- sublabel: e(A).locationOptionsTypePurchase.value.length ? void 0 : e(l)("inventory.transfer.form.noSupplierAvailable")
1113
- },
1114
- {
1115
- label: e(l)("inventory.transfer.form.type.transfer"),
1116
- value: e(V).TRANSFER,
1117
- disabled: !e(A).locationOptionsTypeTransfer.value.length,
1118
- sublabel: e(A).locationOptionsTypeTransfer.value.length ? void 0 : e(l)("inventory.transfer.form.noLocationAvailable")
1119
- }
1120
- ],
1121
- rules: [e(Pe)(1)(L.value)]
1122
- }, null, 8, ["label", "model-value", "items", "rules"]),
1123
- k(ve, {
1124
- label: U.value === e(V).PURCHASE ? e(l)("inventory.transfer.form.purchaseFrom") : e(l)("inventory.transfer.form.transferFrom"),
1125
- modelValue: G.value,
1126
- "onUpdate:modelValue": f[1] || (f[1] = (h) => G.value = h),
1127
- items: L.value
1128
- }, null, 8, ["label", "modelValue", "items"])
1129
- ], 64)),
1130
- k(he, {
1131
- label: e(l)("inventory.transfer.form.reference"),
1132
- "label-mark": "optional",
1133
- modelValue: e(t).ref,
1134
- "onUpdate:modelValue": f[2] || (f[2] = (h) => e(t).ref = h)
1135
- }, null, 8, ["label", "modelValue"]),
1136
- k(we, {
1137
- label: e(l)("inventory.transfer.form.remark"),
1138
- "label-mark": "optional",
1139
- "max-length": 240,
1140
- modelValue: ee.value,
1141
- "onUpdate:modelValue": f[3] || (f[3] = (h) => ee.value = h),
1142
- class: Y([o.disabled ? "text-fm-color-typo-disabled " : ""])
1143
- }, null, 8, ["label", "modelValue", "class"]),
1144
- e(s).isEnabled ? (F(), j(ve, {
1145
- key: 2,
1146
- modelValue: K.value,
1147
- "onUpdate:modelValue": f[4] || (f[4] = (h) => K.value = h),
1148
- label: `NetSuite ${e(l)("inventory.transfer.form.netsuite.subsidiary")}`,
1149
- items: e(s).subsidiaryOptions,
1150
- "label-mark": "required",
1151
- rules: [e(Ve)()]
1152
- }, null, 8, ["modelValue", "label", "items", "rules"])) : z("", !0),
1153
- e(b).enableBackdatePo ? (F(), $("div", Cs, [
1154
- r("div", {
1155
- class: Y([
1156
- "flex",
1157
- {
1158
- "flex-col": g.value
1159
- }
1160
- ])
1161
- }, [
1162
- k(be, {
1163
- modelValue: e(Q),
1164
- "onUpdate:modelValue": f[5] || (f[5] = (h) => me(Q) ? Q.value = h : null),
1165
- label: e(l)("inventory.transfer.form.backdate.title"),
1166
- sublabel: e(l)("inventory.transfer.form.backdate.subtitle"),
1167
- "label-placement": "right",
1168
- disabled: x.value && !o.lastClosingDate || o.disabled
1169
- }, null, 8, ["modelValue", "label", "sublabel", "disabled"]),
1170
- r("div", {
1171
- class: Y({ hidden: g.value, "w-16": !g.value })
1172
- }, null, 2),
1173
- e(Q) ? (F(), $("div", hs, [
1174
- r("div", ws, [
1175
- k(Se, {
1176
- modelValue: e(_),
1177
- "onUpdate:modelValue": f[6] || (f[6] = (h) => me(_) ? _.value = h : null)
1178
- }, null, 8, ["modelValue"])
1179
- ]),
1180
- r("div", Ss, [
1181
- k(T, {
1182
- modelValue: e(C),
1183
- "onUpdate:modelValue": f[7] || (f[7] = (h) => me(C) ? C.value = h : null)
1184
- }, null, 8, ["modelValue"])
1185
- ])
1186
- ])) : z("", !0)
1187
- ], 2),
1188
- e(J) ? (F(), j(ne, {
1189
- key: 0,
1190
- modelValue: e(J),
1191
- "onUpdate:modelValue": f[8] || (f[8] = (h) => me(J) ? J.value = h : null),
1192
- rules: [e(gt)(new Date(o.lastClosingDate), /* @__PURE__ */ new Date())]
1193
- }, null, 8, ["modelValue", "rules"])) : z("", !0),
1194
- x.value && !o.lastClosingDate ? (F(), $("div", xs, [
1195
- k(ue, {
1196
- name: "error",
1197
- size: "sm",
1198
- class: "text-fm-color-typo-warning"
1199
- }),
1200
- r("span", Fs, D(e(l)("inventory.transfer.form.backdate.error")), 1)
1201
- ])) : z("", !0)
1202
- ])) : z("", !0)
1203
- ])
1204
- ]),
1205
- r("div", Ps, [
1206
- k(ne, {
1207
- "model-value": e(t).items,
1208
- rules: [e(Pe)(1)]
1209
- }, null, 8, ["model-value", "rules"]),
1210
- r("div", {
1211
- class: Y([
1212
- "flex gap-16",
1213
- {
1214
- "flex-col items-start": g.value,
1215
- "items-center": !g.value
1216
- }
1217
- ])
1218
- }, [
1219
- r("div", Is, D(e(l)("inventory.transfer.form.items.title")), 1),
1220
- r("div", Ts, [
1221
- k(X, {
1222
- disabled: o.disabled,
1223
- label: e(l)("inventory.transfer.form.items.addItem"),
1224
- "prepend-icon": "add",
1225
- variant: "secondary",
1226
- "text-color": "primary",
1227
- "bg-color": "transparent",
1228
- "border-color": "primary",
1229
- onClick: f[9] || (f[9] = (h) => Xe()),
1230
- size: "md"
1231
- }, null, 8, ["disabled", "label"]),
1232
- e(t).template ? (F(), j(de, {
1233
- key: 0,
1234
- "z-index": 50
1235
- }, {
1236
- content: O(() => [
1237
- r("div", null, D(e(l)("inventory.transfer.form.items.forecastStock.notAvailable")), 1)
1238
- ]),
1239
- default: O(() => [
1240
- k(Le, {
1241
- "onUpdate:poItems": f[10] || (f[10] = (h) => e(t).items = h),
1242
- disabled: ""
1243
- })
1244
- ]),
1245
- _: 1
1246
- })) : (F(), j(Le, {
1247
- key: 1,
1248
- "onUpdate:poItems": f[11] || (f[11] = (h) => e(t).items = h),
1249
- disabled: o.disabled || !!e(t).template
1250
- }, null, 8, ["disabled"]))
1251
- ])
1252
- ], 2),
1253
- U.value === e(V).PURCHASE && S.value && e(b).enableTotalCost && ((Me = o.modelValue) != null && Me.items.length) ? (F(), $("div", $s, [
1254
- k(be, {
1255
- label: e(te) ? e(l)("inventory.transfer.form.items.fetchingData") : e(l)("inventory.transfer.form.items.comparePriceHistory"),
1256
- "prepend-icon": "compare_arrows",
1257
- "label-placement": "right",
1258
- "model-value": e(R),
1259
- "onUpdate:modelValue": f[12] || (f[12] = (h) => me(R) ? R.value = h : null),
1260
- disabled: e(te) || o.disabled
1261
- }, null, 8, ["label", "model-value", "disabled"])
1262
- ])) : z("", !0),
1263
- (F(), j(le, {
1264
- "column-defs": Je.value,
1265
- "row-data": e(t).items,
1266
- key: e(t).items.map((h) => h.sku._id).join("."),
1267
- "hide-footer": "",
1268
- "page-size": e(t).items.length
1269
- }, {
1270
- "table-row": O((h) => [
1271
- k(ps, {
1272
- "compare-price-by-sku": e(W),
1273
- "show-compare-price": U.value === e(V).PURCHASE && e(R),
1274
- row: h
1275
- }, null, 8, ["compare-price-by-sku", "show-compare-price", "row"])
1276
- ]),
1277
- "list-row": O((h) => [
1278
- (F(), j(St, {
1279
- row: h,
1280
- key: e(t).items.map((ge) => ge.sku._id).join(".")
1281
- }, {
1282
- default: O((ge) => [
1283
- k(zt, {
1284
- "compare-price-by-sku": e(W),
1285
- "show-compare-price": U.value === e(V).PURCHASE && e(R),
1286
- row: h,
1287
- "cell-by-col-id": ge
1288
- }, null, 8, ["compare-price-by-sku", "show-compare-price", "row", "cell-by-col-id"])
1289
- ]),
1290
- _: 2
1291
- }, 1032, ["row"]))
1292
- ]),
1293
- _: 1
1294
- }, 8, ["column-defs", "row-data", "page-size"]))
1295
- ])
1296
- ];
1297
- }),
1298
- _: 1
1299
- }, 8, ["disabled", "onValidationFailed"])
1300
- ]);
1301
- };
1302
- }
1303
- }), Vs = { class: "flex items-center" }, Ds = { class: "fm-typo-en-title-md-800" }, Rs = { class: "flex gap-4" }, Ys = /* @__PURE__ */ ie({
1304
- __name: "TransferDialog",
1305
- props: {
1306
- mode: {},
1307
- modelValue: {},
1308
- templateId: {},
1309
- show: { type: Boolean },
1310
- lastClosingDate: {}
1311
- },
1312
- emits: ["update:show", "submitted"],
1313
- setup(n, { expose: v, emit: u }) {
1314
- var Q;
1315
- const i = n, d = u, t = He(), l = Re(), w = Ie(), m = Be(), s = Ue(), { t: a } = ye(), b = q(!1), c = q(!1), p = q(!1);
1316
- async function g(_) {
1317
- if (_) {
1318
- c.value = !1;
1319
- try {
1320
- await w.readSuppliers(), c.value = !0;
1321
- } catch {
1322
- l.open({
1323
- title: a("inventory.transfer.form.unableToFetchListOfSuppliers.title"),
1324
- message: a("inventory.transfer.form.unableToFetchListOfSuppliers.message"),
1325
- type: "error"
1326
- });
1327
- }
1328
- }
1329
- }
1330
- s.watchLocation(g);
1331
- function y() {
1332
- return {
1333
- remark: void 0,
1334
- ref: void 0,
1335
- stockSnapshotId: void 0,
1336
- effectiveAt: void 0,
1337
- items: [],
1338
- supplier: {
1339
- _rev: void 0,
1340
- email: void 0,
1341
- internal: void 0,
1342
- contactName: void 0,
1343
- phoneNumber: void 0,
1344
- registrationNumber: void 0,
1345
- supplyItems: void 0,
1346
- _id: "",
1347
- name: "",
1348
- address: {
1349
- line2: void 0,
1350
- line1: "",
1351
- state: "",
1352
- city: "",
1353
- postcode: "",
1354
- country: ""
1355
- }
1356
- },
1357
- status: "DRAFT",
1358
- _id: "",
1359
- seqNumber: 0,
1360
- deliveryOrder: [],
1361
- template: i.templateId
1362
- };
1363
- }
1364
- const S = ot(i, "show"), x = q(i.modelValue ?? y()), E = q(((Q = i.modelValue) == null ? void 0 : Q._id) ?? `${Math.random()}`);
1365
- De(
1366
- () => i.show,
1367
- (_) => {
1368
- var C;
1369
- _ && (p.value = !1, x.value = i.modelValue ?? y(), E.value = ((C = i.modelValue) == null ? void 0 : C._id) ?? `${Math.random()}`);
1370
- }
1371
- );
1372
- const A = P(() => !c.value || !p.value), U = P(() => {
1373
- switch (i.mode) {
1374
- case ke.READ:
1375
- return "View transfer";
1376
- case ke.CREATE:
1377
- return a("inventory.transfer.receiveRequest.create.title");
1378
- case ke.UPDATE:
1379
- return a("inventory.transfer.receiveRequest.update.title");
1380
- }
1381
- return "";
1382
- }), L = q();
1383
- v({
1384
- validateInputs: () => {
1385
- var _, C;
1386
- (C = (_ = L.value) == null ? void 0 : _.validateInputs) == null || C.call(_);
1387
- },
1388
- resetInputsValidation: () => {
1389
- var _, C;
1390
- (C = (_ = L.value) == null ? void 0 : _.resetInputsValidation) == null || C.call(_);
1391
- },
1392
- resetInputs: () => {
1393
- var _, C;
1394
- (C = (_ = L.value) == null ? void 0 : _.resetInputs) == null || C.call(_);
1395
- }
1396
- });
1397
- async function G() {
1398
- const _ = x.value;
1399
- b.value = !0, (_.supplier.internal === "warehouse" || _.supplier.internal === "restaurant") && (_.items = _.items.map(({ totalCost: C, ...R }) => R));
1400
- try {
1401
- await t.createPurchaseOrder(_), await new Promise((C) => setTimeout(C, 1e3)), l.open({
1402
- title: a("inventory.transfer.receiveRequest.create.success"),
1403
- message: a("inventory.transfer.receiveRequest.create.successMessage"),
1404
- type: "success"
1405
- }), d("update:show", !1), d("submitted");
1406
- } catch (C) {
1407
- l.open({
1408
- title: a("inventory.transfer.receiveRequest.create.error.title"),
1409
- message: a("inventory.transfer.receiveRequest.create.error.message"),
1410
- type: "error"
1411
- }), console.error("Error in creating purchase order", C);
1412
- } finally {
1413
- b.value = !1;
1414
- }
1415
- }
1416
- async function ee() {
1417
- const _ = x.value;
1418
- b.value = !0, (_.supplier.internal === "warehouse" || _.supplier.internal === "restaurant") && (_.items = _.items.map(({ totalCost: C, ...R }) => R));
1419
- try {
1420
- await t.updatePurchaseOrder(_), await new Promise((C) => setTimeout(C, 1e3)), l.open({
1421
- title: a("inventory.transfer.receiveRequest.update.success"),
1422
- message: a("inventory.transfer.receiveRequest.update.successMessage"),
1423
- type: "success"
1424
- }), d("update:show", !1), d("submitted");
1425
- } catch (C) {
1426
- l.open({
1427
- title: a("inventory.transfer.receiveRequest.update.error.title"),
1428
- message: a("inventory.transfer.receiveRequest.update.error.message"),
1429
- type: "error"
1430
- }), console.error("Error in updating purchase order", C);
1431
- } finally {
1432
- b.value = !1;
1433
- }
1434
- }
1435
- function K() {
1436
- switch (i.mode) {
1437
- case ke.CREATE:
1438
- return G();
1439
- case ke.UPDATE:
1440
- return ee();
1441
- }
1442
- }
1443
- function J() {
1444
- var _, C;
1445
- (C = (_ = L.value) == null ? void 0 : _.validateInputs) == null || C.call(_);
1446
- }
1447
- return (_, C) => {
1448
- const R = I("FmButton"), te = I("FmSideSheet");
1449
- return F(), j(te, {
1450
- modelValue: e(S),
1451
- "onUpdate:modelValue": C[3] || (C[3] = (W) => me(S) ? S.value = W : null),
1452
- "dismiss-away": "",
1453
- "close-button": "",
1454
- "max-width": 900
1455
- }, {
1456
- "side-sheet-header": O(() => [
1457
- r("div", Vs, [
1458
- r("div", Ds, D(U.value), 1)
1459
- ])
1460
- ]),
1461
- default: O(() => [
1462
- (F(), j(As, {
1463
- class: "w-full",
1464
- ref_key: "formRef",
1465
- ref: L,
1466
- "onForm:ready": C[0] || (C[0] = () => p.value = !0),
1467
- onValidationSuccess: K,
1468
- modelValue: x.value,
1469
- "onUpdate:modelValue": C[1] || (C[1] = (W) => x.value = W),
1470
- disabled: b.value || A.value,
1471
- suppliers: e(w).suppliers,
1472
- skus: e(m).skus,
1473
- key: E.value,
1474
- "last-closing-date": _.lastClosingDate
1475
- }, null, 8, ["modelValue", "disabled", "suppliers", "skus", "last-closing-date"]))
1476
- ]),
1477
- "side-sheet-footer": O(() => [
1478
- r("div", Rs, [
1479
- k(R, {
1480
- loading: b.value,
1481
- disabled: A.value,
1482
- label: e(a)("common.save"),
1483
- onClick: J
1484
- }, null, 8, ["loading", "disabled", "label"]),
1485
- k(R, {
1486
- disabled: A.value,
1487
- variant: "tertiary",
1488
- label: e(a)("common.close"),
1489
- onClick: C[2] || (C[2] = (W) => d("update:show", !1))
1490
- }, null, 8, ["disabled", "label"])
1491
- ])
1492
- ]),
1493
- _: 1
1494
- }, 8, ["modelValue"]);
1495
- };
1496
- }
1497
- });
1498
- export {
1499
- Ys as _,
1500
- ae as c,
1501
- jt as u
1502
- };