mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-18 16:54:25 +08:00
Feature - Add support for a fiscal year period defined in user settings.
* Add "This fiscal year", "Last fiscal year" as date range options in Transaction Details to filter transactions to those periods * Add fiscal year ranges to Statistics & Trend Analysis * Add "fiscal year start date" to user profile settings, allowing the user to select any date of the calendar year as the start of the fiscal year * Add "fiscal year format" to user profile settings, allowing the user to specify how financial year date labels should appear Implementation notes: * The default fiscal year start is January 1 and the default fiscal year display format is "FY 2025" * Fiscal year start date (month number & day number) are stored together in db as a uint16, high byte & low byte respectively * February 29 is disallowed as a fiscal year start date, since it is never used as a convention in any country * Jest is added to the project as a dev dependency, for unit tests in frontend Signed-off-by: Sebastian Reategui <seb.reategui@gmail.com>
This commit is contained in:
committed by
mayswind
parent
70eea8ff33
commit
b94dc8eb83
@@ -1,4 +1,5 @@
|
||||
import type { YearMonth, YearUnixTime, YearQuarterUnixTime, YearMonthUnixTime } from '@/core/datetime.ts';
|
||||
import type { FiscalYearUnixTime } from '@/core/fiscalyear.ts';
|
||||
import { ChartSortingType, ChartDateAggregationType } from '@/core/statistics.ts';
|
||||
import type {
|
||||
YearMonthItems,
|
||||
@@ -8,7 +9,8 @@ import type {
|
||||
import {
|
||||
getAllMonthsStartAndEndUnixTimes,
|
||||
getAllQuartersStartAndEndUnixTimes,
|
||||
getAllYearsStartAndEndUnixTimes
|
||||
getAllYearsStartAndEndUnixTimes,
|
||||
getAllFiscalYearsStartAndEndUnixTimes
|
||||
} from '@/lib/datetime.ts';
|
||||
|
||||
export function sortStatisticsItems<T extends SortableTransactionStatisticDataItem>(items: T[], sortingType: number): void {
|
||||
@@ -46,7 +48,7 @@ export function sortStatisticsItems<T extends SortableTransactionStatisticDataIt
|
||||
}
|
||||
}
|
||||
|
||||
export function getAllDateRanges<T extends YearMonth>(items: YearMonthItems<T>[], startYearMonth: YearMonth | string, endYearMonth: YearMonth | string, dateAggregationType: number): YearUnixTime[] | YearQuarterUnixTime[] | YearMonthUnixTime[] {
|
||||
export function getAllDateRanges<T extends YearMonth>(items: YearMonthItems<T>[], startYearMonth: YearMonth | string, endYearMonth: YearMonth | string, fiscalYearStart: number, dateAggregationType: number): YearUnixTime[] | YearQuarterUnixTime[] | YearMonthUnixTime[] | FiscalYearUnixTime[] {
|
||||
if ((!startYearMonth || !endYearMonth) && items && items.length) {
|
||||
let minYear = Number.MAX_SAFE_INTEGER, minMonth = Number.MAX_SAFE_INTEGER, maxYear = 0, maxMonth = 0;
|
||||
|
||||
@@ -78,6 +80,8 @@ export function getAllDateRanges<T extends YearMonth>(items: YearMonthItems<T>[]
|
||||
|
||||
if (dateAggregationType === ChartDateAggregationType.Year.type) {
|
||||
return getAllYearsStartAndEndUnixTimes(startYearMonth, endYearMonth);
|
||||
} else if (dateAggregationType === ChartDateAggregationType.FiscalYear.type) {
|
||||
return getAllFiscalYearsStartAndEndUnixTimes(startYearMonth, endYearMonth, fiscalYearStart);
|
||||
} else if (dateAggregationType === ChartDateAggregationType.Quarter.type) {
|
||||
return getAllQuartersStartAndEndUnixTimes(startYearMonth, endYearMonth);
|
||||
} else { // if (dateAggregationType === ChartDateAggregationType.Month.type) {
|
||||
|
||||
Reference in New Issue
Block a user