Skip to content

A local-first personal finance app

Don't update transaction date when importing manually (#2648)

Wizmastere5933ad8cde4
diff --git a/packages/api/methods.test.ts b/packages/api/methods.test.ts
index 7d14d59687..4a3cc09001 100644
--- a/packages/api/methods.test.ts
+++ b/packages/api/methods.test.ts
@@ -559,8 +559,8 @@ describe('API CRUD operations', () => {
const accountId = await api.createAccount({ name: 'test-account' }, 0);
let newTransaction = [
- { date: '2023-11-03', imported_id: '11', amount: 100 },
- { date: '2023-11-03', imported_id: '11', amount: 100 },
+ { date: '2023-11-03', imported_id: '11', amount: 100, notes: 'notes' },
+ { date: '2023-11-03', imported_id: '12', amount: 100, notes: '' },
];
const addResult = await api.addTransactions(accountId, newTransaction, {
@@ -583,8 +583,9 @@ describe('API CRUD operations', () => {
expect(transactions).toHaveLength(2);
newTransaction = [
- { date: '2023-12-03', imported_id: '11', amount: 100 },
- { date: '2023-12-03', imported_id: '22', amount: 200 },
+ { date: '2023-12-03', imported_id: '11', amount: 100, notes: 'notes' },
+ { date: '2023-12-03', imported_id: '12', amount: 100, notes: 'notes' },
+ { date: '2023-12-03', imported_id: '22', amount: 200, notes: '' },
];
const reconciled = await api.importTransactions(accountId, newTransaction);
@@ -600,9 +601,22 @@ describe('API CRUD operations', () => {
'2023-12-31',
);
expect(transactions).toEqual(
- expect.arrayContaining(
- newTransaction.map(trans => expect.objectContaining(trans)),
- ),
+ expect.arrayContaining([
+ expect.objectContaining({ imported_id: '22', amount: 200 }),
+ ]),
+ );
+ expect(transactions).toHaveLength(1);
+
+ // confirm imported transactions update perfomed
+ transactions = await api.getTransactions(
+ accountId,
+ '2023-11-01',
+ '2023-11-30',
+ );
+ expect(transactions).toEqual(
+ expect.arrayContaining([
+ expect.objectContaining({ notes: 'notes', amount: 100 }),
+ ]),
);
expect(transactions).toHaveLength(2);
diff --git a/packages/loot-core/src/server/accounts/sync.ts b/packages/loot-core/src/server/accounts/sync.ts
index d8f919524f..39f48bcdbf 100644
--- a/packages/loot-core/src/server/accounts/sync.ts
+++ b/packages/loot-core/src/server/accounts/sync.ts
@@ -490,7 +490,6 @@ export async function reconcileTransactions(
// Update the transaction
const updates = {
- ...(isBankSyncAccount ? {} : { date: trans.date }),
imported_id: trans.imported_id || null,
payee: existing.payee || trans.payee || null,
category: existing.category || trans.category || null,
diff --git a/upcoming-release-notes/2648.md b/upcoming-release-notes/2648.md
new file mode 100644
index 0000000000..6d76bca187
--- /dev/null
+++ b/upcoming-release-notes/2648.md
@@ -0,0 +1,6 @@
+---
+category: Bugfix
+authors: [Wizmaster]
+---
+
+Don't update transaction date when importing manually
\ No newline at end of file