support setting timezone type for the time range of statistical data

This commit is contained in:
MaysWind
2024-04-12 09:51:01 +08:00
parent 14f6de8af1
commit ea32bfa5fc
18 changed files with 398 additions and 31 deletions
+16
View File
@@ -762,6 +762,21 @@ function getDateRangeDisplayName(userStore, dateType, startTime, endTime, transl
return `${displayStartTime} ~ ${displayEndTime}`;
}
function getAllTimezoneTypesUsedForStatistics(currentTimezone, translateFn) {
const currentTimezoneOffset = getTimezoneOffset(currentTimezone);
return [
{
displayName: translateFn('Application Timezone') + ` (UTC${currentTimezoneOffset})`,
type: timezone.allTimezoneTypesUsedForStatistics.ApplicationTimezone
},
{
displayName: translateFn('Transaction Timezone'),
type: timezone.allTimezoneTypesUsedForStatistics.TransactionTimezone
}
];
}
function getAllAccountCategories(translateFn) {
const allAccountCategories = [];
@@ -1333,6 +1348,7 @@ export function i18nFunctions(i18nGlobal) {
getAllDateRanges: (includeCustom) => getAllDateRanges(includeCustom, i18nGlobal.t),
getAllRecentMonthDateRanges: (userStore, includeAll, includeCustom) => getAllRecentMonthDateRanges(userStore, includeAll, includeCustom, i18nGlobal.t),
getDateRangeDisplayName: (userStore, dateType, startTime, endTime) => getDateRangeDisplayName(userStore, dateType, startTime, endTime, i18nGlobal.t),
getAllTimezoneTypesUsedForStatistics: (currentTimezone) => getAllTimezoneTypesUsedForStatistics(currentTimezone, i18nGlobal.t),
getAllAccountCategories: () => getAllAccountCategories(i18nGlobal.t),
getAllAccountTypes: () => getAllAccountTypes(i18nGlobal.t),
getAllStatisticsChartDataTypes: () => getAllStatisticsChartDataTypes(i18nGlobal.t),
+4 -4
View File
@@ -283,7 +283,7 @@ export default {
keyword = encodeURIComponent(keyword);
return axios.get(`v1/transactions/list/by_month.json?year=${year}&month=${month}&type=${type}&category_id=${categoryId}&account_id=${accountId}&keyword=${keyword}&trim_account=true&trim_category=true&trim_tag=true`);
},
getTransactionStatistics: ({ startTime, endTime }) => {
getTransactionStatistics: ({ startTime, endTime, useTransactionTimezone }) => {
const queryParams = [];
if (startTime) {
@@ -294,9 +294,9 @@ export default {
queryParams.push(`end_time=${endTime}`);
}
return axios.get('v1/transactions/statistics.json' + (queryParams.length ? '?' + queryParams.join('&') : ''));
return axios.get(`v1/transactions/statistics.json?use_transaction_timezone=${useTransactionTimezone}` + (queryParams.length ? '&' + queryParams.join('&') : ''));
},
getTransactionAmounts: ({ today, thisWeek, thisMonth, thisYear, lastMonth, monthBeforeLastMonth, monthBeforeLast2Months, monthBeforeLast3Months, monthBeforeLast4Months, monthBeforeLast5Months, monthBeforeLast6Months, monthBeforeLast7Months, monthBeforeLast8Months, monthBeforeLast9Months, monthBeforeLast10Months }) => {
getTransactionAmounts: ({ useTransactionTimezone, today, thisWeek, thisMonth, thisYear, lastMonth, monthBeforeLastMonth, monthBeforeLast2Months, monthBeforeLast3Months, monthBeforeLast4Months, monthBeforeLast5Months, monthBeforeLast6Months, monthBeforeLast7Months, monthBeforeLast8Months, monthBeforeLast9Months, monthBeforeLast10Months }) => {
const queryParams = [];
if (today) {
@@ -359,7 +359,7 @@ export default {
queryParams.push(`monthBeforeLast10Months_${monthBeforeLast10Months.startTime}_${monthBeforeLast10Months.endTime}`);
}
return axios.get('v1/transactions/amounts.json' + (queryParams.length ? '?query=' + queryParams.join('|') : ''));
return axios.get(`v1/transactions/amounts.json?use_transaction_timezone=${useTransactionTimezone}` + (queryParams.length ? '&query=' + queryParams.join('|') : ''));
},
getTransaction: ({ id }) => {
return axios.get(`v1/transactions/get.json?id=${id}&trim_account=true&trim_category=true&trim_tag=true`);
+19
View File
@@ -1,4 +1,5 @@
import currencyConstants from '@/consts/currency.js';
import timezoneConstants from '@/consts/timezone.js';
import statisticsConstants from '@/consts/statistics.js';
const settingsLocalStorageKey = 'ebk_app_settings';
@@ -15,6 +16,7 @@ const defaultSettings = {
thousandsSeparator: true,
currencyDisplayMode: currencyConstants.defaultCurrencyDisplayMode,
showAmountInHomePage: true,
timezoneUsedForStatisticsInHomePage: timezoneConstants.defaultTimezoneTypesUsedForStatistics,
itemsCountInTransactionListPage: 15,
showTotalAmountInTransactionListPage: true,
showAccountBalance: true,
@@ -22,6 +24,7 @@ const defaultSettings = {
defaultChartType: statisticsConstants.defaultChartType,
defaultChartDataType: statisticsConstants.defaultChartDataType,
defaultDataRangeType: statisticsConstants.defaultDataRangeType,
defaultTimezoneType: timezoneConstants.defaultTimezoneTypesUsedForStatistics,
defaultAccountFilter: {},
defaultTransactionCategoryFilter: {},
defaultSortingType: statisticsConstants.defaultSortingType
@@ -186,6 +189,14 @@ export function setShowAmountInHomePage(value) {
setOption('showAmountInHomePage', value);
}
export function getTimezoneUsedForStatisticsInHomePage() {
return getOption('timezoneUsedForStatisticsInHomePage');
}
export function setTimezoneUsedForStatisticsInHomePage(value) {
setOption('timezoneUsedForStatisticsInHomePage', value);
}
export function getItemsCountInTransactionListPage() {
return getOption('itemsCountInTransactionListPage');
}
@@ -230,6 +241,14 @@ export function getStatisticsDefaultDateRange() {
return getSubOption('statistics', 'defaultDataRangeType');
}
export function getStatisticsDefaultTimezoneType() {
return getSubOption('statistics', 'defaultTimezoneType');
}
export function setStatisticsDefaultTimezoneType(value) {
setSubOption('statistics', 'defaultTimezoneType', value);
}
export function setStatisticsDefaultDateRange(value) {
setSubOption('statistics', 'defaultDataRangeType', value);
}