changed vat rate calculation logic #1194
Merged
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.
What does this PR address?
The issue here is related to the method override of the vat_rate column in the invoice table. It is expected that each invoice will have its unique vat_rate depending on the country associated with the user's billing profile, whether the user is an organization or an individual. However, due to the presence of the vat_rate method in the invoice model's code, it overrides the existing column, preventing data from being stored in the column and making the values dynamic. Additionally, since the Estonian income tax has been changed, these tax rate changes would also affect old invoices created before 2024.
To resolve this, it is necessary to eliminate this method and ensure that each invoice stores its own value so that changes in the tax rate do not affect old invoices.
What do I need to know?
In this PR, I have also included a rake task that allows you to go through all the accounts that do not have a vat rate and assign them a value. Ideally, this should be a separate PR and I will make it, because first the commands that assign the necessary values for the accounts are executed, and only then the current PR is deployed in production. This will help avoid errors, but for testing purposes, to simplify this PR, it also includes such a command:
rake invoices:assign_invoices_vat_rate
What does this command do?
How to test?