fix currency recalc

This commit is contained in:
2024-03-19 20:18:54 +01:00
parent 08cadfcf33
commit 46496d7438
3 changed files with 16 additions and 11 deletions

View File

@@ -145,6 +145,19 @@ const fetch = async () => {
} }
}; };
function selectCurrency(item, id) {
if (typeof countryCurrency.value[settingsStore.country.country] !== 'undefined') {
settingsStore.currency = countryCurrency.value[settingsStore.country.country];
} else {
settingsStore.currency = "EUR";
}
if (settingsStore.currency != "EUR")
settingsStore.currencyCoef = currencyHash.value[settingsStore.currency];
else settingsStore.currencyCoef = 1.0;
}
function selectCountry(item, id) { function selectCountry(item, id) {
let cCntry = [["Country"]]; let cCntry = [["Country"]];
@@ -212,7 +225,7 @@ onMounted(fetch_menu);
<span class="font-extrabold font-mono">Country in which search product</span> <span class="font-extrabold font-mono">Country in which search product</span>
</div> </div>
<div class=""> <div class="">
<multiselect placeholder="All" :close-on-select="true" :multiple="false" v-model="settingsStore.country" :options="ccodes" label="country" track-by="code"> <multiselect @select="selectCurrency" placeholder="All" :close-on-select="true" :multiple="false" v-model="settingsStore.country" :options="ccodes" label="country" track-by="code">
<template #option="slotProps"> <template #option="slotProps">
<span :class="'pl-6 fi fi-' + slotProps.option.code.toLowerCase()">{{ slotProps.option.country }}</span> <span :class="'pl-6 fi fi-' + slotProps.option.code.toLowerCase()">{{ slotProps.option.country }}</span>
</template> </template>

View File

@@ -93,7 +93,7 @@ const tproducts = computed(() => {
if (prod.tag == "NONE") prod.tag = ""; if (prod.tag == "NONE") prod.tag = "";
prod.salesPrice = Math.round(prod.salesPrice * 100) / 100; prod.salesPrice = Math.round(prod.salesPrice * 100) / 100;
prod.calcPrice = prod.calcPrice =
Math.round(prod.calcPrice * currencyCoef.value * 100) / 100; Math.round(prod.calcPrice * settingsStore.currencyCoef * 100) / 100;
prod.rate = currencyHash.value[prod.currency]; prod.rate = currencyHash.value[prod.currency];
if (prod.tag != null && prod.tag.length > 1) prod.tag = prod.tag.replace(/_/g, " "); if (prod.tag != null && prod.tag.length > 1) prod.tag = prod.tag.replace(/_/g, " ");
return prod; return prod;
@@ -183,7 +183,6 @@ const ccountry = ref([]);
const ccountry_list = ref(["TEST"]); const ccountry_list = ref(["TEST"]);
const currencyHash = ref({}); const currencyHash = ref({});
const currency = ref([]); const currency = ref([]);
const currencyCoef = ref(1.0);
const items = ref([]); const items = ref([]);
@@ -387,14 +386,6 @@ const showRow = async (item) => {
response.isConfirmed && fetch(); response.isConfirmed && fetch();
} }
}; };
const onSelectCurrency = () => {
console.log("CURR", settingsStore.currency);
console.log("COEF", currencyCoef.value);
if (settingsStore.currency != "EUR")
currencyCoef.value = currencyHash.value[settingsStore.currency];
else currencyCoef.value = 1.0;
};
const submit = () => { const submit = () => {
console.log("ITEM=", form); console.log("ITEM=", form);

View File

@@ -9,5 +9,6 @@ export const settingsStore = reactive({
currency: "EUR", currency: "EUR",
online: false, online: false,
ccountry_filter: [["Country"]], ccountry_filter: [["Country"]],
currencyCoef: 1.0,
settings: {}, settings: {},
}); });