forked from beancount/fava
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
In some countries (such as Australia), it is very common for wages to be paid on a fortnightly basis, that is, every 2 weeks. As a result, a number of other expenses are also paid on a fortnightly basis. This commit extends the `Interval` enum by adding a `FORTNIGHT` option. I have added a test for that, and have updated the translations where possible (not that other than for English and French, the other translations may be suboptimal). As part of this commit, I have also taken the opportunity to fix a confusion between ISO weeks and calendar weeks as the two do not always match, and `2025-W01` is the ISO format indicating the week starting on December 30 2024. Resolves: beancount#1939 Signed-off-by: JP-Ellis <[email protected]>
- Loading branch information
Showing
21 changed files
with
307 additions
and
130 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,36 @@ | ||
import { _ } from "../i18n"; | ||
|
||
export type Interval = "year" | "quarter" | "month" | "week" | "day"; | ||
export type Interval = | ||
| "year" | ||
| "quarter" | ||
| "month" | ||
| "fortnight" | ||
| "week" | ||
| "day"; | ||
|
||
export const DEFAULT_INTERVAL: Interval = "month"; | ||
|
||
export const INTERVALS: Interval[] = [ | ||
"year", | ||
"quarter", | ||
"month", | ||
"week", | ||
"day", | ||
"year", | ||
"quarter", | ||
"month", | ||
"fortnight", | ||
"week", | ||
"day", | ||
]; | ||
|
||
export function getInterval(s: string | null): Interval { | ||
return INTERVALS.includes(s as Interval) ? (s as Interval) : DEFAULT_INTERVAL; | ||
return INTERVALS.includes(s as Interval) ? (s as Interval) : DEFAULT_INTERVAL; | ||
} | ||
|
||
/** Get the translateable label for an interval. */ | ||
export function intervalLabel(s: Interval): string { | ||
return { | ||
year: _("Yearly"), | ||
quarter: _("Quarterly"), | ||
month: _("Monthly"), | ||
week: _("Weekly"), | ||
day: _("Daily"), | ||
}[s]; | ||
return { | ||
year: _("Yearly"), | ||
quarter: _("Quarterly"), | ||
month: _("Monthly"), | ||
fortnight: _("Fortnightly"), | ||
week: _("Weekly"), | ||
day: _("Daily"), | ||
}[s]; | ||
} |
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
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
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.