/**
* Tax years basic info
* @module
* @since 0.1.0
*/
/**
* Create a designated number of tax years with year info
* @param {number} start_year Start year in XX format, e.g. 19 not 2019
* @param {number} cnt_years Number of years
* @returns {array} Array of basic tax years with just date info
*/
const createTaxYears = (start_year, cnt_years) => {
const arr_return = [];
const skv_start_year = {};
skv_start_year.year = start_year;
skv_start_year.year_short = `${skv_start_year.year - 1}${skv_start_year.year}`;
skv_start_year.year_slash = `${skv_start_year.year - 1}/${skv_start_year.year}`;
skv_start_year.year_text = `20${skv_start_year.year_slash}`;
for (let i = 0; i < cnt_years; i += 1) {
const num_tmp_year = skv_start_year.year + i;
const num_prev_year = num_tmp_year - 1;
const skv_year = {};
skv_year.tax_year = num_tmp_year.toString();
skv_year.year_short = `${num_prev_year}${num_tmp_year}`;
skv_year.year_slash = `${num_prev_year}/${num_tmp_year}`;
skv_year.year_text = `20${skv_year.year_slash}`;
arr_return.push(skv_year);
}
return arr_return;
};
/**
* Generates a human-friendly sentence describing the tax year
* @param {number} months_occupied Number of months the tax year covers
* @param {string} year_slash e.g 20/21
* @returns {string} Nice text
*/
const describeTaxYear = (months_occupied, year_slash) => {
let str_return = `${months_occupied} month`;
if (months_occupied > 1) {
str_return += 's';
}
str_return = `${str_return} of tax year ${year_slash}`;
return str_return;
};
export {
createTaxYears,
describeTaxYear,
};