fix: partially paid invoice transaction.

This commit is contained in:
a.bouhuolia
2020-12-19 13:51:44 +02:00
parent cc47314a62
commit 1a0aad7dc4

View File

@@ -5,13 +5,6 @@ import { defaultToTransform } from 'utils';
import { QueryBuilder } from 'knex'; import { QueryBuilder } from 'knex';
export default class SaleInvoice extends TenantModel { export default class SaleInvoice extends TenantModel {
/**
* Virtual attributes.
*/
static get virtualAttributes() {
return ['dueAmount'];
}
/** /**
* Table name * Table name
*/ */
@@ -60,10 +53,10 @@ export default class SaleInvoice extends TenantModel {
/** /**
* Retrieve the invoice due amount. * Retrieve the invoice due amount.
* (Invoice amount - payment amount = Due amount) * Equation (Invoice amount - payment amount = Due amount)
* @return {boolean} * @return {boolean}
*/ */
dueAmount() { get dueAmount() {
return Math.max(this.balance - this.paymentAmount, 0); return Math.max(this.balance - this.paymentAmount, 0);
} }