@fuzzle/opencode-accountant 0.10.8-next.1 → 0.11.0
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 +10 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -25065,7 +25065,7 @@ function removeLots(inventory, symbol2, logger) {
|
|
|
25065
25065
|
return [];
|
|
25066
25066
|
}
|
|
25067
25067
|
const removedLots = [...lots];
|
|
25068
|
-
|
|
25068
|
+
inventory[symbol2] = [];
|
|
25069
25069
|
const totalQuantity = removedLots.reduce((sum, lot) => sum + lot.quantity, 0);
|
|
25070
25070
|
const totalCost = removedLots.reduce((sum, lot) => sum + lot.quantity * lot.costBasis, 0);
|
|
25071
25071
|
logger?.info(`Removed ${removedLots.length} lots for ${symbol2}: ${totalQuantity} shares, cost basis ${totalCost}`);
|
|
@@ -25234,17 +25234,18 @@ function generateWorthlessEntry(action, removedLots, logger) {
|
|
|
25234
25234
|
`;
|
|
25235
25235
|
return entry;
|
|
25236
25236
|
}
|
|
25237
|
-
function generateMultiWayMergerEntry(group, crossCurrencyOutgoingSymbols, logger) {
|
|
25237
|
+
function generateMultiWayMergerEntry(group, crossCurrencyOutgoingSymbols, crossCurrencyOutgoingIsins, logger) {
|
|
25238
25238
|
const date5 = formatDate(group.date);
|
|
25239
25239
|
const outSymbols = crossCurrencyOutgoingSymbols ?? group.outgoing.map((a) => a.symbol);
|
|
25240
25240
|
const inSymbols = group.incoming.map((a) => a.symbol);
|
|
25241
|
-
const
|
|
25241
|
+
const descriptionParts = outSymbols.join(" + ");
|
|
25242
|
+
const description = escapeDescription(inSymbols.length > 0 ? `Merger: ${descriptionParts} -> ${inSymbols.join(" + ")}` : `Merger: ${descriptionParts}`);
|
|
25242
25243
|
logger?.debug(`Generating multi-way merger entry: ${outSymbols.join(", ")} -> ${inSymbols.join(", ")}`);
|
|
25243
25244
|
let entry = `${date5} ${description}
|
|
25244
25245
|
`;
|
|
25245
25246
|
entry += ` ; swissquote:order:${group.orderNum}
|
|
25246
25247
|
`;
|
|
25247
|
-
const oldIsins = group.outgoing.map((a) => a.isin).filter(Boolean);
|
|
25248
|
+
const oldIsins = (crossCurrencyOutgoingIsins ?? group.outgoing.map((a) => a.isin)).filter(Boolean);
|
|
25248
25249
|
const newIsins = group.incoming.map((a) => a.isin).filter(Boolean);
|
|
25249
25250
|
if (oldIsins.length > 0 || newIsins.length > 0) {
|
|
25250
25251
|
entry += ` ; Old ISIN: ${oldIsins.join(", ") || "n/a"}, New ISINs: ${newIsins.join(", ") || "n/a"}
|
|
@@ -25546,7 +25547,7 @@ function processMultiWayMerger(group, inventory, lotInventoryPath, projectDir, l
|
|
|
25546
25547
|
inventory[inc.symbol].push(lot);
|
|
25547
25548
|
logger?.info(`Cross-currency merger incoming: ${absQty} ${inc.symbol} @ ${costBasisPerUnit.toFixed(2)} ${pendingState.currency}`);
|
|
25548
25549
|
}
|
|
25549
|
-
const entry2 = generateMultiWayMergerEntry(group, pendingState.outgoingSymbols, logger);
|
|
25550
|
+
const entry2 = generateMultiWayMergerEntry(group, pendingState.outgoingSymbols, pendingState.outgoingIsins, logger);
|
|
25550
25551
|
entries.push(entry2);
|
|
25551
25552
|
removePendingMerger(projectDir, lotInventoryPath, group.key, logger);
|
|
25552
25553
|
} else {
|
|
@@ -25577,9 +25578,12 @@ function processMultiWayMerger(group, inventory, lotInventoryPath, projectDir, l
|
|
|
25577
25578
|
date: group.date,
|
|
25578
25579
|
orderNum: group.orderNum,
|
|
25579
25580
|
outgoingSymbols,
|
|
25581
|
+
outgoingIsins: group.outgoing.map((a) => a.isin),
|
|
25580
25582
|
totalCostBasis,
|
|
25581
25583
|
currency: outgoingCurrency || "CAD"
|
|
25582
25584
|
}, logger);
|
|
25585
|
+
const entry2 = generateMultiWayMergerEntry(group, undefined, undefined, logger);
|
|
25586
|
+
entries.push(entry2);
|
|
25583
25587
|
logger?.info(`Cross-currency merger outgoing: ${outgoingSymbols.join(", ")} -> pending (cost basis: ${totalCostBasis.toFixed(2)})`);
|
|
25584
25588
|
return entries;
|
|
25585
25589
|
}
|
|
@@ -25608,7 +25612,7 @@ function processMultiWayMerger(group, inventory, lotInventoryPath, projectDir, l
|
|
|
25608
25612
|
inventory[inc.symbol].push(lot);
|
|
25609
25613
|
logger?.debug(`Merger incoming: added ${absQty} ${inc.symbol} @ ${costBasisPerUnit.toFixed(2)}`);
|
|
25610
25614
|
}
|
|
25611
|
-
const entry = generateMultiWayMergerEntry(group, undefined, logger);
|
|
25615
|
+
const entry = generateMultiWayMergerEntry(group, undefined, undefined, logger);
|
|
25612
25616
|
entries.push(entry);
|
|
25613
25617
|
return entries;
|
|
25614
25618
|
}
|