Skip to content

Commit

Permalink
feat(server fiscal controller) get fiscal year by period id function
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremielodi committed Aug 7, 2018
1 parent 331ba68 commit c762285
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 c762285

Please sign in to comment.