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