mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-17 00:12:11 +08:00
support batch update accounts for transactions
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user