@fuzzle/opencode-accountant 0.7.1-next.1 → 0.7.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.
Files changed (2) hide show
  1. package/dist/index.js +13 -13
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -17417,18 +17417,11 @@ function normalizeHeader(fields) {
17417
17417
  function detectProvider(filename, content, config2) {
17418
17418
  for (const [providerName, providerConfig] of Object.entries(config2.providers)) {
17419
17419
  for (const rule of providerConfig.detect) {
17420
- let filenameMetadata = {};
17421
17420
  if (rule.filenamePattern !== undefined) {
17422
17421
  const filenameRegex = new RegExp(rule.filenamePattern);
17423
- const filenameMatch = filenameRegex.exec(filename);
17424
- if (!filenameMatch) {
17422
+ if (!filenameRegex.test(filename)) {
17425
17423
  continue;
17426
17424
  }
17427
- if (filenameMatch.groups) {
17428
- for (const [key, value] of Object.entries(filenameMatch.groups)) {
17429
- filenameMetadata[key.replace(/_/g, "-")] = value;
17430
- }
17431
- }
17432
17425
  }
17433
17426
  const skipRows = rule.skipRows ?? 0;
17434
17427
  const delimiter = rule.delimiter ?? ",";
@@ -17447,20 +17440,27 @@ function detectProvider(filename, content, config2) {
17447
17440
  if (!rawCurrency) {
17448
17441
  continue;
17449
17442
  }
17450
- const headerMetadata = extractMetadata(content, skipRows, delimiter, rule.metadata);
17451
- const metadata = { ...filenameMetadata, ...headerMetadata };
17443
+ const metadata = extractMetadata(content, skipRows, delimiter, rule.metadata);
17452
17444
  if (rule.closingBalanceField) {
17453
17445
  const closingBalance = extractLastRowField(content, skipRows, delimiter, rule.closingBalanceField);
17454
17446
  if (closingBalance) {
17455
17447
  metadata["closing-balance"] = closingBalance;
17456
17448
  }
17457
17449
  }
17458
- const normalizedCurrency = providerConfig.currencies[rawCurrency];
17459
- metadata["currency"] = normalizedCurrency || rawCurrency.toLowerCase();
17460
17450
  const outputFilename = generateOutputFilename(rule.renamePattern, metadata);
17451
+ const normalizedCurrency = providerConfig.currencies[rawCurrency];
17452
+ if (!normalizedCurrency) {
17453
+ return {
17454
+ provider: providerName,
17455
+ currency: rawCurrency.toLowerCase(),
17456
+ rule,
17457
+ outputFilename,
17458
+ metadata: Object.keys(metadata).length > 0 ? metadata : undefined
17459
+ };
17460
+ }
17461
17461
  return {
17462
17462
  provider: providerName,
17463
- currency: normalizedCurrency || rawCurrency.toLowerCase(),
17463
+ currency: normalizedCurrency,
17464
17464
  rule,
17465
17465
  outputFilename,
17466
17466
  metadata: Object.keys(metadata).length > 0 ? metadata : undefined
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fuzzle/opencode-accountant",
3
- "version": "0.7.1-next.1",
3
+ "version": "0.7.1",
4
4
  "description": "An OpenCode accounting agent, specialized in double-entry-bookkepping with hledger",
5
5
  "author": {
6
6
  "name": "ali bengali",