-
Notifications
You must be signed in to change notification settings - Fork 9
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
Calculate and apply the instrument's tax rate percentage to transactions #44
Calculate and apply the instrument's tax rate percentage to transactions #44
Conversation
Thanks for your suggestions and for your work done on this project. Tax rate is on the instrument Is automatic tax be applied always Opening a position is usually tax free Computing the tax in the background |
Oh, I see - you are talking about a tax that is automatically charged on execution (both buy and sell). This makes sense with the 0.12% rate that you added in the tests. Another thing I noticed: in the database, I like to keep percentages between 0-1 value wise like in I think we can leave the automatic computation in the background for now - since it only affects executions with a set tax rate anyways. In the long-term I will definitely move this computation to the front-end. The main reason is that I want to see the complete transaction in one form (currently you only see the effect of a transaction on your cash account if you change the view). My idea is to have some active code on the edit form that takes volume/price, direction, commission and tax into account to show the overall sum. Doing automatic tax compuations (as long as not overwritten by the user) fits into this concept nicely. But I have too many other side-projects at the moment, so php-invest is on pause for me (development wise). |
Use a scaled value instead percentage Tax is always negative
Your suggestions make sense, I've implemented these changes. |
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.
Looks good to me except for the small issue with initializing $total
. Please fix this and once all checks are green, I can merge your PR. Thank for you for your contribution.
Thank you again for the PR and all the fixes! |
I implemented this feature to automatically pre-fill the tax field with the calculated value based on the tax rate defined in the instrument.
How to use:
Each instrument can have a specified tax rate percentage. When adding or editing a trade, the tax value is automatically calculated based on the defined tax rate and the total amount. If the field is manually modified, the entered tax value is retained. To disable the automatic calculation, the field must be set to 0.