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