@feedmepos/mf-inventory-portal 0.0.5 → 0.0.7-dev.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/dist/{ApprovalView-CTQdDgGH.js → ApprovalView-BYZcvkso.js} +6 -6
  2. package/dist/BindingsDialog-pdS86VDU.js +94 -0
  3. package/dist/{BindingsPicker-CQIGhTCR.js → BindingsPicker-D891Cfzu.js} +2 -2
  4. package/dist/{BindingsTable-Da4BLkvc.js → BindingsTable-tmr6QwLk.js} +30 -31
  5. package/dist/{ChangeLocationComponent.vue_vue_type_script_setup_true_lang-DcixBOcX.js → ChangeLocationComponent.vue_vue_type_script_setup_true_lang-Bss0q2Zt.js} +7 -7
  6. package/dist/{FmMultiselectDialog.vue_vue_type_script_setup_true_lang-BXU7x6di.js → FmMultiselectDialog.vue_vue_type_script_setup_true_lang-BHcLUkdm.js} +19 -20
  7. package/dist/{IngredientBindedItem.vue_vue_type_script_setup_true_lang-CD89qCIa.js → IngredientBindedItem.vue_vue_type_script_setup_true_lang-BIww2Noe.js} +1 -1
  8. package/dist/IngredientsView-BH6G7830.js +819 -0
  9. package/dist/{IntegrationView-BRWYO3VE.js → IntegrationView-CfJn6Fzn.js} +3 -3
  10. package/dist/InventoryBindingForm.vue_vue_type_script_setup_true_lang-39U8Iavr.js +258 -0
  11. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-DBK7mpQS.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-nDxqau1g.js} +1 -1
  12. package/dist/{PurchaseOrderPrintPreview-CH9gVYDg.js → PurchaseOrderPrintPreview-Db2U_IQL.js} +1 -1
  13. package/dist/ReceiveRequestView-CgVfcS8C.js +1483 -0
  14. package/dist/{RecipeView-DFG9Wkx-.js → RecipeView-C9_Y_A9b.js} +58 -58
  15. package/dist/StockView-CoUI3Faj.js +1916 -0
  16. package/dist/SupplierView-CNq6wVfN.js +818 -0
  17. package/dist/{TransferDetails.vue_vue_type_script_setup_true_lang-Ffe9bhq8.js → TransferDetails.vue_vue_type_script_setup_true_lang-Cmajrg-9.js} +5 -5
  18. package/dist/{UnitView-C3XVSbJY.js → UnitView-Buyp4Gnc.js} +190 -177
  19. package/dist/{WarehouseView-BntzAdz3.js → WarehouseView-DbUib0PR.js} +56 -56
  20. package/dist/api/inventory.d.ts +33 -0
  21. package/dist/api/stock-estimate.d.ts +16 -0
  22. package/dist/api/stock.d.ts +8 -0
  23. package/dist/app-DM4Thqjw.js +42756 -0
  24. package/dist/app.js +1 -1
  25. package/dist/components/StockForecast.vue.d.ts +12 -0
  26. package/dist/components/StockForecastProps.d.ts +3 -0
  27. package/dist/components/inventory-binding/InventoryBinding.vue.d.ts +16 -0
  28. package/dist/components/shell/inventory/binding-ui.vue.d.ts +16 -0
  29. package/dist/core.d.ts +3 -2
  30. package/dist/date2-DpU4LDaP.js +199 -0
  31. package/dist/dayjs.min-D4Q_pHH9.js +13556 -0
  32. package/dist/{decimal-D3a0BwVj.js → decimal-M4vjE6Br.js} +1 -1
  33. package/dist/{fuzzy-BW8ZYsDG.js → fuzzy-fD_FTJWH.js} +1 -1
  34. package/dist/helper/number.d.ts +1 -0
  35. package/dist/{init-date-range-M3Q03-Fd.js → init-date-range-DJ1Nl5TB.js} +1 -1
  36. package/dist/{layout-BvUjg6JS.js → layout-kY567oHX.js} +1 -1
  37. package/dist/{rules-DHfAMDW3.js → rules-CVxh5XVG.js} +3 -3
  38. package/dist/stock-estimate-lkaYlz7I.js +90 -0
  39. package/dist/stores/api.d.ts +1 -0
  40. package/dist/stores/helper/generate-backend-urls.d.ts +1 -0
  41. package/dist/stores/inventory.d.ts +64 -0
  42. package/dist/stores/stock-estimate.d.ts +11 -0
  43. package/dist/stores/supplier.d.ts +19 -1
  44. package/dist/style.css +1 -1
  45. package/dist/{supplier-DTiiOLtg.js → supplier-evd71Y1H.js} +3 -3
  46. package/dist/tsconfig.app.tsbuildinfo +1 -1
  47. package/dist/{use-inventory-binding-dialog-B6JO7050.js → use-inventory-binding-dialog-CGuXojFC.js} +2 -2
  48. package/dist/views/ingredients/components/ingredient-form/IngredientForm.vue.d.ts +32 -0
  49. package/dist/views/ingredients/composables/use-ingredient-table.d.ts +16 -0
  50. package/dist/views/receive-request/components/transfer-form/SparkIcon.vue.d.ts +23 -0
  51. package/dist/views/receive-request/components/transfer-form/TransferForm.vue.d.ts +213 -7
  52. package/dist/views/receive-request/composables/use-receive-request-form.d.ts +102 -2
  53. package/dist/views/receive-request/composables/use-receive-request-table.d.ts +306 -6
  54. package/dist/views/stock/components/StockRecalculateDialog.vue.d.ts +9 -0
  55. package/dist/views/stock/components/dialog/AdjustedItemForm.vue.d.ts +32 -0
  56. package/dist/views/stock/type.d.ts +1 -0
  57. package/dist/views/supplier/components/SupplierForm.vue.d.ts +38 -2
  58. package/dist/views/supplier/components/SupplierSupplyItemField.vue.d.ts +45 -0
  59. package/dist/views/supplier/composables/use-supplier-table.d.ts +19 -1
  60. package/dist/{xlsx-BljO4Lx2.js → xlsx-DpBw8KA4.js} +1010 -1010
  61. package/package.json +13 -7
  62. package/dist/BindingsDialog-DvX_DRsO.js +0 -82
  63. package/dist/IngredientsView-2ZKdzsgI.js +0 -739
  64. package/dist/InventoryBindingForm.vue_vue_type_script_setup_true_lang-CnsDmPTe.js +0 -240
  65. package/dist/ReceiveRequestView-DQBqc3GF.js +0 -1298
  66. package/dist/StockView-DLWMp_I5.js +0 -1733
  67. package/dist/SupplierView-CZhM2ie3.js +0 -607
  68. package/dist/app-BzDhmCVx.js +0 -36639
  69. package/dist/components/shell/inventory/binding-ui.test.d.ts +0 -1
  70. package/dist/components/ui-library/FmSpecialChip.vue.d.ts +0 -79
  71. package/dist/date2-C7HiAWQG.js +0 -209
  72. package/dist/dayjs.min-Db57WhI9.js +0 -282
  73. package/dist/id-to-date-ReZIpUDw.js +0 -30
  74. package/dist/index-D46it8Rk.js +0 -12956
