date-fns#addMonths TypeScript Examples

The following examples show how to use date-fns#addMonths. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TimeFrameData.ts    From cashcash-desktop with MIT License 6 votes vote down vote up
state: ITimeFrameDataState = {
    parameters: {
        accountIdList: [],
        fromAccountIdList: [],
        toAccountIdList: [],
        currencyIdList: [],
        transactionTypeList: [],
        accountTypeList: [],
        tagIdList: [],
        createdDateFrom: undefined,
        createdDateTo: undefined,
        updatedDateFrom: undefined,
        updatedDateTo: undefined,
        transactionDateFrom: startOfDay(addMonths(DateUtils.newDate(), -6)),
        transactionDateTo: endOfDay(DateUtils.newDate()),
        searchString: undefined,
        detailSearchString: undefined,
        amountLessThan: undefined,
        amountGreaterThan: undefined,
    },

    splitList: [],
    splitSumList: [],
    activeAccountIdSet: new Set(),
    splitListValid: false,
    splitSumListValid: false,
}
Example #2
Source File: make-monthly-stat.ts    From merged-pr-stat with MIT License 6 votes vote down vote up
async function main(): Promise<void> {
  program.requiredOption("--start <yyyy/MM>").requiredOption("--end <yyyy/MM>").requiredOption("--query <query>");

  program.parse(process.argv);

  const startDate = parse(program.start, "yyyy/MM", new Date());
  const endDate = parse(program.end, "yyyy/MM", new Date());
  const query = program.query as string;

  const allStats = [];
  for (let start = startDate; start <= endDate; start = addMonths(start, 1)) {
    const end = add(start, { months: 1, seconds: -1 });
    console.error(format(start, "yyyy-MM-dd HH:mm:ss"));
    console.error(format(end, "yyyy-MM-dd HH:mm:ss"));

    const stdout = execFileSync(
      "merged-pr-stat",
      ["--start", start.toISOString(), "--end", end.toISOString(), "--query", query],
      { encoding: "utf8" }
    );
    const result = {
      startDate: format(start, "yyyy-MM-dd HH:mm:ss"),
      endDate: format(end, "yyyy-MM-dd HH:mm:ss"),
      ...JSON.parse(stdout),
    };
    allStats.push(result);
  }
  process.stdout.write(csvStringify(allStats, { header: true }));
}
Example #3
Source File: date.ts    From ngx-gantt with MIT License 6 votes vote down vote up
add(amount: number, unit?: GanttDateUtil) {
        switch (unit) {
            case 'second':
                return new GanttDate(this.value).addSeconds(amount);
            case 'minute':
                return new GanttDate(this.value).addMinutes(amount);
            case 'hour':
                return new GanttDate(this.value).addHours(amount);
            case 'day':
                return new GanttDate(this.value).addDays(amount);
            case 'week':
                return new GanttDate(this.value).addWeeks(amount);
            case 'month':
                return new GanttDate(this.value).addMonths(amount);
            case 'quarter':
                return new GanttDate(this.value).addQuarters(amount);
            case 'year':
                return new GanttDate(this.value).addYears(amount);
            default:
                return new GanttDate(this.value).addSeconds(amount);
        }
    }
