Skip to content

Commit

Permalink
Improved some comments
Browse files Browse the repository at this point in the history
  • Loading branch information
eprbell committed Nov 16, 2024
1 parent bc75d8f commit 5691a26
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/rp2/abstract_accounting_method.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ def seek_non_exhausted_acquired_lot(
if not isinstance(lot_candidates, FeatureBasedAcquiredLotCandidates):
raise RP2TypeError(f"Internal error: lot_candidates is not of type FeatureBasedAcquiredLotCandidates, but of type {type(lot_candidates)}")
# This plugin features O(n * log(m)) complexity, where n is the number
# of transactions and m is the number of unexhausted acquistion lots
# of transactions and m is the number of unexhausted acquisition lots
for acquired_lot in lot_candidates:
acquired_lot_amount: RP2Decimal = ZERO

Expand Down
7 changes: 4 additions & 3 deletions src/rp2/accounting_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def get_next_taxable_event_and_amount(
new_taxable_event_amount: RP2Decimal = new_taxable_event.crypto_balance_change

# If the new taxable event is newer than the old one (and it's not earn-typed) check if there is a newer acquired lot that
# meets the accounting method criteria (but it's still older than the new taxable event)
# meets the accounting method criteria (but it's still older than the new taxable event).
if taxable_event and taxable_event.timestamp < new_taxable_event.timestamp:
if acquired_lot:
self._set_partial_amount(acquired_lot, new_acquired_lot_amount)
Expand All @@ -189,8 +189,7 @@ def get_next_taxable_event_and_amount(
acquired_lot_amount=new_acquired_lot_amount,
)

# After selecting the taxable event, RP2 calls this function to find the acquired_lot to pair with it. This means that the taxable
# event can be passed to this function (which is useful for certain accounting methods)
# After selecting the taxable event, RP2 calls this function to find the acquired_lot to pair with it.
def get_acquired_lot_for_taxable_event(
self,
taxable_event: AbstractTransaction,
Expand All @@ -199,6 +198,8 @@ def get_acquired_lot_for_taxable_event(
acquired_lot_amount: RP2Decimal,
) -> TaxableEventAndAcquiredLot:
new_taxable_event_amount: RP2Decimal = taxable_event_amount - acquired_lot_amount
# Find the acquired_lot and index just before the taxable event: the index is used as an upper bound
# in the search of acquired lot candidates (see set_to_index() below).
acquired_lot_and_index: Optional[_AcquiredLotAndIndex] = self.__acquired_lot_avl.find_max_value_less_than(
self._get_avl_node_key_with_max_disambiguator(taxable_event.timestamp)
)
Expand Down

0 comments on commit 5691a26

Please sign in to comment.