@feedmepos/mf-inventory-portal 0.0.25-dev.3 → 0.0.25-dev.30

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 (121) hide show
  1. package/dist/App-CbGTNGMK.js +280 -0
  2. package/dist/ApprovalView-C9hrKiel.js +146 -0
  3. package/dist/{BindingsDialog-DPvBW5cM.js → BindingsDialog-DIxrUmBp.js} +6 -6
  4. package/dist/{BindingsPicker-DHjUZp_W.js → BindingsPicker-DT2fCUQ7.js} +3 -3
  5. package/dist/{BindingsTable-D29VX7KG.js → BindingsTable-rpRrfxfm.js} +6 -6
  6. package/dist/ClosingDraftView-aETdobNv.js +1340 -0
  7. package/dist/ClosingTemplateView-Cl-7Agfl.js +1859 -0
  8. package/dist/FmCustomAttribute.vue_vue_type_script_setup_true_lang-D-IWRjRD.js +34 -0
  9. package/dist/FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-Ugss5lqQ.js +215 -0
  10. package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-DLVeADwI.js → FmUnitInput.vue_vue_type_script_setup_true_lang-BZoFs1-5.js} +52 -52
  11. package/dist/IngredientBindedItem.vue_vue_type_script_setup_true_lang-uRrJNVoO.js +51 -0
  12. package/dist/{IngredientGroupView-BZGkNkrt.js → IngredientGroupView-DCtkP28-.js} +1 -1
  13. package/dist/{IngredientsView-V_vDYAho.js → IngredientsView-C4jOCqij.js} +394 -382
  14. package/dist/{IntegrationView-CK_4s6nJ.js → IntegrationView-DDAVjLV5.js} +660 -623
  15. package/dist/{InventoryBindingForm-CAWQBqr1.js → InventoryBindingForm-CbM-0GcS.js} +1 -1
  16. package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-BDWmhU7C.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-uGVP8nwi.js} +99 -99
  17. package/dist/{InventoryBindingSummary-BBppQstd.js → InventoryBindingSummary-DOdGKen4.js} +1 -1
  18. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-e54jzd1P.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-CBu3pj-m.js} +1 -1
  19. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-DKUl-kuR.js → PremiumBadge.vue_vue_type_script_setup_true_lang-BPmKDzxI.js} +15 -15
  20. package/dist/PublishView-BE8Fo2Go.js +222 -0
  21. package/dist/{PurchaseOrderPrintPreview-DiDSTpNu.js → PurchaseOrderPrintPreview-DBEfp8uZ.js} +1 -1
  22. package/dist/ReceiveRequestView-BmrpIRSM.js +2895 -0
  23. package/dist/{RecipeView-DmYWjO2j.js → RecipeView-DTFpgZwH.js} +32 -31
  24. package/dist/{index-CBXvWfSg.js → StockView-CF7VlY8S.js} +3577 -1764
  25. package/dist/{SupplierView-DKISIdqs.js → SupplierView-BZ4rA2D1.js} +12 -11
  26. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-CidXuoBS.js +1831 -0
  27. package/dist/TransferTemplateView-C7bYJLit.js +1660 -0
  28. package/dist/{UnitView-CvUayQQ1.js → UnitView-1lzQaH5U.js} +14 -14
  29. package/dist/{WarehouseView-IoiXm1I8.js → WarehouseView-eRypQalS.js} +332 -314
  30. package/dist/api/closing-draft.d.ts +1 -0
  31. package/dist/api/inventory.d.ts +9 -6
  32. package/dist/api/netsuite.d.ts +17 -0
  33. package/dist/api/purchase-order.d.ts +3 -1
  34. package/dist/{app-CX6n1ion.js → app-d94DuF5R.js} +28901 -28676
  35. package/dist/app.js +1 -1
  36. package/dist/components/FmAutocompleteTextField.vue.d.ts +31 -0
  37. package/dist/components/FmCustomAttribute.vue.d.ts +3 -8
  38. package/dist/components/FmLockableField.vue.d.ts +3 -0
  39. package/dist/components/FmMultiselectDialog.d.ts +46 -0
  40. package/dist/components/FmMultiselectDialog.vue.d.ts +20 -3
  41. package/dist/components/FmMultiselectDialogProps.d.ts +2 -0
  42. package/dist/components/MountListener.vue.d.ts +15 -0
  43. package/dist/components/inventory-binding/InventoryBinding.vue.d.ts +1 -1
  44. package/dist/components/shell/inventory/binding-ui.vue.d.ts +1 -1
  45. package/dist/{decimal-CWOfT2lu.js → decimal-BCeq_89w.js} +1 -1
  46. package/dist/feature-BiSY0JBR.js +1011 -0
  47. package/dist/{format-unit-display-9aWRoLgP.js → format-unit-display-x2P1kVbK.js} +334 -327
  48. package/dist/helper/fuzzy.d.ts +10 -0
  49. package/dist/index-DnkQqb_5.js +35546 -0
  50. package/dist/{stock-C2QEA4Bf.js → stock-BHtAAvq5.js} +3 -3
  51. package/dist/stores/feature.d.ts +7 -7
  52. package/dist/stores/integration/netsuite.d.ts +22 -0
  53. package/dist/stores/inventory.d.ts +135 -8
  54. package/dist/stores/location.d.ts +100 -0
  55. package/dist/stores/warehouse.d.ts +1 -0
  56. package/dist/style.css +1 -1
  57. package/dist/{supplier-DNuzB_6-.js → supplier-BSiJWxYO.js} +1 -1
  58. package/dist/tsconfig.app.tsbuildinfo +1 -1
  59. package/dist/use-ingredient-select-dialog-CvsCbtLc.js +51 -0
  60. package/dist/{use-inventory-binding-dialog-D4We0HnY.js → use-inventory-binding-dialog-CmiGDFT9.js} +1 -1
  61. package/dist/views/adjustment-template/wastage-template/actions.d.ts +24 -0
  62. package/dist/views/adjustment-template/wastage-template/table.d.ts +24 -0
  63. package/dist/views/closing-draft/components/closing-draft-dialog/ClosingDraftDialog.vue.d.ts +8 -4
  64. package/dist/views/closing-draft/composables/use-closing-draft-actions.d.ts +4 -1
  65. package/dist/views/closing-draft/composables/use-closing-draft-table.d.ts +48 -24
  66. package/dist/views/closing-draft/helpers/export-draft.helper.d.ts +1 -1
  67. package/dist/views/closing-template/components/closing-template-form/composables/use-closing-template-items.d.ts +1 -1
  68. package/dist/views/closing-template/composables/use-closing-template-actions.d.ts +36 -12
  69. package/dist/views/closing-template/composables/use-closing-template-table.d.ts +36 -12
  70. package/dist/views/dev/components/AutocompleteTextField.vue.d.ts +2 -0
  71. package/dist/views/ingredient-group/composables/use-ingredient-group-table.d.ts +3 -3
  72. package/dist/views/ingredients/components/ingredient-form/IngredientForm.vue.d.ts +2 -2
  73. package/dist/views/ingredients/composables/use-ingredient-select-dialog.d.ts +16 -0
  74. package/dist/views/ingredients/composables/use-ingredient-table.d.ts +1 -1
  75. package/dist/views/receive-request/components/netsuite/NetSuiteProps.d.ts +2 -0
  76. package/dist/views/receive-request/components/transfer-details/TransferDetails.vue.d.ts +1389 -0
  77. package/dist/views/receive-request/components/transfer-details/TransferDetailsProps.d.ts +5 -1
  78. package/dist/views/receive-request/components/transfer-dialog/TransferDialogProps.d.ts +3 -0
  79. package/dist/views/receive-request/components/transfer-form/TransferFormProps.d.ts +1 -2
  80. package/dist/views/receive-request/components/transfer-form/components/ForecastStock.vue.d.ts +48 -2
  81. package/dist/views/receive-request/components/transfer-form/components/TransferItemTable.vue.d.ts +490 -2
  82. package/dist/views/receive-request/components/transfer-form/components/TransferSubItemTable.vue.d.ts +72 -0
  83. package/dist/views/receive-request/components/transfer-form/composables/use-transfer-items.d.ts +25 -2
  84. package/dist/views/receive-request/components/transfer-form/helpers/calculate-sub-item-total.helper.d.ts +4 -0
  85. package/dist/views/receive-request/composables/use-receive-request-form.d.ts +702 -35
  86. package/dist/views/receive-request/composables/use-receive-request-table.d.ts +690 -35
  87. package/dist/views/receive-request/helper/po-to-po-template.util.d.ts +1 -0
  88. package/dist/views/receive-request/helper/print-po.d.ts +9 -2
  89. package/dist/views/receive-request/import/XilnexImportDialog.vue.d.ts +22 -0
  90. package/dist/views/receive-request/import/XilnexImportForm.vue.d.ts +17 -0
  91. package/dist/views/receive-request/import/XilnexResult.vue.d.ts +17 -0
  92. package/dist/views/receive-request/import/export.d.ts +12 -0
  93. package/dist/views/receive-request/import/props.d.ts +7 -0
  94. package/dist/views/stock/components/dialog/AdjustedItemForm.vue.d.ts +2 -2
  95. package/dist/views/transfer-template/components/transfer-template-form/components/TransferTemplateItem.vue.d.ts +270 -2
  96. package/dist/views/transfer-template/components/transfer-template-form/components/TransferTemplateItemTable.vue.d.ts +286 -0
  97. package/dist/views/transfer-template/components/transfer-template-form/components/TransferTemplateSubItem.vue.d.ts +74 -0
  98. package/dist/views/transfer-template/components/transfer-template-form/components/TransferTemplateSubItemTable.vue.d.ts +92 -0
  99. package/dist/views/transfer-template/components/transfer-template-form/composables/use-template-enabled-locations-2.d.ts +8 -0
  100. package/dist/views/transfer-template/components/transfer-template-form/composables/use-template-enabled-locations.d.ts +1 -0
  101. package/dist/views/transfer-template/components/transfer-template-form/composables/use-transfer-template-items.d.ts +36 -2
  102. package/dist/views/transfer-template/composables/use-transfer-template-actions.d.ts +456 -12
  103. package/dist/views/transfer-template/composables/use-transfer-template-table.d.ts +456 -12
  104. package/dist/views/transfer-template/helpers/location-to-po-supplier.util.d.ts +75 -0
  105. package/dist/views/warehouse/components/WarehouseForm.vue.d.ts +2 -0
  106. package/dist/{vue-i18n-D1f9MmwY.js → vue-i18n-DC5cHFol.js} +153 -153
  107. package/package.json +2 -2
  108. package/dist/App-Du7DrI4b.js +0 -276
  109. package/dist/ApprovalView-CTZVmCbC.js +0 -138
  110. package/dist/ClosingDraftView-D6_mQmyF.js +0 -1225
  111. package/dist/ClosingTemplateView-DMConQNm.js +0 -1819
  112. package/dist/FmCustomAttribute.vue_vue_type_script_setup_true_lang-DuB-gluw.js +0 -142
  113. package/dist/FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-ttr6ec9b.js +0 -286
  114. package/dist/PublishView-BzUykEd5.js +0 -192
  115. package/dist/ReceiveRequestView-BWgm4e46.js +0 -1876
  116. package/dist/StockView--YVDLsgO.js +0 -1817
  117. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-CTy65dTx.js +0 -1327
  118. package/dist/TransferTemplateView-KOeBENZz.js +0 -1284
  119. package/dist/components/FmCustomAttribute2.vue.d.ts +0 -18
  120. package/dist/index-CCWsIAQX.js +0 -29202
  121. package/dist/views/receive-request/components/transfer-form/TransferForm.vue.d.ts +0 -2628
