@feedmepos/mf-inventory-portal 0.0.22-dev.1 → 0.0.22-dev.11

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 (77) hide show
  1. package/dist/App.vue.d.ts +2 -0
  2. package/dist/{ApprovalView-CtH8I01g.js → ApprovalView-D0WHopPL.js} +19 -19
  3. package/dist/{BindingsDialog-DFrk_fyd.js → BindingsDialog-Ddv46-I4.js} +1 -1
  4. package/dist/{BindingsPicker-400gISaV.js → BindingsPicker-CbNehOQo.js} +19 -19
  5. package/dist/{BindingsTable-CnFKI6iP.js → BindingsTable-C-z5jzGu.js} +1 -1
  6. package/dist/ClosingTemplateView-Bs59bML_.js +1067 -0
  7. package/dist/{FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-B9RU_arW.js → FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-CGIfL24N.js} +13 -15
  8. package/dist/{IngredientsView-CRTAgKJz.js → IngredientsView-Bk0U9IrL.js} +5 -6
  9. package/dist/{IntegrationView-CNFTKqjk.js → IntegrationView-hEv2Fe67.js} +2 -2
  10. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-VkiVLx1K.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-ButZx6Cm.js} +1 -1
  11. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-DkZrgqyr.js → PremiumBadge.vue_vue_type_script_setup_true_lang-D1WcEO5R.js} +1 -1
  12. package/dist/{PurchaseOrderPrintPreview-CJli-_Vn.js → PurchaseOrderPrintPreview-wJLaWy-I.js} +1 -1
  13. package/dist/{ReceiveRequestView-DV_GDzJG.js → ReceiveRequestView-CT7_gSPj.js} +15 -16
  14. package/dist/{RecipeView-CTm_7oNG.js → RecipeView-smOk18iy.js} +3 -3
  15. package/dist/{StockView-DtHT2ulM.js → StockView-CE00jzyG.js} +8 -9
  16. package/dist/{SupplierView-B9A5R2Vm.js → SupplierView-D346tx42.js} +37 -37
  17. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-ixxW-kNE.js +762 -0
  18. package/dist/TransferDialog.vue_vue_type_script_setup_true_lang-Cf9TVjj7.js +1505 -0
  19. package/dist/TransferTemplateView-Cz6Hlmtm.js +1262 -0
  20. package/dist/{UnitView-BL-jtVuZ.js → UnitView-BdEvCjCv.js} +4 -4
  21. package/dist/WarehouseView-CtqTSV9B.js +1017 -0
  22. package/dist/api/closing-template.d.ts +14 -0
  23. package/dist/api/inventory.d.ts +5 -7
  24. package/dist/api/netsuite.d.ts +46 -0
  25. package/dist/api/purchase-order-template.d.ts +0 -4
  26. package/dist/{app-C-z1MfF6.js → app-BbLqKVBN.js} +15757 -15397
  27. package/dist/app.d.ts +6 -0
  28. package/dist/app.js +2 -2
  29. package/dist/components/FmMultiselectDialogProps.d.ts +1 -0
  30. package/dist/components/VirtualScroll.vue.d.ts +47 -0
  31. package/dist/{decimal-DZz-_lgE.js → decimal-BXH34eZD.js} +1 -1
  32. package/dist/{defineDeepModel-7VQajdPt.js → defineDeepModel-CN2db5nM.js} +4 -4
  33. package/dist/extensions/promises.d.ts +14 -0
  34. package/dist/{format-time-from-id-9XFszs1J.js → format-time-from-id-mDqFHPw7.js} +1 -1
  35. package/dist/helper/date2.d.ts +1 -0
  36. package/dist/helper/rules.d.ts +1 -0
  37. package/dist/{id-to-date-Bkue77uI.js → id-to-date-CRXORa4v.js} +1 -1
  38. package/dist/purchase-order-transaction-type-DHsIlV8_.js +676 -0
  39. package/dist/stores/api.d.ts +1 -0
  40. package/dist/stores/feature.d.ts +0 -1
  41. package/dist/stores/helper/core-store-proxy.d.ts +3 -0
  42. package/dist/stores/helper/generate-backend-urls.d.ts +1 -0
  43. package/dist/stores/inventory.d.ts +7 -0
  44. package/dist/stores/location.d.ts +24 -42
  45. package/dist/stores/netsuite.d.ts +56 -0
  46. package/dist/stores/route.d.ts +0 -5
  47. package/dist/stores/warehouse.d.ts +4 -7
  48. package/dist/style.css +1 -1
  49. package/dist/{supplier-C6YWXF2Y.js → supplier-DTKB6s-P.js} +1 -1
  50. package/dist/tsconfig.app.tsbuildinfo +1 -1
  51. package/dist/use-template-enabled-locations-2-BVp9gXZX.js +85 -0
  52. package/dist/views/closing-template/components/closing-template-publish/ClosingTemplatePublish.vue.d.ts +6 -0
  53. package/dist/views/closing-template/composables/use-closing-template-actions.d.ts +276 -84
  54. package/dist/views/closing-template/composables/use-closing-template-table.d.ts +341 -85
  55. package/dist/views/receive-request/components/transfer-form/TransferForm.vue.d.ts +14 -0
  56. package/dist/views/receive-request/composables/use-receive-request-form.d.ts +42 -0
  57. package/dist/views/receive-request/composables/use-receive-request-table.d.ts +42 -0
  58. package/dist/views/transfer-template/components/transfer-template-form/composables/use-template-enabled-locations-2.d.ts +13 -0
  59. package/dist/views/transfer-template/components/transfer-template-form/composables/use-template-enabled-locations.d.ts +4 -7
  60. package/dist/views/transfer-template/components/transfer-template-form/composables/use-transfer-locations.d.ts +2 -2
  61. package/dist/views/transfer-template/composables/use-transfer-template-actions.d.ts +132 -84
  62. package/dist/views/transfer-template/composables/use-transfer-template-table.d.ts +44 -1014
  63. package/dist/views/transfer-template/helpers/remove-deleted-skus.helper.d.ts +251 -0
  64. package/dist/views/warehouse/components/WarehouseForm.vue.d.ts +8 -14
  65. package/dist/{xlsx-Dl6dAHFx.js → xlsx-CZubj3Ki.js} +1 -1
  66. package/dist/{xlsx.util-C1tUhDb8.js → xlsx.util-DjhsRAqO.js} +2 -2
  67. package/package.json +7 -7
  68. package/dist/ClosingTemplateView--8m8cua_.js +0 -919
  69. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-mUNCQTNw.js +0 -740
  70. package/dist/TransferDialog.vue_vue_type_script_setup_true_lang-BwkUuXqj.js +0 -1428
  71. package/dist/TransferTemplateView-DnyenkGu.js +0 -1349
  72. package/dist/WarehouseView-BkUv1792.js +0 -1056
  73. package/dist/array-ClJzD_Lt.js +0 -30
  74. package/dist/layout/InventoryLayout.vue.d.ts +0 -2
  75. package/dist/layout/layout-routes.d.ts +0 -6
  76. package/dist/purchase-order-transaction-type-DHzMBgFs.js +0 -712
  77. package/dist/use-template-enabled-locations-CFCfbaOd.js +0 -57
