Skip to content
Snippets Groups Projects
Unverified Commit 384fc68e authored by Matiss Janis Aboltins's avatar Matiss Janis Aboltins Committed by GitHub
Browse files

:bug: allow deleting both transfer transactions at the same time (#491)

Closes #487
parent 8d8eab34
No related branches found
No related tags found
No related merge requests found
...@@ -90,17 +90,24 @@ export async function addTransfer(transaction, transferredAccount) { ...@@ -90,17 +90,24 @@ export async function addTransfer(transaction, transferredAccount) {
export async function removeTransfer(transaction) { export async function removeTransfer(transaction) {
let transferTrans = await db.getTransaction(transaction.transfer_id); let transferTrans = await db.getTransaction(transaction.transfer_id);
if (transferTrans.is_child) {
// If it's a child transaction, we don't delete it because that // Perform operations on the transfer transaction only
// would invalidate the whole split transaction. Instead of turn // if it is found. For example: when users delete both
// it into a normal transaction // (in & out) transfer transactions at the same time -
await db.updateTransaction({ // transfer transaction will not be found.
id: transaction.transfer_id, if (transferTrans) {
transfer_id: null, if (transferTrans.is_child) {
payee: null // If it's a child transaction, we don't delete it because that
}); // would invalidate the whole split transaction. Instead of turn
} else { // it into a normal transaction
await db.deleteTransaction({ id: transaction.transfer_id }); await db.updateTransaction({
id: transaction.transfer_id,
transfer_id: null,
payee: null
});
} else {
await db.deleteTransaction({ id: transaction.transfer_id });
}
} }
await db.updateTransaction({ id: transaction.id, transfer_id: null }); await db.updateTransaction({ id: transaction.id, transfer_id: null });
return { id: transaction.id, transfer_id: null }; return { id: transaction.id, transfer_id: null };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment