Skip to content

Commit

Permalink
Use positive values for liabilities
Browse files Browse the repository at this point in the history
  • Loading branch information
mbayopanda committed Oct 26, 2018
1 parent 903e73a commit fdd38cf
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .env.development
Expand Up @@ -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'
Expand Down
Expand Up @@ -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 = ?;
Expand All @@ -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]);
})
Expand Down
10 changes: 10 additions & 0 deletions server/controllers/finance/reports/ohada_balance_sheet/index.js
Expand Up @@ -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);
})
Expand Down

0 comments on commit fdd38cf

Please sign in to comment.