@feedmepos/mf-inventory-portal 1.0.20 → 1.0.21

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 (57) hide show
  1. package/dist/{App-HCucbXT5.js → App-Dm1dub7v.js} +2 -2
  2. package/dist/{ApprovalView-CR8Ievmh.js → ApprovalView-DZK5guKS.js} +2 -2
  3. package/dist/{BindingsDialog-BsbaWyqP.js → BindingsDialog-BL2jOxN4.js} +2 -2
  4. package/dist/{BindingsPicker-ByFOp6B3.js → BindingsPicker-G1SdBXsq.js} +1 -1
  5. package/dist/{BindingsTable-BhGnyUQH.js → BindingsTable-Coy6_ryj.js} +1 -1
  6. package/dist/{ClosingDraftView-5Eem33MA.js → ClosingDraftView-RTjmn1uK.js} +2 -2
  7. package/dist/{ClosingTemplateView-CydMQc2L.js → ClosingTemplateView-DkX8edyP.js} +2 -2
  8. package/dist/{DeliveryOrderPrintPreview-Csbca_v0.js → DeliveryOrderPrintPreview-j-DgrDiv.js} +1 -1
  9. package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-LV2wLWWk.js → FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-BL8MG9yR.js} +3 -3
  10. package/dist/{FmMultiselectDialog-DISDKgZY.js → FmMultiselectDialog-C2FfQXZp.js} +1 -1
  11. package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-TSO_zgPu.js → FmUnitInput.vue_vue_type_script_setup_true_lang-D4dnq4rA.js} +1 -1
  12. package/dist/{IngredientBindedItem.vue_vue_type_script_setup_true_lang-Cg8vkF_r.js → IngredientBindedItem.vue_vue_type_script_setup_true_lang-DXbFhLpK.js} +1 -1
  13. package/dist/{IngredientGroupView-BONl2HNV.js → IngredientGroupView-DHbQCRy_.js} +2 -2
  14. package/dist/{IngredientsView-b-ztsnrh.js → IngredientsView-CF-wb-6-.js} +5 -5
  15. package/dist/IntegrationView-X5yvur-x.js +6007 -0
  16. package/dist/{InventoryBindingForm-BJvKlpQv.js → InventoryBindingForm-CeJZHDY0.js} +1 -1
  17. package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-Cw_LyQCc.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-9hirHThb.js} +3 -3
  18. package/dist/{InventoryBindingSummary-o1qzcGiz.js → InventoryBindingSummary-CBg7KhPi.js} +1 -1
  19. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-8ne5kKtT.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-BSVs7T4a.js} +1 -1
  20. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-D60Y07cG.js → PremiumBadge.vue_vue_type_script_setup_true_lang-ChZwsyJM.js} +1 -1
  21. package/dist/{PublishView-BAzw6iNq.js → PublishView-BjvKb7f-.js} +2 -2
  22. package/dist/{PurchaseOrderPrintPreview-DBaLVHMs.js → PurchaseOrderPrintPreview-CbAMXMPU.js} +1 -1
  23. package/dist/{ReceiveRequestView-CHwB-N1X.js → ReceiveRequestView-ihHtocTf.js} +10 -10
  24. package/dist/{RecipeView-CTNJ1Alw.js → RecipeView-BoR36rGq.js} +4 -4
  25. package/dist/{StockView-Dd0FpkBz.js → StockView-DcHopPZO.js} +7 -7
  26. package/dist/{SupplierView-C5tHBFjz.js → SupplierView-V67QXaLX.js} +482 -480
  27. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-eeL8-QuF.js +2181 -0
  28. package/dist/TransferTemplateView-DKDeo49Q.js +1432 -0
  29. package/dist/{UnitView-DIqdD9rK.js → UnitView-BRVRLheN.js} +3 -3
  30. package/dist/WarehouseView-tRg5Hn4L.js +1034 -0
  31. package/dist/api/netsuite.d.ts +1 -0
  32. package/dist/{app-D6VUced2.js → app-82JEull2.js} +43642 -39723
  33. package/dist/app.js +4 -4
  34. package/dist/{decimal-B-F4KR7a.js → decimal-D-zH_vXe.js} +1 -1
  35. package/dist/{feature-BXo8MNXq.js → feature-UG6T1t8f.js} +394 -387
  36. package/dist/{format-unit-display-CKfsmYU1.js → format-unit-display-CIPAWL-6.js} +2 -2
  37. package/dist/{index-Bx9GXnw-.js → index-B7w4ky-g.js} +2 -2
  38. package/dist/{index-DWWzKqnk.js → index-BDC93VCL.js} +1 -1
  39. package/dist/{stock-CKqcI427.js → stock-Bq9xHemt.js} +1 -1
  40. package/dist/stores/integration/netsuite.d.ts +31 -0
  41. package/dist/{supplier-DsBIy15T.js → supplier-BrZdgPMN.js} +2 -2
  42. package/dist/tsconfig.app.tsbuildinfo +1 -1
  43. package/dist/{use-ingredient-select-dialog-DVBnJIlK.js → use-ingredient-select-dialog-Dzy7PO1j.js} +1 -1
  44. package/dist/{use-inventory-binding-dialog-DgbGDAWk.js → use-inventory-binding-dialog-DT4t22Eb.js} +1 -1
  45. package/dist/views/receive-request/components/netsuite/NetSuiteLatestInfo.vue.d.ts +17 -0
  46. package/dist/views/transfer-template/components/transfer-template-dialog/TransferTemplateDialog.vue.d.ts +497 -12
  47. package/dist/views/transfer-template/components/transfer-template-form/TransferTemplateForm.vue.d.ts +5 -1
  48. package/dist/views/transfer-template/components/transfer-template-form/components/NetSuiteCustomCodeSelection.vue.d.ts +172 -0
  49. package/dist/views/transfer-template/components/transfer-template-form/components/TransferTemplateItemTable.vue.d.ts +2 -0
  50. package/dist/views/transfer-template/components/transfer-template-form/composables/use-transfer-template-items.d.ts +3 -2
  51. package/dist/{vue-i18n-g4GUXOuk.js → vue-i18n-D5ETg5F3.js} +300 -300
  52. package/package.json +5 -3
  53. package/dist/IntegrationView-oRHoLLjT.js +0 -9671
  54. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-CpngWNmz.js +0 -2095
  55. package/dist/TransferTemplateView-CP24Mv9n.js +0 -1421
  56. package/dist/WarehouseView-DCtBNHvx.js +0 -1032
  57. package/dist/views/transfer-template/composables/useTransferTemplateHelper.d.ts +0 -305
