@feedmepos/mf-inventory-portal 0.0.23-dev.28 → 0.0.23-dev.3

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