@fuzzle/opencode-accountant 0.4.0-next.1 → 0.4.0
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/README.md +6 -28
- package/agent/accountant.md +1 -3
- package/dist/index.js +7 -20
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -122,21 +122,12 @@ providers:
|
|
|
122
122
|
currencyField: Currency
|
|
123
123
|
skipRows: 9
|
|
124
124
|
delimiter: ';'
|
|
125
|
-
renamePattern: 'ubs-{account-number}
|
|
125
|
+
renamePattern: 'transactions-ubs-{account-number}.csv'
|
|
126
126
|
metadata:
|
|
127
127
|
- field: account-number
|
|
128
128
|
row: 0
|
|
129
129
|
column: 1
|
|
130
130
|
normalize: spaces-to-dashes
|
|
131
|
-
- field: from-date
|
|
132
|
-
row: 2
|
|
133
|
-
column: 1
|
|
134
|
-
- field: until-date
|
|
135
|
-
row: 3
|
|
136
|
-
column: 1
|
|
137
|
-
- field: closing-balance
|
|
138
|
-
row: 5
|
|
139
|
-
column: 1
|
|
140
131
|
currencies:
|
|
141
132
|
CHF: chf
|
|
142
133
|
EUR: eur
|
|
@@ -235,14 +226,7 @@ The `import-pipeline` tool is the single entry point for importing bank statemen
|
|
|
235
226
|
|
|
236
227
|
#### Rules File Matching
|
|
237
228
|
|
|
238
|
-
The tool matches CSV files to their rules files
|
|
239
|
-
|
|
240
|
-
1. **Source directive matching** (primary): Parses the `source` directive in each `.rules` file and supports glob patterns
|
|
241
|
-
2. **Filename matching** (fallback): If path matching fails, matches based on the rules filename prefix
|
|
242
|
-
|
|
243
|
-
**Example using source directive:**
|
|
244
|
-
|
|
245
|
-
If `ubs-account.rules` contains:
|
|
229
|
+
The tool matches CSV files to their rules files by parsing the `source` directive in each `.rules` file. For example, if `ubs-account.rules` contains:
|
|
246
230
|
|
|
247
231
|
```
|
|
248
232
|
source ../../import/pending/ubs/chf/transactions.csv
|
|
@@ -250,13 +234,7 @@ source ../../import/pending/ubs/chf/transactions.csv
|
|
|
250
234
|
|
|
251
235
|
The tool will use that rules file when processing `transactions.csv`.
|
|
252
236
|
|
|
253
|
-
**
|
|
254
|
-
|
|
255
|
-
If you have a rules file named `ubs-1234-567890.rules` and a CSV file named `ubs-1234-567890-transactions-2026-01-05-to-2026-01-31.csv`, the tool will automatically match them based on the common prefix `ubs-1234-567890`.
|
|
256
|
-
|
|
257
|
-
This is particularly useful when CSV files move between directories (e.g., from `pending/` to `done/`) or when maintaining exact source paths is impractical.
|
|
258
|
-
|
|
259
|
-
**Note:** Name your rules files to match the prefix of your CSV files for automatic matching.
|
|
237
|
+
**Note:** The `source` path should match your configured `{paths.pending}` directory structure.
|
|
260
238
|
|
|
261
239
|
See the hledger documentation for details on rules file format and syntax.
|
|
262
240
|
|
|
@@ -287,13 +265,13 @@ Configure metadata extraction in `providers.yaml`:
|
|
|
287
265
|
|
|
288
266
|
```yaml
|
|
289
267
|
metadata:
|
|
290
|
-
- field:
|
|
268
|
+
- field: closing_balance
|
|
291
269
|
row: 5
|
|
292
270
|
column: 1
|
|
293
|
-
- field:
|
|
271
|
+
- field: from_date
|
|
294
272
|
row: 2
|
|
295
273
|
column: 1
|
|
296
|
-
- field:
|
|
274
|
+
- field: until_date
|
|
297
275
|
row: 3
|
|
298
276
|
column: 1
|
|
299
277
|
```
|
package/agent/accountant.md
CHANGED
|
@@ -105,9 +105,7 @@ The `import-pipeline` tool provides an **atomic, safe workflow** using git workt
|
|
|
105
105
|
### Rules Files
|
|
106
106
|
|
|
107
107
|
- The location of the rules files is configured in `config/import/providers.yaml`
|
|
108
|
-
- Match CSV to rules file via the `source` directive in each `.rules` file
|
|
109
|
-
- **Filename matching example:** If the rules file is named `ubs-1234-567890.rules`, it will automatically match CSV files like `ubs-1234-567890-transactions-2026-01.csv` based on the common prefix. This works even when CSV files move between directories.
|
|
110
|
-
- When account detection fails, recommend users either fix their `source` directive or rename their rules file to match the CSV filename prefix
|
|
108
|
+
- Match CSV to rules file via the `source` directive in each `.rules` file
|
|
111
109
|
- Use field names from the `fields` directive for matching
|
|
112
110
|
- Unknown account pattern: `income:unknown` (positive amounts) / `expenses:unknown` (negative amounts)
|
|
113
111
|
|
package/dist/index.js
CHANGED
|
@@ -23458,18 +23458,6 @@ function findRulesForCsv(csvPath, mapping) {
|
|
|
23458
23458
|
return rulesFile;
|
|
23459
23459
|
}
|
|
23460
23460
|
}
|
|
23461
|
-
const csvBasename = path9.basename(csvPath);
|
|
23462
|
-
const matches = [];
|
|
23463
|
-
for (const rulesFile of Object.values(mapping)) {
|
|
23464
|
-
const rulesBasename = path9.basename(rulesFile, ".rules");
|
|
23465
|
-
if (csvBasename.startsWith(rulesBasename)) {
|
|
23466
|
-
matches.push({ rulesFile, prefixLength: rulesBasename.length });
|
|
23467
|
-
}
|
|
23468
|
-
}
|
|
23469
|
-
if (matches.length > 0) {
|
|
23470
|
-
matches.sort((a, b) => b.prefixLength - a.prefixLength);
|
|
23471
|
-
return matches[0].rulesFile;
|
|
23472
|
-
}
|
|
23473
23461
|
return null;
|
|
23474
23462
|
}
|
|
23475
23463
|
|
|
@@ -24252,11 +24240,10 @@ function determineClosingBalance(csvFile, config2, options, relativeCsvPath, rul
|
|
|
24252
24240
|
metadata = undefined;
|
|
24253
24241
|
}
|
|
24254
24242
|
let closingBalance = options.closingBalance;
|
|
24255
|
-
if (!closingBalance && metadata?.
|
|
24256
|
-
const
|
|
24257
|
-
|
|
24258
|
-
closingBalance
|
|
24259
|
-
if (currency && closingBalance && !closingBalance.includes(currency)) {
|
|
24243
|
+
if (!closingBalance && metadata?.closing_balance) {
|
|
24244
|
+
const { closing_balance, currency } = metadata;
|
|
24245
|
+
closingBalance = closing_balance;
|
|
24246
|
+
if (currency && !closingBalance.includes(currency)) {
|
|
24260
24247
|
closingBalance = `${currency} ${closingBalance}`;
|
|
24261
24248
|
}
|
|
24262
24249
|
}
|
|
@@ -24337,7 +24324,7 @@ function tryExtractClosingBalanceFromCSV(csvFile, rulesDir) {
|
|
|
24337
24324
|
"balance",
|
|
24338
24325
|
"Balance",
|
|
24339
24326
|
"BALANCE",
|
|
24340
|
-
"
|
|
24327
|
+
"closing_balance",
|
|
24341
24328
|
"Closing Balance",
|
|
24342
24329
|
"account_balance",
|
|
24343
24330
|
"Account Balance",
|
|
@@ -24888,8 +24875,8 @@ async function executeMergeStep(context, worktree) {
|
|
|
24888
24875
|
throw new Error("Import or reconcile step not completed before merge");
|
|
24889
24876
|
}
|
|
24890
24877
|
const commitInfo = {
|
|
24891
|
-
fromDate: reconcileDetails.metadata?.
|
|
24892
|
-
untilDate: reconcileDetails.metadata?.
|
|
24878
|
+
fromDate: reconcileDetails.metadata?.from_date,
|
|
24879
|
+
untilDate: reconcileDetails.metadata?.until_date
|
|
24893
24880
|
};
|
|
24894
24881
|
const transactionCount = importDetails.summary?.totalTransactions || 0;
|
|
24895
24882
|
const commitMessage = buildCommitMessage(context.options.provider, context.options.currency, commitInfo.fromDate, commitInfo.untilDate, transactionCount);
|