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