@feedmepos/mf-inventory-portal 0.0.25-dev.2 → 0.0.25-dev.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/dist/App-D6WBVERc.js +278 -0
  2. package/dist/ApprovalView-BIBoagE8.js +146 -0
  3. package/dist/{BindingsDialog-qeGh3ND8.js → BindingsDialog-DHRRkK1Z.js} +6 -6
  4. package/dist/{BindingsPicker-SfiA8fmD.js → BindingsPicker-DohvMDDF.js} +3 -3
  5. package/dist/{BindingsTable-BjW-eJr6.js → BindingsTable-C_JwU9ei.js} +6 -6
  6. package/dist/ClosingDraftView-BBebhUj-.js +1308 -0
  7. package/dist/ClosingTemplateView-CXRN19-D.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-BJufUQNE.js +215 -0
  10. package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-5rldKjyh.js → FmUnitInput.vue_vue_type_script_setup_true_lang-C5Xk19jY.js} +52 -52
  11. package/dist/IngredientBindedItem.vue_vue_type_script_setup_true_lang-7HNI82u-.js +51 -0
  12. package/dist/{IngredientGroupView-CGyyFyvj.js → IngredientGroupView-l2bAc1Kj.js} +1 -1
  13. package/dist/{IngredientsView-BLKk-VxQ.js → IngredientsView-zDXt7KEx.js} +394 -382
  14. package/dist/{IntegrationView-C6gwvZ9b.js → IntegrationView-BYnlAPrP.js} +660 -623
  15. package/dist/{InventoryBindingForm-BB3ZN3Lx.js → InventoryBindingForm-BuweG4Vl.js} +1 -1
  16. package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-PT7Quw7j.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-DgxN0U4N.js} +99 -99
  17. package/dist/{InventoryBindingSummary-yr0oie3c.js → InventoryBindingSummary-BpEo0JsK.js} +1 -1
  18. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-DjJGUE9a.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-CcjzkzCt.js} +1 -1
  19. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-O1mYRa5W.js → PremiumBadge.vue_vue_type_script_setup_true_lang-Ej20iSHA.js} +15 -15
  20. package/dist/PublishView-DCZ0zIaP.js +222 -0
  21. package/dist/{PurchaseOrderPrintPreview-Q_9-KVNj.js → PurchaseOrderPrintPreview-Cag7UEvz.js} +1 -1
  22. package/dist/ReceiveRequestView-ChIJGA98.js +2319 -0
  23. package/dist/{RecipeView-DBfugmRY.js → RecipeView-bBshe0eF.js} +32 -31
  24. package/dist/{index-CgspzSQi.js → StockView-D6-oKpAC.js} +3577 -1764
  25. package/dist/{SupplierView-BQViPyfj.js → SupplierView-dyIcGp9Q.js} +12 -11
  26. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-C_7wbQow.js +1771 -0
  27. package/dist/TransferTemplateView-D2rxV0k_.js +1660 -0
  28. package/dist/{UnitView-CrbFeWaB.js → UnitView-DVS5Az5c.js} +14 -14
  29. package/dist/{WarehouseView-Dy5GljxY.js → WarehouseView-CR03TpnA.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/purchase-order.d.ts +2 -1
  33. package/dist/{app-D0O4wr2X.js → app-oV9ISfFL.js} +28343 -28141
  34. package/dist/app.js +1 -1
  35. package/dist/components/FmAutocompleteTextField.vue.d.ts +31 -0
  36. package/dist/components/FmCustomAttribute.vue.d.ts +3 -8
  37. package/dist/components/FmLockableField.vue.d.ts +3 -0
  38. package/dist/components/FmMultiselectDialog.d.ts +46 -0
  39. package/dist/components/FmMultiselectDialog.vue.d.ts +20 -3
  40. package/dist/components/FmMultiselectDialogProps.d.ts +2 -0
  41. package/dist/components/MountListener.vue.d.ts +15 -0
  42. package/dist/components/inventory-binding/InventoryBinding.vue.d.ts +1 -1
  43. package/dist/components/shell/inventory/binding-ui.vue.d.ts +1 -1
  44. package/dist/{decimal-CPGmj9BT.js → decimal-C7zgfr5G.js} +1 -1
  45. package/dist/feature-CDQQ-mV9.js +1003 -0
  46. package/dist/{format-unit-display-CMM6DZJj.js → format-unit-display-CVBzrNQ4.js} +334 -327
  47. package/dist/helper/fuzzy.d.ts +10 -0
  48. package/dist/index-0VS4cuk3.js +35546 -0
  49. package/dist/{stock-9nTT4Amy.js → stock-BIP_NIK_.js} +3 -3
  50. package/dist/stores/feature.d.ts +4 -7
  51. package/dist/stores/integration/netsuite.d.ts +5 -0
  52. package/dist/stores/inventory.d.ts +135 -8
  53. package/dist/stores/location.d.ts +100 -0
  54. package/dist/stores/warehouse.d.ts +1 -0
  55. package/dist/style.css +1 -1
  56. package/dist/{supplier-CH4EwBZM.js → supplier-DUQ2VSMg.js} +1 -1
  57. package/dist/tsconfig.app.tsbuildinfo +1 -1
  58. package/dist/use-ingredient-select-dialog-VkU5_Aaj.js +51 -0
  59. package/dist/{use-inventory-binding-dialog-Dli3xtq4.js → use-inventory-binding-dialog-BXp0z3v_.js} +1 -1
  60. package/dist/views/adjustment-template/wastage-template/actions.d.ts +24 -0
  61. package/dist/views/adjustment-template/wastage-template/table.d.ts +24 -0
  62. package/dist/views/closing-draft/components/closing-draft-dialog/ClosingDraftDialog.vue.d.ts +8 -4
  63. package/dist/views/closing-draft/composables/use-closing-draft-actions.d.ts +4 -1
  64. package/dist/views/closing-draft/composables/use-closing-draft-table.d.ts +48 -24
  65. package/dist/views/closing-draft/helpers/export-draft.helper.d.ts +1 -1
  66. package/dist/views/closing-template/components/closing-template-form/composables/use-closing-template-items.d.ts +1 -1
  67. package/dist/views/closing-template/composables/use-closing-template-actions.d.ts +36 -12
  68. package/dist/views/closing-template/composables/use-closing-template-table.d.ts +36 -12
  69. package/dist/views/dev/components/AutocompleteTextField.vue.d.ts +2 -0
  70. package/dist/views/ingredient-group/composables/use-ingredient-group-table.d.ts +3 -3
  71. package/dist/views/ingredients/components/ingredient-form/IngredientForm.vue.d.ts +2 -2
  72. package/dist/views/ingredients/composables/use-ingredient-select-dialog.d.ts +16 -0
  73. package/dist/views/ingredients/composables/use-ingredient-table.d.ts +1 -1
  74. package/dist/views/receive-request/components/netsuite/NetSuiteProps.d.ts +2 -0
  75. package/dist/views/receive-request/components/transfer-details/TransferDetails.vue.d.ts +1387 -0
  76. package/dist/views/receive-request/components/transfer-details/TransferDetailsProps.d.ts +5 -1
  77. package/dist/views/receive-request/components/transfer-dialog/TransferDialogProps.d.ts +3 -0
  78. package/dist/views/receive-request/components/transfer-form/TransferFormProps.d.ts +1 -2
  79. package/dist/views/receive-request/components/transfer-form/components/ForecastStock.vue.d.ts +48 -2
  80. package/dist/views/receive-request/components/transfer-form/components/TransferItemTable.vue.d.ts +490 -2
  81. package/dist/views/receive-request/components/transfer-form/components/TransferSubItemTable.vue.d.ts +72 -0
  82. package/dist/views/receive-request/components/transfer-form/composables/use-transfer-items.d.ts +25 -2
  83. package/dist/views/receive-request/components/transfer-form/helpers/calculate-sub-item-total.helper.d.ts +4 -0
  84. package/dist/views/receive-request/composables/use-receive-request-form.d.ts +693 -35
  85. package/dist/views/receive-request/composables/use-receive-request-table.d.ts +684 -35
  86. package/dist/views/receive-request/helper/po-to-po-template.util.d.ts +1 -0
  87. package/dist/views/receive-request/helper/print-po.d.ts +9 -2
  88. package/dist/views/stock/components/dialog/AdjustedItemForm.vue.d.ts +2 -2
  89. package/dist/views/transfer-template/components/transfer-template-form/components/TransferTemplateItem.vue.d.ts +270 -2
  90. package/dist/views/transfer-template/components/transfer-template-form/components/TransferTemplateItemTable.vue.d.ts +286 -0
  91. package/dist/views/transfer-template/components/transfer-template-form/components/TransferTemplateSubItem.vue.d.ts +74 -0
  92. package/dist/views/transfer-template/components/transfer-template-form/components/TransferTemplateSubItemTable.vue.d.ts +92 -0
  93. package/dist/views/transfer-template/components/transfer-template-form/composables/use-template-enabled-locations-2.d.ts +8 -0
  94. package/dist/views/transfer-template/components/transfer-template-form/composables/use-template-enabled-locations.d.ts +1 -0
  95. package/dist/views/transfer-template/components/transfer-template-form/composables/use-transfer-template-items.d.ts +36 -2
  96. package/dist/views/transfer-template/composables/use-transfer-template-actions.d.ts +456 -12
  97. package/dist/views/transfer-template/composables/use-transfer-template-table.d.ts +456 -12
  98. package/dist/views/transfer-template/helpers/location-to-po-supplier.util.d.ts +75 -0
  99. package/dist/views/warehouse/components/WarehouseForm.vue.d.ts +2 -0
  100. package/dist/{vue-i18n-BcYt8MNZ.js → vue-i18n-CCd5_SRR.js} +212 -212
  101. package/package.json +3 -3
  102. package/dist/App-oKNdl2la.js +0 -276
  103. package/dist/ApprovalView-hDGkcBDy.js +0 -138
  104. package/dist/ClosingDraftView-CEeeL7W4.js +0 -1225
  105. package/dist/ClosingTemplateView-CkS9e0MV.js +0 -1819
  106. package/dist/FmCustomAttribute.vue_vue_type_script_setup_true_lang-CIBSvY0s.js +0 -142
  107. package/dist/FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-Dg_7ELeT.js +0 -286
  108. package/dist/PublishView-ByXdmuJL.js +0 -192
  109. package/dist/ReceiveRequestView-CApg7LGM.js +0 -1876
  110. package/dist/StockView-D6o_oUlz.js +0 -1817
  111. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-D2skLe2M.js +0 -1327
  112. package/dist/TransferTemplateView-DVesObTd.js +0 -1284
  113. package/dist/components/FmCustomAttribute2.vue.d.ts +0 -18
  114. package/dist/index-P5iEcRw3.js +0 -29202
  115. package/dist/views/receive-request/components/transfer-form/TransferForm.vue.d.ts +0 -2628
@@ -0,0 +1,2319 @@
1
+ import { defineComponent as le, onMounted as Be, onUnmounted as Vt, renderSlot as Rt, h as q, reactive as vt, computed as O, openBlock as C, createElementBlock as V, Fragment as be, renderList as Te, createElementVNode as i, toDisplayString as E, unref as t, resolveComponent as P, createVNode as v, withCtx as T, createCommentVNode as j, ref as Q, createBlock as Y, watch as _e, normalizeClass as ee, createTextVNode as Me, normalizeStyle as bt, nextTick as qt, mergeProps as Ye, isRef as we, Teleport as At } from "vue";
2
+ import { H as Ke, J as Et, Y as Ot, Z as $e, b as Je, l as mt, i as ae, O as Ne, a0 as We, K as gt, as as Mt, A as Ue, M as Ut, m as _t, ab as Xe, E as de, at as Bt, a as kt, au as Nt, av as zt, aw as Lt, G as ht, u as ze, ax as Ht, $ as jt, T as Qt, ay as Yt, B as St, d as De, az as Oe, a5 as ct, y as Kt, _ as Zt, z as Gt, N as pt } from "./app-oV9ISfFL.js";
3
+ import { u as Ct, a as Jt, P as Qe, b as Wt, _ as Xt, g as es } from "./TransferDetails.vue_vue_type_script_setup_true_lang-C_7wbQow.js";
4
+ import { _ as xt, u as ts, i as ss, e as os } from "./PremiumBadge.vue_vue_type_script_setup_true_lang-Ej20iSHA.js";
5
+ import { u as ns } from "./useTabStorage-BkIVScW_.js";
6
+ import { useDialog as wt, useBreakpoints as et, components as ue, FmButtonVariant as as, useSnackbar as Le, useProxiedModel as ls } from "@feedmepos/ui-library";
7
+ import { P as X, u as It } from "./format-unit-display-CVBzrNQ4.js";
8
+ import { _ as Ft, F as Dt, a as Ze, b as $t } from "./FmUnitInput.vue_vue_type_script_setup_true_lang-C5Xk19jY.js";
9
+ import { u as tt } from "./feature-CDQQ-mV9.js";
10
+ import { c as ve, u as rs, _ as is, l as us } from "./FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-BJufUQNE.js";
11
+ import { useI18n as ke } from "@feedmepos/mf-common";
12
+ import { defineStore as ds } from "pinia";
13
+ import { u as st } from "./supplier-DUQ2VSMg.js";
14
+ import { _ as ms } from "./PreviewBadge.vue_vue_type_script_setup_true_lang-CRZiQHjx.js";
15
+ import { u as cs } from "./vue-i18n-CCd5_SRR.js";
16
+ import "./array-hChJVZLE.js";
17
+ const ps = /* @__PURE__ */ le({
18
+ __name: "MountListener",
19
+ emits: ["mounted", "unmounted"],
20
+ setup(m, { emit: b }) {
21
+ const l = b;
22
+ return Be(() => l("mounted")), Vt(() => l("unmounted")), (r, h) => Rt(r.$slots, "default");
23
+ }
24
+ }), Tt = ds("inventoryMultiSelectDialog", () => {
25
+ const m = wt(), { t: b } = ke();
26
+ return { multiSelect: async (s, p, c) => {
27
+ const u = c ?? ((e) => e), { promise: _, resolve: n } = Promise.withResolvers();
28
+ return m.open({
29
+ title: "Select items",
30
+ closeButton: !0,
31
+ contentComponent: Ke,
32
+ contentComponentProps: {
33
+ modelValue: p ?? [],
34
+ items: s,
35
+ virtualScroll: !0,
36
+ onClose: () => n(null)
37
+ },
38
+ primaryActions: {
39
+ text: b("common.confirm"),
40
+ close: !0
41
+ },
42
+ secondaryActions: {
43
+ text: b("common.close"),
44
+ close: !0,
45
+ variant: "tertiary"
46
+ }
47
+ }).onPrimary((e) => {
48
+ const a = e.map((k) => u(k));
49
+ n(a);
50
+ }), _;
51
+ }, singleSelect: async (s, p, c) => {
52
+ const u = c ?? ((e) => e), { promise: _, resolve: n } = Promise.withResolvers();
53
+ return m.open({
54
+ title: "Select items",
55
+ closeButton: !0,
56
+ contentComponent: Ke,
57
+ contentComponentProps: {
58
+ modelValue: p ? [p] : [],
59
+ items: s,
60
+ virtualScroll: !0,
61
+ onClose: () => n(void 0),
62
+ singleSelect: !0
63
+ },
64
+ primaryActions: {
65
+ text: b("common.confirm"),
66
+ close: !0
67
+ },
68
+ secondaryActions: {
69
+ text: b("common.close"),
70
+ close: !0,
71
+ variant: "tertiary"
72
+ }
73
+ }).onPrimary((e) => {
74
+ if (!e.length)
75
+ return n(null);
76
+ const a = u(e[0]);
77
+ n(a);
78
+ }), _;
79
+ }, confirmation: async (s, p, c, u, _) => {
80
+ const { promise: n, resolve: e } = Promise.withResolvers();
81
+ return m.open({
82
+ title: s,
83
+ message: typeof p == "string" ? p : void 0,
84
+ contentComponent: q(
85
+ ps,
86
+ {
87
+ onUnmounted: () => {
88
+ e(null);
89
+ }
90
+ },
91
+ p
92
+ ),
93
+ contentComponentProps: {},
94
+ primaryActions: c ?? {
95
+ text: b("common.confirm"),
96
+ close: !0
97
+ },
98
+ secondaryActions: u ?? {
99
+ text: b("common.close"),
100
+ close: !0,
101
+ variant: "tertiary"
102
+ },
103
+ tertiaryActions: _,
104
+ closeButton: !0,
105
+ dismissAway: !0
106
+ }).onPrimary(() => {
107
+ e((c == null ? void 0 : c.value) ?? !0);
108
+ }).onSecondary(() => {
109
+ e((u == null ? void 0 : u.value) ?? !1);
110
+ }).onTertiary(() => {
111
+ e((_ == null ? void 0 : _.value) ?? void 0);
112
+ }), n;
113
+ } };
114
+ });
115
+ function Ge(m) {
116
+ return m.reduce((b, l) => {
117
+ const r = l.measurement ? Et(l.quantity, l.measurement.conversion) : l.quantity;
118
+ return Ot(b, r);
119
+ }, $e.reset());
120
+ }
121
+ var H = /* @__PURE__ */ ((m) => (m.Code = "Code", m.Name = "Name", m.TemplateName = "TemplateName", m.Amount = "Amount", m.Cost = "Cost", m.Delete = "Delete", m))(H || {});
122
+ const fs = () => (ke(), q(
123
+ xt,
124
+ {
125
+ zIndex: 50,
126
+ class: "whitespace-nowrap"
127
+ },
128
+ `Total (${_t()})`
129
+ ));
130
+ function ys(m) {
131
+ const { t: b } = ke(), l = vt({}), { breakpoints: r } = et(), h = tt(), s = Je(), p = Tt();
132
+ Be(() => {
133
+ for (const n of m.items) {
134
+ if (!n.totalCost)
135
+ continue;
136
+ const e = ve(n.sku, n.quantity, n.measurement, {
137
+ supplier: m.supplier
138
+ }), a = n.totalCost ?? $e.reset();
139
+ e ? l[n.sku._id] = e.amount !== a.amount || e.precision !== a.precision : l[n.sku._id] = !0;
140
+ }
141
+ });
142
+ function c(n) {
143
+ var a, k, S, g, x, w, $;
144
+ return !!(((k = (a = n.defaultCost) == null ? void 0 : a.costPerUnit) == null ? void 0 : k.amount) ?? (($ = (w = (x = (g = (S = m.supplier) == null ? void 0 : S.supplyItems) == null ? void 0 : g.find((M) => M.skuId === n._id)) == null ? void 0 : x.defaultCost) == null ? void 0 : w.costPerUnit) == null ? void 0 : $.amount));
145
+ }
146
+ const u = [
147
+ {
148
+ id: "Code",
149
+ header: () => b("inventory.transfer.form.items.table.Code"),
150
+ accessorKey: "code",
151
+ size: 200,
152
+ cell(n) {
153
+ var a;
154
+ const e = n.row.original;
155
+ return (a = e.subItems) != null && a.length ? q(
156
+ "span",
157
+ { class: "text-fm-color-typo-primary fm-typo-en-body-md-600 line-clamp-1" },
158
+ e.sku.code
159
+ ) : s.isEnabled ? q(
160
+ ue.FmTooltip,
161
+ {
162
+ content: e.code,
163
+ placement: "top",
164
+ variant: "plain",
165
+ zIndex: 50
166
+ },
167
+ q(
168
+ "span",
169
+ {
170
+ class: "flex-auto line-clamp-2 text-ellipsis break-all"
171
+ },
172
+ e.code
173
+ )
174
+ ) : q(ue.FmTextField, {
175
+ modelValue: e.code,
176
+ "onUpdate:modelValue": (k) => {
177
+ m.updateItem({
178
+ ...e,
179
+ code: k
180
+ });
181
+ },
182
+ key: e.sku._id,
183
+ rules: [mt()],
184
+ labelMark: "required"
185
+ });
186
+ },
187
+ enableSorting: !1
188
+ },
189
+ {
190
+ id: "Name",
191
+ header: () => b("inventory.transfer.form.items.table.Name"),
192
+ minSize: 300,
193
+ cell(n) {
194
+ var a;
195
+ const e = n.row.original;
196
+ return (a = e.subItems) != null && a.length ? q(
197
+ "span",
198
+ { class: "text-fm-color-typo-primary fm-typo-en-body-md-600 line-clamp-1" },
199
+ e.sku.name
200
+ ) : s.isEnabled ? q(
201
+ ue.FmTooltip,
202
+ {
203
+ content: e.name,
204
+ placement: "top",
205
+ variant: "plain",
206
+ zIndex: 50
207
+ },
208
+ q(
209
+ "span",
210
+ {
211
+ class: "flex-auto line-clamp-2 text-ellipsis break-all"
212
+ },
213
+ e.name
214
+ )
215
+ ) : q(ue.FmTextField, {
216
+ modelValue: e.name,
217
+ "onUpdate:modelValue": (k) => {
218
+ m.updateItem({
219
+ ...e,
220
+ name: k
221
+ });
222
+ },
223
+ key: e.sku._id,
224
+ rules: [mt()],
225
+ labelMark: "required"
226
+ });
227
+ },
228
+ enableSorting: !1
229
+ },
230
+ {
231
+ id: "TemplateName",
232
+ header: () => b("inventory.transfer.form.items.table.Name"),
233
+ minSize: 300,
234
+ enableSorting: !1,
235
+ cell(n) {
236
+ var S, g;
237
+ const e = n.row.original, a = (S = e.subItems) != null && S.length ? e.sku.code : e.code, k = (g = e.subItems) != null && g.length ? e.sku.name : e.name;
238
+ return q(
239
+ ue.FmTooltip,
240
+ { zIndex: 50 },
241
+ {
242
+ default() {
243
+ return q("div", { class: "flex flex-col w-full" }, [
244
+ q(
245
+ "div",
246
+ { class: "line-clamp-1 fm-typo-en-body-lg-400 text-fm-color-typo-primary" },
247
+ k
248
+ ),
249
+ q(
250
+ "div",
251
+ {
252
+ class: "line-clamp-1 fm-typo-en-body-md-400 text-fm-color-typo-secondary"
253
+ },
254
+ a
255
+ )
256
+ ]);
257
+ },
258
+ content() {
259
+ return k;
260
+ }
261
+ }
262
+ );
263
+ }
264
+ },
265
+ {
266
+ id: "Amount",
267
+ header: () => b("inventory.transfer.form.items.table.Amount"),
268
+ minSize: 200,
269
+ cell(n) {
270
+ var k, S, g, x;
271
+ const e = n.row.original;
272
+ if ((k = e.subItems) != null && k.length) {
273
+ const w = Ge(e.subItems);
274
+ return q(
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
+ q("span", { class: " fm-typo-en-body-md-400" }, "Total: "),
281
+ q(
282
+ "span",
283
+ { class: " fm-typo-en-body-md-600" },
284
+ `${ae(w)} ${e.sku.unit.abbrev}`
285
+ )
286
+ ]
287
+ );
288
+ }
289
+ const a = (x = (g = (S = m.template) == null ? void 0 : S.purchaseOrder) == null ? void 0 : g.items) == null ? void 0 : x.find(
290
+ (w) => w.sku._id === e.sku._id
291
+ );
292
+ return q(Ft, {
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": (w) => {
303
+ const $ = {
304
+ ...e,
305
+ quantity: w.amount,
306
+ measurement: w.measurement
307
+ };
308
+ h.enableTotalCost && ($.totalCost = ve(e.sku, e.quantity, e.measurement, {
309
+ supplier: m.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: l[e.sku._id] ? $.totalCost : void 0
313
+ })), m.updateItem($);
314
+ },
315
+ stepper: a == null ? void 0 : a.quantityStep,
316
+ disableUnit: !!a,
317
+ disabled: m.disabled,
318
+ rules: [
319
+ Dt(
320
+ +ae(
321
+ (a != null && a.minimumQuantity && (a == null ? void 0 : a.minimumQuantity.amount) > 0 ? a == null ? void 0 : a.minimumQuantity : void 0) ?? {
322
+ amount: 1,
323
+ precision: Ne(e.sku.unit, e.measurement)
324
+ }
325
+ )
326
+ ),
327
+ a != null && a.maximumQuantity ? Ze(
328
+ +ae(a == null ? void 0 : a.maximumQuantity)
329
+ ) : Ze(1 / 0),
330
+ ...a != null && a.quantityStep ? [$t(a.quantityStep)] : []
331
+ ],
332
+ applyDefaultRules: !0
333
+ });
334
+ },
335
+ enableSorting: !1
336
+ },
337
+ {
338
+ id: "Cost",
339
+ header: fs,
340
+ size: 180,
341
+ cell(n) {
342
+ const e = n.row.original, a = c(e.sku), k = r.value.xs || r.value.sm;
343
+ return !l[e.sku._id] && a ? q(
344
+ "div",
345
+ {
346
+ class: [
347
+ "flex gap-4 fm-typo-en-body-md-400 items-center",
348
+ m.disabled ? "text-fm-color-typo-disabled" : ""
349
+ ],
350
+ key: e.sku._id
351
+ },
352
+ [
353
+ q(ue.FmButton, {
354
+ prependIcon: "edit",
355
+ variant: as.Tertiary,
356
+ disabled: m.disabled,
357
+ onClick() {
358
+ m.updateItem({
359
+ ...e,
360
+ totalCost: ve(e.sku, e.quantity, e.measurement, {
361
+ supplier: m.supplier
362
+ })
363
+ }), l[e.sku._id] = !0;
364
+ }
365
+ }),
366
+ q(
367
+ "div",
368
+ {
369
+ class: "flex flex-col"
370
+ },
371
+ [
372
+ q(
373
+ "span",
374
+ k ? We(
375
+ ve(e.sku, e.quantity, e.measurement, {
376
+ supplier: m.supplier
377
+ })
378
+ ) : ae(
379
+ ve(e.sku, e.quantity, e.measurement, {
380
+ supplier: m.supplier
381
+ })
382
+ )
383
+ ),
384
+ q(
385
+ "span",
386
+ {
387
+ class: [
388
+ "fm-typo-en-body-sm-400",
389
+ m.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-neutral-gray-400"
390
+ ]
391
+ },
392
+ b("inventory.transfer.form.items.autoCalculated")
393
+ )
394
+ ]
395
+ )
396
+ ]
397
+ ) : q(
398
+ ue.FmTextField,
399
+ {
400
+ modelValue: ae(e.totalCost ?? { amount: 0, precision: 0 }),
401
+ key: e.sku._id,
402
+ "onUpdate:modelValue": (S) => {
403
+ m.updateItem({
404
+ ...e,
405
+ totalCost: {
406
+ ...gt(+S),
407
+ currency: Mt()
408
+ }
409
+ });
410
+ },
411
+ rules: [Ue(0), Ut(2)]
412
+ },
413
+ {
414
+ prepend() {
415
+ return k ? q(
416
+ "div",
417
+ {
418
+ class: [
419
+ "text-fm-typo-en-body-lg-400",
420
+ m.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-typo-primary"
421
+ ]
422
+ },
423
+ _t()
424
+ ) : null;
425
+ },
426
+ append() {
427
+ return a ? q(ue.FmButton, {
428
+ prependIcon: "close",
429
+ variant: "tertiary",
430
+ disabled: m.disabled,
431
+ onClick() {
432
+ m.updateItem({
433
+ ...e,
434
+ // NOTE: different from PO template, if a default cost is reenabled,
435
+ // the total cost will automatically assigned
436
+ totalCost: ve(e.sku, e.quantity, e.measurement, {
437
+ supplier: m.supplier
438
+ })
439
+ }), l[e.sku._id] = !1;
440
+ }
441
+ }) : null;
442
+ }
443
+ }
444
+ );
445
+ },
446
+ enableSorting: !1
447
+ },
448
+ {
449
+ id: "Delete",
450
+ header: "",
451
+ cell(n) {
452
+ var S, g, x;
453
+ const e = n.row.original, a = (x = (g = (S = m.template) == null ? void 0 : S.purchaseOrder) == null ? void 0 : g.items) == null ? void 0 : x.find(
454
+ (w) => w.sku._id === e.sku._id
455
+ ), k = (a == null ? void 0 : a.subItems) ?? [];
456
+ return q("div", { class: "flex justify-end" }, [
457
+ ...k.length ? [
458
+ q(ue.FmButton, {
459
+ key: e.sku._id,
460
+ type: "button",
461
+ icon: "add_circle",
462
+ variant: "tertiary",
463
+ size: "md",
464
+ disabled: m.disabled,
465
+ onClick: async () => {
466
+ var te;
467
+ const w = ((te = e.subItems) == null ? void 0 : te.map((F) => F.id)) ?? [], $ = k.map(
468
+ (F) => ({
469
+ label: F.name,
470
+ sublabel: F.code,
471
+ value: F.id
472
+ })
473
+ ), M = await p.multiSelect($, w, (F) => {
474
+ var D;
475
+ return ((D = e.subItems) == null ? void 0 : D.find((L) => L.id === F)) ?? k.find((L) => L.id === F);
476
+ }).then((F) => F == null ? void 0 : F.filter((D) => D).map((D) => D));
477
+ M && m.updateItem({
478
+ ...e,
479
+ subItems: M.length ? M : null
480
+ });
481
+ }
482
+ })
483
+ ] : [],
484
+ q(ue.FmButton, {
485
+ key: e.sku._id,
486
+ class: "delete-button",
487
+ type: "button",
488
+ icon: "delete",
489
+ variant: "tertiary",
490
+ size: "md",
491
+ disabled: m.disabled,
492
+ onClick: () => {
493
+ m.deleteItem(e);
494
+ }
495
+ })
496
+ ]);
497
+ },
498
+ enableSorting: !1,
499
+ size: 40,
500
+ meta: {
501
+ cellClass: "",
502
+ headerClass: ""
503
+ }
504
+ }
505
+ ];
506
+ return {
507
+ columnDefs: O(() => h.enableTotalCost && m.transferType === X.PURCHASE ? u : u.filter(
508
+ (n) => n.id !== "Cost"
509
+ /* Cost */
510
+ ))
511
+ };
512
+ }
513
+ const vs = { class: "flex flex-col gap-8 px-16 xs:px-4 sm:px-4 py-4 items-center" }, bs = { class: "fm-typo-en-body-lg-600 xs:fm-typo-en-body-md-600 mr-auto xs:w-full" }, gs = { class: "w-[450px] xs:w-full flex" }, _s = { class: "fm-typo-en-body-md-400 whitespace-nowrap" }, ks = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Pt = /* @__PURE__ */ le({
514
+ __name: "SupplierPriceHistory",
515
+ props: {
516
+ prices: {}
517
+ },
518
+ setup(m) {
519
+ const b = st();
520
+ function l(r) {
521
+ return b.suppliers.find((h) => h._id === r);
522
+ }
523
+ return (r, h) => (C(), V("div", vs, [
524
+ (C(!0), V(be, null, Te(Object.keys(r.prices), (s) => {
525
+ var p;
526
+ return C(), V("div", {
527
+ key: s,
528
+ class: "flex items-center gap-12 xs:gap-4 xs:flex-wrap w-full"
529
+ }, [
530
+ i("div", bs, E((p = l(s)) == null ? void 0 : p.name), 1),
531
+ i("div", gs, [
532
+ (C(!0), V(be, null, Te(r.prices[s].slice(0, 3), (c) => {
533
+ var u;
534
+ return C(), V("div", {
535
+ key: c.date,
536
+ class: "flex flex-col w-[150px] xs:flex-1 text-ellipsis cursor-pointer"
537
+ }, [
538
+ i("div", _s, [
539
+ i("span", null, E(c.totalCost ? t(We)(c.totalCost) : "No data"), 1),
540
+ h[0] || (h[0] = i("span", { class: "text-fm-color-typo-secondary" }, "/", -1)),
541
+ i("span", null, E(t(ae)(c.totalUnit, !1)), 1),
542
+ i("span", null, E(((u = c.measurement) == null ? void 0 : u.abbrev) ?? c.unit.abbrev), 1)
543
+ ]),
544
+ i("div", ks, [
545
+ i("span", null, "(#" + E(c.seqNumber) + ")", 1),
546
+ h[1] || (h[1] = i("span", null, E(" "), -1)),
547
+ i("span", null, E(t(Xe)(new Date(c.date))), 1)
548
+ ])
549
+ ]);
550
+ }), 128))
551
+ ])
552
+ ]);
553
+ }), 128))
554
+ ]));
555
+ }
556
+ }), hs = { class: "flex flex-col gap-8 py-16" }, Ss = { class: "flex items-center" }, Cs = { class: "flex-1 flex gap-1 items-center" }, xs = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, ws = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, Is = { class: "flex gap-8 w-full" }, Fs = { class: "flex-1 flex flex-col gap-4" }, Ds = { class: "flex-1 flex flex-col gap-4" }, $s = { class: "flex gap-8 w-full" }, Ts = { class: "flex-1 flex flex-col gap-4" }, Ps = {
557
+ key: 0,
558
+ class: "flex-1 flex flex-col gap-4"
559
+ }, Vs = /* @__PURE__ */ le({
560
+ __name: "TransferItem",
561
+ props: {
562
+ cellByColId: {},
563
+ comparePriceBySku: {},
564
+ showComparePrice: { type: Boolean },
565
+ row: {}
566
+ },
567
+ setup(m) {
568
+ const { t: b } = ke();
569
+ return (l, r) => {
570
+ var p, c, u, _, n, e, a, k, S, g, x, w, $, M, te, F, D, L, U, A, N, G, J, y, d, R, K;
571
+ const h = P("FmLabel"), s = P("FmSpacer");
572
+ return C(), V("div", hs, [
573
+ i("div", Ss, [
574
+ i("div", Cs, [
575
+ i("span", xs, " (" + E(l.row.original.sku.code) + ") ", 1),
576
+ i("span", ws, E(l.row.original.sku.name), 1)
577
+ ]),
578
+ i("div", null, [
579
+ v(t(de), {
580
+ render: (u = (c = (p = l.cellByColId.Delete) == null ? void 0 : p.column) == null ? void 0 : c.columnDef) == null ? void 0 : u.cell,
581
+ props: (n = (_ = l.cellByColId.Delete) == null ? void 0 : _.getContext) == null ? void 0 : n.call(_)
582
+ }, null, 8, ["render", "props"])
583
+ ])
584
+ ]),
585
+ i("div", Is, [
586
+ i("div", Fs, [
587
+ v(h, {
588
+ label: t(b)(`inventory.transfer.form.items.table.${t(H).Code}`)
589
+ }, null, 8, ["label"]),
590
+ v(t(de), {
591
+ render: (k = (a = (e = l.cellByColId[t(H).Code]) == null ? void 0 : e.column) == null ? void 0 : a.columnDef) == null ? void 0 : k.cell,
592
+ props: (g = (S = l.cellByColId[t(H).Code]) == null ? void 0 : S.getContext) == null ? void 0 : g.call(S)
593
+ }, null, 8, ["render", "props"]),
594
+ r[0] || (r[0] = i("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
595
+ ]),
596
+ i("div", Ds, [
597
+ v(h, {
598
+ label: t(b)(`inventory.transfer.form.items.table.${t(H).Name}`)
599
+ }, null, 8, ["label"]),
600
+ v(t(de), {
601
+ render: ($ = (w = (x = l.cellByColId[t(H).Name]) == null ? void 0 : x.column) == null ? void 0 : w.columnDef) == null ? void 0 : $.cell,
602
+ props: (te = (M = l.cellByColId[t(H).Name]) == null ? void 0 : M.getContext) == null ? void 0 : te.call(M)
603
+ }, null, 8, ["render", "props"]),
604
+ r[1] || (r[1] = i("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
605
+ ])
606
+ ]),
607
+ i("div", $s, [
608
+ i("div", Ts, [
609
+ v(h, {
610
+ label: t(b)(`inventory.transfer.form.items.table.${t(H).Amount}`)
611
+ }, null, 8, ["label"]),
612
+ v(t(de), {
613
+ render: (L = (D = (F = l.cellByColId[t(H).Amount]) == null ? void 0 : F.column) == null ? void 0 : D.columnDef) == null ? void 0 : L.cell,
614
+ props: (A = (U = l.cellByColId[t(H).Amount]) == null ? void 0 : U.getContext) == null ? void 0 : A.call(U)
615
+ }, null, 8, ["render", "props"]),
616
+ r[2] || (r[2] = i("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
617
+ ]),
618
+ l.cellByColId[t(H).Cost] ? (C(), V("div", Ps, [
619
+ v(xt, { "z-index": 50 }, {
620
+ default: T(() => [
621
+ v(h, {
622
+ label: t(b)(`inventory.transfer.form.items.table.${t(H).Cost}2`)
623
+ }, null, 8, ["label"])
624
+ ]),
625
+ _: 1
626
+ }),
627
+ v(t(de), {
628
+ render: (J = (G = (N = l.cellByColId[t(H).Cost]) == null ? void 0 : N.column) == null ? void 0 : G.columnDef) == null ? void 0 : J.cell,
629
+ props: (d = (y = l.cellByColId[t(H).Cost]) == null ? void 0 : y.getContext) == null ? void 0 : d.call(y)
630
+ }, null, 8, ["render", "props"]),
631
+ r[3] || (r[3] = i("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
632
+ ])) : j("", !0)
633
+ ]),
634
+ l.showComparePrice && Object.keys(l.comparePriceBySku[(R = l.row.original.sku) == null ? void 0 : R._id] ?? {}).length > 0 ? (C(), V(be, { key: 0 }, [
635
+ v(s, { class: "h-8" }),
636
+ v(Pt, {
637
+ prices: l.comparePriceBySku[(K = l.row.original.sku) == null ? void 0 : K._id]
638
+ }, null, 8, ["prices"])
639
+ ], 64)) : j("", !0)
640
+ ]);
641
+ };
642
+ }
643
+ });
644
+ function Rs(m) {
645
+ const b = O({
646
+ get() {
647
+ const s = m.getEffectiveAt();
648
+ return s ? new Date(s) : null;
649
+ },
650
+ set(s) {
651
+ m.setEffectiveAt((s == null ? void 0 : s.toISOString()) ?? null);
652
+ }
653
+ }), l = O({
654
+ get() {
655
+ return !!b.value;
656
+ },
657
+ set(s) {
658
+ s ? b.value = /* @__PURE__ */ new Date() : b.value = null;
659
+ }
660
+ }), r = O({
661
+ get() {
662
+ return b.value === null ? "" : Xe(b.value);
663
+ },
664
+ set(s) {
665
+ s ? b.value = /* @__PURE__ */ new Date(`${s} ${h.value}`) : b.value = null;
666
+ }
667
+ }), h = O({
668
+ get() {
669
+ return b.value === null ? "" : Bt(b.value);
670
+ },
671
+ set(s) {
672
+ s ? b.value = /* @__PURE__ */ new Date(`${r.value} ${s}`) : b.value = null;
673
+ }
674
+ });
675
+ return {
676
+ backdatePo: b,
677
+ backdateSwitch: l,
678
+ backdateModel: r,
679
+ backdateTimeModel: h
680
+ };
681
+ }
682
+ const qs = {
683
+ width: "24",
684
+ height: "24",
685
+ viewBox: "0 0 24 24",
686
+ fill: "none",
687
+ xmlns: "http://www.w3.org/2000/svg"
688
+ }, As = ["fill"], Es = ["fill"], Os = ["stroke"], Ms = ["stroke"], Us = /* @__PURE__ */ le({
689
+ __name: "SparkIcon",
690
+ props: {
691
+ size: {
692
+ type: Number,
693
+ default: 24
694
+ },
695
+ color: {
696
+ type: String,
697
+ default: "#c7c7cc"
698
+ }
699
+ },
700
+ setup(m) {
701
+ return (b, l) => (C(), V("svg", qs, [
702
+ i("path", {
703
+ 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",
704
+ fill: m.color
705
+ }, null, 8, As),
706
+ i("path", {
707
+ 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",
708
+ fill: m.color
709
+ }, null, 8, Es),
710
+ i("path", {
711
+ 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",
712
+ stroke: m.color,
713
+ "stroke-width": "1.5",
714
+ "stroke-linecap": "round",
715
+ "stroke-linejoin": "round"
716
+ }, null, 8, Os),
717
+ i("path", {
718
+ 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",
719
+ stroke: m.color,
720
+ "stroke-width": "1.5",
721
+ "stroke-linecap": "round",
722
+ "stroke-linejoin": "round"
723
+ }, null, 8, Ms)
724
+ ]));
725
+ }
726
+ }), Bs = { class: "flex gap-8 items-center" }, Ns = { 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]" }, Ls = { class: "flex items-center w-full" }, Hs = { class: "flex-1" }, js = { class: "fm-typo-en-title-sm-800" }, Qs = { class: "flex items-start gap-8" }, Ys = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Ks = { class: "flex gap-1" }, ft = /* @__PURE__ */ le({
727
+ __name: "ForecastStock",
728
+ props: {
729
+ disabled: { type: Boolean }
730
+ },
731
+ emits: ["update:poItems"],
732
+ setup(m, { emit: b }) {
733
+ const l = b, r = Q(!1), h = Q(7), s = ts(), p = Le(), c = kt(), { t: u } = ke();
734
+ async function _() {
735
+ if (h.value < 1)
736
+ return;
737
+ r.value = !1, await s.readPurchaseOrder(h.value);
738
+ const n = [];
739
+ if (s.purchaseOrderForecast.skus.length <= 0) {
740
+ p.open({
741
+ message: u("inventory.transfer.form.items.forecastStock.notAvailable"),
742
+ type: "info"
743
+ });
744
+ return;
745
+ }
746
+ const e = s.purchaseOrderForecast.skus.reduce((a, k) => {
747
+ const S = c.skus.find((w) => w._id === k.id);
748
+ if (a.find((w) => w.sku._id === k.id) || !S)
749
+ return a;
750
+ const x = {
751
+ sku: S,
752
+ code: S.code,
753
+ name: S.name,
754
+ quantity: {
755
+ amount: k.amount,
756
+ precision: 0
757
+ }
758
+ };
759
+ return a.push(x), a;
760
+ }, n);
761
+ l("update:poItems", e);
762
+ }
763
+ return (n, e) => {
764
+ const a = P("FmButton"), k = P("FmIcon"), S = P("FmStepperField"), g = P("FmPopover");
765
+ return C(), Y(g, {
766
+ disabled: n.disabled,
767
+ class: "flex",
768
+ "show-popover": r.value,
769
+ onPopoverChanged: e[3] || (e[3] = (x) => r.value = x)
770
+ }, {
771
+ "popover-button": T(() => [
772
+ v(a, {
773
+ label: "unused",
774
+ variant: "secondary",
775
+ "text-color": n.disabled ? "disabled" : "primary",
776
+ "bg-color": "transparent",
777
+ "border-color": n.disabled ? "disabled" : "primary",
778
+ disabled: n.disabled
779
+ }, {
780
+ default: T(() => [
781
+ i("div", Bs, [
782
+ v(Us, {
783
+ size: 24,
784
+ color: n.disabled ? "#c7c7cc" : "#ff7823"
785
+ }, null, 8, ["color"]),
786
+ i("div", Ns, E(t(u)("inventory.transfer.form.items.forecastStock.title")), 1)
787
+ ])
788
+ ]),
789
+ _: 1
790
+ }, 8, ["text-color", "border-color", "disabled"])
791
+ ]),
792
+ default: T(() => [
793
+ i("div", zs, [
794
+ i("div", Ls, [
795
+ i("div", Hs, [
796
+ v(ms, { "z-index": 99 }, {
797
+ default: T(() => [
798
+ i("p", js, E(t(u)("inventory.transfer.form.items.forecastStock.title")), 1)
799
+ ]),
800
+ _: 1
801
+ })
802
+ ]),
803
+ v(a, {
804
+ icon: "close",
805
+ size: "md",
806
+ variant: "tertiary",
807
+ onClick: e[0] || (e[0] = (x) => r.value = !1)
808
+ })
809
+ ]),
810
+ v(S, {
811
+ modelValue: h.value,
812
+ "onUpdate:modelValue": e[1] || (e[1] = (x) => h.value = x),
813
+ label: t(u)("inventory.transfer.form.items.forecastStock.days"),
814
+ rules: [t(Ue)(1)]
815
+ }, {
816
+ "helper-text": T(() => [
817
+ i("div", Qs, [
818
+ v(k, {
819
+ name: "warning",
820
+ size: "sm",
821
+ class: "text-fm-color-system-warning-300"
822
+ }),
823
+ i("div", Ys, E(t(u)("inventory.transfer.form.items.forecastStock.replace")), 1)
824
+ ])
825
+ ]),
826
+ _: 1
827
+ }, 8, ["modelValue", "label", "rules"]),
828
+ i("div", Ks, [
829
+ e[4] || (e[4] = i("div", { class: "grow" }, null, -1)),
830
+ v(a, {
831
+ label: t(u)("common.cancel"),
832
+ variant: "tertiary",
833
+ onClick: e[2] || (e[2] = (x) => r.value = !1)
834
+ }, null, 8, ["label"]),
835
+ v(a, {
836
+ label: t(u)("inventory.transfer.form.items.forecastStock.generate"),
837
+ onClick: _
838
+ }, null, 8, ["label"])
839
+ ])
840
+ ])
841
+ ]),
842
+ _: 1
843
+ }, 8, ["disabled", "show-popover"]);
844
+ };
845
+ }
846
+ });
847
+ function Zs() {
848
+ const m = Le(), b = Ct(), l = Q(!1);
849
+ _e(l, (p) => {
850
+ p && (h.value = !0, r().finally(() => {
851
+ h.value = !1;
852
+ }));
853
+ });
854
+ async function r() {
855
+ try {
856
+ const { startDate: p, endDate: c } = Nt(6), n = (await b.getPurchaseOrders({ start: p, end: c })).filter(
857
+ (e) => {
858
+ var a, k;
859
+ return e.status === zt.enum.COMPLETE && ((a = e.supplier) == null ? void 0 : a.internal) !== "warehouse" && ((k = e.supplier) == null ? void 0 : k.internal) !== "restaurant";
860
+ }
861
+ ).reduce((e, a) => {
862
+ const k = new Date(Lt(a._id)), S = a.supplier._id;
863
+ for (const g of a.items) {
864
+ if (!g.totalCost) continue;
865
+ const x = e[g.sku._id] ?? {}, w = x[S] ?? [];
866
+ w.push({
867
+ date: k.toISOString(),
868
+ totalUnit: g.quantity,
869
+ totalCost: g.totalCost,
870
+ unit: g.sku.unit,
871
+ measurement: g.measurement,
872
+ seqNumber: a.seqNumber
873
+ }), x[S] = w, e[g.sku._id] = x;
874
+ }
875
+ return e;
876
+ }, {});
877
+ s.value = n;
878
+ } catch {
879
+ m.open({
880
+ title: "Something went wrong",
881
+ message: "Cannot retrieve supplier purchase history. Please try again."
882
+ }), l.value = !1;
883
+ }
884
+ }
885
+ const h = Q(!1), s = Q({});
886
+ return {
887
+ comparePricesToggle: l,
888
+ comparePriceFetching: h,
889
+ comparePriceBySku: s
890
+ };
891
+ }
892
+ const Gs = { class: "hover:bg-fm-color-opacity-sm" }, Js = { class: "flex items-center" }, Ws = {
893
+ key: 0,
894
+ class: "flex h-full w-24"
895
+ }, Xs = { class: "flex flex-col flex-1 line-clamp-1" }, eo = { class: "text-fm-color-typo-primary fm-typo-en-body-md-400" }, to = { class: "text-fm-color-typo-secondary fm-typo-en-body-sm-400" }, so = {
896
+ key: 2,
897
+ class: "flex-1"
898
+ }, oo = {
899
+ key: 3,
900
+ class: "flex w-full justify-end"
901
+ }, no = /* @__PURE__ */ le({
902
+ __name: "TransferSubItemTable",
903
+ props: {
904
+ templateSubItem: {},
905
+ row: {},
906
+ modelValue: {},
907
+ disabled: { type: Boolean },
908
+ subItemIndex: {}
909
+ },
910
+ emits: ["delete:model-value"],
911
+ setup(m, { emit: b }) {
912
+ const l = ht(), r = b, h = Q(ae(l.quantity));
913
+ return _e(h, (s) => {
914
+ if (!`${s}`) return;
915
+ const p = +s;
916
+ Number.isNaN(p) || (l.quantity = gt(p));
917
+ }), (s, p) => {
918
+ const c = P("FmIcon"), u = P("FmTooltip"), _ = P("FmButton");
919
+ return C(), V("tr", Gs, [
920
+ (C(!0), V(be, null, Te(s.row.getVisibleCells(), (n, e) => (C(), V("td", {
921
+ key: n.id,
922
+ class: ee([e === 0 ? "px-16" : n.column.id === t(H).Delete ? "" : "px-16"])
923
+ }, [
924
+ i("div", Js, [
925
+ e === 0 ? (C(), V("div", Ws, [
926
+ s.subItemIndex === 0 ? (C(), Y(c, {
927
+ key: 0,
928
+ name: "subdirectory_arrow_right",
929
+ size: "sm"
930
+ })) : j("", !0)
931
+ ])) : j("", !0),
932
+ n.column.id === t(H).TemplateName ? (C(), Y(u, {
933
+ key: 1,
934
+ "z-index": 50
935
+ }, {
936
+ content: T(() => [
937
+ Me(E(t(l).name), 1)
938
+ ]),
939
+ default: T(() => [
940
+ i("div", Xs, [
941
+ i("div", eo, E(t(l).name), 1),
942
+ i("div", to, E(t(l).code), 1)
943
+ ])
944
+ ]),
945
+ _: 1
946
+ })) : n.column.id === t(H).Amount ? (C(), V("div", so, [
947
+ v(Ft, {
948
+ "model-value": {
949
+ amount: t(l).quantity,
950
+ measurement: t(l).measurement
951
+ },
952
+ "onUpdate:modelValue": p[0] || (p[0] = (a) => t(l).quantity = a.amount),
953
+ unit: s.row.original.sku.unit,
954
+ rules: [
955
+ t(Dt)(
956
+ +t(ae)(
957
+ s.templateSubItem.minimumQuantity ?? {
958
+ amount: 1,
959
+ precision: t(Ne)(s.row.original.sku.unit, t(l).measurement)
960
+ }
961
+ )
962
+ ),
963
+ t(Ze)(
964
+ s.templateSubItem.maximumQuantity ? +t(ae)(s.templateSubItem.maximumQuantity) : 1 / 0
965
+ ),
966
+ t($t)(s.templateSubItem.quantityStep)
967
+ ],
968
+ stepper: s.templateSubItem.quantityStep,
969
+ disabled: s.disabled,
970
+ "disable-unit": ""
971
+ }, null, 8, ["model-value", "unit", "rules", "stepper", "disabled"])
972
+ ])) : n.column.id === t(H).Delete ? (C(), V("div", oo, [
973
+ v(_, {
974
+ key: "row.sku._id",
975
+ type: "button",
976
+ icon: "delete",
977
+ variant: "tertiary",
978
+ size: "md",
979
+ onClick: p[1] || (p[1] = (a) => r("delete:model-value", s.modelValue)),
980
+ disabled: s.disabled
981
+ }, null, 8, ["disabled"])
982
+ ])) : j("", !0)
983
+ ])
984
+ ], 2))), 128))
985
+ ]);
986
+ };
987
+ }
988
+ }), ao = { class: "fm-typo-body-md-400 line-clamp-2 w-full" }, lo = { key: 1 }, ro = ["colspan"], io = /* @__PURE__ */ le({
989
+ __name: "TransferItemTable",
990
+ props: {
991
+ templateItem: {},
992
+ row: {},
993
+ comparePriceBySku: {},
994
+ showComparePrice: { type: Boolean },
995
+ disabled: { type: Boolean }
996
+ },
997
+ emits: ["update:item"],
998
+ setup(m, { emit: b }) {
999
+ const l = m, r = b;
1000
+ function h(u) {
1001
+ return u.column.columnDef.meta;
1002
+ }
1003
+ function s(u) {
1004
+ var _, n;
1005
+ return ((n = (_ = l.templateItem) == null ? void 0 : _.subItems) == null ? void 0 : n.find((e) => e.id === u.id)) ?? {
1006
+ id: u.id,
1007
+ code: u.code,
1008
+ name: u.name,
1009
+ quantity: u.quantity,
1010
+ quantityStep: {
1011
+ amount: 1,
1012
+ precision: Ne(l.row.original.sku.unit, u.measurement)
1013
+ }
1014
+ };
1015
+ }
1016
+ function p(u) {
1017
+ const n = (l.row.original.subItems ?? []).map((e) => e.id !== u.id ? e : u);
1018
+ r("update:item", {
1019
+ ...l.row.original,
1020
+ subItems: n
1021
+ });
1022
+ }
1023
+ function c(u) {
1024
+ const n = (l.row.original.subItems ?? []).filter((e) => e.id !== u.id);
1025
+ r("update:item", {
1026
+ ...l.row.original,
1027
+ subItems: n.length ? n : null
1028
+ });
1029
+ }
1030
+ return (u, _) => {
1031
+ var n, e, a, k, S;
1032
+ return C(), V(be, null, [
1033
+ i("tr", {
1034
+ class: ee(["border-b border-fm-color-neutral-gray-100 hover:bg-fm-color-opacity-sm", {
1035
+ "bg-fm-color-neutral-gray-100": u.row.getIsSelected()
1036
+ }])
1037
+ }, [
1038
+ (C(!0), V(be, null, Te(u.row.getVisibleCells(), (g) => {
1039
+ var x, w, $, M;
1040
+ return C(), V("td", {
1041
+ key: g.id,
1042
+ class: ee(["h-[56px] text-fm-color-typo-primary", ((x = h(g)) == null ? void 0 : x.cellClass) ?? "px-16"]),
1043
+ style: bt({
1044
+ width: (w = h(g)) == null ? void 0 : w.width,
1045
+ maxWidth: ($ = h(g)) == null ? void 0 : $.maxWidth,
1046
+ textAlign: ((M = h(g)) == null ? void 0 : M.textAlign) ?? "left"
1047
+ })
1048
+ }, [
1049
+ i("span", ao, [
1050
+ v(t(de), {
1051
+ render: g.column.columnDef.cell,
1052
+ props: g.getContext()
1053
+ }, null, 8, ["render", "props"])
1054
+ ])
1055
+ ], 6);
1056
+ }), 128))
1057
+ ], 2),
1058
+ (e = (n = u.row.original) == null ? void 0 : n.subItems) != null && e.length ? (C(!0), V(be, { key: 0 }, Te((a = u.row.original) == null ? void 0 : a.subItems, (g, x) => (C(), Y(no, {
1059
+ key: g.id,
1060
+ row: u.row,
1061
+ "model-value": g,
1062
+ "onUpdate:modelValue": p,
1063
+ "onDelete:modelValue": c,
1064
+ "template-sub-item": s(g),
1065
+ "sub-item-index": x,
1066
+ disabled: u.disabled
1067
+ }, null, 8, ["row", "model-value", "template-sub-item", "sub-item-index", "disabled"]))), 128)) : j("", !0),
1068
+ u.showComparePrice && Object.keys(u.comparePriceBySku[(k = u.row.original.sku) == null ? void 0 : k._id] ?? {}).length > 0 ? (C(), V("tr", lo, [
1069
+ i("td", {
1070
+ colspan: u.row.getVisibleCells().length
1071
+ }, [
1072
+ v(Pt, {
1073
+ prices: u.comparePriceBySku[(S = u.row.original.sku) == null ? void 0 : S._id]
1074
+ }, null, 8, ["prices"])
1075
+ ], 8, ro)
1076
+ ])) : j("", !0)
1077
+ ], 64);
1078
+ };
1079
+ }
1080
+ }), uo = {
1081
+ key: 0,
1082
+ class: "flex flex-col gap-8"
1083
+ }, mo = { class: "flex flex-col gap-4" }, co = { class: "flex items-center gap-4" }, po = {
1084
+ key: 0,
1085
+ class: "fm-typo-en-body-sm-400 text-fm-color-typo-error"
1086
+ }, fo = /* @__PURE__ */ le({
1087
+ __name: "NetSuiteField",
1088
+ props: {
1089
+ required: { type: Boolean },
1090
+ disabled: { type: Boolean },
1091
+ supplier: {},
1092
+ setting: {},
1093
+ items: {},
1094
+ onChange: { type: Function }
1095
+ },
1096
+ emits: ["netsuite:ready"],
1097
+ setup(m, { emit: b }) {
1098
+ const l = Je(), r = m, h = b, { t: s } = cs(), p = Q(!1), c = Q();
1099
+ Be(() => {
1100
+ var e, a, k, S;
1101
+ let n = {
1102
+ id: "",
1103
+ subsidiary: { id: "", name: "" },
1104
+ errors: []
1105
+ };
1106
+ if (!l.isEnabled || !r.required) {
1107
+ h("netsuite:ready", n);
1108
+ return;
1109
+ }
1110
+ try {
1111
+ const g = l.currentLocationSubsidiary();
1112
+ r.setting ? n = {
1113
+ ...r.setting,
1114
+ subsidiary: {
1115
+ id: g.id || "",
1116
+ name: g.name
1117
+ }
1118
+ } : n = {
1119
+ ...n,
1120
+ subsidiary: {
1121
+ id: g.id || "",
1122
+ name: g.name
1123
+ }
1124
+ };
1125
+ const x = l.getAvailableItems(g.id), w = r.items.filter(($) => {
1126
+ if ($.measurement != null) {
1127
+ const M = l.getAvailableMeasurements(
1128
+ $.sku._id,
1129
+ g.id
1130
+ );
1131
+ return x.includes($.sku._id) && M.includes($.measurement.id);
1132
+ }
1133
+ return x.includes($.sku._id);
1134
+ }).map(($) => $.sku._id);
1135
+ r.onChange(
1136
+ r.items.filter(($) => w.includes($.sku._id)),
1137
+ n
1138
+ );
1139
+ } finally {
1140
+ r.supplier.internal ? c.value = l.getNetSuiteLocation(
1141
+ `${r.supplier.internal}_${r.supplier._id}`
1142
+ ) : c.value = l.getNetSuiteVendor(r.supplier._id);
1143
+ const g = r.supplier.internal ? l.getLocationSubsidiary((e = c.value) == null ? void 0 : e.netSuiteId).id : (a = c.value) == null ? void 0 : a.subsidiaryId, x = r.supplier.internal ? (k = l.currentLocationSubsidiary()) == null ? void 0 : k.id : (S = l.currentVendorSubsidiary(r.supplier._id)) == null ? void 0 : S.id;
1144
+ !l.isEnabled || g && l.isEnabled && g == x ? h("netsuite:ready", n) : p.value = !0;
1145
+ }
1146
+ });
1147
+ const u = O(
1148
+ () => r.supplier.internal ? l.currentLocationSubsidiary() : l.currentVendorSubsidiary(r.supplier._id)
1149
+ ), _ = O(() => {
1150
+ var n, e;
1151
+ return c.value == null ? `Cannot find the NetSuite location for "${r.supplier.name}"` : `The subsidiary of the request
1152
+ location is ${(e = l.getLocationSubsidiary((n = c.value) == null ? void 0 : n.netSuiteId)) == null ? void 0 : e.fullName}`;
1153
+ });
1154
+ return (n, e) => {
1155
+ const a = P("FmLabel"), k = P("FmIcon"), S = P("FmField"), g = P("FmTooltip");
1156
+ return t(l).isEnabled && r.required ? (C(), V("div", uo, [
1157
+ v(a, {
1158
+ label: `NetSuite ${t(s)("inventory.transfer.form.netsuite.subsidiary")}`
1159
+ }, null, 8, ["label"]),
1160
+ i("div", mo, [
1161
+ v(g, {
1162
+ "z-index": 51,
1163
+ placement: "left",
1164
+ disabled: n.disabled
1165
+ }, {
1166
+ content: T(() => e[0] || (e[0] = [
1167
+ Me("This field is locked and based on the location of the request.")
1168
+ ])),
1169
+ default: T(() => [
1170
+ v(S, null, {
1171
+ default: T(() => {
1172
+ var x;
1173
+ return [
1174
+ i("div", co, [
1175
+ v(k, {
1176
+ name: "lock_outline",
1177
+ size: "sm",
1178
+ color: n.disabled ? "neutral-gray-200" : "neutral-gray-400"
1179
+ }, null, 8, ["color"]),
1180
+ i("div", {
1181
+ class: ee([n.disabled ? "text-fm-color-typo-disabled" : ""])
1182
+ }, E((x = u.value) == null ? void 0 : x.fullName), 3)
1183
+ ])
1184
+ ];
1185
+ }),
1186
+ _: 1
1187
+ })
1188
+ ]),
1189
+ _: 1
1190
+ }, 8, ["disabled"]),
1191
+ p.value ? (C(), V("div", po, E(_.value), 1)) : j("", !0)
1192
+ ])
1193
+ ])) : j("", !0);
1194
+ };
1195
+ }
1196
+ }), yo = { class: "flex flex-col gap-4" }, vo = { class: "flex items-center gap-8 overflow-x-auto pb-12" }, bo = { class: "flex flex-col gap-16" }, go = { class: "flex flex-col gap-24" }, _o = { class: "flex flex-col gap-8" }, ko = { class: "flex flex-col gap-4" }, ho = { class: "flex items-center gap-4" }, So = { class: "flex flex-col gap-8" }, Co = { class: "flex flex-col gap-4" }, xo = { class: "flex items-center gap-4" }, wo = {
1197
+ key: 3,
1198
+ class: "p-16 border border-fm-color-neutral-gray-300 fm-corner-radius-md flex flex-col"
1199
+ }, Io = {
1200
+ key: 0,
1201
+ class: "flex-1 flex gap-8 h-48 xs:flex-col xs:pt-16 sm:flex-col sm:pt-16"
1202
+ }, Fo = { class: "flex-1" }, Do = { class: "flex-1" }, $o = {
1203
+ key: 1,
1204
+ class: "flex items-center gap-4"
1205
+ }, To = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary translate-y-[1px]" }, Po = { class: "flex flex-col gap-16" }, Vo = { class: "flex-1 gap-8 fm-typo-en-title-sm-600" }, Ro = { class: "flex gap-8" }, qo = { key: 0 }, Ao = /* @__PURE__ */ le({
1206
+ __name: "TransferForm2",
1207
+ props: {
1208
+ modelValue: {},
1209
+ request: {},
1210
+ disabled: { type: Boolean },
1211
+ returnFrom: {},
1212
+ lastClosingDate: {}
1213
+ },
1214
+ emits: ["validation-success", "form:ready"],
1215
+ setup(m, { expose: b, emit: l }) {
1216
+ const r = m, h = l, s = ht(), { t: p } = ke(), c = ze(), u = kt(), _ = Je(), n = st(), e = tt(), a = It(), { breakpoints: k } = et(), S = O(() => k.value.xs || k.value.sm), g = vt({
1217
+ value: !1
1218
+ }), x = Q(!1), w = O(
1219
+ () => {
1220
+ var o;
1221
+ return ((o = r.modelValue) == null ? void 0 : o.templateDoc) ?? a.templates.find((f) => f._id === s.template);
1222
+ }
1223
+ ), $ = O(() => s.status === "DRAFT" || !s._rev);
1224
+ _e(w, (o) => {
1225
+ o && $.value && (s.supplier = (o == null ? void 0 : o.purchaseOrder.supplier) ?? s.supplier);
1226
+ }), Be(() => {
1227
+ var o;
1228
+ try {
1229
+ if (!s.templateDoc) return;
1230
+ if (!s.items.length) {
1231
+ let f = [];
1232
+ (o = w.value) != null && o.purchaseOrder.items && (f = w.value.purchaseOrder.items.filter((z) => {
1233
+ var W;
1234
+ return ((W = z.quantity) == null ? void 0 : W.amount) != 0;
1235
+ })), s.items = f;
1236
+ }
1237
+ } finally {
1238
+ x.value = !0;
1239
+ }
1240
+ }), _e([x, g], ([o, f], [z, W]) => {
1241
+ f.value && W.value && h("form:ready");
1242
+ });
1243
+ const M = O(
1244
+ () => c.currentLocation.type === Ht.enum.restaurant
1245
+ );
1246
+ c.watchLocation(async () => {
1247
+ location && (s.supplier || (s.supplier = n.suppliers.find((o) => o) ?? s.supplier));
1248
+ });
1249
+ const te = wt(), F = rs(
1250
+ () => s,
1251
+ (o) => {
1252
+ Object.assign(s, o);
1253
+ },
1254
+ !0,
1255
+ !0
1256
+ ), D = O({
1257
+ get() {
1258
+ var o;
1259
+ return typeof ((o = s == null ? void 0 : s.supplier) == null ? void 0 : o.internal) == "string" ? X.TRANSFER : X.PURCHASE;
1260
+ },
1261
+ set(o) {
1262
+ var z;
1263
+ const f = typeof ((z = s == null ? void 0 : s.supplier) == null ? void 0 : z.internal) == "string" ? X.TRANSFER : X.PURCHASE;
1264
+ o !== f && (s.supplier = o === X.PURCHASE ? F.locationOptionsTypePurchase.value[0] : F.locationOptionsTypeTransfer.value[0]);
1265
+ }
1266
+ });
1267
+ _e(
1268
+ () => {
1269
+ var o;
1270
+ return (o = r.modelValue) == null ? void 0 : o.template;
1271
+ },
1272
+ (o) => {
1273
+ e.mustUsePoTemplate && !o && qt(() => {
1274
+ var f, z;
1275
+ s.supplier = ((z = (f = F.locationOptionsTypeTransfer.value) == null ? void 0 : f.filter(
1276
+ (W) => W.internal === "restaurant"
1277
+ )) == null ? void 0 : z[0]) ?? s.supplier;
1278
+ });
1279
+ },
1280
+ { immediate: !0 }
1281
+ );
1282
+ const L = O(() => {
1283
+ let o = F.transferLocationOptions.value;
1284
+ return e.mustUsePoTemplate && !s.templateDoc && (o = o.filter((f) => {
1285
+ var z;
1286
+ return (z = f.sublabel) == null ? void 0 : z.startsWith("restaurant");
1287
+ })), o;
1288
+ }), U = O({
1289
+ get() {
1290
+ return s.supplier._id;
1291
+ },
1292
+ set(o) {
1293
+ F.transferLocationModel.value = o;
1294
+ }
1295
+ }), A = O({
1296
+ get() {
1297
+ return s.remark ?? void 0;
1298
+ },
1299
+ set(o) {
1300
+ s.remark = o;
1301
+ }
1302
+ }), { backdatePo: N, backdateSwitch: G, backdateModel: J, backdateTimeModel: y } = Rs({
1303
+ getEffectiveAt() {
1304
+ return s.effectiveAt;
1305
+ },
1306
+ setEffectiveAt(o) {
1307
+ s.effectiveAt = o;
1308
+ }
1309
+ }), { comparePricesToggle: d, comparePriceFetching: R, comparePriceBySku: K } = Zs(), se = Q();
1310
+ b({
1311
+ validateInputs: () => {
1312
+ var o, f;
1313
+ (f = (o = se.value) == null ? void 0 : o.validateInputs) == null || f.call(o);
1314
+ },
1315
+ resetInputsValidation: () => {
1316
+ var o, f;
1317
+ (f = (o = se.value) == null ? void 0 : o.resetInputsValidation) == null || f.call(o);
1318
+ },
1319
+ resetInputs: () => {
1320
+ var o, f;
1321
+ (f = (o = se.value) == null ? void 0 : o.resetInputs) == null || f.call(o);
1322
+ }
1323
+ });
1324
+ const Ce = O(() => ({
1325
+ updateItem: (o) => {
1326
+ s.items = s.items.map((f) => f.sku._id !== o.sku._id ? f : o);
1327
+ },
1328
+ deleteItem: (o) => {
1329
+ s.items = s.items.filter((f) => f.sku._id !== o.sku._id);
1330
+ }
1331
+ })), xe = ys({
1332
+ updateItem: (o) => Ce.value.updateItem(o),
1333
+ deleteItem: (o) => Ce.value.deleteItem(o),
1334
+ get supplier() {
1335
+ return s.supplier;
1336
+ },
1337
+ get items() {
1338
+ return s.items;
1339
+ },
1340
+ get transferType() {
1341
+ return D.value;
1342
+ },
1343
+ get template() {
1344
+ return w.value;
1345
+ },
1346
+ get disabled() {
1347
+ return r.disabled;
1348
+ }
1349
+ }), Pe = O(() => xe.columnDefs.value);
1350
+ function Ve() {
1351
+ var pe, he, qe, Ae, Ie;
1352
+ const o = new Set((qe = (he = (pe = w.value) == null ? void 0 : pe.purchaseOrder) == null ? void 0 : he.items) == null ? void 0 : qe.map((B) => B.sku._id)), f = _.isEnabled ? _.getAvailableItems((Ie = (Ae = s.netSuite) == null ? void 0 : Ae.subsidiary) == null ? void 0 : Ie.id) : [], z = o.size ? u.skus.filter((B) => o.has(B._id)) : u.skus, W = _.isEnabled ? z.filter((B) => {
1353
+ var re, ne, fe, ie;
1354
+ const oe = (ne = (re = w.value) == null ? void 0 : re.purchaseOrder) == null ? void 0 : ne.items.find(
1355
+ (ye) => ye.sku._id === B._id
1356
+ );
1357
+ if (oe != null && oe.measurement != null) {
1358
+ const ye = _.getAvailableMeasurements(
1359
+ oe.sku._id,
1360
+ (ie = (fe = s.netSuite) == null ? void 0 : fe.subsidiary) == null ? void 0 : ie.id
1361
+ );
1362
+ return f.includes(oe.sku._id) && ye.includes(oe.measurement.id);
1363
+ }
1364
+ return f.includes(B._id);
1365
+ }).map((B) => B._id) : z.map((B) => B._id), me = z.map(
1366
+ (B) => ({
1367
+ label: B.name,
1368
+ sublabel: B.code,
1369
+ value: B,
1370
+ disabled: !W.includes(B._id)
1371
+ })
1372
+ ), ce = me.filter((B) => {
1373
+ var oe;
1374
+ return (oe = s.items) == null ? void 0 : oe.find((re) => re.sku._id === B.value._id);
1375
+ }).map((B) => B.value);
1376
+ te.open({
1377
+ title: p("inventory.transfer.form.items.selectItem"),
1378
+ closeButton: !0,
1379
+ contentComponent: Ke,
1380
+ contentComponentProps: {
1381
+ modelValue: ce,
1382
+ items: me,
1383
+ virtualScroll: !0
1384
+ },
1385
+ primaryActions: {
1386
+ text: p("common.confirm"),
1387
+ close: !0
1388
+ },
1389
+ secondaryActions: {
1390
+ text: p("common.close"),
1391
+ close: !0,
1392
+ variant: "tertiary"
1393
+ }
1394
+ }).onPrimary((B) => {
1395
+ const oe = s.items ?? [], re = B.map((ne) => {
1396
+ var ye, Fe;
1397
+ const fe = oe.find((Se) => Se.sku._id === ne._id);
1398
+ if (fe)
1399
+ return fe;
1400
+ const ie = ((Fe = (ye = w.value) == null ? void 0 : ye.purchaseOrder.items) == null ? void 0 : Fe.find(
1401
+ (Se) => Se.sku._id === ne._id
1402
+ )) ?? {
1403
+ sku: ne,
1404
+ code: ne.code,
1405
+ name: ne.name,
1406
+ quantity: {
1407
+ amount: 1,
1408
+ precision: 0
1409
+ }
1410
+ };
1411
+ return D.value == X.PURCHASE && (ie.totalCost = ve(
1412
+ ie.sku,
1413
+ ie.quantity,
1414
+ ie.measurement,
1415
+ {
1416
+ supplier: s.supplier
1417
+ }
1418
+ )), ie;
1419
+ });
1420
+ re.sort((ne, fe) => ne.sku.code.localeCompare(fe.sku.code)), s.items = re;
1421
+ });
1422
+ }
1423
+ function He(o) {
1424
+ return o;
1425
+ }
1426
+ const Re = O(() => {
1427
+ const o = [];
1428
+ return (!e.mustUsePoTemplate || e.mustUsePoTemplate && s.templateDoc) && o.push({
1429
+ label: p("inventory.transfer.form.type.purchase"),
1430
+ value: X.PURCHASE
1431
+ }), o.push({
1432
+ label: p("inventory.transfer.form.type.transfer"),
1433
+ value: X.TRANSFER
1434
+ }), o;
1435
+ });
1436
+ return (o, f) => {
1437
+ var ye, Fe;
1438
+ const z = P("FmChip"), W = P("FmLabel"), me = P("FmIcon"), ce = P("FmField"), pe = P("FmTooltip"), he = P("FmSelect"), qe = P("FmTextField"), Ae = P("FmTextarea"), Ie = P("FmSwitch"), B = P("FmDatePicker"), oe = P("FmTimePicker"), re = P("FmFormGroup"), ne = P("FmButton"), fe = P("FmTable"), ie = P("FmForm");
1439
+ return C(), V("div", yo, [
1440
+ i("div", vo, [
1441
+ (ye = r.modelValue) != null && ye.template ? (C(), Y(z, {
1442
+ key: 0,
1443
+ variant: o.disabled ? "warning" : void 0,
1444
+ label: `${t(p)("inventory.transfer.template.title")}: ${((Fe = w.value) == null ? void 0 : Fe.name) ?? t(p)("inventory.transfer.form.loading")}`,
1445
+ icon: "summarize",
1446
+ compact: ""
1447
+ }, null, 8, ["variant", "label"])) : j("", !0),
1448
+ o.returnFrom ? j("", !0) : (C(), Y(z, {
1449
+ key: 1,
1450
+ label: t(c).currentLocation.name,
1451
+ icon: "storefront",
1452
+ compact: ""
1453
+ }, null, 8, ["label"])),
1454
+ o.lastClosingDate ? (C(), Y(z, {
1455
+ key: 2,
1456
+ label: `${t(p)("inventory.transfer.form.lastClosing")}: ${t(Xe)(o.lastClosingDate)} ${t(jt)(o.lastClosingDate)}`,
1457
+ icon: "calendar_month",
1458
+ compact: ""
1459
+ }, null, 8, ["label"])) : j("", !0)
1460
+ ]),
1461
+ v(ie, {
1462
+ ref_key: "formRef",
1463
+ ref: se,
1464
+ class: "flex flex-col gap-32",
1465
+ disabled: o.disabled,
1466
+ onValidationFailed: console.log,
1467
+ onValidationSuccess: f[14] || (f[14] = (Se) => h("validation-success"))
1468
+ }, {
1469
+ default: T(() => {
1470
+ var Se, ot, nt, at, lt, rt, it, ut;
1471
+ return [
1472
+ i("div", bo, [
1473
+ i("div", go, [
1474
+ (Se = r.modelValue) != null && Se.template ? (C(), V(be, { key: 0 }, [
1475
+ i("div", _o, [
1476
+ v(W, {
1477
+ label: t(p)("inventory.transfer.form.type.title")
1478
+ }, null, 8, ["label"]),
1479
+ i("div", ko, [
1480
+ v(pe, {
1481
+ "z-index": 51,
1482
+ placement: "left",
1483
+ disabled: o.disabled
1484
+ }, {
1485
+ content: T(() => f[15] || (f[15] = [
1486
+ Me("This field is locked from template.")
1487
+ ])),
1488
+ default: T(() => [
1489
+ v(ce, null, {
1490
+ default: T(() => [
1491
+ i("div", ho, [
1492
+ v(me, {
1493
+ name: "lock_outline",
1494
+ size: "sm",
1495
+ color: o.disabled ? "neutral-gray-200" : "neutral-gray-400"
1496
+ }, null, 8, ["color"]),
1497
+ i("div", {
1498
+ class: ee({ "text-fm-color-typo-disabled": o.disabled })
1499
+ }, E(t(p)(`inventory.transfer.form.type.${D.value.toLocaleLowerCase("en-us")}`)), 3)
1500
+ ])
1501
+ ]),
1502
+ _: 1
1503
+ })
1504
+ ]),
1505
+ _: 1
1506
+ }, 8, ["disabled"]),
1507
+ i("div", {
1508
+ class: ee([
1509
+ "fm-typo-en-body-sm-400",
1510
+ o.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-typo-secondary"
1511
+ ])
1512
+ }, null, 2)
1513
+ ])
1514
+ ]),
1515
+ i("div", So, [
1516
+ v(W, {
1517
+ label: o.returnFrom ? "Return to" : D.value === t(X).PURCHASE ? t(p)("inventory.transfer.form.purchaseFrom") : t(p)("inventory.transfer.form.transferFrom")
1518
+ }, null, 8, ["label"]),
1519
+ i("div", Co, [
1520
+ v(pe, {
1521
+ "z-index": 51,
1522
+ placement: "left",
1523
+ disabled: o.disabled
1524
+ }, {
1525
+ content: T(() => f[16] || (f[16] = [
1526
+ Me("This field is locked from template.")
1527
+ ])),
1528
+ default: T(() => [
1529
+ v(ce, null, {
1530
+ default: T(() => {
1531
+ var I, Z, ge;
1532
+ return [
1533
+ i("div", xo, [
1534
+ v(me, {
1535
+ name: "lock_outline",
1536
+ size: "sm",
1537
+ color: o.disabled ? "neutral-gray-200" : "neutral-gray-400"
1538
+ }, null, 8, ["color"]),
1539
+ i("div", {
1540
+ class: ee({ "text-fm-color-typo-disabled": o.disabled })
1541
+ }, E(((Z = (I = o.returnFrom) == null ? void 0 : I.supplier) == null ? void 0 : Z.name) ?? ((ge = L.value.find((Ee) => Ee.value === U.value)) == null ? void 0 : ge.label)), 3)
1542
+ ])
1543
+ ];
1544
+ }),
1545
+ _: 1
1546
+ })
1547
+ ]),
1548
+ _: 1
1549
+ }, 8, ["disabled"])
1550
+ ])
1551
+ ])
1552
+ ], 64)) : (C(), V(be, { key: 1 }, [
1553
+ v(he, {
1554
+ label: t(p)("inventory.transfer.form.type.title"),
1555
+ "label-mark": "required",
1556
+ modelValue: D.value,
1557
+ "onUpdate:modelValue": f[0] || (f[0] = (I) => D.value = I),
1558
+ items: Re.value,
1559
+ rules: [t(Ue)(1)(L.value)]
1560
+ }, {
1561
+ default: T(() => [
1562
+ i("span", {
1563
+ class: ee([
1564
+ "line-clamp-1 fm-typo-en-body-lg-400",
1565
+ o.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-typo-primary"
1566
+ ])
1567
+ }, E(t(Qt)(D.value)), 3)
1568
+ ]),
1569
+ _: 1
1570
+ }, 8, ["label", "modelValue", "items", "rules"]),
1571
+ v(he, {
1572
+ label: D.value === t(X).PURCHASE ? t(p)("inventory.transfer.form.purchaseFrom") : t(p)("inventory.transfer.form.transferFrom"),
1573
+ "label-mark": "required",
1574
+ modelValue: U.value,
1575
+ "onUpdate:modelValue": f[1] || (f[1] = (I) => U.value = I),
1576
+ items: L.value
1577
+ }, {
1578
+ "menu-wrapper": T((I) => {
1579
+ var Z, ge;
1580
+ return [
1581
+ v(is, Ye(I, {
1582
+ items: L.value,
1583
+ "model-value": (ge = (Z = o.modelValue) == null ? void 0 : Z.supplier) == null ? void 0 : ge._id
1584
+ }), null, 16, ["items", "model-value"])
1585
+ ];
1586
+ }),
1587
+ default: T(() => {
1588
+ var I;
1589
+ return [
1590
+ i("span", {
1591
+ class: ee([
1592
+ "line-clamp-1 fm-typo-en-body-lg-400",
1593
+ o.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-typo-primary"
1594
+ ])
1595
+ }, E((I = L.value.find((Z) => Z.value === U.value)) == null ? void 0 : I.label), 3)
1596
+ ];
1597
+ }),
1598
+ _: 1
1599
+ }, 8, ["label", "modelValue", "items"])
1600
+ ], 64)),
1601
+ v(qe, {
1602
+ label: t(p)("inventory.transfer.form.reference"),
1603
+ "label-mark": "optional",
1604
+ modelValue: t(s).ref,
1605
+ "onUpdate:modelValue": f[2] || (f[2] = (I) => t(s).ref = I)
1606
+ }, null, 8, ["label", "modelValue"]),
1607
+ v(Ae, {
1608
+ label: t(p)("inventory.transfer.form.remark"),
1609
+ "label-mark": "optional",
1610
+ "max-length": 240,
1611
+ modelValue: A.value,
1612
+ "onUpdate:modelValue": f[3] || (f[3] = (I) => A.value = I),
1613
+ class: ee([o.disabled ? "text-fm-color-typo-disabled " : ""])
1614
+ }, null, 8, ["label", "modelValue", "class"]),
1615
+ x.value ? (C(), Y(fo, {
1616
+ key: 2,
1617
+ required: t(s).templateDoc != null,
1618
+ disabled: o.disabled,
1619
+ supplier: t(s).supplier,
1620
+ setting: t(s).netSuite,
1621
+ items: t(s).items,
1622
+ onChange: (I, Z) => {
1623
+ t(s).items = I, t(s).netSuite = Z;
1624
+ },
1625
+ "onNetsuite:ready": f[4] || (f[4] = (I) => {
1626
+ g.value = !0;
1627
+ })
1628
+ }, null, 8, ["required", "disabled", "supplier", "setting", "items", "onChange"])) : j("", !0),
1629
+ t(e).enableBackdatePo ? (C(), V("div", wo, [
1630
+ i("div", {
1631
+ class: ee([
1632
+ "flex",
1633
+ {
1634
+ "flex-col": S.value
1635
+ }
1636
+ ])
1637
+ }, [
1638
+ v(Ie, {
1639
+ modelValue: t(G),
1640
+ "onUpdate:modelValue": f[5] || (f[5] = (I) => we(G) ? G.value = I : null),
1641
+ label: t(p)("inventory.transfer.form.backdate.title"),
1642
+ sublabel: t(p)("inventory.transfer.form.backdate.subtitle"),
1643
+ "label-placement": "right",
1644
+ disabled: M.value && !o.lastClosingDate || o.disabled
1645
+ }, null, 8, ["modelValue", "label", "sublabel", "disabled"]),
1646
+ i("div", {
1647
+ class: ee({ hidden: S.value, "w-16": !S.value })
1648
+ }, null, 2),
1649
+ t(G) ? (C(), V("div", Io, [
1650
+ i("div", Fo, [
1651
+ v(B, {
1652
+ modelValue: t(J),
1653
+ "onUpdate:modelValue": f[6] || (f[6] = (I) => we(J) ? J.value = I : null)
1654
+ }, null, 8, ["modelValue"])
1655
+ ]),
1656
+ i("div", Do, [
1657
+ v(oe, {
1658
+ modelValue: t(y),
1659
+ "onUpdate:modelValue": f[7] || (f[7] = (I) => we(y) ? y.value = I : null)
1660
+ }, null, 8, ["modelValue"])
1661
+ ])
1662
+ ])) : j("", !0)
1663
+ ], 2),
1664
+ t(N) ? (C(), Y(re, {
1665
+ key: 0,
1666
+ modelValue: t(N),
1667
+ "onUpdate:modelValue": f[8] || (f[8] = (I) => we(N) ? N.value = I : null),
1668
+ rules: [t(Yt)(new Date(o.lastClosingDate), /* @__PURE__ */ new Date())]
1669
+ }, null, 8, ["modelValue", "rules"])) : j("", !0),
1670
+ M.value && !o.lastClosingDate ? (C(), V("div", $o, [
1671
+ v(me, {
1672
+ name: "error",
1673
+ size: "sm",
1674
+ class: "text-fm-color-typo-warning"
1675
+ }),
1676
+ i("span", To, E(t(p)("inventory.transfer.form.backdate.error")), 1)
1677
+ ])) : j("", !0)
1678
+ ])) : j("", !0)
1679
+ ])
1680
+ ]),
1681
+ i("div", Po, [
1682
+ v(re, {
1683
+ "model-value": t(s).items,
1684
+ rules: [t(Ue)(1)]
1685
+ }, null, 8, ["model-value", "rules"]),
1686
+ i("div", {
1687
+ class: ee([
1688
+ "flex gap-16",
1689
+ {
1690
+ "flex-col items-start": S.value,
1691
+ "items-center": !S.value
1692
+ }
1693
+ ])
1694
+ }, [
1695
+ i("div", Vo, E(t(p)("inventory.transfer.form.items.title")), 1),
1696
+ i("div", Ro, [
1697
+ v(ne, {
1698
+ disabled: o.disabled,
1699
+ label: t(p)("inventory.transfer.form.items.addItem"),
1700
+ "prepend-icon": "add",
1701
+ variant: "secondary",
1702
+ "text-color": "primary",
1703
+ "bg-color": "transparent",
1704
+ "border-color": "primary",
1705
+ onClick: f[9] || (f[9] = (I) => Ve()),
1706
+ size: "md"
1707
+ }, null, 8, ["disabled", "label"]),
1708
+ t(s).templateDoc ? (C(), Y(pe, {
1709
+ key: 0,
1710
+ "z-index": 50
1711
+ }, {
1712
+ content: T(() => [
1713
+ i("div", null, E(t(p)("inventory.transfer.form.items.forecastStock.notAvailable")), 1)
1714
+ ]),
1715
+ default: T(() => [
1716
+ v(ft, {
1717
+ "onUpdate:poItems": f[10] || (f[10] = (I) => t(s).items = I),
1718
+ disabled: ""
1719
+ })
1720
+ ]),
1721
+ _: 1
1722
+ })) : (C(), Y(ft, {
1723
+ key: 1,
1724
+ "onUpdate:poItems": f[11] || (f[11] = (I) => t(s).items = I),
1725
+ disabled: o.disabled || !!t(s).templateDoc
1726
+ }, null, 8, ["disabled"]))
1727
+ ])
1728
+ ], 2),
1729
+ D.value === t(X).PURCHASE && $.value && t(e).enableTotalCost && ((ot = o.modelValue) != null && ot.items.length) ? (C(), V("div", qo, [
1730
+ v(Ie, {
1731
+ label: t(R) ? t(p)("inventory.transfer.form.items.fetchingData") : t(p)("inventory.transfer.form.items.comparePriceHistory"),
1732
+ "prepend-icon": "compare_arrows",
1733
+ "label-placement": "right",
1734
+ "model-value": t(d),
1735
+ "onUpdate:modelValue": f[12] || (f[12] = (I) => we(d) ? d.value = I : null),
1736
+ disabled: t(R) || o.disabled
1737
+ }, null, 8, ["label", "model-value", "disabled"])
1738
+ ])) : j("", !0),
1739
+ (C(), Y(fe, {
1740
+ "column-defs": Pe.value,
1741
+ "column-visibility": {
1742
+ [t(H).Code]: !(((nt = o.modelValue) == null ? void 0 : nt.template) ?? ((at = o.modelValue) == null ? void 0 : at.templateDoc)),
1743
+ [t(H).Name]: !(((lt = o.modelValue) == null ? void 0 : lt.template) ?? ((rt = o.modelValue) == null ? void 0 : rt.templateDoc)),
1744
+ [t(H).TemplateName]: !!(((it = o.modelValue) == null ? void 0 : it.template) ?? ((ut = o.modelValue) == null ? void 0 : ut.templateDoc))
1745
+ },
1746
+ "row-data": t(s).items,
1747
+ key: t(s).items.map((I) => I.sku._id).join("."),
1748
+ "hide-footer": "",
1749
+ "page-size": t(s).items.length
1750
+ }, {
1751
+ "table-row": T((I) => {
1752
+ var Z, ge, Ee, dt;
1753
+ return [
1754
+ v(io, {
1755
+ "compare-price-by-sku": t(K),
1756
+ "show-compare-price": D.value === t(X).PURCHASE && t(d),
1757
+ row: I,
1758
+ "template-item": (dt = (Ee = (ge = (Z = o.modelValue) == null ? void 0 : Z.templateDoc) == null ? void 0 : ge.purchaseOrder) == null ? void 0 : Ee.items) == null ? void 0 : dt.find(
1759
+ (je) => je.sku._id === I.original.sku._id
1760
+ ),
1761
+ "onUpdate:item": f[13] || (f[13] = (je) => Ce.value.updateItem(je)),
1762
+ disabled: o.disabled
1763
+ }, null, 8, ["compare-price-by-sku", "show-compare-price", "row", "template-item", "disabled"])
1764
+ ];
1765
+ }),
1766
+ "list-row": T((I) => [
1767
+ (C(), Y(St, {
1768
+ row: I,
1769
+ key: t(s).items.map((Z) => Z.sku._id).join(".")
1770
+ }, {
1771
+ default: T((Z) => [
1772
+ v(Vs, {
1773
+ "compare-price-by-sku": t(K),
1774
+ "show-compare-price": D.value === t(X).PURCHASE && t(d),
1775
+ row: I,
1776
+ "cell-by-col-id": Z
1777
+ }, null, 8, ["compare-price-by-sku", "show-compare-price", "row", "cell-by-col-id"])
1778
+ ]),
1779
+ _: 2
1780
+ }, 1032, ["row"]))
1781
+ ]),
1782
+ _: 1
1783
+ }, 8, ["column-defs", "column-visibility", "row-data", "page-size"]))
1784
+ ])
1785
+ ];
1786
+ }),
1787
+ _: 1
1788
+ }, 8, ["disabled", "onValidationFailed"])
1789
+ ]);
1790
+ };
1791
+ }
1792
+ });
1793
+ function Eo(m, b) {
1794
+ b ?? (b = `Return to ${m.supplier.name}`);
1795
+ const r = ze().currentLocation, h = us(r), s = {};
1796
+ for (const c of m.items) {
1797
+ const u = c.sku._id;
1798
+ s[u] = $e.reset();
1799
+ }
1800
+ const p = m.deliveryOrder.flatMap((c) => c.received);
1801
+ for (const c of p) {
1802
+ const u = c.sku._id;
1803
+ if (!s[u]) continue;
1804
+ const _ = c.measurement ? $e.multiply([c.measurement.conversion, c.amount]) : c.amount;
1805
+ s[u] = $e.add([s[u], _]);
1806
+ }
1807
+ return {
1808
+ _id: m._id,
1809
+ name: b,
1810
+ purchaseOrder: {
1811
+ supplier: h,
1812
+ ref: m.ref,
1813
+ remark: m.remark,
1814
+ items: m.items.map((c) => {
1815
+ if (c.subItems) {
1816
+ const { subItems: u, ..._ } = c;
1817
+ c = _;
1818
+ }
1819
+ return {
1820
+ ...c,
1821
+ quantityStep: {
1822
+ amount: 1,
1823
+ precision: Ne(c.sku.unit, c.measurement)
1824
+ },
1825
+ quantity: s[c.sku._id],
1826
+ maximumQuantity: s[c.sku._id]
1827
+ };
1828
+ }).filter((c) => {
1829
+ var u;
1830
+ return (u = c.maximumQuantity) == null ? void 0 : u.amount;
1831
+ })
1832
+ }
1833
+ };
1834
+ }
1835
+ const Oo = { class: "flex items-center" }, Mo = { class: "fm-typo-en-title-md-800" }, Uo = { class: "flex gap-4" }, Bo = /* @__PURE__ */ le({
1836
+ __name: "TransferDialog",
1837
+ props: {
1838
+ mode: {},
1839
+ modelValue: {},
1840
+ returnFrom: {},
1841
+ "onSubmit:returnStock": { type: Function },
1842
+ templateId: {},
1843
+ show: { type: Boolean },
1844
+ lastClosingDate: {}
1845
+ },
1846
+ emits: ["update:show", "submitted"],
1847
+ setup(m, { expose: b, emit: l }) {
1848
+ var J;
1849
+ const r = m, h = l, s = Ct(), p = It(), c = Le(), u = st(), _ = ze(), { t: n } = ke(), e = Q(!1), a = Q(!1), k = Q(!1), S = Tt();
1850
+ async function g(y) {
1851
+ if (y) {
1852
+ a.value = !1;
1853
+ try {
1854
+ await u.readSuppliers(), a.value = !0;
1855
+ } catch {
1856
+ c.open({
1857
+ title: n("inventory.transfer.form.unableToFetchListOfSuppliers.title"),
1858
+ message: n("inventory.transfer.form.unableToFetchListOfSuppliers.message"),
1859
+ type: "error"
1860
+ });
1861
+ }
1862
+ }
1863
+ }
1864
+ _.watchLocation(g);
1865
+ function x() {
1866
+ const y = {
1867
+ remark: void 0,
1868
+ ref: void 0,
1869
+ stockSnapshotId: void 0,
1870
+ effectiveAt: void 0,
1871
+ items: [],
1872
+ supplier: {
1873
+ _rev: void 0,
1874
+ email: void 0,
1875
+ internal: void 0,
1876
+ contactName: void 0,
1877
+ phoneNumber: void 0,
1878
+ registrationNumber: void 0,
1879
+ supplyItems: void 0,
1880
+ _id: "",
1881
+ name: "",
1882
+ address: {
1883
+ line2: void 0,
1884
+ line1: "",
1885
+ state: "",
1886
+ city: "",
1887
+ postcode: "",
1888
+ country: ""
1889
+ }
1890
+ },
1891
+ status: "DRAFT",
1892
+ _id: "",
1893
+ seqNumber: 0,
1894
+ deliveryOrder: [],
1895
+ template: r.templateId,
1896
+ templateDoc: p.templates.find((d) => d._id === r.templateId)
1897
+ };
1898
+ if (r.returnFrom) {
1899
+ const d = Eo(r.returnFrom);
1900
+ y.templateDoc = d, y.template = d._id, y.supplier = d.purchaseOrder.supplier ?? y.supplier, y.items = d.purchaseOrder.items ?? [], y.isReturnPo = !0;
1901
+ }
1902
+ return y;
1903
+ }
1904
+ const w = ls(r, "show"), $ = Q(r.modelValue ?? x()), M = Q(((J = r.modelValue) == null ? void 0 : J._id) ?? `${Math.random()}`);
1905
+ _e(
1906
+ () => r.show,
1907
+ (y) => {
1908
+ var d;
1909
+ y && (k.value = !1, $.value = r.modelValue ?? x(), M.value = ((d = r.modelValue) == null ? void 0 : d._id) ?? `${Math.random()}`);
1910
+ }
1911
+ );
1912
+ const te = O(() => !a.value || !k.value), F = O(() => {
1913
+ if (r.returnFrom)
1914
+ return "Return transfer";
1915
+ switch (r.mode) {
1916
+ case De.READ:
1917
+ return "View transfer";
1918
+ case De.CREATE:
1919
+ return n("inventory.transfer.receiveRequest.create.title");
1920
+ case De.UPDATE:
1921
+ return n("inventory.transfer.receiveRequest.update.title");
1922
+ }
1923
+ return "";
1924
+ }), D = Q();
1925
+ b({
1926
+ validateInputs: () => {
1927
+ var y, d;
1928
+ (d = (y = D.value) == null ? void 0 : y.validateInputs) == null || d.call(y);
1929
+ },
1930
+ resetInputsValidation: () => {
1931
+ var y, d;
1932
+ (d = (y = D.value) == null ? void 0 : y.resetInputsValidation) == null || d.call(y);
1933
+ },
1934
+ resetInputs: () => {
1935
+ var y, d;
1936
+ (d = (y = D.value) == null ? void 0 : y.resetInputs) == null || d.call(y);
1937
+ }
1938
+ });
1939
+ async function L() {
1940
+ var d;
1941
+ if (!(!await S.confirmation(
1942
+ "Submit return stock request?",
1943
+ "Stock will be deducted upon confirmation."
1944
+ ) || !$.value || !r.returnFrom)) {
1945
+ e.value = !0;
1946
+ try {
1947
+ await ((d = r["onSubmit:returnStock"]) == null ? void 0 : d.call(r, $.value, r.returnFrom));
1948
+ } catch (R) {
1949
+ c.open({
1950
+ title: n("inventory.transfer.receiveRequest.create.error.title"),
1951
+ message: n("inventory.transfer.receiveRequest.create.error.message"),
1952
+ type: "error"
1953
+ }), console.error("Error in creating purchase order", R);
1954
+ } finally {
1955
+ e.value = !1, h("update:show", !1);
1956
+ }
1957
+ }
1958
+ }
1959
+ async function U() {
1960
+ const y = $.value;
1961
+ e.value = !0, y.items.some((d) => {
1962
+ var R;
1963
+ return (R = d.subItems) == null ? void 0 : R.length;
1964
+ }) && (y.items = y.items.map((d) => {
1965
+ var K;
1966
+ if (!((K = d.subItems) != null && K.length)) return d;
1967
+ const R = Ge(d.subItems);
1968
+ return {
1969
+ ...d,
1970
+ quantity: R,
1971
+ // note: no measurement, total is calculate in base unit
1972
+ measurement: null,
1973
+ totalCost: ve(d.sku, R)
1974
+ };
1975
+ })), (y.supplier.internal === "warehouse" || y.supplier.internal === "restaurant") && (y.items = y.items.map(({ totalCost: d, ...R }) => R));
1976
+ try {
1977
+ await s.createPurchaseOrder(y), await new Promise((d) => setTimeout(d, 1e3)), c.open({
1978
+ title: n("inventory.transfer.receiveRequest.create.success"),
1979
+ message: n("inventory.transfer.receiveRequest.create.successMessage"),
1980
+ type: "success"
1981
+ }), h("update:show", !1), h("submitted");
1982
+ } catch (d) {
1983
+ c.open({
1984
+ title: n("inventory.transfer.receiveRequest.create.error.title"),
1985
+ message: n("inventory.transfer.receiveRequest.create.error.message"),
1986
+ type: "error"
1987
+ }), console.error("Error in creating purchase order", d);
1988
+ } finally {
1989
+ e.value = !1;
1990
+ }
1991
+ }
1992
+ async function A() {
1993
+ const y = $.value;
1994
+ e.value = !0, y.items.some((d) => {
1995
+ var R;
1996
+ return (R = d.subItems) == null ? void 0 : R.length;
1997
+ }) && (y.items = y.items.map((d) => {
1998
+ var K;
1999
+ if (!((K = d.subItems) != null && K.length)) return d;
2000
+ const R = Ge(d.subItems);
2001
+ return {
2002
+ ...d,
2003
+ quantity: R,
2004
+ // note: no measurement, total is calculate in base unit
2005
+ measurement: null,
2006
+ totalCost: ve(d.sku, R)
2007
+ };
2008
+ })), (y.supplier.internal === "warehouse" || y.supplier.internal === "restaurant") && (y.items = y.items.map(({ totalCost: d, ...R }) => R));
2009
+ try {
2010
+ await s.updatePurchaseOrder(y), await new Promise((d) => setTimeout(d, 1e3)), c.open({
2011
+ title: n("inventory.transfer.receiveRequest.update.success"),
2012
+ message: n("inventory.transfer.receiveRequest.update.successMessage"),
2013
+ type: "success"
2014
+ }), h("update:show", !1), h("submitted");
2015
+ } catch (d) {
2016
+ c.open({
2017
+ title: n("inventory.transfer.receiveRequest.update.error.title"),
2018
+ message: n("inventory.transfer.receiveRequest.update.error.message"),
2019
+ type: "error"
2020
+ }), console.error("Error in updating purchase order", d);
2021
+ } finally {
2022
+ e.value = !1;
2023
+ }
2024
+ }
2025
+ function N() {
2026
+ switch (r.mode) {
2027
+ case De.CREATE:
2028
+ return r.returnFrom ? L() : U();
2029
+ case De.UPDATE:
2030
+ return A();
2031
+ }
2032
+ }
2033
+ function G() {
2034
+ var y, d;
2035
+ (d = (y = D.value) == null ? void 0 : y.validateInputs) == null || d.call(y);
2036
+ }
2037
+ return (y, d) => {
2038
+ const R = P("FmButton"), K = P("FmSideSheet");
2039
+ return C(), Y(K, {
2040
+ modelValue: t(w),
2041
+ "onUpdate:modelValue": d[3] || (d[3] = (se) => we(w) ? w.value = se : null),
2042
+ "dismiss-away": "",
2043
+ "close-button": "",
2044
+ "max-width": 900
2045
+ }, {
2046
+ "side-sheet-header": T(() => [
2047
+ i("div", Oo, [
2048
+ i("div", Mo, E(F.value), 1)
2049
+ ])
2050
+ ]),
2051
+ default: T(() => [
2052
+ (C(), Y(Ao, {
2053
+ class: "w-full",
2054
+ ref_key: "formRef",
2055
+ ref: D,
2056
+ "onForm:ready": d[0] || (d[0] = () => k.value = !0),
2057
+ onValidationSuccess: N,
2058
+ modelValue: $.value,
2059
+ "onUpdate:modelValue": d[1] || (d[1] = (se) => $.value = se),
2060
+ disabled: e.value || te.value,
2061
+ "return-from": y.returnFrom,
2062
+ key: M.value,
2063
+ "last-closing-date": y.lastClosingDate
2064
+ }, null, 8, ["modelValue", "disabled", "return-from", "last-closing-date"]))
2065
+ ]),
2066
+ "side-sheet-footer": T(() => [
2067
+ i("div", Uo, [
2068
+ v(R, {
2069
+ loading: e.value,
2070
+ disabled: te.value,
2071
+ label: t(n)("common.save"),
2072
+ onClick: G
2073
+ }, null, 8, ["loading", "disabled", "label"]),
2074
+ v(R, {
2075
+ disabled: te.value,
2076
+ variant: "tertiary",
2077
+ label: t(n)("common.close"),
2078
+ onClick: d[2] || (d[2] = (se) => h("update:show", !1))
2079
+ }, null, 8, ["disabled", "label"])
2080
+ ])
2081
+ ]),
2082
+ _: 1
2083
+ }, 8, ["modelValue"]);
2084
+ };
2085
+ }
2086
+ }), No = { class: "flex flex-col py-8" }, zo = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Lo = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary line-clamp-1" }, Ho = { class: "fm-typo-en-body-md-400 text-fm-color-typo-primary line-clamp-1" }, jo = {
2087
+ key: 0,
2088
+ class: "fm-typo-en-body-md-400 text-fm-color-typo-primary line-clamp-1"
2089
+ }, Qo = { class: "pt-8" }, yt = "ReceiveRequestViewSearchCriteria", dn = /* @__PURE__ */ le({
2090
+ __name: "ReceiveRequestView",
2091
+ setup(m) {
2092
+ const { t: b } = ke(), l = Le();
2093
+ Oe.object({
2094
+ name: Oe.string().optional().nullable(),
2095
+ startDate: Oe.string().optional().nullable(),
2096
+ endDate: Oe.string().optional().nullable()
2097
+ });
2098
+ const r = O(
2099
+ () => !e._currentLocation || _.loading.value
2100
+ ), h = ns(), s = tt();
2101
+ function p() {
2102
+ const F = {
2103
+ name: "",
2104
+ ...ct()
2105
+ }, D = h.getItem(yt);
2106
+ if (!D)
2107
+ return F;
2108
+ try {
2109
+ return JSON.parse(D);
2110
+ } catch {
2111
+ return F;
2112
+ }
2113
+ }
2114
+ function c() {
2115
+ h.setItem(yt, JSON.stringify(u.value));
2116
+ }
2117
+ const u = Q(p()), _ = Jt(
2118
+ Qe.RECEIVE_REQUEST,
2119
+ u.value
2120
+ ), { columnDefs: n } = Wt(
2121
+ Qe.RECEIVE_REQUEST,
2122
+ _
2123
+ ), e = ze();
2124
+ async function a() {
2125
+ const F = `inventory-record_${pt(u.value.startDate).format("DD-MM-YYYY_HH-mm")}-${pt(u.value.endDate).format("DD-MM-YYYY_HH-mm")}.xlsx`, D = _.purchaseOrders.value.flatMap(
2126
+ (U) => U.items.map((A) => {
2127
+ const N = new Date(ss(U._id) ?? ""), G = U.effectiveAt ? new Date(U.effectiveAt) : void 0, J = ae(
2128
+ es(A.sku, U.deliveryOrder || [])
2129
+ ), y = ae(A.quantity);
2130
+ return {
2131
+ "SKU code": A.code,
2132
+ "SKU name": A.name,
2133
+ "PO #": U.seqNumber,
2134
+ "Effective at": G,
2135
+ Date: N,
2136
+ Status: U.status,
2137
+ Reference: U.ref ?? "",
2138
+ "Received quantity": J,
2139
+ "Ordered quantity": y,
2140
+ Unit: A.sku.unit.abbrev,
2141
+ "Total cost": A.totalCost ? We(A.totalCost) : null
2142
+ };
2143
+ })
2144
+ ), L = [
2145
+ "SKU code",
2146
+ "SKU name",
2147
+ "PO #",
2148
+ "Date",
2149
+ "Status",
2150
+ "Reference",
2151
+ "Received quantity",
2152
+ "Ordered quantity",
2153
+ "Unit"
2154
+ ];
2155
+ s.enableBackdatePo && L.insert("Effective at", 4), s.enableTotalCost && L.push("Total cost"), await os(
2156
+ [
2157
+ {
2158
+ name: "purchases",
2159
+ data: D,
2160
+ columns: L
2161
+ }
2162
+ ],
2163
+ F
2164
+ ), l.open({
2165
+ title: b("inventory.transfer.receiveRequest.export.success"),
2166
+ message: b("inventory.transfer.receiveRequest.export.message", [F]),
2167
+ type: "success"
2168
+ });
2169
+ }
2170
+ const k = Q(ct()), S = Q("");
2171
+ _e([() => k.value], ([F]) => {
2172
+ !F.startDate || !F.endDate || (u.value.startDate = F.startDate, u.value.endDate = F.endDate, _.updateDateRange(
2173
+ u.value.startDate,
2174
+ u.value.endDate
2175
+ ), c());
2176
+ }), _e([() => S.value], () => {
2177
+ c();
2178
+ });
2179
+ function g(F) {
2180
+ if (F === "create") {
2181
+ if (r.value) {
2182
+ l.open({
2183
+ title: "Loading data...",
2184
+ message: "Please wait.",
2185
+ type: "info"
2186
+ });
2187
+ return;
2188
+ }
2189
+ return _.promptCreateTransferDialog();
2190
+ }
2191
+ if (F === "refresh")
2192
+ return _.fetchData();
2193
+ if (F === "export")
2194
+ return a();
2195
+ }
2196
+ const { breakpoints: x } = et(), w = O(() => x.value.xs || x.value.sm), $ = O(() => w.value ? 10 : 20), M = Kt(), te = O(() => [
2197
+ {
2198
+ label: b("inventory.transfer.receiveRequest.actions.create"),
2199
+ value: "create",
2200
+ isPrimary: !0,
2201
+ prependIcon: "add"
2202
+ },
2203
+ {
2204
+ label: b("common.refresh"),
2205
+ value: "refresh"
2206
+ },
2207
+ {
2208
+ label: b("common.export"),
2209
+ value: "export"
2210
+ }
2211
+ ]);
2212
+ return (F, D) => {
2213
+ const L = P("FmTable");
2214
+ return C(), Y(Zt, {
2215
+ title: t(b)("inventory.transfer.receiveRequest.title2"),
2216
+ actions: te.value,
2217
+ "onClick:action": g
2218
+ }, {
2219
+ default: T(() => {
2220
+ var U;
2221
+ return [
2222
+ i("div", {
2223
+ class: ee([
2224
+ "flex flex-col gap-8 max-h-full",
2225
+ {
2226
+ "p-0": w.value,
2227
+ "px-24 ": !w.value
2228
+ }
2229
+ ])
2230
+ }, [
2231
+ v(Gt, {
2232
+ "date-range-query": "",
2233
+ "date-range": k.value,
2234
+ "onUpdate:dateRange": D[0] || (D[0] = (A) => k.value = A),
2235
+ searchable: "",
2236
+ "change-location": "",
2237
+ search: S.value,
2238
+ "onUpdate:search": D[1] || (D[1] = (A) => S.value = A)
2239
+ }, null, 8, ["date-range", "search"]),
2240
+ (C(), Y(L, {
2241
+ style: bt(t(M).tableHeight),
2242
+ "column-defs": t(n),
2243
+ "row-data": t(_).purchaseOrders.value,
2244
+ "search-value": S.value,
2245
+ loading: r.value,
2246
+ onRowClick: D[2] || (D[2] = (A) => t(_).promptShowTransferDetails(A.original)),
2247
+ key: (U = t(e)._currentLocation) == null ? void 0 : U.dbName,
2248
+ "page-size": $.value
2249
+ }, {
2250
+ "list-row": T((A) => [
2251
+ v(St, {
2252
+ row: A,
2253
+ onRowClick: t(_).promptShowTransferDetails
2254
+ }, {
2255
+ default: T((N) => {
2256
+ var G, J, y, d, R, K, se, Ce, xe, Pe, Ve, He, Re, o, f, z, W, me, ce, pe;
2257
+ return [
2258
+ i("div", No, [
2259
+ i("div", zo, [
2260
+ v(t(de), {
2261
+ render: (y = (J = (G = N._id) == null ? void 0 : G.column) == null ? void 0 : J.columnDef) == null ? void 0 : y.cell,
2262
+ props: (R = (d = N._id) == null ? void 0 : d.getContext) == null ? void 0 : R.call(d)
2263
+ }, null, 8, ["render", "props"])
2264
+ ]),
2265
+ i("div", Lo, [
2266
+ v(t(de), {
2267
+ render: (Ce = (se = (K = N.supplier_name) == null ? void 0 : K.column) == null ? void 0 : se.columnDef) == null ? void 0 : Ce.cell,
2268
+ props: (Pe = (xe = N.supplier_name) == null ? void 0 : xe.getContext) == null ? void 0 : Pe.call(xe)
2269
+ }, null, 8, ["render", "props"])
2270
+ ]),
2271
+ i("div", Ho, E(A.original.items.map((he) => `${he.name}`).join(", ")), 1),
2272
+ A.original.ref ? (C(), V("div", jo, [
2273
+ v(t(de), {
2274
+ render: (Re = (He = (Ve = N.ref) == null ? void 0 : Ve.column) == null ? void 0 : He.columnDef) == null ? void 0 : Re.cell,
2275
+ props: (f = (o = N.ref) == null ? void 0 : o.getContext) == null ? void 0 : f.call(o)
2276
+ }, null, 8, ["render", "props"])
2277
+ ])) : j("", !0),
2278
+ i("div", Qo, [
2279
+ v(t(de), {
2280
+ render: (me = (W = (z = N.status) == null ? void 0 : z.column) == null ? void 0 : W.columnDef) == null ? void 0 : me.cell,
2281
+ props: (pe = (ce = N.status) == null ? void 0 : ce.getContext) == null ? void 0 : pe.call(ce)
2282
+ }, null, 8, ["render", "props"])
2283
+ ])
2284
+ ])
2285
+ ];
2286
+ }),
2287
+ _: 2
2288
+ }, 1032, ["row", "onRowClick"])
2289
+ ]),
2290
+ _: 1
2291
+ }, 8, ["style", "column-defs", "row-data", "search-value", "loading", "page-size"]))
2292
+ ], 2),
2293
+ (C(), Y(At, { to: "body" }, [
2294
+ v(Bo, Ye(t(_).transferDialogProps.value, {
2295
+ onSubmitted: t(_).fetchData,
2296
+ "on-submit:return-stock": (A, N) => t(_).submitAction(
2297
+ A,
2298
+ "returnStock",
2299
+ void 0,
2300
+ N
2301
+ )
2302
+ }), null, 16, ["onSubmitted", "on-submit:return-stock"]),
2303
+ v(Xt, Ye({
2304
+ scope: t(Qe).RECEIVE_REQUEST
2305
+ }, t(_).transferDetailsProps.value, {
2306
+ onSubmitted: t(_).fetchData,
2307
+ onReturnStock: t(_).promptReturnTransferDialog
2308
+ }), null, 16, ["scope", "onSubmitted", "onReturnStock"])
2309
+ ]))
2310
+ ];
2311
+ }),
2312
+ _: 1
2313
+ }, 8, ["title", "actions"]);
2314
+ };
2315
+ }
2316
+ });
2317
+ export {
2318
+ dn as default
2319
+ };