Added last month to PR if avrop enddate is past
This commit is contained in:
@@ -15,7 +15,7 @@ export function extractAvropPeriods(avropStartDate: Date, avropEndDate: Date): A
|
|||||||
throw new Error('Avropets startdatum måste komma innan slutdatumet.');
|
throw new Error('Avropets startdatum måste komma innan slutdatumet.');
|
||||||
}
|
}
|
||||||
|
|
||||||
const previousPeriod = dateToPeriodId(subMonths(today, 1));
|
const previousPeriod = dateToPeriodId(today >= avropEndDate ? avropEndDate : subMonths(today, 1));
|
||||||
const periods: AvropPeriod[] = [] as AvropPeriod[];
|
const periods: AvropPeriod[] = [] as AvropPeriod[];
|
||||||
let dateCounter = avropStartDate;
|
let dateCounter = avropStartDate;
|
||||||
|
|
||||||
@@ -24,7 +24,7 @@ export function extractAvropPeriods(avropStartDate: Date, avropEndDate: Date): A
|
|||||||
const endDate = endOfMonth(dateCounter) > avropEndDate ? avropEndDate : endOfMonth(dateCounter);
|
const endDate = endOfMonth(dateCounter) > avropEndDate ? avropEndDate : endOfMonth(dateCounter);
|
||||||
const period: AvropPeriod = { startDate, endDate, periodId: dateToPeriodId(dateCounter) };
|
const period: AvropPeriod = { startDate, endDate, periodId: dateToPeriodId(dateCounter) };
|
||||||
periods.push(period);
|
periods.push(period);
|
||||||
dateCounter = addMonths(dateCounter, 1);
|
dateCounter = startOfMonth(addMonths(dateCounter, 1));
|
||||||
}
|
}
|
||||||
return periods;
|
return periods;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user