@feedmepos/mf-inventory-portal 0.0.25-dev.12 → 0.0.25-dev.14

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-PehI6qSK.js → App-6g25LiMb.js} +2 -2
  2. package/dist/{ApprovalView-a6tbFyO2.js → ApprovalView-D1QD09Yc.js} +2 -2
  3. package/dist/{BindingsDialog-BNco1Vhd.js → BindingsDialog-eUQ1_YJ6.js} +2 -2
  4. package/dist/{BindingsPicker-Dns2kFS-.js → BindingsPicker-CG9yJgeU.js} +1 -1
  5. package/dist/{BindingsTable-DTrXzYzr.js → BindingsTable-BVRcqAy9.js} +1 -1
  6. package/dist/{ClosingDraftView-BXBkI6WL.js → ClosingDraftView-BBASz7i8.js} +2 -2
  7. package/dist/{ClosingTemplateView-BiAGOmVg.js → ClosingTemplateView-Bax4L6YF.js} +2 -2
  8. package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-IlN0Uj04.js → FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-CqU3Pubo.js} +3 -3
  9. package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-JDL6LVAb.js → FmUnitInput.vue_vue_type_script_setup_true_lang-BBaQYJia.js} +1 -1
  10. package/dist/{IngredientBindedItem.vue_vue_type_script_setup_true_lang-DR5ewA1c.js → IngredientBindedItem.vue_vue_type_script_setup_true_lang-DrZCk-3P.js} +1 -1
  11. package/dist/{IngredientGroupView-Bci0qysG.js → IngredientGroupView-Cs5ZJb3h.js} +1 -1
  12. package/dist/{IngredientsView-Dpc_GncE.js → IngredientsView-DrRbwLdZ.js} +4 -4
  13. package/dist/{IntegrationView-DCWg-DR4.js → IntegrationView-CF-K0lEk.js} +1 -1
  14. package/dist/{InventoryBindingForm-BwwF-2NM.js → InventoryBindingForm-Kq7F7Hxw.js} +1 -1
  15. package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-1BVSUfuT.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-djscF-a_.js} +54 -54
  16. package/dist/{InventoryBindingSummary-DgoHed7T.js → InventoryBindingSummary-9iGC54ax.js} +1 -1
  17. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-Bu4Dw_6P.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-CSVc9YqP.js} +1 -1
  18. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-CW7-Eu69.js → PremiumBadge.vue_vue_type_script_setup_true_lang-C0liINI-.js} +1 -1
  19. package/dist/{PublishView-DVYBAYBI.js → PublishView-DSkvsS-T.js} +2 -2
  20. package/dist/{PurchaseOrderPrintPreview-Dp2v_J3o.js → PurchaseOrderPrintPreview-BZjkqH8w.js} +1 -1
  21. package/dist/ReceiveRequestView-DUmyosqT.js +2239 -0
  22. package/dist/{RecipeView-Cv5EH2Ah.js → RecipeView-B3mlZR2U.js} +3 -3
  23. package/dist/{StockView-B7x9Pywp.js → StockView-DS8W3pK-.js} +7 -7
  24. package/dist/{SupplierView-BgyqCgOQ.js → SupplierView-Pm-PoUsN.js} +4 -4
  25. package/dist/{TransferDetails.vue_vue_type_script_setup_true_lang-ByAN3s-h.js → TransferDetails.vue_vue_type_script_setup_true_lang-DTKXMB4E.js} +204 -197
  26. package/dist/TransferTemplateView-CEJK7_3f.js +1660 -0
  27. package/dist/{UnitView-IUEnJvH0.js → UnitView-CaA3eoV3.js} +3 -3
  28. package/dist/{WarehouseView-Bcwta2ui.js → WarehouseView-uL4l-lXl.js} +1 -1
  29. package/dist/{app-BKrf9Qul.js → app-DLF5oQUX.js} +4494 -4276
  30. package/dist/app.js +1 -1
  31. package/dist/components/FmMultiselectDialog.d.ts +23 -0
  32. package/dist/{decimal-pm1D555G.js → decimal-BfL1Dfin.js} +1 -1
  33. package/dist/{feature-IIGwFZ6m.js → feature-D67-S0RZ.js} +7 -2
  34. package/dist/{format-unit-display-DAzCcqoK.js → format-unit-display-e9wEtPRW.js} +2 -2
  35. package/dist/{index-phCfzXTb.js → index-mvz-S4fO.js} +2 -2
  36. package/dist/{stock-B9Im7AGF.js → stock-Bh8xDSyj.js} +1 -1
  37. package/dist/style.css +1 -1
  38. package/dist/{supplier-D5z7EqEg.js → supplier-BTSc7hfQ.js} +1 -1
  39. package/dist/tsconfig.app.tsbuildinfo +1 -1
  40. package/dist/{use-ingredient-select-dialog-QJXtuwbP.js → use-ingredient-select-dialog-BBI1-Yt3.js} +1 -1
  41. package/dist/{use-inventory-binding-dialog-DbK__hMV.js → use-inventory-binding-dialog-B06jZrl3.js} +1 -1
  42. package/dist/views/receive-request/components/transfer-form/TransferForm.vue.d.ts +370 -0
  43. package/dist/views/receive-request/components/transfer-form/components/ForecastStock.vue.d.ts +46 -0
  44. package/dist/views/receive-request/components/transfer-form/components/TransferItemTable.vue.d.ts +490 -2
  45. package/dist/views/receive-request/components/transfer-form/components/TransferSubItemTable.vue.d.ts +72 -0
  46. package/dist/views/receive-request/components/transfer-form/composables/use-transfer-items.d.ts +24 -0
  47. package/dist/views/receive-request/components/transfer-form/helpers/calculate-sub-item-total.helper.d.ts +4 -0
  48. package/dist/views/receive-request/composables/use-receive-request-form.d.ts +624 -0
  49. package/dist/views/receive-request/composables/use-receive-request-table.d.ts +624 -0
  50. package/dist/views/transfer-template/components/transfer-template-form/components/TransferTemplateItem.vue.d.ts +270 -2
  51. package/dist/views/transfer-template/components/transfer-template-form/components/TransferTemplateItemTable.vue.d.ts +286 -0
  52. package/dist/views/transfer-template/components/transfer-template-form/components/TransferTemplateSubItem.vue.d.ts +74 -0
  53. package/dist/views/transfer-template/components/transfer-template-form/components/TransferTemplateSubItemTable.vue.d.ts +92 -0
  54. package/dist/views/transfer-template/components/transfer-template-form/composables/use-transfer-template-items.d.ts +35 -0
  55. package/dist/views/transfer-template/composables/use-transfer-template-actions.d.ts +420 -0
  56. package/dist/views/transfer-template/composables/use-transfer-template-table.d.ts +420 -0
  57. package/dist/{vue-i18n-sbiTSWWp.js → vue-i18n-Dy5gAXv-.js} +209 -209
  58. package/package.json +3 -3
  59. package/dist/ReceiveRequestView-DVq8tkzd.js +0 -1885
  60. package/dist/TransferTemplateView-C30bwI6y.js +0 -1371
