feat: record excessed payments as credit

This commit is contained in:
Ahmed Bouhuolia
2024-07-25 18:46:24 +02:00
parent fe214b1b2d
commit 6d17f9cbeb
33 changed files with 597 additions and 100 deletions

View File

@@ -525,9 +525,9 @@ export default class Bill extends mixin(TenantModel, [
return notFoundBillsIds;
}
static changePaymentAmount(billId, amount) {
static changePaymentAmount(billId, amount, trx) {
const changeMethod = amount > 0 ? 'increment' : 'decrement';
return this.query()
return this.query(trx)
.where('id', billId)
[changeMethod]('payment_amount', Math.abs(amount));
}