Example #4
Source File: MonthlyCalendar.tsx    From react-calendar with MIT License 6 votes vote down vote up
MonthlyNav = () => {
  let { locale, currentMonth, onCurrentMonthChange } = useMonthlyCalendar();

  return (
    <div className="rc-flex rc-justify-end rc-mb-4">
      <button
        onClick={() => onCurrentMonthChange(subMonths(currentMonth, 1))}
        className="rc-cursor-pointer"
      >
        Previous
      </button>
      <div
        className="rc-ml-4 rc-mr-4 rc-w-32 rc-text-center"
        aria-label="Current Month"
      >
        {format(
          currentMonth,
          getYear(currentMonth) === getYear(new Date()) ? 'LLLL' : 'LLLL yyyy',
          { locale }
        )}
      </div>
      <button
        onClick={() => onCurrentMonthChange(addMonths(currentMonth, 1))}
        className="rc-cursor-pointer"
      >
        Next
      </button>
    </div>
  );
}
Example #5
Source File: dummyEvents.ts    From react-calendar with MIT License 6 votes vote down vote up
events: { [key: string]: EventType[] } = {
  firstMonth: [
    { title: 'Call John', date: subHours(new Date(), 2) },
    { title: 'Call John', date: subHours(new Date(), 1) },
    { title: 'Meeting with Bob', date: new Date() },
    { title: 'Bike Appt', date: addHours(new Date(), 3) },
    { title: 'John Hilmer', date: addDays(new Date(), 3) },
    { title: 'Jane Call', date: subDays(new Date(), 4) },
    { title: 'Sound alarm', date: addDays(new Date(), 6) },
    { title: 'Soccer Practice', date: subDays(new Date(), 3) },
    { title: 'Alert', date: addHours(subDays(new Date(), 4), 4) },
    { title: 'Donation', date: addDays(new Date(), 6) },
  ],
  secondMonth: [
    { title: 'Meeting Next Month', date: addMonths(new Date(), 1) },
  ],
}
Example #6
Source File: DayPicker.tsx    From symphony-ui-toolkit with Apache License 2.0 5 votes vote down vote up
focusOnlyEnabledCell(
    date: Date,
    action: 'next' | 'previous',
    maxStepCheck: number,
    needToChangeMonth = true
  ) {
    const { locale } = this.props;
    const index = date.getDate();
    if (index) {
      if (this.dayPicker) {
        const enabledCell = this.getEnabledCell(index, action, maxStepCheck);
        if (enabledCell) {
          enabledCell.focus();
        } else {
          if (needToChangeMonth) {
            // when called through arrow navigation
            // when changing month, focus the first available date, if exists
            const step = action === 'next' ? 1 : -1;
            const nextMonth = addMonths(date, step);
            this.setState({ currentMonth: nextMonth }, () => {
              // we need to use the callback to be sure the date picker is re-rendered with the new month
              const index = action === 'next' ? 1 : endOfMonth(nextMonth).getDate();
              const enabledCell = this.getEnabledCell(index, action, maxStepCheck);
              if (enabledCell) {
                enabledCell.focus();
              } else {
                // if all cell are disabled, focus the first day of month
                this.focusCell(
                  getBoundedDay(startOfMonth(nextMonth), nextMonth, locale)
                );
              }
            });
          } else {
            // when called through ARROWS navigation
            this.focusCell(getBoundedDay(startOfMonth(date), date, locale));
          }
        }
      }
    }
  }
