@feedmepos/mf-inventory-portal 0.0.19-dev.4 → 0.0.19-dev.5

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