- corretto la gestione degli Sconti

- Duplicare un Catalogo
This commit is contained in:
Surya Paolo
2025-06-11 01:05:20 +02:00
parent 56d1870bc1
commit d99ad47483
17 changed files with 296 additions and 147 deletions

View File

@@ -5,7 +5,7 @@ import { CCopyBtn } from '../CCopyBtn';
import type { IOrder } from '@src/model';
import { IOperators, IProduct } from '@src/model';
import type { PropType } from 'vue';
import { defineComponent, toRef, ref, watch, onMounted } from 'vue';
import { defineComponent, toRef, ref, watch, onMounted, computed } from 'vue';
import { CTitleBanner } from '@src/components/CTitleBanner';
import { useProducts } from '@store/Products';
import { useI18n } from 'vue-i18n';
@@ -59,6 +59,10 @@ export default defineComponent({
const enableQtyPreordered = ref(false);
const enableChangeTotalPrice = ref(false);
watch(props.order, (newVal: any) => {
order.value = { ...newVal };
});
watch(orderQuantity, (newValue: any) => {
if (!newValue) order.value.quantity = 0;
else order.value.quantity = parseFloat(newValue);
@@ -151,15 +155,17 @@ export default defineComponent({
});
}
function isApplicatoSconto() {
const isApplicatoSconto = computed(() => {
const totalipotetico =
order.value.product!.price *
(order.value.quantity + order.value.quantitypreordered);
if (totalipotetico.toFixed(2) > order.value.TotalPriceProduct.toFixed(2)) {
const totalipoteticoNum = parseFloat(totalipotetico.toFixed(2));
const totalpriceNum = parseFloat(order.value.TotalPriceProduct.toFixed(2));
if (totalipoteticoNum > totalpriceNum) {
return true;
}
return false;
}
});
function removeFromCard() {
$q.dialog({
@@ -197,12 +203,21 @@ export default defineComponent({
mounted();
}
function getRisparmio(): string {
const getRisparmio = computed((): string => {
return (
order.value.product!.price * order.value.quantity -
order.value.TotalPriceProduct
).toFixed(2);
}
});
const getRispPerc = computed((): string => {
const risparmioPerc = parseFloat(
(
(getRisparmio.value / (order.value.product!.price * order.value.quantity)) *
100
).toFixed(2)
);
return risparmioPerc.toFixed(0);
});
function mounted() {
endload.value = false;
@@ -248,6 +263,7 @@ export default defineComponent({
orderTotalPriceProduct,
endload,
qtyInCart,
getRispPerc,
};
},
});