@fuzzle/opencode-accountant 0.10.4 → 0.10.5-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 +22 -17
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -24807,7 +24807,7 @@ import * as path13 from "path";
24807
24807
 
24808
24808
  // src/utils/symbolNormalizer.ts
24809
24809
  function normalizeSymbol(symbol2) {
24810
- return symbol2.toLowerCase().replace(/\./g, "-");
24810
+ return symbol2.toLowerCase();
24811
24811
  }
24812
24812
 
24813
24813
  // src/utils/swissquoteLotTracker.ts
@@ -25006,11 +25006,16 @@ function escapeDescription(desc) {
25006
25006
  function formatQuantity(qty) {
25007
25007
  return qty.toFixed(6).replace(/\.?0+$/, "");
25008
25008
  }
25009
+ function formatPrice(price) {
25010
+ const full = price.toFixed(6).replace(/0+$/, "");
25011
+ const [integer2, decimal = ""] = full.split(".");
25012
+ return `${integer2}.${decimal.padEnd(2, "0")}`;
25013
+ }
25009
25014
  function generateBuyEntry(trade, logger) {
25010
25015
  const date5 = formatDate(trade.date);
25011
25016
  const description = escapeDescription(`Buy ${trade.symbol} - ${trade.name}`);
25012
25017
  const qty = formatQuantity(trade.quantity);
25013
- const price = trade.unitPrice.toFixed(2);
25018
+ const price = formatPrice(trade.unitPrice);
25014
25019
  const totalCost = trade.quantity * trade.unitPrice;
25015
25020
  const fees = trade.costs;
25016
25021
  const cashOut = totalCost + fees;
@@ -25019,7 +25024,7 @@ function generateBuyEntry(trade, logger) {
25019
25024
  `;
25020
25025
  entry += ` ; swissquote:order:${trade.orderNum} isin:${trade.isin}
25021
25026
  `;
25022
- entry += ` assets:investments:stocks:${trade.symbol} ${qty} ${trade.symbol} @ ${price} ${trade.currency}
25027
+ entry += ` assets:investments:stocks:${trade.symbol} ${qty} @ ${price} ${trade.currency}
25023
25028
  `;
25024
25029
  if (fees > 0) {
25025
25030
  entry += ` expenses:fees:trading:swissquote ${formatAmount2(fees, trade.currency)}
@@ -25043,13 +25048,13 @@ function generateSellEntry(trade, consumed, logger) {
25043
25048
  `;
25044
25049
  entry += ` ; swissquote:order:${trade.orderNum} isin:${trade.isin}
25045
25050
  `;
25046
- const lotDetails = consumed.map((c) => `${c.lot.date}: ${formatQuantity(c.quantity)}@${c.lot.costBasis.toFixed(2)}`).join(", ");
25051
+ const lotDetails = consumed.map((c) => `${c.lot.date}: ${formatQuantity(c.quantity)}@${formatPrice(c.lot.costBasis)}`).join(", ");
25047
25052
  entry += ` ; FIFO lots: ${lotDetails}
25048
25053
  `;
25049
25054
  for (const c of consumed) {
25050
25055
  const lotQty = formatQuantity(c.quantity);
25051
- const lotPrice = c.lot.costBasis.toFixed(2);
25052
- entry += ` assets:investments:stocks:${trade.symbol} -${lotQty} ${trade.symbol} @ ${lotPrice} ${trade.currency}
25056
+ const lotPrice = formatPrice(c.lot.costBasis);
25057
+ entry += ` assets:investments:stocks:${trade.symbol} -${lotQty} @ ${lotPrice} ${trade.currency}
25053
25058
  `;
25054
25059
  }
25055
25060
  entry += ` assets:broker:swissquote:${trade.currency.toLowerCase()} ${formatAmount2(cashIn, trade.currency)}
@@ -25097,13 +25102,13 @@ function generateSplitEntry(action, oldQuantity, newQuantity, logger) {
25097
25102
  `;
25098
25103
  entry += ` ; Ratio: ${ratio.toFixed(4)} (${oldQuantity} -> ${newQuantity})
25099
25104
  `;
25100
- entry += ` assets:investments:stocks:${action.symbol} -${formatQuantity(oldQuantity)} ${action.symbol}
25105
+ entry += ` assets:investments:stocks:${action.symbol} -${formatQuantity(oldQuantity)}
25101
25106
  `;
25102
- entry += ` equity:conversion ${formatQuantity(oldQuantity)} ${action.symbol}
25107
+ entry += ` equity:conversion ${formatQuantity(oldQuantity)}
25103
25108
  `;
25104
- entry += ` equity:conversion -${formatQuantity(newQuantity)} ${action.symbol}
25109
+ entry += ` equity:conversion -${formatQuantity(newQuantity)}
25105
25110
  `;
25106
- entry += ` assets:investments:stocks:${action.symbol} ${formatQuantity(newQuantity)} ${action.symbol}
25111
+ entry += ` assets:investments:stocks:${action.symbol} ${formatQuantity(newQuantity)}
25107
25112
  `;
25108
25113
  return entry;
25109
25114
  }
@@ -25122,8 +25127,8 @@ function generateWorthlessEntry(action, removedLots, logger) {
25122
25127
  `;
25123
25128
  for (const lot of removedLots) {
25124
25129
  const qty = formatQuantity(lot.quantity);
25125
- const price = lot.costBasis.toFixed(2);
25126
- entry += ` assets:investments:stocks:${action.symbol} -${qty} ${action.symbol} @ ${price} ${currency}
25130
+ const price = formatPrice(lot.costBasis);
25131
+ entry += ` assets:investments:stocks:${action.symbol} -${qty} @ ${price} ${currency}
25127
25132
  `;
25128
25133
  }
25129
25134
  entry += ` expenses:losses:capital ${formatAmount2(totalCost, currency)}
@@ -25148,16 +25153,16 @@ function generateMultiWayMergerEntry(group, crossCurrencyOutgoingSymbols, logger
25148
25153
  }
25149
25154
  for (const out of group.outgoing) {
25150
25155
  const qty = formatQuantity(Math.abs(out.quantity));
25151
- entry += ` assets:investments:stocks:${out.symbol} -${qty} ${out.symbol}
25156
+ entry += ` assets:investments:stocks:${out.symbol} -${qty}
25152
25157
  `;
25153
- entry += ` equity:conversion ${qty} ${out.symbol}
25158
+ entry += ` equity:conversion ${qty}
25154
25159
  `;
25155
25160
  }
25156
25161
  for (const inc of group.incoming) {
25157
25162
  const qty = formatQuantity(Math.abs(inc.quantity));
25158
- entry += ` equity:conversion -${qty} ${inc.symbol}
25163
+ entry += ` equity:conversion -${qty}
25159
25164
  `;
25160
- entry += ` assets:investments:stocks:${inc.symbol} ${qty} ${inc.symbol}
25165
+ entry += ` assets:investments:stocks:${inc.symbol} ${qty}
25161
25166
  `;
25162
25167
  }
25163
25168
  return entry;
@@ -25171,7 +25176,7 @@ function generateRightsDistributionEntry(action, logger) {
25171
25176
  `;
25172
25177
  entry += ` ; swissquote:order:${action.orderNum} isin:${action.isin}
25173
25178
  `;
25174
- entry += ` assets:investments:stocks:${action.symbol} ${qty} ${action.symbol} @ 0.00 CAD
25179
+ entry += ` assets:investments:stocks:${action.symbol} ${qty} @ 0.00 CAD
25175
25180
  `;
25176
25181
  entry += ` income:capital-gains:rights-distribution 0.00 CAD
25177
25182
  `;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fuzzle/opencode-accountant",
3
- "version": "0.10.4",
3
+ "version": "0.10.5-next.1",
4
4
  "description": "An OpenCode accounting agent, specialized in double-entry-bookkepping with hledger",
5
5
  "author": {
6
6
  "name": "ali bengali",