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