coupon bug

This commit is contained in:
2025-12-07 09:08:33 +03:30
parent f2ae0fe020
commit bc159a983b
10 changed files with 37 additions and 23 deletions
+3 -2
View File
@@ -17,7 +17,7 @@ import { Delivery } from '../../delivery/entities/delivery.entity';
import { Cart, CartItem } from '../interfaces/cart.interface';
import { CouponService } from 'src/modules/coupons/providers/coupon.service';
import { OrderCouponDetail } from 'src/modules/orders/interface/order-status';
import { CouponType } from 'src/modules/coupons/entities/coupon.entity';
import { CouponType } from 'src/modules/coupons/interface/coupon';
@Injectable()
export class CartService {
@@ -489,7 +489,8 @@ export class CartService {
*/
async setAddress(userId: string, restaurantId: string, setAddressDto: SetAddressDto): Promise<Cart> {
const cart = await this.findOneOrFail(userId, restaurantId);
if (!cart.deliveryMethodId) throw new BadRequestException('Delivery method must be set before setting address');
// Find and validate address belongs to user
const address = await this.em.findOne(UserAddress, { id: setAddressDto.addressId }, { populate: ['user'] });
if (!address) {