This commit is contained in:
2025-12-02 20:01:07 +03:30
parent e43727f1c6
commit 40442686be
24 changed files with 420 additions and 490 deletions
@@ -26,7 +26,7 @@ export interface Cart {
totalDiscount: number;
subTotal: number;
tax: number;
deliveryFee: number;
shipmentFee: number;
total: number;
totalItems: number;
createdAt: string;
+10 -10
View File
@@ -45,7 +45,7 @@ export class CartService {
restaurantId,
restaurantName: restaurant.name,
items: [],
deliveryFee: 0,
shipmentFee: 0,
subTotal: 0,
itemsDiscount: 0,
couponDiscount: 0,
@@ -449,7 +449,7 @@ export class CartService {
}
cart.paymentMethodId = setPaymentMethodDto.paymentMethodId;
// cart.deliveryFee = Number(restaurantPaymentMethod.price) || 0;
// cart.shipmentFee = Number(restaurantPaymentMethod.price) || 0;
// Recalculate cart totals to include delivery fee
await this.recalculateCartTotals(cart);
@@ -505,22 +505,22 @@ export class CartService {
cart.tax = tax;
// Get delivery fee if payment method is set
let deliveryFee = 0;
// Get shipment fee if payment method is set
let shipmentFee = 0;
// if (cart.paymentMethodId) {
// const restaurantPaymentMethod = await this.em.findOne(RestaurantPaymentMethod, {
// restaurant: { id: cart.restaurantId },
// paymentMethod: { id: cart.paymentMethodId },
// });
// if (restaurantPaymentMethod) {
// deliveryFee = Number(restaurantPaymentMethod.price) || 0;
// deliveryFee = 1;
// shipmentFee = Number(restaurantPaymentMethod.price) || 0;
// shipmentFee = 1;
// }
// }
cart.deliveryFee = deliveryFee;
cart.shipmentFee = shipmentFee;
// Calculate total: total = subtotal totalDiscount + tax + deliveryFee
cart.total = subTotal - cart.totalDiscount + tax + deliveryFee;
// Calculate total: total = subtotal totalDiscount + tax + shipmentFee
cart.total = subTotal - cart.totalDiscount + tax + shipmentFee;
cart.totalItems = totalItems;
cart.updatedAt = new Date().toISOString();
}
@@ -542,7 +542,7 @@ export class CartService {
typeof cart.couponDiscount === 'number' &&
typeof cart.totalDiscount === 'number' &&
typeof cart.tax === 'number' &&
typeof cart.deliveryFee === 'number' &&
typeof cart.shipmentFee === 'number' &&
typeof cart.total === 'number' &&
typeof cart.totalItems === 'number' &&
typeof cart.createdAt === 'string' &&