@fuzzle/opencode-accountant 0.13.16-next.1 → 0.13.17-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 +44 -2
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -25462,6 +25462,18 @@ function generateMultiWayMergerEntry(group, crossCurrencyOutgoingSymbols, crossC
25462
25462
  entries.push(sub);
25463
25463
  }
25464
25464
  }
25465
+ if (group.cashSettlement) {
25466
+ const cashCurrency = group.cashSettlement.currency.toLowerCase();
25467
+ const cashAmount = formatAmount2(group.cashSettlement.amount, group.cashSettlement.currency);
25468
+ let sub = `${date5} ${description}
25469
+ `;
25470
+ sub += metadata;
25471
+ sub += ` assets:broker:swissquote:${cashCurrency} ${cashAmount}
25472
+ `;
25473
+ sub += ` income:capital-gains:realized
25474
+ `;
25475
+ entries.push(sub);
25476
+ }
25465
25477
  return entries.join(`
25466
25478
  `);
25467
25479
  }
@@ -26034,6 +26046,7 @@ async function preprocessSwissquote(csvPath, projectDir, currency, year, lotInve
26034
26046
  const dividends = [];
26035
26047
  const corporateActions = [];
26036
26048
  const forexTransactions = [];
26049
+ const mergerCashSettlements = [];
26037
26050
  for (const txn of transactions) {
26038
26051
  const category = categorizeTransaction(txn);
26039
26052
  switch (category) {
@@ -26052,8 +26065,12 @@ async function preprocessSwissquote(csvPath, projectDir, currency, year, lotInve
26052
26065
  case "corporate":
26053
26066
  if (!txn.symbol || txn.symbol.trim() === "") {
26054
26067
  if (txn.netAmount && txn.netAmount !== "-") {
26055
- simpleTransactions.push(txn);
26056
- stats.simpleTransactions++;
26068
+ mergerCashSettlements.push({
26069
+ dateOrderKey: `${txn.date}-${txn.orderNum}`,
26070
+ amount: parseNumber(txn.netAmount),
26071
+ currency: txn.currency
26072
+ });
26073
+ stats.corporateActions++;
26057
26074
  } else {
26058
26075
  stats.skipped++;
26059
26076
  }
@@ -26097,6 +26114,31 @@ async function preprocessSwissquote(csvPath, projectDir, currency, year, lotInve
26097
26114
  }
26098
26115
  }
26099
26116
  const mergerGroups = groupMergerActions(mergerActions);
26117
+ for (const cash of mergerCashSettlements) {
26118
+ const matchingGroup = mergerGroups.find((g) => g.key === cash.dateOrderKey);
26119
+ if (matchingGroup) {
26120
+ matchingGroup.cashSettlement = { amount: cash.amount, currency: cash.currency };
26121
+ } else {
26122
+ simpleTransactions.push({
26123
+ date: cash.dateOrderKey.split("-").slice(0, 3).join("-"),
26124
+ orderNum: cash.dateOrderKey.split("-").slice(3).join("-"),
26125
+ transaction: "Merger",
26126
+ symbol: "",
26127
+ name: "",
26128
+ isin: "",
26129
+ quantity: "",
26130
+ unitPrice: "",
26131
+ costs: "",
26132
+ accruedInterest: "",
26133
+ netAmount: String(cash.amount),
26134
+ balance: "",
26135
+ currency: cash.currency
26136
+ });
26137
+ stats.simpleTransactions++;
26138
+ stats.corporateActions--;
26139
+ logger?.warn(`Cash settlement ${cash.dateOrderKey} has no matching merger group \u2014 routed to simple CSV`);
26140
+ }
26141
+ }
26100
26142
  for (const group of mergerGroups) {
26101
26143
  timeline.push({ kind: "mergerGroup", sortDate: formatDate(group.date), group });
26102
26144
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fuzzle/opencode-accountant",
3
- "version": "0.13.16-next.1",
3
+ "version": "0.13.17-next.1",
4
4
  "description": "An OpenCode accounting agent, specialized in double-entry-bookkepping with hledger",
5
5
  "author": {
6
6
  "name": "ali bengali",