- 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

@@ -22,15 +22,7 @@
.barrato {
text-decoration: line-through;
}
.ordine_scontato_nuovo{
font-size: 1.1rem;
font-weight: bold;
}
.ordine_scritta_sconto{
font-style: italic;
color: green;
font-weight: bold;
}
.gasordine {
font-style: italic;
color: blue;
@@ -105,14 +97,15 @@
}
.quantity-display {
min-width: 60px;
width: 80px;
text-align: center;
font-size: 1.4rem;
font-size: 1.2rem;
font-weight: 600;
color: #1f2937;
background: #f8fafc;
border-radius: 12px;
padding: 12px 16px;
padding: 4px 8px;
margin: 4px;
border: 2px solid #e2e8f0;
transition: all 0.3s ease;
}
@@ -241,4 +234,17 @@
.remove-btn {
margin: 16px auto 0;
}
}
}
.myval_sconto{
font-size: 1.2em;
font-weight: bold;
color: green;
}
.myperc_sconto{
font-size: 1.2em;
font-weight: bold;
color: green;
margin-left: 10px;
}

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,
};
},
});

View File

@@ -106,9 +106,9 @@
size="sm"
class="quantity-btn"
data-gradiente="negative"
:icon="qtyInCart() === 1 ? 'fas fa-trash': 'fas fa-minus'"
:icon="qtyInCart() === 1 ? 'fas fa-trash' : 'fas fa-minus'"
:color="products.enableSubQty(order) ? undefined : 'grey'"
@click="qtyInCart() === 1 ? removeFromCard(): addsubqty(false, true)"
@click="qtyInCart() === 1 ? removeFromCard() : addsubqty(false, true)"
rounded
></q-btn>
<div v-if="editmode">
@@ -195,27 +195,12 @@
{{ order.quantity + order.quantitypreordered }} x €
{{ order.price ? order.price : 0 }}
</span>
<span :class="isApplicatoSconto() ? 'ordine_scontato_nuovo' : ''">
= €
=
<span :class="isApplicatoSconto ? 'ordine_scontato_nuovo' : ''">
{{ order.TotalPriceProduct ? order.TotalPriceProduct.toFixed(2) : 0 }}
</span>
<span
v-if="
tools.isManager() &&
order.TotalPriceProduct.toFixed(2) !==
order.TotalPriceProductCalc.toFixed(2)
"
:class="isApplicatoSconto() ? 'ordine_scontato_nuovo' : ''"
>
(Calc: €
{{
order.TotalPriceProductCalc
? order.TotalPriceProductCalc.toFixed(2)
: 0
}})
</span>
<span v-if="isApplicatoSconto()">
<span v-if="isApplicatoSconto">
&nbsp;<span class="ordine_scontato"
>(<span class="barrato"
>€
@@ -228,11 +213,17 @@
>)</span
>&nbsp;
</span>
<span
v-if="isApplicatoSconto() && !editmode"
<div
v-if="isApplicatoSconto && !editmode"
class="ordine_scritta_sconto"
>{{ $t('ecomm.sconto_applicato', { risparmio: getRisparmio() }) }}</span
v-html="
$t('ecomm.sconto_applicato', {
risparmio: getRisparmio,
perc: getRispPerc,
})
"
>
</div>
</div>
</q-item-label>
</q-item-section>