Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
3007: feat(server fiscal controller) get fiscal year by period id function r=jniles a=jeremielodi

closes IMA-WorldHealth#2995

Co-authored-by: jeremielodi <jeremielodi@gmail.com>
  • Loading branch information
bors[bot] and jeremielodi committed Aug 9, 2018
2 parents a68373b + c762285 commit 2ffe6b5
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions server/controllers/finance/fiscal.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ exports.getDateRangeFromPeriods = getDateRangeFromPeriods;
exports.getPeriodsFromDateRange = getPeriodsFromDateRange;
exports.getAccountBalancesByTypeId = getAccountBalancesByTypeId;
exports.getOpeningBalance = getOpeningBalance;
exports.getFiscalYearByPeriodId = getFiscalYearByPeriodId;

/**
* @method lookupFiscalYear
Expand All @@ -67,6 +68,21 @@ function lookupFiscalYear(id) {
return db.one(sql, [id], id, 'fiscal year');
}


function getFiscalYearByPeriodId(periodId) {
const sql = `
SELECT id, enterprise_id, number_of_months, label, start_date, end_date,
previous_fiscal_year_id, locked, note
FROM fiscal_year
WHERE id IN (
SELECT fiscal_year_id FROM period WHERE id = ?
);
`;

return db.one(sql, periodId);
}


/**
* @method list
*
Expand Down

0 comments on commit 2ffe6b5

Please sign in to comment.