@@ -1,1421 +0,0 @@
1
- import { defineComponent as ee, onMounted as ve, computed as U, ref as Q, watch as be, inject as et, resolveComponent as A, openBlock as R, createElementBlock as j, createElementVNode as s, createVNode as p, withCtx as N, renderSlot as Re, withDirectives as Ae, normalizeClass as Z, vModelText as Pe, reactive as tt, h as J, toDisplayString as V, unref as t, createCommentVNode as oe, Fragment as _e, renderList as ze, normalizeStyle as He, createBlock as X, mergeProps as Qe, isRef as je, Teleport as st, normalizeProps as ot, guardReactiveProps as lt } from "vue";
2
- import { J as Ge, aD as ce, t as Ue, I as nt, aE as at, aF as rt, i as Y, aG as it, b as ut, a as Ke, P as Le, l as fe, X as me, Q as ue, A as ye, M as dt, E as W, u as We, ah as mt, $ as pt, C as Ye, d as ne, aH as de, ae as ct, a6 as ft, z as yt, h as Be, _ as vt, B as bt } from "./app-D6VUced2.js";
3
- import { useI18n as le } from "@feedmepos/mf-common";
4
- import { P as K, a as _t, f as ht, t as xt, b as qe, u as gt } from "./format-unit-display-CKfsmYU1.js";
5
- import { components as se, useDialog as kt, useSnackbar as Tt, useProxiedModel as Je, useBreakpoints as wt } from "@feedmepos/ui-library";
6
- import { defineStore as Ft, storeToRefs as Ee } from "pinia";
7
- import { _ as It, b as St, F as Ct, a as $t } from "./FmUnitInput.vue_vue_type_script_setup_true_lang-TSO_zgPu.js";
8
- import { u as pe } from "./feature-BXo8MNXq.js";
9
- import { c as Ot, u as Mt, _ as Dt } from "./FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-LV2wLWWk.js";
10
- import { u as Vt } from "./supplier-DsBIy15T.js";
11
- import { u as Rt } from "./use-ingredient-select-dialog-DVBnJIlK.js";
12
- const At = { class: "flex flex-col" }, Pt = { class: "flex flex-col" }, Ut = { class: "flex-1" }, Lt = { class: "flex items-center" }, Bt = { class: "flex-1" }, qt = { class: "flex-1" }, Et = /* @__PURE__ */ ee({
13
- __name: "FmMinMaxInput",
14
- props: {
15
- rules: {},
16
- label: {},
17
- minPlaceholder: {},
18
- maxPlaceholder: {},
19
- modelValue: {},
20
- precision: {},
21
- minLength: {},
22
- maxLength: {},
23
- inputmode: {},
24
- type: {},
25
- readonly: { type: Boolean },
26
- labelMark: {},
27
- prependIcon: {},
28
- appendIcon: {},
29
- showValidBorder: { type: Boolean },
30
- labelInfo: {},
31
- showWordCount: { type: Boolean },
32
- invalid: { type: Boolean },
33
- autofocus: { type: Boolean },
34
- formatter: { type: Function },
35
- decimal: {},
36
- datalist: {},
37
- shiftDatalist: { type: Boolean },
38
- datalistMaxHeight: {},
39
- datalistMinHeight: {},
40
- offsetDatalist: {},
41
- datalistPlacement: {},
42
- datalistZIndex: {},
43
- datalistWidth: {},
44
- disabled: { type: Boolean },
45
- focused: { type: Boolean },
46
- helperText: {},
47
- helperState: {}
48
- },
49
- setup(m) {
50
- const c = m, v = Ge("modelValue"), e = nt();
51
- ve(() => {
52
- const { min: y, max: d } = v ?? {};
53
- if (!(!y || !d) && y.precision !== d.precision) {
54
- const k = Math.max(y.precision, d.precision), a = ce(y, k), f = ce(d, k);
55
- v.min = a, v.max = f;
56
- }
57
- });
58
- const n = U(() => {
59
- const { min: y, max: d } = v ?? {};
60
- return Math.max((y == null ? void 0 : y.precision) ?? 0, (d == null ? void 0 : d.precision) ?? 0, c.precision ?? 0);
61
- }), g = (y) => {
62
- if (!y) return "";
63
- const d = at(y), k = n.value, a = ce(d, k);
64
- return rt(
65
- +Y(a),
66
- a.precision
67
- );
68
- }, b = Q(g(v.min)), i = Q(g(v.max));
69
- be([b, i], ([y, d]) => {
70
- const k = v ?? {}, a = e(y), f = e(d), C = n.value;
71
- if (y !== "" && a === !0) {
72
- const $ = Ue(+y, C);
73
- k.min = $;
74
- } else
75
- k.min = null;
76
- if (d !== "" && f === !0) {
77
- const $ = Ue(+d, C);
78
- k.max = $;
79
- } else
80
- k.max = null;
81
- v.min = k.min, v.max = k.max;
82
- });
83
- const o = Symbol.for("fm:form-state"), u = et(o, null), _ = U(() => c.disabled ?? (u == null ? void 0 : u.getDisabled()) ?? !1), P = Q(), I = Q(), h = Q(!1), S = Q(!1), D = U(() => h.value || S.value), G = U(() => [...[
84
- function() {
85
- return typeof e(b.value) == "string" || typeof e(i.value) == "string" ? "Must be a number" : !0;
86
- },
87
- function(k) {
88
- return !k || !k.min || !k.max ? !0 : +Y(k.min) > +Y(k.max) ? "Min must be less than or equal to max" : !0;
89
- }
90
- ], ...c.rules ?? []]);
91
- return (y, d) => {
92
- const k = A("FmLabel"), a = A("FmField"), f = A("FmFormGroup");
93
- return R(), j("div", At, [
94
- s("div", Pt, [
95
- s("div", Ut, [
96
- p(k, {
97
- label: y.label,
98
- disabled: y.disabled,
99
- required: y.labelMark === "required",
100
- optional: y.labelMark === "optional"
101
- }, null, 8, ["label", "disabled", "required", "optional"])
102
- ]),
103
- p(a, { focused: D.value }, {
104
- default: N(() => [
105
- s("div", Lt, [
106
- Re(y.$slots, "prepend"),
107
- d[6] || (d[6] = s("div", { class: "text-fm-color-typo-secondary fm-typo-en-body-lg-400 pr-4" }, "Min.", -1)),
108
- s("div", Bt, [
109
- Ae(s("input", {
110
- type: "text",
111
- ref_key: "minInputRef",
112
- ref: P,
113
- onFocus: d[0] || (d[0] = () => h.value = !0),
114
- onBlur: d[1] || (d[1] = () => h.value = !1),
115
- "onUpdate:modelValue": d[2] || (d[2] = (C) => b.value = C),
116
- class: Z({
117
- "fm-text-field--input fm-typo-en-body-lg-400": !0,
118
- "text-fm-color-typo-primary": !_.value,
119
- "text-fm-color-typo-disabled": _.value
120
- })
121
- }, null, 34), [
122
- [Pe, b.value]
123
- ])
124
- ]),
125
- d[7] || (d[7] = s("div", { class: "block h-32 mx-4 w-[1px] bg-fm-color-neutral-gray-200" }, null, -1)),
126
- d[8] || (d[8] = s("div", { class: "text-fm-color-typo-secondary fm-typo-en-body-lg-400 pr-4" }, "Max.", -1)),
127
- s("div", qt, [
128
- Ae(s("input", {
129
- type: "text",
130
- ref_key: "maxInputRef",
131
- ref: I,
132
- onFocus: d[3] || (d[3] = () => S.value = !0),
133
- onBlur: d[4] || (d[4] = () => S.value = !1),
134
- "onUpdate:modelValue": d[5] || (d[5] = (C) => i.value = C),
135
- class: Z({
136
- "fm-text-field--input fm-typo-en-body-lg-400": !0,
137
- "text-fm-color-typo-primary": !_.value,
138
- "text-fm-color-typo-disabled": _.value
139
- })
140
- }, null, 34), [
141
- [Pe, i.value]
142
- ])
143
- ]),
144
- Re(y.$slots, "append")
145
- ])
146
- ]),
147
- _: 3
148
- }, 8, ["focused"])
149
- ]),
150
- p(f, {
151
- class: "flex-1",
152
- "model-value": y.modelValue,
153
- info: y.labelInfo,
154
- rules: G.value,
155
- "helper-text": y.helperText,
156
- "helper-state": y.helperState
157
- }, null, 8, ["model-value", "info", "rules", "helper-text", "helper-state"])
158
- ]);
159
- };
160
- }
161
- });
162
- function Nt({ min: m, max: c } = { min: !0, max: !0 }) {
163
- return function(e) {
164
- return !e || !e.min && m != !1 || !e.max && c != !1 ? "Required" : !0;
165
- };
166
- }
167
- function zt(m, c) {
168
- return function(e) {
169
- return !e || !e.min || !e.max ? !0 : +Y(e.min) < m ? `Must be between ${m} and ${c}` : +Y(e.max) > c ? `Must be between ${m} and ${c}` : !0;
170
- };
171
- }
172
- function Ht(m) {
173
- const c = it(m), v = Y(m);
174
- return function(n) {
175
- const g = !(n != null && n.min) || c(n.min) === !0, b = !(n != null && n.max) || c(n.max) === !0;
176
- return !g && !b ? `Min & max must be a multiple of ${v}` : g ? b ? !0 : `Max must be a multiple of ${v}` : `Min must be a multiple of ${v}`;
177
- };
178
- }
179
- const Xe = Ft("transfer-template-helper", () => {
180
- const m = ut();
181
- function c(v, e, n, g, b) {
182
- var o;
183
- if (!n) {
184
- b == null || b("Unit is not valid");
185
- return;
186
- }
187
- let i = v.code;
188
- if (m.isEnabled) {
189
- const u = m.getItemPKTCode(e, (o = n.measurement) == null ? void 0 : o.id);
190
- u && (i = u);
191
- }
192
- g({
193
- ...v,
194
- quantity: n.amount,
195
- measurement: n.measurement ?? null,
196
- code: i
197
- });
198
- }
199
- return {
200
- validateUnitInput: c
201
- };
202
- });
203
- var H = /* @__PURE__ */ ((m) => (m.Code = "Code", m.Name = "Name", m.DefaultAmount = "DefaultAmount", m.Limit = "Limit", m.Step = "Step", m.Cost = "Cost", m.Delete = "Delete", m))(H || {});
204
- const Ne = Xe();
205
- function Qt(m) {
206
- const { t: c } = le(), v = Ke(), e = pe(), n = tt({});
207
- ve(() => {
208
- for (const i of m.items) {
209
- if (!i.totalCost)
210
- continue;
211
- const o = Ot(i.sku, i.quantity, i.measurement, {
212
- supplier: m.supplier
213
- }), u = i.totalCost ?? Le.reset();
214
- o ? n[i.sku._id] = o.amount !== u.amount || o.precision !== u.precision : n[i.sku._id] = !0;
215
- }
216
- });
217
- const g = [
218
- {
219
- id: "Code",
220
- header: () => c("inventory.transfer.form.items.table.Code"),
221
- accessorKey: "code",
222
- size: 180,
223
- cell(i) {
224
- const o = i.row.original;
225
- return J(se.FmTextField, {
226
- modelValue: o.code,
227
- "onUpdate:modelValue": (u) => {
228
- m.updateItem({
229
- ...o,
230
- code: u
231
- });
232
- },
233
- key: o.sku._id,
234
- rules: [fe()],
235
- labelMark: "required"
236
- });
237
- },
238
- enableSorting: !1
239
- },
240
- {
241
- id: "Name",
242
- header: () => c("inventory.transfer.form.items.table.Name"),
243
- minSize: 300,
244
- cell(i) {
245
- const o = i.row.original;
246
- return J(se.FmTextField, {
247
- modelValue: o.name,
248
- "onUpdate:modelValue": (u) => {
249
- m.updateItem({
250
- ...o,
251
- name: u
252
- });
253
- },
254
- key: o.sku._id,
255
- rules: [fe()],
256
- labelMark: "required"
257
- });
258
- },
259
- enableSorting: !1
260
- },
261
- {
262
- id: "DefaultAmount",
263
- header: () => c("inventory.transfer.form.items.table.DefaultAmount"),
264
- minSize: 200,
265
- cell(i) {
266
- var h;
267
- const o = i.row.original, u = v.skuById[o.sku._id], _ = v.unitById[(h = u.unit) == null ? void 0 : h._id], P = _.measurements.find((S) => {
268
- var D;
269
- return ((D = o.measurement) == null ? void 0 : D.id) === S.id;
270
- }), I = o.sku.unit._id !== u.unit._id || !_ || o.measurement && !P;
271
- return J(It, {
272
- style: {
273
- flex: "1 1 0%"
274
- },
275
- modelValue: {
276
- amount: o.quantity ?? { amount: 1, precision: 0 },
277
- // NOTE: leave this reading from row.sku.unit and row.measurement instead,
278
- measurement: o.measurement ?? (o.sku.unit._id !== u.unit._id ? { ...o.sku.unit, id: "", conversion: { amount: 1, precision: 0 } } : null)
279
- },
280
- disabled: m.disabled,
281
- key: o.sku._id,
282
- unit: _,
283
- "onUpdate:modelValue": (S) => {
284
- Ne.validateUnitInput(
285
- o,
286
- u,
287
- S,
288
- (D) => {
289
- m.updateItem({
290
- ...o,
291
- code: D.code,
292
- sku: u,
293
- quantity: D.quantity,
294
- measurement: D.measurement
295
- });
296
- }
297
- );
298
- },
299
- rules: [
300
- St(o.quantityStep),
301
- ...+Y(o.quantity) ? [
302
- Ct(
303
- +Y(
304
- o.minimumQuantity ?? {
305
- amount: 1,
306
- // NOTE: leave this reading from row.sku.unit and row.measurement instead,
307
- precision: me(o.sku.unit, o.measurement)
308
- }
309
- )
310
- )
311
- ] : [],
312
- $t(
313
- o.maximumQuantity ? +Y(o.maximumQuantity) : 1 / 0
314
- ),
315
- function(D) {
316
- return I ? "This item is no longer valid due to change in unit. Please reapply unit." : !0;
317
- }
318
- ],
319
- applyDefaultRules: !0
320
- });
321
- },
322
- enableSorting: !1
323
- },
324
- {
325
- id: "Limit",
326
- header: () => "Limit",
327
- // TODO: i18n,
328
- minSize: 280,
329
- cell(i) {
330
- const o = i.row.original;
331
- return J(Et, {
332
- style: {
333
- flex: "1 1 0%"
334
- },
335
- modelValue: {
336
- min: o.minimumQuantity,
337
- max: o.maximumQuantity
338
- },
339
- disabled: m.disabled,
340
- key: o.sku._id,
341
- unit: o.sku.unit,
342
- "onUpdate:modelValue": (u) => {
343
- const _ = { ...o };
344
- u != null && u.min ? _.minimumQuantity = u.min : _.minimumQuantity = null, u != null && u.max ? _.maximumQuantity = u.max : _.maximumQuantity = null, m.updateItem(_);
345
- },
346
- rules: [
347
- Nt({ max: !1 }),
348
- Ht(o.quantityStep),
349
- zt(
350
- +Y({
351
- amount: 0,
352
- precision: me(o.sku.unit, o.measurement)
353
- }),
354
- 1 / 0
355
- )
356
- ],
357
- disableUnit: !0,
358
- applyDefaultRules: !0
359
- });
360
- }
361
- },
362
- {
363
- id: "Step",
364
- header: () => c("inventory.transfer.form.items.table.Step"),
365
- minSize: 100,
366
- cell(i) {
367
- const o = i.row.original;
368
- return J(se.FmTextField, {
369
- modelValue: Y(o.quantityStep ?? Le.reset(), !1),
370
- key: o.sku._id,
371
- "onUpdate:modelValue": (u) => {
372
- m.updateItem({
373
- ...o,
374
- quantityStep: ue(+u)
375
- });
376
- },
377
- rules: [
378
- ye({
379
- amount: 1,
380
- precision: me(o.sku.unit, o.measurement)
381
- }),
382
- dt(o.sku.unit, o.measurement)
383
- ]
384
- });
385
- },
386
- enableSorting: !1
387
- },
388
- {
389
- id: "Delete",
390
- header: "",
391
- cell(i) {
392
- const o = i.row.original;
393
- return J("div", { class: "flex items-center" }, [
394
- e.usePurchaseOrderV2 ? J(
395
- se.FmTooltip,
396
- {
397
- zIndex: 50,
398
- placement: "left"
399
- },
400
- {
401
- default() {
402
- return J(se.FmButton, {
403
- key: o.sku._id,
404
- type: "button",
405
- icon: "add_circle",
406
- variant: "tertiary",
407
- size: "md",
408
- disabled: m.disabled,
409
- onClick: async () => {
410
- const u = {
411
- id: crypto.randomUUID(),
412
- sku: o.sku,
413
- code: o.sku.code,
414
- name: o.sku.name,
415
- quantity: ue(1),
416
- quantityStep: ue(1),
417
- minimumQuantity: ue(1)
418
- };
419
- Ne.validateUnitInput(
420
- u,
421
- o.sku,
422
- {
423
- amount: u.quantity,
424
- measurement: null
425
- },
426
- (_) => {
427
- u.code = _.code;
428
- }
429
- ), m.duplicateItem(u);
430
- }
431
- });
432
- },
433
- content() {
434
- return "Duplicate entry";
435
- }
436
- }
437
- ) : null,
438
- J(se.FmButton, {
439
- class: "delete-button",
440
- key: o.sku._id,
441
- type: "button",
442
- icon: "delete",
443
- variant: "tertiary",
444
- size: "md",
445
- disabled: m.disabled,
446
- onClick: () => {
447
- m.deleteItem(o);
448
- }
449
- })
450
- ]);
451
- },
452
- enableSorting: !1,
453
- size: 40,
454
- meta: {
455
- cellClass: "",
456
- headerClass: ""
457
- }
458
- }
459
- ];
460
- return {
461
- columnDefs: U(() => pe().enableTotalCost && m.transferType === K.PURCHASE ? g : g.filter((o) => o.id !== "Cost"))
462
- };
463
- }
464
- const jt = { class: "flex flex-col gap-8 py-16" }, Gt = { class: "flex items-center" }, Kt = { class: "flex-1 flex gap-1 items-center" }, Wt = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, Yt = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, Jt = { class: "flex gap-8 w-full" }, Xt = { class: "flex-1 flex flex-col gap-4" }, Zt = { class: "flex-1 flex flex-col gap-4" }, es = {
465
- key: 0,
466
- class: "flex gap-8 w-full"
467
- }, ts = { class: "flex-1 flex flex-col gap-4" }, ss = { class: "flex-1 flex flex-col gap-4" }, os = { class: "flex gap-8 w-full" }, ls = { class: "flex-1 flex flex-col gap-4" }, ns = /* @__PURE__ */ ee({
468
- __name: "TransferTemplateItem",
469
- props: {
470
- cellByColId: {},
471
- row: {}
472
- },
473
- setup(m) {
474
- const { t: c } = le();
475
- function v(e) {
476
- return e;
477
- }
478
- return (e, n) => {
479
- var b, i, o, u, _, P, I, h, S, D, G, y, d, k, a, f, C, $, x, l, r, T, F, L, z, O, M, B, q, w;
480
- const g = A("FmLabel");
481
- return R(), j("div", jt, [
482
- s("div", Gt, [
483
- s("div", Kt, [
484
- s("span", Wt, " (" + V(e.row.original.sku.code) + ") ", 1),
485
- s("span", Yt, V(e.row.original.sku.name), 1)
486
- ]),
487
- s("div", null, [
488
- p(t(W), {
489
- render: (o = (i = (b = e.cellByColId.Delete) == null ? void 0 : b.column) == null ? void 0 : i.columnDef) == null ? void 0 : o.cell,
490
- props: (_ = (u = e.cellByColId.Delete) == null ? void 0 : u.getContext) == null ? void 0 : _.call(u)
491
- }, null, 8, ["render", "props"])
492
- ])
493
- ]),
494
- s("div", Jt, [
495
- s("div", Xt, [
496
- p(g, {
497
- label: t(c)(`inventory.transfer.form.items.table.${t(H).Code}`)
498
- }, null, 8, ["label"]),
499
- p(t(W), {
500
- render: (h = (I = (P = e.cellByColId[t(H).Code]) == null ? void 0 : P.column) == null ? void 0 : I.columnDef) == null ? void 0 : h.cell,
501
- props: (D = (S = e.cellByColId[t(H).Code]) == null ? void 0 : S.getContext) == null ? void 0 : D.call(S)
502
- }, null, 8, ["render", "props"]),
503
- n[0] || (n[0] = s("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
504
- ]),
505
- s("div", Zt, [
506
- p(g, {
507
- label: t(c)(`inventory.transfer.form.items.table.${t(H).Name}`)
508
- }, null, 8, ["label"]),
509
- p(t(W), {
510
- render: (d = (y = (G = e.cellByColId[t(H).Name]) == null ? void 0 : G.column) == null ? void 0 : y.columnDef) == null ? void 0 : d.cell,
511
- props: (a = (k = e.cellByColId[t(H).Name]) == null ? void 0 : k.getContext) == null ? void 0 : a.call(k)
512
- }, null, 8, ["render", "props"]),
513
- n[1] || (n[1] = s("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
514
- ])
515
- ]),
516
- e.row.original ? (R(), j("div", es, [
517
- s("div", ts, [
518
- p(g, {
519
- label: t(c)(`inventory.transfer.form.items.table.${t(H).DefaultAmount}`)
520
- }, null, 8, ["label"]),
521
- p(t(W), {
522
- render: ($ = (C = (f = e.cellByColId[t(H).DefaultAmount]) == null ? void 0 : f.column) == null ? void 0 : C.columnDef) == null ? void 0 : $.cell,
523
- props: (l = (x = e.cellByColId[t(H).DefaultAmount]) == null ? void 0 : x.getContext) == null ? void 0 : l.call(x)
524
- }, null, 8, ["render", "props"]),
525
- n[2] || (n[2] = s("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
526
- ]),
527
- s("div", ss, [
528
- p(g, {
529
- label: t(c)(`inventory.transfer.form.items.table.${t(H).Step}`)
530
- }, null, 8, ["label"]),
531
- p(t(W), {
532
- render: (F = (T = (r = e.cellByColId[t(H).Step]) == null ? void 0 : r.column) == null ? void 0 : T.columnDef) == null ? void 0 : F.cell,
533
- props: (z = (L = e.cellByColId[t(H).Step]) == null ? void 0 : L.getContext) == null ? void 0 : z.call(L)
534
- }, null, 8, ["render", "props"]),
535
- n[3] || (n[3] = s("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
536
- ])
537
- ])) : oe("", !0),
538
- s("div", os, [
539
- s("div", ls, [
540
- p(g, {
541
- label: t(c)(`inventory.transfer.form.items.table.${t(H).Limit}`)
542
- }, null, 8, ["label"]),
543
- p(t(W), {
544
- render: (B = (M = (O = e.cellByColId[t(H).Limit]) == null ? void 0 : O.column) == null ? void 0 : M.columnDef) == null ? void 0 : B.cell,
545
- props: (w = (q = e.cellByColId[t(H).Limit]) == null ? void 0 : q.getContext) == null ? void 0 : w.call(q)
546
- }, null, 8, ["render", "props"]),
547
- n[4] || (n[4] = s("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
548
- ])
549
- ])
550
- ]);
551
- };
552
- }
553
- }), as = { class: "hover:bg-fm-color-opacity-sm" }, rs = { class: "fm-typo-en-body-md-400 line-clamp-2 w-full" }, is = /* @__PURE__ */ ee({
554
- __name: "TransferTemplateItemTable",
555
- props: {
556
- row: {},
557
- disabled: { type: Boolean }
558
- },
559
- emits: ["update:item"],
560
- setup(m) {
561
- function c(v) {
562
- return v.column.columnDef.meta;
563
- }
564
- return (v, e) => (R(), j("tr", as, [
565
- (R(!0), j(_e, null, ze(v.row.getVisibleCells(), (n) => {
566
- var g, b, i, o, u;
567
- return R(), j("td", {
568
- key: n.id,
569
- class: Z(["text-fm-color-typo-primary", ((g = c(n)) == null ? void 0 : g.cellClass) ?? "px-16"]),
570
- style: He({
571
- width: (b = c(n)) != null && b.width ? (i = c(n)) == null ? void 0 : i.width : n.column.getSize() !== 0 ? `${n.column.getSize()}px` : void 0,
572
- maxWidth: (o = c(n)) == null ? void 0 : o.maxWidth,
573
- textAlign: ((u = c(n)) == null ? void 0 : u.textAlign) ?? "left"
574
- })
575
- }, [
576
- s("span", rs, [
577
- p(t(W), {
578
- props: n.getContext(),
579
- render: n.column.columnDef.cell
580
- }, null, 8, ["props", "render"])
581
- ])
582
- ], 6);
583
- }), 128))
584
- ]));
585
- }
586
- }), us = { class: "flex flex-col gap-16" }, ds = { class: "flex flex-col gap-24" }, ms = { class: "flex flex-col gap-16" }, ps = { class: "flex items-center" }, cs = { class: "flex flex-col" }, fs = { class: "flex flex-col gap-16" }, ys = { class: "flex" }, vs = { class: "flex-1 gap-8 fm-typo-en-title-sm-600" }, bs = /* @__PURE__ */ ee({
587
- __name: "TransferTemplateForm",
588
- props: {
589
- modelValue: {},
590
- disabled: { type: Boolean }
591
- },
592
- setup(m, { expose: c }) {
593
- const v = m, e = Ge(), { t: n } = le(), g = We(), b = Ke(), i = Vt(), o = pe(), u = Xe();
594
- be(
595
- () => v.modelValue,
596
- (l) => {
597
- console.log("TransferTemplateForm.model", l);
598
- }
599
- ), g.watchLocation(async () => {
600
- location && (e.purchaseOrder.supplier || (e.purchaseOrder.supplier = i.suppliers.find((l) => l) ?? e.purchaseOrder.supplier));
601
- }), kt();
602
- const _ = Mt(
603
- () => e.purchaseOrder,
604
- (l) => {
605
- e.purchaseOrder = {
606
- ...e.purchaseOrder,
607
- supplier: l.supplier ?? (e == null ? void 0 : e.purchaseOrder.supplier)
608
- };
609
- }
610
- ), P = U({
611
- get() {
612
- var l, r;
613
- return typeof ((r = (l = e.purchaseOrder) == null ? void 0 : l.supplier) == null ? void 0 : r.internal) == "string" ? K.TRANSFER : K.PURCHASE;
614
- },
615
- set(l) {
616
- var T, F;
617
- const r = typeof ((F = (T = e.purchaseOrder) == null ? void 0 : T.supplier) == null ? void 0 : F.internal) == "string" ? K.TRANSFER : K.PURCHASE;
618
- l !== r && (e.purchaseOrder.supplier = l === K.PURCHASE ? _.locationOptionsTypePurchase.value[0] : _.locationOptionsTypeTransfer.value[0]);
619
- }
620
- }), I = U(() => _.transferLocationOptions.value), h = U({
621
- get() {
622
- var l;
623
- return (l = e.purchaseOrder.supplier) == null ? void 0 : l._id;
624
- },
625
- set(l) {
626
- _.transferLocationModel.value = l;
627
- }
628
- }), {
629
- promptSelectLocations: S,
630
- columnDefs: D,
631
- rowData: G
632
- } = mt({
633
- getLocations() {
634
- return e.locations;
635
- },
636
- setLocations(l) {
637
- e.locations = l;
638
- }
639
- });
640
- function y() {
641
- var l, r;
642
- return (l = e.locations) != null && l.find((T) => {
643
- var F, L;
644
- return ((F = T.doc) == null ? void 0 : F._id) === ((L = e.purchaseOrder.supplier) == null ? void 0 : L._id);
645
- }) ? `Location ${(r = e.purchaseOrder.supplier) == null ? void 0 : r.name} must be removed because template cannot be used to transfer to itself.` : !0;
646
- }
647
- const d = U({
648
- get() {
649
- return e.purchaseOrder.remark ?? void 0;
650
- },
651
- set(l) {
652
- e.purchaseOrder.remark = l;
653
- }
654
- }), k = Q();
655
- c({
656
- validateInputs: () => {
657
- var l, r;
658
- (r = (l = k.value) == null ? void 0 : l.validateInputs) == null || r.call(l);
659
- },
660
- resetInputsValidation: () => {
661
- var l, r;
662
- (r = (l = k.value) == null ? void 0 : l.resetInputsValidation) == null || r.call(l);
663
- },
664
- resetInputs: () => {
665
- var l, r;
666
- (r = (l = k.value) == null ? void 0 : l.resetInputs) == null || r.call(l);
667
- }
668
- });
669
- const a = U(() => ({
670
- duplicateItem: (l) => {
671
- e.purchaseOrder.items = [
672
- ...e.purchaseOrder.items,
673
- {
674
- ...l
675
- }
676
- ];
677
- },
678
- updateItem: (l) => {
679
- let r = [];
680
- l.id ? r = e.purchaseOrder.items.map((T) => T.id !== l.id ? T : l) : r = e.purchaseOrder.items.map((T) => T.sku._id !== l.sku._id ? T : l), e.purchaseOrder.items = r;
681
- },
682
- deleteItem: (l) => {
683
- console.log(l.id);
684
- let r = [];
685
- l.id ? r = e.purchaseOrder.items.filter((T) => T.id !== l.id) : r = e.purchaseOrder.items.filter((T) => T.sku._id !== l.sku._id), e.purchaseOrder.items = r;
686
- }
687
- })), f = Qt({
688
- duplicateItem: a.value.duplicateItem,
689
- updateItem: a.value.updateItem,
690
- deleteItem: a.value.deleteItem,
691
- get supplier() {
692
- return e.purchaseOrder.supplier;
693
- },
694
- get items() {
695
- return e.purchaseOrder.items;
696
- },
697
- get transferType() {
698
- return K.PURCHASE;
699
- },
700
- get disabled() {
701
- return v.disabled;
702
- }
703
- }), C = U(() => f.columnDefs.value), { promptSelectIngredients: $ } = Rt();
704
- async function x() {
705
- const r = b.skus.map((O) => ({
706
- label: O.name,
707
- sublabel: O.code,
708
- value: O
709
- })).filter((O) => {
710
- var M;
711
- return (M = e.purchaseOrder.items) == null ? void 0 : M.find((B) => B.sku._id === O.value._id);
712
- }).map((O) => O.value), T = e.purchaseOrder.items ?? [], F = await $(
713
- r.map((O) => O._id),
714
- (O) => {
715
- const M = b.skuById[O], B = T.find((E) => E.sku._id === M._id);
716
- if (B)
717
- return B;
718
- const q = { amount: 1, precision: me(M.unit) };
719
- let w = {
720
- id: o.usePurchaseOrderV2 ? crypto.randomUUID() : void 0,
721
- sku: M,
722
- code: M.code,
723
- name: M.name,
724
- quantity: q,
725
- minimumQuantity: q,
726
- // maximumQuantity: adjustmentAmountMultiplyDecimal(minimumQuantity, {
727
- // amount: 100,
728
- // precision: 0
729
- // }),
730
- quantityStep: q
731
- };
732
- return u.validateUnitInput(
733
- w,
734
- M,
735
- {
736
- amount: q,
737
- measurement: null
738
- },
739
- (E) => {
740
- w.code = E.code;
741
- }
742
- ), w;
743
- }
744
- );
745
- if (!F) return;
746
- const L = F.map((O) => O.sku._id), z = [];
747
- for (const O of L) {
748
- const M = T.filter((B) => B.sku._id === O);
749
- if (M.length > 0)
750
- z.push(...M);
751
- else {
752
- const B = F.find((q) => q.sku._id === O);
753
- B && z.push(B);
754
- }
755
- }
756
- z.sort((O, M) => O.sku.code.localeCompare(M.sku.code)), e.purchaseOrder.items = z;
757
- }
758
- return (l, r) => {
759
- const T = A("FmTextField"), F = A("FmSelect"), L = A("FmTextarea"), z = A("FmButton"), O = A("FmTable"), M = A("FmFormGroup"), B = A("FmForm");
760
- return R(), X(B, {
761
- ref_key: "formRef",
762
- ref: k,
763
- class: "flex flex-col gap-32",
764
- disabled: l.disabled
765
- }, {
766
- default: N(() => {
767
- var q;
768
- return [
769
- s("div", us, [
770
- s("div", ds, [
771
- p(T, {
772
- label: t(n)("inventory.transfer.form.name"),
773
- "label-mark": "required",
774
- modelValue: t(e).name,
775
- "onUpdate:modelValue": r[0] || (r[0] = (w) => t(e).name = w),
776
- rules: [t(fe)()]
777
- }, null, 8, ["label", "modelValue", "rules"]),
778
- p(F, {
779
- label: t(n)("inventory.transfer.form.type.title"),
780
- "model-value": P.value,
781
- "onUpdate:modelValue": r[1] || (r[1] = (w) => P.value = w),
782
- items: [
783
- {
784
- label: t(n)("inventory.transfer.form.type.purchase"),
785
- value: t(K).PURCHASE,
786
- disabled: !t(_).locationOptionsTypePurchase.value.length,
787
- sublabel: t(_).locationOptionsTypePurchase.value.length ? void 0 : t(n)("inventory.transfer.form.noSupplierAvailable")
788
- },
789
- {
790
- label: t(n)("inventory.transfer.form.type.transfer"),
791
- value: t(K).TRANSFER,
792
- disabled: !t(_).locationOptionsTypeTransfer.value.length,
793
- sublabel: t(_).locationOptionsTypeTransfer.value.length ? void 0 : t(n)("inventory.transfer.form.noLocationAvailable")
794
- }
795
- ],
796
- rules: [t(ye)(1)(I.value)]
797
- }, {
798
- default: N(() => [
799
- s("span", {
800
- class: Z([
801
- "line-clamp-1 fm-typo-en-body-lg-400",
802
- l.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-typo-primary"
803
- ])
804
- }, V(t(pt)(P.value)), 3)
805
- ]),
806
- _: 1
807
- }, 8, ["label", "model-value", "items", "rules"]),
808
- p(F, {
809
- label: P.value === t(K).PURCHASE ? t(n)("inventory.transfer.form.purchaseFrom") : t(n)("inventory.transfer.form.transferFrom"),
810
- modelValue: h.value,
811
- "onUpdate:modelValue": r[2] || (r[2] = (w) => h.value = w),
812
- items: I.value
813
- }, {
814
- "menu-wrapper": N((w) => {
815
- var E;
816
- return [
817
- p(Dt, Qe(w, {
818
- items: I.value,
819
- "model-value": (E = l.modelValue.purchaseOrder.supplier) == null ? void 0 : E._id
820
- }), null, 16, ["items", "model-value"])
821
- ];
822
- }),
823
- default: N(() => {
824
- var w;
825
- return [
826
- s("span", {
827
- class: Z([
828
- "line-clamp-1 fm-typo-en-body-lg-400",
829
- l.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-typo-primary"
830
- ])
831
- }, V((w = I.value.find((E) => E.value === h.value)) == null ? void 0 : w.label), 3)
832
- ];
833
- }),
834
- _: 1
835
- }, 8, ["label", "modelValue", "items"]),
836
- p(T, {
837
- label: t(n)("inventory.transfer.form.reference"),
838
- "label-mark": "optional",
839
- modelValue: t(e).purchaseOrder.ref,
840
- "onUpdate:modelValue": r[3] || (r[3] = (w) => t(e).purchaseOrder.ref = w)
841
- }, null, 8, ["label", "modelValue"]),
842
- p(L, {
843
- label: t(n)("inventory.transfer.form.remark"),
844
- "label-mark": "optional",
845
- "max-length": 240,
846
- modelValue: d.value,
847
- "onUpdate:modelValue": r[4] || (r[4] = (w) => d.value = w),
848
- class: Z({ "text-fm-color-typo-disabled": l.disabled })
849
- }, null, 8, ["label", "modelValue", "class"])
850
- ])
851
- ]),
852
- s("div", ms, [
853
- s("div", ps, [
854
- r[8] || (r[8] = s("div", { class: "flex-1 fm-typo-en-title-sm-600" }, "Locations", -1)),
855
- p(z, {
856
- disabled: l.disabled,
857
- label: "Select location",
858
- "prepend-icon": "add",
859
- variant: "plain",
860
- class: "border-2 rounded-lg border-fm-color-primary",
861
- onClick: t(S)
862
- }, null, 8, ["disabled", "onClick"])
863
- ]),
864
- p(O, {
865
- "column-defs": t(D),
866
- "row-data": t(G),
867
- "shrink-at": 9999,
868
- onRowClick: t(S),
869
- "hide-footer": ""
870
- }, null, 8, ["column-defs", "row-data", "onRowClick"]),
871
- s("div", cs, [
872
- p(M, {
873
- "model-value": [
874
- (q = v.modelValue.purchaseOrder.supplier) == null ? void 0 : q._id,
875
- ...v.modelValue.locations ?? []
876
- ].join(","),
877
- rules: [y]
878
- }, null, 8, ["model-value", "rules"])
879
- ])
880
- ]),
881
- s("div", fs, [
882
- s("div", ys, [
883
- s("div", vs, V(t(n)("inventory.transfer.form.items.title")), 1),
884
- p(z, {
885
- disabled: l.disabled,
886
- label: t(n)("inventory.transfer.form.items.addItem"),
887
- "prepend-icon": "add",
888
- variant: "plain",
889
- class: "border-2 rounded-lg border-fm-color-primary",
890
- onClick: r[5] || (r[5] = (w) => x()),
891
- size: "md"
892
- }, null, 8, ["disabled", "label"])
893
- ]),
894
- (R(), X(O, {
895
- "column-defs": C.value,
896
- "row-data": t(e).purchaseOrder.items,
897
- key: t(e).purchaseOrder.items.map((w) => w.sku._id).join("."),
898
- "hide-footer": "",
899
- "page-size": t(e).purchaseOrder.items.length
900
- }, {
901
- "table-row": N((w) => [
902
- p(is, {
903
- row: w,
904
- "onUpdate:item": r[6] || (r[6] = (E) => a.value.updateItem(E)),
905
- disabled: l.disabled
906
- }, null, 8, ["row", "disabled"])
907
- ]),
908
- "list-row": N((w) => [
909
- (R(), X(Ye, {
910
- row: w,
911
- key: t(e).purchaseOrder.items.map((E) => E.sku._id).join(".")
912
- }, {
913
- default: N((E) => [
914
- p(ns, {
915
- row: w,
916
- "cell-by-col-id": E,
917
- "onUpdate:item": r[7] || (r[7] = (te) => a.value.updateItem(te)),
918
- disabled: l.disabled
919
- }, null, 8, ["row", "cell-by-col-id", "disabled"])
920
- ]),
921
- _: 2
922
- }, 1032, ["row"]))
923
- ]),
924
- _: 1
925
- }, 8, ["column-defs", "row-data", "page-size"])),
926
- p(M, {
927
- "model-value": t(e).purchaseOrder.items.length,
928
- rules: [t(ye)(1)]
929
- }, null, 8, ["model-value", "rules"])
930
- ])
931
- ];
932
- }),
933
- _: 1
934
- }, 8, ["disabled"]);
935
- };
936
- }
937
- }), _s = { class: "flex items-center" }, hs = { class: "fm-typo-en-title-md-800" }, xs = { class: "flex gap-4" }, gs = /* @__PURE__ */ ee({
938
- __name: "TransferTemplateDialog",
939
- props: {
940
- mode: {},
941
- modelValue: {},
942
- show: { type: Boolean }
943
- },
944
- emits: ["update:show", "submitted"],
945
- setup(m, { expose: c, emit: v }) {
946
- var k;
947
- const e = m, n = v, g = _t(), b = Tt(), { t: i } = le(), o = Je(e, "show");
948
- function u() {
949
- return {
950
- _id: "",
951
- name: "",
952
- purchaseOrder: {
953
- remark: void 0,
954
- ref: void 0,
955
- items: [],
956
- supplier: {
957
- _rev: void 0,
958
- email: void 0,
959
- internal: void 0,
960
- contactName: void 0,
961
- phoneNumber: void 0,
962
- registrationNumber: void 0,
963
- supplyItems: void 0,
964
- _id: "",
965
- name: "",
966
- address: {
967
- line2: void 0,
968
- line1: "",
969
- state: "",
970
- city: "",
971
- postcode: "",
972
- country: ""
973
- }
974
- }
975
- }
976
- };
977
- }
978
- const _ = Q(e.modelValue ?? u()), P = Q(((k = e.modelValue) == null ? void 0 : k._id) ?? `${Math.random()}`);
979
- be(
980
- () => e.show,
981
- (a) => {
982
- var f;
983
- a && (_.value = e.modelValue ?? u(), P.value = ((f = e.modelValue) == null ? void 0 : f._id) ?? `${Math.random()}`);
984
- }
985
- );
986
- const I = Q(!1), h = U(() => {
987
- switch (e.mode) {
988
- case ne.READ:
989
- return "";
990
- case ne.CREATE:
991
- return i("inventory.transfer.template.create.title");
992
- case ne.UPDATE:
993
- return i("inventory.transfer.template.update.title");
994
- }
995
- return "";
996
- }), S = Q();
997
- c({
998
- validateInputs: () => {
999
- var a, f;
1000
- (f = (a = S.value) == null ? void 0 : a.validateInputs) == null || f.call(a);
1001
- },
1002
- resetInputsValidation: () => {
1003
- var a, f;
1004
- (f = (a = S.value) == null ? void 0 : a.resetInputsValidation) == null || f.call(a);
1005
- },
1006
- resetInputs: () => {
1007
- var a, f;
1008
- (f = (a = S.value) == null ? void 0 : a.resetInputs) == null || f.call(a);
1009
- }
1010
- });
1011
- async function D() {
1012
- var f, C;
1013
- const a = _.value;
1014
- if (a) {
1015
- I.value = !0, (((f = a.purchaseOrder.supplier) == null ? void 0 : f.internal) === de.enum.warehouse || ((C = a.purchaseOrder.supplier) == null ? void 0 : C.internal) === de.enum.restaurant) && (a.purchaseOrder.items = a.purchaseOrder.items.map(
1016
- ({ totalCost: $, ...x }) => x
1017
- ));
1018
- try {
1019
- await g.createTemplate(a), await new Promise(($) => setTimeout($, 1e3)), b.open({
1020
- title: i("inventory.transfer.template.create.success"),
1021
- message: i("inventory.transfer.template.create.successMessage"),
1022
- type: "success"
1023
- }), n("update:show", !1), n("submitted");
1024
- } catch ($) {
1025
- b.open({
1026
- title: i("inventory.transfer.template.create.error"),
1027
- message: i("inventory.transfer.template.create.errorMessage"),
1028
- type: "error"
1029
- }), console.error("Error in creating transfer template", $);
1030
- } finally {
1031
- I.value = !1;
1032
- }
1033
- }
1034
- }
1035
- async function G() {
1036
- var f, C;
1037
- const a = _.value;
1038
- if (a) {
1039
- I.value = !0, (((f = a.purchaseOrder.supplier) == null ? void 0 : f.internal) === de.enum.warehouse || ((C = a.purchaseOrder.supplier) == null ? void 0 : C.internal) === de.enum.restaurant) && (a.purchaseOrder.items = a.purchaseOrder.items.map(
1040
- ({ totalCost: $, ...x }) => x
1041
- ));
1042
- try {
1043
- await g.updateTemplate(a), await new Promise(($) => setTimeout($, 1e3)), b.open({
1044
- title: i("inventory.transfer.template.update.success"),
1045
- message: i("inventory.transfer.template.update.successMessage"),
1046
- type: "success"
1047
- }), n("update:show", !1), n("submitted");
1048
- } catch ($) {
1049
- b.open({
1050
- title: i("inventory.transfer.template.update.error"),
1051
- message: i("inventory.transfer.template.update.errorMessage"),
1052
- type: "error"
1053
- }), console.error("Error in updating transfer template", $);
1054
- } finally {
1055
- I.value = !1;
1056
- }
1057
- }
1058
- }
1059
- function y() {
1060
- switch (e.mode) {
1061
- case ne.CREATE:
1062
- return D();
1063
- case ne.UPDATE:
1064
- return G();
1065
- }
1066
- }
1067
- function d() {
1068
- var a, f;
1069
- (f = (a = S.value) == null ? void 0 : a.validateInputs) == null || f.call(a);
1070
- }
1071
- return (a, f) => {
1072
- const C = A("FmButton"), $ = A("FmSideSheet");
1073
- return R(), X($, {
1074
- modelValue: t(o),
1075
- "onUpdate:modelValue": f[2] || (f[2] = (x) => je(o) ? o.value = x : null),
1076
- "dismiss-away": "",
1077
- "close-button": "",
1078
- "max-width": 1200
1079
- }, {
1080
- "side-sheet-header": N(() => [
1081
- s("div", _s, [
1082
- s("div", hs, V(h.value), 1)
1083
- ])
1084
- ]),
1085
- default: N(() => [
1086
- (R(), X(bs, {
1087
- class: "w-full",
1088
- ref_key: "formRef",
1089
- ref: S,
1090
- onValidationSuccess: y,
1091
- "model-value": _.value,
1092
- "onUpdate:modelValue": f[0] || (f[0] = (x) => _.value = x),
1093
- disabled: I.value,
1094
- key: P.value
1095
- }, null, 8, ["model-value", "disabled"]))
1096
- ]),
1097
- "side-sheet-footer": N(() => [
1098
- s("div", xs, [
1099
- p(C, {
1100
- loading: I.value,
1101
- label: t(i)("common.save"),
1102
- onClick: d
1103
- }, null, 8, ["loading", "label"]),
1104
- p(C, {
1105
- disabled: I.value,
1106
- variant: "tertiary",
1107
- label: t(i)("common.close"),
1108
- onClick: f[1] || (f[1] = (x) => n("update:show", !1))
1109
- }, null, 8, ["disabled", "label"])
1110
- ])
1111
- ]),
1112
- _: 1
1113
- }, 8, ["modelValue"]);
1114
- };
1115
- }
1116
- }), ks = { class: "flex flex-col gap-16 w-full h-full overflow-y-auto" }, Ts = { class: "flex justify-between" }, ws = { class: "fm-typo-en-body-lg-600" }, Fs = { class: "fm-status-badge fm-status-badge-info-secondary" }, Is = { class: "flex flex-col gap-8" }, Ss = { class: "flex flex-col gap-4" }, Cs = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, $s = { class: "flex gap-1" }, Os = { class: "fm-typo-en-body-lg-600" }, Ms = {
1117
- key: 0,
1118
- class: "flex flex-col gap-4"
1119
- }, Ds = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Vs = { class: "fm-typo-en-body-lg-600" }, Rs = {
1120
- key: 1,
1121
- class: "flex flex-col gap-4"
1122
- }, As = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Ps = { class: "fm-typo-en-body-lg-600" }, Us = {
1123
- key: 2,
1124
- class: "flex flex-col gap-4"
1125
- }, Ls = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Bs = { class: "fm-typo-en-body-lg-600" }, qs = { class: "border border-fm-color-neutral-gray-200 fm-corner-radius-lg p-16" }, Es = { class: "flex flex-col gap-8" }, Ns = { class: "fm-typo-en-body-lg-600" }, zs = { class: "flex w-full gap-4" }, Hs = { class: "grow fm-typo-en-body-lg-400 line-clamp-2" }, Qs = { class: "fm-typo-en-body-lg-600 shrink-0" }, js = { class: "flex w-full gap-4 fm-typo-en-body-sm-400" }, Gs = { class: "grow fm-typo-en-body-lg-400 text-fm-color-typo-secondary line-clamp-2" }, Ks = {
1126
- key: 0,
1127
- class: "shrink-0 fm-typo-en-body-lg-400 text-fm-color-typo-secondary"
1128
- }, Ws = {
1129
- key: 0,
1130
- class: "flex gap-4 items-center"
1131
- }, Ys = { class: "flex flex-col gap-12" }, Js = { class: "flex flex-col gap-8" }, Xs = { class: "flex gap-8 xs:flex-col" }, Zs = /* @__PURE__ */ ee({
1132
- __name: "TransferTemplateDetails",
1133
- props: {
1134
- template: {},
1135
- show: { type: Boolean }
1136
- },
1137
- emits: ["update:show", "action:edit"],
1138
- setup(m, { emit: c }) {
1139
- const v = m, e = c, n = pe(), { t: g } = le(), b = U(() => {
1140
- var I;
1141
- return (I = v.template) == null ? void 0 : I.purchaseOrder;
1142
- }), i = [
1143
- { accessorKey: "name", header: () => "Name" },
1144
- { accessorKey: "type", header: () => "Type" }
1145
- ], o = Q(""), u = U(
1146
- () => {
1147
- var I, h, S, D;
1148
- return ((h = (I = b.value) == null ? void 0 : I.supplier) == null ? void 0 : h.internal) === "restaurant" || ((D = (S = b.value) == null ? void 0 : S.supplier) == null ? void 0 : D.internal) === "warehouse" ? K.TRANSFER : K.PURCHASE;
1149
- }
1150
- ), _ = Q(!0), P = Je(v, "show");
1151
- return (I, h) => {
1152
- var f;
1153
- const S = A("FmMenuDivider"), D = A("FmCard"), G = A("FmIcon"), y = A("FmTextField"), d = A("FmTable"), k = A("FmButton"), a = A("FmSideSheet");
1154
- return R(), X(a, {
1155
- header: t(g)("inventory.transfer.template.details.view", { template: (f = I.template) == null ? void 0 : f.name }),
1156
- modelValue: t(P),
1157
- "onUpdate:modelValue": h[2] || (h[2] = (C) => je(P) ? P.value = C : null),
1158
- "dismiss-away": _.value,
1159
- "close-button": "",
1160
- "max-width": 500
1161
- }, {
1162
- default: N(() => {
1163
- var C, $;
1164
- return [
1165
- s("div", ks, [
1166
- s("div", null, [
1167
- p(D, {
1168
- variant: "outlined",
1169
- class: "flex flex-col gap-8 px-12 py-16"
1170
- }, {
1171
- default: N(() => {
1172
- var x, l, r, T, F, L, z;
1173
- return [
1174
- s("div", Ts, [
1175
- s("div", ws, V(t(g)("inventory.transfer.template.details.templateSummary")), 1),
1176
- s("div", Fs, V(t(g)(
1177
- `inventory.transfer.receiveRequest.details.type.${u.value.toLocaleLowerCase("en-US")}`
1178
- )), 1)
1179
- ]),
1180
- p(S),
1181
- s("div", Is, [
1182
- s("div", Ss, [
1183
- s("div", Cs, [
1184
- s("div", $s, V(t(g)("inventory.transfer.receiveRequest.details.createdAt")), 1)
1185
- ]),
1186
- s("div", Os, V(t(ct)(((x = I.template) == null ? void 0 : x._id) ?? "")), 1)
1187
- ]),
1188
- (r = (l = b.value) == null ? void 0 : l.supplier) != null && r.name ? (R(), j("div", Ms, [
1189
- s("div", Ds, V(t(g)("inventory.transfer.receiveRequest.details.from")), 1),
1190
- s("div", Vs, V((F = (T = b.value) == null ? void 0 : T.supplier) == null ? void 0 : F.name), 1)
1191
- ])) : oe("", !0),
1192
- (L = b.value) != null && L.ref ? (R(), j("div", Rs, [
1193
- s("div", As, V(t(g)("inventory.transfer.receiveRequest.details.reference")), 1),
1194
- s("div", Ps, V(b.value.ref), 1)
1195
- ])) : oe("", !0),
1196
- (z = b.value) != null && z.remark ? (R(), j("div", Us, [
1197
- s("div", Ls, V(t(g)("inventory.transfer.receiveRequest.details.remark")), 1),
1198
- s("div", Bs, V(b.value.remark), 1)
1199
- ])) : oe("", !0)
1200
- ])
1201
- ];
1202
- }),
1203
- _: 1
1204
- })
1205
- ]),
1206
- s("div", qs, [
1207
- s("div", Es, [
1208
- s("div", Ns, V(t(g)("inventory.transfer.receiveRequest.details.requestedItems")), 1),
1209
- (R(!0), j(_e, null, ze(((C = b.value) == null ? void 0 : C.items) ?? [], (x) => (R(), j("div", {
1210
- key: x.code,
1211
- class: "flex flex-col"
1212
- }, [
1213
- s("div", zs, [
1214
- s("div", Hs, V(x.name), 1),
1215
- h[3] || (h[3] = s("div", { class: "flex-1 min-w-32" }, null, -1)),
1216
- s("div", Qs, V(t(ht)(x.quantity, x.sku.unit, x.measurement)), 1)
1217
- ]),
1218
- s("div", js, [
1219
- s("div", Gs, V(x.code), 1),
1220
- x.totalCost && t(n).enableTotalCost ? (R(), j("div", Ks, " (" + V(t(ft)(x.totalCost)) + ") ", 1)) : oe("", !0)
1221
- ]),
1222
- t(xt)(x) ? (R(), j("div", Ws, [
1223
- p(G, {
1224
- name: "error",
1225
- color: "system-error-300",
1226
- size: "sm"
1227
- }),
1228
- h[4] || (h[4] = s("div", { class: "fm-typo-en-body-sm-400 text-fm-color-system-error-400" }, " This item has invalid unit configuration. Apply update on this item. ", -1))
1229
- ])) : oe("", !0)
1230
- ]))), 128))
1231
- ])
1232
- ]),
1233
- h[6] || (h[6] = s("div", null, null, -1)),
1234
- h[7] || (h[7] = s("div", null, null, -1)),
1235
- s("div", Ys, [
1236
- h[5] || (h[5] = s("div", { class: "flex flex-col" }, [
1237
- s("div", { class: "fm-typo-en-body-lg-600" }, "Enabled locations"),
1238
- s("div", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " This template is only usable for the following locations. ")
1239
- ], -1)),
1240
- s("div", Js, [
1241
- p(y, {
1242
- modelValue: o.value,
1243
- "onUpdate:modelValue": h[0] || (h[0] = (x) => o.value = x),
1244
- placeholder: "Filter locations",
1245
- "prepend-icon": "search"
1246
- }, null, 8, ["modelValue"]),
1247
- p(d, {
1248
- "hide-footer": "",
1249
- style: { height: "500px" },
1250
- "column-defs": i,
1251
- "search-value": o.value,
1252
- "row-data": (($ = v.template) == null ? void 0 : $.locations) ?? [{ name: "All locations" }]
1253
- }, null, 8, ["search-value", "row-data"])
1254
- ])
1255
- ])
1256
- ])
1257
- ];
1258
- }),
1259
- "side-sheet-footer": N(() => [
1260
- s("div", Xs, [
1261
- p(k, {
1262
- label: t(g)("common.edit"),
1263
- onClick: h[1] || (h[1] = (C) => e("action:edit")),
1264
- variant: "tertiary"
1265
- }, null, 8, ["label"])
1266
- ])
1267
- ]),
1268
- _: 1
1269
- }, 8, ["header", "modelValue", "dismiss-away"]);
1270
- };
1271
- }
1272
- }), eo = { class: "flex-1 flex flex-col gap-8" }, to = { class: "flex flex-col" }, so = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, oo = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, lo = { class: "fm-typo-en-body-lg-400" }, no = { class: "fm-typo-en-body-lg-400 line-clamp-1" }, ao = { class: "fm-typo-en-body-lg-400 line-clamp-2" }, ho = /* @__PURE__ */ ee({
1273
- __name: "TransferTemplateView",
1274
- setup(m) {
1275
- const { t: c } = le(), { createTemplate: v, viewTemplate: e, importTemplates: n, exportTemplates: g } = qe(), { templateDialogProps: b, templateDetailsProps: i } = Ee(qe()), o = gt(), { loading: u, templates: _ } = Ee(o), P = Q(!1), I = yt(), h = We(), { breakpoints: S } = wt();
1276
- ve(o.fetchTemplates);
1277
- const D = U(
1278
- () => P.value || u.value || !h._currentLocation
1279
- ), G = U(() => _.value), y = Q(""), d = U(() => S.value.xs || S.value.sm), k = U(() => d.value ? 10 : 20);
1280
- function a($) {
1281
- switch ($) {
1282
- case Be.Add:
1283
- return v();
1284
- case "refresh":
1285
- return o.fetchTemplates();
1286
- case "import":
1287
- return n();
1288
- case "export":
1289
- return g();
1290
- }
1291
- }
1292
- function f($) {
1293
- return $;
1294
- }
1295
- const C = U(() => [
1296
- {
1297
- label: c("inventory.closing.template.create.title"),
1298
- value: Be.Add,
1299
- isPrimary: !0,
1300
- prependIcon: "add"
1301
- },
1302
- {
1303
- label: c("inventory.common.refresh"),
1304
- value: "refresh",
1305
- isPrimary: !1
1306
- },
1307
- {
1308
- label: c("inventory.common.import"),
1309
- value: "import",
1310
- isPrimary: !1
1311
- },
1312
- {
1313
- label: c("inventory.common.export"),
1314
- value: "export",
1315
- isPrimary: !1
1316
- }
1317
- ]);
1318
- return ($, x) => {
1319
- const l = A("FmTable");
1320
- return R(), j(_e, null, [
1321
- p(vt, {
1322
- title: t(c)("inventory.transfer.template.title2"),
1323
- actions: C.value,
1324
- "onClick:action": a
1325
- }, {
1326
- default: N(() => {
1327
- var r;
1328
- return [
1329
- s("div", {
1330
- class: Z([
1331
- "flex flex-col gap-8 max-h-full",
1332
- {
1333
- "p-0": d.value,
1334
- "px-24 ": !d.value
1335
- }
1336
- ])
1337
- }, [
1338
- p(bt, {
1339
- searchable: "",
1340
- search: y.value,
1341
- "onUpdate:search": x[0] || (x[0] = (T) => y.value = T)
1342
- }, null, 8, ["search"]),
1343
- (R(), X(l, {
1344
- style: He(t(I).tableHeight),
1345
- "column-defs": t(o).columnDefs,
1346
- "row-data": G.value,
1347
- "search-value": y.value,
1348
- loading: D.value,
1349
- key: (r = t(h)._currentLocation) == null ? void 0 : r.dbName,
1350
- onRowClick: x[1] || (x[1] = (T) => t(e)(T.original)),
1351
- "page-size": k.value
1352
- }, {
1353
- "list-row": N((T) => [
1354
- p(Ye, {
1355
- row: T,
1356
- onRowClick: (F) => t(e)(F)
1357
- }, {
1358
- default: N((F) => {
1359
- var L, z, O, M, B, q, w, E, te, he, xe, ge, ke, ae, Te, we, Fe, Ie, Se, Ce, re, $e, Oe, Me, De, ie, Ve;
1360
- return [
1361
- s("div", eo, [
1362
- s("div", to, [
1363
- s("div", so, [
1364
- p(t(W), {
1365
- render: (O = (z = (L = F._id) == null ? void 0 : L.column) == null ? void 0 : z.columnDef) == null ? void 0 : O.cell,
1366
- props: (B = (M = F._id) == null ? void 0 : M.getContext) == null ? void 0 : B.call(M)
1367
- }, null, 8, ["render", "props"])
1368
- ]),
1369
- s("div", oo, [
1370
- p(t(W), {
1371
- render: (E = (w = (q = F.name) == null ? void 0 : q.column) == null ? void 0 : w.columnDef) == null ? void 0 : E.cell,
1372
- props: (he = (te = F.name) == null ? void 0 : te.getContext) == null ? void 0 : he.call(te)
1373
- }, null, 8, ["render", "props"])
1374
- ]),
1375
- s("div", lo, [
1376
- p(t(W), {
1377
- render: (ke = (ge = (xe = F.supplier) == null ? void 0 : xe.column) == null ? void 0 : ge.columnDef) == null ? void 0 : ke.cell,
1378
- props: (Te = (ae = F.supplier) == null ? void 0 : ae.getContext) == null ? void 0 : Te.call(ae)
1379
- }, null, 8, ["render", "props"])
1380
- ]),
1381
- s("div", null, V((we = T.original.locations) != null && we.length ? `Enabled for ${(Fe = T.original.locations) == null ? void 0 : Fe.length} outlets` : "Enabled for all outlets"), 1),
1382
- s("div", no, V(T.original.purchaseOrder.items.length ? T.original.purchaseOrder.items.map((Ze) => Ze.name).join(", ") : "No items"), 1),
1383
- s("div", ao, [
1384
- p(t(W), {
1385
- render: (Ce = (Se = (Ie = F.ref) == null ? void 0 : Ie.column) == null ? void 0 : Se.columnDef) == null ? void 0 : Ce.cell,
1386
- props: ($e = (re = F.ref) == null ? void 0 : re.getContext) == null ? void 0 : $e.call(re)
1387
- }, null, 8, ["render", "props"])
1388
- ])
1389
- ]),
1390
- s("div", null, [
1391
- p(t(W), {
1392
- render: (De = (Me = (Oe = F.type) == null ? void 0 : Oe.column) == null ? void 0 : Me.columnDef) == null ? void 0 : De.cell,
1393
- props: (Ve = (ie = F.type) == null ? void 0 : ie.getContext) == null ? void 0 : Ve.call(ie)
1394
- }, null, 8, ["render", "props"])
1395
- ])
1396
- ])
1397
- ];
1398
- }),
1399
- _: 2
1400
- }, 1032, ["row", "onRowClick"])
1401
- ]),
1402
- _: 1
1403
- }, 8, ["style", "column-defs", "row-data", "search-value", "loading", "page-size"]))
1404
- ], 2)
1405
- ];
1406
- }),
1407
- _: 1
1408
- }, 8, ["title", "actions"]),
1409
- (R(), X(st, { to: "body" }, [
1410
- p(Zs, ot(lt(t(i))), null, 16),
1411
- p(gs, Qe(t(b), {
1412
- onSubmitted: x[2] || (x[2] = (r) => t(o).fetchTemplates())
1413
- }), null, 16)
1414
- ]))
1415
- ], 64);
1416
- };
1417
- }
1418
- });
1419
- export {
1420
- ho as default
1421
- };