@fuzzle/opencode-accountant 0.9.0 → 0.9.1

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 CHANGED
@@ -101,6 +101,7 @@ paths:
101
101
 
102
102
  providers:
103
103
  revolut:
104
+ importOrder: 10
104
105
  detect:
105
106
  - filenamePattern: '^account-statement_'
106
107
  header: 'Type,Product,Started Date,Completed Date,Description,Amount,Fee,Currency,State,Balance'
@@ -115,6 +116,7 @@ providers:
115
116
  BTC: btc
116
117
 
117
118
  ubs:
119
+ importOrder: 0
118
120
  detect:
119
121
  # Note: UBS exports have a trailing semicolon in the header row, which creates
120
122
  # an empty field when parsed. The header must include a trailing comma to match.
@@ -167,6 +169,7 @@ providers:
167
169
  | `renamePattern` | No | Output filename pattern with `{placeholder}` substitutions |
168
170
  | `metadata` | No | Array of metadata extraction rules (see below) |
169
171
  | `currencies` | Yes | Map of raw currency values to normalized folder names |
172
+ | `importOrder` | No | Numeric priority for import sequencing (default: `0`, lower imports first) |
170
173
 
171
174
  \* **Note on trailing delimiters:** If the CSV header row ends with a trailing delimiter (e.g., `Field1;Field2;`), this creates an empty field when parsed. The `header` config must include a trailing comma to account for this (e.g., `Field1,Field2,`).
172
175
 
package/dist/index.js CHANGED
@@ -17314,7 +17314,16 @@ function validateProviderConfig(name, config2) {
17314
17314
  if (Object.keys(currencies).length === 0) {
17315
17315
  throw new Error(`Invalid config for provider '${name}': 'currencies' must contain at least one mapping`);
17316
17316
  }
17317
- return { detect, currencies };
17317
+ if (configObj.importOrder !== undefined) {
17318
+ if (typeof configObj.importOrder !== "number") {
17319
+ throw new Error(`Invalid config for provider '${name}': 'importOrder' must be a number`);
17320
+ }
17321
+ }
17322
+ return {
17323
+ detect,
17324
+ currencies,
17325
+ importOrder: configObj.importOrder
17326
+ };
17318
17327
  }
17319
17328
  function loadImportConfig(directory) {
17320
17329
  return loadYamlConfig(directory, CONFIG_FILE2, (parsedObj) => {
@@ -25254,9 +25263,14 @@ async function importPipeline(directory, agent, options, configLoader = loadImpo
25254
25263
  executePreprocessFiatStep(context, contextIds, logger);
25255
25264
  executePreprocessBtcStep(context, contextIds, logger);
25256
25265
  await executeBtcPurchaseStep(context, contextIds, logger);
25266
+ const importConfig = loadImportConfig(context.directory);
25257
25267
  const orderedContextIds = [...contextIds].sort((a, b) => {
25258
25268
  const ctxA = loadContext(context.directory, a);
25259
25269
  const ctxB = loadContext(context.directory, b);
25270
+ const orderA = importConfig.providers[ctxA.provider]?.importOrder ?? 0;
25271
+ const orderB = importConfig.providers[ctxB.provider]?.importOrder ?? 0;
25272
+ if (orderA !== orderB)
25273
+ return orderA - orderB;
25260
25274
  const isBtcA = ctxA.provider === "revolut" && ctxA.currency === "btc" ? 1 : 0;
25261
25275
  const isBtcB = ctxB.provider === "revolut" && ctxB.currency === "btc" ? 1 : 0;
25262
25276
  return isBtcA - isBtcB;
@@ -348,10 +348,13 @@ See [reconcile-statement](reconcile-statement.md) for details.
348
348
 
349
349
  ### Sequential Processing (Fail-Fast)
350
350
 
351
- The pipeline processes contexts **one at a time**:
351
+ The pipeline processes contexts **one at a time**, ordered by:
352
+
353
+ 1. **Provider `importOrder`** — lower values first (default: `0`). Configure in `providers.yaml` to control which provider imports first (e.g., UBS before Revolut).
354
+ 2. **BTC-last** — within the same `importOrder`, Revolut BTC contexts are sorted after fiat contexts (needed for fiat→BTC purchase matching).
352
355
 
353
356
  ```
354
- for each contextId:
357
+ for each contextId (sorted by importOrder, then BTC-last):
355
358
  1. Load context
356
359
  2. Run steps 2-4 for this context
357
360
  3. If ANY step fails → STOP PIPELINE
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fuzzle/opencode-accountant",
3
- "version": "0.9.0",
3
+ "version": "0.9.1",
4
4
  "description": "An OpenCode accounting agent, specialized in double-entry-bookkepping with hledger",
5
5
  "author": {
6
6
  "name": "ali bengali",