@optimiser/common 1.0.303 → 1.0.304

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 +22 -20
  2. package/package.json +1 -1
@@ -405,8 +405,8 @@ 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")) {
409
- // if (operator.includes("Fiscal") || ["Year to Date","year-to-date"].includes(operator)) {
408
+ // if (operator.includes("Fiscal")) {
409
+ if (operator.toLowerCase().includes("fiscal") || ["Year to Date", "year-to-date"].includes(operator)) {
410
410
  if (fiscalFrom === "End") {
411
411
  fiscalMonth = momentObj.clone().month(fiscalMonth).add(1, "months").format('MMM'); // Modify FiscalMonth in FiscalFrom - End
412
412
  }
@@ -595,7 +595,7 @@ var GetDateRangeFromOperatorValue = function (operator, fiscalMonth, fiscalFrom)
595
595
  }
596
596
  break;
597
597
  case "This Fiscal Year":
598
- case "this-fiscal-quarter":
598
+ case "this-fiscal-year":
599
599
  if (fiscalFrom === "Start") {
600
600
  if (getFiscalMonthIndex == 0 || getFiscalMonthIndex && getFiscalMonthIndex <= momentObj.clone().month()) {
601
601
  startDate = moment_1.default(startDate, currentDateFormat).clone().month(fiscalMonth).startOf('month').format(requiredDateFormat);
@@ -618,7 +618,7 @@ var GetDateRangeFromOperatorValue = function (operator, fiscalMonth, fiscalFrom)
618
618
  }
619
619
  break;
620
620
  case "Next Fiscal Year":
621
- case "next-fiscal-quarter":
621
+ case "next-fiscal-year":
622
622
  if (fiscalFrom === "Start") {
623
623
  if (getFiscalMonthIndex == 0 || getFiscalMonthIndex && getFiscalMonthIndex <= momentObj.clone().month()) {
624
624
  startDate = moment_1.default(startDate, currentDateFormat).clone().month(fiscalMonth).add(1, "years").startOf('month').format(requiredDateFormat);
@@ -659,25 +659,27 @@ var GetDateRangeFromOperatorValue = function (operator, fiscalMonth, fiscalFrom)
659
659
  case "year-to-date":
660
660
  endDate = momentObj.clone().format(requiredDateFormat);
661
661
  // Commented Below Hanisha's Code - Implemented following as per QPC-6370
662
- if (parseInt(momentObj.format('M')) > 3) {
663
- startDate = momentObj.clone().startOf('month').month("Apr").format(requiredDateFormat);
662
+ // if (parseInt(momentObj.format('M')) > 3) {
663
+ // startDate = momentObj.clone().startOf('month').month("Apr").format(requiredDateFormat);
664
+ // } else {
665
+ // startDate = momentObj.clone().subtract(1, "years").startOf('month').month("Apr").format(requiredDateFormat);
666
+ // }
667
+ if (fiscalFrom === "Start") {
668
+ if (getFiscalMonthIndex == 0 || getFiscalMonthIndex && getFiscalMonthIndex <= momentObj.clone().month()) {
669
+ startDate = moment_1.default(startDate, currentDateFormat).clone().month(fiscalMonth).startOf('month').format(requiredDateFormat);
670
+ }
671
+ else {
672
+ startDate = moment_1.default(startDate, currentDateFormat).clone().month(fiscalMonth).subtract(12, "months").startOf('month').format(requiredDateFormat);
673
+ }
664
674
  }
665
675
  else {
666
- startDate = momentObj.clone().subtract(1, "years").startOf('month').month("Apr").format(requiredDateFormat);
676
+ if (getFiscalMonthIndex == 0 || getFiscalMonthIndex && getFiscalMonthIndex < momentObj.clone().month() || getFiscalMonthIndex == 11) {
677
+ startDate = moment_1.default(startDate, currentDateFormat).clone().month(fiscalMonth).startOf('month').format(requiredDateFormat);
678
+ }
679
+ else {
680
+ startDate = moment_1.default(startDate, currentDateFormat).clone().month(fiscalMonth).subtract(12, "months").startOf('month').format(requiredDateFormat);
681
+ }
667
682
  }
668
- // if (fiscalFrom === "Start") {
669
- // if (getFiscalMonthIndex == 0 || getFiscalMonthIndex && getFiscalMonthIndex <= momentObj.clone().month()) {
670
- // startDate = moment(startDate, currentDateFormat).clone().month(fiscalMonth).startOf('month').format(requiredDateFormat);
671
- // } else {
672
- // startDate = moment(startDate, currentDateFormat).clone().month(fiscalMonth).subtract(12, "months").startOf('month').format(requiredDateFormat);
673
- // }
674
- // } else {
675
- // if (getFiscalMonthIndex == 0 || getFiscalMonthIndex && getFiscalMonthIndex < momentObj.clone().month() || getFiscalMonthIndex == 11) {
676
- // startDate = moment(startDate, currentDateFormat).clone().month(fiscalMonth).startOf('month').format(requiredDateFormat);
677
- // } else {
678
- // startDate = moment(startDate, currentDateFormat).clone().month(fiscalMonth).subtract(12, "months").startOf('month').format(requiredDateFormat);
679
- // }
680
- // }
681
683
  break;
682
684
  default:
683
685
  break;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optimiser/common",
3
- "version": "1.0.303",
3
+ "version": "1.0.304",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {