mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-21 02:04:26 +08:00
fix default time is wrong in add transaction dialog when default time zone is not the browser time zone in desktop version
This commit is contained in:
@@ -14,7 +14,7 @@ import {
|
|||||||
getFirstAvaiableSubCategoryId
|
getFirstAvaiableSubCategoryId
|
||||||
} from './category.js';
|
} from './category.js';
|
||||||
|
|
||||||
export function setTransactionModelByTransaction(transaction, transaction2, allCategories, allCategoriesMap, allVisibleAccounts, allAccountsMap, defaultAccountId, options, setContextData) {
|
export function setTransactionModelByTransaction(transaction, transaction2, allCategories, allCategoriesMap, allVisibleAccounts, allAccountsMap, defaultAccountId, options, setContextData, convertContextTime) {
|
||||||
if ((!options.type || options.type === '0') && options.categoryId && options.categoryId !== '0' && allCategoriesMap[options.categoryId]) {
|
if ((!options.type || options.type === '0') && options.categoryId && options.categoryId !== '0' && allCategoriesMap[options.categoryId]) {
|
||||||
const category = allCategoriesMap[options.categoryId];
|
const category = allCategoriesMap[options.categoryId];
|
||||||
const type = categoryTypeToTransactionType(category.type);
|
const type = categoryTypeToTransactionType(category.type);
|
||||||
@@ -115,7 +115,12 @@ export function setTransactionModelByTransaction(transaction, transaction2, allC
|
|||||||
if (setContextData) {
|
if (setContextData) {
|
||||||
transaction.utcOffset = transaction2.utcOffset;
|
transaction.utcOffset = transaction2.utcOffset;
|
||||||
transaction.timeZone = transaction2.timeZone;
|
transaction.timeZone = transaction2.timeZone;
|
||||||
transaction.time = getDummyUnixTimeForLocalUsage(transaction2.time, transaction.utcOffset, getBrowserTimezoneOffsetMinutes());
|
|
||||||
|
if (convertContextTime) {
|
||||||
|
transaction.time = getDummyUnixTimeForLocalUsage(transaction2.time, transaction.utcOffset, getBrowserTimezoneOffsetMinutes());
|
||||||
|
} else {
|
||||||
|
transaction.time = transaction2.time;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
transaction.sourceAccountId = transaction2.sourceAccountId;
|
transaction.sourceAccountId = transaction2.sourceAccountId;
|
||||||
|
|||||||
@@ -614,7 +614,7 @@ export default {
|
|||||||
self.originalTransactionEditable = false;
|
self.originalTransactionEditable = false;
|
||||||
|
|
||||||
const newTransaction = self.transactionsStore.generateNewTransactionModel(options.type);
|
const newTransaction = self.transactionsStore.generateNewTransactionModel(options.type);
|
||||||
self.setTransaction(newTransaction, options, true);
|
self.setTransaction(newTransaction, options, true, false);
|
||||||
|
|
||||||
const promises = [
|
const promises = [
|
||||||
self.accountsStore.loadAllAccounts({ force: false }),
|
self.accountsStore.loadAllAccounts({ force: false }),
|
||||||
@@ -624,7 +624,7 @@ export default {
|
|||||||
|
|
||||||
if (options && options.id) {
|
if (options && options.id) {
|
||||||
if (options.currentTransaction) {
|
if (options.currentTransaction) {
|
||||||
self.setTransaction(options.currentTransaction, options, true);
|
self.setTransaction(options.currentTransaction, options, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
self.mode = 'view';
|
self.mode = 'view';
|
||||||
@@ -658,10 +658,10 @@ export default {
|
|||||||
|
|
||||||
if (options.id && responses[3]) {
|
if (options.id && responses[3]) {
|
||||||
const transaction = responses[3];
|
const transaction = responses[3];
|
||||||
self.setTransaction(transaction, options, true);
|
self.setTransaction(transaction, options, true, true);
|
||||||
self.originalTransactionEditable = transaction.editable;
|
self.originalTransactionEditable = transaction.editable;
|
||||||
} else {
|
} else {
|
||||||
self.setTransaction(null, options, true);
|
self.setTransaction(null, options, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
self.loading = false;
|
self.loading = false;
|
||||||
@@ -837,7 +837,7 @@ export default {
|
|||||||
this.transaction.destinationAmount = oldSourceAmount;
|
this.transaction.destinationAmount = oldSourceAmount;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
setTransaction(transaction, options, setContextData) {
|
setTransaction(transaction, options, setContextData, convertContextTime) {
|
||||||
setTransactionModelByTransaction(
|
setTransactionModelByTransaction(
|
||||||
this.transaction,
|
this.transaction,
|
||||||
transaction,
|
transaction,
|
||||||
@@ -851,7 +851,8 @@ export default {
|
|||||||
categoryId: options.categoryId,
|
categoryId: options.categoryId,
|
||||||
accountId: options.accountId
|
accountId: options.accountId
|
||||||
},
|
},
|
||||||
setContextData
|
setContextData,
|
||||||
|
convertContextTime
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -677,6 +677,7 @@ export default {
|
|||||||
categoryId: query.categoryId,
|
categoryId: query.categoryId,
|
||||||
accountId: query.accountId
|
accountId: query.accountId
|
||||||
},
|
},
|
||||||
|
(self.mode === 'edit' || self.mode === 'view'),
|
||||||
(self.mode === 'edit' || self.mode === 'view')
|
(self.mode === 'edit' || self.mode === 'view')
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user