@@ -0,0 +1,1262 @@
1
+ import { defineComponent as K, onMounted as me, computed as M, ref as B, watch as ce, inject as Ge, resolveComponent as R, openBlock as C, createElementBlock as N, createElementVNode as o, createVNode as p, withCtx as L, renderSlot as Me, withDirectives as De, normalizeClass as re, vModelText as Re, reactive as Ye, h as W, toDisplayString as S, unref as t, createBlock as H, isRef as Ee, createCommentVNode as X, Fragment as ue, renderList as Ae, normalizeStyle as We, Teleport as Ke, mergeProps as Ie, normalizeProps as Ze, guardReactiveProps as Je } from "vue";
2
+ import { u as Xe, _ as et, a as tt } from "./FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-CGIfL24N.js";
3
+ import { useI18n as Y } from "@feedmepos/mf-common";
4
+ import { P as U, a as ot, f as nt, b as Ve, c as st } from "./purchase-order-transaction-type-DHsIlV8_.js";
5
+ import { F as ee, R as Le } from "./row-action.enum-PMKMRrZR.js";
6
+ import { a0 as ie, t as Oe, I as lt, a1 as at, a2 as rt, a as j, D as Pe, R as de, a3 as it, a4 as ut, r as ae, a5 as dt, l as mt, A as Be, M as ct, b as Ue, u as pt, j as pe, y as qe, k as ft, a6 as se, a7 as yt, G as vt, a8 as bt } from "./app-BbLqKVBN.js";
7
+ import { components as le, useDialog as Ne, useSnackbar as _t, useProxiedModel as ze, useBreakpoints as xt } from "@feedmepos/ui-library";
8
+ import { storeToRefs as ht } from "pinia";
9
+ import { d as He } from "./defineDeepModel-CN2db5nM.js";
10
+ import { c as gt, u as kt, _ as wt } from "./TransferDialog.vue_vue_type_script_setup_true_lang-Cf9TVjj7.js";
11
+ import { useRouter as Tt } from "vue-router";
12
+ import { u as Ft } from "./supplier-DTKB6s-P.js";
13
+ import { F as z, _ as je } from "./TableActionableRow.vue_vue_type_script_setup_true_lang-DlNJ6kRg.js";
14
+ import { u as St } from "./use-template-enabled-locations-2-BVp9gXZX.js";
15
+ import { f as Ct } from "./format-time-from-id-mDqFHPw7.js";
16
+ const $t = { class: "flex flex-col" }, Mt = { class: "flex flex-col" }, Dt = { class: "flex-1" }, Rt = { class: "flex items-center" }, At = { class: "flex-1" }, It = { class: "flex-1" }, Vt = /* @__PURE__ */ K({
17
+ __name: "FmMinMaxInput",
18
+ props: {
19
+ rules: {},
20
+ label: {},
21
+ minPlaceholder: {},
22
+ maxPlaceholder: {},
23
+ modelValue: {},
24
+ precision: {},
25
+ minLength: {},
26
+ maxLength: {},
27
+ inputmode: {},
28
+ type: {},
29
+ readonly: { type: Boolean },
30
+ labelMark: {},
31
+ prependIcon: {},
32
+ appendIcon: {},
33
+ showValidBorder: { type: Boolean },
34
+ labelInfo: {},
35
+ showWordCount: { type: Boolean },
36
+ invalid: { type: Boolean },
37
+ autofocus: { type: Boolean },
38
+ formatter: { type: Function },
39
+ decimal: {},
40
+ datalist: {},
41
+ shiftDatalist: { type: Boolean },
42
+ datalistMaxHeight: {},
43
+ datalistMinHeight: {},
44
+ offsetDatalist: {},
45
+ datalistPlacement: {},
46
+ datalistZIndex: {},
47
+ datalistWidth: {},
48
+ disabled: { type: Boolean },
49
+ focused: { type: Boolean },
50
+ helperText: {},
51
+ helperState: {}
52
+ },
53
+ setup(m) {
54
+ const _ = m, c = He("modelValue"), n = lt();
55
+ me(() => {
56
+ const { min: f, max: i } = c ?? {};
57
+ if (!(!f || !i) && f.precision !== i.precision) {
58
+ const l = Math.max(f.precision, i.precision), e = ie(f, l), a = ie(i, l);
59
+ c.min = e, c.max = a;
60
+ }
61
+ });
62
+ const v = M(() => {
63
+ const { min: f, max: i } = c ?? {};
64
+ return Math.max((f == null ? void 0 : f.precision) ?? 0, (i == null ? void 0 : i.precision) ?? 0, _.precision ?? 0);
65
+ }), d = M(() => ({
66
+ ...c
67
+ })), s = (f) => {
68
+ if (!f) return "";
69
+ const i = at(f), l = v.value, e = ie(i, l);
70
+ return rt(
71
+ +j(e),
72
+ e.precision
73
+ );
74
+ }, r = B(s(c.min)), x = B(s(c.max));
75
+ ce([r, x], ([f, i]) => {
76
+ const l = c ?? {}, e = n(f), a = n(i), u = v.value;
77
+ if (f !== "" && e === !0) {
78
+ const y = Oe(+f, u);
79
+ l.min = y;
80
+ } else
81
+ l.min = null;
82
+ if (i !== "" && a === !0) {
83
+ const y = Oe(+i, u);
84
+ l.max = y;
85
+ } else
86
+ l.max = null;
87
+ c.min = l.min, c.max = l.max;
88
+ });
89
+ const b = Symbol.for("fm:form-state"), h = Ge(b, null), k = M(() => _.disabled ?? (h == null ? void 0 : h.getDisabled()) ?? !1), g = B(), $ = B(), F = B(!1), O = B(!1), E = M(() => F.value || O.value), P = M(() => [...[
90
+ function() {
91
+ return typeof n(r.value) == "string" || typeof n(x.value) == "string" ? "Must be a number" : !0;
92
+ },
93
+ function(l) {
94
+ return !l || !l.min || !l.max ? !0 : +j(l.min) > +j(l.max) ? "Min must be less than or equal to max" : !0;
95
+ }
96
+ ], ..._.rules ?? []]);
97
+ return (f, i) => {
98
+ const l = R("FmLabel"), e = R("FmField"), a = R("FmFormGroup");
99
+ return C(), N("div", $t, [
100
+ o("div", Mt, [
101
+ o("div", Dt, [
102
+ p(l, {
103
+ label: f.label,
104
+ disabled: f.disabled,
105
+ required: f.labelMark === "required",
106
+ optional: f.labelMark === "optional"
107
+ }, null, 8, ["label", "disabled", "required", "optional"])
108
+ ]),
109
+ p(e, { focused: E.value }, {
110
+ default: L(() => [
111
+ o("div", Rt, [
112
+ Me(f.$slots, "prepend"),
113
+ i[6] || (i[6] = o("div", { class: "text-fm-color-typo-secondary fm-typo-en-body-lg-400 pr-4" }, "Min.", -1)),
114
+ o("div", At, [
115
+ De(o("input", {
116
+ type: "text",
117
+ ref_key: "minInputRef",
118
+ ref: g,
119
+ onFocus: i[0] || (i[0] = () => F.value = !0),
120
+ onBlur: i[1] || (i[1] = () => F.value = !1),
121
+ "onUpdate:modelValue": i[2] || (i[2] = (u) => r.value = u),
122
+ class: re({
123
+ "fm-text-field--input fm-typo-en-body-lg-400": !0,
124
+ "text-fm-color-typo-primary": !k.value,
125
+ "text-fm-color-typo-disabled": k.value
126
+ })
127
+ }, null, 34), [
128
+ [Re, r.value]
129
+ ])
130
+ ]),
131
+ i[7] || (i[7] = o("div", { class: "block h-32 mx-4 w-[1px] bg-fm-color-neutral-gray-200" }, null, -1)),
132
+ i[8] || (i[8] = o("div", { class: "text-fm-color-typo-secondary fm-typo-en-body-lg-400 pr-4" }, "Max.", -1)),
133
+ o("div", It, [
134
+ De(o("input", {
135
+ type: "text",
136
+ ref_key: "maxInputRef",
137
+ ref: $,
138
+ onFocus: i[3] || (i[3] = () => O.value = !0),
139
+ onBlur: i[4] || (i[4] = () => O.value = !1),
140
+ "onUpdate:modelValue": i[5] || (i[5] = (u) => x.value = u),
141
+ class: re({
142
+ "fm-text-field--input fm-typo-en-body-lg-400": !0,
143
+ "text-fm-color-typo-primary": !k.value,
144
+ "text-fm-color-typo-disabled": k.value
145
+ })
146
+ }, null, 34), [
147
+ [Re, x.value]
148
+ ])
149
+ ]),
150
+ Me(f.$slots, "append")
151
+ ])
152
+ ]),
153
+ _: 3
154
+ }, 8, ["focused"])
155
+ ]),
156
+ p(a, {
157
+ class: "flex-1",
158
+ "model-value": d.value,
159
+ info: f.labelInfo,
160
+ rules: P.value,
161
+ "helper-text": f.helperText,
162
+ "helper-state": f.helperState
163
+ }, null, 8, ["model-value", "info", "rules", "helper-text", "helper-state"])
164
+ ]);
165
+ };
166
+ }
167
+ });
168
+ function Lt() {
169
+ return function(_) {
170
+ return !_ || !_.min || !_.max ? "Required" : !0;
171
+ };
172
+ }
173
+ function Ot(m, _) {
174
+ return function(n) {
175
+ return !n || !n.min || !n.max ? !0 : +j(n.min) < m ? `Must be between ${m} and ${_}` : +j(n.max) > _ ? `Must be between ${m} and ${_}` : !0;
176
+ };
177
+ }
178
+ var V = /* @__PURE__ */ ((m) => (m.Code = "Code", m.Name = "Name", m.DefaultAmount = "DefaultAmount", m.Limit = "Limit", m.MinimumAmount = "MinimumAmount", m.Step = "Step", m.Cost = "Cost", m.Delete = "Delete", m))(V || {});
179
+ function Pt(m) {
180
+ const { t: _ } = Y(), c = Ye({});
181
+ me(() => {
182
+ for (const d of m.items) {
183
+ if (!d.totalCost)
184
+ continue;
185
+ const s = gt(d.sku, d.quantity, d.measurement, {
186
+ supplier: m.supplier
187
+ }), r = d.totalCost ?? Pe.reset();
188
+ s ? c[d.sku._id] = s.amount !== r.amount || s.precision !== r.precision : c[d.sku._id] = !0;
189
+ }
190
+ });
191
+ const n = [
192
+ {
193
+ id: "Code",
194
+ header: () => _("inventory.transfer.form.items.table.Code"),
195
+ accessorKey: "code",
196
+ size: 96,
197
+ cell(d) {
198
+ const s = d.row.original;
199
+ return W(le.FmTextField, {
200
+ modelValue: s.code,
201
+ "onUpdate:modelValue": (r) => {
202
+ m.updateItem({
203
+ ...s,
204
+ code: r
205
+ });
206
+ },
207
+ key: s.sku._id,
208
+ rules: [de()],
209
+ labelMark: "required"
210
+ });
211
+ },
212
+ enableSorting: !1
213
+ },
214
+ {
215
+ id: "Name",
216
+ header: () => _("inventory.transfer.form.items.table.Name"),
217
+ minSize: 300,
218
+ cell(d) {
219
+ const s = d.row.original;
220
+ return W(le.FmTextField, {
221
+ modelValue: s.name,
222
+ "onUpdate:modelValue": (r) => {
223
+ m.updateItem({
224
+ ...s,
225
+ name: r
226
+ });
227
+ },
228
+ key: s.sku._id,
229
+ rules: [de()],
230
+ labelMark: "required"
231
+ });
232
+ },
233
+ enableSorting: !1
234
+ },
235
+ {
236
+ id: "DefaultAmount",
237
+ header: () => _("inventory.transfer.form.items.table.DefaultAmount2"),
238
+ minSize: 200,
239
+ cell(d) {
240
+ const s = d.row.original;
241
+ return W(it, {
242
+ style: {
243
+ flex: "1 1 0%"
244
+ },
245
+ modelValue: {
246
+ amount: s.quantity ?? { amount: 1, precision: 0 },
247
+ measurement: s.measurement ?? null
248
+ },
249
+ disabled: m.disabled,
250
+ key: s.sku._id,
251
+ unit: s.sku.unit,
252
+ "onUpdate:modelValue": (r) => {
253
+ m.updateItem({
254
+ ...s,
255
+ quantity: r.amount,
256
+ measurement: r.measurement
257
+ });
258
+ },
259
+ rules: [
260
+ ut(
261
+ +j(
262
+ s.minimumQuantity ?? {
263
+ amount: 1,
264
+ precision: ae(s.sku.unit, s.measurement)
265
+ }
266
+ )
267
+ ),
268
+ dt(
269
+ s.maximumQuantity ? +j(s.maximumQuantity) : 1 / 0
270
+ )
271
+ ],
272
+ applyDefaultRules: !0
273
+ });
274
+ },
275
+ enableSorting: !1
276
+ },
277
+ {
278
+ id: "Limit",
279
+ header: () => "Limit",
280
+ // TODO: i18n,
281
+ minSize: 280,
282
+ cell(d) {
283
+ const s = d.row.original;
284
+ return W(Vt, {
285
+ style: {
286
+ flex: "1 1 0%"
287
+ },
288
+ modelValue: {
289
+ min: s.minimumQuantity,
290
+ max: s.maximumQuantity
291
+ },
292
+ disabled: m.disabled,
293
+ key: s.sku._id,
294
+ unit: s.sku.unit,
295
+ "onUpdate:modelValue": (r) => {
296
+ const x = { ...s };
297
+ r != null && r.min && (x.minimumQuantity = r.min), r != null && r.max && (x.maximumQuantity = r.max), m.updateItem(x);
298
+ },
299
+ rules: [
300
+ Lt(),
301
+ Ot(
302
+ +j({
303
+ amount: 1,
304
+ precision: ae(s.sku.unit, s.measurement)
305
+ }),
306
+ 1 / 0
307
+ )
308
+ ],
309
+ disableUnit: !0,
310
+ applyDefaultRules: !0
311
+ });
312
+ }
313
+ },
314
+ {
315
+ id: "Step",
316
+ header: () => _("inventory.transfer.form.items.table.Step"),
317
+ minSize: 100,
318
+ cell(d) {
319
+ const s = d.row.original;
320
+ return W(le.FmTextField, {
321
+ modelValue: j(s.quantityStep ?? Pe.reset(), !1),
322
+ key: s.sku._id,
323
+ "onUpdate:modelValue": (r) => {
324
+ m.updateItem({
325
+ ...s,
326
+ quantityStep: mt(+r)
327
+ });
328
+ },
329
+ rules: [
330
+ Be({
331
+ amount: 1,
332
+ precision: ae(s.sku.unit, s.measurement)
333
+ }),
334
+ ct(s.sku.unit, s.measurement)
335
+ ]
336
+ });
337
+ },
338
+ enableSorting: !1
339
+ },
340
+ {
341
+ id: "Delete",
342
+ header: "",
343
+ cell(d) {
344
+ const s = d.row.original;
345
+ return W(le.FmButton, {
346
+ class: "delete-button",
347
+ key: s.sku._id,
348
+ type: "button",
349
+ icon: "delete",
350
+ variant: "tertiary",
351
+ size: "md",
352
+ disabled: m.disabled,
353
+ onClick: () => {
354
+ m.deleteItem(s);
355
+ }
356
+ });
357
+ },
358
+ enableSorting: !1,
359
+ size: 40,
360
+ meta: {
361
+ cellClass: "",
362
+ headerClass: ""
363
+ }
364
+ }
365
+ ];
366
+ return {
367
+ columnDefs: M(() => Ue().enableTotalCost && m.transferType === U.PURCHASE ? n : n.filter((s) => s.id !== "Cost"))
368
+ };
369
+ }
370
+ const Et = { class: "flex flex-col gap-8 py-16" }, Bt = { class: "flex items-center" }, Ut = { class: "flex-1 flex gap-1 items-center" }, qt = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, Nt = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, zt = { class: "flex gap-8 w-full" }, Ht = { class: "flex-1 flex flex-col gap-4" }, jt = { class: "flex-1 flex flex-col gap-4" }, Qt = { class: "flex gap-8 w-full" }, Gt = { class: "flex-1 flex flex-col gap-4" }, Yt = { class: "flex-1 flex flex-col gap-4" }, Wt = { class: "flex gap-8 w-full" }, Kt = { class: "flex-1 flex flex-col gap-4" }, Zt = /* @__PURE__ */ K({
371
+ __name: "TransferTemplateItem",
372
+ props: {
373
+ cellByColId: {},
374
+ row: {}
375
+ },
376
+ setup(m) {
377
+ const { t: _ } = Y();
378
+ return (c, n) => {
379
+ var d, s, r, x, b, h, k, g, $, F, O, E, P, f, i, l, e, a, u, y, T, D, I, A, w, q, Z, J, Q, G;
380
+ const v = R("FmLabel");
381
+ return C(), N("div", Et, [
382
+ o("div", Bt, [
383
+ o("div", Ut, [
384
+ o("span", qt, " (" + S(c.row.original.sku.code) + ") ", 1),
385
+ o("span", Nt, S(c.row.original.sku.name), 1)
386
+ ]),
387
+ o("div", null, [
388
+ p(t(z), {
389
+ render: (r = (s = (d = c.cellByColId.Delete) == null ? void 0 : d.column) == null ? void 0 : s.columnDef) == null ? void 0 : r.cell,
390
+ props: (b = (x = c.cellByColId.Delete) == null ? void 0 : x.getContext) == null ? void 0 : b.call(x)
391
+ }, null, 8, ["render", "props"])
392
+ ])
393
+ ]),
394
+ o("div", zt, [
395
+ o("div", Ht, [
396
+ p(v, {
397
+ label: t(_)(`inventory.transfer.form.items.table.${t(V).Code}`)
398
+ }, null, 8, ["label"]),
399
+ p(t(z), {
400
+ render: (g = (k = (h = c.cellByColId[t(V).Code]) == null ? void 0 : h.column) == null ? void 0 : k.columnDef) == null ? void 0 : g.cell,
401
+ props: (F = ($ = c.cellByColId[t(V).Code]) == null ? void 0 : $.getContext) == null ? void 0 : F.call($)
402
+ }, null, 8, ["render", "props"]),
403
+ n[0] || (n[0] = o("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
404
+ ]),
405
+ o("div", jt, [
406
+ p(v, {
407
+ label: t(_)(`inventory.transfer.form.items.table.${t(V).Name}`)
408
+ }, null, 8, ["label"]),
409
+ p(t(z), {
410
+ render: (P = (E = (O = c.cellByColId[t(V).Name]) == null ? void 0 : O.column) == null ? void 0 : E.columnDef) == null ? void 0 : P.cell,
411
+ props: (i = (f = c.cellByColId[t(V).Name]) == null ? void 0 : f.getContext) == null ? void 0 : i.call(f)
412
+ }, null, 8, ["render", "props"]),
413
+ n[1] || (n[1] = o("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
414
+ ])
415
+ ]),
416
+ o("div", Qt, [
417
+ o("div", Gt, [
418
+ p(v, {
419
+ label: t(_)(`inventory.transfer.form.items.table.${t(V).DefaultAmount}`)
420
+ }, null, 8, ["label"]),
421
+ p(t(z), {
422
+ render: (a = (e = (l = c.cellByColId[t(V).DefaultAmount]) == null ? void 0 : l.column) == null ? void 0 : e.columnDef) == null ? void 0 : a.cell,
423
+ props: (y = (u = c.cellByColId[t(V).DefaultAmount]) == null ? void 0 : u.getContext) == null ? void 0 : y.call(u)
424
+ }, null, 8, ["render", "props"]),
425
+ n[2] || (n[2] = o("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
426
+ ]),
427
+ o("div", Yt, [
428
+ p(v, {
429
+ label: t(_)(`inventory.transfer.form.items.table.${t(V).Step}`)
430
+ }, null, 8, ["label"]),
431
+ p(t(z), {
432
+ render: (I = (D = (T = c.cellByColId[t(V).Step]) == null ? void 0 : T.column) == null ? void 0 : D.columnDef) == null ? void 0 : I.cell,
433
+ props: (w = (A = c.cellByColId[t(V).Step]) == null ? void 0 : A.getContext) == null ? void 0 : w.call(A)
434
+ }, null, 8, ["render", "props"]),
435
+ n[3] || (n[3] = o("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
436
+ ])
437
+ ]),
438
+ o("div", Wt, [
439
+ o("div", Kt, [
440
+ p(v, {
441
+ label: t(_)(`inventory.transfer.form.items.table.${t(V).Limit}`)
442
+ }, null, 8, ["label"]),
443
+ p(t(z), {
444
+ render: (J = (Z = (q = c.cellByColId[t(V).Limit]) == null ? void 0 : q.column) == null ? void 0 : Z.columnDef) == null ? void 0 : J.cell,
445
+ props: (G = (Q = c.cellByColId[t(V).Limit]) == null ? void 0 : Q.getContext) == null ? void 0 : G.call(Q)
446
+ }, null, 8, ["render", "props"]),
447
+ n[4] || (n[4] = o("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
448
+ ])
449
+ ])
450
+ ]);
451
+ };
452
+ }
453
+ }), Jt = { class: "flex flex-col gap-16" }, Xt = { class: "flex flex-col gap-24" }, eo = { class: "flex flex-col gap-16" }, to = { class: "flex items-center" }, oo = { class: "flex flex-col gap-16" }, no = { class: "flex" }, so = { class: "flex-1 gap-8 fm-typo-en-title-sm-600" }, lo = /* @__PURE__ */ K({
454
+ __name: "TransferTemplateForm",
455
+ props: {
456
+ modelValue: {},
457
+ disabled: { type: Boolean }
458
+ },
459
+ setup(m, { expose: _ }) {
460
+ const c = m, n = He(), { t: v } = Y(), d = pe(), s = pt(), r = Ft();
461
+ ce(
462
+ () => c.modelValue,
463
+ (e) => {
464
+ console.log("TransferTemplateForm.model", e);
465
+ }
466
+ ), d.watchLocation(async () => {
467
+ location && (n.purchaseOrder.supplier || (n.purchaseOrder.supplier = r.suppliers.find((e) => e) ?? n.purchaseOrder.supplier));
468
+ });
469
+ const x = Ne(), b = kt(
470
+ () => n.purchaseOrder,
471
+ (e) => {
472
+ n.purchaseOrder = {
473
+ ...n.purchaseOrder,
474
+ supplier: e.supplier
475
+ };
476
+ }
477
+ ), h = M({
478
+ get() {
479
+ var e, a;
480
+ return typeof ((a = (e = n.purchaseOrder) == null ? void 0 : e.supplier) == null ? void 0 : a.internal) == "string" ? U.TRANSFER : U.PURCHASE;
481
+ },
482
+ set(e) {
483
+ var u, y;
484
+ const a = typeof ((y = (u = n.purchaseOrder) == null ? void 0 : u.supplier) == null ? void 0 : y.internal) == "string" ? U.TRANSFER : U.PURCHASE;
485
+ e !== a && (n.purchaseOrder.supplier = e === U.PURCHASE ? b.locationOptionsTypePurchase.value[0] : b.locationOptionsTypeTransfer.value[0]);
486
+ }
487
+ }), k = M(() => b.transferLocationOptions.value), g = M({
488
+ get() {
489
+ var e;
490
+ return (e = n.purchaseOrder.supplier) == null ? void 0 : e._id;
491
+ },
492
+ set(e) {
493
+ b.transferLocationModel.value = e;
494
+ }
495
+ }), {
496
+ promptSelectLocations: $,
497
+ columnDefs: F,
498
+ rowData: O
499
+ } = St({
500
+ getLocations() {
501
+ return n.locations;
502
+ },
503
+ setLocations(e) {
504
+ n.locations = e;
505
+ }
506
+ }), E = M({
507
+ get() {
508
+ return n.purchaseOrder.remark ?? void 0;
509
+ },
510
+ set(e) {
511
+ n.purchaseOrder.remark = e;
512
+ }
513
+ }), P = B();
514
+ _({
515
+ validateInputs: () => {
516
+ var e, a;
517
+ (a = (e = P.value) == null ? void 0 : e.validateInputs) == null || a.call(e);
518
+ },
519
+ resetInputsValidation: () => {
520
+ var e, a;
521
+ (a = (e = P.value) == null ? void 0 : e.resetInputsValidation) == null || a.call(e);
522
+ },
523
+ resetInputs: () => {
524
+ var e, a;
525
+ (a = (e = P.value) == null ? void 0 : e.resetInputs) == null || a.call(e);
526
+ }
527
+ });
528
+ const f = Pt({
529
+ updateItem: (e) => {
530
+ n.purchaseOrder.items = n.purchaseOrder.items.map((a) => a.sku._id !== e.sku._id ? a : e);
531
+ },
532
+ deleteItem: (e) => {
533
+ n.purchaseOrder.items = n.purchaseOrder.items.filter(
534
+ (a) => a.sku._id !== e.sku._id
535
+ );
536
+ },
537
+ get supplier() {
538
+ return n.purchaseOrder.supplier;
539
+ },
540
+ get items() {
541
+ return n.purchaseOrder.items;
542
+ },
543
+ get transferType() {
544
+ return U.PURCHASE;
545
+ },
546
+ get disabled() {
547
+ return c.disabled;
548
+ }
549
+ }), i = M(() => f.columnDefs.value);
550
+ function l() {
551
+ const e = s.skus.map((u) => ({
552
+ label: u.name,
553
+ sublabel: u.code,
554
+ value: u
555
+ })), a = e.filter((u) => {
556
+ var y;
557
+ return (y = n.purchaseOrder.items) == null ? void 0 : y.find((T) => T.sku._id === u.value._id);
558
+ }).map((u) => u.value);
559
+ x.open({
560
+ title: v("inventory.transfer.form.items.selectItem"),
561
+ closeButton: !0,
562
+ contentComponent: qe,
563
+ contentComponentProps: {
564
+ modelValue: a,
565
+ items: e,
566
+ virtualScroll: !0
567
+ },
568
+ primaryActions: {
569
+ text: v("common.confirm"),
570
+ close: !0
571
+ },
572
+ secondaryActions: {
573
+ text: v("common.close"),
574
+ close: !0,
575
+ variant: "tertiary"
576
+ }
577
+ }).onPrimary((u) => {
578
+ const y = n.purchaseOrder.items ?? [], T = u.map((D) => {
579
+ const I = y.find((q) => q.sku._id === D._id);
580
+ if (I)
581
+ return I;
582
+ const A = { amount: 1, precision: ae(D.unit) };
583
+ return {
584
+ sku: D,
585
+ code: D.code,
586
+ name: D.name,
587
+ quantity: A,
588
+ minimumQuantity: A,
589
+ maximumQuantity: ft(A, {
590
+ amount: 100,
591
+ precision: 0
592
+ }),
593
+ quantityStep: A
594
+ };
595
+ });
596
+ T.sort((D, I) => D.sku.code.localeCompare(I.sku.code)), n.purchaseOrder.items = T;
597
+ });
598
+ }
599
+ return (e, a) => {
600
+ const u = R("FmTextField"), y = R("FmSelect"), T = R("FmTextarea"), D = R("FmButton"), I = R("FmTable"), A = R("FmForm");
601
+ return C(), H(A, {
602
+ ref_key: "formRef",
603
+ ref: P,
604
+ class: "flex flex-col gap-32",
605
+ disabled: e.disabled
606
+ }, {
607
+ default: L(() => [
608
+ o("div", Jt, [
609
+ o("div", Xt, [
610
+ p(u, {
611
+ label: t(v)("inventory.transfer.form.name"),
612
+ "label-mark": "required",
613
+ modelValue: t(n).name,
614
+ "onUpdate:modelValue": a[0] || (a[0] = (w) => t(n).name = w),
615
+ rules: [t(de)()]
616
+ }, null, 8, ["label", "modelValue", "rules"]),
617
+ p(y, {
618
+ label: t(v)("inventory.transfer.form.type.title"),
619
+ "model-value": h.value,
620
+ "onUpdate:modelValue": a[1] || (a[1] = (w) => h.value = w),
621
+ items: [
622
+ {
623
+ label: t(v)("inventory.transfer.form.type.purchase"),
624
+ value: t(U).PURCHASE,
625
+ disabled: !t(b).locationOptionsTypePurchase.value.length,
626
+ sublabel: t(b).locationOptionsTypePurchase.value.length ? void 0 : t(v)("inventory.transfer.form.noSupplierAvailable")
627
+ },
628
+ {
629
+ label: t(v)("inventory.transfer.form.type.transfer"),
630
+ value: t(U).TRANSFER,
631
+ disabled: !t(b).locationOptionsTypeTransfer.value.length,
632
+ sublabel: t(b).locationOptionsTypeTransfer.value.length ? void 0 : t(v)("inventory.transfer.form.noLocationAvailable")
633
+ }
634
+ ],
635
+ rules: [t(Be)(1)(k.value)]
636
+ }, null, 8, ["label", "model-value", "items", "rules"]),
637
+ p(y, {
638
+ label: h.value === t(U).PURCHASE ? t(v)("inventory.transfer.form.purchaseFrom") : t(v)("inventory.transfer.form.transferFrom"),
639
+ modelValue: g.value,
640
+ "onUpdate:modelValue": a[2] || (a[2] = (w) => g.value = w),
641
+ items: k.value
642
+ }, null, 8, ["label", "modelValue", "items"]),
643
+ p(u, {
644
+ label: t(v)("inventory.transfer.form.reference"),
645
+ "label-mark": "optional",
646
+ modelValue: t(n).purchaseOrder.ref,
647
+ "onUpdate:modelValue": a[3] || (a[3] = (w) => t(n).purchaseOrder.ref = w)
648
+ }, null, 8, ["label", "modelValue"]),
649
+ p(T, {
650
+ label: t(v)("inventory.transfer.form.remark"),
651
+ "label-mark": "optional",
652
+ "max-length": 240,
653
+ modelValue: E.value,
654
+ "onUpdate:modelValue": a[4] || (a[4] = (w) => E.value = w),
655
+ class: re({ "text-fm-color-typo-disabled": e.disabled })
656
+ }, null, 8, ["label", "modelValue", "class"])
657
+ ])
658
+ ]),
659
+ o("div", eo, [
660
+ o("div", to, [
661
+ a[6] || (a[6] = o("div", { class: "flex-1 fm-typo-en-title-sm-600" }, "Locations", -1)),
662
+ p(D, {
663
+ disabled: e.disabled,
664
+ label: "Select location",
665
+ "prepend-icon": "add",
666
+ variant: "plain",
667
+ class: "border-2 rounded-lg border-fm-color-primary",
668
+ onClick: t($)
669
+ }, null, 8, ["disabled", "onClick"])
670
+ ]),
671
+ p(I, {
672
+ "column-defs": t(F),
673
+ "row-data": t(O),
674
+ "shrink-at": 9999,
675
+ onRowClick: t($),
676
+ "hide-footer": ""
677
+ }, null, 8, ["column-defs", "row-data", "onRowClick"])
678
+ ]),
679
+ o("div", oo, [
680
+ o("div", no, [
681
+ o("div", so, S(t(v)("inventory.transfer.form.items.title")), 1),
682
+ p(D, {
683
+ disabled: e.disabled,
684
+ label: t(v)("inventory.transfer.form.items.addItem"),
685
+ "prepend-icon": "add",
686
+ variant: "plain",
687
+ class: "border-2 rounded-lg border-fm-color-primary",
688
+ onClick: a[5] || (a[5] = (w) => l()),
689
+ size: "md"
690
+ }, null, 8, ["disabled", "label"])
691
+ ]),
692
+ (C(), H(I, {
693
+ "column-defs": i.value,
694
+ "row-data": t(n).purchaseOrder.items,
695
+ key: t(n).purchaseOrder.items.map((w) => w.sku._id).join("."),
696
+ "hide-footer": ""
697
+ }, {
698
+ "list-row": L((w) => [
699
+ (C(), H(je, {
700
+ row: w,
701
+ key: t(n).purchaseOrder.items.map((q) => q.sku._id).join(".")
702
+ }, {
703
+ default: L((q) => [
704
+ p(Zt, {
705
+ row: w,
706
+ "cell-by-col-id": q
707
+ }, null, 8, ["row", "cell-by-col-id"])
708
+ ]),
709
+ _: 2
710
+ }, 1032, ["row"]))
711
+ ]),
712
+ _: 1
713
+ }, 8, ["column-defs", "row-data"]))
714
+ ])
715
+ ]),
716
+ _: 1
717
+ }, 8, ["disabled"]);
718
+ };
719
+ }
720
+ }), ao = { class: "flex items-center" }, ro = { class: "fm-typo-en-title-md-800" }, io = { class: "flex gap-4" }, uo = /* @__PURE__ */ K({
721
+ __name: "TransferTemplateDialog",
722
+ props: {
723
+ mode: {},
724
+ modelValue: {},
725
+ show: { type: Boolean }
726
+ },
727
+ emits: ["update:show", "submitted"],
728
+ setup(m, { expose: _, emit: c }) {
729
+ var i;
730
+ const n = m, v = c, d = ot(), s = _t(), { t: r } = Y(), x = ze(n, "show");
731
+ function b() {
732
+ return {
733
+ _id: "",
734
+ name: "",
735
+ purchaseOrder: {
736
+ remark: void 0,
737
+ ref: void 0,
738
+ stockSnapshotId: void 0,
739
+ effectiveAt: void 0,
740
+ items: [],
741
+ supplier: {
742
+ _rev: void 0,
743
+ email: void 0,
744
+ internal: void 0,
745
+ contactName: void 0,
746
+ phoneNumber: void 0,
747
+ registrationNumber: void 0,
748
+ supplyItems: void 0,
749
+ _id: "",
750
+ name: "",
751
+ address: {
752
+ line2: void 0,
753
+ line1: "",
754
+ state: "",
755
+ city: "",
756
+ postcode: "",
757
+ country: ""
758
+ }
759
+ }
760
+ }
761
+ };
762
+ }
763
+ const h = B(n.modelValue ?? b()), k = B(((i = n.modelValue) == null ? void 0 : i._id) ?? `${Math.random()}`);
764
+ ce(
765
+ () => n.show,
766
+ (l) => {
767
+ var e;
768
+ l && (h.value = n.modelValue ?? b(), k.value = ((e = n.modelValue) == null ? void 0 : e._id) ?? `${Math.random()}`);
769
+ }
770
+ );
771
+ const g = B(!1), $ = M(() => {
772
+ switch (n.mode) {
773
+ case ee.READ:
774
+ return "";
775
+ case ee.CREATE:
776
+ return r("inventory.transfer.template.create.title");
777
+ case ee.UPDATE:
778
+ return r("inventory.transfer.template.update.title");
779
+ }
780
+ return "";
781
+ }), F = B();
782
+ _({
783
+ validateInputs: () => {
784
+ var l, e;
785
+ (e = (l = F.value) == null ? void 0 : l.validateInputs) == null || e.call(l);
786
+ },
787
+ resetInputsValidation: () => {
788
+ var l, e;
789
+ (e = (l = F.value) == null ? void 0 : l.resetInputsValidation) == null || e.call(l);
790
+ },
791
+ resetInputs: () => {
792
+ var l, e;
793
+ (e = (l = F.value) == null ? void 0 : l.resetInputs) == null || e.call(l);
794
+ }
795
+ });
796
+ async function O() {
797
+ var e, a;
798
+ const l = h.value;
799
+ if (l) {
800
+ g.value = !0, (((e = l.purchaseOrder.supplier) == null ? void 0 : e.internal) === se.enum.warehouse || ((a = l.purchaseOrder.supplier) == null ? void 0 : a.internal) === se.enum.restaurant) && (l.purchaseOrder.items = l.purchaseOrder.items.map(
801
+ ({ totalCost: u, ...y }) => y
802
+ ));
803
+ try {
804
+ await d.createTemplate(l), await new Promise((u) => setTimeout(u, 1e3)), s.open({
805
+ title: r("inventory.transfer.template.create.success"),
806
+ message: r("inventory.transfer.template.create.successMessage"),
807
+ type: "success"
808
+ }), v("update:show", !1), v("submitted");
809
+ } catch (u) {
810
+ s.open({
811
+ title: r("inventory.transfer.template.create.error"),
812
+ message: r("inventory.transfer.template.create.errorMessage"),
813
+ type: "error"
814
+ }), console.error("Error in creating transfer template", u);
815
+ } finally {
816
+ g.value = !1;
817
+ }
818
+ }
819
+ }
820
+ async function E() {
821
+ var e, a;
822
+ const l = h.value;
823
+ if (l) {
824
+ g.value = !0, (((e = l.purchaseOrder.supplier) == null ? void 0 : e.internal) === se.enum.warehouse || ((a = l.purchaseOrder.supplier) == null ? void 0 : a.internal) === se.enum.restaurant) && (l.purchaseOrder.items = l.purchaseOrder.items.map(
825
+ ({ totalCost: u, ...y }) => y
826
+ ));
827
+ try {
828
+ await d.updateTemplate(l), await new Promise((u) => setTimeout(u, 1e3)), s.open({
829
+ title: r("inventory.transfer.template.update.success"),
830
+ message: r("inventory.transfer.template.update.successMessage"),
831
+ type: "success"
832
+ }), v("update:show", !1), v("submitted");
833
+ } catch (u) {
834
+ s.open({
835
+ title: r("inventory.transfer.template.update.error"),
836
+ message: r("inventory.transfer.template.update.errorMessage"),
837
+ type: "error"
838
+ }), console.error("Error in updating transfer template", u);
839
+ } finally {
840
+ g.value = !1;
841
+ }
842
+ }
843
+ }
844
+ function P() {
845
+ switch (n.mode) {
846
+ case ee.CREATE:
847
+ return O();
848
+ case ee.UPDATE:
849
+ return E();
850
+ }
851
+ }
852
+ function f() {
853
+ var l, e;
854
+ (e = (l = F.value) == null ? void 0 : l.validateInputs) == null || e.call(l);
855
+ }
856
+ return (l, e) => {
857
+ const a = R("FmButton"), u = R("FmSideSheet");
858
+ return C(), H(u, {
859
+ modelValue: t(x),
860
+ "onUpdate:modelValue": e[2] || (e[2] = (y) => Ee(x) ? x.value = y : null),
861
+ "dismiss-away": "",
862
+ "close-button": "",
863
+ "max-width": 1200
864
+ }, {
865
+ "side-sheet-header": L(() => [
866
+ o("div", ao, [
867
+ o("div", ro, S($.value), 1)
868
+ ])
869
+ ]),
870
+ default: L(() => [
871
+ (C(), H(lo, {
872
+ class: "w-full",
873
+ ref_key: "formRef",
874
+ ref: F,
875
+ onValidationSuccess: P,
876
+ "model-value": h.value,
877
+ "onUpdate:modelValue": e[0] || (e[0] = (y) => h.value = y),
878
+ disabled: g.value,
879
+ key: k.value
880
+ }, null, 8, ["model-value", "disabled"]))
881
+ ]),
882
+ "side-sheet-footer": L(() => [
883
+ o("div", io, [
884
+ p(a, {
885
+ loading: g.value,
886
+ label: t(r)("common.save"),
887
+ onClick: f
888
+ }, null, 8, ["loading", "label"]),
889
+ p(a, {
890
+ disabled: g.value,
891
+ variant: "tertiary",
892
+ label: t(r)("common.close"),
893
+ onClick: e[1] || (e[1] = (y) => v("update:show", !1))
894
+ }, null, 8, ["disabled", "label"])
895
+ ])
896
+ ]),
897
+ _: 1
898
+ }, 8, ["modelValue"]);
899
+ };
900
+ }
901
+ });
902
+ function mo(m) {
903
+ const _ = Ne(), c = pe(), { t: n } = Y(), v = M({
904
+ get() {
905
+ return Array.isArray(m.getLocations());
906
+ },
907
+ set(x) {
908
+ x ? m.setLocations([]) : m.setLocations(null);
909
+ }
910
+ });
911
+ function d() {
912
+ var x;
913
+ _.open({
914
+ title: "Select at least one location",
915
+ contentComponent: qe,
916
+ contentComponentProps: {
917
+ modelValue: ((x = s.value) == null ? void 0 : x.map((b) => b.doc._id)) ?? [],
918
+ items: c.locations.map((b) => ({
919
+ label: b.name,
920
+ sublabel: b.type,
921
+ value: b.doc._id
922
+ }))
923
+ },
924
+ primaryActions: {
925
+ text: n("common.confirm"),
926
+ close: !0
927
+ },
928
+ secondaryActions: {
929
+ text: n("common.close"),
930
+ close: !0
931
+ }
932
+ }).onPrimary((b) => {
933
+ m.setLocations(c.locations.filter((h) => b.includes(h.doc._id)));
934
+ });
935
+ }
936
+ const s = M(() => {
937
+ var b;
938
+ const x = /* @__PURE__ */ new Set([...c.locations.map((h) => h.doc._id)]);
939
+ return (b = m.getLocations()) == null ? void 0 : b.filter((h) => x.has(h.doc._id));
940
+ });
941
+ function r(x) {
942
+ var b;
943
+ m.setLocations((b = m.getLocations()) == null ? void 0 : b.filter((h) => h.doc._id !== x));
944
+ }
945
+ return {
946
+ enabledLocations: s,
947
+ enabledLocationsSwitch: v,
948
+ promptSelectLocations: d,
949
+ removeLocation: r
950
+ };
951
+ }
952
+ const co = { class: "flex flex-col gap-16 w-full h-full overflow-y-auto" }, po = { class: "flex justify-between" }, fo = { class: "fm-typo-en-body-lg-600" }, yo = { class: "flex flex-col gap-8" }, vo = { class: "flex flex-col gap-4" }, bo = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, _o = { class: "flex gap-1" }, xo = { class: "fm-typo-en-body-lg-600" }, ho = {
953
+ key: 0,
954
+ class: "flex flex-col gap-4"
955
+ }, go = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, ko = { class: "fm-typo-en-body-lg-600" }, wo = { class: "flex flex-col gap-4" }, To = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Fo = { class: "fm-typo-en-body-lg-600" }, So = {
956
+ key: 1,
957
+ class: "flex flex-col gap-4"
958
+ }, Co = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, $o = { class: "fm-typo-en-body-lg-600" }, Mo = {
959
+ key: 2,
960
+ class: "flex flex-col gap-4"
961
+ }, Do = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Ro = { class: "fm-typo-en-body-lg-600" }, Ao = {
962
+ key: 3,
963
+ class: "flex flex-col gap-4"
964
+ }, Io = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Vo = { class: "fm-typo-en-body-lg-600" }, Lo = { class: "border border-fm-color-neutral-gray-200 fm-corner-radius-lg p-16" }, Oo = { class: "flex flex-col gap-8" }, Po = { class: "fm-typo-en-body-lg-600" }, Eo = { class: "flex w-full gap-4" }, Bo = { class: "grow fm-typo-en-body-lg-400 line-clamp-2" }, Uo = { class: "fm-typo-en-body-lg-600 shrink-0" }, qo = { class: "flex w-full gap-4 fm-typo-en-body-sm-400" }, No = { class: "grow fm-typo-en-body-lg-400 text-fm-color-typo-secondary line-clamp-2" }, zo = {
965
+ key: 0,
966
+ class: "shrink-0 fm-typo-en-body-lg-400 text-fm-color-typo-secondary"
967
+ }, Ho = { class: "flex gap-8 xs:flex-col" }, jo = /* @__PURE__ */ K({
968
+ __name: "TransferTemplateDetails",
969
+ props: {
970
+ template: {},
971
+ show: { type: Boolean }
972
+ },
973
+ emits: ["update:show", "action:use", "action:edit"],
974
+ setup(m, { emit: _ }) {
975
+ const c = m, n = _, v = Ue(), { t: d } = Y(), s = M(() => {
976
+ var k;
977
+ return (k = c.template) == null ? void 0 : k.purchaseOrder;
978
+ }), { enabledLocations: r } = mo({
979
+ getLocations() {
980
+ var k;
981
+ return (k = c.template) == null ? void 0 : k.locations;
982
+ },
983
+ setLocations() {
984
+ }
985
+ }), x = M(
986
+ () => {
987
+ var k, g, $, F;
988
+ return ((g = (k = s.value) == null ? void 0 : k.supplier) == null ? void 0 : g.internal) === "restaurant" || ((F = ($ = s.value) == null ? void 0 : $.supplier) == null ? void 0 : F.internal) === "warehouse" ? U.TRANSFER : U.PURCHASE;
989
+ }
990
+ ), b = B(!0), h = ze(c, "show");
991
+ return (k, g) => {
992
+ var i;
993
+ const $ = R("FmMenuDivider"), F = R("FmCard"), O = R("FmButton"), E = R("FmListItem"), P = R("FmList"), f = R("FmSideSheet");
994
+ return C(), H(f, {
995
+ header: t(d)("inventory.transfer.template.details.view", { template: (i = k.template) == null ? void 0 : i.name }),
996
+ modelValue: t(h),
997
+ "onUpdate:modelValue": g[1] || (g[1] = (l) => Ee(h) ? h.value = l : null),
998
+ "dismiss-away": b.value,
999
+ "close-button": "",
1000
+ "max-width": 500
1001
+ }, {
1002
+ default: L(() => {
1003
+ var l;
1004
+ return [
1005
+ o("div", co, [
1006
+ o("div", null, [
1007
+ p(F, {
1008
+ variant: "outlined",
1009
+ class: "flex flex-col gap-8 px-12 py-16"
1010
+ }, {
1011
+ default: L(() => {
1012
+ var e, a, u, y, T, D, I, A, w;
1013
+ return [
1014
+ o("div", po, [
1015
+ o("div", fo, S(t(d)("inventory.transfer.template.details.templateSummary")), 1)
1016
+ ]),
1017
+ p($),
1018
+ o("div", yo, [
1019
+ o("div", vo, [
1020
+ o("div", bo, [
1021
+ o("div", _o, S(t(d)("inventory.transfer.receiveRequest.details.createdAt")), 1)
1022
+ ]),
1023
+ o("div", xo, S(t(Ct)(((e = k.template) == null ? void 0 : e._id) ?? "")), 1)
1024
+ ]),
1025
+ (a = s.value) != null && a.effectiveAt ? (C(), N("div", ho, [
1026
+ o("div", go, S(t(d)("inventory.transfer.receiveRequest.details.backdatedTo")), 1),
1027
+ o("div", ko, S(t(yt)(new Date((u = s.value) == null ? void 0 : u.effectiveAt))), 1)
1028
+ ])) : X("", !0),
1029
+ o("div", wo, [
1030
+ o("div", To, S(t(d)("inventory.transfer.receiveRequest.details.type.title")), 1),
1031
+ o("div", Fo, S(t(d)(
1032
+ `inventory.transfer.receiveRequest.details.type.${x.value.toLocaleLowerCase("en-US")}`
1033
+ )), 1)
1034
+ ]),
1035
+ (T = (y = s.value) == null ? void 0 : y.supplier) != null && T.name ? (C(), N("div", So, [
1036
+ o("div", Co, S(t(d)("inventory.transfer.receiveRequest.details.from")), 1),
1037
+ o("div", $o, S((I = (D = s.value) == null ? void 0 : D.supplier) == null ? void 0 : I.name), 1)
1038
+ ])) : X("", !0),
1039
+ (A = s.value) != null && A.ref ? (C(), N("div", Mo, [
1040
+ o("div", Do, S(t(d)("inventory.transfer.receiveRequest.details.reference")), 1),
1041
+ o("div", Ro, S(s.value.ref), 1)
1042
+ ])) : X("", !0),
1043
+ (w = s.value) != null && w.remark ? (C(), N("div", Ao, [
1044
+ o("div", Io, S(t(d)("inventory.transfer.receiveRequest.details.remark")), 1),
1045
+ o("div", Vo, S(s.value.remark), 1)
1046
+ ])) : X("", !0)
1047
+ ])
1048
+ ];
1049
+ }),
1050
+ _: 1
1051
+ })
1052
+ ]),
1053
+ o("div", Lo, [
1054
+ o("div", Oo, [
1055
+ o("div", Po, S(t(d)("inventory.transfer.receiveRequest.details.requestedItems")), 1),
1056
+ (C(!0), N(ue, null, Ae(((l = s.value) == null ? void 0 : l.items) ?? [], (e) => (C(), N("div", {
1057
+ key: e.code,
1058
+ class: "flex flex-col"
1059
+ }, [
1060
+ o("div", Eo, [
1061
+ o("div", Bo, S(e.name), 1),
1062
+ g[2] || (g[2] = o("div", { class: "flex-1 min-w-32" }, null, -1)),
1063
+ o("div", Uo, S(t(nt)(e.quantity, e.sku.unit, e.measurement)), 1)
1064
+ ]),
1065
+ o("div", qo, [
1066
+ o("div", No, S(e.code), 1),
1067
+ e.totalCost && t(v).enableTotalCost ? (C(), N("div", zo, " (" + S(t(vt)(e.totalCost)) + ") ", 1)) : X("", !0)
1068
+ ])
1069
+ ]))), 128))
1070
+ ])
1071
+ ]),
1072
+ o("div", null, [
1073
+ p(F, {
1074
+ variant: "outlined",
1075
+ class: "flex flex-col"
1076
+ }, {
1077
+ default: L(() => [
1078
+ g[3] || (g[3] = o("div", { class: "flex flex-col p-16" }, [
1079
+ o("div", { class: "fm-typo-en-body-lg-600" }, "Enabled locations"),
1080
+ o("div", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " This template is only usable for the following locations. ")
1081
+ ], -1)),
1082
+ p(P, null, {
1083
+ default: L(() => {
1084
+ var e;
1085
+ return [
1086
+ (e = t(r)) != null && e.length ? (C(!0), N(ue, { key: 0 }, Ae(t(r), (a) => (C(), H(E, {
1087
+ key: a.doc._id,
1088
+ label: a.name,
1089
+ sublabel: a.type,
1090
+ onClick: (u) => n("action:use", a.doc._id)
1091
+ }, {
1092
+ append: L(() => [
1093
+ p(O, {
1094
+ "prepend-icon": "chevron_right",
1095
+ variant: "tertiary"
1096
+ })
1097
+ ]),
1098
+ _: 2
1099
+ }, 1032, ["label", "sublabel", "onClick"]))), 128)) : (C(), H(E, {
1100
+ key: 1,
1101
+ label: "All locations"
1102
+ }))
1103
+ ];
1104
+ }),
1105
+ _: 1
1106
+ })
1107
+ ]),
1108
+ _: 1
1109
+ })
1110
+ ])
1111
+ ])
1112
+ ];
1113
+ }),
1114
+ "side-sheet-footer": L(() => [
1115
+ o("div", Ho, [
1116
+ p(O, {
1117
+ label: t(d)("common.edit"),
1118
+ onClick: g[0] || (g[0] = (l) => n("action:edit")),
1119
+ variant: "tertiary"
1120
+ }, null, 8, ["label"])
1121
+ ])
1122
+ ]),
1123
+ _: 1
1124
+ }, 8, ["header", "modelValue", "dismiss-away"]);
1125
+ };
1126
+ }
1127
+ }), Qo = { class: "flex-1 flex flex-col gap-8" }, Go = { class: "flex flex-col" }, Yo = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Wo = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, Ko = { class: "fm-typo-en-body-lg-400" }, Zo = { class: "fm-typo-en-body-lg-400 line-clamp-1" }, Jo = { class: "fm-typo-en-body-lg-400 line-clamp-2" }, yn = /* @__PURE__ */ K({
1128
+ __name: "TransferTemplateView",
1129
+ setup(m) {
1130
+ const { t: _ } = Y(), { createTemplate: c, viewTemplate: n } = Ve(), { templateDialogProps: v, transferFormDialogProps: d, templateDetailsProps: s } = ht(
1131
+ Ve()
1132
+ ), r = st(), x = Xe(), b = pe(), { breakpoints: h } = xt();
1133
+ me(r.fetchTemplates);
1134
+ const k = M(
1135
+ () => r.loading.value || !b._currentLocation
1136
+ ), g = M(() => r.templates.value), $ = B(""), F = M(() => h.value.xs || h.value.sm), O = M(() => F.value ? 10 : 20);
1137
+ function E(l) {
1138
+ switch (l) {
1139
+ case Le.Add:
1140
+ return c();
1141
+ }
1142
+ }
1143
+ const P = Tt();
1144
+ function f() {
1145
+ P.push({ name: bt.RECEIVE_REQUEST });
1146
+ }
1147
+ function i(l) {
1148
+ return l;
1149
+ }
1150
+ return (l, e) => {
1151
+ const a = R("FmTable");
1152
+ return C(), N(ue, null, [
1153
+ p(et, {
1154
+ title: t(_)("inventory.transfer.template.title2"),
1155
+ actions: [
1156
+ {
1157
+ label: t(_)("inventory.transfer.template.create.title"),
1158
+ value: t(Le).Add,
1159
+ isPrimary: !0,
1160
+ prependIcon: "add"
1161
+ }
1162
+ ],
1163
+ "onClick:action": E
1164
+ }, {
1165
+ default: L(() => {
1166
+ var u;
1167
+ return [
1168
+ o("div", {
1169
+ class: re([
1170
+ "flex flex-col gap-8 max-h-full",
1171
+ {
1172
+ "p-0": F.value,
1173
+ "px-24 ": !F.value
1174
+ }
1175
+ ])
1176
+ }, [
1177
+ p(tt, {
1178
+ searchable: "",
1179
+ search: $.value,
1180
+ "onUpdate:search": e[0] || (e[0] = (y) => $.value = y),
1181
+ actions: [{ icon: "refresh", onClick: t(r).fetchTemplates }]
1182
+ }, null, 8, ["search", "actions"]),
1183
+ (C(), H(a, {
1184
+ style: We(t(x).tableHeight),
1185
+ "column-defs": t(r).columnDefs,
1186
+ "row-data": g.value,
1187
+ "search-value": $.value,
1188
+ loading: k.value,
1189
+ key: (u = t(b)._currentLocation) == null ? void 0 : u.dbName,
1190
+ onRowClick: e[1] || (e[1] = (y) => t(n)(y.original)),
1191
+ "page-size": O.value
1192
+ }, {
1193
+ "list-row": L((y) => [
1194
+ p(je, {
1195
+ row: y,
1196
+ onRowClick: (T) => t(n)(T)
1197
+ }, {
1198
+ default: L((T) => {
1199
+ var D, I, A, w, q, Z, J, Q, G, fe, ye, ve, be, te, _e, xe, he, ge, ke, we, oe, Te, Fe, Se, Ce, ne, $e;
1200
+ return [
1201
+ o("div", Qo, [
1202
+ o("div", Go, [
1203
+ o("div", Yo, [
1204
+ p(t(z), {
1205
+ render: (A = (I = (D = T._id) == null ? void 0 : D.column) == null ? void 0 : I.columnDef) == null ? void 0 : A.cell,
1206
+ props: (q = (w = T._id) == null ? void 0 : w.getContext) == null ? void 0 : q.call(w)
1207
+ }, null, 8, ["render", "props"])
1208
+ ]),
1209
+ o("div", Wo, [
1210
+ p(t(z), {
1211
+ render: (Q = (J = (Z = T.name) == null ? void 0 : Z.column) == null ? void 0 : J.columnDef) == null ? void 0 : Q.cell,
1212
+ props: (fe = (G = T.name) == null ? void 0 : G.getContext) == null ? void 0 : fe.call(G)
1213
+ }, null, 8, ["render", "props"])
1214
+ ]),
1215
+ o("div", Ko, [
1216
+ p(t(z), {
1217
+ render: (be = (ve = (ye = T.supplier) == null ? void 0 : ye.column) == null ? void 0 : ve.columnDef) == null ? void 0 : be.cell,
1218
+ props: (_e = (te = T.supplier) == null ? void 0 : te.getContext) == null ? void 0 : _e.call(te)
1219
+ }, null, 8, ["render", "props"])
1220
+ ]),
1221
+ o("div", null, S((xe = y.original.locations) != null && xe.length ? `Enabled for ${(he = y.original.locations) == null ? void 0 : he.length} outlets` : "Enabled for all outlets"), 1),
1222
+ o("div", Zo, S(y.original.purchaseOrder.items.length ? y.original.purchaseOrder.items.map((Qe) => Qe.name).join(", ") : "No items"), 1),
1223
+ o("div", Jo, [
1224
+ p(t(z), {
1225
+ render: (we = (ke = (ge = T.ref) == null ? void 0 : ge.column) == null ? void 0 : ke.columnDef) == null ? void 0 : we.cell,
1226
+ props: (Te = (oe = T.ref) == null ? void 0 : oe.getContext) == null ? void 0 : Te.call(oe)
1227
+ }, null, 8, ["render", "props"])
1228
+ ])
1229
+ ]),
1230
+ o("div", null, [
1231
+ p(t(z), {
1232
+ render: (Ce = (Se = (Fe = T.type) == null ? void 0 : Fe.column) == null ? void 0 : Se.columnDef) == null ? void 0 : Ce.cell,
1233
+ props: ($e = (ne = T.type) == null ? void 0 : ne.getContext) == null ? void 0 : $e.call(ne)
1234
+ }, null, 8, ["render", "props"])
1235
+ ])
1236
+ ])
1237
+ ];
1238
+ }),
1239
+ _: 2
1240
+ }, 1032, ["row", "onRowClick"])
1241
+ ]),
1242
+ _: 1
1243
+ }, 8, ["style", "column-defs", "row-data", "search-value", "loading", "page-size"]))
1244
+ ], 2)
1245
+ ];
1246
+ }),
1247
+ _: 1
1248
+ }, 8, ["title", "actions"]),
1249
+ (C(), H(Ke, { to: "body" }, [
1250
+ p(wt, Ie(t(d), { onSubmitted: f }), null, 16),
1251
+ p(jo, Ze(Je(t(s))), null, 16),
1252
+ p(uo, Ie(t(v), {
1253
+ onSubmitted: e[2] || (e[2] = (u) => t(r).fetchTemplates())
1254
+ }), null, 16)
1255
+ ]))
1256
+ ], 64);
1257
+ };
1258
+ }
1259
+ });
1260
+ export {
1261
+ yn as default
1262
+ };