Example #7
Source File: DayPicker.tsx    From symphony-ui-toolkit with Apache License 2.0 5 votes vote down vote up
handleKeyDownCell(e: React.KeyboardEvent, date: Date, modifers): void {
    const { locale, dir } = this.props;
    const { currentMonth } = this.state;
    if (e.key !== Keys.ESC) {
      cancelEvent(e);
    }

    const direction = dir === 'ltr' ? 1 : -1;
    const MAX_STEP_TO_CHECK = 7;
    let nextCell;
    switch (e.key) {
    case Keys.TAB:
      if (this.dayPicker) {
        if (e.shiftKey) {
          this.dayPicker
            .querySelector('.tk-daypicker-header--nextYear')
            .focus();
        } else {
          this.dayPicker.querySelector('.tk-daypicker-today').focus();
        }
      }
      break;
    case Keys.SPACE:
    case Keys.SPACEBAR:
    case Keys.ENTER:
      // eslint-disable-next-line no-case-declarations
      const { onDayClick } = this.props;
      onDayClick(date, modifers);
      break;
    case Keys.PAGE_UP:
      if (e.shiftKey) {
        this.monthNavigation(date, addYears(currentMonth, -1));
      } else {
        this.monthNavigation(date, addMonths(currentMonth, -1));
      }
      break;
    case Keys.PAGE_DOWN:
      if (e.shiftKey) {
        this.monthNavigation(date, addYears(currentMonth, 1));
      } else {
        this.monthNavigation(date, addMonths(currentMonth, 1));
      }
      break;
    case Keys.HOME:
      // eslint-disable-next-line no-case-declarations
      const firstDayOfWeek = startOfWeek(date, { locale });
      nextCell =
          firstDayOfWeek.getDate() <= date.getDate()
            ? firstDayOfWeek
            : startOfMonth(date);
      this.focusOnlyEnabledCell(nextCell, 'next', MAX_STEP_TO_CHECK);
      break;
    case Keys.END:
      // eslint-disable-next-line no-case-declarations
      const lastDayOfWeek = endOfWeek(date, { locale });
      nextCell =
          date.getDate() <= lastDayOfWeek.getDate()
            ? lastDayOfWeek
            : lastDayOfMonth(date);
      this.focusOnlyEnabledCell(nextCell, 'previous', MAX_STEP_TO_CHECK);
      break;
    case Keys.ARROW_LEFT:
      this.arrowNavigation(date, addDays(date, -1 * direction));
      break;
    case Keys.ARROW_UP:
      this.arrowNavigation(date, addDays(date, -7));
      break;
    case Keys.ARROW_RIGHT:
      this.arrowNavigation(date, addDays(date, 1 * direction));
      break;
    case Keys.ARROW_DOWN:
      this.arrowNavigation(date, addDays(date, 7));
      break;
    default:
      break;
    }
  }
Example #8
Source File: dateUtils.ts    From ant-extensions with MIT License 5 votes vote down vote up
parseDate = (dt?: string, rounded?: "start" | "end"): ParsedDate => {
  if (dt && isDate(dt)) {
    return parseISO(dt);
  } else if (dt && isDateLike(dt)) {
    const parts = getDateParts(dt);

    if (parts) {
      const { part, op, diff } = parts;
      const diffNum = parseInt(`${op}${diff}`, 10);
      let date = startOfMinute(new Date());

      switch (part) {
        case DateParts.NOW:
          return date;
        case DateParts.DECADE:
          if (rounded) {
            date = (rounded === "start" ? startOfDecade : endOfDecade)(date);
          }
          return addYears(date, diffNum * 10);
        case DateParts.YEAR:
          if (rounded) {
            date = (rounded === "start" ? startOfYear : endOfYear)(date);
          }
          return addYears(date, diffNum);
        case DateParts.QUARTER:
          if (rounded) {
            date = (rounded === "start" ? startOfQuarter : endOfQuarter)(date);
          }
          return addQuarters(date, diffNum);
        case DateParts.MONTH:
          if (rounded) {
            date = (rounded === "start" ? startOfMonth : endOfMonth)(date);
          }
          return addMonths(date, diffNum);
        case DateParts.WEEK:
          if (rounded) {
            date = (rounded === "start" ? startOfWeek : endOfWeek)(date);
          }
          return addWeeks(date, diffNum);
        case DateParts.DAY:
          if (rounded) {
            date = (rounded === "start" ? startOfDay : endOfDay)(date);
          }
          return addDays(date, diffNum);
        case DateParts.HOUR:
          if (rounded) {
            date = (rounded === "start" ? startOfHour : endOfHour)(date);
          }
          return addHours(date, diffNum);
        case DateParts.MINUTE:
          if (rounded) {
            date = (rounded === "start" ? startOfMinute : endOfMinute)(date);
          }
          return addMinutes(date, diffNum);
      }
    }
  }
  return undefined;
}
Example #9
Source File: DatePicker.stories.tsx    From gio-design with Apache License 2.0 5 votes vote down vote up
StaticViewDate.args = {
  viewDate: addMonths(startOfToday(), 1),
};
Example #10
Source File: ngx-mat-datefns-date-adapter.ts    From ngx-mat-datefns-date-adapter with MIT License 5 votes vote down vote up
addCalendarMonths(date: Date, months: number): Date {
    return addMonths(date, months);
  }
