israeli-banks-actual-budget-importer 1.7.4 → 1.7.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [1.7.5](https://github.com/tomerh2001/israeli-banks-actual-budget-importer/compare/v1.7.4...v1.7.5) (2025-12-04)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * optimize reconciliation logic to skip unnecessary updates when balances are in sync ([5153911](https://github.com/tomerh2001/israeli-banks-actual-budget-importer/commit/515391177d37e5ef0577ab5a306317e21bf990e4))
7
+
1
8
  ## [1.7.4](https://github.com/tomerh2001/israeli-banks-actual-budget-importer/compare/v1.7.3...v1.7.4) (2025-12-04)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.7.4",
2
+ "version": "1.7.5",
3
3
  "name": "israeli-banks-actual-budget-importer",
4
4
  "module": "index.ts",
5
5
  "type": "module",
package/src/utils.ts CHANGED
@@ -91,11 +91,11 @@ export async function scrapeAndImportTransactions({companyId, bank}: ScrapeTrans
91
91
 
92
92
  const existingReconciliation = allAccountTxns.find(txn => txn.imported_id === reconciliationImportedId);
93
93
 
94
- log('RECONCILIATION', {
95
- from: currentBalance,
96
- to: accountBalance,
97
- diff: balanceDiff,
98
- });
94
+ // If balances are already in sync, no need to create/update reconciliation.
95
+ if (existingReconciliation && balanceDiff === 0) {
96
+ log('RECONCILIATION_NOT_NEEDED');
97
+ return;
98
+ }
99
99
 
100
100
  const reconciliationTxn = {
101
101
  account: bank.actualAccountId,
@@ -107,28 +107,24 @@ export async function scrapeAndImportTransactions({companyId, bank}: ScrapeTrans
107
107
  imported_id: reconciliationImportedId,
108
108
  };
109
109
 
110
- stdout.mute();
111
110
  if (existingReconciliation) {
112
- // Update the single reconciliation transaction
113
111
  stdout.mute();
114
112
  await actual.updateTransaction(existingReconciliation.id, reconciliationTxn);
115
113
  stdout.unmute();
116
- log('RECONCILIATION_UPDATED', {transactionId: existingReconciliation.id});
117
114
 
115
+ log('RECONCILIATION_UPDATED', {from: currentBalance, to: accountBalance, diff: balanceDiff});
118
116
  return;
119
117
  }
120
118
 
121
119
  // Create the reconciliation transaction for the first time
122
- const reconciliationResult = await actual.importTransactions(
123
- bank.actualAccountId,
124
- [reconciliationTxn],
125
- );
120
+ stdout.mute();
121
+ const reconciliationResult = await actual.importTransactions(bank.actualAccountId, [reconciliationTxn]);
126
122
  stdout.unmute();
127
123
 
128
124
  if (!reconciliationResult || _.isEmpty(reconciliationResult.added)) {
129
125
  console.error('Reconciliation errors', reconciliationResult?.errors);
130
126
  } else {
131
- log('RECONCILIATION_ADDED', {transactions: reconciliationResult.added.length});
127
+ log('RECONCILIATION_ADDED', {from: currentBalance, to: accountBalance, diff: balanceDiff});
132
128
  }
133
129
  } catch (error) {
134
130
  console.error('Error', companyId, error);