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
VAT code for all products which is removed from a document (proposal / invoices / command ) when adding a global reduction #29192
Comments
@donowr why don't you think it is the best way to patch it? |
Because it does not solve the problem at its source. Instead of fixing the code that handles the application of global discounts so that it correctly preserves the VAT discount codes, my solution is to manually reinsert the VAT codes after they have been deleted. While this may temporarily resolve the issue, it does not resolve the underlying cause of the issue. A more robust approach would be to identify and fix the part of Dolibarr's code that removes VAT codes when applying global discounts. This would ensure correct and consistent behavior in all situations, without requiring additional fixes in the future. In summary, my solution is a temporary solution that works around the problem, but the real solution would be to modify the Dolibarr code so that it works correctly from the start. |
I found where the problem comes from. The $object->updateline() function uses the content of the $txtva parameter to extract the VAT code: // Clean vat code $vat_src_code = '';
$reg = array();
if (preg_match('/\((.*)\)/', $txtva, $reg)) {
$vat_src_code = $reg[1];
$txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate.
} However, I looked in $object and it turns out that not all the lines in the documents contain the VAT code when the object is instantiated: I tried to add the VAT code when the object retrieved the document lines but this is not the right solution because the frontend does not handle it when the VAT code is in $line->tva_tx . My first solution remains valid but I have a second solution to propose. We can modify the $object->updateline() function so that it takes the VAT code as a parameter. By default the parameter would be False, this will allow the basic logic to be preserved in the case where the parameter was not provided. |
@donowr I like that, but I have no authority to say I wonder if there are more places than proposal/order/invoice (propal/commande/facture) where it needs to be fixed
|
Who has the authority to tell me what to do? Concerning the places where the modification must be made I cannot answer you with certainty but I think you have listed them all. I'll ask a colleague this tomorrow |
@JonBendtsen I have to wait waitfor @eldy to give his answer here? |
I think it is either that or submit a pull request |
It is better to add the Can you submit a Pull Request in this way ? |
hello, I did a pr but the phan test failed, is this disturbing? How do I resolve the problem so that my pr passes all the tests? |
that depends - was it your fault or was it something that you did not change? |
@donowr if you can update your merge request to a newer base version (there should be a button in the bottom of the merge request page if possible) then use that possibility. Even if there is not such a thing, come back regularly and update which triggers a new build and maybe someone else fixed the phan error. But it might just be your code that has the issue, so check where you edited and what, and correlate with the error message in phan. |
@JonBendtsen |
good, then i'd suggest that you keep updating when possible until all checks are clean, then you leave it. |
Bug
Good morning,
I have a problem with the VAT accounting codes on the lines of a document (invoice/proposal or other).
When I add a global reduction to a document it removes the VAT code from each line.
I tried it on a blank Dolibarr.
I also found how to fix the problem by adding a small piece of code in each card.php of a document.
Here is the line that I added temporarily in all card.php:
This line was added in the following condition in each in card.php:
I dont think it is the best way to patch that.
Dolibarr Version
18.0.5
Environment PHP
8.1.27
Environment Database
Mysql 8.3.0
Steps to reproduce the behavior and expected behavior
Apply a discount to all lines of a document:
Output:
Attached files
No response
The text was updated successfully, but these errors were encountered: