@optimiser/common 1.0.299 → 1.0.300

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.
Files changed (2) hide show
  1. package/dist/lib/helper.js +20 -4
  2. package/package.json +1 -1
@@ -405,7 +405,7 @@ var GetDateRangeFromOperatorValue = function (operator, fiscalMonth, fiscalFrom)
405
405
  var momentObj = moment_1.default();
406
406
  var getFiscalMonthIndex = moment_1.default.monthsShort().findIndex(function (month) { return month === fiscalMonth; });
407
407
  // GET FISCAL MONTH INDEX
408
- if (operator.includes("Fiscal")) {
408
+ if (operator.includes("Fiscal") || ["Year to Date", "year-to-date"].includes(operator)) {
409
409
  if (fiscalFrom === "End") {
410
410
  fiscalMonth = momentObj.clone().month(fiscalMonth).add(1, "months").format('MMM'); // Modify FiscalMonth in FiscalFrom - End
411
411
  }
@@ -657,11 +657,27 @@ var GetDateRangeFromOperatorValue = function (operator, fiscalMonth, fiscalFrom)
657
657
  case "Year to Date":
658
658
  case "year-to-date":
659
659
  endDate = momentObj.clone().format(requiredDateFormat);
660
- if (parseInt(momentObj.format('M')) > 3) {
661
- startDate = momentObj.clone().startOf('month').month("Apr").format(requiredDateFormat);
660
+ // Commented Below Hanisha's Code - Implemented following as per QPC-6370
661
+ // if (parseInt(momentObj.format('M')) > 3) {
662
+ // startDate = momentObj.clone().startOf('month').month("Apr").format(requiredDateFormat);
663
+ // } else {
664
+ // startDate = momentObj.clone().subtract(1, "years").startOf('month').month("Apr").format(requiredDateFormat);
665
+ // }
666
+ if (fiscalFrom === "Start") {
667
+ if (getFiscalMonthIndex == 0 || getFiscalMonthIndex && getFiscalMonthIndex <= momentObj.clone().month()) {
668
+ startDate = moment_1.default(startDate, currentDateFormat).clone().month(fiscalMonth).startOf('month').format(requiredDateFormat);
669
+ }
670
+ else {
671
+ startDate = moment_1.default(startDate, currentDateFormat).clone().month(fiscalMonth).subtract(12, "months").startOf('month').format(requiredDateFormat);
672
+ }
662
673
  }
663
674
  else {
664
- startDate = momentObj.clone().subtract(1, "years").startOf('month').month("Apr").format(requiredDateFormat);
675
+ if (getFiscalMonthIndex == 0 || getFiscalMonthIndex && getFiscalMonthIndex < momentObj.clone().month() || getFiscalMonthIndex == 11) {
676
+ startDate = moment_1.default(startDate, currentDateFormat).clone().month(fiscalMonth).startOf('month').format(requiredDateFormat);
677
+ }
678
+ else {
679
+ startDate = moment_1.default(startDate, currentDateFormat).clone().month(fiscalMonth).subtract(12, "months").startOf('month').format(requiredDateFormat);
680
+ }
665
681
  }
666
682
  break;
667
683
  default:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optimiser/common",
3
- "version": "1.0.299",
3
+ "version": "1.0.300",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {