-
Notifications
You must be signed in to change notification settings - Fork 45
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
Add more output to acquired lots exhausted exception. #110
Open
jayr0d
wants to merge
2
commits into
eprbell:main
Choose a base branch
from
jayr0d:AcquiredLotsExhaustedException
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately this is not quite correct: line 196 doesn't capture
acquired_lot_amount - taxable_event_amount < 0
(this is already captured above at line 179 and is a condition related to an individual couple of acquired lot and taxable event). Line 196 captures the fact that acquired lots have been exhausted for the given taxable event using the given accounting method, so it's not even possible to try with the next acquired lot, because there are no more (unlike what happens at line 176).When running into this, the solution is to enable debug logs (by prepending the command with
LOG_LEVEL=DEBUG
) and carefully analyze the various logs starting with "tax_engine: " (see above in this file). This will lead to pinpointing the problem.I think this is an important issue though: it probably deserves a user FAQ.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the feedback. I will look into this further (run through debug logs for a specific case) when I have a chance.
It might be good to give some user direction in the exception output, even if that is a redirection to LOG_LEVEL=DEBUG. In my case I did find the time and value at the time of occurrence useful, but it sounds like I at least got the value wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think this PR could change to:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please consider the following and let me know your thoughts.
Setting an environment variable varies by environment. In PowerShell for example, it needs to be set via a different execution line, such as:
$Env:LOG_LEVEL = "DEBUG"
I modified my data set to reintroduce one of the issues I cited and ran with LOG_LEVEL=DEBUG. If we are going to redirect the user to debug logging, they will need to navigate to the end of the log file and look for the DEBUG: tax_engine as you suggest, where the last entry will be taxable > acquired. It is likely there will be many other entries with id=y->x as it searches for acquired lots to meet the taxable out transaction. In my case, there were almost 300 lots (x) to try and account for y. There is also no direct output to the user the amount they are negative by; the user needs to calculate it manually from the last "DEBUG: tax_engine: taxable > acquired ..." output.
The change I made does output the transaction information for the correct id (y). I think it does well to point the user in the right direction. Each time I had this problem I needed to know when/where I went negative and scrutinize in that area, and this clearly points that out.
I recommend still printing the offending output transaction information when this condition is met, since it is a fatal exception and I think most of the time this will be enough information for the user to determine what the problem is and they will not actually need to turn on debug. I think this is a more user friendly approach and that is my goal, to make transitioning to DaLI and RP2 easier.
Whether you want the output transaction in the normal output or not, I can take a stab at modifying the output to refer to an FAQ section where both DEBUG and review of the DEBUG logs can be described.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at this a bit more it does seem the values I am populating for "Total in-transaction crypto value - total taxable crypto value" are for the individual taxable and acquired lot portion, and not the total. Maybe something like:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The way I see it is that the CSV files are meant as an "in progress" version of the "Gain / Loss Detail" table in the rp2_full_report.ods output file. So they should contain similar data. We could have one CSV file per asset to keep things easy for the user.
I suggest appending one new CSV row for the current gain loss entry at this location: https://github.com/eprbell/rp2/blob/main/src/rp2/gain_loss_set.py#L129 (just before the "if" statement).
For reference you can look at
_fill_cell
calls here: https://github.com/eprbell/rp2/blob/main/src/rp2/plugin/report/rp2_full_report.py#L802 (it's where the columns of the "Gain / Loss Detail" table are filled).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the pointers, I certainly don't know the best place in the code to insert new behavior.
I was not suggesting one CSV per asset. One asset should not have direct impact on the other. Also, since this error condition results in termination, not all assets will be processed.
If the intent is to show the user as much information as possible (all assets, not just the one that ran into the error), and the intent is to show the user information in a manner similar to the Asset Tax sheet in the full report, I wonder if it is just best to ignore the difference and keep going, and reporting it to the user (something like an auto-balance I was suggesting). They will know there is an issue to look into, they will get the output in a similar manner as they would the full report, and they will get all of the other features like being able to click around and navigate throughout the ODS report. No need to use CSV files with no "features".
I think in either case it is beneficial to add a balance column to the In-Out sheet and now I guess the Tax sheet as well, since Crypto (In/Out/Intra/Amt) Running Sum is in both of those.
Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting thought... this will need to be experimented with a bit. We need to understand if there are any side effects of not interrupting execution. I guess to start with we can change the exceptions that are raised in
tax_engine.py:_create_unfiltered_gain_and_loss_set()
to a new custom exception (e.g. RP2AccountingMethodException) and capture that in the caller, which iscompute_tax()
in the same file.Let's do the balance column addition in a separate PR to keep things simple (that will require updating the golden files).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I will work on the balance column addition first, probably not this week.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a working prototype for in, out, and intra balance columns. Gain/loss is not being calculated correctly. I think once I get that working I might ask for an initial review before I start updating automated testing, gold, etc. More work than I expected and it is now the nice weather months so this might take a bit!