@feedmepos/mf-inventory-portal 1.2.61-dev.1 → 1.2.63-dev.1

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