israeli-banks-actual-budget-importer 1.7.1 → 1.7.3

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,17 @@
1
+ ## [1.7.3](https://github.com/tomerh2001/israeli-banks-actual-budget-importer/compare/v1.7.2...v1.7.3) (2025-12-04)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * streamline reconciliation transaction handling and improve logging ([46fc2b0](https://github.com/tomerh2001/israeli-banks-actual-budget-importer/commit/46fc2b082e4e7b69666bb338960e0b7e6152f892))
7
+
8
+ ## [1.7.2](https://github.com/tomerh2001/israeli-banks-actual-budget-importer/compare/v1.7.1...v1.7.2) (2025-12-04)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * improve reconciliation logic to log transaction removal when balances are in sync ([c2f3fba](https://github.com/tomerh2001/israeli-banks-actual-budget-importer/commit/c2f3fba73588fb1591ddfcc92cb0e2b0fe9a54f5))
14
+
1
15
  ## [1.7.1](https://github.com/tomerh2001/israeli-banks-actual-budget-importer/compare/v1.7.0...v1.7.1) (2025-12-04)
2
16
 
3
17
 
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.7.1",
2
+ "version": "1.7.3",
3
3
  "name": "israeli-banks-actual-budget-importer",
4
4
  "module": "index.ts",
5
5
  "type": "module",
package/src/utils.ts CHANGED
@@ -91,24 +91,22 @@ export async function scrapeAndImportTransactions({companyId, bank}: ScrapeTrans
91
91
 
92
92
  const existingReconciliation = allAccountTxns.find(txn => txn.imported_id === reconciliationImportedId);
93
93
 
94
- // If balances are already in sync, remove any existing reconciliation and exit.
95
- if (balanceDiff === 0) {
96
- if (existingReconciliation) {
97
- stdout.mute();
98
- await actual.deleteTransaction(existingReconciliation.id);
99
- stdout.unmute();
100
- log('RECONCILIATION_REMOVED');
101
- }
102
-
103
- return;
104
- }
105
-
106
94
  log('RECONCILIATION', {
107
95
  from: currentBalance,
108
96
  to: accountBalance,
109
97
  diff: balanceDiff,
110
98
  });
111
99
 
100
+ // If balances are already in sync, remove any existing reconciliation and exit.
101
+ if (existingReconciliation && balanceDiff === 0) {
102
+ stdout.mute();
103
+ await actual.deleteTransaction(existingReconciliation.id);
104
+ stdout.unmute();
105
+ log(`RECONCILIATION_REMOVED, since ${currentBalance.toLocaleString()} === ${accountBalance.toLocaleString()}`, {transactionId: existingReconciliation.id});
106
+
107
+ return;
108
+ }
109
+
112
110
  const reconciliationTxn = {
113
111
  account: bank.actualAccountId,
114
112
  date: moment().format('YYYY-MM-DD'),
@@ -122,22 +120,25 @@ export async function scrapeAndImportTransactions({companyId, bank}: ScrapeTrans
122
120
  stdout.mute();
123
121
  if (existingReconciliation) {
124
122
  // Update the single reconciliation transaction
123
+ stdout.mute();
125
124
  await actual.updateTransaction(existingReconciliation.id, reconciliationTxn);
126
125
  stdout.unmute();
127
126
  log('RECONCILIATION_UPDATED', {transactionId: existingReconciliation.id});
128
- } else {
129
- // Create the reconciliation transaction for the first time
130
- const reconciliationResult = await actual.importTransactions(
131
- bank.actualAccountId,
132
- [reconciliationTxn],
133
- );
134
- stdout.unmute();
135
127
 
136
- if (!reconciliationResult || _.isEmpty(reconciliationResult.added)) {
137
- console.error('Reconciliation errors', reconciliationResult?.errors);
138
- } else {
139
- log('RECONCILIATION_ADDED', {transactions: reconciliationResult.added.length});
140
- }
128
+ return;
129
+ }
130
+
131
+ // Create the reconciliation transaction for the first time
132
+ const reconciliationResult = await actual.importTransactions(
133
+ bank.actualAccountId,
134
+ [reconciliationTxn],
135
+ );
136
+ stdout.unmute();
137
+
138
+ if (!reconciliationResult || _.isEmpty(reconciliationResult.added)) {
139
+ console.error('Reconciliation errors', reconciliationResult?.errors);
140
+ } else {
141
+ log('RECONCILIATION_ADDED', {transactions: reconciliationResult.added.length});
141
142
  }
142
143
  } catch (error) {
143
144
  console.error('Error', companyId, error);