@@ -0,0 +1,2895 @@
1
+ import { defineComponent as ae, onMounted as Le, onUnmounted as At, renderSlot as Et, h as U, reactive as ht, computed as O, openBlock as S, createElementBlock as F, Fragment as ne, renderList as ge, createElementVNode as a, toDisplayString as q, unref as s, resolveComponent as D, createVNode as b, withCtx as R, createCommentVNode as N, ref as A, createBlock as Q, watch as be, normalizeClass as X, createTextVNode as Ie, normalizeStyle as kt, nextTick as Mt, mergeProps as Xe, isRef as Ce, createSlots as Ut, Teleport as Ot, normalizeProps as Nt, guardReactiveProps as Bt } from "vue";
2
+ import { H as Ze, J as zt, Y as Lt, Z as we, b as He, l as qe, i as me, a0 as Je, K as xt, as as Ht, A as ze, M as jt, m as St, ab as We, E as pe, at as Qt, a as et, au as Yt, av as Kt, aw as Xt, G as tt, O as st, u as je, ax as Zt, $ as Gt, T as Jt, ay as Wt, B as Ct, d as Re, v as es, w as ts, x as ss, az as Be, a5 as vt, y as os, _ as ns, z as as, N as yt } from "./app-d94DuF5R.js";
3
+ import { u as ot, a as ls, P as Ke, b as rs, _ as is, g as us } from "./TransferDetails.vue_vue_type_script_setup_true_lang-CidXuoBS.js";
4
+ import { _ as wt, u as ms, i as ds, e as cs } from "./PremiumBadge.vue_vue_type_script_setup_true_lang-BPmKDzxI.js";
5
+ import { u as ps } from "./useTabStorage-BkIVScW_.js";
6
+ import { useDialog as It, useBreakpoints as nt, components as ce, FmButtonVariant as fs, useSnackbar as De, useProxiedModel as Ft } from "@feedmepos/ui-library";
7
+ import { P as oe, u as $t } from "./format-unit-display-x2P1kVbK.js";
8
+ import { _ as Dt, F as Tt, a as Vt, b as Pt } from "./FmUnitInput.vue_vue_type_script_setup_true_lang-BZoFs1-5.js";
9
+ import { u as at } from "./feature-BiSY0JBR.js";
10
+ import { c as ye, u as vs, _ as ys, l as bs } from "./FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-Ugss5lqQ.js";
11
+ import { useI18n as fe } from "@feedmepos/mf-common";
12
+ import { defineStore as gs } from "pinia";
13
+ import { u as lt } from "./supplier-BSiJWxYO.js";
14
+ import { _ as _s } from "./PreviewBadge.vue_vue_type_script_setup_true_lang-CRZiQHjx.js";
15
+ import { u as hs } from "./vue-i18n-DC5cHFol.js";
16
+ import "./array-hChJVZLE.js";
17
+ const ks = /* @__PURE__ */ ae({
18
+ __name: "MountListener",
19
+ emits: ["mounted", "unmounted"],
20
+ setup(f, { emit: x }) {
21
+ const r = x;
22
+ return Le(() => r("mounted")), At(() => r("unmounted")), (l, C) => Et(l.$slots, "default");
23
+ }
24
+ }), Rt = gs("inventoryMultiSelectDialog", () => {
25
+ const f = It(), { t: x } = fe();
26
+ return { multiSelect: async (t, m, d) => {
27
+ const u = d ?? ((e) => e), { promise: h, resolve: o } = Promise.withResolvers();
28
+ return f.open({
29
+ title: "Select items",
30
+ closeButton: !0,
31
+ contentComponent: Ze,
32
+ contentComponentProps: {
33
+ modelValue: m ?? [],
34
+ items: t,
35
+ virtualScroll: !0,
36
+ onClose: () => o(null)
37
+ },
38
+ primaryActions: {
39
+ text: x("common.confirm"),
40
+ close: !0
41
+ },
42
+ secondaryActions: {
43
+ text: x("common.close"),
44
+ close: !0,
45
+ variant: "tertiary"
46
+ }
47
+ }).onPrimary((e) => {
48
+ const i = e.map((c) => u(c));
49
+ o(i);
50
+ }), h;
51
+ }, singleSelect: async (t, m, d) => {
52
+ const u = d ?? ((e) => e), { promise: h, resolve: o } = Promise.withResolvers();
53
+ return f.open({
54
+ title: "Select items",
55
+ closeButton: !0,
56
+ contentComponent: Ze,
57
+ contentComponentProps: {
58
+ modelValue: m ? [m] : [],
59
+ items: t,
60
+ virtualScroll: !0,
61
+ onClose: () => o(void 0),
62
+ singleSelect: !0
63
+ },
64
+ primaryActions: {
65
+ text: x("common.confirm"),
66
+ close: !0
67
+ },
68
+ secondaryActions: {
69
+ text: x("common.close"),
70
+ close: !0,
71
+ variant: "tertiary"
72
+ }
73
+ }).onPrimary((e) => {
74
+ if (!e.length)
75
+ return o(null);
76
+ const i = u(e[0]);
77
+ o(i);
78
+ }), h;
79
+ }, confirmation: async (t, m, d, u, h) => {
80
+ const { promise: o, resolve: e } = Promise.withResolvers();
81
+ return f.open({
82
+ title: t,
83
+ message: typeof m == "string" ? m : void 0,
84
+ contentComponent: U(
85
+ ks,
86
+ {
87
+ onUnmounted: () => {
88
+ e(null);
89
+ }
90
+ },
91
+ m
92
+ ),
93
+ contentComponentProps: {},
94
+ primaryActions: d ?? {
95
+ text: x("common.confirm"),
96
+ close: !0
97
+ },
98
+ secondaryActions: u ?? {
99
+ text: x("common.close"),
100
+ close: !0,
101
+ variant: "tertiary"
102
+ },
103
+ tertiaryActions: h,
104
+ closeButton: !0,
105
+ dismissAway: !0
106
+ }).onPrimary(() => {
107
+ e((d == null ? void 0 : d.value) ?? !0);
108
+ }).onSecondary(() => {
109
+ e((u == null ? void 0 : u.value) ?? !1);
110
+ }).onTertiary(() => {
111
+ e((h == null ? void 0 : h.value) ?? void 0);
112
+ }), o;
113
+ } };
114
+ });
115
+ function Ge(f) {
116
+ return f.reduce((x, r) => {
117
+ const l = r.measurement ? zt(r.quantity, r.measurement.conversion) : r.quantity;
118
+ return Lt(x, l);
119
+ }, we.reset());
120
+ }
121
+ var K = /* @__PURE__ */ ((f) => (f.Code = "Code", f.Name = "Name", f.TemplateName = "TemplateName", f.Amount = "Amount", f.Cost = "Cost", f.Delete = "Delete", f))(K || {});
122
+ const xs = () => (fe(), U(
123
+ wt,
124
+ {
125
+ zIndex: 50,
126
+ class: "whitespace-nowrap"
127
+ },
128
+ `Total (${St()})`
129
+ ));
130
+ function Ss(f) {
131
+ const { t: x } = fe(), r = ht({}), { breakpoints: l } = nt(), C = at(), t = He(), m = Rt();
132
+ Le(() => {
133
+ for (const o of f.items) {
134
+ if (!o.totalCost)
135
+ continue;
136
+ const e = ye(o.sku, o.quantity, o.measurement, {
137
+ supplier: f.supplier
138
+ }), i = o.totalCost ?? we.reset();
139
+ e ? r[o.sku._id] = e.amount !== i.amount || e.precision !== i.precision : r[o.sku._id] = !0;
140
+ }
141
+ });
142
+ function d(o) {
143
+ var i, c, y, k, I, v, p;
144
+ return !!(((c = (i = o.defaultCost) == null ? void 0 : i.costPerUnit) == null ? void 0 : c.amount) ?? ((p = (v = (I = (k = (y = f.supplier) == null ? void 0 : y.supplyItems) == null ? void 0 : k.find((V) => V.skuId === o._id)) == null ? void 0 : I.defaultCost) == null ? void 0 : v.costPerUnit) == null ? void 0 : p.amount));
145
+ }
146
+ const u = [
147
+ {
148
+ id: "Code",
149
+ header: () => x("inventory.transfer.form.items.table.Code"),
150
+ accessorKey: "code",
151
+ size: 200,
152
+ cell(o) {
153
+ var i;
154
+ const e = o.row.original;
155
+ return (i = e.subItems) != null && i.length ? U(
156
+ "span",
157
+ { class: "text-fm-color-typo-primary fm-typo-en-body-md-600 line-clamp-1" },
158
+ e.sku.code
159
+ ) : t.isEnabled ? U(
160
+ ce.FmTooltip,
161
+ {
162
+ content: e.code,
163
+ placement: "top",
164
+ variant: "plain",
165
+ zIndex: 50
166
+ },
167
+ U(
168
+ "span",
169
+ {
170
+ class: "flex-auto line-clamp-2 text-ellipsis break-all"
171
+ },
172
+ e.code
173
+ )
174
+ ) : U(ce.FmTextField, {
175
+ modelValue: e.code,
176
+ "onUpdate:modelValue": (c) => {
177
+ f.updateItem({
178
+ ...e,
179
+ code: c
180
+ });
181
+ },
182
+ key: e.sku._id,
183
+ rules: [qe()],
184
+ labelMark: "required"
185
+ });
186
+ },
187
+ enableSorting: !1
188
+ },
189
+ {
190
+ id: "Name",
191
+ header: () => x("inventory.transfer.form.items.table.Name"),
192
+ minSize: 300,
193
+ cell(o) {
194
+ var i;
195
+ const e = o.row.original;
196
+ return (i = e.subItems) != null && i.length ? U(
197
+ "span",
198
+ { class: "text-fm-color-typo-primary fm-typo-en-body-md-600 line-clamp-1" },
199
+ e.sku.name
200
+ ) : t.isEnabled ? U(
201
+ ce.FmTooltip,
202
+ {
203
+ content: e.name,
204
+ placement: "top",
205
+ variant: "plain",
206
+ zIndex: 50
207
+ },
208
+ U(
209
+ "span",
210
+ {
211
+ class: "flex-auto line-clamp-2 text-ellipsis break-all"
212
+ },
213
+ e.name
214
+ )
215
+ ) : U(ce.FmTextField, {
216
+ modelValue: e.name,
217
+ "onUpdate:modelValue": (c) => {
218
+ f.updateItem({
219
+ ...e,
220
+ name: c
221
+ });
222
+ },
223
+ key: e.sku._id,
224
+ rules: [qe()],
225
+ labelMark: "required"
226
+ });
227
+ },
228
+ enableSorting: !1
229
+ },
230
+ {
231
+ id: "TemplateName",
232
+ header: () => x("inventory.transfer.form.items.table.Name"),
233
+ minSize: 300,
234
+ enableSorting: !1,
235
+ cell(o) {
236
+ var y, k;
237
+ const e = o.row.original, i = (y = e.subItems) != null && y.length ? e.sku.code : e.code, c = (k = e.subItems) != null && k.length ? e.sku.name : e.name;
238
+ return U(
239
+ ce.FmTooltip,
240
+ { zIndex: 50 },
241
+ {
242
+ default() {
243
+ return U("div", { class: "flex flex-col w-full" }, [
244
+ U(
245
+ "div",
246
+ { class: "line-clamp-1 fm-typo-en-body-lg-400 text-fm-color-typo-primary" },
247
+ c
248
+ ),
249
+ U(
250
+ "div",
251
+ {
252
+ class: "line-clamp-1 fm-typo-en-body-md-400 text-fm-color-typo-secondary"
253
+ },
254
+ i
255
+ )
256
+ ]);
257
+ },
258
+ content() {
259
+ return c;
260
+ }
261
+ }
262
+ );
263
+ }
264
+ },
265
+ {
266
+ id: "Amount",
267
+ header: () => x("inventory.transfer.form.items.table.Amount"),
268
+ minSize: 200,
269
+ cell(o) {
270
+ var c, y, k, I, v;
271
+ const e = o.row.original;
272
+ if ((c = e.subItems) != null && c.length) {
273
+ const p = Ge(e.subItems);
274
+ return U(
275
+ "span",
276
+ {
277
+ class: "text-fm-color-typo-primary line-clamp-1 text-fm-color-typo-primary line-clamp-1 text-right"
278
+ },
279
+ [
280
+ U("span", { class: " fm-typo-en-body-md-400" }, "Total: "),
281
+ U(
282
+ "span",
283
+ { class: " fm-typo-en-body-md-600" },
284
+ `${me(p)} ${e.sku.unit.abbrev}`
285
+ )
286
+ ]
287
+ );
288
+ }
289
+ const i = (I = (k = (y = f.template) == null ? void 0 : y.purchaseOrder) == null ? void 0 : k.items) == null ? void 0 : I.find(
290
+ (p) => p.sku._id === e.sku._id
291
+ );
292
+ return U(Dt, {
293
+ style: {
294
+ flex: "1 1 0%"
295
+ },
296
+ modelValue: {
297
+ amount: e.quantity ?? { amount: 1, precision: 0 },
298
+ measurement: e.measurement ?? null
299
+ },
300
+ key: e.sku._id,
301
+ unit: e.sku.unit,
302
+ "onUpdate:modelValue": (p) => {
303
+ const V = {
304
+ ...e,
305
+ quantity: p.amount,
306
+ measurement: p.measurement
307
+ };
308
+ C.enableTotalCost && (V.totalCost = ye(e.sku, e.quantity, e.measurement, {
309
+ supplier: f.supplier,
310
+ // NOTE: set undefined here if `manualTotalCost[row.sku._id] = false`, so that the function
311
+ // will return the auto calculated default cost instead of the manual total cost
312
+ manualTotalCost: r[e.sku._id] ? V.totalCost : void 0
313
+ })), f.updateItem(V);
314
+ },
315
+ stepper: i == null ? void 0 : i.quantityStep,
316
+ disableUnit: !!i,
317
+ disabled: f.disabled,
318
+ rules: [
319
+ Tt(
320
+ +me(
321
+ ((v = e.quantity) == null ? void 0 : v.amount) === 0 ? { amount: 0, precision: 0 } : (i == null ? void 0 : i.minimumQuantity) ?? { amount: 0, precision: 0 }
322
+ )
323
+ ),
324
+ Vt(
325
+ i != null && i.maximumQuantity ? +me(i == null ? void 0 : i.maximumQuantity) : 1 / 0
326
+ ),
327
+ ...i != null && i.quantityStep ? [Pt(i.quantityStep)] : []
328
+ ],
329
+ applyDefaultRules: !0
330
+ });
331
+ },
332
+ enableSorting: !1
333
+ },
334
+ {
335
+ id: "Cost",
336
+ header: xs,
337
+ size: 180,
338
+ cell(o) {
339
+ const e = o.row.original, i = d(e.sku), c = l.value.xs || l.value.sm;
340
+ return !r[e.sku._id] && i ? U(
341
+ "div",
342
+ {
343
+ class: [
344
+ "flex gap-4 fm-typo-en-body-md-400 items-center",
345
+ f.disabled ? "text-fm-color-typo-disabled" : ""
346
+ ],
347
+ key: e.sku._id
348
+ },
349
+ [
350
+ U(ce.FmButton, {
351
+ prependIcon: "edit",
352
+ variant: fs.Tertiary,
353
+ disabled: f.disabled,
354
+ onClick() {
355
+ f.updateItem({
356
+ ...e,
357
+ totalCost: ye(e.sku, e.quantity, e.measurement, {
358
+ supplier: f.supplier
359
+ })
360
+ }), r[e.sku._id] = !0;
361
+ }
362
+ }),
363
+ U(
364
+ "div",
365
+ {
366
+ class: "flex flex-col"
367
+ },
368
+ [
369
+ U(
370
+ "span",
371
+ c ? Je(
372
+ ye(e.sku, e.quantity, e.measurement, {
373
+ supplier: f.supplier
374
+ })
375
+ ) : me(
376
+ ye(e.sku, e.quantity, e.measurement, {
377
+ supplier: f.supplier
378
+ })
379
+ )
380
+ ),
381
+ U(
382
+ "span",
383
+ {
384
+ class: [
385
+ "fm-typo-en-body-sm-400",
386
+ f.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-neutral-gray-400"
387
+ ]
388
+ },
389
+ x("inventory.transfer.form.items.autoCalculated")
390
+ )
391
+ ]
392
+ )
393
+ ]
394
+ ) : U(
395
+ ce.FmTextField,
396
+ {
397
+ modelValue: me(e.totalCost ?? { amount: 0, precision: 0 }),
398
+ key: e.sku._id,
399
+ "onUpdate:modelValue": (y) => {
400
+ f.updateItem({
401
+ ...e,
402
+ totalCost: {
403
+ ...xt(+y),
404
+ currency: Ht()
405
+ }
406
+ });
407
+ },
408
+ rules: [ze(0), jt(2)]
409
+ },
410
+ {
411
+ prepend() {
412
+ return c ? U(
413
+ "div",
414
+ {
415
+ class: [
416
+ "text-fm-typo-en-body-lg-400",
417
+ f.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-typo-primary"
418
+ ]
419
+ },
420
+ St()
421
+ ) : null;
422
+ },
423
+ append() {
424
+ return i ? U(ce.FmButton, {
425
+ prependIcon: "close",
426
+ variant: "tertiary",
427
+ disabled: f.disabled,
428
+ onClick() {
429
+ f.updateItem({
430
+ ...e,
431
+ // NOTE: different from PO template, if a default cost is reenabled,
432
+ // the total cost will automatically assigned
433
+ totalCost: ye(e.sku, e.quantity, e.measurement, {
434
+ supplier: f.supplier
435
+ })
436
+ }), r[e.sku._id] = !1;
437
+ }
438
+ }) : null;
439
+ }
440
+ }
441
+ );
442
+ },
443
+ enableSorting: !1
444
+ },
445
+ {
446
+ id: "Delete",
447
+ header: "",
448
+ cell(o) {
449
+ var y, k, I;
450
+ const e = o.row.original, i = (I = (k = (y = f.template) == null ? void 0 : y.purchaseOrder) == null ? void 0 : k.items) == null ? void 0 : I.find(
451
+ (v) => v.sku._id === e.sku._id
452
+ ), c = (i == null ? void 0 : i.subItems) ?? [];
453
+ return U("div", { class: "flex justify-end" }, [
454
+ ...c.length ? [
455
+ U(ce.FmButton, {
456
+ key: e.sku._id,
457
+ type: "button",
458
+ icon: "add_circle",
459
+ variant: "tertiary",
460
+ size: "md",
461
+ disabled: f.disabled,
462
+ onClick: async () => {
463
+ var L;
464
+ const v = ((L = e.subItems) == null ? void 0 : L.map(($) => $.id)) ?? [], p = c.map(
465
+ ($) => ({
466
+ label: $.name,
467
+ sublabel: $.code,
468
+ value: $.id
469
+ })
470
+ ), V = await m.multiSelect(p, v, ($) => {
471
+ var T;
472
+ return ((T = e.subItems) == null ? void 0 : T.find((Y) => Y.id === $)) ?? c.find((Y) => Y.id === $);
473
+ }).then(($) => $ == null ? void 0 : $.filter((T) => T).map((T) => T));
474
+ V && f.updateItem({
475
+ ...e,
476
+ subItems: V.length ? V : null
477
+ });
478
+ }
479
+ })
480
+ ] : [],
481
+ U(ce.FmButton, {
482
+ key: e.sku._id,
483
+ class: "delete-button",
484
+ type: "button",
485
+ icon: "delete",
486
+ variant: "tertiary",
487
+ size: "md",
488
+ disabled: f.disabled,
489
+ onClick: () => {
490
+ f.deleteItem(e);
491
+ }
492
+ })
493
+ ]);
494
+ },
495
+ enableSorting: !1,
496
+ size: 40,
497
+ meta: {
498
+ cellClass: "",
499
+ headerClass: ""
500
+ }
501
+ }
502
+ ];
503
+ return {
504
+ columnDefs: O(() => C.enableTotalCost && f.transferType === oe.PURCHASE ? u : u.filter(
505
+ (o) => o.id !== "Cost"
506
+ /* Cost */
507
+ ))
508
+ };
509
+ }
510
+ const Cs = { class: "flex flex-col gap-8 px-16 xs:px-4 sm:px-4 py-4 items-center" }, ws = { class: "fm-typo-en-body-lg-600 xs:fm-typo-en-body-md-600 mr-auto xs:w-full" }, Is = { class: "w-[450px] xs:w-full flex" }, Fs = { class: "fm-typo-en-body-md-400 whitespace-nowrap" }, $s = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, qt = /* @__PURE__ */ ae({
511
+ __name: "SupplierPriceHistory",
512
+ props: {
513
+ prices: {}
514
+ },
515
+ setup(f) {
516
+ const x = lt();
517
+ function r(l) {
518
+ return x.suppliers.find((C) => C._id === l);
519
+ }
520
+ return (l, C) => (S(), F("div", Cs, [
521
+ (S(!0), F(ne, null, ge(Object.keys(l.prices), (t) => {
522
+ var m;
523
+ return S(), F("div", {
524
+ key: t,
525
+ class: "flex items-center gap-12 xs:gap-4 xs:flex-wrap w-full"
526
+ }, [
527
+ a("div", ws, q((m = r(t)) == null ? void 0 : m.name), 1),
528
+ a("div", Is, [
529
+ (S(!0), F(ne, null, ge(l.prices[t].slice(0, 3), (d) => {
530
+ var u;
531
+ return S(), F("div", {
532
+ key: d.date,
533
+ class: "flex flex-col w-[150px] xs:flex-1 text-ellipsis cursor-pointer"
534
+ }, [
535
+ a("div", Fs, [
536
+ a("span", null, q(d.totalCost ? s(Je)(d.totalCost) : "No data"), 1),
537
+ C[0] || (C[0] = a("span", { class: "text-fm-color-typo-secondary" }, "/", -1)),
538
+ a("span", null, q(s(me)(d.totalUnit, !1)), 1),
539
+ a("span", null, q(((u = d.measurement) == null ? void 0 : u.abbrev) ?? d.unit.abbrev), 1)
540
+ ]),
541
+ a("div", $s, [
542
+ a("span", null, "(#" + q(d.seqNumber) + ")", 1),
543
+ C[1] || (C[1] = a("span", null, q(" "), -1)),
544
+ a("span", null, q(s(We)(new Date(d.date))), 1)
545
+ ])
546
+ ]);
547
+ }), 128))
548
+ ])
549
+ ]);
550
+ }), 128))
551
+ ]));
552
+ }
553
+ }), Ds = { class: "flex flex-col gap-8 py-16" }, Ts = { class: "flex items-center" }, Vs = { class: "flex-1 flex gap-1 items-center" }, Ps = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, Rs = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, qs = { class: "flex gap-8 w-full" }, As = { class: "flex-1 flex flex-col gap-4" }, Es = { class: "flex-1 flex flex-col gap-4" }, Ms = { class: "flex gap-8 w-full" }, Us = { class: "flex-1 flex flex-col gap-4" }, Os = {
554
+ key: 0,
555
+ class: "flex-1 flex flex-col gap-4"
556
+ }, Ns = /* @__PURE__ */ ae({
557
+ __name: "TransferItem",
558
+ props: {
559
+ cellByColId: {},
560
+ comparePriceBySku: {},
561
+ showComparePrice: { type: Boolean },
562
+ row: {}
563
+ },
564
+ setup(f) {
565
+ const { t: x } = fe();
566
+ return (r, l) => {
567
+ var m, d, u, h, o, e, i, c, y, k, I, v, p, V, L, $, T, Y, z, E, j, B, G, _, g, M, J;
568
+ const C = D("FmLabel"), t = D("FmSpacer");
569
+ return S(), F("div", Ds, [
570
+ a("div", Ts, [
571
+ a("div", Vs, [
572
+ a("span", Ps, " (" + q(r.row.original.sku.code) + ") ", 1),
573
+ a("span", Rs, q(r.row.original.sku.name), 1)
574
+ ]),
575
+ a("div", null, [
576
+ b(s(pe), {
577
+ render: (u = (d = (m = r.cellByColId.Delete) == null ? void 0 : m.column) == null ? void 0 : d.columnDef) == null ? void 0 : u.cell,
578
+ props: (o = (h = r.cellByColId.Delete) == null ? void 0 : h.getContext) == null ? void 0 : o.call(h)
579
+ }, null, 8, ["render", "props"])
580
+ ])
581
+ ]),
582
+ a("div", qs, [
583
+ a("div", As, [
584
+ b(C, {
585
+ label: s(x)(`inventory.transfer.form.items.table.${s(K).Code}`)
586
+ }, null, 8, ["label"]),
587
+ b(s(pe), {
588
+ render: (c = (i = (e = r.cellByColId[s(K).Code]) == null ? void 0 : e.column) == null ? void 0 : i.columnDef) == null ? void 0 : c.cell,
589
+ props: (k = (y = r.cellByColId[s(K).Code]) == null ? void 0 : y.getContext) == null ? void 0 : k.call(y)
590
+ }, null, 8, ["render", "props"]),
591
+ l[0] || (l[0] = a("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
592
+ ]),
593
+ a("div", Es, [
594
+ b(C, {
595
+ label: s(x)(`inventory.transfer.form.items.table.${s(K).Name}`)
596
+ }, null, 8, ["label"]),
597
+ b(s(pe), {
598
+ render: (p = (v = (I = r.cellByColId[s(K).Name]) == null ? void 0 : I.column) == null ? void 0 : v.columnDef) == null ? void 0 : p.cell,
599
+ props: (L = (V = r.cellByColId[s(K).Name]) == null ? void 0 : V.getContext) == null ? void 0 : L.call(V)
600
+ }, null, 8, ["render", "props"]),
601
+ l[1] || (l[1] = a("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
602
+ ])
603
+ ]),
604
+ a("div", Ms, [
605
+ a("div", Us, [
606
+ b(C, {
607
+ label: s(x)(`inventory.transfer.form.items.table.${s(K).Amount}`)
608
+ }, null, 8, ["label"]),
609
+ b(s(pe), {
610
+ render: (Y = (T = ($ = r.cellByColId[s(K).Amount]) == null ? void 0 : $.column) == null ? void 0 : T.columnDef) == null ? void 0 : Y.cell,
611
+ props: (E = (z = r.cellByColId[s(K).Amount]) == null ? void 0 : z.getContext) == null ? void 0 : E.call(z)
612
+ }, null, 8, ["render", "props"]),
613
+ l[2] || (l[2] = a("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
614
+ ]),
615
+ r.cellByColId[s(K).Cost] ? (S(), F("div", Os, [
616
+ b(wt, { "z-index": 50 }, {
617
+ default: R(() => [
618
+ b(C, {
619
+ label: s(x)(`inventory.transfer.form.items.table.${s(K).Cost}2`)
620
+ }, null, 8, ["label"])
621
+ ]),
622
+ _: 1
623
+ }),
624
+ b(s(pe), {
625
+ render: (G = (B = (j = r.cellByColId[s(K).Cost]) == null ? void 0 : j.column) == null ? void 0 : B.columnDef) == null ? void 0 : G.cell,
626
+ props: (g = (_ = r.cellByColId[s(K).Cost]) == null ? void 0 : _.getContext) == null ? void 0 : g.call(_)
627
+ }, null, 8, ["render", "props"]),
628
+ l[3] || (l[3] = a("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
629
+ ])) : N("", !0)
630
+ ]),
631
+ r.showComparePrice && Object.keys(r.comparePriceBySku[(M = r.row.original.sku) == null ? void 0 : M._id] ?? {}).length > 0 ? (S(), F(ne, { key: 0 }, [
632
+ b(t, { class: "h-8" }),
633
+ b(qt, {
634
+ prices: r.comparePriceBySku[(J = r.row.original.sku) == null ? void 0 : J._id]
635
+ }, null, 8, ["prices"])
636
+ ], 64)) : N("", !0)
637
+ ]);
638
+ };
639
+ }
640
+ });
641
+ function Bs(f) {
642
+ const x = O({
643
+ get() {
644
+ const t = f.getEffectiveAt();
645
+ return t ? new Date(t) : null;
646
+ },
647
+ set(t) {
648
+ f.setEffectiveAt((t == null ? void 0 : t.toISOString()) ?? null);
649
+ }
650
+ }), r = O({
651
+ get() {
652
+ return !!x.value;
653
+ },
654
+ set(t) {
655
+ t ? x.value = /* @__PURE__ */ new Date() : x.value = null;
656
+ }
657
+ }), l = O({
658
+ get() {
659
+ return x.value === null ? "" : We(x.value);
660
+ },
661
+ set(t) {
662
+ t ? x.value = /* @__PURE__ */ new Date(`${t} ${C.value}`) : x.value = null;
663
+ }
664
+ }), C = O({
665
+ get() {
666
+ return x.value === null ? "" : Qt(x.value);
667
+ },
668
+ set(t) {
669
+ t ? x.value = /* @__PURE__ */ new Date(`${l.value} ${t}`) : x.value = null;
670
+ }
671
+ });
672
+ return {
673
+ backdatePo: x,
674
+ backdateSwitch: r,
675
+ backdateModel: l,
676
+ backdateTimeModel: C
677
+ };
678
+ }
679
+ const zs = {
680
+ width: "24",
681
+ height: "24",
682
+ viewBox: "0 0 24 24",
683
+ fill: "none",
684
+ xmlns: "http://www.w3.org/2000/svg"
685
+ }, Ls = ["fill"], Hs = ["fill"], js = ["stroke"], Qs = ["stroke"], Ys = /* @__PURE__ */ ae({
686
+ __name: "SparkIcon",
687
+ props: {
688
+ size: {
689
+ type: Number,
690
+ default: 24
691
+ },
692
+ color: {
693
+ type: String,
694
+ default: "#c7c7cc"
695
+ }
696
+ },
697
+ setup(f) {
698
+ return (x, r) => (S(), F("svg", zs, [
699
+ a("path", {
700
+ d: "M7.6 7.6C8.17076 6.94229 8.5 5.5 8.5 5.5C8.5 5.5 8.81356 6.87361 9.35714 7.5C9.92948 8.15953 11.5 8.5 11.5 8.5C11.5 8.5 9.92948 8.69761 9.35714 9.35714C8.81356 9.98354 8.5 11.5 8.5 11.5C8.5 11.5 8.32076 10.1888 7.75 9.59091C7.14905 8.96136 5.5 8.5 5.5 8.5C5.5 8.5 6.99905 8.29251 7.6 7.6Z",
701
+ fill: f.color
702
+ }, null, 8, Ls),
703
+ a("path", {
704
+ d: "M12.2 12.2C13.3415 10.8846 14 8 14 8C14 8 14.6271 10.7472 15.7143 12C16.859 13.3191 20 14 20 14C20 14 16.859 14.3952 15.7143 15.7143C14.6271 16.9671 14 20 14 20C14 20 13.6415 17.3777 12.5 16.1818C11.2981 14.9227 8 14 8 14C8 14 10.9981 13.585 12.2 12.2Z",
705
+ fill: f.color
706
+ }, null, 8, Hs),
707
+ a("path", {
708
+ d: "M7.6 7.6C8.17076 6.94229 8.5 5.5 8.5 5.5C8.5 5.5 8.81356 6.87361 9.35714 7.5C9.92948 8.15953 11.5 8.5 11.5 8.5C11.5 8.5 9.92948 8.69761 9.35714 9.35714C8.81356 9.98354 8.5 11.5 8.5 11.5C8.5 11.5 8.32076 10.1888 7.75 9.59091C7.14905 8.96136 5.5 8.5 5.5 8.5C5.5 8.5 6.99905 8.29251 7.6 7.6Z",
709
+ stroke: f.color,
710
+ "stroke-width": "1.5",
711
+ "stroke-linecap": "round",
712
+ "stroke-linejoin": "round"
713
+ }, null, 8, js),
714
+ a("path", {
715
+ d: "M12.2 12.2C13.3415 10.8846 14 8 14 8C14 8 14.6271 10.7472 15.7143 12C16.859 13.3191 20 14 20 14C20 14 16.859 14.3952 15.7143 15.7143C14.6271 16.9671 14 20 14 20C14 20 13.6415 17.3777 12.5 16.1818C11.2981 14.9227 8 14 8 14C8 14 10.9981 13.585 12.2 12.2Z",
716
+ stroke: f.color,
717
+ "stroke-width": "1.5",
718
+ "stroke-linecap": "round",
719
+ "stroke-linejoin": "round"
720
+ }, null, 8, Qs)
721
+ ]));
722
+ }
723
+ }), Ks = { class: "flex gap-8 items-center" }, Xs = { class: "fm-typo-en-body-lg-600 line-clamp-1" }, Zs = { class: "w-[343px] px-24 py-16 rounded-lg shadow-light-300 flex flex-col gap-[20px]" }, Gs = { class: "flex items-center w-full" }, Js = { class: "flex-1" }, Ws = { class: "fm-typo-en-title-sm-800" }, eo = { class: "flex items-start gap-8" }, to = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, so = { class: "flex gap-1" }, bt = /* @__PURE__ */ ae({
724
+ __name: "ForecastStock",
725
+ props: {
726
+ disabled: { type: Boolean }
727
+ },
728
+ emits: ["update:poItems"],
729
+ setup(f, { emit: x }) {
730
+ const r = x, l = A(!1), C = A(7), t = ms(), m = De(), d = et(), { t: u } = fe();
731
+ async function h() {
732
+ if (C.value < 1)
733
+ return;
734
+ l.value = !1, await t.readPurchaseOrder(C.value);
735
+ const o = [];
736
+ if (t.purchaseOrderForecast.skus.length <= 0) {
737
+ m.open({
738
+ message: u("inventory.transfer.form.items.forecastStock.notAvailable"),
739
+ type: "info"
740
+ });
741
+ return;
742
+ }
743
+ const e = t.purchaseOrderForecast.skus.reduce((i, c) => {
744
+ const y = d.skus.find((v) => v._id === c.id);
745
+ if (i.find((v) => v.sku._id === c.id) || !y)
746
+ return i;
747
+ const I = {
748
+ sku: y,
749
+ code: y.code,
750
+ name: y.name,
751
+ quantity: {
752
+ amount: c.amount,
753
+ precision: 0
754
+ }
755
+ };
756
+ return i.push(I), i;
757
+ }, o);
758
+ r("update:poItems", e);
759
+ }
760
+ return (o, e) => {
761
+ const i = D("FmButton"), c = D("FmIcon"), y = D("FmStepperField"), k = D("FmPopover");
762
+ return S(), Q(k, {
763
+ disabled: o.disabled,
764
+ class: "flex",
765
+ "show-popover": l.value,
766
+ onPopoverChanged: e[3] || (e[3] = (I) => l.value = I)
767
+ }, {
768
+ "popover-button": R(() => [
769
+ b(i, {
770
+ label: "unused",
771
+ variant: "secondary",
772
+ "text-color": o.disabled ? "disabled" : "primary",
773
+ "bg-color": "transparent",
774
+ "border-color": o.disabled ? "disabled" : "primary",
775
+ disabled: o.disabled
776
+ }, {
777
+ default: R(() => [
778
+ a("div", Ks, [
779
+ b(Ys, {
780
+ size: 24,
781
+ color: o.disabled ? "#c7c7cc" : "#ff7823"
782
+ }, null, 8, ["color"]),
783
+ a("div", Xs, q(s(u)("inventory.transfer.form.items.forecastStock.title")), 1)
784
+ ])
785
+ ]),
786
+ _: 1
787
+ }, 8, ["text-color", "border-color", "disabled"])
788
+ ]),
789
+ default: R(() => [
790
+ a("div", Zs, [
791
+ a("div", Gs, [
792
+ a("div", Js, [
793
+ b(_s, { "z-index": 99 }, {
794
+ default: R(() => [
795
+ a("p", Ws, q(s(u)("inventory.transfer.form.items.forecastStock.title")), 1)
796
+ ]),
797
+ _: 1
798
+ })
799
+ ]),
800
+ b(i, {
801
+ icon: "close",
802
+ size: "md",
803
+ variant: "tertiary",
804
+ onClick: e[0] || (e[0] = (I) => l.value = !1)
805
+ })
806
+ ]),
807
+ b(y, {
808
+ modelValue: C.value,
809
+ "onUpdate:modelValue": e[1] || (e[1] = (I) => C.value = I),
810
+ label: s(u)("inventory.transfer.form.items.forecastStock.days"),
811
+ rules: [s(ze)(1)]
812
+ }, {
813
+ "helper-text": R(() => [
814
+ a("div", eo, [
815
+ b(c, {
816
+ name: "warning",
817
+ size: "sm",
818
+ class: "text-fm-color-system-warning-300"
819
+ }),
820
+ a("div", to, q(s(u)("inventory.transfer.form.items.forecastStock.replace")), 1)
821
+ ])
822
+ ]),
823
+ _: 1
824
+ }, 8, ["modelValue", "label", "rules"]),
825
+ a("div", so, [
826
+ e[4] || (e[4] = a("div", { class: "grow" }, null, -1)),
827
+ b(i, {
828
+ label: s(u)("common.cancel"),
829
+ variant: "tertiary",
830
+ onClick: e[2] || (e[2] = (I) => l.value = !1)
831
+ }, null, 8, ["label"]),
832
+ b(i, {
833
+ label: s(u)("inventory.transfer.form.items.forecastStock.generate"),
834
+ onClick: h
835
+ }, null, 8, ["label"])
836
+ ])
837
+ ])
838
+ ]),
839
+ _: 1
840
+ }, 8, ["disabled", "show-popover"]);
841
+ };
842
+ }
843
+ });
844
+ function oo() {
845
+ const f = De(), x = ot(), r = A(!1);
846
+ be(r, (m) => {
847
+ m && (C.value = !0, l().finally(() => {
848
+ C.value = !1;
849
+ }));
850
+ });
851
+ async function l() {
852
+ try {
853
+ const { startDate: m, endDate: d } = Yt(6), o = (await x.getPurchaseOrders({ start: m, end: d })).filter(
854
+ (e) => {
855
+ var i, c;
856
+ return e.status === Kt.enum.COMPLETE && ((i = e.supplier) == null ? void 0 : i.internal) !== "warehouse" && ((c = e.supplier) == null ? void 0 : c.internal) !== "restaurant";
857
+ }
858
+ ).reduce((e, i) => {
859
+ const c = new Date(Xt(i._id)), y = i.supplier._id;
860
+ for (const k of i.items) {
861
+ if (!k.totalCost) continue;
862
+ const I = e[k.sku._id] ?? {}, v = I[y] ?? [];
863
+ v.push({
864
+ date: c.toISOString(),
865
+ totalUnit: k.quantity,
866
+ totalCost: k.totalCost,
867
+ unit: k.sku.unit,
868
+ measurement: k.measurement,
869
+ seqNumber: i.seqNumber
870
+ }), I[y] = v, e[k.sku._id] = I;
871
+ }
872
+ return e;
873
+ }, {});
874
+ t.value = o;
875
+ } catch {
876
+ f.open({
877
+ title: "Something went wrong",
878
+ message: "Cannot retrieve supplier purchase history. Please try again."
879
+ }), r.value = !1;
880
+ }
881
+ }
882
+ const C = A(!1), t = A({});
883
+ return {
884
+ comparePricesToggle: r,
885
+ comparePriceFetching: C,
886
+ comparePriceBySku: t
887
+ };
888
+ }
889
+ const no = { class: "hover:bg-fm-color-opacity-sm" }, ao = { class: "flex items-center" }, lo = {
890
+ key: 0,
891
+ class: "flex h-full w-24"
892
+ }, ro = { class: "flex flex-col flex-1 line-clamp-1" }, io = { class: "text-fm-color-typo-primary fm-typo-en-body-md-400" }, uo = { class: "text-fm-color-typo-secondary fm-typo-en-body-sm-400" }, mo = {
893
+ key: 2,
894
+ class: "flex-1"
895
+ }, co = {
896
+ key: 3,
897
+ class: "flex w-full justify-end"
898
+ }, po = /* @__PURE__ */ ae({
899
+ __name: "TransferSubItemTable",
900
+ props: {
901
+ templateSubItem: {},
902
+ row: {},
903
+ modelValue: {},
904
+ disabled: { type: Boolean },
905
+ subItemIndex: {}
906
+ },
907
+ emits: ["delete:model-value"],
908
+ setup(f, { emit: x }) {
909
+ const r = tt(), l = x, C = A(me(r.quantity));
910
+ return be(C, (t) => {
911
+ if (!`${t}`) return;
912
+ const m = +t;
913
+ Number.isNaN(m) || (r.quantity = xt(m));
914
+ }), (t, m) => {
915
+ const d = D("FmIcon"), u = D("FmTooltip"), h = D("FmButton");
916
+ return S(), F("tr", no, [
917
+ (S(!0), F(ne, null, ge(t.row.getVisibleCells(), (o, e) => (S(), F("td", {
918
+ key: o.id,
919
+ class: X([e === 0 ? "px-16" : o.column.id === s(K).Delete ? "" : "px-16"])
920
+ }, [
921
+ a("div", ao, [
922
+ e === 0 ? (S(), F("div", lo, [
923
+ t.subItemIndex === 0 ? (S(), Q(d, {
924
+ key: 0,
925
+ name: "subdirectory_arrow_right",
926
+ size: "sm"
927
+ })) : N("", !0)
928
+ ])) : N("", !0),
929
+ o.column.id === s(K).TemplateName ? (S(), Q(u, {
930
+ key: 1,
931
+ "z-index": 50
932
+ }, {
933
+ content: R(() => [
934
+ Ie(q(s(r).name), 1)
935
+ ]),
936
+ default: R(() => [
937
+ a("div", ro, [
938
+ a("div", io, q(s(r).name), 1),
939
+ a("div", uo, q(s(r).code), 1)
940
+ ])
941
+ ]),
942
+ _: 1
943
+ })) : o.column.id === s(K).Amount ? (S(), F("div", mo, [
944
+ b(Dt, {
945
+ "model-value": {
946
+ amount: s(r).quantity,
947
+ measurement: s(r).measurement
948
+ },
949
+ "onUpdate:modelValue": m[0] || (m[0] = (i) => s(r).quantity = i.amount),
950
+ unit: t.row.original.sku.unit,
951
+ rules: [
952
+ s(Tt)(
953
+ +s(me)(
954
+ t.templateSubItem.minimumQuantity ?? {
955
+ amount: 1,
956
+ precision: s(st)(t.row.original.sku.unit, s(r).measurement)
957
+ }
958
+ )
959
+ ),
960
+ s(Vt)(
961
+ t.templateSubItem.maximumQuantity ? +s(me)(t.templateSubItem.maximumQuantity) : 1 / 0
962
+ ),
963
+ s(Pt)(t.templateSubItem.quantityStep)
964
+ ],
965
+ stepper: t.templateSubItem.quantityStep,
966
+ disabled: t.disabled,
967
+ "disable-unit": ""
968
+ }, null, 8, ["model-value", "unit", "rules", "stepper", "disabled"])
969
+ ])) : o.column.id === s(K).Delete ? (S(), F("div", co, [
970
+ b(h, {
971
+ key: "row.sku._id",
972
+ type: "button",
973
+ icon: "delete",
974
+ variant: "tertiary",
975
+ size: "md",
976
+ onClick: m[1] || (m[1] = (i) => l("delete:model-value", t.modelValue)),
977
+ disabled: t.disabled
978
+ }, null, 8, ["disabled"])
979
+ ])) : N("", !0)
980
+ ])
981
+ ], 2))), 128))
982
+ ]);
983
+ };
984
+ }
985
+ }), fo = { class: "fm-typo-body-md-400 line-clamp-2 w-full" }, vo = { key: 1 }, yo = ["colspan"], bo = /* @__PURE__ */ ae({
986
+ __name: "TransferItemTable",
987
+ props: {
988
+ templateItem: {},
989
+ row: {},
990
+ comparePriceBySku: {},
991
+ showComparePrice: { type: Boolean },
992
+ disabled: { type: Boolean }
993
+ },
994
+ emits: ["update:item"],
995
+ setup(f, { emit: x }) {
996
+ const r = f, l = x;
997
+ function C(u) {
998
+ return u.column.columnDef.meta;
999
+ }
1000
+ function t(u) {
1001
+ var h, o;
1002
+ return ((o = (h = r.templateItem) == null ? void 0 : h.subItems) == null ? void 0 : o.find((e) => e.id === u.id)) ?? {
1003
+ id: u.id,
1004
+ code: u.code,
1005
+ name: u.name,
1006
+ quantity: u.quantity,
1007
+ quantityStep: {
1008
+ amount: 1,
1009
+ precision: st(r.row.original.sku.unit, u.measurement)
1010
+ }
1011
+ };
1012
+ }
1013
+ function m(u) {
1014
+ const o = (r.row.original.subItems ?? []).map((e) => e.id !== u.id ? e : u);
1015
+ l("update:item", {
1016
+ ...r.row.original,
1017
+ subItems: o
1018
+ });
1019
+ }
1020
+ function d(u) {
1021
+ const o = (r.row.original.subItems ?? []).filter((e) => e.id !== u.id);
1022
+ l("update:item", {
1023
+ ...r.row.original,
1024
+ subItems: o.length ? o : null
1025
+ });
1026
+ }
1027
+ return (u, h) => {
1028
+ var o, e, i, c, y;
1029
+ return S(), F(ne, null, [
1030
+ a("tr", {
1031
+ class: X(["border-b border-fm-color-neutral-gray-100 hover:bg-fm-color-opacity-sm", {
1032
+ "bg-fm-color-neutral-gray-100": u.row.getIsSelected()
1033
+ }])
1034
+ }, [
1035
+ (S(!0), F(ne, null, ge(u.row.getVisibleCells(), (k) => {
1036
+ var I, v, p, V;
1037
+ return S(), F("td", {
1038
+ key: k.id,
1039
+ class: X(["h-[56px] text-fm-color-typo-primary", ((I = C(k)) == null ? void 0 : I.cellClass) ?? "px-16"]),
1040
+ style: kt({
1041
+ width: (v = C(k)) == null ? void 0 : v.width,
1042
+ maxWidth: (p = C(k)) == null ? void 0 : p.maxWidth,
1043
+ textAlign: ((V = C(k)) == null ? void 0 : V.textAlign) ?? "left"
1044
+ })
1045
+ }, [
1046
+ a("span", fo, [
1047
+ b(s(pe), {
1048
+ render: k.column.columnDef.cell,
1049
+ props: k.getContext()
1050
+ }, null, 8, ["render", "props"])
1051
+ ])
1052
+ ], 6);
1053
+ }), 128))
1054
+ ], 2),
1055
+ (e = (o = u.row.original) == null ? void 0 : o.subItems) != null && e.length ? (S(!0), F(ne, { key: 0 }, ge((i = u.row.original) == null ? void 0 : i.subItems, (k, I) => (S(), Q(po, {
1056
+ key: k.id,
1057
+ row: u.row,
1058
+ "model-value": k,
1059
+ "onUpdate:modelValue": m,
1060
+ "onDelete:modelValue": d,
1061
+ "template-sub-item": t(k),
1062
+ "sub-item-index": I,
1063
+ disabled: u.disabled
1064
+ }, null, 8, ["row", "model-value", "template-sub-item", "sub-item-index", "disabled"]))), 128)) : N("", !0),
1065
+ u.showComparePrice && Object.keys(u.comparePriceBySku[(c = u.row.original.sku) == null ? void 0 : c._id] ?? {}).length > 0 ? (S(), F("tr", vo, [
1066
+ a("td", {
1067
+ colspan: u.row.getVisibleCells().length
1068
+ }, [
1069
+ b(qt, {
1070
+ prices: u.comparePriceBySku[(y = u.row.original.sku) == null ? void 0 : y._id]
1071
+ }, null, 8, ["prices"])
1072
+ ], 8, yo)
1073
+ ])) : N("", !0)
1074
+ ], 64);
1075
+ };
1076
+ }
1077
+ }), go = {
1078
+ key: 0,
1079
+ class: "flex flex-col gap-8"
1080
+ }, _o = { class: "flex flex-col gap-4" }, ho = { class: "flex items-center gap-4" }, ko = {
1081
+ key: 0,
1082
+ class: "fm-typo-en-body-sm-400 text-fm-color-typo-error"
1083
+ }, xo = /* @__PURE__ */ ae({
1084
+ __name: "NetSuiteField",
1085
+ props: {
1086
+ required: { type: Boolean },
1087
+ disabled: { type: Boolean },
1088
+ supplier: {},
1089
+ setting: {},
1090
+ items: {},
1091
+ onChange: { type: Function }
1092
+ },
1093
+ emits: ["netsuite:ready"],
1094
+ setup(f, { emit: x }) {
1095
+ const r = He(), l = f, C = x, { t } = hs(), m = A(!1), d = A();
1096
+ Le(() => {
1097
+ var e, i, c, y;
1098
+ let o = {
1099
+ id: "",
1100
+ subsidiary: { id: "", name: "" },
1101
+ errors: []
1102
+ };
1103
+ if (!r.isEnabled || !l.required) {
1104
+ C("netsuite:ready", o);
1105
+ return;
1106
+ }
1107
+ try {
1108
+ const k = r.currentLocationSubsidiary();
1109
+ l.setting ? o = {
1110
+ ...l.setting,
1111
+ subsidiary: {
1112
+ id: k.id || "",
1113
+ name: k.name
1114
+ }
1115
+ } : o = {
1116
+ ...o,
1117
+ subsidiary: {
1118
+ id: k.id || "",
1119
+ name: k.name
1120
+ }
1121
+ };
1122
+ const I = r.getAvailableItems(k.id), v = l.items.filter((p) => {
1123
+ if (p.measurement != null) {
1124
+ const V = r.getAvailableMeasurements(
1125
+ p.sku._id,
1126
+ k.id
1127
+ );
1128
+ return I.includes(p.sku._id) && V.includes(p.measurement.id);
1129
+ }
1130
+ return I.includes(p.sku._id);
1131
+ }).map((p) => p.sku._id);
1132
+ l.onChange(
1133
+ l.items.filter((p) => v.includes(p.sku._id)),
1134
+ o
1135
+ );
1136
+ } finally {
1137
+ l.supplier.internal ? d.value = r.getNetSuiteLocation(
1138
+ `${l.supplier.internal}_${l.supplier._id}`
1139
+ ) : d.value = r.getNetSuiteVendor(l.supplier._id);
1140
+ const k = l.supplier.internal ? r.getLocationSubsidiary((e = d.value) == null ? void 0 : e.netSuiteId).id : (i = d.value) == null ? void 0 : i.subsidiaryId, I = l.supplier.internal ? (c = r.currentLocationSubsidiary()) == null ? void 0 : c.id : (y = r.currentVendorSubsidiary(l.supplier._id)) == null ? void 0 : y.id;
1141
+ !r.isEnabled || k && r.isEnabled && k == I ? C("netsuite:ready", o) : m.value = !0;
1142
+ }
1143
+ });
1144
+ const u = O(
1145
+ () => l.supplier.internal ? r.currentLocationSubsidiary() : r.currentVendorSubsidiary(l.supplier._id)
1146
+ ), h = O(() => {
1147
+ var o, e;
1148
+ return d.value == null ? `Cannot find the NetSuite location for "${l.supplier.name}"` : `The subsidiary of the request
1149
+ location is ${(e = r.getLocationSubsidiary((o = d.value) == null ? void 0 : o.netSuiteId)) == null ? void 0 : e.fullName}`;
1150
+ });
1151
+ return (o, e) => {
1152
+ const i = D("FmLabel"), c = D("FmIcon"), y = D("FmField"), k = D("FmTooltip");
1153
+ return s(r).isEnabled && l.required ? (S(), F("div", go, [
1154
+ b(i, {
1155
+ label: `NetSuite ${s(t)("inventory.transfer.form.netsuite.subsidiary")}`
1156
+ }, null, 8, ["label"]),
1157
+ a("div", _o, [
1158
+ b(k, {
1159
+ "z-index": 51,
1160
+ placement: "left",
1161
+ disabled: o.disabled
1162
+ }, {
1163
+ content: R(() => e[0] || (e[0] = [
1164
+ Ie("This field is locked and based on the location of the request.")
1165
+ ])),
1166
+ default: R(() => [
1167
+ b(y, null, {
1168
+ default: R(() => {
1169
+ var I;
1170
+ return [
1171
+ a("div", ho, [
1172
+ b(c, {
1173
+ name: "lock_outline",
1174
+ size: "sm",
1175
+ color: o.disabled ? "neutral-gray-200" : "neutral-gray-400"
1176
+ }, null, 8, ["color"]),
1177
+ a("div", {
1178
+ class: X([o.disabled ? "text-fm-color-typo-disabled" : ""])
1179
+ }, q((I = u.value) == null ? void 0 : I.fullName), 3)
1180
+ ])
1181
+ ];
1182
+ }),
1183
+ _: 1
1184
+ })
1185
+ ]),
1186
+ _: 1
1187
+ }, 8, ["disabled"]),
1188
+ m.value ? (S(), F("div", ko, q(h.value), 1)) : N("", !0)
1189
+ ])
1190
+ ])) : N("", !0);
1191
+ };
1192
+ }
1193
+ }), So = { class: "flex flex-col gap-4" }, Co = { class: "flex items-center gap-8 overflow-x-auto pb-12" }, wo = { class: "flex flex-col gap-16" }, Io = { class: "flex flex-col gap-24" }, Fo = { class: "flex flex-col gap-8" }, $o = { class: "flex flex-col gap-4" }, Do = { class: "flex items-center gap-4" }, To = { class: "flex flex-col gap-8" }, Vo = { class: "flex flex-col gap-4" }, Po = { class: "flex items-center gap-4" }, Ro = {
1194
+ key: 3,
1195
+ class: "p-16 border border-fm-color-neutral-gray-300 fm-corner-radius-md flex flex-col"
1196
+ }, qo = {
1197
+ key: 0,
1198
+ class: "flex-1 flex gap-8 h-48 xs:flex-col xs:pt-16 sm:flex-col sm:pt-16"
1199
+ }, Ao = { class: "flex-1" }, Eo = { class: "flex-1" }, Mo = {
1200
+ key: 1,
1201
+ class: "flex items-center gap-4"
1202
+ }, Uo = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary translate-y-[1px]" }, Oo = { class: "flex flex-col gap-16" }, No = { class: "flex-1 gap-8 fm-typo-en-title-sm-600" }, Bo = { class: "flex gap-8" }, zo = { key: 0 }, Lo = /* @__PURE__ */ ae({
1203
+ __name: "TransferForm2",
1204
+ props: {
1205
+ modelValue: {},
1206
+ request: {},
1207
+ disabled: { type: Boolean },
1208
+ returnFrom: {},
1209
+ lastClosingDate: {}
1210
+ },
1211
+ emits: ["validation-success", "form:ready"],
1212
+ setup(f, { expose: x, emit: r }) {
1213
+ const l = f, C = r, t = tt(), { t: m } = fe(), d = je(), u = et(), h = He(), o = lt(), e = at(), i = $t(), { breakpoints: c } = nt(), y = O(() => c.value.xs || c.value.sm), k = ht({
1214
+ value: !1
1215
+ }), I = A(!1), v = O(
1216
+ () => {
1217
+ var n;
1218
+ return ((n = l.modelValue) == null ? void 0 : n.templateDoc) ?? i.templates.find((w) => w._id === t.template);
1219
+ }
1220
+ ), p = O(() => t.status === "DRAFT" || !t._rev);
1221
+ be(v, (n) => {
1222
+ n && p.value && (t.supplier = (n == null ? void 0 : n.purchaseOrder.supplier) ?? t.supplier);
1223
+ }), Le(() => {
1224
+ var n;
1225
+ try {
1226
+ if (!t.templateDoc) return;
1227
+ t.items.length || (t.items = ((n = v.value) == null ? void 0 : n.purchaseOrder.items) ?? []);
1228
+ } finally {
1229
+ I.value = !0;
1230
+ }
1231
+ }), be([I, k], ([n, w], [Z, ie]) => {
1232
+ w.value && ie.value && C("form:ready");
1233
+ });
1234
+ const V = O(
1235
+ () => d.currentLocation.type === Zt.enum.restaurant
1236
+ );
1237
+ d.watchLocation(async () => {
1238
+ location && (t.supplier || (t.supplier = o.suppliers.find((n) => n) ?? t.supplier));
1239
+ });
1240
+ const L = It(), $ = vs(
1241
+ () => t,
1242
+ (n) => {
1243
+ Object.assign(t, n);
1244
+ },
1245
+ !0,
1246
+ !0
1247
+ ), T = O({
1248
+ get() {
1249
+ var n;
1250
+ return typeof ((n = t == null ? void 0 : t.supplier) == null ? void 0 : n.internal) == "string" ? oe.TRANSFER : oe.PURCHASE;
1251
+ },
1252
+ set(n) {
1253
+ var Z;
1254
+ const w = typeof ((Z = t == null ? void 0 : t.supplier) == null ? void 0 : Z.internal) == "string" ? oe.TRANSFER : oe.PURCHASE;
1255
+ n !== w && (t.supplier = n === oe.PURCHASE ? $.locationOptionsTypePurchase.value[0] : $.locationOptionsTypeTransfer.value[0]);
1256
+ }
1257
+ });
1258
+ be(
1259
+ () => {
1260
+ var n;
1261
+ return (n = l.modelValue) == null ? void 0 : n.template;
1262
+ },
1263
+ (n) => {
1264
+ e.mustUsePoTemplate && !n && Mt(() => {
1265
+ var w, Z;
1266
+ t.supplier = ((Z = (w = $.locationOptionsTypeTransfer.value) == null ? void 0 : w.filter(
1267
+ (ie) => ie.internal === "restaurant"
1268
+ )) == null ? void 0 : Z[0]) ?? t.supplier;
1269
+ });
1270
+ },
1271
+ { immediate: !0 }
1272
+ );
1273
+ const Y = O(() => {
1274
+ let n = $.transferLocationOptions.value;
1275
+ return e.mustUsePoTemplate && !t.templateDoc && (n = n.filter((w) => {
1276
+ var Z;
1277
+ return (Z = w.sublabel) == null ? void 0 : Z.startsWith("restaurant");
1278
+ })), n;
1279
+ }), z = O({
1280
+ get() {
1281
+ return t.supplier._id;
1282
+ },
1283
+ set(n) {
1284
+ $.transferLocationModel.value = n;
1285
+ }
1286
+ }), E = O({
1287
+ get() {
1288
+ return t.remark ?? void 0;
1289
+ },
1290
+ set(n) {
1291
+ t.remark = n;
1292
+ }
1293
+ }), { backdatePo: j, backdateSwitch: B, backdateModel: G, backdateTimeModel: _ } = Bs({
1294
+ getEffectiveAt() {
1295
+ return t.effectiveAt;
1296
+ },
1297
+ setEffectiveAt(n) {
1298
+ t.effectiveAt = n;
1299
+ }
1300
+ }), { comparePricesToggle: g, comparePriceFetching: M, comparePriceBySku: J } = oo(), le = A();
1301
+ x({
1302
+ validateInputs: () => {
1303
+ var n, w;
1304
+ (w = (n = le.value) == null ? void 0 : n.validateInputs) == null || w.call(n);
1305
+ },
1306
+ resetInputsValidation: () => {
1307
+ var n, w;
1308
+ (w = (n = le.value) == null ? void 0 : n.resetInputsValidation) == null || w.call(n);
1309
+ },
1310
+ resetInputs: () => {
1311
+ var n, w;
1312
+ (w = (n = le.value) == null ? void 0 : n.resetInputs) == null || w.call(n);
1313
+ }
1314
+ });
1315
+ const Fe = O(() => ({
1316
+ updateItem: (n) => {
1317
+ t.items = t.items.map((w) => w.sku._id !== n.sku._id ? w : n);
1318
+ },
1319
+ deleteItem: (n) => {
1320
+ t.items = t.items.filter((w) => w.sku._id !== n.sku._id);
1321
+ }
1322
+ })), $e = Ss({
1323
+ updateItem: (n) => Fe.value.updateItem(n),
1324
+ deleteItem: (n) => Fe.value.deleteItem(n),
1325
+ get supplier() {
1326
+ return t.supplier;
1327
+ },
1328
+ get items() {
1329
+ return t.items;
1330
+ },
1331
+ get transferType() {
1332
+ return T.value;
1333
+ },
1334
+ get template() {
1335
+ return v.value;
1336
+ },
1337
+ get disabled() {
1338
+ return l.disabled;
1339
+ }
1340
+ }), Ae = O(() => $e.columnDefs.value);
1341
+ function Ee() {
1342
+ var _e, Te, Ue, Oe, Ve;
1343
+ const n = (Ue = (Te = (_e = v.value) == null ? void 0 : _e.purchaseOrder) == null ? void 0 : Te.items) == null ? void 0 : Ue.groupBy((H) => H.sku._id), w = h.isEnabled ? h.getAvailableItems((Ve = (Oe = t.netSuite) == null ? void 0 : Oe.subsidiary) == null ? void 0 : Ve.id) : [], Z = n != null && n.size ? u.skus.filter((H) => n.has(H._id)) : u.skus, ie = h.isEnabled ? Z.filter((H) => {
1344
+ var se, te, re, de;
1345
+ const ee = (te = (se = v.value) == null ? void 0 : se.purchaseOrder) == null ? void 0 : te.items.find(
1346
+ (ve) => ve.sku._id === H._id
1347
+ );
1348
+ if (ee != null && ee.measurement != null) {
1349
+ const ve = h.getAvailableMeasurements(
1350
+ ee.sku._id,
1351
+ (de = (re = t.netSuite) == null ? void 0 : re.subsidiary) == null ? void 0 : de.id
1352
+ );
1353
+ return w.includes(ee.sku._id) && ve.includes(ee.measurement.id);
1354
+ }
1355
+ return w.includes(H._id);
1356
+ }).map((H) => H._id) : Z.map((H) => H._id), ue = Z.map(
1357
+ (H) => {
1358
+ var ee, se, te, re;
1359
+ return {
1360
+ label: ((se = (ee = n == null ? void 0 : n.get(H._id)) == null ? void 0 : ee[0]) == null ? void 0 : se.name) ?? H.name,
1361
+ sublabel: ((re = (te = n == null ? void 0 : n.get(H._id)) == null ? void 0 : te[0]) == null ? void 0 : re.code) ?? H.code,
1362
+ value: H,
1363
+ disabled: !ie.includes(H._id)
1364
+ };
1365
+ }
1366
+ ), xe = ue.filter((H) => {
1367
+ var ee;
1368
+ return (ee = t.items) == null ? void 0 : ee.find((se) => se.sku._id === H.value._id);
1369
+ }).map((H) => H.value);
1370
+ L.open({
1371
+ title: m("inventory.transfer.form.items.selectItem"),
1372
+ closeButton: !0,
1373
+ contentComponent: Ze,
1374
+ contentComponentProps: {
1375
+ modelValue: xe,
1376
+ items: ue,
1377
+ virtualScroll: !0
1378
+ },
1379
+ primaryActions: {
1380
+ text: m("common.confirm"),
1381
+ close: !0
1382
+ },
1383
+ secondaryActions: {
1384
+ text: m("common.close"),
1385
+ close: !0,
1386
+ variant: "tertiary"
1387
+ }
1388
+ }).onPrimary((H) => {
1389
+ const ee = t.items ?? [], se = H.map((te) => {
1390
+ var ve, Pe;
1391
+ const re = ee.find((Se) => Se.sku._id === te._id);
1392
+ if (re)
1393
+ return re;
1394
+ const de = ((Pe = (ve = v.value) == null ? void 0 : ve.purchaseOrder.items) == null ? void 0 : Pe.find(
1395
+ (Se) => Se.sku._id === te._id
1396
+ )) ?? {
1397
+ sku: te,
1398
+ code: te.code,
1399
+ name: te.name,
1400
+ quantity: {
1401
+ amount: 1,
1402
+ precision: 0
1403
+ }
1404
+ };
1405
+ return T.value == oe.PURCHASE && (de.totalCost = ye(
1406
+ de.sku,
1407
+ de.quantity,
1408
+ de.measurement,
1409
+ {
1410
+ supplier: t.supplier
1411
+ }
1412
+ )), de;
1413
+ });
1414
+ se.sort((te, re) => te.sku.code.localeCompare(re.sku.code)), t.items = se;
1415
+ });
1416
+ }
1417
+ function Qe(n) {
1418
+ return n;
1419
+ }
1420
+ const Me = O(() => {
1421
+ const n = [];
1422
+ return (!e.mustUsePoTemplate || e.mustUsePoTemplate && t.templateDoc) && n.push({
1423
+ label: m("inventory.transfer.form.type.purchase"),
1424
+ value: oe.PURCHASE
1425
+ }), n.push({
1426
+ label: m("inventory.transfer.form.type.transfer"),
1427
+ value: oe.TRANSFER
1428
+ }), n;
1429
+ }), ke = O(() => {
1430
+ var n;
1431
+ return (n = l.modelValue) == null ? void 0 : n.items.every((w) => w.quantity.amount <= 0);
1432
+ });
1433
+ return (n, w) => {
1434
+ var ve, Pe;
1435
+ const Z = D("FmChip"), ie = D("FmLabel"), ue = D("FmIcon"), xe = D("FmField"), _e = D("FmTooltip"), Te = D("FmSelect"), Ue = D("FmTextField"), Oe = D("FmTextarea"), Ve = D("FmSwitch"), H = D("FmDatePicker"), ee = D("FmTimePicker"), se = D("FmFormGroup"), te = D("FmButton"), re = D("FmTable"), de = D("FmForm");
1436
+ return S(), F("div", So, [
1437
+ a("div", Co, [
1438
+ (ve = l.modelValue) != null && ve.template ? (S(), Q(Z, {
1439
+ key: 0,
1440
+ variant: n.disabled ? "warning" : void 0,
1441
+ label: `${s(m)("inventory.transfer.template.title")}: ${((Pe = v.value) == null ? void 0 : Pe.name) ?? s(m)("inventory.transfer.form.loading")}`,
1442
+ icon: "summarize",
1443
+ compact: ""
1444
+ }, null, 8, ["variant", "label"])) : N("", !0),
1445
+ n.returnFrom ? N("", !0) : (S(), Q(Z, {
1446
+ key: 1,
1447
+ label: s(d).currentLocation.name,
1448
+ icon: "storefront",
1449
+ compact: ""
1450
+ }, null, 8, ["label"])),
1451
+ n.lastClosingDate ? (S(), Q(Z, {
1452
+ key: 2,
1453
+ label: `${s(m)("inventory.transfer.form.lastClosing")}: ${s(We)(n.lastClosingDate)} ${s(Gt)(n.lastClosingDate)}`,
1454
+ icon: "calendar_month",
1455
+ compact: ""
1456
+ }, null, 8, ["label"])) : N("", !0)
1457
+ ]),
1458
+ b(de, {
1459
+ ref_key: "formRef",
1460
+ ref: le,
1461
+ class: "flex flex-col gap-32",
1462
+ disabled: n.disabled,
1463
+ onValidationFailed: console.log,
1464
+ onValidationSuccess: w[14] || (w[14] = (Se) => C("validation-success"))
1465
+ }, {
1466
+ default: R(() => {
1467
+ var Se, rt, it, ut, mt, dt, ct, pt;
1468
+ return [
1469
+ a("div", wo, [
1470
+ a("div", Io, [
1471
+ (Se = l.modelValue) != null && Se.template ? (S(), F(ne, { key: 0 }, [
1472
+ a("div", Fo, [
1473
+ b(ie, {
1474
+ label: s(m)("inventory.transfer.form.type.title")
1475
+ }, null, 8, ["label"]),
1476
+ a("div", $o, [
1477
+ b(_e, {
1478
+ "z-index": 51,
1479
+ placement: "left",
1480
+ disabled: n.disabled
1481
+ }, {
1482
+ content: R(() => w[15] || (w[15] = [
1483
+ Ie("This field is locked from template.")
1484
+ ])),
1485
+ default: R(() => [
1486
+ b(xe, null, {
1487
+ default: R(() => [
1488
+ a("div", Do, [
1489
+ b(ue, {
1490
+ name: "lock_outline",
1491
+ size: "sm",
1492
+ color: n.disabled ? "neutral-gray-200" : "neutral-gray-400"
1493
+ }, null, 8, ["color"]),
1494
+ a("div", {
1495
+ class: X({ "text-fm-color-typo-disabled": n.disabled })
1496
+ }, q(s(m)(`inventory.transfer.form.type.${T.value.toLocaleLowerCase("en-us")}`)), 3)
1497
+ ])
1498
+ ]),
1499
+ _: 1
1500
+ })
1501
+ ]),
1502
+ _: 1
1503
+ }, 8, ["disabled"]),
1504
+ a("div", {
1505
+ class: X([
1506
+ "fm-typo-en-body-sm-400",
1507
+ n.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-typo-secondary"
1508
+ ])
1509
+ }, null, 2)
1510
+ ])
1511
+ ]),
1512
+ a("div", To, [
1513
+ b(ie, {
1514
+ label: n.returnFrom ? "Return to" : T.value === s(oe).PURCHASE ? s(m)("inventory.transfer.form.purchaseFrom") : s(m)("inventory.transfer.form.transferFrom")
1515
+ }, null, 8, ["label"]),
1516
+ a("div", Vo, [
1517
+ b(_e, {
1518
+ "z-index": 51,
1519
+ placement: "left",
1520
+ disabled: n.disabled
1521
+ }, {
1522
+ content: R(() => w[16] || (w[16] = [
1523
+ Ie("This field is locked from template.")
1524
+ ])),
1525
+ default: R(() => [
1526
+ b(xe, null, {
1527
+ default: R(() => {
1528
+ var P, W, he;
1529
+ return [
1530
+ a("div", Po, [
1531
+ b(ue, {
1532
+ name: "lock_outline",
1533
+ size: "sm",
1534
+ color: n.disabled ? "neutral-gray-200" : "neutral-gray-400"
1535
+ }, null, 8, ["color"]),
1536
+ a("div", {
1537
+ class: X({ "text-fm-color-typo-disabled": n.disabled })
1538
+ }, q(((W = (P = n.returnFrom) == null ? void 0 : P.supplier) == null ? void 0 : W.name) ?? ((he = Y.value.find((Ne) => Ne.value === z.value)) == null ? void 0 : he.label)), 3)
1539
+ ])
1540
+ ];
1541
+ }),
1542
+ _: 1
1543
+ })
1544
+ ]),
1545
+ _: 1
1546
+ }, 8, ["disabled"])
1547
+ ])
1548
+ ])
1549
+ ], 64)) : (S(), F(ne, { key: 1 }, [
1550
+ b(Te, {
1551
+ label: s(m)("inventory.transfer.form.type.title"),
1552
+ "label-mark": "required",
1553
+ modelValue: T.value,
1554
+ "onUpdate:modelValue": w[0] || (w[0] = (P) => T.value = P),
1555
+ items: Me.value,
1556
+ rules: [s(ze)(1)(Y.value)]
1557
+ }, {
1558
+ default: R(() => [
1559
+ a("span", {
1560
+ class: X([
1561
+ "line-clamp-1 fm-typo-en-body-lg-400",
1562
+ n.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-typo-primary"
1563
+ ])
1564
+ }, q(s(Jt)(T.value)), 3)
1565
+ ]),
1566
+ _: 1
1567
+ }, 8, ["label", "modelValue", "items", "rules"]),
1568
+ b(Te, {
1569
+ label: T.value === s(oe).PURCHASE ? s(m)("inventory.transfer.form.purchaseFrom") : s(m)("inventory.transfer.form.transferFrom"),
1570
+ "label-mark": "required",
1571
+ modelValue: z.value,
1572
+ "onUpdate:modelValue": w[1] || (w[1] = (P) => z.value = P),
1573
+ items: Y.value
1574
+ }, {
1575
+ "menu-wrapper": R((P) => {
1576
+ var W, he;
1577
+ return [
1578
+ b(ys, Xe(P, {
1579
+ items: Y.value,
1580
+ "model-value": (he = (W = n.modelValue) == null ? void 0 : W.supplier) == null ? void 0 : he._id
1581
+ }), null, 16, ["items", "model-value"])
1582
+ ];
1583
+ }),
1584
+ default: R(() => {
1585
+ var P;
1586
+ return [
1587
+ a("span", {
1588
+ class: X([
1589
+ "line-clamp-1 fm-typo-en-body-lg-400",
1590
+ n.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-typo-primary"
1591
+ ])
1592
+ }, q((P = Y.value.find((W) => W.value === z.value)) == null ? void 0 : P.label), 3)
1593
+ ];
1594
+ }),
1595
+ _: 1
1596
+ }, 8, ["label", "modelValue", "items"])
1597
+ ], 64)),
1598
+ b(Ue, {
1599
+ label: s(m)("inventory.transfer.form.reference"),
1600
+ "label-mark": "optional",
1601
+ modelValue: s(t).ref,
1602
+ "onUpdate:modelValue": w[2] || (w[2] = (P) => s(t).ref = P)
1603
+ }, null, 8, ["label", "modelValue"]),
1604
+ b(Oe, {
1605
+ label: s(m)("inventory.transfer.form.remark"),
1606
+ "label-mark": "optional",
1607
+ "max-length": 240,
1608
+ modelValue: E.value,
1609
+ "onUpdate:modelValue": w[3] || (w[3] = (P) => E.value = P),
1610
+ class: X([n.disabled ? "text-fm-color-typo-disabled " : ""])
1611
+ }, null, 8, ["label", "modelValue", "class"]),
1612
+ I.value ? (S(), Q(xo, {
1613
+ key: 2,
1614
+ required: s(t).templateDoc != null,
1615
+ disabled: n.disabled,
1616
+ supplier: s(t).supplier,
1617
+ setting: s(t).netSuite,
1618
+ items: s(t).items,
1619
+ onChange: (P, W) => {
1620
+ s(t).items = P, s(t).netSuite = W;
1621
+ },
1622
+ "onNetsuite:ready": w[4] || (w[4] = (P) => {
1623
+ k.value = !0;
1624
+ })
1625
+ }, null, 8, ["required", "disabled", "supplier", "setting", "items", "onChange"])) : N("", !0),
1626
+ s(e).enableBackdatePo ? (S(), F("div", Ro, [
1627
+ a("div", {
1628
+ class: X([
1629
+ "flex",
1630
+ {
1631
+ "flex-col": y.value
1632
+ }
1633
+ ])
1634
+ }, [
1635
+ b(Ve, {
1636
+ modelValue: s(B),
1637
+ "onUpdate:modelValue": w[5] || (w[5] = (P) => Ce(B) ? B.value = P : null),
1638
+ label: s(m)("inventory.transfer.form.backdate.title"),
1639
+ sublabel: s(m)("inventory.transfer.form.backdate.subtitle"),
1640
+ "label-placement": "right",
1641
+ disabled: V.value && !n.lastClosingDate || n.disabled
1642
+ }, null, 8, ["modelValue", "label", "sublabel", "disabled"]),
1643
+ a("div", {
1644
+ class: X({ hidden: y.value, "w-16": !y.value })
1645
+ }, null, 2),
1646
+ s(B) ? (S(), F("div", qo, [
1647
+ a("div", Ao, [
1648
+ b(H, {
1649
+ modelValue: s(G),
1650
+ "onUpdate:modelValue": w[6] || (w[6] = (P) => Ce(G) ? G.value = P : null)
1651
+ }, null, 8, ["modelValue"])
1652
+ ]),
1653
+ a("div", Eo, [
1654
+ b(ee, {
1655
+ modelValue: s(_),
1656
+ "onUpdate:modelValue": w[7] || (w[7] = (P) => Ce(_) ? _.value = P : null)
1657
+ }, null, 8, ["modelValue"])
1658
+ ])
1659
+ ])) : N("", !0)
1660
+ ], 2),
1661
+ s(j) ? (S(), Q(se, {
1662
+ key: 0,
1663
+ modelValue: s(j),
1664
+ "onUpdate:modelValue": w[8] || (w[8] = (P) => Ce(j) ? j.value = P : null),
1665
+ rules: [s(Wt)(new Date(n.lastClosingDate), /* @__PURE__ */ new Date())]
1666
+ }, null, 8, ["modelValue", "rules"])) : N("", !0),
1667
+ V.value && !n.lastClosingDate ? (S(), F("div", Mo, [
1668
+ b(ue, {
1669
+ name: "error",
1670
+ size: "sm",
1671
+ class: "text-fm-color-typo-warning"
1672
+ }),
1673
+ a("span", Uo, q(s(m)("inventory.transfer.form.backdate.error")), 1)
1674
+ ])) : N("", !0)
1675
+ ])) : N("", !0)
1676
+ ])
1677
+ ]),
1678
+ a("div", Oo, [
1679
+ b(se, {
1680
+ "model-value": s(t).items,
1681
+ rules: [s(ze)(1)]
1682
+ }, null, 8, ["model-value", "rules"]),
1683
+ a("div", {
1684
+ class: X([
1685
+ "flex gap-16",
1686
+ {
1687
+ "flex-col items-start": y.value,
1688
+ "items-center": !y.value
1689
+ }
1690
+ ])
1691
+ }, [
1692
+ a("div", No, q(s(m)("inventory.transfer.form.items.title")), 1),
1693
+ a("div", Bo, [
1694
+ b(te, {
1695
+ disabled: n.disabled,
1696
+ label: s(m)("inventory.transfer.form.items.addItem"),
1697
+ "prepend-icon": "add",
1698
+ variant: "secondary",
1699
+ "text-color": "primary",
1700
+ "bg-color": "transparent",
1701
+ "border-color": "primary",
1702
+ onClick: w[9] || (w[9] = (P) => Ee()),
1703
+ size: "md"
1704
+ }, null, 8, ["disabled", "label"]),
1705
+ s(t).templateDoc ? (S(), Q(_e, {
1706
+ key: 0,
1707
+ "z-index": 50
1708
+ }, {
1709
+ content: R(() => [
1710
+ a("div", null, q(s(m)("inventory.transfer.form.items.forecastStock.notAvailable")), 1)
1711
+ ]),
1712
+ default: R(() => [
1713
+ b(bt, {
1714
+ "onUpdate:poItems": w[10] || (w[10] = (P) => s(t).items = P),
1715
+ disabled: ""
1716
+ })
1717
+ ]),
1718
+ _: 1
1719
+ })) : (S(), Q(bt, {
1720
+ key: 1,
1721
+ "onUpdate:poItems": w[11] || (w[11] = (P) => s(t).items = P),
1722
+ disabled: n.disabled || !!s(t).templateDoc
1723
+ }, null, 8, ["disabled"]))
1724
+ ])
1725
+ ], 2),
1726
+ T.value === s(oe).PURCHASE && p.value && s(e).enableTotalCost && ((rt = n.modelValue) != null && rt.items.length) ? (S(), F("div", zo, [
1727
+ b(Ve, {
1728
+ label: s(M) ? s(m)("inventory.transfer.form.items.fetchingData") : s(m)("inventory.transfer.form.items.comparePriceHistory"),
1729
+ "prepend-icon": "compare_arrows",
1730
+ "label-placement": "right",
1731
+ "model-value": s(g),
1732
+ "onUpdate:modelValue": w[12] || (w[12] = (P) => Ce(g) ? g.value = P : null),
1733
+ disabled: s(M) || n.disabled
1734
+ }, null, 8, ["label", "model-value", "disabled"])
1735
+ ])) : N("", !0),
1736
+ b(se, {
1737
+ "model-value": ke.value,
1738
+ rules: [() => ke.value ? "Must have at least one non-zero item" : !0]
1739
+ }, null, 8, ["model-value", "rules"]),
1740
+ (S(), Q(re, {
1741
+ "column-defs": Ae.value,
1742
+ "column-visibility": {
1743
+ [s(K).Code]: !(((it = n.modelValue) == null ? void 0 : it.template) ?? ((ut = n.modelValue) == null ? void 0 : ut.templateDoc)),
1744
+ [s(K).Name]: !(((mt = n.modelValue) == null ? void 0 : mt.template) ?? ((dt = n.modelValue) == null ? void 0 : dt.templateDoc)),
1745
+ [s(K).TemplateName]: !!(((ct = n.modelValue) == null ? void 0 : ct.template) ?? ((pt = n.modelValue) == null ? void 0 : pt.templateDoc))
1746
+ },
1747
+ "row-data": s(t).items,
1748
+ key: s(t).items.map((P) => P.sku._id).join("."),
1749
+ "hide-footer": "",
1750
+ "page-size": s(t).items.length
1751
+ }, {
1752
+ "table-row": R((P) => {
1753
+ var W, he, Ne, ft;
1754
+ return [
1755
+ b(bo, {
1756
+ "compare-price-by-sku": s(J),
1757
+ "show-compare-price": T.value === s(oe).PURCHASE && s(g),
1758
+ row: P,
1759
+ "template-item": (ft = (Ne = (he = (W = n.modelValue) == null ? void 0 : W.templateDoc) == null ? void 0 : he.purchaseOrder) == null ? void 0 : Ne.items) == null ? void 0 : ft.find(
1760
+ (Ye) => Ye.sku._id === P.original.sku._id
1761
+ ),
1762
+ "onUpdate:item": w[13] || (w[13] = (Ye) => Fe.value.updateItem(Ye)),
1763
+ disabled: n.disabled
1764
+ }, null, 8, ["compare-price-by-sku", "show-compare-price", "row", "template-item", "disabled"])
1765
+ ];
1766
+ }),
1767
+ "list-row": R((P) => [
1768
+ (S(), Q(Ct, {
1769
+ row: P,
1770
+ key: s(t).items.map((W) => W.sku._id).join(".")
1771
+ }, {
1772
+ default: R((W) => [
1773
+ b(Ns, {
1774
+ "compare-price-by-sku": s(J),
1775
+ "show-compare-price": T.value === s(oe).PURCHASE && s(g),
1776
+ row: P,
1777
+ "cell-by-col-id": W
1778
+ }, null, 8, ["compare-price-by-sku", "show-compare-price", "row", "cell-by-col-id"])
1779
+ ]),
1780
+ _: 2
1781
+ }, 1032, ["row"]))
1782
+ ]),
1783
+ _: 1
1784
+ }, 8, ["column-defs", "column-visibility", "row-data", "page-size"]))
1785
+ ])
1786
+ ];
1787
+ }),
1788
+ _: 1
1789
+ }, 8, ["disabled", "onValidationFailed"])
1790
+ ]);
1791
+ };
1792
+ }
1793
+ });
1794
+ function Ho(f, x) {
1795
+ x ?? (x = `Return to ${f.supplier.name}`);
1796
+ const l = je().currentLocation, C = bs(l), t = {};
1797
+ for (const d of f.items) {
1798
+ const u = d.sku._id;
1799
+ t[u] = we.reset();
1800
+ }
1801
+ const m = f.deliveryOrder.flatMap((d) => d.received);
1802
+ for (const d of m) {
1803
+ const u = d.sku._id;
1804
+ if (!t[u]) continue;
1805
+ const h = d.measurement ? we.multiply([d.measurement.conversion, d.amount]) : d.amount;
1806
+ t[u] = we.add([t[u], h]);
1807
+ }
1808
+ return {
1809
+ _id: f._id,
1810
+ name: x,
1811
+ purchaseOrder: {
1812
+ supplier: C,
1813
+ ref: f.ref,
1814
+ remark: f.remark,
1815
+ items: f.items.map((d) => {
1816
+ const u = d.measurement ? we.divide([t[d.sku._id], d.measurement.conversion]) : t[d.sku._id];
1817
+ return {
1818
+ sku: d.sku,
1819
+ code: d.code,
1820
+ name: d.name,
1821
+ quantityStep: {
1822
+ amount: 1,
1823
+ precision: st(d.sku.unit, d.measurement)
1824
+ },
1825
+ quantity: u,
1826
+ maximumQuantity: u
1827
+ };
1828
+ }).filter((d) => d.maximumQuantity.amount > 0)
1829
+ }
1830
+ };
1831
+ }
1832
+ const jo = { class: "flex items-center" }, Qo = { class: "fm-typo-en-title-md-800" }, Yo = { class: "flex gap-4" }, Ko = /* @__PURE__ */ ae({
1833
+ __name: "TransferDialog",
1834
+ props: {
1835
+ mode: {},
1836
+ modelValue: {},
1837
+ returnFrom: {},
1838
+ "onSubmit:returnStock": { type: Function },
1839
+ templateId: {},
1840
+ show: { type: Boolean },
1841
+ lastClosingDate: {}
1842
+ },
1843
+ emits: ["update:show", "submitted"],
1844
+ setup(f, { expose: x, emit: r }) {
1845
+ var G;
1846
+ const l = f, C = r, t = ot(), m = $t(), d = De(), u = lt(), h = je(), { t: o } = fe(), e = A(!1), i = A(!1), c = A(!1), y = Rt();
1847
+ async function k(_) {
1848
+ if (_) {
1849
+ i.value = !1;
1850
+ try {
1851
+ await u.readSuppliers(), i.value = !0;
1852
+ } catch {
1853
+ d.open({
1854
+ title: o("inventory.transfer.form.unableToFetchListOfSuppliers.title"),
1855
+ message: o("inventory.transfer.form.unableToFetchListOfSuppliers.message"),
1856
+ type: "error"
1857
+ });
1858
+ }
1859
+ }
1860
+ }
1861
+ h.watchLocation(k);
1862
+ function I() {
1863
+ const _ = {
1864
+ remark: void 0,
1865
+ ref: void 0,
1866
+ stockSnapshotId: void 0,
1867
+ effectiveAt: void 0,
1868
+ items: [],
1869
+ supplier: {
1870
+ _rev: void 0,
1871
+ email: void 0,
1872
+ internal: void 0,
1873
+ contactName: void 0,
1874
+ phoneNumber: void 0,
1875
+ registrationNumber: void 0,
1876
+ supplyItems: void 0,
1877
+ _id: "",
1878
+ name: "",
1879
+ address: {
1880
+ line2: void 0,
1881
+ line1: "",
1882
+ state: "",
1883
+ city: "",
1884
+ postcode: "",
1885
+ country: ""
1886
+ }
1887
+ },
1888
+ status: "DRAFT",
1889
+ _id: "",
1890
+ seqNumber: 0,
1891
+ deliveryOrder: [],
1892
+ template: l.templateId,
1893
+ templateDoc: m.templates.find((g) => g._id === l.templateId)
1894
+ };
1895
+ if (l.returnFrom) {
1896
+ const g = Ho(l.returnFrom);
1897
+ _.templateDoc = g, _.template = g._id, _.supplier = g.purchaseOrder.supplier ?? _.supplier, _.items = g.purchaseOrder.items ?? [], _.isReturnPo = !0;
1898
+ }
1899
+ return _;
1900
+ }
1901
+ const v = Ft(l, "show"), p = A(l.modelValue ?? I()), V = A(((G = l.modelValue) == null ? void 0 : G._id) ?? `${Math.random()}`);
1902
+ be(
1903
+ () => l.show,
1904
+ (_) => {
1905
+ var g;
1906
+ _ && (c.value = !1, p.value = l.modelValue ?? I(), V.value = ((g = l.modelValue) == null ? void 0 : g._id) ?? `${Math.random()}`);
1907
+ }
1908
+ );
1909
+ const L = O(() => !i.value || !c.value), $ = O(() => {
1910
+ if (l.returnFrom)
1911
+ return "Return transfer";
1912
+ switch (l.mode) {
1913
+ case Re.READ:
1914
+ return "View transfer";
1915
+ case Re.CREATE:
1916
+ return o("inventory.transfer.receiveRequest.create.title");
1917
+ case Re.UPDATE:
1918
+ return o("inventory.transfer.receiveRequest.update.title");
1919
+ }
1920
+ return "";
1921
+ }), T = A();
1922
+ x({
1923
+ validateInputs: () => {
1924
+ var _, g;
1925
+ (g = (_ = T.value) == null ? void 0 : _.validateInputs) == null || g.call(_);
1926
+ },
1927
+ resetInputsValidation: () => {
1928
+ var _, g;
1929
+ (g = (_ = T.value) == null ? void 0 : _.resetInputsValidation) == null || g.call(_);
1930
+ },
1931
+ resetInputs: () => {
1932
+ var _, g;
1933
+ (g = (_ = T.value) == null ? void 0 : _.resetInputs) == null || g.call(_);
1934
+ }
1935
+ });
1936
+ async function Y() {
1937
+ var g;
1938
+ if (!(!await y.confirmation(
1939
+ "Submit return stock request?",
1940
+ "Stock will be deducted upon confirmation."
1941
+ ) || !p.value || !l.returnFrom)) {
1942
+ e.value = !0;
1943
+ try {
1944
+ await ((g = l["onSubmit:returnStock"]) == null ? void 0 : g.call(l, p.value, l.returnFrom));
1945
+ } catch (M) {
1946
+ d.open({
1947
+ title: o("inventory.transfer.receiveRequest.create.error.title"),
1948
+ message: o("inventory.transfer.receiveRequest.create.error.message"),
1949
+ type: "error"
1950
+ }), console.error("Error in creating purchase order", M);
1951
+ } finally {
1952
+ e.value = !1, C("update:show", !1);
1953
+ }
1954
+ }
1955
+ }
1956
+ async function z() {
1957
+ const _ = p.value;
1958
+ if (e.value = !0, _.items.some((g) => {
1959
+ var M;
1960
+ return (M = g.subItems) == null ? void 0 : M.length;
1961
+ }) && (_.items = _.items.map((g) => {
1962
+ var J;
1963
+ if (!((J = g.subItems) != null && J.length)) return g;
1964
+ const M = Ge(g.subItems);
1965
+ return {
1966
+ ...g,
1967
+ quantity: M,
1968
+ // note: no measurement, total is calculate in base unit
1969
+ measurement: null,
1970
+ totalCost: ye(g.sku, M)
1971
+ };
1972
+ })), _.items = _.items.filter((g) => g.quantity.amount > 0), !_.items.length) {
1973
+ d.open({
1974
+ title: "Cannot create order",
1975
+ message: "There are no items with non-zero amount in your request.",
1976
+ type: "error"
1977
+ });
1978
+ return;
1979
+ }
1980
+ (_.supplier.internal === "warehouse" || _.supplier.internal === "restaurant") && (_.items = _.items.map(({ totalCost: g, ...M }) => M));
1981
+ try {
1982
+ await t.createPurchaseOrder(_), await new Promise((g) => setTimeout(g, 1e3)), d.open({
1983
+ title: o("inventory.transfer.receiveRequest.create.success"),
1984
+ message: o("inventory.transfer.receiveRequest.create.successMessage"),
1985
+ type: "success"
1986
+ }), C("update:show", !1), C("submitted");
1987
+ } catch (g) {
1988
+ d.open({
1989
+ title: o("inventory.transfer.receiveRequest.create.error.title"),
1990
+ message: o("inventory.transfer.receiveRequest.create.error.message"),
1991
+ type: "error"
1992
+ }), console.error("Error in creating purchase order", g);
1993
+ } finally {
1994
+ e.value = !1;
1995
+ }
1996
+ }
1997
+ async function E() {
1998
+ const _ = p.value;
1999
+ if (e.value = !0, _.items.some((g) => {
2000
+ var M;
2001
+ return (M = g.subItems) == null ? void 0 : M.length;
2002
+ }) && (_.items = _.items.map((g) => {
2003
+ var J;
2004
+ if (!((J = g.subItems) != null && J.length)) return g;
2005
+ const M = Ge(g.subItems);
2006
+ return {
2007
+ ...g,
2008
+ quantity: M,
2009
+ // note: no measurement, total is calculate in base unit
2010
+ measurement: null,
2011
+ totalCost: ye(g.sku, M)
2012
+ };
2013
+ })), _.items = _.items.filter((g) => g.quantity.amount > 0), !_.items.length) {
2014
+ d.open({
2015
+ title: "Cannot create order",
2016
+ message: "There are no items with non-zero amount in your request.",
2017
+ type: "error"
2018
+ });
2019
+ return;
2020
+ }
2021
+ (_.supplier.internal === "warehouse" || _.supplier.internal === "restaurant") && (_.items = _.items.map(({ totalCost: g, ...M }) => M));
2022
+ try {
2023
+ await t.updatePurchaseOrder(_), await new Promise((g) => setTimeout(g, 1e3)), d.open({
2024
+ title: o("inventory.transfer.receiveRequest.update.success"),
2025
+ message: o("inventory.transfer.receiveRequest.update.successMessage"),
2026
+ type: "success"
2027
+ }), C("update:show", !1), C("submitted");
2028
+ } catch (g) {
2029
+ d.open({
2030
+ title: o("inventory.transfer.receiveRequest.update.error.title"),
2031
+ message: o("inventory.transfer.receiveRequest.update.error.message"),
2032
+ type: "error"
2033
+ }), console.error("Error in updating purchase order", g);
2034
+ } finally {
2035
+ e.value = !1;
2036
+ }
2037
+ }
2038
+ function j() {
2039
+ switch (l.mode) {
2040
+ case Re.CREATE:
2041
+ return l.returnFrom ? Y() : z();
2042
+ case Re.UPDATE:
2043
+ return E();
2044
+ }
2045
+ }
2046
+ function B() {
2047
+ var _, g;
2048
+ (g = (_ = T.value) == null ? void 0 : _.validateInputs) == null || g.call(_);
2049
+ }
2050
+ return (_, g) => {
2051
+ const M = D("FmButton"), J = D("FmSideSheet");
2052
+ return S(), Q(J, {
2053
+ modelValue: s(v),
2054
+ "onUpdate:modelValue": g[3] || (g[3] = (le) => Ce(v) ? v.value = le : null),
2055
+ "dismiss-away": "",
2056
+ "close-button": "",
2057
+ "max-width": 900
2058
+ }, {
2059
+ "side-sheet-header": R(() => [
2060
+ a("div", jo, [
2061
+ a("div", Qo, q($.value), 1)
2062
+ ])
2063
+ ]),
2064
+ default: R(() => [
2065
+ (S(), Q(Lo, {
2066
+ class: "w-full",
2067
+ ref_key: "formRef",
2068
+ ref: T,
2069
+ "onForm:ready": g[0] || (g[0] = () => c.value = !0),
2070
+ onValidationSuccess: j,
2071
+ modelValue: p.value,
2072
+ "onUpdate:modelValue": g[1] || (g[1] = (le) => p.value = le),
2073
+ disabled: e.value || L.value,
2074
+ "return-from": _.returnFrom,
2075
+ key: V.value,
2076
+ "last-closing-date": _.lastClosingDate
2077
+ }, null, 8, ["modelValue", "disabled", "return-from", "last-closing-date"]))
2078
+ ]),
2079
+ "side-sheet-footer": R(() => [
2080
+ a("div", Yo, [
2081
+ b(M, {
2082
+ loading: e.value,
2083
+ disabled: L.value,
2084
+ label: s(o)("common.save"),
2085
+ onClick: B
2086
+ }, null, 8, ["loading", "disabled", "label"]),
2087
+ b(M, {
2088
+ disabled: L.value,
2089
+ variant: "tertiary",
2090
+ label: s(o)("common.close"),
2091
+ onClick: g[2] || (g[2] = (le) => C("update:show", !1))
2092
+ }, null, 8, ["disabled", "label"])
2093
+ ])
2094
+ ]),
2095
+ _: 1
2096
+ }, 8, ["modelValue"]);
2097
+ };
2098
+ }
2099
+ });
2100
+ function Xo(f) {
2101
+ const [x, ...r] = es(f), l = x.map((d) => d.toLowerCase().trim().replace(/ /g, "_")), t = ["item_code", "quantity"].filter((d) => !l.includes(d));
2102
+ if (t.length)
2103
+ throw new Error(
2104
+ `Missing headers (${t.join()}). Excel file does not come from the template.`
2105
+ );
2106
+ return r.map((d, u) => {
2107
+ const h = {};
2108
+ for (const o in l) {
2109
+ const e = l[o];
2110
+ Object.assign(h, { [e]: d[o] });
2111
+ }
2112
+ return {
2113
+ index: u,
2114
+ data: h
2115
+ };
2116
+ });
2117
+ }
2118
+ function Zo(f) {
2119
+ const x = f.SheetNames;
2120
+ try {
2121
+ return x.reduce(
2122
+ (l, C) => {
2123
+ const t = new Array(), m = f.Sheets[C], d = et(), u = Xo(m), h = [];
2124
+ for (const { index: e, data: i } of u) {
2125
+ i.item_code === "" && t.push(`Row ${e + 1}: Item code is empty`), i.quantity === "" && t.push(`Row ${e + 1}: Quantity is empty`);
2126
+ const c = d.skus.find((k) => k.code === i.item_code);
2127
+ if (!c) {
2128
+ t.push(`Row ${e + 1}: SKU not found`);
2129
+ continue;
2130
+ }
2131
+ h.push({
2132
+ sku: c,
2133
+ code: i.item_code,
2134
+ name: c.name,
2135
+ quantity: we.fromNumber(Number(i.quantity)),
2136
+ measurement: null
2137
+ });
2138
+ }
2139
+ const o = {
2140
+ type: "create",
2141
+ poItems: h,
2142
+ excelSheetName: C,
2143
+ errors: t
2144
+ };
2145
+ return l.importCreateResult.push(o), l;
2146
+ },
2147
+ {
2148
+ invalidExcel: !1,
2149
+ importCreateResult: new Array()
2150
+ }
2151
+ );
2152
+ } catch (r) {
2153
+ return {
2154
+ invalidExcel: !0,
2155
+ invalidExcelMessage: (r == null ? void 0 : r.message) ?? "Invalid excel",
2156
+ importCreateResult: []
2157
+ };
2158
+ }
2159
+ }
2160
+ const Go = exports.FfCalculator, Jo = { class: "flex flex-col flex-1" }, Wo = { class: "flex flex-col" }, en = { class: "fm-typo-en-body-md-400 text-fm-color-typo-primary flex items-center gap-4" }, tn = {
2161
+ key: 0,
2162
+ class: "text-fm-color-typo-secondary fm-typo-en-body-sm-400"
2163
+ }, sn = { key: 0 }, on = {
2164
+ class: /* @__PURE__ */ X(["fm-typo-en-body-lg-600"])
2165
+ }, nn = { class: "flex-1" }, an = { class: "flex-auto line-clamp-2 text-ellipsis break-all fm-typo-en-body-sm-400" }, ln = { class: "flex-auto line-clamp-2 text-ellipsis break-all" }, rn = { class: "text-fm-color-typo-primary" }, un = { class: "ml-auto" }, mn = { key: 0 }, dn = /* @__PURE__ */ ae({
2166
+ __name: "XilnexResult",
2167
+ props: {
2168
+ type: {},
2169
+ name: {},
2170
+ items: {},
2171
+ errors: {}
2172
+ },
2173
+ setup(f) {
2174
+ const x = f, { t: r } = fe(), l = A(!1), C = () => {
2175
+ x.errors.length && (l.value = !l.value);
2176
+ };
2177
+ return (t, m) => {
2178
+ var h;
2179
+ const d = D("FmIcon"), u = D("FmTooltip");
2180
+ return S(), F("div", Jo, [
2181
+ a("div", {
2182
+ onClick: C,
2183
+ class: X({
2184
+ "cursor-pointer": t.errors.length
2185
+ })
2186
+ }, [
2187
+ a("div", Wo, [
2188
+ a("div", en, [
2189
+ a("div", {
2190
+ class: X({
2191
+ "text-fm-color-system-error-300": t.errors.length
2192
+ })
2193
+ }, [
2194
+ Ie(q(t.name) + " ", 1),
2195
+ t.type === "create" ? (S(), F("span", tn, "(" + q(s(r)("inventory.closing.template.import.new")) + ")", 1)) : N("", !0)
2196
+ ], 2),
2197
+ t.errors.length ? (S(), F("div", sn, [
2198
+ b(d, {
2199
+ name: "error",
2200
+ size: "sm",
2201
+ color: "system-error-300"
2202
+ })
2203
+ ])) : N("", !0)
2204
+ ]),
2205
+ m[0] || (m[0] = a("hr", { class: "my-2" }, null, -1)),
2206
+ a("div", on, [
2207
+ (h = t.items) != null && h.length ? (S(!0), F(ne, { key: 0 }, ge(t.items, (o, e) => (S(), F("div", {
2208
+ key: e,
2209
+ class: "flex gap-4 mt-2 items-center"
2210
+ }, [
2211
+ a("div", nn, [
2212
+ b(u, {
2213
+ content: o.code,
2214
+ placement: "top",
2215
+ "z-index": 51
2216
+ }, {
2217
+ default: R(() => [
2218
+ a("span", an, q(o.code), 1)
2219
+ ]),
2220
+ _: 2
2221
+ }, 1032, ["content"]),
2222
+ b(u, {
2223
+ content: o.name,
2224
+ placement: "top",
2225
+ "z-index": 51
2226
+ }, {
2227
+ default: R(() => [
2228
+ a("span", ln, q(o.name), 1)
2229
+ ]),
2230
+ _: 2
2231
+ }, 1032, ["content"])
2232
+ ]),
2233
+ a("div", null, [
2234
+ a("span", rn, q(s(Go).toFormatString({
2235
+ value: o.quantity
2236
+ })), 1),
2237
+ Ie(" " + q(o.measurement ? o.measurement.abbrev : o.sku.unit.abbrev), 1)
2238
+ ])
2239
+ ]))), 128)) : N("", !0)
2240
+ ])
2241
+ ]),
2242
+ a("div", un, [
2243
+ t.errors.length ? (S(), Q(d, {
2244
+ key: 0,
2245
+ name: l.value ? "keyboard_arrow_up" : "keyboard_arrow_down",
2246
+ size: "md"
2247
+ }, null, 8, ["name"])) : N("", !0)
2248
+ ])
2249
+ ], 2),
2250
+ l.value ? (S(), F("div", {
2251
+ key: 0,
2252
+ class: X(["flex flex-col gap-4 pl-8 fm-typo-en-body-sm-400", {
2253
+ "text-fm-color-typo-secondary": !t.errors.length,
2254
+ "text-fm-color-system-error-300": t.errors.length
2255
+ }])
2256
+ }, [
2257
+ t.errors.length ? (S(), F("div", mn, [
2258
+ a("ol", null, [
2259
+ (S(!0), F(ne, null, ge(t.errors, (o, e) => (S(), F("li", { key: e }, q(o), 1))), 128))
2260
+ ])
2261
+ ])) : N("", !0)
2262
+ ], 2)) : N("", !0)
2263
+ ]);
2264
+ };
2265
+ }
2266
+ }), cn = { class: "flex flex-col gap-24" }, pn = {
2267
+ key: 0,
2268
+ class: "flex items-center gap-8"
2269
+ }, fn = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, vn = { class: "flex flex-col gap-8" }, yn = { class: "line-clamp-2 text-ellipsis break-all" }, bn = {
2270
+ key: 2,
2271
+ class: "shrink-0"
2272
+ }, gn = {
2273
+ key: 0,
2274
+ class: "flex flex-col"
2275
+ }, _n = { class: "text-fm-color-system-error-300 fm-typo-en-body-sm-400" }, hn = {
2276
+ key: 0,
2277
+ class: "max-h-[200px] overflow-y-auto flex flex-col gap-8"
2278
+ }, kn = { class: "fm-typo-en-body-lg-600" }, gt = "Transfer note", xn = /* @__PURE__ */ ae({
2279
+ __name: "XilnexImportForm",
2280
+ setup(f, { expose: x }) {
2281
+ const r = A(null), l = De(), C = A(!1), t = A(!1), m = tt();
2282
+ A(!1), He();
2283
+ const d = A([
2284
+ {
2285
+ label: "LMSL389 MSU Medical Centre",
2286
+ value: {
2287
+ netsuiteId: "1279",
2288
+ name: "LMSL389 MSU Medical Centre"
2289
+ }
2290
+ },
2291
+ {
2292
+ label: "LMSL540 Central I-City",
2293
+ value: {
2294
+ netsuiteId: "1463",
2295
+ name: "LMSL540 Central I-City"
2296
+ }
2297
+ },
2298
+ {
2299
+ label: "LMSL572 Giant Shah Alam Stadium",
2300
+ value: {
2301
+ netsuiteId: "1521",
2302
+ name: "LMSL572 Giant Shah Alam Stadium"
2303
+ }
2304
+ }
2305
+ ]), u = O({
2306
+ get() {
2307
+ var v;
2308
+ return ((v = m.supplier) == null ? void 0 : v.name) ?? "";
2309
+ },
2310
+ set(v) {
2311
+ v && (m.supplier = {
2312
+ name: v.name,
2313
+ registrationNumber: "",
2314
+ _id: v.netsuiteId,
2315
+ internal: "restaurant",
2316
+ address: {
2317
+ line1: "",
2318
+ line2: "",
2319
+ city: "",
2320
+ state: "",
2321
+ country: "",
2322
+ postcode: ""
2323
+ }
2324
+ });
2325
+ }
2326
+ }), h = O({
2327
+ get() {
2328
+ return "";
2329
+ },
2330
+ set(v) {
2331
+ if (v) {
2332
+ const p = m.effectiveAt ? new Date(m.effectiveAt) : /* @__PURE__ */ new Date(), [V, L, $] = v.split("-");
2333
+ p.setFullYear(parseInt(V)), p.setMonth(parseInt(L) - 1), p.setDate(parseInt($)), m.effectiveAt = p.toISOString();
2334
+ }
2335
+ }
2336
+ }), o = O({
2337
+ get() {
2338
+ return null;
2339
+ },
2340
+ set(v) {
2341
+ if (v) {
2342
+ const p = m.effectiveAt ? new Date(m.effectiveAt) : /* @__PURE__ */ new Date(), [V, L] = v.split(":");
2343
+ p.setHours(parseInt(V)), p.setMinutes(parseInt(L)), p.setSeconds(0), p.setMilliseconds(0), m.effectiveAt = p.toISOString();
2344
+ }
2345
+ }
2346
+ }), e = A(new Array()), i = A([]), c = O(
2347
+ () => !!e.value.length || i.value.some((v) => v.errors.length)
2348
+ ), y = A();
2349
+ x({
2350
+ validateInputs: () => {
2351
+ var v, p;
2352
+ (p = (v = y.value) == null ? void 0 : v.validateInputs) == null || p.call(v);
2353
+ },
2354
+ resetInputsValidation: () => {
2355
+ var v, p;
2356
+ (p = (v = y.value) == null ? void 0 : v.resetInputsValidation) == null || p.call(v);
2357
+ },
2358
+ resetInputs: () => {
2359
+ var v, p;
2360
+ (p = (v = y.value) == null ? void 0 : v.resetInputs) == null || p.call(v);
2361
+ }
2362
+ });
2363
+ const { t: k } = fe();
2364
+ async function I(v) {
2365
+ e.value = [], i.value = [];
2366
+ try {
2367
+ C.value = !0;
2368
+ const [p] = await Promise.all([
2369
+ ss(v),
2370
+ // fake buffer
2371
+ new Promise((L) => setTimeout(L, 1e3))
2372
+ ]), V = Zo(p);
2373
+ if (V.invalidExcel) {
2374
+ e.value.push(
2375
+ V.invalidExcelMessage ?? k("inventory.ingredient.import.fileError.invalidExcel")
2376
+ );
2377
+ return;
2378
+ }
2379
+ if (i.value = V.importCreateResult, !i.value.length) {
2380
+ e.value.push(k("inventory.ingredient.import.fileError.noData"));
2381
+ return;
2382
+ }
2383
+ m.items = i.value.map((L) => L.poItems).flat();
2384
+ } catch (p) {
2385
+ l.open({
2386
+ title: k("inventory.ingredient.import.fileError.unableToRead"),
2387
+ message: p == null ? void 0 : p.message,
2388
+ type: "error"
2389
+ }), console.error("Error in reading file", p);
2390
+ } finally {
2391
+ e.value.length && l.open({
2392
+ title: k("inventory.ingredient.import.fileError.invalidExcel"),
2393
+ type: "error"
2394
+ }), C.value = !1;
2395
+ }
2396
+ }
2397
+ return be(r, (v) => {
2398
+ v && I(v);
2399
+ }), (v, p) => {
2400
+ const V = D("FmSelect"), L = D("FmDatePicker"), $ = D("FmTimePicker"), T = D("FmCircularProgress"), Y = D("FmLabel"), z = D("FmIcon"), E = D("FmButton"), j = D("FmForm");
2401
+ return S(), Q(j, {
2402
+ ref_key: "formRef",
2403
+ ref: y
2404
+ }, {
2405
+ default: R(() => [
2406
+ a("div", cn, [
2407
+ b(V, {
2408
+ modelValue: u.value,
2409
+ "onUpdate:modelValue": p[0] || (p[0] = (B) => u.value = B),
2410
+ label: "Transfer from",
2411
+ searchable: "",
2412
+ searchTarget: "label",
2413
+ items: d.value,
2414
+ rules: [s(qe)()]
2415
+ }, null, 8, ["modelValue", "items", "rules"]),
2416
+ b(L, {
2417
+ modelValue: h.value,
2418
+ "onUpdate:modelValue": p[1] || (p[1] = (B) => h.value = B),
2419
+ label: "Transfer date",
2420
+ rules: [s(qe)()]
2421
+ }, null, 8, ["modelValue", "rules"]),
2422
+ b($, {
2423
+ modelValue: o.value,
2424
+ "onUpdate:modelValue": p[2] || (p[2] = (B) => o.value = B),
2425
+ label: "Transfer time",
2426
+ rules: [s(qe)()]
2427
+ }, null, 8, ["modelValue", "rules"]),
2428
+ t.value ? (S(), F("div", pn, [
2429
+ a("div", null, [
2430
+ b(T, {
2431
+ size: "md",
2432
+ color: "neutral-gray-200"
2433
+ })
2434
+ ]),
2435
+ a("div", fn, q(s(k)("inventory.formField.loading")), 1)
2436
+ ])) : (S(), F(ne, { key: 1 }, [
2437
+ b(ts, {
2438
+ "max-file-size": 5,
2439
+ class: X({
2440
+ "w-full": !0,
2441
+ "h-[200px]": !r.value
2442
+ }),
2443
+ accept: ".xlsx,.xls,.csv",
2444
+ label: gt,
2445
+ onFileUpload: p[3] || (p[3] = (B) => r.value = B),
2446
+ "button-label": s(k)("inventory.ingredient.import.selectFile")
2447
+ }, Ut({ _: 2 }, [
2448
+ r.value ? {
2449
+ name: "default",
2450
+ fn: R(({ openFileDialog: B }) => [
2451
+ b(Y, null, {
2452
+ default: R(() => [
2453
+ Ie(q(gt))
2454
+ ]),
2455
+ _: 1
2456
+ }),
2457
+ a("div", vn, [
2458
+ a("div", {
2459
+ class: X([
2460
+ "fm-corner-radius-md p-16 flex items-center gap-16",
2461
+ {
2462
+ "border border-fm-color-neutral-gray-100": C.value,
2463
+ "border border-fm-color-neutral-gray-200": !C.value && !c.value,
2464
+ "border border-fm-color-system-error-200": c.value
2465
+ }
2466
+ ])
2467
+ }, [
2468
+ C.value ? (S(), Q(T, {
2469
+ key: 0,
2470
+ size: "md",
2471
+ color: "neutral-gray-200"
2472
+ })) : (S(), Q(z, {
2473
+ key: 1,
2474
+ name: c.value ? "error" : "attach_file",
2475
+ outline: "",
2476
+ color: c.value ? "system-error-300" : void 0
2477
+ }, null, 8, ["name", "color"])),
2478
+ a("div", {
2479
+ class: X([
2480
+ "fm-typo-en-body-md-400 flex-1 h-[36px] flex items-center",
2481
+ {
2482
+ "text-fm-color-typo-disabled": C.value,
2483
+ "text-fm-color-typo-primary": !C.value
2484
+ }
2485
+ ])
2486
+ }, [
2487
+ a("div", yn, q(r.value.name), 1)
2488
+ ], 2),
2489
+ C.value ? N("", !0) : (S(), F("div", bn, [
2490
+ b(E, {
2491
+ label: s(k)("inventory.ingredient.import.replaceFile"),
2492
+ variant: c.value ? "destructive" : "secondary",
2493
+ "prepend-icon": c.value ? void 0 : "autorenew",
2494
+ onClick: B
2495
+ }, null, 8, ["label", "variant", "prepend-icon", "onClick"])
2496
+ ]))
2497
+ ], 2),
2498
+ e.value.length ? (S(), F("div", gn, [
2499
+ (S(!0), F(ne, null, ge(e.value, (G, _) => (S(), F("div", {
2500
+ key: _,
2501
+ class: "flex gap-8 items-center"
2502
+ }, [
2503
+ b(z, {
2504
+ name: "error",
2505
+ size: "sm",
2506
+ color: "system-error-300"
2507
+ }),
2508
+ a("div", _n, q(G), 1)
2509
+ ]))), 128))
2510
+ ])) : N("", !0)
2511
+ ])
2512
+ ]),
2513
+ key: "0"
2514
+ } : void 0
2515
+ ]), 1032, ["class", "button-label"]),
2516
+ r.value ? (S(), F("div", hn, [
2517
+ a("div", kn, q(s(k)("inventory.ingredient.import.summary")), 1),
2518
+ (S(!0), F(ne, null, ge(i.value, (B, G) => (S(), Q(dn, {
2519
+ key: G,
2520
+ name: `Transfer Note ${G + 1}`,
2521
+ items: B.poItems,
2522
+ errors: B.errors,
2523
+ type: "create"
2524
+ }, null, 8, ["name", "items", "errors"]))), 128))
2525
+ ])) : N("", !0)
2526
+ ], 64))
2527
+ ])
2528
+ ]),
2529
+ _: 1
2530
+ }, 512);
2531
+ };
2532
+ }
2533
+ }), Sn = { class: "w-[480px]" }, Cn = /* @__PURE__ */ ae({
2534
+ __name: "XilnexImportDialog",
2535
+ props: {
2536
+ show: { type: Boolean }
2537
+ },
2538
+ emits: ["update:show", "submitted"],
2539
+ setup(f, { expose: x, emit: r }) {
2540
+ const l = r, t = Ft(f, "show"), m = De(), d = ot(), u = A(!1), h = A(), o = A();
2541
+ x({
2542
+ validateInputs: () => {
2543
+ var c, y;
2544
+ (y = (c = h.value) == null ? void 0 : c.validateInputs) == null || y.call(c);
2545
+ },
2546
+ resetInputsValidation: () => {
2547
+ var c, y;
2548
+ (y = (c = h.value) == null ? void 0 : c.resetInputsValidation) == null || y.call(c);
2549
+ },
2550
+ resetInputs: () => {
2551
+ var c, y;
2552
+ (y = (c = h.value) == null ? void 0 : c.resetInputs) == null || y.call(c);
2553
+ }
2554
+ });
2555
+ function e() {
2556
+ var c, y;
2557
+ (y = (c = h.value) == null ? void 0 : c.validateInputs) == null || y.call(c);
2558
+ }
2559
+ async function i() {
2560
+ var y, k, I, v, p;
2561
+ if (!((k = (y = o.value) == null ? void 0 : y.supplier) != null && k.name)) {
2562
+ m.open({
2563
+ title: "Upload failed",
2564
+ message: "Location is required",
2565
+ type: "error"
2566
+ });
2567
+ return;
2568
+ }
2569
+ if (!((I = o.value) != null && I.items) || ((p = (v = o.value) == null ? void 0 : v.items) == null ? void 0 : p.length) === 0) {
2570
+ m.open({
2571
+ title: "Upload failed",
2572
+ message: "No data to upload",
2573
+ type: "error"
2574
+ });
2575
+ return;
2576
+ }
2577
+ const c = o.value.effectiveAt ? new Date(o.value.effectiveAt) : null;
2578
+ if (!c) {
2579
+ m.open({
2580
+ title: "Invalid date",
2581
+ message: "Transfer date is required",
2582
+ type: "error"
2583
+ });
2584
+ return;
2585
+ }
2586
+ if (c.getTime() > (/* @__PURE__ */ new Date()).getTime()) {
2587
+ m.open({
2588
+ title: "Invalid date",
2589
+ message: "Transfer date cannot be in the future",
2590
+ type: "error"
2591
+ });
2592
+ return;
2593
+ }
2594
+ u.value = !0;
2595
+ try {
2596
+ await d.importFromXilnex(o.value), l("update:show", !1);
2597
+ } catch (V) {
2598
+ await new Promise((L) => setTimeout(L, 1e3)), m.open({
2599
+ title: "Upload failed",
2600
+ message: V == null ? void 0 : V.message,
2601
+ type: "error"
2602
+ });
2603
+ } finally {
2604
+ u.value = !1;
2605
+ }
2606
+ }
2607
+ return (c, y) => {
2608
+ const k = D("FmSpacer"), I = D("FmButton"), v = D("FmDialog");
2609
+ return S(), Q(v, {
2610
+ modelValue: s(t),
2611
+ "onUpdate:modelValue": y[2] || (y[2] = (p) => Ce(t) ? t.value = p : null),
2612
+ overlay: !0,
2613
+ "close-button": !1
2614
+ }, {
2615
+ "dialog-header": R(() => y[3] || (y[3] = [
2616
+ a("div", null, "Xilnex transfer order", -1)
2617
+ ])),
2618
+ "dialog-footer": R(() => [
2619
+ b(k, { class: "sm:hidden xs:hidden" }),
2620
+ b(I, {
2621
+ disabled: u.value,
2622
+ class: "sm:w-full xs:w-full",
2623
+ label: "Cancel",
2624
+ size: "md",
2625
+ variant: "tertiary",
2626
+ onClick: y[1] || (y[1] = (p) => l("update:show", !1))
2627
+ }, null, 8, ["disabled"]),
2628
+ b(I, {
2629
+ disabled: u.value,
2630
+ loading: u.value,
2631
+ class: "sm:w-full xs:w-full",
2632
+ label: "Upload",
2633
+ size: "md",
2634
+ variant: "primary",
2635
+ onClick: e
2636
+ }, null, 8, ["disabled", "loading"])
2637
+ ]),
2638
+ default: R(() => [
2639
+ a("div", Sn, [
2640
+ b(xn, {
2641
+ ref_key: "formRef",
2642
+ ref: h,
2643
+ onValidationSuccess: i,
2644
+ modelValue: o.value,
2645
+ "onUpdate:modelValue": y[0] || (y[0] = (p) => o.value = p)
2646
+ }, null, 8, ["modelValue"])
2647
+ ])
2648
+ ]),
2649
+ _: 1
2650
+ }, 8, ["modelValue"]);
2651
+ };
2652
+ }
2653
+ }), wn = { class: "flex flex-col py-8" }, In = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Fn = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary line-clamp-1" }, $n = { class: "fm-typo-en-body-md-400 text-fm-color-typo-primary line-clamp-1" }, Dn = {
2654
+ key: 0,
2655
+ class: "fm-typo-en-body-md-400 text-fm-color-typo-primary line-clamp-1"
2656
+ }, Tn = { class: "pt-8" }, _t = "ReceiveRequestViewSearchCriteria", Yn = /* @__PURE__ */ ae({
2657
+ __name: "ReceiveRequestView",
2658
+ setup(f) {
2659
+ const { t: x } = fe(), r = De();
2660
+ Be.object({
2661
+ name: Be.string().optional().nullable(),
2662
+ startDate: Be.string().optional().nullable(),
2663
+ endDate: Be.string().optional().nullable()
2664
+ });
2665
+ const l = O(
2666
+ () => !e._currentLocation || h.loading.value
2667
+ ), C = ps(), t = at();
2668
+ function m() {
2669
+ const $ = {
2670
+ name: "",
2671
+ ...vt()
2672
+ }, T = C.getItem(_t);
2673
+ if (!T)
2674
+ return $;
2675
+ try {
2676
+ return JSON.parse(T);
2677
+ } catch {
2678
+ return $;
2679
+ }
2680
+ }
2681
+ function d() {
2682
+ C.setItem(_t, JSON.stringify(u.value));
2683
+ }
2684
+ const u = A(m()), h = ls(
2685
+ Ke.RECEIVE_REQUEST,
2686
+ u.value
2687
+ ), { columnDefs: o } = rs(
2688
+ Ke.RECEIVE_REQUEST,
2689
+ h
2690
+ ), e = je();
2691
+ async function i() {
2692
+ const $ = `inventory-record_${yt(u.value.startDate).format("DD-MM-YYYY_HH-mm")}-${yt(u.value.endDate).format("DD-MM-YYYY_HH-mm")}.xlsx`, T = h.purchaseOrders.value.flatMap(
2693
+ (z) => z.items.map((E) => {
2694
+ const j = new Date(ds(z._id) ?? ""), B = z.effectiveAt ? new Date(z.effectiveAt) : void 0, G = me(
2695
+ us(E.sku, z.deliveryOrder || [])
2696
+ ), _ = me(E.quantity);
2697
+ return {
2698
+ "SKU code": E.code,
2699
+ "SKU name": E.name,
2700
+ "PO #": z.seqNumber,
2701
+ "Effective at": B,
2702
+ Date: j,
2703
+ Status: z.status,
2704
+ Reference: z.ref ?? "",
2705
+ "Received quantity": G,
2706
+ "Ordered quantity": _,
2707
+ Unit: E.sku.unit.abbrev,
2708
+ "Total cost": E.totalCost ? Je(E.totalCost) : null
2709
+ };
2710
+ })
2711
+ ), Y = [
2712
+ "SKU code",
2713
+ "SKU name",
2714
+ "PO #",
2715
+ "Date",
2716
+ "Status",
2717
+ "Reference",
2718
+ "Received quantity",
2719
+ "Ordered quantity",
2720
+ "Unit"
2721
+ ];
2722
+ t.enableBackdatePo && Y.insert("Effective at", 4), t.enableTotalCost && Y.push("Total cost"), await cs(
2723
+ [
2724
+ {
2725
+ name: "purchases",
2726
+ data: T,
2727
+ columns: Y
2728
+ }
2729
+ ],
2730
+ $
2731
+ ), r.open({
2732
+ title: x("inventory.transfer.receiveRequest.export.success"),
2733
+ message: x("inventory.transfer.receiveRequest.export.message", [$]),
2734
+ type: "success"
2735
+ });
2736
+ }
2737
+ const c = A(vt()), y = A("");
2738
+ be([() => c.value], ([$]) => {
2739
+ !$.startDate || !$.endDate || (u.value.startDate = $.startDate, u.value.endDate = $.endDate, h.updateDateRange(
2740
+ u.value.startDate,
2741
+ u.value.endDate
2742
+ ), d());
2743
+ }), be([() => y.value], () => {
2744
+ d();
2745
+ });
2746
+ function k($) {
2747
+ if ($ === "create") {
2748
+ if (l.value) {
2749
+ r.open({
2750
+ title: "Loading data...",
2751
+ message: "Please wait.",
2752
+ type: "info"
2753
+ });
2754
+ return;
2755
+ }
2756
+ return h.promptCreateTransferDialog();
2757
+ }
2758
+ if ($ === "upload" && t.enableXilnexTransferNote)
2759
+ return h.promptUploadTransferDialog();
2760
+ if ($ === "refresh")
2761
+ return h.fetchData();
2762
+ if ($ === "export")
2763
+ return i();
2764
+ }
2765
+ const { breakpoints: I } = nt(), v = O(() => I.value.xs || I.value.sm), p = O(() => v.value ? 10 : 20), V = os(), L = O(() => [
2766
+ {
2767
+ label: x("inventory.transfer.receiveRequest.actions.create"),
2768
+ value: "create",
2769
+ isPrimary: !0,
2770
+ prependIcon: "add"
2771
+ },
2772
+ ...t.enableXilnexTransferNote ? [
2773
+ {
2774
+ label: "Upload",
2775
+ value: "upload"
2776
+ }
2777
+ ] : [],
2778
+ {
2779
+ label: x("common.refresh"),
2780
+ value: "refresh"
2781
+ },
2782
+ {
2783
+ label: x("common.export"),
2784
+ value: "export"
2785
+ }
2786
+ ]);
2787
+ return ($, T) => {
2788
+ const Y = D("FmTable");
2789
+ return S(), Q(ns, {
2790
+ title: s(x)("inventory.transfer.receiveRequest.title2"),
2791
+ actions: L.value,
2792
+ "onClick:action": k
2793
+ }, {
2794
+ default: R(() => {
2795
+ var z;
2796
+ return [
2797
+ a("div", {
2798
+ class: X([
2799
+ "flex flex-col gap-8 max-h-full",
2800
+ {
2801
+ "p-0": v.value,
2802
+ "px-24 ": !v.value
2803
+ }
2804
+ ])
2805
+ }, [
2806
+ b(as, {
2807
+ "date-range-query": "",
2808
+ "date-range": c.value,
2809
+ "onUpdate:dateRange": T[0] || (T[0] = (E) => c.value = E),
2810
+ searchable: "",
2811
+ "change-location": "",
2812
+ search: y.value,
2813
+ "onUpdate:search": T[1] || (T[1] = (E) => y.value = E)
2814
+ }, null, 8, ["date-range", "search"]),
2815
+ (S(), Q(Y, {
2816
+ style: kt(s(V).tableHeight),
2817
+ "column-defs": s(o),
2818
+ "row-data": s(h).purchaseOrders.value,
2819
+ "search-value": y.value,
2820
+ loading: l.value,
2821
+ onRowClick: T[2] || (T[2] = (E) => s(h).promptShowTransferDetails(E.original)),
2822
+ key: (z = s(e)._currentLocation) == null ? void 0 : z.dbName,
2823
+ "page-size": p.value
2824
+ }, {
2825
+ "list-row": R((E) => [
2826
+ b(Ct, {
2827
+ row: E,
2828
+ onRowClick: s(h).promptShowTransferDetails
2829
+ }, {
2830
+ default: R((j) => {
2831
+ var B, G, _, g, M, J, le, Fe, $e, Ae, Ee, Qe, Me, ke, n, w, Z, ie, ue, xe;
2832
+ return [
2833
+ a("div", wn, [
2834
+ a("div", In, [
2835
+ b(s(pe), {
2836
+ render: (_ = (G = (B = j._id) == null ? void 0 : B.column) == null ? void 0 : G.columnDef) == null ? void 0 : _.cell,
2837
+ props: (M = (g = j._id) == null ? void 0 : g.getContext) == null ? void 0 : M.call(g)
2838
+ }, null, 8, ["render", "props"])
2839
+ ]),
2840
+ a("div", Fn, [
2841
+ b(s(pe), {
2842
+ render: (Fe = (le = (J = j.supplier_name) == null ? void 0 : J.column) == null ? void 0 : le.columnDef) == null ? void 0 : Fe.cell,
2843
+ props: (Ae = ($e = j.supplier_name) == null ? void 0 : $e.getContext) == null ? void 0 : Ae.call($e)
2844
+ }, null, 8, ["render", "props"])
2845
+ ]),
2846
+ a("div", $n, q(E.original.items.map((_e) => `${_e.name}`).join(", ")), 1),
2847
+ E.original.ref ? (S(), F("div", Dn, [
2848
+ b(s(pe), {
2849
+ render: (Me = (Qe = (Ee = j.ref) == null ? void 0 : Ee.column) == null ? void 0 : Qe.columnDef) == null ? void 0 : Me.cell,
2850
+ props: (n = (ke = j.ref) == null ? void 0 : ke.getContext) == null ? void 0 : n.call(ke)
2851
+ }, null, 8, ["render", "props"])
2852
+ ])) : N("", !0),
2853
+ a("div", Tn, [
2854
+ b(s(pe), {
2855
+ render: (ie = (Z = (w = j.status) == null ? void 0 : w.column) == null ? void 0 : Z.columnDef) == null ? void 0 : ie.cell,
2856
+ props: (xe = (ue = j.status) == null ? void 0 : ue.getContext) == null ? void 0 : xe.call(ue)
2857
+ }, null, 8, ["render", "props"])
2858
+ ])
2859
+ ])
2860
+ ];
2861
+ }),
2862
+ _: 2
2863
+ }, 1032, ["row", "onRowClick"])
2864
+ ]),
2865
+ _: 1
2866
+ }, 8, ["style", "column-defs", "row-data", "search-value", "loading", "page-size"]))
2867
+ ], 2),
2868
+ (S(), Q(Ot, { to: "body" }, [
2869
+ b(Ko, Xe(s(h).transferDialogProps.value, {
2870
+ onSubmitted: s(h).fetchData,
2871
+ "on-submit:return-stock": (E, j) => s(h).submitAction(
2872
+ E,
2873
+ "returnStock",
2874
+ void 0,
2875
+ j
2876
+ )
2877
+ }), null, 16, ["onSubmitted", "on-submit:return-stock"]),
2878
+ b(is, Xe({
2879
+ scope: s(Ke).RECEIVE_REQUEST
2880
+ }, s(h).transferDetailsProps.value, {
2881
+ onSubmitted: s(h).fetchData,
2882
+ onReturnStock: s(h).promptReturnTransferDialog
2883
+ }), null, 16, ["scope", "onSubmitted", "onReturnStock"]),
2884
+ b(Cn, Nt(Bt(s(h).xilnexImportDialogProps.value)), null, 16)
2885
+ ]))
2886
+ ];
2887
+ }),
2888
+ _: 1
2889
+ }, 8, ["title", "actions"]);
2890
+ };
2891
+ }
2892
+ });
2893
+ export {
2894
+ Yn as default
2895
+ };