Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make LIFO/HIFO accounting methods O(n*log(m)) #116

Merged
merged 15 commits into from
Jun 9, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Only add lot back to heap if it will not be completely consumed
  • Loading branch information
qwhelan committed Jun 1, 2024
commit 21f9e184fc2d076d893c38bb8af9e2ef821083a9
3 changes: 2 additions & 1 deletion src/rp2/plugin/accounting_method/hifo.py
Original file line number Diff line number Diff line change
@@ -59,7 +59,8 @@ def seek_non_exhausted_acquired_lot(

if selected_acquired_lot_amount > ZERO and selected_acquired_lot:
lot_candidates.clear_partial_amount(selected_acquired_lot)
lot_candidates.add_selected_lot_to_heap(selected_acquired_lot)
if selected_acquired_lot_amount > taxable_event_amount:
eprbell marked this conversation as resolved.
Show resolved Hide resolved
lot_candidates.add_selected_lot_to_heap(selected_acquired_lot)
return AcquiredLotAndAmount(acquired_lot=selected_acquired_lot, amount=selected_acquired_lot_amount)
return None

3 changes: 2 additions & 1 deletion src/rp2/plugin/accounting_method/lifo.py
Original file line number Diff line number Diff line change
@@ -60,7 +60,8 @@ def seek_non_exhausted_acquired_lot(

if selected_acquired_lot_amount > ZERO and selected_acquired_lot:
lot_candidates.clear_partial_amount(selected_acquired_lot)
lot_candidates.add_selected_lot_to_heap(selected_acquired_lot)
if selected_acquired_lot_amount > taxable_event_amount:
eprbell marked this conversation as resolved.
Show resolved Hide resolved
lot_candidates.add_selected_lot_to_heap(selected_acquired_lot)
return AcquiredLotAndAmount(acquired_lot=selected_acquired_lot, amount=selected_acquired_lot_amount)
return None