@fuzzle/opencode-accountant 0.16.1-next.1 → 0.16.2-next.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 +51 -2
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -16987,6 +16987,7 @@ function loadPricesConfig(directory) {
16987
16987
  }
16988
16988
 
16989
16989
  // src/utils/journalUtils.ts
16990
+ init_js_yaml();
16990
16991
  import * as fs4 from "fs";
16991
16992
  import * as path3 from "path";
16992
16993
 
@@ -17178,6 +17179,50 @@ function ensureInvestmentAccountDeclarations(accountJournalPath, accounts, logge
17178
17179
  logger?.info(`Account declarations: added ${missing.length} (${missing.join(", ")})`);
17179
17180
  return { added: missing.sort(), updated: true };
17180
17181
  }
17182
+ function ensureStockPriceEntries(directory, symbols, logger) {
17183
+ const pricesPath = path3.join(directory, "config", "prices.yaml");
17184
+ if (!fs4.existsSync(pricesPath)) {
17185
+ return { added: [], updated: false };
17186
+ }
17187
+ const content = fs4.readFileSync(pricesPath, "utf-8");
17188
+ const parsed = jsYaml.load(content);
17189
+ const existingStocks = new Set;
17190
+ if (parsed?.stocks && typeof parsed.stocks === "object" && !Array.isArray(parsed.stocks)) {
17191
+ for (const key of Object.keys(parsed.stocks)) {
17192
+ existingStocks.add(key);
17193
+ }
17194
+ }
17195
+ const missing = [];
17196
+ for (const symbol2 of symbols) {
17197
+ const ticker = symbol2.toUpperCase();
17198
+ if (!existingStocks.has(ticker)) {
17199
+ missing.push(ticker);
17200
+ }
17201
+ }
17202
+ if (missing.length === 0) {
17203
+ return { added: [], updated: false };
17204
+ }
17205
+ let updatedContent = content;
17206
+ if (!parsed?.stocks) {
17207
+ updatedContent = updatedContent.trimEnd() + `
17208
+
17209
+ stocks:
17210
+ `;
17211
+ }
17212
+ if (!updatedContent.endsWith(`
17213
+ `)) {
17214
+ updatedContent += `
17215
+ `;
17216
+ }
17217
+ const sorted = missing.sort();
17218
+ for (const ticker of sorted) {
17219
+ updatedContent += ` ${ticker}:
17220
+ `;
17221
+ }
17222
+ fs4.writeFileSync(pricesPath, updatedContent);
17223
+ logger?.info(`Price config: added ${sorted.length} stock(s) (${sorted.join(", ")})`);
17224
+ return { added: sorted, updated: true };
17225
+ }
17181
17226
 
17182
17227
  // src/utils/dateUtils.ts
17183
17228
  function formatDateISO(date5) {
@@ -17506,7 +17551,9 @@ function validateProviderConfig(name, config2) {
17506
17551
  return {
17507
17552
  detect,
17508
17553
  currencies,
17509
- importOrder: configObj.importOrder
17554
+ importOrder: configObj.importOrder,
17555
+ lotInventoryPath: typeof configObj.lotInventoryPath === "string" ? configObj.lotInventoryPath : undefined,
17556
+ symbolMapPath: typeof configObj.symbolMapPath === "string" ? configObj.symbolMapPath : undefined
17510
17557
  };
17511
17558
  }
17512
17559
  function loadImportConfig(directory) {
@@ -26428,6 +26475,7 @@ async function preprocessSwissquote(csvPath, projectDir, currency, year, lotInve
26428
26475
  investmentAccounts.add(`equity:conversion:${currency.toLowerCase()}`);
26429
26476
  investmentAccounts.add("equity:rounding");
26430
26477
  ensureInvestmentAccountDeclarations(accountJournalPath, investmentAccounts, logger);
26478
+ ensureStockPriceEntries(projectDir, stockSymbols, logger);
26431
26479
  }
26432
26480
  logger?.logResult({
26433
26481
  totalRows: stats.totalRows,
@@ -27020,7 +27068,7 @@ function parseIbkrCsv(content) {
27020
27068
  const account = values[3]?.trim() || "";
27021
27069
  const description = values[4]?.trim() || "";
27022
27070
  const transactionType = values[5]?.trim() || "";
27023
- const symbol2 = values[6]?.trim() || "";
27071
+ const symbol2 = normalizeSymbol(values[6]?.trim() || "");
27024
27072
  const quantity = parseFloat(values[7] || "0") || 0;
27025
27073
  const price = parseFloat(values[8] || "0") || 0;
27026
27074
  const priceCurrency = values[9]?.trim() || "";
@@ -27255,6 +27303,7 @@ async function preprocessIbkr(csvPath, directory, currency, year, lotInventoryPa
27255
27303
  const accountJournalPath = path17.join(directory, "ledger", "investments", "accounts.journal");
27256
27304
  ensureInvestmentAccountDeclarations(accountJournalPath, usedAccounts, logger);
27257
27305
  }
27306
+ ensureStockPriceEntries(directory, tradedSymbols, logger);
27258
27307
  logger?.info(`Generated IBKR journal: ${journalPath} with ${journalEntries.length} entries`);
27259
27308
  }
27260
27309
  let simpleTransactionsCsvPath = null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fuzzle/opencode-accountant",
3
- "version": "0.16.1-next.1",
3
+ "version": "0.16.2-next.1",
4
4
  "description": "An OpenCode accounting agent, specialized in double-entry-bookkepping with hledger",
5
5
  "author": {
6
6
  "name": "ali bengali",