move all transactions from one account to another account (#288)
This commit is contained in:
@@ -1103,6 +1103,51 @@ export const useTransactionsStore = defineStore('transactions', () => {
|
||||
});
|
||||
}
|
||||
|
||||
function moveAllTransactionsBetweenAccounts({ fromAccountId, toAccountId }: { fromAccountId: string, toAccountId: string }): Promise<boolean> {
|
||||
return new Promise((resolve, reject) => {
|
||||
services.moveAllTransactionsBetweenAccounts({ fromAccountId, toAccountId }).then(response => {
|
||||
const data = response.data;
|
||||
|
||||
if (!data || !data.success || !data.result) {
|
||||
reject({ message: 'Unable to move transactions' });
|
||||
return;
|
||||
}
|
||||
|
||||
if (!transactionListStateInvalid.value) {
|
||||
updateTransactionListInvalidState(true);
|
||||
}
|
||||
|
||||
if (!transactionReconciliationStatementStateInvalid.value) {
|
||||
updateTransactionReconciliationStatementInvalidState(true);
|
||||
}
|
||||
|
||||
if (!accountsStore.accountListStateInvalid) {
|
||||
accountsStore.updateAccountListInvalidState(true);
|
||||
}
|
||||
|
||||
if (!overviewStore.transactionOverviewStateInvalid) {
|
||||
overviewStore.updateTransactionOverviewInvalidState(true);
|
||||
}
|
||||
|
||||
if (!statisticsStore.transactionStatisticsStateInvalid) {
|
||||
statisticsStore.updateTransactionStatisticsInvalidState(true);
|
||||
}
|
||||
|
||||
resolve(data.result);
|
||||
}).catch(error => {
|
||||
logger.error('failed to move 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 move transactions' });
|
||||
} else {
|
||||
reject(error);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function deleteTransaction({ transaction, defaultCurrency, beforeResolve }: { transaction: TransactionInfoResponse, defaultCurrency: string, beforeResolve?: BeforeResolveFunction }): Promise<boolean> {
|
||||
return new Promise((resolve, reject) => {
|
||||
services.deleteTransaction({
|
||||
@@ -1405,6 +1450,7 @@ export const useTransactionsStore = defineStore('transactions', () => {
|
||||
getReconciliationStatements,
|
||||
getTransaction,
|
||||
saveTransaction,
|
||||
moveAllTransactionsBetweenAccounts,
|
||||
deleteTransaction,
|
||||
recognizeReceiptImage,
|
||||
cancelRecognizeReceiptImage,
|
||||
|
||||
Reference in New Issue
Block a user