Example #11
Source File: date.ts    From ngx-gantt with MIT License 5 votes vote down vote up
addMonths(amount: number): GanttDate {
        return new GanttDate(addMonths(this.value, amount));
    }
Example #12
Source File: Header.tsx    From symphony-ui-toolkit with Apache License 2.0 4 votes vote down vote up
Header: FunctionComponent<HeaderProps> = ({ date, dir, labels, months, onChange, parentRef }) => {
  const changeYear = (amount: number) => {
    onChange(addYears(date, amount));
  };

  const changeMonth = (amount: number) => {
    onChange(addMonths(date, amount));
  };

  /**
   * Change the behaviour of 'Tab' and 'Shift + Tab' event of an html element
   * Used to allow loop navigation "'Today Button' --> Header (<<) --> Header (<)"
   */
  const ajustLoopNavigation = (event) => {
    if (!parentRef) {
      return;
    }
    if (event.key === Keys.TAB) {
      cancelEvent(event);
      if (event.shiftKey) {
        const elClassPrevious = parentRef.querySelector('.tk-daypicker-today');
        if (elClassPrevious) {
          elClassPrevious.focus();
        }
      } else {
        const elClassNext = parentRef.querySelector(
          '.tk-daypicker-header--prevMonth'
        );
        if (elClassNext) {
          elClassNext.focus();
        }
      }
    }
  };

  const textHeader = `${months[date.getMonth()]} ${date.getFullYear()}`;
  return (
    <div
      className="tk-daypicker-header"
      role="heading"
      style={{ direction: dir }}
    >
      <div>
        <button
          aria-label={labels.previousYear}
          className="tk-daypicker-header--prevYear"
          onClick={() => changeYear(-1)}
          onKeyDown={ajustLoopNavigation}
        >
          <Icon
            iconName={dir === 'rtl' ? 'chevron-right' : 'chevron-left'}
          ></Icon>
        </button>
        <button
          aria-label={labels.previousMonth}
          className="tk-daypicker-header--prevMonth"
          onClick={() => changeMonth(-1)}
        >
          <Icon iconName={dir === 'rtl' ? 'right' : 'left'}></Icon>
        </button>
      </div>
      <div className="tk-daypicker-header--text">{textHeader}</div>
      <div>
        <button
          aria-label={labels.nextMonth}
          className="tk-daypicker-header--nextMonth"
          onClick={() => changeMonth(1)}
        >
          <Icon iconName={dir === 'rtl' ? 'left' : 'right'}></Icon>
        </button>
        <button
          aria-label={labels.nextYear}
          className="tk-daypicker-header--nextYear"
          onClick={() => changeYear(1)}
        >
          <Icon
            iconName={dir === 'rtl' ? 'chevron-left' : 'chevron-right'}
          ></Icon>
        </button>
      </div>
    </div>
  );
}
Example #13
Source File: MockService.ts    From cashcash-desktop with MIT License 4 votes vote down vote up
async addMockData() {
        if (process.env.NODE_ENV === 'development') {
            const mockInputArray = [
                {
                    outAccount: i18n.t('Wages and salarie'),
                    inAccount: i18n.t('Checking account'),
                    amount: 1150,
                    transactionDay: 3,
                },
                {
                    outAccount: i18n.t('Cash gifts received'),
                    inAccount: i18n.t('Checking account'),
                    amount: 80,
                    probablity: 0.1,
                    valueVariability: 80 * 0.5,
                },
                {
                    outAccount: i18n.t('Checking account'),
                    inAccount: i18n.t('Clothing'),
                    amount: 1566 / 12,
                    probablity: 0.5,
                    valueVariability: (1566 / 12) * 0.5,
                },
                {
                    outAccount: i18n.t('Checking account'),
                    inAccount: i18n.t('Footwear'),
                    amount: 391 / 12,
                    probablity: 0.3,
                    valueVariability: (391 / 12) * 0.8,
                },
                {
                    outAccount: i18n.t('Checking account'),
                    inAccount: i18n.t('Other clothing products and services'),
                    amount: 221 / 12,
                    probablity: 0.3,
                    valueVariability: (221 / 12) * 0.99,
                },
                {
                    outAccount: i18n.t('Checking account'),
                    inAccount: i18n.t('School books and supplies'),
                    amount: 56 / 12,
                    probablity: 0.8,
                    valueVariability: (56 / 12) * 0.5,
                },
                {
                    outAccount: i18n.t('Checking account'),
                    inAccount: i18n.t('Tuition'),
                    amount: 798 / 12,
                    probablity: 0.3,
                    valueVariability: (798 / 12) * 0.5,
                },
                {
                    outAccount: i18n.t('Checking account'),
                    inAccount: i18n.t('Television/cable services'),
                    amount: 672 / 12,
                    valueVariability: 672 / 12,
                },
                {
                    outAccount: i18n.t('Checking account'),
                    inAccount: i18n.t('Musical instruments'),
                    amount: 33 / 12,
                    probablity: 0.2,
                    valueVariability: (33 / 12) * 0.8,
                },
                {
                    outAccount: i18n.t('Checking account'),
                    inAccount: i18n.t('Video game and services'),
                    amount: 14 / 12,
                    probablity: 0.4,
                    valueVariability: (14 / 12) * 0.5,
                },
                {
                    outAccount: i18n.t('Checking account'),
                    inAccount: i18n.t('Streaming video services'),
                    amount: 50 / 12,
                    probablity: 0.8,
                    valueVariability: (50 / 12) * 1,
                },
                {
                    outAccount: i18n.t('Checking account'),
                    inAccount: i18n.t('Streaming audio services'),
                    amount: 11 / 12,
                    probablity: 0.8,
                    valueVariability: (11 / 12) * 0.5,
                },
                {
                    outAccount: i18n.t('Checking account'),
                    inAccount: i18n.t('Television and sound equipments'),
                    amount: 89 / 12,
                    probablity: 0.8,
                    valueVariability: (89 / 12) * 0.5,
                },
                {
                    outAccount: i18n.t('Checking account'),
                    inAccount: i18n.t('Video game and services'),
                    amount: 43 / 12,
                    probablity: 0.8,
                    valueVariability: (43 / 12) * 0.5,
                },
                {
                    outAccount: i18n.t('Checking account'),
                    inAccount: i18n.t('Sporting events'),
                    amount: 50 / 12,
                    probablity: 0.2,
                    valueVariability: (50 / 12) * 0.9,
                },
                {
                    outAccount: i18n.t('Checking account'),
                    inAccount: i18n.t('Sport/Gym subscription'),
                    amount: 198 / 12,
                    probablity: 0.8,
                    valueVariability: (198 / 12) * 0.5,
                },
                {
                    outAccount: i18n.t('Checking account'),
                    inAccount: i18n.t('Recreational lessons'),
                    amount: 113 / 12,
                    probablity: 0.8,
                    valueVariability: (113 / 12) * 0.5,
                },
                {
                    outAccount: i18n.t('Checking account'),
                    inAccount: i18n.t('Play, theater, opera'),
                    amount: 66 / 12,
                    probablity: 0.8,
                    valueVariability: (66 / 12) * 0.5,
                },
                {
                    outAccount: i18n.t('Checking account'),
                    inAccount: i18n.t('Movies'),
                    amount: 48 / 12,
                    probablity: 0.8,
                    valueVariability: (48 / 12) * 0.5,
                },
                {
                    outAccount: i18n.t('Checking account'),
                    inAccount: i18n.t('Parks or museums'),
                    amount: 26 / 12,
                    probablity: 0.8,
                    valueVariability: (26 / 12) * 0.5,
                },
                {
                    outAccount: i18n.t('Checking account'),
                    inAccount: i18n.t('Photographic equipment'),
                    amount: 40 / 12,
                    probablity: 0.8,
                    valueVariability: (40 / 12) * 0.5,
                },
                {
                    outAccount: i18n.t('Checking account'),
                    inAccount: i18n.t('Pet food'),
                    amount: 219 / 12,
                    probablity: 0.8,
                    valueVariability: (219 / 12) * 0.5,
                },
                {
                    outAccount: i18n.t('Checking account'),
                    inAccount: i18n.t('Pet purchase, supplies, medicine'),
                    amount: 150 / 12,
                    probablity: 0.8,
                    valueVariability: (150 / 12) * 0.5,
                },
                {
                    outAccount: i18n.t('Checking account'),
                    inAccount: i18n.t('Pet services'),
                    amount: 66 / 12,
                    probablity: 0.8,
                    valueVariability: (66 / 12) * 0.5,
                },
                {
                    outAccount: i18n.t('Checking account'),
                    inAccount: i18n.t('Vet services'),
                    amount: 225 / 12,
                    probablity: 0.8,
                    valueVariability: (225 / 12) * 0.5,
                },
                {
                    outAccount: i18n.t('Checking account'),
                    inAccount: i18n.t('Toys, arts and crafts'),
                    amount: 148 / 12,
                    probablity: 0.8,
                    valueVariability: (148 / 12) * 0.5,
                },
                {
                    outAccount: i18n.t('Checking account'),
                    inAccount: i18n.t('E-Books'),
                    amount: 24 / 12,
                    probablity: 0.8,
                    valueVariability: (24 / 12) * 0.5,
                },
                {
                    outAccount: i18n.t('Checking account'),
                    inAccount: i18n.t('Newspapers/Magazines'),
                    amount: 53 / 12,
                    probablity: 0.8,
                    valueVariability: (53 / 12) * 0.5,
                },
                {
                    outAccount: i18n.t('Checking account'),
                    inAccount: i18n.t('Bar'),
                    amount: 289 / 12,
                    probablity: 0.8,
                    valueVariability: (289 / 12) * 0.5,
                },
                {
                    outAccount: i18n.t('Checking account'),
                    inAccount: i18n.t('Market'),
                    amount: 1200 / 12,
                    probablity: 0.8,
                    valueVariability: (1200 / 12) * 0.5,
                },
                {
                    outAccount: i18n.t('Checking account'),
                    inAccount: i18n.t('Restaurant'),
                    amount: 3458 / 12,
                    probablity: 0.8,
                    valueVariability: (3458 / 12) * 0.5,
                },
                {
                    outAccount: i18n.t('Checking account'),
                    inAccount: i18n.t('Supermarket'),
                    amount: 3200 / 12,
                    probablity: 0.8,
                    valueVariability: (3200 / 12) * 0.5,
                },
                {
                    outAccount: i18n.t('Checking account'),
                    inAccount: i18n.t('Drugs'),
                    amount: 483 / 12,
                    probablity: 0.8,
                    valueVariability: (483 / 12) * 0.5,
                },
                {
                    outAccount: i18n.t('Checking account'),
                    inAccount: i18n.t('Commercial health insurance'),
                    amount: 662 / 12,
                    probablity: 0.8,
                    valueVariability: (662 / 12) * 0.5,
                },
                {
                    outAccount: i18n.t('Checking account'),
                    inAccount: i18n.t('Medical services'),
                    amount: 1566 / 12,
                    probablity: 0.8,
                    valueVariability: (1566 / 12) * 0.5,
                },
                {
                    outAccount: i18n.t('Checking account'),
                    inAccount: i18n.t('Medical supplies'),
                    amount: 171 / 12,
                    probablity: 0.8,
                    valueVariability: (171 / 12) * 0.5,
                },
                {
                    outAccount: i18n.t('Checking account'),
                    inAccount: i18n.t('Furniture'),
                    amount: 2024 / 12,
                    probablity: 0.8,
                    valueVariability: (2024 / 12) * 0.5,
                },
                {
                    outAccount: i18n.t('Checking account'),
                    inAccount: i18n.t('Other household expenses'),
                    amount: 1050 / 12,
                    probablity: 0.8,
                    valueVariability: (1050 / 12) * 0.5,
                },
                {
                    outAccount: i18n.t('Checking account'),
                    inAccount: i18n.t('Medical services'),
                    amount: 908 / 12,
                    probablity: 0.8,
                    valueVariability: (908 / 12) * 0.5,
                },
                {
                    outAccount: i18n.t('Checking account'),
                    inAccount: i18n.t('Babysitting'),
                    amount: 100 / 12,
                    probablity: 0.8,
                    valueVariability: (100 / 12) * 0.5,
                },
                {
                    outAccount: i18n.t('Checking account'),
                    inAccount: i18n.t('Insurance (Housing)'),
                    amount: 467 / 12,
                    probablity: 0.8,
                    valueVariability: (467 / 12) * 0.5,
                },
                {
                    outAccount: i18n.t('Checking account'),
                    inAccount: i18n.t('Repair commodities (Housing)'),
                    amount: 26 / 12,
                    probablity: 0.8,
                    valueVariability: (26 / 12) * 0.5,
                },
                {
                    outAccount: i18n.t('Checking account'),
                    inAccount: i18n.t('Repair services (Housing)'),
                    amount: 55 / 12,
                    probablity: 0.8,
                    valueVariability: (55 / 12) * 0.5,
                },
                {
                    outAccount: i18n.t('Checking account'),
                    inAccount: i18n.t('Rent'),
                    amount: 4057 / 12,
                },
                {
                    outAccount: i18n.t('Checking account'),
                    inAccount: i18n.t('Electricity'),
                    amount: 1496 / 12,
                    probablity: 0.8,
                    valueVariability: (1496 / 12) * 0.5,
                },
                {
                    outAccount: i18n.t('Checking account'),
                    inAccount: i18n.t('Natural gas'),
                    amount: 409 / 12,
                    probablity: 0.8,
                    valueVariability: (1566 / 12) * 0.5,
                },
                {
                    outAccount: i18n.t('Checking account'),
                    inAccount: i18n.t('Garbage collection'),
                    amount: 162 / 12,
                    probablity: 0.8,
                    valueVariability: (162 / 12) * 0.5,
                },
                {
                    outAccount: i18n.t('Checking account'),
                    inAccount: i18n.t('Water'),
                    amount: 445 / 12,
                    probablity: 0.8,
                    valueVariability: (445 / 12) * 0.5,
                },
                {
                    outAccount: i18n.t('Checking account'),
                    inAccount: i18n.t('Bank service charges'),
                    amount: 25 / 12,
                    probablity: 0.8,
                    valueVariability: (25 / 12) * 0.5,
                },
                {
                    outAccount: i18n.t('Checking account'),
                    inAccount: i18n.t('Personal care products'),
                    amount: 395 / 12,
                    probablity: 0.8,
                    valueVariability: (395 / 12) * 0.5,
                },
                {
                    outAccount: i18n.t('Checking account'),
                    inAccount: i18n.t('Personal care services'),
                    amount: 372 / 12,
                    probablity: 0.8,
                    valueVariability: (372 / 12) * 0.5,
                },
                {
                    outAccount: i18n.t('Checking account'),
                    inAccount: i18n.t('Gasoline and other fuels'),
                    amount: 2108 / 12,
                    probablity: 0.8,
                    valueVariability: (2108 / 12) * 0.5,
                },
                {
                    outAccount: i18n.t('Checking account'),
                    inAccount: i18n.t('Vehicle maintenance'),
                    amount: 889 / 12,
                    probablity: 0.8,
                    valueVariability: (889 / 12) * 0.5,
                },
                {
                    outAccount: i18n.t('Checking account'),
                    inAccount: i18n.t('Vehicle insurance'),
                    amount: 976 / 12,
                    probablity: 0.8,
                    valueVariability: (976 / 12) * 0.5,
                },
                {
                    outAccount: i18n.t('Checking account'),
                    inAccount: i18n.t('Parking fees'),
                    amount: 56 / 12,
                    probablity: 0.8,
                    valueVariability: (56 / 12) * 0.5,
                },
                {
                    outAccount: i18n.t('Checking account'),
                    inAccount: i18n.t('Tolls passes'),
                    amount: 48 / 12,
                    probablity: 0.8,
                    valueVariability: (48 / 12) * 0.5,
                },
                {
                    outAccount: i18n.t('Checking account'),
                    inAccount: i18n.t('Airline fares'),
                    amount: 500 / 12,
                    probablity: 0.8,
                    valueVariability: (500 / 12) * 0.5,
                },
                {
                    outAccount: i18n.t('Checking account'),
                    inAccount: i18n.t('Intercity bus/train fares'),
                    amount: 89 / 12,
                    probablity: 0.8,
                    valueVariability: (89 / 12) * 0.5,
                },
                {
                    outAccount: i18n.t('Checking account'),
                    inAccount: i18n.t('Intracity bus/train/metro fares'),
                    amount: 211 / 12,
                    probablity: 0.8,
                    valueVariability: (211 / 12) * 0.5,
                },
                {
                    outAccount: i18n.t('Checking account'),
                    inAccount: i18n.t('Taxi fares'),
                    amount: 71 / 12,
                    probablity: 0.8,
                    valueVariability: (71 / 12) * 0.5,
                },
            ];

            const now = startOfMonth(new Date());
            const nowMinus24month = addMonths(now, -24);

            let currentMonth = now;

            const cashAccountService = Container.get(CashAccountService);
            const cashTransactionService = Container.get(CashTransactionService);
            while (isAfter(currentMonth, nowMinus24month)) {
                for (const oneMockInput of mockInputArray) {
                    if (!oneMockInput.probablity || Math.random() < oneMockInput.probablity) {
                        let transactionDate = new Date(currentMonth);
                        if (oneMockInput.transactionDay) {
                            transactionDate = setDate(transactionDate, oneMockInput.transactionDay);
                        } else {
                            transactionDate = faker.date.between(
                                startOfMonth(currentMonth),
                                endOfMonth(currentMonth),
                            );
                        }
                        let amount;
                        if (oneMockInput.valueVariability) {
                            const fromValue = Math.max(
                                1,
                                oneMockInput.amount - oneMockInput.valueVariability,
                            );
                            const toValue = oneMockInput.amount - oneMockInput.valueVariability;
                            amount = this.getRandomNumber(fromValue, toValue);
                        } else {
                            amount = oneMockInput.amount;
                        }

                        const inAccount = await cashAccountService.find(
                            oneMockInput.inAccount.toString(),
                        );
                        if (!inAccount) {
                            throw new Error(`Account not found: ${oneMockInput.inAccount}`);
                        }
                        const outAccount = await cashAccountService.find(
                            oneMockInput.outAccount.toString(),
                        );
                        if (!outAccount) {
                            throw new Error(`Account not found: ${oneMockInput.outAccount}`);
                        }
                        const flatCashTransaction: FlatCashTransaction = new FlatCashTransaction({
                            description: `${faker.commerce.product()} from ${faker.company.companyName()}`,
                            detail: faker.lorem.sentence(3),
                            transactionDate,
                            currency: inAccount.currency,
                            amount,
                            inAccount,
                            outAccount,
                            type:
                                inAccount.type === CashAccountType.ASSET
                                    ? CashTransactionType.INCOME
                                    : CashTransactionType.EXPENSE,
                        });
                        await cashTransactionService.save(flatCashTransaction);
                        // tslint:disable-next-line:no-console
                        console.log('Transaction created');
                    }
                }
                currentMonth = addMonths(currentMonth, -1);
            }
        }
    }