chore: add user to the invoice
This commit is contained in:
@@ -686,8 +686,11 @@ export class InvoicesService {
|
||||
|
||||
const discount = await queryRunner.manager.findOne(Discount, {
|
||||
where: { code: discountCode, isActive: true },
|
||||
relations: { user: true },
|
||||
});
|
||||
|
||||
if (discount?.user?.id && discount?.user?.id !== userId) throw new BadRequestException(InvoiceMessage.DISCOUNT_NOT_FOR_THIS_USER);
|
||||
|
||||
if (!discount) throw new BadRequestException(InvoiceMessage.INVALID_DISCOUNT_CODE);
|
||||
|
||||
if (discount.endDate && dayjs(discount.endDate).isBefore(dayjs())) throw new BadRequestException(InvoiceMessage.DISCOUNT_EXPIRED);
|
||||
|
||||
Reference in New Issue
Block a user