@fuzzle/opencode-accountant 0.16.5-next.1 → 0.16.5

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 +16 -46
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -17850,7 +17850,7 @@ function extractMetadata2(detection) {
17850
17850
  fromDate: metadata["from-date"],
17851
17851
  untilDate: metadata["until-date"],
17852
17852
  openingBalance: metadata["opening-balance"],
17853
- closingBalance: metadata["closing-balance"] ? parseFloat(metadata["closing-balance"]).toFixed(2) : undefined
17853
+ closingBalance: metadata["closing-balance"]
17854
17854
  };
17855
17855
  }
17856
17856
  function executeMoves(plannedMoves, config2, unrecognizedDir, directory) {
@@ -26997,7 +26997,6 @@ var TAX_TYPE = "Foreign Tax Withholding";
26997
26997
  var ADJUSTMENT_TYPE = "Adjustment";
26998
26998
  var FOREX_TYPE = "Forex Trade Component";
26999
26999
  var DEPOSIT_TYPE = "Deposit";
27000
- var round2 = (n) => Math.round(n * 100) / 100;
27001
27000
  function parseIbkrCsv(content) {
27002
27001
  const transactions = [];
27003
27002
  const result = import_papaparse3.default.parse(content, {
@@ -27103,8 +27102,6 @@ async function preprocessIbkr(csvPath, directory, currency, year, lotInventoryPa
27103
27102
  const content = fs22.readFileSync(csvPath, "utf-8");
27104
27103
  const transactions = parseIbkrCsv(content);
27105
27104
  logger?.info(`Parsed ${transactions.length} IBKR transactions from ${path17.basename(csvPath)}`);
27106
- let rawSum = 0;
27107
- let roundedSum = 0;
27108
27105
  const deposits = [];
27109
27106
  const trades = [];
27110
27107
  const dividendTxns = [];
@@ -27131,8 +27128,6 @@ async function preprocessIbkr(csvPath, directory, currency, year, lotInventoryPa
27131
27128
  const usedAccounts = new Set;
27132
27129
  const journalEntries = [];
27133
27130
  for (const trade of trades) {
27134
- rawSum += trade.netAmount;
27135
- roundedSum += round2(trade.netAmount);
27136
27131
  const totalCost = Math.abs(trade.grossAmount);
27137
27132
  const unitPrice = trade.quantity !== 0 ? totalCost / Math.abs(trade.quantity) : 0;
27138
27133
  const tradeEntry = {
@@ -27185,8 +27180,6 @@ async function preprocessIbkr(csvPath, directory, currency, year, lotInventoryPa
27185
27180
  const dividendGroups = groupDividends(dividendTxns);
27186
27181
  for (const group of dividendGroups) {
27187
27182
  const netAmount = group.grossAmount - group.withholdingTax;
27188
- rawSum += netAmount;
27189
- roundedSum += round2(netAmount);
27190
27183
  const dividendEntry = {
27191
27184
  date: group.date,
27192
27185
  account: group.account,
@@ -27239,52 +27232,29 @@ async function preprocessIbkr(csvPath, directory, currency, year, lotInventoryPa
27239
27232
  logger?.info(`Generated IBKR journal: ${journalPath} with ${journalEntries.length} entries`);
27240
27233
  }
27241
27234
  const simpleTransactions = [...deposits, ...adjustments, ...forexTxns];
27242
- for (const d of simpleTransactions) {
27243
- rawSum += d.netAmount;
27244
- roundedSum += round2(d.netAmount);
27245
- }
27246
- const csvRows = simpleTransactions.map((d) => [
27247
- d.date,
27248
- d.account,
27249
- `"${d.description.replace(/"/g, '""')}"`,
27250
- d.transactionType,
27251
- d.symbol,
27252
- d.quantity || "",
27253
- d.price || "",
27254
- d.priceCurrency,
27255
- d.grossAmount ? round2(d.grossAmount) : "",
27256
- d.commission ? round2(d.commission) : "",
27257
- round2(d.netAmount)
27258
- ].join(","));
27259
- const roundingAdj = round2(round2(rawSum) - roundedSum);
27260
- if (roundingAdj !== 0 && Math.abs(roundingAdj) <= 0.05) {
27261
- const lastDate = transactions[transactions.length - 1]?.date ?? "";
27262
- const account = transactions[0]?.account ?? "";
27263
- csvRows.push([
27264
- lastDate,
27265
- account,
27266
- '"Rounding adjustment"',
27267
- "Rounding",
27268
- "",
27269
- "",
27270
- "",
27271
- "",
27272
- "",
27273
- "",
27274
- roundingAdj
27275
- ].join(","));
27276
- logger?.info(`Added rounding adjustment: ${roundingAdj} CHF`);
27277
- }
27278
27235
  let simpleTransactionsCsvPath = null;
27279
- if (csvRows.length > 0) {
27236
+ if (simpleTransactions.length > 0) {
27280
27237
  const filteredCsvPath = path17.join(csvDir, `${csvBasename}-filtered.csv`);
27281
27238
  const csvHeader = "Date,Account,Description,Transaction Type,Symbol,Quantity,Price,Price Currency,Gross Amount,Commission,Net Amount";
27239
+ const csvRows = simpleTransactions.map((d) => [
27240
+ d.date,
27241
+ d.account,
27242
+ `"${d.description.replace(/"/g, '""')}"`,
27243
+ d.transactionType,
27244
+ d.symbol,
27245
+ d.quantity || "",
27246
+ d.price || "",
27247
+ d.priceCurrency,
27248
+ d.grossAmount ? Math.round(d.grossAmount * 100) / 100 : "",
27249
+ d.commission ? Math.round(d.commission * 100) / 100 : "",
27250
+ Math.round(d.netAmount * 100) / 100
27251
+ ].join(","));
27282
27252
  fs22.writeFileSync(filteredCsvPath, csvHeader + `
27283
27253
  ` + csvRows.join(`
27284
27254
  `) + `
27285
27255
  `);
27286
27256
  simpleTransactionsCsvPath = filteredCsvPath;
27287
- logger?.info(`Generated filtered CSV: ${filteredCsvPath} (${csvRows.length} rows)`);
27257
+ logger?.info(`Generated filtered CSV: ${filteredCsvPath} (${simpleTransactions.length} rows)`);
27288
27258
  }
27289
27259
  const dividendCount = dividendGroups.length;
27290
27260
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fuzzle/opencode-accountant",
3
- "version": "0.16.5-next.1",
3
+ "version": "0.16.5",
4
4
  "description": "An OpenCode accounting agent, specialized in double-entry-bookkepping with hledger",
5
5
  "author": {
6
6
  "name": "ali bengali",