-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into LinkProps
- Loading branch information
Showing
12 changed files
with
338 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
packages/desktop-client/src/components/reports/getLiveRange.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import * as monthUtils from 'loot-core/src/shared/months'; | ||
|
||
import { ReportOptions } from './ReportOptions'; | ||
import { getSpecificRange, validateRange } from './reportRanges'; | ||
|
||
export function getLiveRange(cond: string, earliestTransaction: string) { | ||
let dateStart; | ||
let dateEnd; | ||
const rangeName = ReportOptions.dateRangeMap.get(cond); | ||
switch (rangeName) { | ||
case 'yearToDate': | ||
[dateStart, dateEnd] = validateRange( | ||
earliestTransaction, | ||
monthUtils.getYearStart(monthUtils.currentMonth()) + '-01', | ||
monthUtils.currentDay(), | ||
); | ||
break; | ||
case 'lastYear': | ||
[dateStart, dateEnd] = validateRange( | ||
earliestTransaction, | ||
monthUtils.getYearStart( | ||
monthUtils.prevYear(monthUtils.currentMonth()), | ||
) + '-01', | ||
monthUtils.getYearEnd(monthUtils.prevYear(monthUtils.currentDate())) + | ||
'-31', | ||
); | ||
break; | ||
case 'allMonths': | ||
dateStart = earliestTransaction; | ||
dateEnd = monthUtils.currentDay(); | ||
break; | ||
default: | ||
if (typeof rangeName === 'number') { | ||
[dateStart, dateEnd] = getSpecificRange( | ||
rangeName, | ||
cond === 'Last month' ? 0 : null, | ||
); | ||
} else { | ||
break; | ||
} | ||
} | ||
|
||
return [dateStart, dateEnd]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.