@feedmepos/mf-inventory-portal 0.0.23-dev.4 → 0.0.23-dev.41

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