From 1a0aad7dc490ae95a027696d00b1f8ac7e2a95b0 Mon Sep 17 00:00:00 2001 From: "a.bouhuolia" Date: Sat, 19 Dec 2020 13:51:44 +0200 Subject: [PATCH] fix: partially paid invoice transaction. --- server/src/models/SaleInvoice.js | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/server/src/models/SaleInvoice.js b/server/src/models/SaleInvoice.js index bb2beee26..cf9fb4b3b 100644 --- a/server/src/models/SaleInvoice.js +++ b/server/src/models/SaleInvoice.js @@ -5,13 +5,6 @@ import { defaultToTransform } from 'utils'; import { QueryBuilder } from 'knex'; export default class SaleInvoice extends TenantModel { - /** - * Virtual attributes. - */ - static get virtualAttributes() { - return ['dueAmount']; - } - /** * Table name */ @@ -60,10 +53,10 @@ export default class SaleInvoice extends TenantModel { /** * Retrieve the invoice due amount. - * (Invoice amount - payment amount = Due amount) + * Equation (Invoice amount - payment amount = Due amount) * @return {boolean} */ - dueAmount() { + get dueAmount() { return Math.max(this.balance - this.paymentAmount, 0); }