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