support batch update accounts for transactions

This commit is contained in:
MaysWind
2026-04-25 23:17:33 +08:00
parent e38ba2ea0a
commit bab7a0041b
27 changed files with 461 additions and 0 deletions
+35
View File
@@ -1164,6 +1164,40 @@ export const useTransactionsStore = defineStore('transactions', () => {
});
}
function batchUpdateTransactionAccounts({ transactionIds, accountId, isDestinationAccount }: { transactionIds: string[], accountId: string, isDestinationAccount: boolean }): Promise<boolean> {
return new Promise((resolve, reject) => {
services.batchUpdateTransactionAccounts({ transactionIds, accountId, isDestinationAccount }).then(response => {
const data = response.data;
if (!data || !data.success || !data.result) {
reject({ message: 'Unable to update accounts for transactions' });
return;
}
updateStoreInvalidState({
transactionList: true,
reconciliationStatement: true,
accountList: true,
overview: true,
statistics: true,
explorer: true
});
resolve(data.result);
}).catch(error => {
logger.error('failed to update accounts for transactions', error);
if (error.response && error.response.data && error.response.data.errorMessage) {
reject({ error: error.response.data });
} else if (!error.processed) {
reject({ message: 'Unable to update accounts for transactions' });
} else {
reject(error);
}
});
});
}
function moveAllTransactionsBetweenAccounts({ fromAccountId, toAccountId }: { fromAccountId: string, toAccountId: string }): Promise<boolean> {
return new Promise((resolve, reject) => {
services.moveAllTransactionsBetweenAccounts({ fromAccountId, toAccountId }).then(response => {
@@ -1539,6 +1573,7 @@ export const useTransactionsStore = defineStore('transactions', () => {
getTransaction,
saveTransaction,
batchUpdateTransactionCategories,
batchUpdateTransactionAccounts,
moveAllTransactionsBetweenAccounts,
deleteTransaction,
batchDeleteTransactions,