From fdd38cfa0a7f94149a407c19697510ab65d04bf4 Mon Sep 17 00:00:00 2001 From: mbayopanda Date: Fri, 26 Oct 2018 16:00:42 +0100 Subject: [PATCH] Use positive values for liabilities --- .env.development | 2 +- .../reports/ohada_balance_sheet/balanceSheetElement.js | 8 ++++---- .../finance/reports/ohada_balance_sheet/index.js | 10 ++++++++++ 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/.env.development b/.env.development index 3185a30a9b..ba8b588006 100644 --- a/.env.development +++ b/.env.development @@ -5,7 +5,7 @@ PORT=8080 DB_HOST='localhost' DB_USER='bhima' DB_PASS='HISCongo2013' -DB_NAME='imck' +DB_NAME='bhima_test' # session variables SESS_SECRET='XopEn BlowFISH' diff --git a/server/controllers/finance/reports/ohada_balance_sheet/balanceSheetElement.js b/server/controllers/finance/reports/ohada_balance_sheet/balanceSheetElement.js index 31c2cd242e..47bb0ef87c 100644 --- a/server/controllers/finance/reports/ohada_balance_sheet/balanceSheetElement.js +++ b/server/controllers/finance/reports/ohada_balance_sheet/balanceSheetElement.js @@ -122,8 +122,8 @@ function getFiscalYearDetails(fiscalYearId) { */ const queryDetails = ` SELECT - cur.id, cur.label AS current_fiscal_year, cur.start_date, cur.end_date, - pre.id AS previous_fiscal_id, pre.label AS previous_fiscal_year + cur.id, cur.label AS current_fiscal_year, cur.start_date, cur.end_date, cur.locked AS current_locked, + pre.id AS previous_fiscal_id, pre.label AS previous_fiscal_year, pre.locked AS previous_locked FROM fiscal_year cur LEFT JOIN fiscal_year pre ON pre.id = cur.previous_fiscal_year_id WHERE cur.id = ?; @@ -143,9 +143,9 @@ function getFiscalYearDetails(fiscalYearId) { .then((rows) => { /** * get details of the next fiscal year for totals, - * if the next fiscal yean doesn't exists use the selected fiscal year until its last period + * if the next fiscal year doesn't exists use the selected fiscal year until its last period */ - const nextFiscalYear = rows.length > 0 ? rows[0] : {}; + const nextFiscalYear = rows.length > 0 && bundle.details.current_locked === 1 ? rows[0] : {}; return nextFiscalYear.id ? db.one(query, [nextFiscalYear.id]) : db.one(queryTemporary, [fiscalYearId, fiscalYearId]); }) diff --git a/server/controllers/finance/reports/ohada_balance_sheet/index.js b/server/controllers/finance/reports/ohada_balance_sheet/index.js index 235e935a44..5efa71a9ab 100644 --- a/server/controllers/finance/reports/ohada_balance_sheet/index.js +++ b/server/controllers/finance/reports/ohada_balance_sheet/index.js @@ -235,6 +235,16 @@ function document(req, res, next) { return item; }); + /** + * liabilities have by default a creditor sold (negative value), + * in order to present them correctly to users they must be converted into positive + * values, so for doing that we will multiply them by -1 + */ + liabilityTable.forEach(item => { + item.currentNet *= -1; + item.previousNet *= -1; + }); + _.merge(context, { assetTable, liabilityTable }); return report.render(context); })