<commit_before>/**
 * Process overview data
 */

import { List as list, Map as map, fromJS } from 'immutable';

import { AVERAGE_MEDIAN, AVERAGE_EXP, MONTHS_SHORT, OVERVIEW_COLUMNS } from '../misc/const';
import { FUTURE_INVESTMENT_RATE } from '../misc/config';
import { yearMonthDifference, monthDays } from '../misc/date';
import { getKeyFromYearMonth, getYearMonthFromKey, listAverage, randnBm } from '../misc/data';
import { getOverviewCategoryColor, getOverviewScoreColor } from '../misc/color';

/**
 * Calculate futures from past averages / predictions
 * @param {list} cost: processed cost data
 * @param {list} futureCategories: categories to process
 * @param {integer} futureMonths: number of months going into the future
 * @param {integer} futureKey: key to separate between past/present and future
 * @returns {list} first six columns of data for overview table
 */
function calculateFutures(cost, futureCategories, futureMonths, futureKey, now = new Date()) {
    if (futureMonths <= 0) {
        return cost;
    }

    const currentMonthRatio = monthDays(now.getMonth() + 1, now.getFullYear()) / now.getDate();

    return cost.map((categoryCost, category) => {
        if (!futureCategories.includes(category)) {
            return categoryCost;
        }

        if (category === 'funds') {
            // randomly generate fund income projections<commit_msg>Use set date to calculate test future predictions<commit_after>/**
 * Process overview data
 */

import { List as list, Map as map, fromJS } from 'immutable';

import { AVERAGE_MEDIAN, AVERAGE_EXP, MONTHS_SHORT, OVERVIEW_COLUMNS } from '../misc/const';
import { FUTURE_INVESTMENT_RATE } from '../misc/config';
import { yearMonthDifference, monthDays } from '../misc/date';
import { getKeyFromYearMonth, getYearMonthFromKey, listAverage, randnBm } from '../misc/data';
import { getOverviewCategoryColor, getOverviewScoreColor } from '../misc/color';

/**
 * Calculate futures from past averages / predictions
 * @param {list} cost: processed cost data
 * @param {list} futureCategories: categories to process
 * @param {integer} futureMonths: number of months going into the future
 * @param {integer} futureKey: key to separate between past/present and future
 * @returns {list} first six columns of data for overview table
 */
function calculateFutures(cost, futureCategories, futureMonths, futureKey) {
    if (futureMonths <= 0) {
        return cost;
    }

    let now = new Date();
    if (process.env.NODE_ENV === 'test') {
        now = new Date('2018-01-22');
    }

    const currentMonthRatio = monthDays(now.getMonth() + 1, now.getFullYear()) / now.getDate();

    return cost.map((categoryCost, category) => {
        if (!futureCategories.includes(category)) {
            return categoryCost;
        }

        if (category === 'funds') {
            // randomly generate fund income projections
{'fraction_non_alphanumeric': 0.11799307958477509, 'fraction_numerical': 0.004152249134948097, 'mean_word_length': 3.754934210526316, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6702921', 'n_tokens_mistral': 849, 'n_tokens_neox': 798, 'n_words': 261}