Skip to content

Commit

Permalink
Minimal rename of internal_id_int to row
Browse files Browse the repository at this point in the history
  • Loading branch information
qwhelan committed Jun 7, 2024
1 parent 554b06d commit 6db4677
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
10 changes: 6 additions & 4 deletions src/rp2/abstract_transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def __init__(
asset: str,
transaction_type: str,
spot_price: RP2Decimal,
internal_id: Optional[int] = None,
row: Optional[int] = None,
unique_id: Optional[str] = None,
notes: Optional[str] = None,
) -> None:
Expand All @@ -39,7 +39,9 @@ def __init__(
self.__timestamp: datetime = configuration.type_check_timestamp_from_string("timestamp", timestamp)
self.__transaction_type: TransactionType = TransactionType.type_check_from_string("transaction_type", transaction_type)
self.__spot_price: RP2Decimal = configuration.type_check_positive_decimal("spot_price", spot_price)
self.__internal_id: int = configuration.type_check_internal_id("internal_id", internal_id) if internal_id is not None else id(self)
# TODO: the fallback case does not semantically match "row", make non-optional # pylint: disable=fixme
self.__row: int = configuration.type_check_internal_id("row", row) if row is not None else id(self)
self.__internal_id: int = self.__row
self.__unique_id: str = configuration.type_check_string_or_integer("unique_id", unique_id) if unique_id is not None else ""
self.__notes = configuration.type_check_string("notes", notes) if notes else ""

Expand Down Expand Up @@ -87,8 +89,8 @@ def internal_id(self) -> str:
return str(self.__internal_id)

@property
def internal_id_int(self) -> int:
return self.__internal_id
def row(self) -> int:
return self.__row

@property
def timestamp(self) -> datetime:
Expand Down
2 changes: 1 addition & 1 deletion src/rp2/plugin/accounting_method/hifo.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,4 @@ def lot_candidates_order(self) -> AcquiredLotCandidatesOrder:
return AcquiredLotCandidatesOrder.OLDER_TO_NEWER

def heap_key(self, lot: InTransaction) -> AcquiredLotHeapSortKey:
return AcquiredLotHeapSortKey(-lot.spot_price, lot.timestamp.timestamp(), lot.internal_id_int)
return AcquiredLotHeapSortKey(-lot.spot_price, lot.timestamp.timestamp(), lot.row)
2 changes: 1 addition & 1 deletion src/rp2/plugin/accounting_method/lifo.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,4 @@ def lot_candidates_order(self) -> AcquiredLotCandidatesOrder:
return AcquiredLotCandidatesOrder.NEWER_TO_OLDER

def heap_key(self, lot: InTransaction) -> AcquiredLotHeapSortKey:
return AcquiredLotHeapSortKey(ZERO, -lot.timestamp.timestamp(), -lot.internal_id_int)
return AcquiredLotHeapSortKey(ZERO, -lot.timestamp.timestamp(), -lot.row)

0 comments on commit 6db4677

Please sign in to comment.