Closed developmentOYR closed 3 months ago
Did you make a pull request to fix the issue?
No, the truth is I'm not very clear on how to do it. If you tell me how I can do it.
Thank you so much
I have tried to implement the fix you provided, but now it gives a popup error (foreign key contraint fails....) dolibarr version 20.0
The issue is that by common sense one should not be able to make a purchase order of a negative value, if you also try to make a (vendor proposal of a line item with negative unit price) you cannot validate it!
So in my opinion dolibarr should not let any purchasing order or proposal to be in negative value.
What is your idea about this?
There are two issues I want to comment on, one on a business level, the other in terms of code development practices.
On a business level, it is a very common practice in Spain, but in many other countries as well to issue a negative vendor purchase order when products are returned before they are actually invoiced.
The scenarios is as follows:
1) Client orders a set of items from vendor on the 5th day of the month.
2) Vendor ships the items to Client, but client decides not to accept shipment for whatever reason or simply no longer needs the items.
3) Vendor only invoices client at the end of the month. This is also a very common practice. A vendor invoices you the totality of your purchases at the end of the month.
Therefore, the vendor purchase order never issues an invoice and instead of issuing an invoice and later a credit note for the returned items, it simply issues a vendor purchase order with negative values for the items included in the original vendor purchase order.
As odd as this may seem, Dolibarr actually takes this into account and has a global variable for allowing negative lines in invoices. (FACTURE_ENABLE_NEGATIVE_LINES)
In terms of code development practices, I find it odd that an object is instantiated without calling the file that includes the necessary class , without which it cannot function.
This is the issue that I was trying to address. The proposed solution is to simply call upon the required file for said class.
thanks for the clarification, please go ahead and create a pull request, checking your profile you have made many pull requests before.
Bug
Guide to reproduce the error:
When you try to create an invoice for an order with a negative value, an error occurs:
I proceed to create the invoice:
I create the invoice:
the error:
Cause of the error
The error occurs when using instantiate the DiscountAbsolute object on line 471 of the htdocs/fourn/commande/list.php file.
The solution:
To fix the error, you must import the class file of the instance that initially produces the error.
(require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php';)
Dolibarr Version
19.2
Environment PHP
8.1.29
Environment Database
10.2.44-MariaDB
Steps to reproduce the behavior and expected behavior
I proceed to create the invoice:
I create the invoice:
Error:
Attached files
No response