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