This commit is contained in:
2026-01-25 15:05:01 +03:30
parent bca1932ae3
commit 55856a40f1
6 changed files with 62 additions and 46 deletions
@@ -106,4 +106,18 @@ export class PaymentRepository extends EntityRepository<Payment> {
},
};
}
async getActualPaidAmount(orderId: string): Promise<number> {
const raw = await this.em.createQueryBuilder(Payment, 'p')
.select('COALESCE(SUM(p.amount), 0) as total')
.where({
order: { id: orderId },
status: PaymentStatusEnum.Paid
})
.execute('get')
const row = raw as unknown as { total: string } | undefined;
return Number(row?.total ?? 0);
}
}