fix(portfolio): tolerate consolidation WAC residue
This commit is contained in:
@@ -16,3 +16,16 @@ def test_stock_consolidation_rejects_fractional_result():
|
||||
with pytest.raises(CorporateActionError) as exc:
|
||||
calculate_stock_consolidation(Decimal(3), Decimal("1.5"), Decimal(10))
|
||||
assert exc.value.code == "FRACTIONAL_RESULT_UNSUPPORTED"
|
||||
|
||||
|
||||
def test_stock_consolidation_allows_stored_wac_rounding_residue():
|
||||
result = calculate_stock_consolidation(
|
||||
Decimal(1452),
|
||||
Decimal(726),
|
||||
Decimal("1086.234145936639256198347107438016528926"),
|
||||
)
|
||||
|
||||
assert result.average_price_before == Decimal("1086.23414594")
|
||||
assert result.average_price_after == Decimal("2172.46829187")
|
||||
assert result.total_cost_basis == Decimal("1577211.97990000")
|
||||
assert result.total_cost_basis - result.average_price_after * result.quantity_after == Decimal("0.00000238")
|
||||
|
||||
Reference in New Issue
Block a user