@feedmepos/mf-inventory-portal 0.0.23-dev.9 → 0.0.24-dev.1

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