@@ -1,1885 +0,0 @@
1
- import { reactive as ot, onMounted as Ne, h as L, computed as E, defineComponent as pe, openBlock as S, createElementBlock as q, Fragment as ke, renderList as Me, createElementVNode as l, toDisplayString as U, unref as e, resolveComponent as P, createVNode as d, withCtx as F, createCommentVNode as G, ref as N, createBlock as W, watch as ge, normalizeClass as J, normalizeStyle as lt, createTextVNode as Oe, nextTick as mt, mergeProps as Be, isRef as Se, Teleport as pt } from "vue";
2
- import { b as ze, Z as ft, l as We, i as ye, O as vt, a0 as Le, K as yt, as as bt, A as Ve, M as _t, m as nt, ab as He, E as ie, at as gt, a as je, au as kt, av as Ct, aw as ht, G as xt, u as Ye, ax as St, $ as wt, T as Dt, ay as Ft, B as rt, H as $t, d as Fe, az as Re, a5 as Je, y as Tt, _ as Pt, z as It, N as Xe } from "./app-BKrf9Qul.js";
3
- import { u as it, a as Rt, P as Ue, b as Vt, _ as At, g as Et } from "./TransferDetails.vue_vue_type_script_setup_true_lang-ByAN3s-h.js";
4
- import { _ as ut, u as qt, i as Ut, e as Mt } from "./PremiumBadge.vue_vue_type_script_setup_true_lang-CW7-Eu69.js";
5
- import { u as Ot } from "./useTabStorage-BkIVScW_.js";
6
- import { useBreakpoints as Qe, components as ve, FmButtonVariant as Bt, useSnackbar as Ae, useDialog as Nt, useProxiedModel as zt } from "@feedmepos/ui-library";
7
- import { P as j, u as dt } from "./format-unit-display-DAzCcqoK.js";
8
- import { _ as Lt, F as Ht, a as et, b as jt } from "./FmUnitInput.vue_vue_type_script_setup_true_lang-JDL6LVAb.js";
9
- import { u as Ee } from "./feature-IIGwFZ6m.js";
10
- import { c as re, u as Yt, _ as Qt } from "./FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-IlN0Uj04.js";
11
- import { useI18n as Ce } from "@feedmepos/mf-common";
12
- import { u as Ke } from "./supplier-D5z7EqEg.js";
13
- import { _ as Kt } from "./PreviewBadge.vue_vue_type_script_setup_true_lang-CRZiQHjx.js";
14
- import { u as Zt } from "./vue-i18n-sbiTSWWp.js";
15
- import "./array-hChJVZLE.js";
16
- var Y = /* @__PURE__ */ ((m) => (m.Code = "Code", m.Name = "Name", m.Amount = "Amount", m.Cost = "Cost", m.TotalCost = "TotalCost", m.Delete = "Delete", m))(Y || {});
17
- const tt = () => {
18
- const { t: m } = Ce();
19
- return L(
20
- ut,
21
- {
22
- zIndex: 50,
23
- class: "whitespace-nowrap"
24
- },
25
- m("inventory.transfer.form.items.table.Cost", [nt()])
26
- );
27
- };
28
- function Gt(m) {
29
- const { t: y } = Ce(), n = ot({}), { breakpoints: i } = Qe(), b = Ee(), t = ze();
30
- Ne(() => {
31
- for (const u of m.items) {
32
- if (!u.totalCost)
33
- continue;
34
- const a = re(u.sku, u.quantity, u.measurement, {
35
- supplier: m.supplier
36
- }), o = u.totalCost ?? ft.reset();
37
- a ? n[u.sku._id] = a.amount !== o.amount || a.precision !== o.precision : n[u.sku._id] = !0;
38
- }
39
- });
40
- function f(u) {
41
- var o, v, k, C, g, x, D;
42
- return !!(((v = (o = u.defaultCost) == null ? void 0 : o.costPerUnit) == null ? void 0 : v.amount) ?? ((D = (x = (g = (C = (k = m.supplier) == null ? void 0 : k.supplyItems) == null ? void 0 : C.find((R) => R.skuId === u._id)) == null ? void 0 : g.defaultCost) == null ? void 0 : x.costPerUnit) == null ? void 0 : D.amount));
43
- }
44
- const _ = [
45
- {
46
- id: "Code",
47
- header: () => y("inventory.transfer.form.items.table.Code"),
48
- accessorKey: "code",
49
- size: 96,
50
- cell(u) {
51
- const a = u.row.original;
52
- return t.isEnabled ? L(
53
- ve.FmTooltip,
54
- {
55
- content: a.code,
56
- placement: "top",
57
- variant: "plain",
58
- zIndex: 50
59
- },
60
- L(
61
- "span",
62
- {
63
- class: "flex-auto line-clamp-2 text-ellipsis break-all"
64
- },
65
- a.code
66
- )
67
- ) : L(ve.FmTextField, {
68
- modelValue: a.code,
69
- "onUpdate:modelValue": (o) => {
70
- m.updateItem({
71
- ...a,
72
- code: o
73
- });
74
- },
75
- key: a.sku._id,
76
- rules: [We()],
77
- labelMark: "required"
78
- });
79
- },
80
- enableSorting: !1
81
- },
82
- {
83
- id: "Name",
84
- header: () => y("inventory.transfer.form.items.table.Name"),
85
- minSize: 300,
86
- cell(u) {
87
- const a = u.row.original;
88
- return t.isEnabled ? L(
89
- ve.FmTooltip,
90
- {
91
- content: a.name,
92
- placement: "top",
93
- variant: "plain",
94
- zIndex: 50
95
- },
96
- L(
97
- "span",
98
- {
99
- class: "flex-auto line-clamp-2 text-ellipsis break-all"
100
- },
101
- a.name
102
- )
103
- ) : L(ve.FmTextField, {
104
- modelValue: a.name,
105
- "onUpdate:modelValue": (o) => {
106
- m.updateItem({
107
- ...a,
108
- name: o
109
- });
110
- },
111
- key: a.sku._id,
112
- rules: [We()],
113
- labelMark: "required"
114
- });
115
- },
116
- enableSorting: !1
117
- },
118
- {
119
- id: "Amount",
120
- header: () => y("inventory.transfer.form.items.table.Amount"),
121
- minSize: 200,
122
- cell(u) {
123
- var v, k, C;
124
- const a = u.row.original, o = (C = (k = (v = m.template) == null ? void 0 : v.purchaseOrder) == null ? void 0 : k.items) == null ? void 0 : C.find(
125
- (g) => g.sku._id === a.sku._id
126
- );
127
- return L(Lt, {
128
- style: {
129
- flex: "1 1 0%"
130
- },
131
- modelValue: {
132
- amount: a.quantity ?? { amount: 1, precision: 0 },
133
- measurement: a.measurement ?? null
134
- },
135
- key: a.sku._id,
136
- unit: a.sku.unit,
137
- "onUpdate:modelValue": (g) => {
138
- const x = {
139
- ...a,
140
- quantity: g.amount,
141
- measurement: g.measurement
142
- };
143
- b.enableTotalCost && (x.totalCost = re(a.sku, a.quantity, a.measurement, {
144
- supplier: m.supplier,
145
- // NOTE: set undefined here if `manualTotalCost[row.sku._id] = false`, so that the function
146
- // will return the auto calculated default cost instead of the manual total cost
147
- manualTotalCost: n[a.sku._id] ? x.totalCost : void 0
148
- })), m.updateItem(x);
149
- },
150
- stepper: o == null ? void 0 : o.quantityStep,
151
- disableUnit: !!o,
152
- disabled: m.disabled,
153
- rules: [
154
- Ht(
155
- +ye(
156
- (o != null && o.minimumQuantity && (o == null ? void 0 : o.minimumQuantity.amount) > 0 ? o == null ? void 0 : o.minimumQuantity : void 0) ?? {
157
- amount: 1,
158
- precision: vt(a.sku.unit, a.measurement)
159
- }
160
- )
161
- ),
162
- o != null && o.maximumQuantity ? et(
163
- +ye(o == null ? void 0 : o.maximumQuantity)
164
- ) : et(1 / 0),
165
- ...o != null && o.quantityStep ? [jt(o.quantityStep)] : []
166
- ],
167
- applyDefaultRules: !0
168
- });
169
- },
170
- enableSorting: !1
171
- },
172
- b.mustUseDefaultCost ? {
173
- id: "TotalCost",
174
- header: tt,
175
- size: 180,
176
- accessorFn: (u) => {
177
- const a = re(u.sku, u.quantity, u.measurement, {
178
- supplier: m.supplier
179
- });
180
- return ye(a);
181
- }
182
- } : {
183
- id: "Cost",
184
- header: tt,
185
- size: 180,
186
- cell(u) {
187
- const a = u.row.original, o = f(a.sku), v = i.value.xs || i.value.sm;
188
- return !n[a.sku._id] && o ? L(
189
- "div",
190
- {
191
- class: [
192
- "flex gap-4 fm-typo-en-body-md-400 items-center",
193
- m.disabled ? "text-fm-color-typo-disabled" : ""
194
- ],
195
- key: a.sku._id
196
- },
197
- [
198
- L(ve.FmButton, {
199
- prependIcon: "edit",
200
- variant: Bt.Tertiary,
201
- disabled: m.disabled,
202
- onClick() {
203
- m.updateItem({
204
- ...a,
205
- totalCost: re(a.sku, a.quantity, a.measurement, {
206
- supplier: m.supplier
207
- })
208
- }), n[a.sku._id] = !0;
209
- }
210
- }),
211
- L(
212
- "div",
213
- {
214
- class: "flex flex-col"
215
- },
216
- [
217
- L(
218
- "span",
219
- v ? Le(
220
- re(a.sku, a.quantity, a.measurement, {
221
- supplier: m.supplier
222
- })
223
- ) : ye(
224
- re(a.sku, a.quantity, a.measurement, {
225
- supplier: m.supplier
226
- })
227
- )
228
- ),
229
- L(
230
- "span",
231
- {
232
- class: [
233
- "fm-typo-en-body-sm-400",
234
- m.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-neutral-gray-400"
235
- ]
236
- },
237
- y("inventory.transfer.form.items.autoCalculated")
238
- )
239
- ]
240
- )
241
- ]
242
- ) : L(
243
- ve.FmTextField,
244
- {
245
- modelValue: ye(a.totalCost ?? { amount: 0, precision: 0 }),
246
- key: a.sku._id,
247
- "onUpdate:modelValue": (k) => {
248
- m.updateItem({
249
- ...a,
250
- totalCost: {
251
- ...yt(+k),
252
- currency: bt()
253
- }
254
- });
255
- },
256
- rules: [Ve(0), _t(2)]
257
- },
258
- {
259
- prepend() {
260
- return v ? L(
261
- "div",
262
- {
263
- class: [
264
- "text-fm-typo-en-body-lg-400",
265
- m.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-typo-primary"
266
- ]
267
- },
268
- nt()
269
- ) : null;
270
- },
271
- append() {
272
- return o ? L(ve.FmButton, {
273
- prependIcon: "close",
274
- variant: "tertiary",
275
- disabled: m.disabled,
276
- onClick() {
277
- m.updateItem({
278
- ...a,
279
- // NOTE: different from PO template, if a default cost is reenabled,
280
- // the total cost will automatically assigned
281
- totalCost: re(a.sku, a.quantity, a.measurement, {
282
- supplier: m.supplier
283
- })
284
- }), n[a.sku._id] = !1;
285
- }
286
- }) : null;
287
- }
288
- }
289
- );
290
- },
291
- enableSorting: !1
292
- },
293
- {
294
- id: "Delete",
295
- header: "",
296
- cell(u) {
297
- const a = u.row.original;
298
- return L(ve.FmButton, {
299
- key: a.sku._id,
300
- class: "delete-button",
301
- type: "button",
302
- icon: "delete",
303
- variant: "tertiary",
304
- size: "md",
305
- disabled: m.disabled,
306
- onClick: () => {
307
- m.deleteItem(a);
308
- }
309
- });
310
- },
311
- enableSorting: !1,
312
- size: 40,
313
- meta: {
314
- cellClass: "",
315
- headerClass: ""
316
- }
317
- }
318
- ];
319
- return {
320
- columnDefs: E(() => b.enableTotalCost && (b.mustUseDefaultCost || m.transferType === j.PURCHASE) ? _ : _.filter(
321
- (u) => u.id !== "Cost"
322
- /* Cost */
323
- ))
324
- };
325
- }
326
- const Wt = { class: "flex flex-col gap-8 px-16 xs:px-4 sm:px-4 py-4 items-center" }, Jt = { class: "fm-typo-en-body-lg-600 xs:fm-typo-en-body-md-600 mr-auto xs:w-full" }, Xt = { class: "w-[450px] xs:w-full flex" }, es = { class: "fm-typo-en-body-md-400 whitespace-nowrap" }, ts = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, ct = /* @__PURE__ */ pe({
327
- __name: "SupplierPriceHistory",
328
- props: {
329
- prices: {}
330
- },
331
- setup(m) {
332
- const y = Ke();
333
- function n(i) {
334
- return y.suppliers.find((b) => b._id === i);
335
- }
336
- return (i, b) => (S(), q("div", Wt, [
337
- (S(!0), q(ke, null, Me(Object.keys(i.prices), (t) => {
338
- var f;
339
- return S(), q("div", {
340
- key: t,
341
- class: "flex items-center gap-12 xs:gap-4 xs:flex-wrap w-full"
342
- }, [
343
- l("div", Jt, U((f = n(t)) == null ? void 0 : f.name), 1),
344
- l("div", Xt, [
345
- (S(!0), q(ke, null, Me(i.prices[t].slice(0, 3), (_) => {
346
- var w;
347
- return S(), q("div", {
348
- key: _.date,
349
- class: "flex flex-col w-[150px] xs:flex-1 text-ellipsis cursor-pointer"
350
- }, [
351
- l("div", es, [
352
- l("span", null, U(_.totalCost ? e(Le)(_.totalCost) : "No data"), 1),
353
- b[0] || (b[0] = l("span", { class: "text-fm-color-typo-secondary" }, "/", -1)),
354
- l("span", null, U(e(ye)(_.totalUnit, !1)), 1),
355
- l("span", null, U(((w = _.measurement) == null ? void 0 : w.abbrev) ?? _.unit.abbrev), 1)
356
- ]),
357
- l("div", ts, [
358
- l("span", null, "(#" + U(_.seqNumber) + ")", 1),
359
- b[1] || (b[1] = l("span", null, U(" "), -1)),
360
- l("span", null, U(e(He)(new Date(_.date))), 1)
361
- ])
362
- ]);
363
- }), 128))
364
- ])
365
- ]);
366
- }), 128))
367
- ]));
368
- }
369
- }), ss = { class: "flex flex-col gap-8 py-16" }, as = { class: "flex items-center" }, os = { class: "flex-1 flex gap-1 items-center" }, ls = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, ns = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, rs = { class: "flex gap-8 w-full" }, is = { class: "flex-1 flex flex-col gap-4" }, us = { class: "flex-1 flex flex-col gap-4" }, ds = { class: "flex gap-8 w-full" }, cs = { class: "flex-1 flex flex-col gap-4" }, ms = {
370
- key: 0,
371
- class: "flex-1 flex flex-col gap-4"
372
- }, ps = /* @__PURE__ */ pe({
373
- __name: "TransferItem",
374
- props: {
375
- cellByColId: {},
376
- comparePriceBySku: {},
377
- showComparePrice: { type: Boolean },
378
- row: {}
379
- },
380
- setup(m) {
381
- const { t: y } = Ce();
382
- return (n, i) => {
383
- var f, _, w, u, a, o, v, k, C, g, x, D, R, z, ue, T, $, O, V, I, B, Q, K, p, c, H, oe;
384
- const b = P("FmLabel"), t = P("FmSpacer");
385
- return S(), q("div", ss, [
386
- l("div", as, [
387
- l("div", os, [
388
- l("span", ls, " (" + U(n.row.original.sku.code) + ") ", 1),
389
- l("span", ns, U(n.row.original.sku.name), 1)
390
- ]),
391
- l("div", null, [
392
- d(e(ie), {
393
- render: (w = (_ = (f = n.cellByColId.Delete) == null ? void 0 : f.column) == null ? void 0 : _.columnDef) == null ? void 0 : w.cell,
394
- props: (a = (u = n.cellByColId.Delete) == null ? void 0 : u.getContext) == null ? void 0 : a.call(u)
395
- }, null, 8, ["render", "props"])
396
- ])
397
- ]),
398
- l("div", rs, [
399
- l("div", is, [
400
- d(b, {
401
- label: e(y)(`inventory.transfer.form.items.table.${e(Y).Code}`)
402
- }, null, 8, ["label"]),
403
- d(e(ie), {
404
- render: (k = (v = (o = n.cellByColId[e(Y).Code]) == null ? void 0 : o.column) == null ? void 0 : v.columnDef) == null ? void 0 : k.cell,
405
- props: (g = (C = n.cellByColId[e(Y).Code]) == null ? void 0 : C.getContext) == null ? void 0 : g.call(C)
406
- }, null, 8, ["render", "props"]),
407
- i[0] || (i[0] = l("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
408
- ]),
409
- l("div", us, [
410
- d(b, {
411
- label: e(y)(`inventory.transfer.form.items.table.${e(Y).Name}`)
412
- }, null, 8, ["label"]),
413
- d(e(ie), {
414
- render: (R = (D = (x = n.cellByColId[e(Y).Name]) == null ? void 0 : x.column) == null ? void 0 : D.columnDef) == null ? void 0 : R.cell,
415
- props: (ue = (z = n.cellByColId[e(Y).Name]) == null ? void 0 : z.getContext) == null ? void 0 : ue.call(z)
416
- }, null, 8, ["render", "props"]),
417
- i[1] || (i[1] = l("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
418
- ])
419
- ]),
420
- l("div", ds, [
421
- l("div", cs, [
422
- d(b, {
423
- label: e(y)(`inventory.transfer.form.items.table.${e(Y).Amount}`)
424
- }, null, 8, ["label"]),
425
- d(e(ie), {
426
- render: (O = ($ = (T = n.cellByColId[e(Y).Amount]) == null ? void 0 : T.column) == null ? void 0 : $.columnDef) == null ? void 0 : O.cell,
427
- props: (I = (V = n.cellByColId[e(Y).Amount]) == null ? void 0 : V.getContext) == null ? void 0 : I.call(V)
428
- }, null, 8, ["render", "props"]),
429
- i[2] || (i[2] = l("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
430
- ]),
431
- n.cellByColId[e(Y).Cost] ? (S(), q("div", ms, [
432
- d(ut, { "z-index": 50 }, {
433
- default: F(() => [
434
- d(b, {
435
- label: e(y)(`inventory.transfer.form.items.table.${e(Y).Cost}2`)
436
- }, null, 8, ["label"])
437
- ]),
438
- _: 1
439
- }),
440
- d(e(ie), {
441
- render: (K = (Q = (B = n.cellByColId[e(Y).Cost]) == null ? void 0 : B.column) == null ? void 0 : Q.columnDef) == null ? void 0 : K.cell,
442
- props: (c = (p = n.cellByColId[e(Y).Cost]) == null ? void 0 : p.getContext) == null ? void 0 : c.call(p)
443
- }, null, 8, ["render", "props"]),
444
- i[3] || (i[3] = l("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
445
- ])) : G("", !0)
446
- ]),
447
- n.showComparePrice && Object.keys(n.comparePriceBySku[(H = n.row.original.sku) == null ? void 0 : H._id] ?? {}).length > 0 ? (S(), q(ke, { key: 0 }, [
448
- d(t, { class: "h-8" }),
449
- d(ct, {
450
- prices: n.comparePriceBySku[(oe = n.row.original.sku) == null ? void 0 : oe._id]
451
- }, null, 8, ["prices"])
452
- ], 64)) : G("", !0)
453
- ]);
454
- };
455
- }
456
- });
457
- function fs(m) {
458
- const y = E({
459
- get() {
460
- const t = m.getEffectiveAt();
461
- return t ? new Date(t) : null;
462
- },
463
- set(t) {
464
- m.setEffectiveAt((t == null ? void 0 : t.toISOString()) ?? null);
465
- }
466
- }), n = E({
467
- get() {
468
- return !!y.value;
469
- },
470
- set(t) {
471
- t ? y.value = /* @__PURE__ */ new Date() : y.value = null;
472
- }
473
- }), i = E({
474
- get() {
475
- return y.value === null ? "" : He(y.value);
476
- },
477
- set(t) {
478
- t ? y.value = /* @__PURE__ */ new Date(`${t} ${b.value}`) : y.value = null;
479
- }
480
- }), b = E({
481
- get() {
482
- return y.value === null ? "" : gt(y.value);
483
- },
484
- set(t) {
485
- t ? y.value = /* @__PURE__ */ new Date(`${i.value} ${t}`) : y.value = null;
486
- }
487
- });
488
- return {
489
- backdatePo: y,
490
- backdateSwitch: n,
491
- backdateModel: i,
492
- backdateTimeModel: b
493
- };
494
- }
495
- const vs = {
496
- width: "24",
497
- height: "24",
498
- viewBox: "0 0 24 24",
499
- fill: "none",
500
- xmlns: "http://www.w3.org/2000/svg"
501
- }, ys = ["fill"], bs = ["fill"], _s = ["stroke"], gs = ["stroke"], ks = /* @__PURE__ */ pe({
502
- __name: "SparkIcon",
503
- props: {
504
- size: {
505
- type: Number,
506
- default: 24
507
- },
508
- color: {
509
- type: String,
510
- default: "#c7c7cc"
511
- }
512
- },
513
- setup(m) {
514
- return (y, n) => (S(), q("svg", vs, [
515
- l("path", {
516
- 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",
517
- fill: m.color
518
- }, null, 8, ys),
519
- l("path", {
520
- 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",
521
- fill: m.color
522
- }, null, 8, bs),
523
- l("path", {
524
- 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",
525
- stroke: m.color,
526
- "stroke-width": "1.5",
527
- "stroke-linecap": "round",
528
- "stroke-linejoin": "round"
529
- }, null, 8, _s),
530
- l("path", {
531
- 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",
532
- stroke: m.color,
533
- "stroke-width": "1.5",
534
- "stroke-linecap": "round",
535
- "stroke-linejoin": "round"
536
- }, null, 8, gs)
537
- ]));
538
- }
539
- }), Cs = { class: "flex gap-8 items-center" }, hs = { class: "fm-typo-en-body-lg-600 line-clamp-1" }, xs = { class: "w-[343px] px-24 py-16 rounded-lg shadow-light-300 flex flex-col gap-[20px]" }, Ss = { class: "flex items-center w-full" }, ws = { class: "flex-1" }, Ds = { class: "fm-typo-en-title-sm-800" }, Fs = { class: "flex items-start gap-8" }, $s = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Ts = { class: "flex gap-1" }, st = /* @__PURE__ */ pe({
540
- __name: "ForecastStock",
541
- props: {
542
- disabled: { type: Boolean }
543
- },
544
- emits: ["update:poItems"],
545
- setup(m, { emit: y }) {
546
- const n = y, i = N(!1), b = N(7), t = qt(), f = Ae(), _ = je(), { t: w } = Ce();
547
- async function u() {
548
- if (b.value < 1)
549
- return;
550
- i.value = !1, await t.readPurchaseOrder(b.value);
551
- const a = [];
552
- if (t.purchaseOrderForecast.skus.length <= 0) {
553
- f.open({
554
- message: w("inventory.transfer.form.items.forecastStock.notAvailable"),
555
- type: "info"
556
- });
557
- return;
558
- }
559
- const o = t.purchaseOrderForecast.skus.reduce((v, k) => {
560
- const C = _.skus.find((D) => D._id === k.id);
561
- if (v.find((D) => D.sku._id === k.id) || !C)
562
- return v;
563
- const x = {
564
- sku: C,
565
- code: C.code,
566
- name: C.name,
567
- quantity: {
568
- amount: k.amount,
569
- precision: 0
570
- }
571
- };
572
- return v.push(x), v;
573
- }, a);
574
- n("update:poItems", o);
575
- }
576
- return (a, o) => {
577
- const v = P("FmButton"), k = P("FmIcon"), C = P("FmStepperField"), g = P("FmPopover");
578
- return S(), W(g, {
579
- disabled: a.disabled,
580
- class: "flex",
581
- "show-popover": i.value,
582
- onPopoverChanged: o[3] || (o[3] = (x) => i.value = x)
583
- }, {
584
- "popover-button": F(() => [
585
- d(v, {
586
- label: "unused",
587
- variant: "secondary",
588
- "text-color": a.disabled ? "disabled" : "primary",
589
- "bg-color": "transparent",
590
- "border-color": a.disabled ? "disabled" : "primary",
591
- disabled: a.disabled
592
- }, {
593
- default: F(() => [
594
- l("div", Cs, [
595
- d(ks, {
596
- size: 24,
597
- color: a.disabled ? "#c7c7cc" : "#ff7823"
598
- }, null, 8, ["color"]),
599
- l("div", hs, U(e(w)("inventory.transfer.form.items.forecastStock.title")), 1)
600
- ])
601
- ]),
602
- _: 1
603
- }, 8, ["text-color", "border-color", "disabled"])
604
- ]),
605
- default: F(() => [
606
- l("div", xs, [
607
- l("div", Ss, [
608
- l("div", ws, [
609
- d(Kt, { "z-index": 99 }, {
610
- default: F(() => [
611
- l("p", Ds, U(e(w)("inventory.transfer.form.items.forecastStock.title")), 1)
612
- ]),
613
- _: 1
614
- })
615
- ]),
616
- d(v, {
617
- icon: "close",
618
- size: "md",
619
- variant: "tertiary",
620
- onClick: o[0] || (o[0] = (x) => i.value = !1)
621
- })
622
- ]),
623
- d(C, {
624
- modelValue: b.value,
625
- "onUpdate:modelValue": o[1] || (o[1] = (x) => b.value = x),
626
- label: e(w)("inventory.transfer.form.items.forecastStock.days"),
627
- rules: [e(Ve)(1)]
628
- }, {
629
- "helper-text": F(() => [
630
- l("div", Fs, [
631
- d(k, {
632
- name: "warning",
633
- size: "sm",
634
- class: "text-fm-color-system-warning-300"
635
- }),
636
- l("div", $s, U(e(w)("inventory.transfer.form.items.forecastStock.replace")), 1)
637
- ])
638
- ]),
639
- _: 1
640
- }, 8, ["modelValue", "label", "rules"]),
641
- l("div", Ts, [
642
- o[4] || (o[4] = l("div", { class: "grow" }, null, -1)),
643
- d(v, {
644
- label: e(w)("common.cancel"),
645
- variant: "tertiary",
646
- onClick: o[2] || (o[2] = (x) => i.value = !1)
647
- }, null, 8, ["label"]),
648
- d(v, {
649
- label: e(w)("inventory.transfer.form.items.forecastStock.generate"),
650
- onClick: u
651
- }, null, 8, ["label"])
652
- ])
653
- ])
654
- ]),
655
- _: 1
656
- }, 8, ["disabled", "show-popover"]);
657
- };
658
- }
659
- });
660
- function Ps() {
661
- const m = Ae(), y = it(), n = N(!1);
662
- ge(n, (f) => {
663
- f && (b.value = !0, i().finally(() => {
664
- b.value = !1;
665
- }));
666
- });
667
- async function i() {
668
- try {
669
- const { startDate: f, endDate: _ } = kt(6), a = (await y.getPurchaseOrders({ start: f, end: _ })).filter(
670
- (o) => {
671
- var v, k;
672
- return o.status === Ct.enum.COMPLETE && ((v = o.supplier) == null ? void 0 : v.internal) !== "warehouse" && ((k = o.supplier) == null ? void 0 : k.internal) !== "restaurant";
673
- }
674
- ).reduce((o, v) => {
675
- const k = new Date(ht(v._id)), C = v.supplier._id;
676
- for (const g of v.items) {
677
- if (!g.totalCost) continue;
678
- const x = o[g.sku._id] ?? {}, D = x[C] ?? [];
679
- D.push({
680
- date: k.toISOString(),
681
- totalUnit: g.quantity,
682
- totalCost: g.totalCost,
683
- unit: g.sku.unit,
684
- measurement: g.measurement,
685
- seqNumber: v.seqNumber
686
- }), x[C] = D, o[g.sku._id] = x;
687
- }
688
- return o;
689
- }, {});
690
- t.value = a;
691
- } catch {
692
- m.open({
693
- title: "Something went wrong",
694
- message: "Cannot retrieve supplier purchase history. Please try again."
695
- }), n.value = !1;
696
- }
697
- }
698
- const b = N(!1), t = N({});
699
- return {
700
- comparePricesToggle: n,
701
- comparePriceFetching: b,
702
- comparePriceBySku: t
703
- };
704
- }
705
- const Is = { class: "fm-typo-body-md-400 line-clamp-2 w-full" }, Rs = { key: 0 }, Vs = ["colspan"], As = /* @__PURE__ */ pe({
706
- __name: "TransferItemTable",
707
- props: {
708
- row: {},
709
- comparePriceBySku: {},
710
- showComparePrice: { type: Boolean }
711
- },
712
- setup(m) {
713
- function y(n) {
714
- return n.column.columnDef.meta;
715
- }
716
- return (n, i) => {
717
- var b, t;
718
- return S(), q(ke, null, [
719
- l("tr", {
720
- class: J(["border-b border-fm-color-neutral-gray-100 hover:bg-fm-color-opacity-sm", {
721
- "bg-fm-color-neutral-gray-100": n.row.getIsSelected()
722
- }])
723
- }, [
724
- (S(!0), q(ke, null, Me(n.row.getVisibleCells(), (f) => {
725
- var _, w, u, a;
726
- return S(), q("td", {
727
- key: f.id,
728
- class: J([
729
- "h-[52px] px-16 text-fm-color-typo-primary",
730
- ((_ = y(f)) == null ? void 0 : _.cellClass) ?? "px-16"
731
- ]),
732
- style: lt({
733
- width: (w = y(f)) == null ? void 0 : w.width,
734
- maxWidth: (u = y(f)) == null ? void 0 : u.maxWidth,
735
- textAlign: ((a = y(f)) == null ? void 0 : a.textAlign) ?? "left"
736
- })
737
- }, [
738
- l("span", Is, [
739
- d(e(ie), {
740
- render: f.column.columnDef.cell,
741
- props: f.getContext()
742
- }, null, 8, ["render", "props"])
743
- ])
744
- ], 6);
745
- }), 128))
746
- ], 2),
747
- n.showComparePrice && Object.keys(n.comparePriceBySku[(b = n.row.original.sku) == null ? void 0 : b._id] ?? {}).length > 0 ? (S(), q("tr", Rs, [
748
- l("td", {
749
- colspan: n.row.getVisibleCells().length
750
- }, [
751
- d(ct, {
752
- prices: n.comparePriceBySku[(t = n.row.original.sku) == null ? void 0 : t._id]
753
- }, null, 8, ["prices"])
754
- ], 8, Vs)
755
- ])) : G("", !0)
756
- ], 64);
757
- };
758
- }
759
- }), Es = {
760
- key: 0,
761
- class: "flex flex-col gap-8"
762
- }, qs = { class: "flex flex-col gap-4" }, Us = { class: "flex items-center gap-4" }, Ms = {
763
- key: 0,
764
- class: "fm-typo-en-body-sm-400 text-fm-color-typo-error"
765
- }, Os = /* @__PURE__ */ pe({
766
- __name: "NetSuiteField",
767
- props: {
768
- required: { type: Boolean },
769
- disabled: { type: Boolean },
770
- supplier: {},
771
- setting: {},
772
- items: {},
773
- onChange: { type: Function }
774
- },
775
- emits: ["netsuite:ready"],
776
- setup(m, { emit: y }) {
777
- const n = ze(), i = m, b = y, { t } = Zt(), f = N(!1), _ = N();
778
- Ne(() => {
779
- var o, v, k, C;
780
- let a = {
781
- id: "",
782
- subsidiary: { id: "", name: "" },
783
- errors: []
784
- };
785
- if (!n.isEnabled || !i.required) {
786
- b("netsuite:ready", a);
787
- return;
788
- }
789
- try {
790
- const g = n.currentLocationSubsidiary();
791
- i.setting ? a = {
792
- ...i.setting,
793
- subsidiary: {
794
- id: g.id || "",
795
- name: g.name
796
- }
797
- } : a = {
798
- ...a,
799
- subsidiary: {
800
- id: g.id || "",
801
- name: g.name
802
- }
803
- };
804
- const x = n.getAvailableItems(g.id), D = i.items.filter((R) => {
805
- if (R.measurement != null) {
806
- const z = n.getAvailableMeasurements(
807
- R.sku._id,
808
- g.id
809
- );
810
- return x.includes(R.sku._id) && z.includes(R.measurement.id);
811
- }
812
- return x.includes(R.sku._id);
813
- }).map((R) => R.sku._id);
814
- i.onChange(
815
- i.items.filter((R) => D.includes(R.sku._id)),
816
- a
817
- );
818
- } finally {
819
- i.supplier.internal ? _.value = n.getNetSuiteLocation(
820
- `${i.supplier.internal}_${i.supplier._id}`
821
- ) : _.value = n.getNetSuiteVendor(i.supplier._id);
822
- const g = i.supplier.internal ? n.getLocationSubsidiary((o = _.value) == null ? void 0 : o.netSuiteId).id : (v = _.value) == null ? void 0 : v.subsidiaryId, x = i.supplier.internal ? (k = n.currentLocationSubsidiary()) == null ? void 0 : k.id : (C = n.currentVendorSubsidiary(i.supplier._id)) == null ? void 0 : C.id;
823
- !n.isEnabled || g && n.isEnabled && g == x ? b("netsuite:ready", a) : f.value = !0;
824
- }
825
- });
826
- const w = E(
827
- () => i.supplier.internal ? n.currentLocationSubsidiary() : n.currentVendorSubsidiary(i.supplier._id)
828
- ), u = E(() => {
829
- var a, o;
830
- return _.value == null ? `Cannot find the NetSuite location for "${i.supplier.name}"` : `The subsidiary of the request
831
- location is ${(o = n.getLocationSubsidiary((a = _.value) == null ? void 0 : a.netSuiteId)) == null ? void 0 : o.fullName}`;
832
- });
833
- return (a, o) => {
834
- const v = P("FmLabel"), k = P("FmIcon"), C = P("FmField"), g = P("FmTooltip");
835
- return e(n).isEnabled && i.required ? (S(), q("div", Es, [
836
- d(v, {
837
- label: `NetSuite ${e(t)("inventory.transfer.form.netsuite.subsidiary")}`
838
- }, null, 8, ["label"]),
839
- l("div", qs, [
840
- d(g, {
841
- "z-index": 51,
842
- placement: "left",
843
- disabled: a.disabled
844
- }, {
845
- content: F(() => o[0] || (o[0] = [
846
- Oe("This field is locked and based on the location of the request.")
847
- ])),
848
- default: F(() => [
849
- d(C, null, {
850
- default: F(() => {
851
- var x;
852
- return [
853
- l("div", Us, [
854
- d(k, {
855
- name: "lock_outline",
856
- size: "sm",
857
- color: a.disabled ? "neutral-gray-200" : "neutral-gray-400"
858
- }, null, 8, ["color"]),
859
- l("div", {
860
- class: J([a.disabled ? "text-fm-color-typo-disabled" : ""])
861
- }, U((x = w.value) == null ? void 0 : x.fullName), 3)
862
- ])
863
- ];
864
- }),
865
- _: 1
866
- })
867
- ]),
868
- _: 1
869
- }, 8, ["disabled"]),
870
- f.value ? (S(), q("div", Ms, U(u.value), 1)) : G("", !0)
871
- ])
872
- ])) : G("", !0);
873
- };
874
- }
875
- }), Bs = { class: "flex flex-col gap-4" }, Ns = { class: "flex items-center gap-8 overflow-x-auto pb-12" }, zs = { class: "flex flex-col gap-16" }, Ls = { class: "flex flex-col gap-24" }, Hs = { class: "flex flex-col gap-8" }, js = { class: "flex flex-col gap-4" }, Ys = { class: "flex items-center gap-4" }, Qs = { class: "flex flex-col gap-8" }, Ks = { class: "flex flex-col gap-4" }, Zs = { class: "flex items-center gap-4" }, Gs = {
876
- key: 3,
877
- class: "p-16 border border-fm-color-neutral-gray-300 fm-corner-radius-md flex flex-col"
878
- }, Ws = {
879
- key: 0,
880
- class: "flex-1 flex gap-8 h-48 xs:flex-col xs:pt-16 sm:flex-col sm:pt-16"
881
- }, Js = { class: "flex-1" }, Xs = { class: "flex-1" }, ea = {
882
- key: 1,
883
- class: "flex items-center gap-4"
884
- }, ta = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary translate-y-[1px]" }, sa = { class: "flex flex-col gap-16" }, aa = { class: "flex-1 gap-8 fm-typo-en-title-sm-600" }, oa = { class: "flex gap-8" }, la = { key: 0 }, na = /* @__PURE__ */ pe({
885
- __name: "TransferForm2",
886
- props: {
887
- modelValue: {},
888
- request: {},
889
- disabled: { type: Boolean },
890
- suppliers: {},
891
- skus: {},
892
- lastClosingDate: {}
893
- },
894
- emits: ["validation-success", "form:ready"],
895
- setup(m, { expose: y, emit: n }) {
896
- const i = m, b = n, t = xt(), { t: f } = Ce(), _ = Ye(), w = je(), u = ze(), a = Ke(), o = Ee(), v = dt(), { breakpoints: k } = Qe(), C = E(() => k.value.xs || k.value.sm), g = ot({
897
- value: !1
898
- }), x = N(!1), D = E(
899
- () => {
900
- var s;
901
- return ((s = i.modelValue) == null ? void 0 : s.templateDoc) ?? v.templates.find((r) => r._id === t.template);
902
- }
903
- ), R = E(() => t.status === "DRAFT" || !t._rev);
904
- ge(D, (s) => {
905
- s && R.value && (t.supplier = (s == null ? void 0 : s.purchaseOrder.supplier) ?? t.supplier);
906
- }), Ne(() => {
907
- var s;
908
- try {
909
- if (!t.template) return;
910
- if (!t.items.length) {
911
- let r = [];
912
- (s = D.value) != null && s.purchaseOrder.items && (r = D.value.purchaseOrder.items.filter((M) => {
913
- var Z;
914
- return ((Z = M.quantity) == null ? void 0 : Z.amount) != 0;
915
- })), t.items = r;
916
- }
917
- } finally {
918
- x.value = !0;
919
- }
920
- }), ge([x, g], ([s, r], [M, Z]) => {
921
- r.value && Z.value && b("form:ready");
922
- });
923
- const z = E(
924
- () => _.currentLocation.type === St.restaurant
925
- );
926
- _.watchLocation(async () => {
927
- location && (t.supplier || (t.supplier = a.suppliers.find((s) => s) ?? t.supplier));
928
- });
929
- const ue = Nt(), T = Yt(
930
- () => t,
931
- (s) => {
932
- Object.assign(t, s);
933
- },
934
- !0,
935
- !0
936
- ), $ = E({
937
- get() {
938
- var s;
939
- return typeof ((s = t == null ? void 0 : t.supplier) == null ? void 0 : s.internal) == "string" ? j.TRANSFER : j.PURCHASE;
940
- },
941
- set(s) {
942
- var M;
943
- const r = typeof ((M = t == null ? void 0 : t.supplier) == null ? void 0 : M.internal) == "string" ? j.TRANSFER : j.PURCHASE;
944
- s !== r && (t.supplier = s === j.PURCHASE ? T.locationOptionsTypePurchase.value[0] : T.locationOptionsTypeTransfer.value[0]);
945
- }
946
- });
947
- ge(
948
- () => {
949
- var s;
950
- return (s = i.modelValue) == null ? void 0 : s.template;
951
- },
952
- (s) => {
953
- o.mustUsePoTemplate && !s && mt(() => {
954
- var r, M;
955
- t.supplier = ((M = (r = T.locationOptionsTypeTransfer.value) == null ? void 0 : r.filter(
956
- (Z) => Z.internal === "restaurant"
957
- )) == null ? void 0 : M[0]) ?? t.supplier;
958
- });
959
- },
960
- { immediate: !0 }
961
- );
962
- const O = E(() => {
963
- let s = T.transferLocationOptions.value;
964
- return o.mustUsePoTemplate && !t.template && (s = s.filter((r) => {
965
- var M;
966
- return (M = r.sublabel) == null ? void 0 : M.startsWith("restaurant");
967
- })), s;
968
- }), V = E({
969
- get() {
970
- return t.supplier._id;
971
- },
972
- set(s) {
973
- T.transferLocationModel.value = s;
974
- }
975
- }), I = E({
976
- get() {
977
- return t.remark ?? void 0;
978
- },
979
- set(s) {
980
- t.remark = s;
981
- }
982
- }), { backdatePo: B, backdateSwitch: Q, backdateModel: K, backdateTimeModel: p } = fs({
983
- getEffectiveAt() {
984
- return t.effectiveAt;
985
- },
986
- setEffectiveAt(s) {
987
- t.effectiveAt = s;
988
- }
989
- }), { comparePricesToggle: c, comparePriceFetching: H, comparePriceBySku: oe } = Ps(), X = N();
990
- y({
991
- validateInputs: () => {
992
- var s, r;
993
- (r = (s = X.value) == null ? void 0 : s.validateInputs) == null || r.call(s);
994
- },
995
- resetInputsValidation: () => {
996
- var s, r;
997
- (r = (s = X.value) == null ? void 0 : s.resetInputsValidation) == null || r.call(s);
998
- },
999
- resetInputs: () => {
1000
- var s, r;
1001
- (r = (s = X.value) == null ? void 0 : s.resetInputs) == null || r.call(s);
1002
- }
1003
- });
1004
- const $e = Gt({
1005
- updateItem: (s) => {
1006
- t.items = t.items.map((r) => r.sku._id !== s.sku._id ? r : s);
1007
- },
1008
- deleteItem: (s) => {
1009
- t.items = t.items.filter((r) => r.sku._id !== s.sku._id);
1010
- },
1011
- get supplier() {
1012
- return t.supplier;
1013
- },
1014
- get items() {
1015
- return t.items;
1016
- },
1017
- get transferType() {
1018
- return $.value;
1019
- },
1020
- get template() {
1021
- return D.value;
1022
- },
1023
- get disabled() {
1024
- return i.disabled;
1025
- }
1026
- }), he = E(() => {
1027
- let s = $e.columnDefs.value;
1028
- return u.isEnabled && $.value === j.TRANSFER && (s = s.filter((r) => r.id !== Y.TotalCost)), s;
1029
- });
1030
- function Te() {
1031
- var ae, fe, xe, Ie, we;
1032
- const s = new Set((xe = (fe = (ae = D.value) == null ? void 0 : ae.purchaseOrder) == null ? void 0 : fe.items) == null ? void 0 : xe.map((A) => A.sku._id)), r = u.isEnabled ? u.getAvailableItems((we = (Ie = t.netSuite) == null ? void 0 : Ie.subsidiary) == null ? void 0 : we.id) : [], M = s.size ? w.skus.filter((A) => s.has(A._id)) : w.skus, Z = u.isEnabled ? M.filter((A) => {
1033
- var le, te, ce, ne;
1034
- const ee = (te = (le = D.value) == null ? void 0 : le.purchaseOrder) == null ? void 0 : te.items.find(
1035
- (me) => me.sku._id === A._id
1036
- );
1037
- if (ee != null && ee.measurement != null) {
1038
- const me = u.getAvailableMeasurements(
1039
- ee.sku._id,
1040
- (ne = (ce = t.netSuite) == null ? void 0 : ce.subsidiary) == null ? void 0 : ne.id
1041
- );
1042
- return r.includes(ee.sku._id) && me.includes(ee.measurement.id);
1043
- }
1044
- return r.includes(A._id);
1045
- }).map((A) => A._id) : M.map((A) => A._id), de = M.map(
1046
- (A) => ({
1047
- label: A.name,
1048
- sublabel: A.code,
1049
- value: A,
1050
- disabled: !Z.includes(A._id)
1051
- })
1052
- ), be = de.filter((A) => {
1053
- var ee;
1054
- return (ee = t.items) == null ? void 0 : ee.find((le) => le.sku._id === A.value._id);
1055
- }).map((A) => A.value);
1056
- ue.open({
1057
- title: f("inventory.transfer.form.items.selectItem"),
1058
- closeButton: !0,
1059
- contentComponent: $t,
1060
- contentComponentProps: {
1061
- modelValue: be,
1062
- items: de,
1063
- virtualScroll: !0
1064
- },
1065
- primaryActions: {
1066
- text: f("common.confirm"),
1067
- close: !0
1068
- },
1069
- secondaryActions: {
1070
- text: f("common.close"),
1071
- close: !0,
1072
- variant: "tertiary"
1073
- }
1074
- }).onPrimary((A) => {
1075
- const ee = t.items ?? [], le = A.map((te) => {
1076
- var me, De;
1077
- const ce = ee.find((_e) => _e.sku._id === te._id);
1078
- if (ce)
1079
- return ce;
1080
- const ne = ((De = (me = D.value) == null ? void 0 : me.purchaseOrder.items) == null ? void 0 : De.find(
1081
- (_e) => _e.sku._id === te._id
1082
- )) ?? {
1083
- sku: te,
1084
- code: te.code,
1085
- name: te.name,
1086
- quantity: {
1087
- amount: 1,
1088
- precision: 0
1089
- }
1090
- };
1091
- return $.value == j.PURCHASE && (ne.totalCost = re(
1092
- ne.sku,
1093
- ne.quantity,
1094
- ne.measurement,
1095
- {
1096
- supplier: t.supplier
1097
- }
1098
- )), ne;
1099
- });
1100
- le.sort((te, ce) => te.sku.code.localeCompare(ce.sku.code)), t.items = le;
1101
- });
1102
- }
1103
- function qe(s) {
1104
- return s;
1105
- }
1106
- const Pe = E(() => {
1107
- const s = [];
1108
- return (!o.mustUsePoTemplate || o.mustUsePoTemplate && t.template) && s.push({
1109
- label: f("inventory.transfer.form.type.purchase"),
1110
- value: j.PURCHASE
1111
- }), s.push({
1112
- label: f("inventory.transfer.form.type.transfer"),
1113
- value: j.TRANSFER
1114
- }), s;
1115
- });
1116
- return (s, r) => {
1117
- var me, De;
1118
- const M = P("FmChip"), Z = P("FmLabel"), de = P("FmIcon"), be = P("FmField"), ae = P("FmTooltip"), fe = P("FmSelect"), xe = P("FmTextField"), Ie = P("FmTextarea"), we = P("FmSwitch"), A = P("FmDatePicker"), ee = P("FmTimePicker"), le = P("FmFormGroup"), te = P("FmButton"), ce = P("FmTable"), ne = P("FmForm");
1119
- return S(), q("div", Bs, [
1120
- l("div", Ns, [
1121
- (me = i.modelValue) != null && me.template ? (S(), W(M, {
1122
- key: 0,
1123
- variant: s.disabled ? "warning" : void 0,
1124
- label: `${e(f)("inventory.transfer.template.title")}: ${((De = D.value) == null ? void 0 : De.name) ?? e(f)("inventory.transfer.form.loading")}`,
1125
- icon: "summarize",
1126
- compact: ""
1127
- }, null, 8, ["variant", "label"])) : G("", !0),
1128
- d(M, {
1129
- label: e(_).currentLocation.name,
1130
- icon: "storefront",
1131
- compact: ""
1132
- }, null, 8, ["label"]),
1133
- s.lastClosingDate ? (S(), W(M, {
1134
- key: 1,
1135
- label: `${e(f)("inventory.transfer.form.lastClosing")}: ${e(He)(s.lastClosingDate)} ${e(wt)(s.lastClosingDate)}`,
1136
- icon: "calendar_month",
1137
- compact: ""
1138
- }, null, 8, ["label"])) : G("", !0)
1139
- ]),
1140
- d(ne, {
1141
- ref_key: "formRef",
1142
- ref: X,
1143
- class: "flex flex-col gap-32",
1144
- disabled: s.disabled,
1145
- onValidationFailed: console.log,
1146
- onValidationSuccess: r[13] || (r[13] = (_e) => b("validation-success"))
1147
- }, {
1148
- default: F(() => {
1149
- var _e, Ze;
1150
- return [
1151
- l("div", zs, [
1152
- l("div", Ls, [
1153
- (_e = i.modelValue) != null && _e.template ? (S(), q(ke, { key: 0 }, [
1154
- l("div", Hs, [
1155
- d(Z, {
1156
- label: e(f)("inventory.transfer.form.type.title")
1157
- }, null, 8, ["label"]),
1158
- l("div", js, [
1159
- d(ae, {
1160
- "z-index": 51,
1161
- placement: "left",
1162
- disabled: s.disabled
1163
- }, {
1164
- content: F(() => r[14] || (r[14] = [
1165
- Oe("This field is locked from template.")
1166
- ])),
1167
- default: F(() => [
1168
- d(be, null, {
1169
- default: F(() => [
1170
- l("div", Ys, [
1171
- d(de, {
1172
- name: "lock_outline",
1173
- size: "sm",
1174
- color: s.disabled ? "neutral-gray-200" : "neutral-gray-400"
1175
- }, null, 8, ["color"]),
1176
- l("div", {
1177
- class: J({ "text-fm-color-typo-disabled": s.disabled })
1178
- }, U(e(f)(`inventory.transfer.form.type.${$.value.toLocaleLowerCase("en-us")}`)), 3)
1179
- ])
1180
- ]),
1181
- _: 1
1182
- })
1183
- ]),
1184
- _: 1
1185
- }, 8, ["disabled"]),
1186
- l("div", {
1187
- class: J([
1188
- "fm-typo-en-body-sm-400",
1189
- s.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-typo-secondary"
1190
- ])
1191
- }, null, 2)
1192
- ])
1193
- ]),
1194
- l("div", Qs, [
1195
- d(Z, {
1196
- label: $.value === e(j).PURCHASE ? e(f)("inventory.transfer.form.purchaseFrom") : e(f)("inventory.transfer.form.transferFrom")
1197
- }, null, 8, ["label"]),
1198
- l("div", Ks, [
1199
- d(ae, {
1200
- "z-index": 51,
1201
- placement: "left",
1202
- disabled: s.disabled
1203
- }, {
1204
- content: F(() => r[15] || (r[15] = [
1205
- Oe("This field is locked from template.")
1206
- ])),
1207
- default: F(() => [
1208
- d(be, null, {
1209
- default: F(() => {
1210
- var h;
1211
- return [
1212
- l("div", Zs, [
1213
- d(de, {
1214
- name: "lock_outline",
1215
- size: "sm",
1216
- color: s.disabled ? "neutral-gray-200" : "neutral-gray-400"
1217
- }, null, 8, ["color"]),
1218
- l("div", {
1219
- class: J({ "text-fm-color-typo-disabled": s.disabled })
1220
- }, U((h = O.value.find((se) => se.value === V.value)) == null ? void 0 : h.label), 3)
1221
- ])
1222
- ];
1223
- }),
1224
- _: 1
1225
- })
1226
- ]),
1227
- _: 1
1228
- }, 8, ["disabled"])
1229
- ])
1230
- ])
1231
- ], 64)) : (S(), q(ke, { key: 1 }, [
1232
- d(fe, {
1233
- label: e(f)("inventory.transfer.form.type.title"),
1234
- "label-mark": "required",
1235
- modelValue: $.value,
1236
- "onUpdate:modelValue": r[0] || (r[0] = (h) => $.value = h),
1237
- items: Pe.value,
1238
- rules: [e(Ve)(1)(O.value)]
1239
- }, {
1240
- default: F(() => [
1241
- l("span", {
1242
- class: J([
1243
- "line-clamp-1 fm-typo-en-body-lg-400",
1244
- s.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-typo-primary"
1245
- ])
1246
- }, U(e(Dt)($.value)), 3)
1247
- ]),
1248
- _: 1
1249
- }, 8, ["label", "modelValue", "items", "rules"]),
1250
- d(fe, {
1251
- label: $.value === e(j).PURCHASE ? e(f)("inventory.transfer.form.purchaseFrom") : e(f)("inventory.transfer.form.transferFrom"),
1252
- "label-mark": "required",
1253
- modelValue: V.value,
1254
- "onUpdate:modelValue": r[1] || (r[1] = (h) => V.value = h),
1255
- items: O.value
1256
- }, {
1257
- "menu-wrapper": F((h) => {
1258
- var se, Ge;
1259
- return [
1260
- d(Qt, Be(h, {
1261
- items: O.value,
1262
- "model-value": (Ge = (se = s.modelValue) == null ? void 0 : se.supplier) == null ? void 0 : Ge._id
1263
- }), null, 16, ["items", "model-value"])
1264
- ];
1265
- }),
1266
- default: F(() => {
1267
- var h;
1268
- return [
1269
- l("span", {
1270
- class: J([
1271
- "line-clamp-1 fm-typo-en-body-lg-400",
1272
- s.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-typo-primary"
1273
- ])
1274
- }, U((h = O.value.find((se) => se.value === V.value)) == null ? void 0 : h.label), 3)
1275
- ];
1276
- }),
1277
- _: 1
1278
- }, 8, ["label", "modelValue", "items"])
1279
- ], 64)),
1280
- d(xe, {
1281
- label: e(f)("inventory.transfer.form.reference"),
1282
- "label-mark": "optional",
1283
- modelValue: e(t).ref,
1284
- "onUpdate:modelValue": r[2] || (r[2] = (h) => e(t).ref = h)
1285
- }, null, 8, ["label", "modelValue"]),
1286
- d(Ie, {
1287
- label: e(f)("inventory.transfer.form.remark"),
1288
- "label-mark": "optional",
1289
- "max-length": 240,
1290
- modelValue: I.value,
1291
- "onUpdate:modelValue": r[3] || (r[3] = (h) => I.value = h),
1292
- class: J([s.disabled ? "text-fm-color-typo-disabled " : ""])
1293
- }, null, 8, ["label", "modelValue", "class"]),
1294
- x.value ? (S(), W(Os, {
1295
- key: 2,
1296
- required: e(t).template != null,
1297
- disabled: s.disabled,
1298
- supplier: e(t).supplier,
1299
- setting: e(t).netSuite,
1300
- items: e(t).items,
1301
- onChange: (h, se) => {
1302
- e(t).items = h, e(t).netSuite = se;
1303
- },
1304
- "onNetsuite:ready": r[4] || (r[4] = (h) => {
1305
- g.value = !0;
1306
- })
1307
- }, null, 8, ["required", "disabled", "supplier", "setting", "items", "onChange"])) : G("", !0),
1308
- e(o).enableBackdatePo ? (S(), q("div", Gs, [
1309
- l("div", {
1310
- class: J([
1311
- "flex",
1312
- {
1313
- "flex-col": C.value
1314
- }
1315
- ])
1316
- }, [
1317
- d(we, {
1318
- modelValue: e(Q),
1319
- "onUpdate:modelValue": r[5] || (r[5] = (h) => Se(Q) ? Q.value = h : null),
1320
- label: e(f)("inventory.transfer.form.backdate.title"),
1321
- sublabel: e(f)("inventory.transfer.form.backdate.subtitle"),
1322
- "label-placement": "right",
1323
- disabled: z.value && !s.lastClosingDate || s.disabled
1324
- }, null, 8, ["modelValue", "label", "sublabel", "disabled"]),
1325
- l("div", {
1326
- class: J({ hidden: C.value, "w-16": !C.value })
1327
- }, null, 2),
1328
- e(Q) ? (S(), q("div", Ws, [
1329
- l("div", Js, [
1330
- d(A, {
1331
- modelValue: e(K),
1332
- "onUpdate:modelValue": r[6] || (r[6] = (h) => Se(K) ? K.value = h : null)
1333
- }, null, 8, ["modelValue"])
1334
- ]),
1335
- l("div", Xs, [
1336
- d(ee, {
1337
- modelValue: e(p),
1338
- "onUpdate:modelValue": r[7] || (r[7] = (h) => Se(p) ? p.value = h : null)
1339
- }, null, 8, ["modelValue"])
1340
- ])
1341
- ])) : G("", !0)
1342
- ], 2),
1343
- e(B) ? (S(), W(le, {
1344
- key: 0,
1345
- modelValue: e(B),
1346
- "onUpdate:modelValue": r[8] || (r[8] = (h) => Se(B) ? B.value = h : null),
1347
- rules: [e(Ft)(new Date(s.lastClosingDate), /* @__PURE__ */ new Date())]
1348
- }, null, 8, ["modelValue", "rules"])) : G("", !0),
1349
- z.value && !s.lastClosingDate ? (S(), q("div", ea, [
1350
- d(de, {
1351
- name: "error",
1352
- size: "sm",
1353
- class: "text-fm-color-typo-warning"
1354
- }),
1355
- l("span", ta, U(e(f)("inventory.transfer.form.backdate.error")), 1)
1356
- ])) : G("", !0)
1357
- ])) : G("", !0)
1358
- ])
1359
- ]),
1360
- l("div", sa, [
1361
- d(le, {
1362
- "model-value": e(t).items,
1363
- rules: [e(Ve)(1)]
1364
- }, null, 8, ["model-value", "rules"]),
1365
- l("div", {
1366
- class: J([
1367
- "flex gap-16",
1368
- {
1369
- "flex-col items-start": C.value,
1370
- "items-center": !C.value
1371
- }
1372
- ])
1373
- }, [
1374
- l("div", aa, U(e(f)("inventory.transfer.form.items.title")), 1),
1375
- l("div", oa, [
1376
- d(te, {
1377
- disabled: s.disabled,
1378
- label: e(f)("inventory.transfer.form.items.addItem"),
1379
- "prepend-icon": "add",
1380
- variant: "secondary",
1381
- "text-color": "primary",
1382
- "bg-color": "transparent",
1383
- "border-color": "primary",
1384
- onClick: r[9] || (r[9] = (h) => Te()),
1385
- size: "md"
1386
- }, null, 8, ["disabled", "label"]),
1387
- e(t).template ? (S(), W(ae, {
1388
- key: 0,
1389
- "z-index": 50
1390
- }, {
1391
- content: F(() => [
1392
- l("div", null, U(e(f)("inventory.transfer.form.items.forecastStock.notAvailable")), 1)
1393
- ]),
1394
- default: F(() => [
1395
- d(st, {
1396
- "onUpdate:poItems": r[10] || (r[10] = (h) => e(t).items = h),
1397
- disabled: ""
1398
- })
1399
- ]),
1400
- _: 1
1401
- })) : (S(), W(st, {
1402
- key: 1,
1403
- "onUpdate:poItems": r[11] || (r[11] = (h) => e(t).items = h),
1404
- disabled: s.disabled || !!e(t).template
1405
- }, null, 8, ["disabled"]))
1406
- ])
1407
- ], 2),
1408
- $.value === e(j).PURCHASE && R.value && e(o).enableTotalCost && ((Ze = s.modelValue) != null && Ze.items.length) ? (S(), q("div", la, [
1409
- d(we, {
1410
- label: e(H) ? e(f)("inventory.transfer.form.items.fetchingData") : e(f)("inventory.transfer.form.items.comparePriceHistory"),
1411
- "prepend-icon": "compare_arrows",
1412
- "label-placement": "right",
1413
- "model-value": e(c),
1414
- "onUpdate:modelValue": r[12] || (r[12] = (h) => Se(c) ? c.value = h : null),
1415
- disabled: e(H) || s.disabled
1416
- }, null, 8, ["label", "model-value", "disabled"])
1417
- ])) : G("", !0),
1418
- (S(), W(ce, {
1419
- "column-defs": he.value,
1420
- "row-data": e(t).items,
1421
- key: e(t).items.map((h) => h.sku._id).join("."),
1422
- "hide-footer": "",
1423
- "page-size": e(t).items.length
1424
- }, {
1425
- "table-row": F((h) => [
1426
- d(As, {
1427
- "compare-price-by-sku": e(oe),
1428
- "show-compare-price": $.value === e(j).PURCHASE && e(c),
1429
- row: h
1430
- }, null, 8, ["compare-price-by-sku", "show-compare-price", "row"])
1431
- ]),
1432
- "list-row": F((h) => [
1433
- (S(), W(rt, {
1434
- row: h,
1435
- key: e(t).items.map((se) => se.sku._id).join(".")
1436
- }, {
1437
- default: F((se) => [
1438
- d(ps, {
1439
- "compare-price-by-sku": e(oe),
1440
- "show-compare-price": $.value === e(j).PURCHASE && e(c),
1441
- row: h,
1442
- "cell-by-col-id": se
1443
- }, null, 8, ["compare-price-by-sku", "show-compare-price", "row", "cell-by-col-id"])
1444
- ]),
1445
- _: 2
1446
- }, 1032, ["row"]))
1447
- ]),
1448
- _: 1
1449
- }, 8, ["column-defs", "row-data", "page-size"]))
1450
- ])
1451
- ];
1452
- }),
1453
- _: 1
1454
- }, 8, ["disabled", "onValidationFailed"])
1455
- ]);
1456
- };
1457
- }
1458
- }), ra = { class: "flex items-center" }, ia = { class: "fm-typo-en-title-md-800" }, ua = { class: "flex gap-4" }, da = /* @__PURE__ */ pe({
1459
- __name: "TransferDialog",
1460
- props: {
1461
- mode: {},
1462
- modelValue: {},
1463
- templateId: {},
1464
- show: { type: Boolean },
1465
- lastClosingDate: {}
1466
- },
1467
- emits: ["update:show", "submitted"],
1468
- setup(m, { expose: y, emit: n }) {
1469
- var K;
1470
- const i = m, b = n, t = it(), f = dt(), _ = Ae(), w = Ke(), u = je(), a = Ye(), o = Ee(), { t: v } = Ce(), k = N(!1), C = N(!1), g = N(!1);
1471
- async function x(p) {
1472
- if (p) {
1473
- C.value = !1;
1474
- try {
1475
- await w.readSuppliers(), C.value = !0;
1476
- } catch {
1477
- _.open({
1478
- title: v("inventory.transfer.form.unableToFetchListOfSuppliers.title"),
1479
- message: v("inventory.transfer.form.unableToFetchListOfSuppliers.message"),
1480
- type: "error"
1481
- });
1482
- }
1483
- }
1484
- }
1485
- a.watchLocation(x);
1486
- function D() {
1487
- return {
1488
- remark: void 0,
1489
- ref: void 0,
1490
- stockSnapshotId: void 0,
1491
- effectiveAt: void 0,
1492
- items: [],
1493
- supplier: {
1494
- _rev: void 0,
1495
- email: void 0,
1496
- internal: void 0,
1497
- contactName: void 0,
1498
- phoneNumber: void 0,
1499
- registrationNumber: void 0,
1500
- supplyItems: void 0,
1501
- _id: "",
1502
- name: "",
1503
- address: {
1504
- line2: void 0,
1505
- line1: "",
1506
- state: "",
1507
- city: "",
1508
- postcode: "",
1509
- country: ""
1510
- }
1511
- },
1512
- status: "DRAFT",
1513
- _id: "",
1514
- seqNumber: 0,
1515
- deliveryOrder: [],
1516
- template: i.templateId,
1517
- templateDoc: f.templates.find((c) => c._id === i.templateId)
1518
- };
1519
- }
1520
- const R = zt(i, "show"), z = N(i.modelValue ?? D()), ue = N(((K = i.modelValue) == null ? void 0 : K._id) ?? `${Math.random()}`);
1521
- ge(
1522
- () => i.show,
1523
- (p) => {
1524
- var c;
1525
- p && (g.value = !1, z.value = i.modelValue ?? D(), ue.value = ((c = i.modelValue) == null ? void 0 : c._id) ?? `${Math.random()}`);
1526
- }
1527
- );
1528
- const T = E(() => !C.value || !g.value), $ = E(() => {
1529
- switch (i.mode) {
1530
- case Fe.READ:
1531
- return "View transfer";
1532
- case Fe.CREATE:
1533
- return v("inventory.transfer.receiveRequest.create.title");
1534
- case Fe.UPDATE:
1535
- return v("inventory.transfer.receiveRequest.update.title");
1536
- }
1537
- return "";
1538
- }), O = N();
1539
- y({
1540
- validateInputs: () => {
1541
- var p, c;
1542
- (c = (p = O.value) == null ? void 0 : p.validateInputs) == null || c.call(p);
1543
- },
1544
- resetInputsValidation: () => {
1545
- var p, c;
1546
- (c = (p = O.value) == null ? void 0 : p.resetInputsValidation) == null || c.call(p);
1547
- },
1548
- resetInputs: () => {
1549
- var p, c;
1550
- (c = (p = O.value) == null ? void 0 : p.resetInputs) == null || c.call(p);
1551
- }
1552
- });
1553
- async function V() {
1554
- const p = z.value;
1555
- k.value = !0, (p.supplier.internal === "warehouse" || p.supplier.internal === "restaurant") && (p.items = p.items.map(({ totalCost: c, ...H }) => H)), o.mustUseDefaultCost && (p.items = p.items.map((c) => ({
1556
- ...c,
1557
- totalCost: re(c.sku, c.quantity, c.measurement)
1558
- })));
1559
- try {
1560
- await t.createPurchaseOrder(p), await new Promise((c) => setTimeout(c, 1e3)), _.open({
1561
- title: v("inventory.transfer.receiveRequest.create.success"),
1562
- message: v("inventory.transfer.receiveRequest.create.successMessage"),
1563
- type: "success"
1564
- }), b("update:show", !1), b("submitted");
1565
- } catch (c) {
1566
- _.open({
1567
- title: v("inventory.transfer.receiveRequest.create.error.title"),
1568
- message: v("inventory.transfer.receiveRequest.create.error.message"),
1569
- type: "error"
1570
- }), console.error("Error in creating purchase order", c);
1571
- } finally {
1572
- k.value = !1;
1573
- }
1574
- }
1575
- async function I() {
1576
- const p = z.value;
1577
- k.value = !0, (p.supplier.internal === "warehouse" || p.supplier.internal === "restaurant") && (p.items = p.items.map(({ totalCost: c, ...H }) => H)), o.mustUseDefaultCost && (p.items = p.items.map((c) => ({
1578
- ...c,
1579
- totalCost: re(c.sku, c.quantity, c.measurement)
1580
- })));
1581
- try {
1582
- await t.updatePurchaseOrder(p), await new Promise((c) => setTimeout(c, 1e3)), _.open({
1583
- title: v("inventory.transfer.receiveRequest.update.success"),
1584
- message: v("inventory.transfer.receiveRequest.update.successMessage"),
1585
- type: "success"
1586
- }), b("update:show", !1), b("submitted");
1587
- } catch (c) {
1588
- _.open({
1589
- title: v("inventory.transfer.receiveRequest.update.error.title"),
1590
- message: v("inventory.transfer.receiveRequest.update.error.message"),
1591
- type: "error"
1592
- }), console.error("Error in updating purchase order", c);
1593
- } finally {
1594
- k.value = !1;
1595
- }
1596
- }
1597
- function B() {
1598
- switch (i.mode) {
1599
- case Fe.CREATE:
1600
- return V();
1601
- case Fe.UPDATE:
1602
- return I();
1603
- }
1604
- }
1605
- function Q() {
1606
- var p, c;
1607
- (c = (p = O.value) == null ? void 0 : p.validateInputs) == null || c.call(p);
1608
- }
1609
- return (p, c) => {
1610
- const H = P("FmButton"), oe = P("FmSideSheet");
1611
- return S(), W(oe, {
1612
- modelValue: e(R),
1613
- "onUpdate:modelValue": c[3] || (c[3] = (X) => Se(R) ? R.value = X : null),
1614
- "dismiss-away": "",
1615
- "close-button": "",
1616
- "max-width": 900
1617
- }, {
1618
- "side-sheet-header": F(() => [
1619
- l("div", ra, [
1620
- l("div", ia, U($.value), 1)
1621
- ])
1622
- ]),
1623
- default: F(() => [
1624
- (S(), W(na, {
1625
- class: "w-full",
1626
- ref_key: "formRef",
1627
- ref: O,
1628
- "onForm:ready": c[0] || (c[0] = () => g.value = !0),
1629
- onValidationSuccess: B,
1630
- modelValue: z.value,
1631
- "onUpdate:modelValue": c[1] || (c[1] = (X) => z.value = X),
1632
- disabled: k.value || T.value,
1633
- suppliers: e(w).suppliers,
1634
- skus: e(u).skus,
1635
- key: ue.value,
1636
- "last-closing-date": p.lastClosingDate
1637
- }, null, 8, ["modelValue", "disabled", "suppliers", "skus", "last-closing-date"]))
1638
- ]),
1639
- "side-sheet-footer": F(() => [
1640
- l("div", ua, [
1641
- d(H, {
1642
- loading: k.value,
1643
- disabled: T.value,
1644
- label: e(v)("common.save"),
1645
- onClick: Q
1646
- }, null, 8, ["loading", "disabled", "label"]),
1647
- d(H, {
1648
- disabled: T.value,
1649
- variant: "tertiary",
1650
- label: e(v)("common.close"),
1651
- onClick: c[2] || (c[2] = (X) => b("update:show", !1))
1652
- }, null, 8, ["disabled", "label"])
1653
- ])
1654
- ]),
1655
- _: 1
1656
- }, 8, ["modelValue"]);
1657
- };
1658
- }
1659
- }), ca = { class: "flex flex-col py-8" }, ma = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, pa = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary line-clamp-1" }, fa = { class: "fm-typo-en-body-md-400 text-fm-color-typo-primary line-clamp-1" }, va = {
1660
- key: 0,
1661
- class: "fm-typo-en-body-md-400 text-fm-color-typo-primary line-clamp-1"
1662
- }, ya = { class: "pt-8" }, at = "ReceiveRequestViewSearchCriteria", Ra = /* @__PURE__ */ pe({
1663
- __name: "ReceiveRequestView",
1664
- setup(m) {
1665
- const { t: y } = Ce(), n = Ae();
1666
- Re.object({
1667
- name: Re.string().optional().nullable(),
1668
- startDate: Re.string().optional().nullable(),
1669
- endDate: Re.string().optional().nullable()
1670
- });
1671
- const i = E(
1672
- () => !o._currentLocation || u.loading.value
1673
- ), b = Ot(), t = Ee();
1674
- function f() {
1675
- const T = {
1676
- name: "",
1677
- ...Je()
1678
- }, $ = b.getItem(at);
1679
- if (!$)
1680
- return T;
1681
- try {
1682
- return JSON.parse($);
1683
- } catch {
1684
- return T;
1685
- }
1686
- }
1687
- function _() {
1688
- b.setItem(at, JSON.stringify(w.value));
1689
- }
1690
- const w = N(f()), u = Rt(
1691
- Ue.RECEIVE_REQUEST,
1692
- w.value
1693
- ), { columnDefs: a } = Vt(
1694
- Ue.RECEIVE_REQUEST,
1695
- u
1696
- ), o = Ye();
1697
- async function v() {
1698
- const T = `inventory-record_${Xe(w.value.startDate).format("DD-MM-YYYY_HH-mm")}-${Xe(w.value.endDate).format("DD-MM-YYYY_HH-mm")}.xlsx`, $ = u.purchaseOrders.value.flatMap(
1699
- (V) => V.items.map((I) => {
1700
- const B = new Date(Ut(V._id) ?? ""), Q = V.effectiveAt ? new Date(V.effectiveAt) : void 0, K = ye(
1701
- Et(I.sku, V.deliveryOrder || [])
1702
- ), p = ye(I.quantity);
1703
- return {
1704
- "SKU code": I.code,
1705
- "SKU name": I.name,
1706
- "PO #": V.seqNumber,
1707
- "Effective at": Q,
1708
- Date: B,
1709
- Status: V.status,
1710
- Reference: V.ref ?? "",
1711
- "Received quantity": K,
1712
- "Ordered quantity": p,
1713
- Unit: I.sku.unit.abbrev,
1714
- "Total cost": I.totalCost ? Le(I.totalCost) : null
1715
- };
1716
- })
1717
- ), O = [
1718
- "SKU code",
1719
- "SKU name",
1720
- "PO #",
1721
- "Date",
1722
- "Status",
1723
- "Reference",
1724
- "Received quantity",
1725
- "Ordered quantity",
1726
- "Unit"
1727
- ];
1728
- t.enableBackdatePo && O.insert("Effective at", 4), t.enableTotalCost && O.push("Total cost"), await Mt(
1729
- [
1730
- {
1731
- name: "purchases",
1732
- data: $,
1733
- columns: O
1734
- }
1735
- ],
1736
- T
1737
- ), n.open({
1738
- title: y("inventory.transfer.receiveRequest.export.success"),
1739
- message: y("inventory.transfer.receiveRequest.export.message", [T]),
1740
- type: "success"
1741
- });
1742
- }
1743
- const k = N(Je()), C = N("");
1744
- ge([() => k.value], ([T]) => {
1745
- !T.startDate || !T.endDate || (w.value.startDate = T.startDate, w.value.endDate = T.endDate, u.updateDateRange(
1746
- w.value.startDate,
1747
- w.value.endDate
1748
- ), _());
1749
- }), ge([() => C.value], () => {
1750
- _();
1751
- });
1752
- function g(T) {
1753
- if (T === "create") {
1754
- if (i.value) {
1755
- n.open({
1756
- title: "Loading data...",
1757
- message: "Please wait.",
1758
- type: "info"
1759
- });
1760
- return;
1761
- }
1762
- return u.promptCreateTransferDialog();
1763
- }
1764
- if (T === "refresh")
1765
- return u.fetchData();
1766
- if (T === "export")
1767
- return v();
1768
- }
1769
- const { breakpoints: x } = Qe(), D = E(() => x.value.xs || x.value.sm), R = E(() => D.value ? 10 : 20), z = Tt(), ue = E(() => [
1770
- {
1771
- label: y("inventory.transfer.receiveRequest.actions.create"),
1772
- value: "create",
1773
- isPrimary: !0,
1774
- prependIcon: "add"
1775
- },
1776
- {
1777
- label: y("common.refresh"),
1778
- value: "refresh"
1779
- },
1780
- {
1781
- label: y("common.export"),
1782
- value: "export"
1783
- }
1784
- ]);
1785
- return (T, $) => {
1786
- const O = P("FmTable");
1787
- return S(), W(Pt, {
1788
- title: e(y)("inventory.transfer.receiveRequest.title2"),
1789
- actions: ue.value,
1790
- "onClick:action": g
1791
- }, {
1792
- default: F(() => {
1793
- var V;
1794
- return [
1795
- l("div", {
1796
- class: J([
1797
- "flex flex-col gap-8 max-h-full",
1798
- {
1799
- "p-0": D.value,
1800
- "px-24 ": !D.value
1801
- }
1802
- ])
1803
- }, [
1804
- d(It, {
1805
- "date-range-query": "",
1806
- "date-range": k.value,
1807
- "onUpdate:dateRange": $[0] || ($[0] = (I) => k.value = I),
1808
- searchable: "",
1809
- "change-location": "",
1810
- search: C.value,
1811
- "onUpdate:search": $[1] || ($[1] = (I) => C.value = I)
1812
- }, null, 8, ["date-range", "search"]),
1813
- (S(), W(O, {
1814
- style: lt(e(z).tableHeight),
1815
- "column-defs": e(a),
1816
- "row-data": e(u).purchaseOrders.value,
1817
- "search-value": C.value,
1818
- loading: i.value,
1819
- onRowClick: $[2] || ($[2] = (I) => e(u).promptShowTransferDetails(I.original)),
1820
- key: (V = e(o)._currentLocation) == null ? void 0 : V.dbName,
1821
- "page-size": R.value
1822
- }, {
1823
- "list-row": F((I) => [
1824
- d(rt, {
1825
- row: I,
1826
- onRowClick: e(u).promptShowTransferDetails
1827
- }, {
1828
- default: F((B) => {
1829
- var Q, K, p, c, H, oe, X, $e, he, Te, qe, Pe, s, r, M, Z, de, be, ae, fe;
1830
- return [
1831
- l("div", ca, [
1832
- l("div", ma, [
1833
- d(e(ie), {
1834
- render: (p = (K = (Q = B._id) == null ? void 0 : Q.column) == null ? void 0 : K.columnDef) == null ? void 0 : p.cell,
1835
- props: (H = (c = B._id) == null ? void 0 : c.getContext) == null ? void 0 : H.call(c)
1836
- }, null, 8, ["render", "props"])
1837
- ]),
1838
- l("div", pa, [
1839
- d(e(ie), {
1840
- render: ($e = (X = (oe = B.supplier_name) == null ? void 0 : oe.column) == null ? void 0 : X.columnDef) == null ? void 0 : $e.cell,
1841
- props: (Te = (he = B.supplier_name) == null ? void 0 : he.getContext) == null ? void 0 : Te.call(he)
1842
- }, null, 8, ["render", "props"])
1843
- ]),
1844
- l("div", fa, U(I.original.items.map((xe) => `${xe.name}`).join(", ")), 1),
1845
- I.original.ref ? (S(), q("div", va, [
1846
- d(e(ie), {
1847
- render: (s = (Pe = (qe = B.ref) == null ? void 0 : qe.column) == null ? void 0 : Pe.columnDef) == null ? void 0 : s.cell,
1848
- props: (M = (r = B.ref) == null ? void 0 : r.getContext) == null ? void 0 : M.call(r)
1849
- }, null, 8, ["render", "props"])
1850
- ])) : G("", !0),
1851
- l("div", ya, [
1852
- d(e(ie), {
1853
- render: (be = (de = (Z = B.status) == null ? void 0 : Z.column) == null ? void 0 : de.columnDef) == null ? void 0 : be.cell,
1854
- props: (fe = (ae = B.status) == null ? void 0 : ae.getContext) == null ? void 0 : fe.call(ae)
1855
- }, null, 8, ["render", "props"])
1856
- ])
1857
- ])
1858
- ];
1859
- }),
1860
- _: 2
1861
- }, 1032, ["row", "onRowClick"])
1862
- ]),
1863
- _: 1
1864
- }, 8, ["style", "column-defs", "row-data", "search-value", "loading", "page-size"]))
1865
- ], 2),
1866
- (S(), W(pt, { to: "body" }, [
1867
- d(da, Be(e(u).transferDialogProps.value, {
1868
- onSubmitted: e(u).fetchData
1869
- }), null, 16, ["onSubmitted"]),
1870
- d(At, Be({
1871
- scope: e(Ue).RECEIVE_REQUEST
1872
- }, e(u).transferDetailsProps.value, {
1873
- onSubmitted: e(u).fetchData
1874
- }), null, 16, ["scope", "onSubmitted"])
1875
- ]))
1876
- ];
1877
- }),
1878
- _: 1
1879
- }, 8, ["title", "actions"]);
1880
- };
1881
- }
1882
- });
1883
- export {
1884
- Ra as default
1885
- };