@fuzzle/opencode-accountant 0.16.5-next.1 → 0.16.6-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.
- package/dist/index.js +31 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -26903,6 +26903,16 @@ function generateIbkrBuyEntry(trade, logger) {
|
|
|
26903
26903
|
account: `assets:broker:ibkr:${trade.currency.toLowerCase()}`,
|
|
26904
26904
|
amount: formatAmount(-cashOut, trade.currency)
|
|
26905
26905
|
});
|
|
26906
|
+
const computedNetCents = Math.round(totalCost * 100) + Math.round(fees * 100);
|
|
26907
|
+
const brokerNetCents = Math.round(cashOut * 100);
|
|
26908
|
+
const roundingCents = brokerNetCents - computedNetCents;
|
|
26909
|
+
if (roundingCents !== 0) {
|
|
26910
|
+
postings.push({
|
|
26911
|
+
account: "equity:rounding",
|
|
26912
|
+
amount: formatAmount(roundingCents / 100, trade.currency)
|
|
26913
|
+
});
|
|
26914
|
+
logger?.debug(`Rounding adjustment: ${roundingCents / 100} ${trade.currency}`);
|
|
26915
|
+
}
|
|
26906
26916
|
let entry = `${trade.date} ${description}
|
|
26907
26917
|
`;
|
|
26908
26918
|
entry += ` ; ibkr:account:${trade.account}
|
|
@@ -26952,6 +26962,16 @@ function generateIbkrSellEntry(trade, consumed, logger) {
|
|
|
26952
26962
|
amount: formatAmount(-capitalGain, trade.currency)
|
|
26953
26963
|
});
|
|
26954
26964
|
}
|
|
26965
|
+
const computedNetCents = Math.round(saleProceeds * 100) - Math.round(fees * 100);
|
|
26966
|
+
const brokerNetCents = Math.round(Math.abs(cashIn) * 100);
|
|
26967
|
+
const roundingCents = computedNetCents - brokerNetCents;
|
|
26968
|
+
if (roundingCents !== 0) {
|
|
26969
|
+
postings.push({
|
|
26970
|
+
account: "equity:rounding",
|
|
26971
|
+
amount: formatAmount(roundingCents / 100, trade.currency)
|
|
26972
|
+
});
|
|
26973
|
+
logger?.debug(`Rounding adjustment: ${roundingCents / 100} ${trade.currency}`);
|
|
26974
|
+
}
|
|
26955
26975
|
let entry = `${trade.date} ${description}
|
|
26956
26976
|
`;
|
|
26957
26977
|
entry += ` ; ibkr:account:${trade.account}
|
|
@@ -26981,6 +27001,16 @@ function generateIbkrDividendEntry(dividend, logger) {
|
|
|
26981
27001
|
account: `income:dividends:${dividend.symbol}`,
|
|
26982
27002
|
amount: formatAmount(-dividend.grossAmount, dividend.currency)
|
|
26983
27003
|
});
|
|
27004
|
+
const computedNetCents = Math.round(dividend.grossAmount * 100) - Math.round(dividend.withholdingTax * 100);
|
|
27005
|
+
const brokerNetCents = Math.round(dividend.netAmount * 100);
|
|
27006
|
+
const roundingCents = brokerNetCents - computedNetCents;
|
|
27007
|
+
if (roundingCents !== 0) {
|
|
27008
|
+
postings.push({
|
|
27009
|
+
account: "equity:rounding",
|
|
27010
|
+
amount: formatAmount(roundingCents / 100, dividend.currency)
|
|
27011
|
+
});
|
|
27012
|
+
logger?.debug(`Rounding adjustment: ${roundingCents / 100} ${dividend.currency}`);
|
|
27013
|
+
}
|
|
26984
27014
|
let entry = `${dividend.date} ${description}
|
|
26985
27015
|
`;
|
|
26986
27016
|
entry += ` ; ibkr:account:${dividend.account}
|
|
@@ -27131,8 +27161,6 @@ async function preprocessIbkr(csvPath, directory, currency, year, lotInventoryPa
|
|
|
27131
27161
|
const usedAccounts = new Set;
|
|
27132
27162
|
const journalEntries = [];
|
|
27133
27163
|
for (const trade of trades) {
|
|
27134
|
-
rawSum += trade.netAmount;
|
|
27135
|
-
roundedSum += round2(trade.netAmount);
|
|
27136
27164
|
const totalCost = Math.abs(trade.grossAmount);
|
|
27137
27165
|
const unitPrice = trade.quantity !== 0 ? totalCost / Math.abs(trade.quantity) : 0;
|
|
27138
27166
|
const tradeEntry = {
|
|
@@ -27185,8 +27213,6 @@ async function preprocessIbkr(csvPath, directory, currency, year, lotInventoryPa
|
|
|
27185
27213
|
const dividendGroups = groupDividends(dividendTxns);
|
|
27186
27214
|
for (const group of dividendGroups) {
|
|
27187
27215
|
const netAmount = group.grossAmount - group.withholdingTax;
|
|
27188
|
-
rawSum += netAmount;
|
|
27189
|
-
roundedSum += round2(netAmount);
|
|
27190
27216
|
const dividendEntry = {
|
|
27191
27217
|
date: group.date,
|
|
27192
27218
|
account: group.account,
|
|
@@ -27231,6 +27257,7 @@ async function preprocessIbkr(csvPath, directory, currency, year, lotInventoryPa
|
|
|
27231
27257
|
const commodityJournalPath = path17.join(directory, "ledger", "investments", "commodities.journal");
|
|
27232
27258
|
ensureCommodityDeclarations(commodityJournalPath, tradedSymbols, logger);
|
|
27233
27259
|
}
|
|
27260
|
+
usedAccounts.add("equity:rounding");
|
|
27234
27261
|
if (usedAccounts.size > 0) {
|
|
27235
27262
|
const accountJournalPath = path17.join(directory, "ledger", "investments", "accounts.journal");
|
|
27236
27263
|
ensureInvestmentAccountDeclarations(accountJournalPath, usedAccounts, logger);
|
package/package.json
CHANGED