Skip to content

Commit

Permalink
Improve and sanitaze code
Browse files Browse the repository at this point in the history
  • Loading branch information
lomamech committed Jul 30, 2019
1 parent 1edfd7b commit b613b29
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions server/controllers/finance/debtors/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,10 @@ function balance(debtorUuid, excludeCautionLinks = false) {
*
*/
const sql = `
SELECT ROUND(IFNULL(SUM(ledger.debit_equiv), 0), 2) AS debit, ROUND(IFNULL(SUM(ledger.credit_equiv), 0),2) AS credit,
ROUND(IFNULL(SUM(ledger.debit_equiv - ledger.credit_equiv), 0),2) AS balance, MIN(trans_date) AS since,
MAX(trans_date) AS until
SELECT ROUND(IFNULL(SUM(ledger.debit_equiv), 0), 2) AS debit,
ROUND(IFNULL(SUM(ledger.credit_equiv), 0),2) AS credit,
ROUND(IFNULL(SUM(ledger.debit_equiv - ledger.credit_equiv), 0),2) AS balance,
MIN(trans_date) AS since, MAX(trans_date) AS until
FROM (
SELECT debit_equiv, credit_equiv, entity_uuid, trans_date FROM posting_journal
WHERE entity_uuid = ? ${excludeCautionLinks ? excludeCautionLinkStatement : ''}
Expand Down

0 comments on commit b613b29

Please sign in to comment.