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

:bug: (import) patch phantom transactions getting created (#2464)

parent d7635755
No related branches found
No related tags found
No related merge requests found
......@@ -482,6 +482,26 @@ export async function reconcileExternalTransactions(acctId, transactions) {
acctId,
],
);
// Sort the matched transactions according to the distance from the original
// transactions date. i.e. if the original transaction is in 21-02-2024 and
// the matched transactions are: 20-02-2024, 21-02-2024, 29-02-2024 then
// the resulting data-set should be: 21-02-2024, 20-02-2024, 29-02-2024.
fuzzyDataset = fuzzyDataset.sort((a, b) => {
const aDistance = Math.abs(
dateFns.differenceInMilliseconds(
dateFns.parseISO(trans.date),
dateFns.parseISO(db.fromDateRepr(a.date)),
),
);
const bDistance = Math.abs(
dateFns.differenceInMilliseconds(
dateFns.parseISO(trans.date),
dateFns.parseISO(db.fromDateRepr(b.date)),
),
);
return aDistance > bDistance ? 1 : -1;
});
}
transactionsStep1.push({
......@@ -645,6 +665,26 @@ export async function reconcileTransactions(acctId, transactions) {
acctId,
],
);
// Sort the matched transactions according to the distance from the original
// transactions date. i.e. if the original transaction is in 21-02-2024 and
// the matched transactions are: 20-02-2024, 21-02-2024, 29-02-2024 then
// the resulting data-set should be: 21-02-2024, 20-02-2024, 29-02-2024.
fuzzyDataset = fuzzyDataset.sort((a, b) => {
const aDistance = Math.abs(
dateFns.differenceInMilliseconds(
dateFns.parseISO(trans.date),
dateFns.parseISO(db.fromDateRepr(a.date)),
),
);
const bDistance = Math.abs(
dateFns.differenceInMilliseconds(
dateFns.parseISO(trans.date),
dateFns.parseISO(db.fromDateRepr(b.date)),
),
);
return aDistance > bDistance ? 1 : -1;
});
}
transactionsStep1.push({
......
---
category: Bugfix
authors: [MatissJanis]
---
Fix csv/ofx import sometimes importing duplicate 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