@feedmepos/mf-inventory-portal 1.2.42 → 1.2.43-dev.2

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