@feedmepos/mf-inventory-portal 1.2.41-dev.2 → 1.2.41

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