@datarailsshared/datarailsshared 1.4.304 → 1.4.305

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -445,11 +445,15 @@
445
445
  this.updateLockedDate();
446
446
  this.chosenTagHandler();
447
447
  };
448
+ ForecastTagComponent.prototype.isNeedToIncrementYear = function (dateObj, fiscalYearStartsFrom) {
449
+ return dateObj.month() + 1 >= fiscalYearStartsFrom;
450
+ };
448
451
  ForecastTagComponent.prototype.initDate = function () {
449
452
  var dateVal = this.defaultValue ? moment$8.unix(this.defaultValue) : moment$8();
450
453
  var fiscal_year_starts_from = this.fiscalYearStartsFrom || 1;
451
454
  var fiscal_year_back = this.fiscalYearBack || false;
452
455
  this.forecastValue = this.getFiscalMonthFromDate(dateVal, fiscal_year_starts_from) - 1;
456
+ this.initialForecastValue = this.forecastValue;
453
457
  var fiscal_year = this.getFiscalYearFromDate(dateVal, fiscal_year_starts_from, fiscal_year_back);
454
458
  this.updateYear(fiscal_year, this.forecastValue);
455
459
  this.updateLockedDate();
@@ -491,15 +495,18 @@
491
495
  return all_months.indexOf(dateObj.month() + 1) + 1;
492
496
  };
493
497
  ForecastTagComponent.prototype.getFiscalYearFromDate = function (dateObj, fiscal_year_starts_from, fiscal_year_back) {
498
+ var _a;
494
499
  var fiscal_year = dateObj.year();
495
- if (!fiscal_year_back) {
496
- if (dateObj.month() + 1 >= fiscal_year_starts_from && fiscal_year_starts_from !== 1) {
497
- fiscal_year += 1;
500
+ if (this.initialForecastValue !== this.forecastValue && !!((_a = this.dateObj) === null || _a === void 0 ? void 0 : _a.date) && dateObj.year() - moment$8.unix(this.defaultValue).year() < 1 && fiscal_year_starts_from !== 1) {
501
+ if (!fiscal_year_back) {
502
+ if (this.isNeedToIncrementYear(dateObj, fiscal_year_starts_from)) {
503
+ fiscal_year += 1;
504
+ }
498
505
  }
499
- }
500
- else {
501
- if (dateObj.month() + 1 < fiscal_year_starts_from && fiscal_year_starts_from !== 1) {
502
- fiscal_year -= 1;
506
+ else {
507
+ if (!this.isNeedToIncrementYear(dateObj, fiscal_year_starts_from)) {
508
+ fiscal_year -= 1;
509
+ }
503
510
  }
504
511
  }
505
512
  return fiscal_year;