- corretto cancellazione ordine

This commit is contained in:
Surya Paolo
2024-02-15 18:59:13 +01:00
parent c6e0caa3f4
commit a82e07b4ce
5 changed files with 58 additions and 8 deletions

View File

@@ -197,7 +197,7 @@ export const useProducts = defineStore('Products', {
getOrdersAllCart: (state: IProductsState) => (idGasordine: string): IOrderCart[] => {
return state.orders.filter((rec: IOrderCart) => {
if ((idGasordine && !rec.items?.some(item => item.order.idGasordine === idGasordine))) {
if ((idGasordine && !rec.items?.some(item => item.order && item.order.idGasordine === idGasordine))) {
return false; // Skip records not matching gasordine condition
}
return true
@@ -210,11 +210,11 @@ export const useProducts = defineStore('Products', {
getOrdersCart: (state: IProductsState) => (tipoord: number, hasGasordine: any, idGasordine: string): IOrderCart[] | undefined => {
return state.orders.filter((rec: IOrderCart) => {
if (idGasordine && !rec.items?.some(item => item.order.idGasordine === idGasordine)) {
if (idGasordine && !rec.items?.some(item => item.order && item.order.idGasordine === idGasordine)) {
return false; // Skip records not matching gasordine condition
}
if (hasGasordine && !rec.items?.some(item => item.order.idGasordine)) {
if (hasGasordine && !rec.items?.some(item => item.order && item.order.idGasordine)) {
return false; // Skip records not matching gasordine condition
}
@@ -1013,6 +1013,13 @@ export const useProducts = defineStore('Products', {
return qty ? qty > 0 : false
},
CanDeleteIfSub(myorder: IOrder): boolean {
let qty = myorder.quantity + myorder.quantitypreordered
qty = qty - this.qtaNextSub(myorder, myorder.product!)
return qty === 0
},
enableAddQty(myorder: IOrder, myproduct: IProduct): boolean {
const globalStore = useGlobalStore()
if (globalStore.site.ecomm && globalStore.site.ecomm.enablePreOrders) {