@feedmepos/mf-inventory-portal 1.2.37-dev.3 → 1.2.37-dev.5

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