order
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user