@@ -0,0 +1,1483 @@
1
+ import { defineComponent as ke, ref as z, watch as ce, computed as M, resolveComponent as D, openBlock as _, createBlock as Z, withCtx as A, createElementVNode as s, createVNode as u, toDisplayString as W, createElementBlock as F, Fragment as $e, renderList as ot, unref as d, createTextVNode as mo, mergeModels as Bt, reactive as po, useModel as fo, onMounted as vo, createCommentVNode as G, normalizeClass as Je, normalizeStyle as no, h as L, isRef as _o, Teleport as go, mergeProps as Gt } from "vue";
2
+ import { I as it, d as xe, m as Ce, n as yo, e as mt, a as ho, C as ut, u as bo, o as Xe, p as xo } from "./app-DM4Thqjw.js";
3
+ import { i as at } from "./init-date-range-DJ1Nl5TB.js";
4
+ import { u as ro, p as Wt, P as R, a as Co, b as ko, _ as wo, g as Do } from "./TransferDetails.vue_vue_type_script_setup_true_lang-Cmajrg-9.js";
5
+ import { a as B, k as Zt, b as tt, s as dt, t as So, u as Fo, v as Jt, w as Vo, i as Xt, x as Po, q as eo, y as To, j as Uo, f as Ro, c as to } from "./date2-DpU4LDaP.js";
6
+ import { u as Mo, i as Ao, e as $o } from "./stock-estimate-lkaYlz7I.js";
7
+ import { d as ct } from "./dayjs.min-D4Q_pHH9.js";
8
+ import { _ as Eo } from "./SingleColumnLayout.vue_vue_type_script_setup_true_lang-CFjO4TPG.js";
9
+ import { _ as Oo } from "./ChangeLocationComponent.vue_vue_type_script_setup_true_lang-Bss0q2Zt.js";
10
+ import { useDialog as No, useSnackbar as pt, components as le, useProxiedModel as Ho, useBreakpoints as Yo } from "@feedmepos/ui-library";
11
+ import { R as oo, F as Ae } from "./row-action.enum-BwQbURNh.js";
12
+ import { useCoreStore as qo } from "@feedmepos/mf-common";
13
+ import { _ as Io } from "./FmMultiselectDialog.vue_vue_type_script_setup_true_lang-BHcLUkdm.js";
14
+ import { F as ee, _ as io, u as jo } from "./layout-kY567oHX.js";
15
+ import { R as et, B as Lo, M as ao, a as zo } from "./rules-CVxh5XVG.js";
16
+ import { u as uo } from "./supplier-evd71Y1H.js";
17
+ const Qo = { class: "inline-flex rounded-md items-center gap-4 justify-center h-[30px] px-8 py-4 bg-fm-color-neutral-gray-100 cursor-pointer text-fm-color-neutral-gray-400" }, Ko = { class: "fm-typo-en-body-md-600 select-none text-ellipsis overflow-hidden whitespace-nowrap" }, Bo = /* @__PURE__ */ ke({
18
+ __name: "FmDateRangePickerChip",
19
+ props: {
20
+ modelValue: { default: (q) => q.modelValue ?? at() }
21
+ },
22
+ emits: ["update:modelValue"],
23
+ setup(q, { emit: te }) {
24
+ const J = te, k = z(at());
25
+ ce(k, (C) => {
26
+ J("update:modelValue", C);
27
+ });
28
+ const $ = M(() => {
29
+ const { startDate: C, endDate: g } = k.value;
30
+ return !C && !g ? "" : `${C} - ${g}`;
31
+ });
32
+ return (C, g) => {
33
+ const P = D("FmIcon"), I = D("FmDateRangePicker");
34
+ return _(), Z(I, {
35
+ "show-predefined-range": "",
36
+ modelValue: k.value,
37
+ "onUpdate:modelValue": g[0] || (g[0] = (y) => k.value = y),
38
+ "start-label": "",
39
+ "end-label": ""
40
+ }, {
41
+ "trigger-button": A(() => [
42
+ s("div", Qo, [
43
+ u(P, {
44
+ name: "calendar_month",
45
+ size: "sm"
46
+ }),
47
+ s("div", Ko, W($.value), 1)
48
+ ])
49
+ ]),
50
+ _: 1
51
+ }, 8, ["modelValue"]);
52
+ };
53
+ }
54
+ }), Go = {
55
+ width: "24",
56
+ height: "24",
57
+ viewBox: "0 0 24 24",
58
+ fill: "none",
59
+ xmlns: "http://www.w3.org/2000/svg"
60
+ }, Wo = ["fill"], Zo = ["fill"], Jo = ["stroke"], Xo = ["stroke"], ea = /* @__PURE__ */ ke({
61
+ __name: "SparkIcon",
62
+ props: {
63
+ size: {
64
+ type: Number,
65
+ default: 24
66
+ },
67
+ color: {
68
+ type: String,
69
+ default: "#c7c7cc"
70
+ }
71
+ },
72
+ setup(q) {
73
+ return (te, J) => (_(), F("svg", Go, [
74
+ s("path", {
75
+ 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",
76
+ fill: q.color
77
+ }, null, 8, Wo),
78
+ s("path", {
79
+ 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",
80
+ fill: q.color
81
+ }, null, 8, Zo),
82
+ s("path", {
83
+ 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",
84
+ stroke: q.color,
85
+ "stroke-width": "1.5",
86
+ "stroke-linecap": "round",
87
+ "stroke-linejoin": "round"
88
+ }, null, 8, Jo),
89
+ s("path", {
90
+ 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",
91
+ stroke: q.color,
92
+ "stroke-width": "1.5",
93
+ "stroke-linecap": "round",
94
+ "stroke-linejoin": "round"
95
+ }, null, 8, Xo)
96
+ ]));
97
+ }
98
+ }), ta = { class: "flex flex-col gap-8 px-16 xs:px-4 sm:px-4 py-4 items-center" }, oa = { class: "fm-typo-body-md-400 mr-auto xs:w-full" }, aa = { class: "hidden xs:inline" }, sa = {
99
+ key: 0,
100
+ class: "fm-typo-body-sm-700"
101
+ }, la = { class: "xs:hidden" }, na = {
102
+ key: 1,
103
+ class: "fm-typo-body-sm-700 text-fm-color-typo-disabled"
104
+ }, ra = { class: "fm-typo-body-sm-400 text-fm-color-typo-secondary" }, ia = {
105
+ key: 0,
106
+ class: "flex flex-col"
107
+ }, ua = { key: 1 }, so = /* @__PURE__ */ ke({
108
+ __name: "SupplierPriceHistory",
109
+ props: {
110
+ prices: {}
111
+ },
112
+ setup(q) {
113
+ const te = uo();
114
+ function J(k) {
115
+ return te.suppliers.find(($) => $._id === k);
116
+ }
117
+ return (k, $) => {
118
+ const C = D("FmTooltip");
119
+ return _(), F("div", ta, [
120
+ (_(!0), F($e, null, ot(Object.keys(k.prices), (g) => {
121
+ var P, I, y;
122
+ return _(), F("div", {
123
+ key: g,
124
+ class: "flex items-center gap-12 xs:gap-4 xs:flex-wrap w-full"
125
+ }, [
126
+ s("div", oa, [
127
+ s("span", null, W((P = J(g)) == null ? void 0 : P.name), 1),
128
+ s("span", aa, " (per " + W((y = (I = k.prices[g].find((f) => f.unit)) == null ? void 0 : I.unit) == null ? void 0 : y.abbrev) + ") ", 1)
129
+ ]),
130
+ (_(!0), F($e, null, ot(k.prices[g], (f) => (_(), F("div", {
131
+ key: f.date,
132
+ class: "flex flex-col w-120 xs:w-72 xs:flex-1 text-ellipsis cursor-pointer"
133
+ }, [
134
+ u(C, { "z-index": 50 }, {
135
+ content: A(() => [
136
+ f.totalUnits && f.unit && f.pricePerUnit ? (_(), F("div", ia, [
137
+ s("div", null, " Total units: " + W(d(B)(f.totalUnits)) + " " + W(f.unit.abbrev), 1),
138
+ s("div", null, " Total bought: " + W(d(Zt)({
139
+ ...d(tt)(f.pricePerUnit, f.totalUnits),
140
+ currency: f.pricePerUnit.currency
141
+ })), 1)
142
+ ])) : (_(), F("div", ua, "No data"))
143
+ ]),
144
+ default: A(() => [
145
+ s("div", null, [
146
+ f.pricePerUnit && f.unit ? (_(), F("div", sa, [
147
+ mo(W(d(Zt)(f.pricePerUnit)) + " ", 1),
148
+ s("span", la, "/ " + W(f.unit.abbrev), 1)
149
+ ])) : (_(), F("div", na, "No data")),
150
+ s("div", ra, W(d(dt)(new Date(f.date))), 1)
151
+ ])
152
+ ]),
153
+ _: 2
154
+ }, 1024)
155
+ ]))), 128))
156
+ ]);
157
+ }), 128))
158
+ ]);
159
+ };
160
+ }
161
+ }), ca = { class: "flex flex-col w-full gap-40" }, da = { class: "flex flex-col gap-8" }, ma = /* @__PURE__ */ s("div", { class: "fm-typo-en-title-sm-800" }, "Transfer details", -1), pa = { class: "flex items-center gap-8" }, fa = /* @__PURE__ */ s("div", null, null, -1), va = { class: "flex flex-col gap-4" }, _a = {
162
+ key: 0,
163
+ class: "p-16 border border-fm-color-neutral-gray-300 fm-corner-radius-md flex flex-col"
164
+ }, ga = { class: "flex xs:flex-col sm:flex-col" }, ya = /* @__PURE__ */ s("div", { class: "xs:hidden sm:hidden h-48 lg:w-16 md:w-16" }, null, -1), ha = {
165
+ key: 0,
166
+ class: "flex-1 flex gap-8 h-48 xs:flex-col xs:pt-16 sm:flex-col sm:pt-16"
167
+ }, ba = { class: "flex-1" }, xa = { class: "flex-1" }, Ca = {
168
+ key: 1,
169
+ class: "flex items-center gap-4"
170
+ }, ka = /* @__PURE__ */ s("span", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary translate-y-[1px]" }, " Cannot backdate without an initial closing made to the system. ", -1), wa = { class: "flex flex-col gap-8" }, Da = { class: "flex items-center xs:flex-col xs:gap-4" }, Sa = /* @__PURE__ */ s("div", { class: "xs:w-full flex-1 fm-typo-en-title-sm-800" }, "Transfer items", -1), Fa = {
171
+ key: 0,
172
+ class: "xs:w-full"
173
+ }, Va = { class: "flex gap-2" }, Pa = ["disabled"], Ta = { class: "w-[343px] px-24 py-16 rounded-lg shadow-light-300 flex flex-col gap-[20px]" }, Ua = { class: "flex" }, Ra = { class: "flex flex-col gap-4" }, Ma = { class: "flex flex-row items-center gap-1 w-full" }, Aa = /* @__PURE__ */ s("p", { class: "fm-typo-en-title-sm-800" }, "Forecast stock", -1), $a = /* @__PURE__ */ s("p", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " Selecting forecast stock will replace your current item selection. ", -1), Ea = { class: "flex gap-1" }, Oa = /* @__PURE__ */ s("div", { class: "grow" }, null, -1), Na = { key: 0 }, Ha = { class: "fm-typo-body-md-400 line-clamp-2 w-full" }, Ya = { key: 0 }, qa = ["colspan"], Ia = { class: "flex flex-col gap-4" }, ja = { class: "flex items-center" }, La = { class: "flex-1" }, za = { class: "grid grid-cols-2 gap-4" }, Qa = { class: "flex flex-col" }, Ka = { class: "flex flex-col" }, Ba = { class: "flex flex-col" }, Ga = { class: "flex flex-col" }, Wa = {
174
+ key: 0,
175
+ class: "flex flex-col col-span-2",
176
+ "data-cy": "fm-table-list-view-cost-label"
177
+ }, Za = /* @__PURE__ */ ke({
178
+ __name: "TransferForm",
179
+ props: /* @__PURE__ */ Bt({
180
+ modelValue: {},
181
+ disabled: { type: Boolean },
182
+ suppliers: { default: () => [] },
183
+ skus: { default: () => [] },
184
+ lastClosingDate: {}
185
+ }, {
186
+ modelValue: {
187
+ default: {
188
+ ref: "",
189
+ supplier: null
190
+ }
191
+ },
192
+ modelModifiers: {}
193
+ }),
194
+ emits: /* @__PURE__ */ Bt(["validation-success"], ["update:modelValue"]),
195
+ setup(q, { expose: te, emit: J }) {
196
+ const k = mt(), $ = Mo(), C = qo(), g = ro(), P = ho(), I = po({}), y = q, f = M(() => {
197
+ function e(o) {
198
+ return Object.prototype.hasOwnProperty.call(o, "_rev") && Object.prototype.hasOwnProperty.call(o, "status");
199
+ }
200
+ const t = y.modelValue;
201
+ return !e(t) || t.status === "DRAFT";
202
+ }), oe = M(() => {
203
+ var o;
204
+ if (f.value)
205
+ return !0;
206
+ const e = y.lastClosingDate, t = (o = y.modelValue) != null && o._id ? Wt(y.modelValue._id) : null;
207
+ return !e || !t ? !1 : t.getTime() > e.getTime();
208
+ }), ae = J, i = fo(q, "modelValue"), _e = M({
209
+ get() {
210
+ var e;
211
+ return ((e = i.value) == null ? void 0 : e.remark) ?? "";
212
+ },
213
+ set(e) {
214
+ i.value.remark = e;
215
+ }
216
+ });
217
+ ce([() => y.suppliers], () => {
218
+ if (b.value === R.PURCHASE) {
219
+ i.value.supplier = y.suppliers[0];
220
+ return;
221
+ }
222
+ });
223
+ const T = M(() => y.disabled), U = M(() => i.value.items ?? []), O = (e) => {
224
+ const { name: t, address: o, regNo: l, phoneNo: a } = e.doc.profile;
225
+ return {
226
+ _id: e.doc._id,
227
+ internal: e.type === it.restaurant ? Ce.enum.restaurant : Ce.enum.warehouse,
228
+ name: t,
229
+ registrationNumber: l,
230
+ address: o,
231
+ contactName: t,
232
+ phoneNumber: a,
233
+ disabled: !e.acceptRequest || e.dbName === k.currentLocation.dbName
234
+ };
235
+ }, Q = [
236
+ {
237
+ label: "Purchase",
238
+ value: R.PURCHASE
239
+ },
240
+ {
241
+ label: "Transfer",
242
+ value: R.TRANSFER
243
+ }
244
+ ], b = z(R.PURCHASE), m = M(() => {
245
+ var t;
246
+ const e = ((t = k._currentLocation) == null ? void 0 : t.type) === it.warehouse;
247
+ return k.locations.filter((o) => {
248
+ var a;
249
+ return !(o.dbName === ((a = k._currentLocation) == null ? void 0 : a.dbName)) && (!e || o.type === it.warehouse) && o.acceptRequest;
250
+ });
251
+ }), c = M(() => b.value === R.PURCHASE ? y.suppliers.map((e) => ({
252
+ label: e.name,
253
+ value: e._id,
254
+ disabled: !1
255
+ })) : m.value.map(O).map((e) => ({
256
+ label: e.disabled ? `${e.name} (Upgrade POS)` : e.name,
257
+ value: e._id,
258
+ disabled: e.disabled
259
+ }))), S = M({
260
+ get() {
261
+ var e;
262
+ return ((e = i.value.supplier) == null ? void 0 : e._id) ?? null;
263
+ },
264
+ set(e) {
265
+ if (b.value === R.PURCHASE) {
266
+ i.value.supplier = y.suppliers.find((o) => o._id === e) ?? null, i.value.items && (i.value.items = i.value.items.map((o) => ({
267
+ ...o,
268
+ totalCost: H(o)
269
+ })));
270
+ return;
271
+ }
272
+ const t = k.locations.find((o) => o.doc._id === e);
273
+ t ? i.value.supplier = O(t) : i.value.supplier = null;
274
+ }
275
+ });
276
+ function X(e) {
277
+ switch (e) {
278
+ case ut.MY:
279
+ return "MYR";
280
+ case ut.SG:
281
+ return "SGD";
282
+ case ut.ID:
283
+ return "IDR";
284
+ default:
285
+ return "MYR";
286
+ }
287
+ }
288
+ function H(e) {
289
+ var x, Y, ne, V, K, w, N, me, E, be;
290
+ if (I[e.sku._id])
291
+ return e.totalCost;
292
+ const t = e.measurement, l = ((K = (V = (ne = (Y = (x = y.modelValue) == null ? void 0 : x.supplier) == null ? void 0 : Y.supplyItems) == null ? void 0 : ne.find(
293
+ (Te) => Te.skuId === e.sku._id
294
+ )) == null ? void 0 : V.defaultCost) == null ? void 0 : K.costPerUnit) ?? ((w = e.sku.defaultCost) == null ? void 0 : w.costPerUnit), a = l ? (N = e.sku.defaultCost) != null && N.measurement ? +B(l) / +B((me = e.sku.defaultCost) == null ? void 0 : me.measurement.conversion) : +B(l) : void 0, r = a ? t ? a * +B(t.conversion) : a : void 0, n = r ? +B(e.quantity) * r : void 0;
295
+ return e.totalCost ?? n ? {
296
+ ...So(n ?? 0, 2),
297
+ currency: X(((E = C.currentCountry) == null ? void 0 : E.value) ?? xe)
298
+ } : {
299
+ amount: 1,
300
+ precision: 0,
301
+ currency: X(((be = C.currentCountry) == null ? void 0 : be.value) ?? xe)
302
+ };
303
+ }
304
+ ce([() => b.value], ([e]) => {
305
+ var t;
306
+ S.value = ((t = c.value.find((o) => !o.disabled)) == null ? void 0 : t.value) ?? null, e === R.PURCHASE && P.enableTotalCost && (i.value.items = i.value.items.map((o) => {
307
+ const l = H(o);
308
+ return {
309
+ ...o,
310
+ totalCost: l
311
+ };
312
+ }));
313
+ }), ce([() => y.modelValue], ([e]) => {
314
+ var t, o, l;
315
+ ((t = e == null ? void 0 : e.supplier) == null ? void 0 : t.internal) === Ce.enum.restaurant || ((o = e == null ? void 0 : e.supplier) == null ? void 0 : o.internal) === Ce.enum.warehouse ? b.value = R.TRANSFER : b.value = R.PURCHASE, S.value = ((l = c.value.find((a) => {
316
+ var r, n;
317
+ return a.value === ((n = (r = y.modelValue) == null ? void 0 : r.supplier) == null ? void 0 : n._id);
318
+ })) == null ? void 0 : l.value) ?? null;
319
+ }), vo(() => {
320
+ var e, t, o, l, a, r, n;
321
+ ((t = (e = y.modelValue) == null ? void 0 : e.supplier) == null ? void 0 : t.internal) === Ce.enum.restaurant || ((l = (o = y.modelValue) == null ? void 0 : o.supplier) == null ? void 0 : l.internal) === Ce.enum.warehouse ? b.value = R.TRANSFER : b.value = R.PURCHASE, S.value = (a = y.modelValue) != null && a.supplier ? ((r = c.value.find((p) => {
322
+ var x, Y;
323
+ return p.value === ((Y = (x = y.modelValue) == null ? void 0 : x.supplier) == null ? void 0 : Y._id);
324
+ })) == null ? void 0 : r.value) ?? null : ((n = c.value.find((p) => !p.disabled)) == null ? void 0 : n.value) ?? null;
325
+ });
326
+ const Ee = No(), re = z(7), ie = z(!1), we = pt();
327
+ async function Oe() {
328
+ ie.value = !1, await $.readPurchaseOrder(re.value);
329
+ const e = {
330
+ ...i.value
331
+ }, t = [];
332
+ if ($.purchaseOrderForecast.skus.length <= 0) {
333
+ we.open({ message: "There is no forecast at the moment.", type: "info" });
334
+ return;
335
+ }
336
+ e.items = $.purchaseOrderForecast.skus.reduce((o, l) => {
337
+ const a = y.skus.find((p) => p._id === l.id);
338
+ if (o.find((p) => p.sku._id === l.id) || !a)
339
+ return o;
340
+ const n = {
341
+ sku: a,
342
+ code: a.code,
343
+ name: a.name,
344
+ quantity: {
345
+ amount: l.amount,
346
+ precision: 0
347
+ }
348
+ };
349
+ return o.push(n), o;
350
+ }, t), i.value = e;
351
+ }
352
+ function Ne() {
353
+ const e = y.skus.map((o) => ({
354
+ label: o.name,
355
+ sublabel: o.code,
356
+ value: o
357
+ })), t = e.filter((o) => {
358
+ var l;
359
+ return (l = i.value.items) == null ? void 0 : l.find((a) => a.sku._id === o.value._id);
360
+ }).map((o) => o.value);
361
+ Ee.open({
362
+ title: "Select item",
363
+ closeButton: !0,
364
+ contentComponent: Io,
365
+ contentComponentProps: {
366
+ modelValue: t,
367
+ items: e
368
+ },
369
+ primaryActions: {
370
+ text: "Confirm",
371
+ close: !0
372
+ },
373
+ secondaryActions: {
374
+ text: "Close",
375
+ close: !0,
376
+ variant: "tertiary"
377
+ }
378
+ }).onPrimary((o) => {
379
+ const l = {
380
+ ...i.value
381
+ }, a = l.items ?? [], r = o.map((n) => {
382
+ const p = a.find((Y) => Y.sku._id === n._id);
383
+ if (p)
384
+ return p;
385
+ const x = {
386
+ sku: n,
387
+ code: n.code,
388
+ name: n.name,
389
+ quantity: {
390
+ amount: 1,
391
+ precision: 0
392
+ }
393
+ };
394
+ return b.value === R.PURCHASE && P.enableTotalCost && (x.totalCost = H(x)), x;
395
+ });
396
+ r.sort((n, p) => n.sku.code.localeCompare(p.sku.code)), l.items = r, i.value = l;
397
+ });
398
+ }
399
+ function ge(e, t) {
400
+ var o;
401
+ if (e === oo.Delete) {
402
+ const l = ((o = i.value) == null ? void 0 : o.items) ?? [];
403
+ i.value.items = l.filter((a) => a.sku._id !== t);
404
+ return;
405
+ }
406
+ }
407
+ function De(e) {
408
+ var r, n;
409
+ const t = ((r = i.value) == null ? void 0 : r.items) ?? [], o = (n = t == null ? void 0 : t.find((p) => p.sku._id === e)) == null ? void 0 : n.sku;
410
+ if (!o)
411
+ return [];
412
+ const l = o.unit.measurements ?? [];
413
+ return [
414
+ {
415
+ label: o.unit.abbrev,
416
+ value: null
417
+ },
418
+ ...l.map((p) => ({
419
+ label: p.abbrev,
420
+ value: p
421
+ }))
422
+ ];
423
+ }
424
+ function Se(e) {
425
+ var r;
426
+ const o = (((r = i.value) == null ? void 0 : r.items) ?? []).find((n) => n.sku._id === e), l = o == null ? void 0 : o.sku;
427
+ if (!o || !l) return null;
428
+ const a = De(e);
429
+ return o.measurement ? a.find((n) => {
430
+ var p, x;
431
+ return ((p = n.value) == null ? void 0 : p.id) === ((x = o.measurement) == null ? void 0 : x.id);
432
+ }) : a.find((n) => n.value === null);
433
+ }
434
+ function He(e, t) {
435
+ var l;
436
+ const o = ((l = i.value) == null ? void 0 : l.items) ?? [];
437
+ i.value.items = o.map((a) => a.sku._id !== e ? a : t ? (a.measurement = t, P.enableTotalCost && (a.totalCost = H(a)), a) : (delete a.measurement, a));
438
+ }
439
+ function Ye(e, t) {
440
+ const o = i.value, l = o.items ?? [];
441
+ o.items = l.map((a) => (a.sku._id !== e || (a.code = t), a));
442
+ }
443
+ function ye(e, t) {
444
+ const o = i.value, l = o.items ?? [];
445
+ o.items = l.map((a) => (a.sku._id !== e || (a.name = t), a));
446
+ }
447
+ function qe(e, t) {
448
+ const o = +t, l = i.value, a = l.items ?? [];
449
+ t.length > 0 && isFinite(o) ? l.items = a.map((r) => (r.sku._id !== e || (r.quantity = to(o), P.enableTotalCost && (r.totalCost = H(r))), r)) : l.items = a.map((r) => (r.sku._id !== e || (r.quantity = { amount: 0, precision: 0 }, P.enableTotalCost && (r.totalCost = H(r))), r));
450
+ }
451
+ function Ie(e, t) {
452
+ const o = +t, l = i.value, a = l.items ?? [];
453
+ t.length > 0 && isFinite(o) ? l.items = a.map((r) => {
454
+ var n;
455
+ return r.sku._id !== e || (r.totalCost = {
456
+ ...to(o),
457
+ currency: X(((n = C.currentCountry) == null ? void 0 : n.value) ?? xe)
458
+ }), r;
459
+ }) : l.items = a.map((r) => {
460
+ var n;
461
+ return r.sku._id !== e || (r.totalCost = {
462
+ amount: 0,
463
+ precision: 0,
464
+ currency: X(((n = C.currentCountry) == null ? void 0 : n.value) ?? xe)
465
+ }), r;
466
+ });
467
+ }
468
+ const Fe = [
469
+ {
470
+ header: "Code",
471
+ accessorKey: "code",
472
+ size: 96,
473
+ cell(e) {
474
+ const t = e.row.original;
475
+ return f.value ? L(le.FmTextField, {
476
+ modelValue: t.code,
477
+ "onUpdate:modelValue": (o) => {
478
+ Ye(t.sku._id, o);
479
+ },
480
+ rules: [et()],
481
+ labelMark: "required"
482
+ }) : t.code;
483
+ },
484
+ enableSorting: !1
485
+ },
486
+ {
487
+ id: "Name",
488
+ header: "Name",
489
+ size: "auto",
490
+ cell(e) {
491
+ const t = e.row.original;
492
+ return f.value ? L(le.FmTextField, {
493
+ modelValue: t.name,
494
+ "onUpdate:modelValue": (o) => {
495
+ ye(t.sku._id, o);
496
+ },
497
+ rules: [et()],
498
+ labelMark: "required"
499
+ }) : t.name;
500
+ },
501
+ enableSorting: !1
502
+ },
503
+ {
504
+ id: "Amount",
505
+ header: "Amount",
506
+ size: 120,
507
+ cell(e) {
508
+ var l, a, r;
509
+ const t = e.row.original, o = (r = (a = (l = i.value) == null ? void 0 : l.items) == null ? void 0 : a.find) == null ? void 0 : r.call(a, (n) => n.sku._id === t.sku._id);
510
+ return f.value ? L(le.FmTextField, {
511
+ style: {
512
+ flex: "1 1 0%"
513
+ },
514
+ modelValue: +B((o == null ? void 0 : o.quantity) ?? { amount: 1, precision: 0 }),
515
+ "onUpdate:modelValue": (n) => {
516
+ qe(t.sku._id, n);
517
+ },
518
+ rules: [ao(o.sku.unit, o.measurement)]
519
+ }) : B((o == null ? void 0 : o.quantity) ?? { amount: 1, precision: 0 });
520
+ },
521
+ enableSorting: !1
522
+ },
523
+ {
524
+ id: "Unit",
525
+ header: "Unit",
526
+ size: 120,
527
+ cell(e) {
528
+ var o, l;
529
+ const t = e.row.original;
530
+ return f.value ? L(le.FmSelect, {
531
+ style: {
532
+ flex: "1 1 0%"
533
+ },
534
+ items: De(t.sku._id),
535
+ modelValue: (o = Se(t.sku._id)) == null ? void 0 : o.value,
536
+ "onUpdate:modelValue": (a) => He(t.sku._id, a)
537
+ }) : (l = Se(t.sku._id)) == null ? void 0 : l.label;
538
+ },
539
+ enableSorting: !1
540
+ },
541
+ {
542
+ id: "Cost",
543
+ header: () => {
544
+ var e, t;
545
+ return `Total cost (${X(((e = C.currentCountry) == null ? void 0 : e.value) ?? xe) === "MYR" ? "RM" : X(((t = C.currentCountry) == null ? void 0 : t.value) ?? xe)})`;
546
+ },
547
+ size: 180,
548
+ cell(e) {
549
+ var l, a, r;
550
+ const t = e.row.original, o = (r = (a = (l = i.value) == null ? void 0 : l.items) == null ? void 0 : a.find) == null ? void 0 : r.call(a, (n) => n.sku._id === t.sku._id);
551
+ return oe.value ? I[(o == null ? void 0 : o.sku._id) ?? ""] ? L(
552
+ le.FmTextField,
553
+ {
554
+ style: {
555
+ flex: "1 1 0%"
556
+ },
557
+ modelValue: +B((o == null ? void 0 : o.totalCost) ?? { amount: 1, precision: 0 }),
558
+ "onUpdate:modelValue": (n) => {
559
+ Ie(t.sku._id, n);
560
+ },
561
+ rules: [zo(0), ao(2)]
562
+ },
563
+ {
564
+ append: L(le.FmButton, {
565
+ prependIcon: "close",
566
+ variant: "tertiary",
567
+ onClick: () => {
568
+ var p;
569
+ I[(o == null ? void 0 : o.sku._id) ?? ""] = !1;
570
+ const n = ((p = i.value) == null ? void 0 : p.items) ?? [];
571
+ i.value.items = n.map((x) => (P.enableTotalCost && (x.totalCost = H(x)), x));
572
+ }
573
+ })
574
+ }
575
+ ) : L(
576
+ "div",
577
+ {
578
+ class: "flex items-center gap-4"
579
+ },
580
+ [
581
+ L(le.FmButton, {
582
+ prependIcon: "edit",
583
+ variant: "tertiary",
584
+ onClick: () => {
585
+ I[(o == null ? void 0 : o.sku._id) ?? ""] = !0;
586
+ }
587
+ }),
588
+ L(
589
+ "div",
590
+ {
591
+ class: "text-fm-color-typo-primary fm-typo-en-body-lg-400"
592
+ },
593
+ B((o == null ? void 0 : o.totalCost) ?? { amount: 1, precision: 0 })
594
+ )
595
+ ]
596
+ ) : L(
597
+ "div",
598
+ {
599
+ style: {
600
+ display: "flex",
601
+ alignItems: "center",
602
+ gap: "4px"
603
+ }
604
+ },
605
+ [
606
+ L(
607
+ "div",
608
+ o != null && o.totalCost ? +B((o == null ? void 0 : o.totalCost) ?? { amount: 1, precision: 0 }) : "0.00"
609
+ ),
610
+ L(
611
+ le.FmTooltip,
612
+ {
613
+ content: y.lastClosingDate ? `Last closing was already done at ${Ro(y.lastClosingDate)}. You may no longer change total cost of this purchase order.` : "You may only change the total cost if you have done a closing with recent costing feature.",
614
+ placement: "left"
615
+ },
616
+ [
617
+ L(le.FmIcon, {
618
+ name: "info",
619
+ size: "sm",
620
+ color: "typo-secondary"
621
+ })
622
+ ]
623
+ )
624
+ ]
625
+ );
626
+ },
627
+ enableSorting: !1
628
+ },
629
+ {
630
+ id: "Delete",
631
+ header: "",
632
+ cell(e) {
633
+ return L(le.FmButton, {
634
+ class: "delete-button",
635
+ type: "button",
636
+ icon: "delete",
637
+ variant: "tertiary",
638
+ size: "md",
639
+ onClick: () => {
640
+ ge(oo.Delete, e.row.original.sku._id);
641
+ }
642
+ });
643
+ },
644
+ enableSorting: !1,
645
+ size: 40,
646
+ meta: {
647
+ cellClass: "",
648
+ headerClass: ""
649
+ }
650
+ }
651
+ ], Ve = M(
652
+ () => f.value ? Fe : Fe.filter((e) => e.id !== "Delete")
653
+ ), he = M(() => b.value === R.PURCHASE && P.enableTotalCost ? Ve.value : Ve.value.filter((e) => e.id !== "Cost")), de = z();
654
+ te({
655
+ validateInputs: () => {
656
+ var e, t;
657
+ (t = (e = de.value) == null ? void 0 : e.validateInputs) == null || t.call(e);
658
+ },
659
+ resetInputsValidation: () => {
660
+ var e, t;
661
+ (t = (e = de.value) == null ? void 0 : e.resetInputsValidation) == null || t.call(e);
662
+ },
663
+ resetInputs: () => {
664
+ var e, t;
665
+ (t = (e = de.value) == null ? void 0 : e.resetInputs) == null || t.call(e);
666
+ }
667
+ });
668
+ const ue = z(!1);
669
+ ce(ue, (e) => {
670
+ e && (je.value = !0, co().finally(() => {
671
+ je.value = !1;
672
+ }));
673
+ });
674
+ async function co() {
675
+ try {
676
+ const { startDate: e, endDate: t } = Fo(3), a = (await g.getPurchaseOrders({ start: e, end: t })).filter(
677
+ (n) => {
678
+ var p, x;
679
+ return n.status === yo.enum.COMPLETE && ((p = n.supplier) == null ? void 0 : p.internal) !== "warehouse" && ((x = n.supplier) == null ? void 0 : x.internal) !== "restaurant";
680
+ }
681
+ ).reduce((n, p) => {
682
+ var ne;
683
+ const x = Wt(p._id), Y = p.supplier._id;
684
+ for (const V of p.items) {
685
+ if (!V.totalCost) continue;
686
+ const K = n[V.sku._id] ?? {}, w = K[Y] ?? [], N = V.measurement ? tt(V.quantity, V.measurement.conversion) : V.quantity;
687
+ w.push({
688
+ date: ((ne = x == null ? void 0 : x.toISOString) == null ? void 0 : ne.call(x)) ?? "",
689
+ pricePerUnit: {
690
+ ...Jt(V.totalCost, N),
691
+ currency: V.totalCost.currency
692
+ },
693
+ totalUnits: N,
694
+ unit: V.sku.unit
695
+ }), K[Y] = w, n[V.sku._id] = K;
696
+ }
697
+ return n;
698
+ }, {}), r = Object.keys(a).reduce((n, p) => {
699
+ const x = Object.keys(a[p]);
700
+ for (const Y of x) {
701
+ const V = a[p][Y].reduce(
702
+ (w, N) => {
703
+ const me = Vo(new Date(N.date)), E = dt(me);
704
+ if (w[E]) {
705
+ const be = tt(
706
+ w[E].pricePerUnit,
707
+ w[E].totalUnits
708
+ ), Te = tt(
709
+ N.pricePerUnit,
710
+ N.totalUnits
711
+ ), rt = Xt(
712
+ be,
713
+ Te
714
+ ), pe = Xt(w[E].totalUnits, N.totalUnits), ze = {
715
+ ...Jt(rt, pe),
716
+ currency: N.pricePerUnit.currency
717
+ };
718
+ w[E].totalUnits = pe, w[E].pricePerUnit = ze;
719
+ } else
720
+ w[E] = N;
721
+ return w[E].date = me.toISOString(), w;
722
+ },
723
+ {}
724
+ );
725
+ n[p] ?? (n[p] = {});
726
+ const K = Po(3).map((w) => dt(w));
727
+ n[p][Y] = K.map((w) => V[w] ? V[w] : {
728
+ date: w
729
+ }), Object.values(V).sort((w, N) => N.date.localeCompare(w.date)).slice(0, 3).reverse();
730
+ }
731
+ return n;
732
+ }, {});
733
+ Pe.value = r;
734
+ } catch {
735
+ we.open({
736
+ title: "Something went wrong",
737
+ message: "Cannot retrieve supplier purchase history. Please try again."
738
+ }), ue.value = !1;
739
+ }
740
+ }
741
+ const je = z(!1), Pe = z({});
742
+ function Le(e) {
743
+ return e.column.columnDef.meta;
744
+ }
745
+ const j = M({
746
+ get() {
747
+ var e, t;
748
+ return (e = y.modelValue) != null && e.effectiveAt ? new Date((t = y.modelValue) == null ? void 0 : t.effectiveAt) : null;
749
+ },
750
+ set(e) {
751
+ i.value.effectiveAt = (e == null ? void 0 : e.toISOString()) ?? null;
752
+ }
753
+ }), st = M({
754
+ get() {
755
+ return !!j.value;
756
+ },
757
+ set(e) {
758
+ e ? j.value = /* @__PURE__ */ new Date() : j.value = null;
759
+ }
760
+ }), lt = M({
761
+ get() {
762
+ return j.value === null ? "" : eo(j.value);
763
+ },
764
+ set(e) {
765
+ e ? j.value = /* @__PURE__ */ new Date(`${e} ${nt.value}`) : j.value = null;
766
+ }
767
+ }), nt = M({
768
+ get() {
769
+ return j.value === null ? "" : To(j.value);
770
+ },
771
+ set(e) {
772
+ e ? j.value = /* @__PURE__ */ new Date(`${lt.value} ${e}`) : j.value = null;
773
+ }
774
+ }), ft = M(() => {
775
+ var e;
776
+ return (e = k._currentLocation) == null ? void 0 : e.dbName.startsWith("restaurant");
777
+ });
778
+ return (e, t) => {
779
+ const o = D("FmChip"), l = D("FmSelect"), a = D("FmMenuItem"), r = D("FmTextField"), n = D("FmTextarea"), p = D("FmSwitch"), x = D("FmDatePicker"), Y = D("FmTimePicker"), ne = D("FmFormGroup"), V = D("FmIcon"), K = D("FmButton"), w = D("FmCard"), N = D("FmStepperField"), me = D("FmPopover"), E = D("FmLabel"), be = D("FmSpacer"), Te = D("FmTable"), rt = D("FmForm");
780
+ return _(), Z(rt, {
781
+ ref_key: "formRef",
782
+ ref: de,
783
+ onReset: t[14] || (t[14] = (pe) => b.value = d(R).PURCHASE),
784
+ onValidationSuccess: t[15] || (t[15] = (pe) => ae("validation-success")),
785
+ disabled: T.value
786
+ }, {
787
+ default: A(() => {
788
+ var pe, ze, vt, _t;
789
+ return [
790
+ s("div", ca, [
791
+ s("div", da, [
792
+ ma,
793
+ s("div", pa, [
794
+ u(o, {
795
+ label: d(k).currentLocation.name,
796
+ icon: "storefront",
797
+ compact: ""
798
+ }, null, 8, ["label"]),
799
+ (ze = (pe = d(C).currentRestaurant) == null ? void 0 : pe.value) != null && ze.posVersion ? (_(), Z(o, {
800
+ key: 0,
801
+ label: `POS v${(_t = (vt = d(C).currentRestaurant) == null ? void 0 : vt.value) == null ? void 0 : _t.posVersion}`,
802
+ icon: "point_of_sale",
803
+ compact: ""
804
+ }, null, 8, ["label"])) : G("", !0),
805
+ e.lastClosingDate ? (_(), Z(o, {
806
+ key: 1,
807
+ label: `Last closing: ${d(eo)(e.lastClosingDate)} ${d(Uo)(e.lastClosingDate)}`,
808
+ icon: "calendar_month",
809
+ compact: ""
810
+ }, null, 8, ["label"])) : G("", !0)
811
+ ]),
812
+ fa,
813
+ s("div", va, [
814
+ u(l, {
815
+ items: Q,
816
+ rules: [d(et)()],
817
+ "label-mark": "required",
818
+ label: "Transfer type",
819
+ modelValue: b.value,
820
+ "onUpdate:modelValue": t[0] || (t[0] = (v) => b.value = v),
821
+ disabled: T.value || !f.value,
822
+ "data-cy": "fm-select-transaction-type"
823
+ }, null, 8, ["rules", "modelValue", "disabled"]),
824
+ u(l, {
825
+ label: b.value === d(R).PURCHASE ? "Supplier" : "Transfer From",
826
+ items: c.value,
827
+ modelValue: S.value,
828
+ "onUpdate:modelValue": t[1] || (t[1] = (v) => S.value = v),
829
+ disabled: T.value || !f.value,
830
+ rules: [d(et)()],
831
+ "label-mark": "required"
832
+ }, {
833
+ "menu-wrapper": A(({ handleItemChange: v }) => [
834
+ (_(!0), F($e, null, ot(c.value, (h) => (_(), Z(a, {
835
+ key: h.value,
836
+ "model-value": h.value === S.value,
837
+ disabled: h.disabled,
838
+ label: h.label,
839
+ "onUpdate:modelValue": (fe) => v(fe, h)
840
+ }, null, 8, ["model-value", "disabled", "label", "onUpdate:modelValue"]))), 128))
841
+ ]),
842
+ _: 1
843
+ }, 8, ["label", "items", "modelValue", "disabled", "rules"]),
844
+ u(r, {
845
+ label: "Reference",
846
+ modelValue: i.value.ref,
847
+ "onUpdate:modelValue": t[2] || (t[2] = (v) => i.value.ref = v),
848
+ "label-mark": "optional",
849
+ disabled: T.value || !f.value
850
+ }, null, 8, ["modelValue", "disabled"]),
851
+ u(n, {
852
+ label: "Remark",
853
+ modelValue: _e.value,
854
+ "onUpdate:modelValue": t[3] || (t[3] = (v) => _e.value = v),
855
+ "label-mark": "optional",
856
+ "max-length": 240,
857
+ disabled: T.value || !f.value,
858
+ "show-word-count": ""
859
+ }, null, 8, ["modelValue", "disabled"]),
860
+ d(P).enableBackdatePo ? (_(), F("div", _a, [
861
+ s("div", ga, [
862
+ u(p, {
863
+ modelValue: st.value,
864
+ "onUpdate:modelValue": t[4] || (t[4] = (v) => st.value = v),
865
+ label: "Backdate transfer",
866
+ sublabel: "Apply transfer to older date",
867
+ "label-placement": "right",
868
+ disabled: T.value || !f.value || ft.value && !e.lastClosingDate
869
+ }, null, 8, ["modelValue", "disabled"]),
870
+ ya,
871
+ st.value ? (_(), F("div", ha, [
872
+ s("div", ba, [
873
+ u(x, {
874
+ modelValue: lt.value,
875
+ "onUpdate:modelValue": t[5] || (t[5] = (v) => lt.value = v)
876
+ }, null, 8, ["modelValue"])
877
+ ]),
878
+ s("div", xa, [
879
+ u(Y, {
880
+ modelValue: nt.value,
881
+ "onUpdate:modelValue": t[6] || (t[6] = (v) => nt.value = v)
882
+ }, null, 8, ["modelValue"])
883
+ ])
884
+ ])) : G("", !0)
885
+ ]),
886
+ j.value ? (_(), Z(ne, {
887
+ key: 0,
888
+ modelValue: j.value,
889
+ "onUpdate:modelValue": t[7] || (t[7] = (v) => j.value = v),
890
+ rules: [d(Lo)(new Date(e.lastClosingDate), /* @__PURE__ */ new Date())]
891
+ }, null, 8, ["modelValue", "rules"])) : G("", !0),
892
+ ft.value && !e.lastClosingDate ? (_(), F("div", Ca, [
893
+ u(V, {
894
+ name: "error",
895
+ size: "sm",
896
+ class: "text-fm-color-typo-warning"
897
+ }),
898
+ ka
899
+ ])) : G("", !0)
900
+ ])) : G("", !0)
901
+ ])
902
+ ]),
903
+ s("div", wa, [
904
+ u(ne, {
905
+ "model-value": i.value.items,
906
+ rules: [
907
+ function(h) {
908
+ return h && h.length > 0 || "Must have at least one item!";
909
+ }
910
+ ]
911
+ }, {
912
+ default: A(() => {
913
+ var v;
914
+ return [
915
+ s("div", Da, [
916
+ Sa,
917
+ b.value === d(R).PURCHASE && f.value && d(P).enableTotalCost ? (_(), F("div", Fa, [
918
+ u(p, {
919
+ label: je.value ? "Fetching data..." : "Compare price history",
920
+ "prepend-icon": "compare_arrows",
921
+ "label-placement": "right",
922
+ "model-value": ue.value,
923
+ "onUpdate:modelValue": t[8] || (t[8] = (h) => ue.value = h),
924
+ disabled: je.value || !((v = i.value) != null && v.items) || i.value.items.length === 0
925
+ }, null, 8, ["label", "model-value", "disabled"])
926
+ ])) : G("", !0)
927
+ ])
928
+ ];
929
+ }),
930
+ _: 1
931
+ }, 8, ["model-value", "rules"]),
932
+ s("div", Va, [
933
+ u(K, {
934
+ disabled: T.value || !f.value,
935
+ label: "Add Item",
936
+ "prepend-icon": "add",
937
+ variant: "plain",
938
+ class: "border-2 rounded-lg border-fm-color-primary",
939
+ onClick: t[9] || (t[9] = (v) => Ne()),
940
+ size: "md"
941
+ }, null, 8, ["disabled"]),
942
+ u(me, {
943
+ class: "flex",
944
+ "show-popover": ie.value,
945
+ onPopoverChanged: t[13] || (t[13] = (v) => ie.value = v)
946
+ }, {
947
+ "popover-button": A(() => [
948
+ u(w, {
949
+ class: Je([
950
+ "flex justify-center items-center gap-[8px] border-2 py-1 px-12 rounded-lg cursor-not-allowed",
951
+ T.value || !f.value ? " border-fm-color-neutral-gray-200" : "border-fm-color-primary"
952
+ ]),
953
+ variant: "flat"
954
+ }, {
955
+ default: A(() => [
956
+ u(ea, {
957
+ size: 24,
958
+ color: T.value || !f.value ? "#c7c7cc" : "#ff7823"
959
+ }, null, 8, ["color"]),
960
+ s("button", {
961
+ type: "button",
962
+ disabled: T.value,
963
+ class: Je([
964
+ "fm-typo-cn-body-lg-600",
965
+ T.value || !f.value ? " text-fm-color-neutral-gray-200 cursor-not-allowed" : "text-fm-color-primary"
966
+ ])
967
+ }, " Forecast stock ", 10, Pa)
968
+ ]),
969
+ _: 1
970
+ }, 8, ["class"])
971
+ ]),
972
+ default: A(() => [
973
+ s("div", Ta, [
974
+ s("div", Ua, [
975
+ s("div", Ra, [
976
+ s("div", Ma, [
977
+ u(V, {
978
+ name: "warning",
979
+ class: "text-fm-color-system-warning-300"
980
+ }),
981
+ Aa
982
+ ]),
983
+ $a
984
+ ]),
985
+ u(K, {
986
+ icon: "close",
987
+ size: "md",
988
+ variant: "tertiary",
989
+ onClick: t[10] || (t[10] = (v) => ie.value = !1)
990
+ })
991
+ ]),
992
+ u(N, {
993
+ modelValue: re.value,
994
+ "onUpdate:modelValue": t[11] || (t[11] = (v) => re.value = v),
995
+ label: "Enter day to forecast stock"
996
+ }, null, 8, ["modelValue"]),
997
+ s("div", Ea, [
998
+ Oa,
999
+ u(K, {
1000
+ label: "Cancel",
1001
+ variant: "tertiary",
1002
+ onClick: t[12] || (t[12] = (v) => ie.value = !1)
1003
+ }),
1004
+ u(K, {
1005
+ label: "Generate",
1006
+ onClick: Oe
1007
+ })
1008
+ ])
1009
+ ])
1010
+ ]),
1011
+ _: 1
1012
+ }, 8, ["show-popover"])
1013
+ ]),
1014
+ U.value.length ? (_(), F("div", Na, [
1015
+ (_(), Z(Te, {
1016
+ "row-data": U.value,
1017
+ "column-defs": he.value,
1018
+ key: b.value,
1019
+ "data-cy": "fm-table-transfer-items",
1020
+ "hide-footer": "",
1021
+ "page-size": U.value.length
1022
+ }, {
1023
+ "table-row": A((v) => {
1024
+ var h, fe;
1025
+ return [
1026
+ s("tr", {
1027
+ class: Je(["border-b border-fm-color-neutral-gray-100 hover:bg-fm-color-opacity-sm", {
1028
+ "bg-fm-color-neutral-gray-100": v.getIsSelected()
1029
+ }])
1030
+ }, [
1031
+ (_(!0), F($e, null, ot(v.getVisibleCells(), (se) => {
1032
+ var Ue, ve, Re, Me;
1033
+ return _(), F("td", {
1034
+ key: se.id,
1035
+ class: Je([
1036
+ "h-[52px] px-16 text-fm-color-typo-primary",
1037
+ ((Ue = Le(se)) == null ? void 0 : Ue.cellClass) ?? "px-16"
1038
+ ]),
1039
+ style: no({
1040
+ width: (ve = Le(se)) == null ? void 0 : ve.width,
1041
+ maxWidth: (Re = Le(se)) == null ? void 0 : Re.maxWidth,
1042
+ textAlign: ((Me = Le(se)) == null ? void 0 : Me.textAlign) ?? "left"
1043
+ })
1044
+ }, [
1045
+ s("span", Ha, [
1046
+ u(d(ee), {
1047
+ render: se.column.columnDef.cell,
1048
+ props: se.getContext()
1049
+ }, null, 8, ["render", "props"])
1050
+ ])
1051
+ ], 6);
1052
+ }), 128))
1053
+ ], 2),
1054
+ b.value === d(R).PURCHASE && ue.value && Object.keys(Pe.value[(h = v.original.sku) == null ? void 0 : h._id] ?? {}).length > 0 ? (_(), F("tr", Ya, [
1055
+ s("td", {
1056
+ colspan: v.getVisibleCells().length
1057
+ }, [
1058
+ u(so, {
1059
+ prices: Pe.value[(fe = v.original.sku) == null ? void 0 : fe._id]
1060
+ }, null, 8, ["prices"])
1061
+ ], 8, qa)
1062
+ ])) : G("", !0)
1063
+ ];
1064
+ }),
1065
+ "list-row": A((v) => [
1066
+ u(io, { row: v }, {
1067
+ default: A((h) => {
1068
+ var fe, se, Ue, ve, Re, Me, gt, yt, Qe, ht, bt, xt, Ct, Ke, kt, wt, Dt, St, Be, Ft, Vt, Pt, Tt, Ge, Ut, Rt, Mt, At, $t, Et, We, Ot, Nt, Ht, Yt, qt, It, jt, Lt, Ze, zt, Qt, Kt;
1069
+ return [
1070
+ s("div", Ia, [
1071
+ s("div", ja, [
1072
+ s("div", La, W(v.original.sku.name), 1),
1073
+ s("div", null, [
1074
+ u(d(ee), {
1075
+ render: (Ue = (se = (fe = h.Delete) == null ? void 0 : fe.column) == null ? void 0 : se.columnDef) == null ? void 0 : Ue.cell,
1076
+ props: (Re = (ve = h.Delete) == null ? void 0 : ve.getContext) == null ? void 0 : Re.call(ve)
1077
+ }, null, 8, ["render", "props"])
1078
+ ])
1079
+ ]),
1080
+ s("div", za, [
1081
+ s("div", Qa, [
1082
+ u(E, { label: "Code" }),
1083
+ u(d(ee), {
1084
+ render: (yt = (gt = (Me = h.code) == null ? void 0 : Me.column) == null ? void 0 : gt.columnDef) == null ? void 0 : yt.cell,
1085
+ props: (ht = (Qe = h.code) == null ? void 0 : Qe.getContext) == null ? void 0 : ht.call(Qe)
1086
+ }, null, 8, ["render", "props"])
1087
+ ]),
1088
+ s("div", Ka, [
1089
+ u(E, { label: "Name" }),
1090
+ u(d(ee), {
1091
+ render: (Ct = (xt = (bt = h.Name) == null ? void 0 : bt.column) == null ? void 0 : xt.columnDef) == null ? void 0 : Ct.cell,
1092
+ props: (kt = (Ke = h.Name) == null ? void 0 : Ke.getContext) == null ? void 0 : kt.call(Ke)
1093
+ }, null, 8, ["render", "props"])
1094
+ ]),
1095
+ s("div", Ba, [
1096
+ u(E, { label: "Amount" }),
1097
+ u(d(ee), {
1098
+ render: (St = (Dt = (wt = h.Amount) == null ? void 0 : wt.column) == null ? void 0 : Dt.columnDef) == null ? void 0 : St.cell,
1099
+ props: (Ft = (Be = h.Amount) == null ? void 0 : Be.getContext) == null ? void 0 : Ft.call(Be)
1100
+ }, null, 8, ["render", "props"])
1101
+ ]),
1102
+ s("div", Ga, [
1103
+ u(E, { label: "Unit" }),
1104
+ u(d(ee), {
1105
+ render: (Tt = (Pt = (Vt = h.Unit) == null ? void 0 : Vt.column) == null ? void 0 : Pt.columnDef) == null ? void 0 : Tt.cell,
1106
+ props: (Ut = (Ge = h.Unit) == null ? void 0 : Ge.getContext) == null ? void 0 : Ut.call(Ge)
1107
+ }, null, 8, ["render", "props"])
1108
+ ]),
1109
+ b.value === d(R).PURCHASE ? (_(), F("div", Wa, [
1110
+ u(E, {
1111
+ label: typeof ((At = (Mt = (Rt = h.Cost) == null ? void 0 : Rt.column) == null ? void 0 : Mt.columnDef) == null ? void 0 : At.header) == "function" ? (Nt = (Et = ($t = h.Cost) == null ? void 0 : $t.column) == null ? void 0 : Et.columnDef) == null ? void 0 : Nt.header(
1112
+ (Ot = (We = h.Cost) == null ? void 0 : We.getContext) == null ? void 0 : Ot.call(We)
1113
+ ) : ((qt = (Yt = (Ht = h.Cost) == null ? void 0 : Ht.column) == null ? void 0 : Yt.columnDef) == null ? void 0 : qt.header) ?? ""
1114
+ }, null, 8, ["label"]),
1115
+ u(d(ee), {
1116
+ render: (Lt = (jt = (It = h.Cost) == null ? void 0 : It.column) == null ? void 0 : jt.columnDef) == null ? void 0 : Lt.cell,
1117
+ props: (zt = (Ze = h.Cost) == null ? void 0 : Ze.getContext) == null ? void 0 : zt.call(Ze)
1118
+ }, null, 8, ["render", "props"])
1119
+ ])) : G("", !0)
1120
+ ]),
1121
+ b.value === d(R).PURCHASE && ue.value && Object.keys(Pe.value[(Qt = v.original.sku) == null ? void 0 : Qt._id] ?? {}).length > 0 ? (_(), F($e, { key: 0 }, [
1122
+ u(be, { class: "h-8" }),
1123
+ u(so, {
1124
+ prices: Pe.value[(Kt = v.original.sku) == null ? void 0 : Kt._id]
1125
+ }, null, 8, ["prices"])
1126
+ ], 64)) : G("", !0)
1127
+ ])
1128
+ ];
1129
+ }),
1130
+ _: 2
1131
+ }, 1032, ["row"])
1132
+ ]),
1133
+ _: 1
1134
+ }, 8, ["row-data", "column-defs", "page-size"]))
1135
+ ])) : G("", !0)
1136
+ ])
1137
+ ])
1138
+ ];
1139
+ }),
1140
+ _: 1
1141
+ }, 8, ["disabled"]);
1142
+ };
1143
+ }
1144
+ }), Ja = { class: "flex items-center" }, Xa = { class: "fm-typo-en-title-md-800" }, es = { class: "flex gap-4" }, ts = /* @__PURE__ */ ke({
1145
+ __name: "TransferDialog",
1146
+ props: {
1147
+ mode: {},
1148
+ modelValue: {},
1149
+ show: { type: Boolean },
1150
+ lastClosingDate: {}
1151
+ },
1152
+ emits: ["update:show", "submitted"],
1153
+ setup(q, { expose: te, emit: J }) {
1154
+ const k = q, $ = J, C = ro(), g = pt(), P = uo(), I = bo(), y = mt();
1155
+ async function f(m) {
1156
+ if (m) {
1157
+ i.value = !0;
1158
+ try {
1159
+ await P.readSuppliers(), i.value = !1;
1160
+ } catch {
1161
+ g.open({
1162
+ title: "Unable to fetch list of suppliers",
1163
+ message: "Try to refresh page to retry operation",
1164
+ type: "error"
1165
+ });
1166
+ }
1167
+ }
1168
+ }
1169
+ y.watchLocation(f);
1170
+ const oe = Ho(k, "show"), ae = z(k.modelValue ?? {});
1171
+ ce([() => k.modelValue], () => {
1172
+ ae.value = k.modelValue ?? {};
1173
+ });
1174
+ const i = z(!1), _e = M(() => {
1175
+ switch (k.mode) {
1176
+ case Ae.CREATE:
1177
+ return "Add transfer";
1178
+ case Ae.READ:
1179
+ return "View transfer";
1180
+ case Ae.UPDATE:
1181
+ return "Edit transfer";
1182
+ }
1183
+ return "";
1184
+ }), T = z();
1185
+ te({
1186
+ validateInputs: () => {
1187
+ var m, c;
1188
+ (c = (m = T.value) == null ? void 0 : m.validateInputs) == null || c.call(m);
1189
+ },
1190
+ resetInputsValidation: () => {
1191
+ var m, c;
1192
+ (c = (m = T.value) == null ? void 0 : m.resetInputsValidation) == null || c.call(m);
1193
+ },
1194
+ resetInputs: () => {
1195
+ var m, c;
1196
+ (c = (m = T.value) == null ? void 0 : m.resetInputs) == null || c.call(m);
1197
+ }
1198
+ });
1199
+ async function U() {
1200
+ const m = ae.value;
1201
+ i.value = !0, (m.supplier.internal === "warehouse" || m.supplier.internal === "restaurant") && (m.items = m.items.map(({ totalCost: c, ...S }) => S));
1202
+ try {
1203
+ await C.createPurchaseOrder(m), await new Promise((c) => setTimeout(c, 1e3)), g.open({
1204
+ title: "Created",
1205
+ message: "Your transfer draft has been created!",
1206
+ type: "success"
1207
+ }), $("update:show", !1), $("submitted");
1208
+ } catch (c) {
1209
+ g.open({
1210
+ title: "Cannot create purchase order",
1211
+ message: "Report to system administrator for troubleshooting.",
1212
+ type: "error"
1213
+ }), console.error("Error in creating purchase order", c);
1214
+ } finally {
1215
+ i.value = !1;
1216
+ }
1217
+ }
1218
+ async function O() {
1219
+ const m = ae.value;
1220
+ i.value = !0, (m.supplier.internal === "warehouse" || m.supplier.internal === "restaurant") && (m.items = m.items.map(({ totalCost: c, ...S }) => S));
1221
+ try {
1222
+ await C.updatePurchaseOrder(m), await new Promise((c) => setTimeout(c, 1e3)), g.open({
1223
+ title: "Updated",
1224
+ message: "Your transfer draft has been updated!",
1225
+ type: "success"
1226
+ }), $("update:show", !1), $("submitted");
1227
+ } catch (c) {
1228
+ g.open({
1229
+ title: "Cannot update purchase order",
1230
+ message: "Report to system administrator for troubleshooting.",
1231
+ type: "error"
1232
+ }), console.error("Error in updating purchase order", c);
1233
+ } finally {
1234
+ i.value = !1;
1235
+ }
1236
+ }
1237
+ function Q() {
1238
+ switch (k.mode) {
1239
+ case Ae.CREATE:
1240
+ return U();
1241
+ case Ae.UPDATE:
1242
+ return O();
1243
+ }
1244
+ }
1245
+ function b() {
1246
+ var m, c;
1247
+ (c = (m = T.value) == null ? void 0 : m.validateInputs) == null || c.call(m);
1248
+ }
1249
+ return (m, c) => {
1250
+ const S = D("FmButton"), X = D("FmSideSheet");
1251
+ return _(), Z(X, {
1252
+ modelValue: d(oe),
1253
+ "onUpdate:modelValue": c[2] || (c[2] = (H) => _o(oe) ? oe.value = H : null),
1254
+ "dismiss-away": "",
1255
+ "close-button": "",
1256
+ "max-width": 900
1257
+ }, {
1258
+ "side-sheet-header": A(() => [
1259
+ s("div", Ja, [
1260
+ s("div", Xa, W(_e.value), 1)
1261
+ ])
1262
+ ]),
1263
+ default: A(() => [
1264
+ (_(), Z(Za, {
1265
+ class: "w-full",
1266
+ ref_key: "formRef",
1267
+ ref: T,
1268
+ onValidationSuccess: Q,
1269
+ modelValue: ae.value,
1270
+ "onUpdate:modelValue": c[0] || (c[0] = (H) => ae.value = H),
1271
+ disabled: i.value,
1272
+ suppliers: d(P).suppliers,
1273
+ skus: d(I).skus,
1274
+ key: ae.value._id ?? "",
1275
+ "last-closing-date": m.lastClosingDate
1276
+ }, null, 8, ["modelValue", "disabled", "suppliers", "skus", "last-closing-date"]))
1277
+ ]),
1278
+ "side-sheet-footer": A(() => [
1279
+ s("div", es, [
1280
+ u(S, {
1281
+ loading: i.value,
1282
+ label: "Save",
1283
+ onClick: b
1284
+ }, null, 8, ["loading"]),
1285
+ u(S, {
1286
+ disabled: i.value,
1287
+ variant: "tertiary",
1288
+ label: "Close",
1289
+ onClick: c[1] || (c[1] = (H) => $("update:show", !1))
1290
+ }, null, 8, ["disabled"])
1291
+ ])
1292
+ ]),
1293
+ _: 1
1294
+ }, 8, ["modelValue"]);
1295
+ };
1296
+ }
1297
+ }), os = { class: "px-24 xs:p-0 sm:p-0 flex flex-col gap-8 max-h-full" }, as = { class: "px-8 flex gap-8 items-center xs:gap-0 xs:flex-col-reverse sm:gap-0 sm:flex-col-reverse" }, ss = { class: "xs:w-full sm:w-full flex gap-8 items-center overflow-x-auto no-scrollbar py-8" }, ls = { class: "flex-1 w-full" }, ns = { class: "flex flex-col py-8" }, rs = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, is = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary line-clamp-1" }, us = { class: "fm-typo-en-body-md-400 text-fm-color-typo-primary line-clamp-1" }, cs = {
1298
+ key: 0,
1299
+ class: "fm-typo-en-body-md-400 text-fm-color-typo-primary line-clamp-1"
1300
+ }, ds = { class: "pt-8" }, lo = "ReceiveRequestViewSearchCriteria", Vs = /* @__PURE__ */ ke({
1301
+ __name: "ReceiveRequestView",
1302
+ setup(q) {
1303
+ const te = pt();
1304
+ Xe.object({
1305
+ name: Xe.string().optional().nullable(),
1306
+ startDate: Xe.string().optional().nullable(),
1307
+ endDate: Xe.string().optional().nullable()
1308
+ });
1309
+ const J = xo();
1310
+ function k() {
1311
+ const U = {
1312
+ name: "",
1313
+ ...at()
1314
+ }, O = J.getItem(lo);
1315
+ if (!O)
1316
+ return U;
1317
+ try {
1318
+ return JSON.parse(O);
1319
+ } catch {
1320
+ return U;
1321
+ }
1322
+ }
1323
+ function $() {
1324
+ J.setItem(lo, JSON.stringify(C.value));
1325
+ }
1326
+ const C = z(k()), g = Co("receive/request", C.value), { columnDefs: P } = ko("receive/request", g), I = mt();
1327
+ async function y() {
1328
+ const U = `inventory-record_${ct(C.value.startDate).format("DD-MM-YYYY_HH-mm")}-${ct(C.value.endDate).format("DD-MM-YYYY_HH-mm")}.xlsx`, O = g.purchaseOrders.value.flatMap(
1329
+ (Q) => Q.items.map((b) => {
1330
+ const m = ct(Ao(Q._id)).format("DD MMM YYYY"), c = B(
1331
+ Do(b.sku, Q.deliveryOrder || [])
1332
+ ), S = B(b.quantity);
1333
+ return {
1334
+ "SKU Code": b.code,
1335
+ "SKU Name": b.name,
1336
+ "PO #": Q.seqNumber,
1337
+ Date: m,
1338
+ Status: Q.status,
1339
+ Reference: Q.ref,
1340
+ "Received Quantity": c,
1341
+ "Ordered Quantity": S,
1342
+ Unit: b.sku.unit.abbrev
1343
+ };
1344
+ })
1345
+ );
1346
+ await $o(
1347
+ [
1348
+ {
1349
+ name: "purchases",
1350
+ data: O,
1351
+ columns: [
1352
+ "SKU Code",
1353
+ "SKU Name",
1354
+ "PO #",
1355
+ "Date",
1356
+ "Status",
1357
+ "Reference",
1358
+ "Received Quantity",
1359
+ "Ordered Quantity",
1360
+ "Unit"
1361
+ ]
1362
+ }
1363
+ ],
1364
+ U
1365
+ ), te.open({
1366
+ title: "Success",
1367
+ message: `Exported ${U}`,
1368
+ type: "success"
1369
+ });
1370
+ }
1371
+ const f = z(at()), oe = z("");
1372
+ ce([() => f.value], ([U]) => {
1373
+ !U.startDate || !U.endDate || (C.value.startDate = U.startDate, C.value.endDate = U.endDate, g.updateDateRange(
1374
+ C.value.startDate,
1375
+ C.value.endDate
1376
+ ), $());
1377
+ }), ce([() => oe.value], () => {
1378
+ $();
1379
+ });
1380
+ function ae(U) {
1381
+ U === "create" && g.promptCreateTransferDialog();
1382
+ }
1383
+ const { breakpoints: i } = Yo(), _e = M(() => i.value.xs || i.value.sm ? 10 : 20), T = jo();
1384
+ return (U, O) => {
1385
+ const Q = D("FmTableToolbar"), b = D("FmTable");
1386
+ return _(), Z(Eo, {
1387
+ title: "Receive and Request",
1388
+ actions: [{ label: "Create transfer", value: "create", isPrimary: !0, prependIcon: "add" }],
1389
+ "onClick:action": ae
1390
+ }, {
1391
+ default: A(() => {
1392
+ var m;
1393
+ return [
1394
+ s("div", os, [
1395
+ s("div", as, [
1396
+ s("div", ss, [
1397
+ u(Oo),
1398
+ u(Bo, {
1399
+ "model-value": f.value,
1400
+ "onUpdate:modelValue": O[0] || (O[0] = (c) => f.value = c)
1401
+ }, null, 8, ["model-value"])
1402
+ ]),
1403
+ s("div", ls, [
1404
+ u(Q, {
1405
+ searchable: "",
1406
+ "search-model": oe.value,
1407
+ "onUpdate:searchModel": O[1] || (O[1] = (c) => oe.value = c),
1408
+ actions: [{ label: "Export", icon: "ios_share", key: "export" }],
1409
+ "onClick:actionExport": y
1410
+ }, null, 8, ["search-model"])
1411
+ ])
1412
+ ]),
1413
+ (_(), Z(b, {
1414
+ style: no(d(T).tableHeight),
1415
+ "column-defs": d(P),
1416
+ "row-data": d(g).purchaseOrders.value,
1417
+ "search-value": oe.value,
1418
+ loading: !d(I)._currentLocation || d(g).loading.value,
1419
+ onRowClick: O[2] || (O[2] = (c) => d(g).promptShowTransferDetails(c.original)),
1420
+ key: (m = d(I)._currentLocation) == null ? void 0 : m.dbName,
1421
+ "page-size": _e.value
1422
+ }, {
1423
+ "list-row": A((c) => [
1424
+ u(io, {
1425
+ row: c,
1426
+ onRowClick: d(g).promptShowTransferDetails
1427
+ }, {
1428
+ default: A((S) => {
1429
+ var X, H, Ee, re, ie, we, Oe, Ne, ge, De, Se, He, Ye, ye, qe, Ie, Fe, Ve, he, de;
1430
+ return [
1431
+ s("div", ns, [
1432
+ s("div", rs, [
1433
+ u(d(ee), {
1434
+ render: (Ee = (H = (X = S._id) == null ? void 0 : X.column) == null ? void 0 : H.columnDef) == null ? void 0 : Ee.cell,
1435
+ props: (ie = (re = S._id) == null ? void 0 : re.getContext) == null ? void 0 : ie.call(re)
1436
+ }, null, 8, ["render", "props"])
1437
+ ]),
1438
+ s("div", is, [
1439
+ u(d(ee), {
1440
+ render: (Ne = (Oe = (we = S.supplier_name) == null ? void 0 : we.column) == null ? void 0 : Oe.columnDef) == null ? void 0 : Ne.cell,
1441
+ props: (De = (ge = S.supplier_name) == null ? void 0 : ge.getContext) == null ? void 0 : De.call(ge)
1442
+ }, null, 8, ["render", "props"])
1443
+ ]),
1444
+ s("div", us, W(c.original.items.map((ue) => `${ue.name}`).join(", ")), 1),
1445
+ c.original.ref ? (_(), F("div", cs, [
1446
+ u(d(ee), {
1447
+ render: (Ye = (He = (Se = S.ref) == null ? void 0 : Se.column) == null ? void 0 : He.columnDef) == null ? void 0 : Ye.cell,
1448
+ props: (qe = (ye = S.ref) == null ? void 0 : ye.getContext) == null ? void 0 : qe.call(ye)
1449
+ }, null, 8, ["render", "props"])
1450
+ ])) : G("", !0),
1451
+ s("div", ds, [
1452
+ u(d(ee), {
1453
+ render: (Ve = (Fe = (Ie = S.status) == null ? void 0 : Ie.column) == null ? void 0 : Fe.columnDef) == null ? void 0 : Ve.cell,
1454
+ props: (de = (he = S.status) == null ? void 0 : he.getContext) == null ? void 0 : de.call(he)
1455
+ }, null, 8, ["render", "props"])
1456
+ ])
1457
+ ])
1458
+ ];
1459
+ }),
1460
+ _: 2
1461
+ }, 1032, ["row", "onRowClick"])
1462
+ ]),
1463
+ _: 1
1464
+ }, 8, ["style", "column-defs", "row-data", "search-value", "loading", "page-size"]))
1465
+ ]),
1466
+ (_(), Z(go, { to: "body" }, [
1467
+ u(ts, Gt(d(g).transferDialogProps.value, {
1468
+ onSubmitted: d(g).fetchData
1469
+ }), null, 16, ["onSubmitted"]),
1470
+ u(wo, Gt(d(g).transferDetailsProps.value, {
1471
+ onSubmitted: d(g).fetchData
1472
+ }), null, 16, ["onSubmitted"])
1473
+ ]))
1474
+ ];
1475
+ }),
1476
+ _: 1
1477
+ });
1478
+ };
1479
+ }
1480
+ });
1481
+ export {
1482
+ Vs as default
1483
+ };