chore: add user to the invoice

This commit is contained in:
Mahyargdz
2025-05-08 10:24:01 +03:30
parent 9faa75b049
commit 3d915930a7
18 changed files with 27 additions and 80 deletions
@@ -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);