Skip to content
Snippets Groups Projects
Unverified Commit 240dc46a authored by Khanh Nguyen's avatar Khanh Nguyen Committed by GitHub
Browse files

Fix bug - Manually entered split transactions are not cleared on import #200 (#1465)

* Added clear transactions on import option

* Added release note

* Added cleared column to csv export

* fixed Manually entered split transactions are not cleared on import

* Revert "Added cleared column to csv export"

This reverts commit 2952bc3e7d6367629e0bc8151b2ede1820e4c9f5.

* added release note

* Copied same code to Gocardless

* Updated var name

* Updated to only query  changed transactions instead of all
parent 3d621c68
No related branches found
No related tags found
No related merge requests found
......@@ -431,7 +431,7 @@ export async function reconcileGoCardlessTransactions(acctId, transactions) {
// matched transaction. See the final pass below for the needed
// fields.
fuzzyDataset = await db.all(
`SELECT id, date, imported_id, payee, category, notes FROM v_transactions
`SELECT id, is_parent, date, imported_id, payee, category, notes FROM v_transactions
WHERE date >= ? AND date <= ? AND amount = ? AND account = ? AND is_child = 0`,
[
db.toDateRepr(monthUtils.subDays(trans.date, 4)),
......@@ -509,6 +509,16 @@ export async function reconcileGoCardlessTransactions(acctId, transactions) {
if (hasFieldsChanged(existing, updates, Object.keys(updates))) {
updated.push({ id: existing.id, ...updates });
}
if (existing.is_parent && existing.cleared !== updates.cleared) {
const children = await db.all(
'SELECT id FROM v_transactions WHERE parent_id = ?',
[existing.id],
);
for (const child of children) {
updated.push({ id: child.id, cleared: updates.cleared });
}
}
} else {
// Insert a new transaction
let finalTransaction = {
......@@ -575,7 +585,7 @@ export async function reconcileTransactions(acctId, transactions) {
// matched transaction. See the final pass below for the needed
// fields.
fuzzyDataset = await db.all(
`SELECT id, date, imported_id, payee, category, notes FROM v_transactions
`SELECT id, is_parent, date, imported_id, payee, category, notes FROM v_transactions
WHERE date >= ? AND date <= ? AND amount = ? AND account = ? AND is_child = 0`,
[
db.toDateRepr(monthUtils.subDays(trans.date, 4)),
......@@ -654,6 +664,16 @@ export async function reconcileTransactions(acctId, transactions) {
if (hasFieldsChanged(existing, updates, Object.keys(updates))) {
updated.push({ id: existing.id, ...updates });
}
if (existing.is_parent && existing.cleared !== updates.cleared) {
const children = await db.all(
'SELECT id FROM v_transactions WHERE parent_id = ?',
[existing.id],
);
for (const child of children) {
updated.push({ id: child.id, cleared: updates.cleared });
}
}
} else {
// Insert a new transaction
let finalTransaction = {
......
---
category: Bugfix
authors: [kstockk]
---
Fixed clearing split transactions when importing matched transactions
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