Closed palexandri closed 8 months ago
I couldn't find any error in this page When updating the U.P. Can you send an example with errors ?
The issue is present only when using multi currency and only when updating the U.P (net) (currency). Creation works fine. Method to reproduce.
The nginx logs state:
PHP message: PHP Fatal error: Uncaught TypeError: Unsupported operand types: string / int in /var/www/dolibarr/htdocs/fourn/commande/card.php:778
The reason is that neither price_ht or price_ttc are set in the post since they are cleared when changing the U.P (net) (currency). Only the multicurrency_subprice is set. To avoid the error, one can replace the line 769 with this:
} elseif (GETPOST('price_ttc') != '') {
I could not reproduce the error in php 8.1 nor in php 7.2
I could not reproduce the error in php 8.1 nor in php 7.2
Are price_ht
and price_ttc
being posted when modifying U.P (net) (currency). Because in my case they are not and this is not relevant to the php version. I can dig deeper in the code and find the reason for this in the future.
I also could not reproduce the problem using multicurrency and Dolibarr 16.0.3 and PHP 7.4.33 (Supplier Purchase orders)
Line 1073 in /commande/card.php modified to
if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS)) && ($price_min && ((float)price2num($pu_ht) * (1 - $remise_percent / 100) < (float)price2num($price_min)))) {
casting price2num
to float solved the problem for me. Any comments?
The main issue, I think, is that, $pu_ht or $price_min are string and not numbers...
I also could not reproduce the problem using multicurrency and Dolibarr 16.0.3 and PHP 7.4.33 (Supplier Purchase orders)
The problem occurs on PHP 8.0
The main issue, I think, is that, $pu_ht or $price_min are string and not numbers...
There is indeed another problem with $pu_ht as well.
When in multi currency starting a new order and adding a product. then add a price in the second currency, it wont take the value entered and give following warning :
Warning: Undefined variable $pu_ht_devise in /customers/3/3/0/metron-technics.be/httpd.www/erp/htdocs/commande/card.php on line 953 Warning: Cannot modify header information - headers already sent by (output started at /customers/3/3/0/
line 953 in Commane/card.php $result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $info_bits, 0, $price_base_type, $pu_ttc, $date_start, $date_end, $type, min($rank, count($object->lines) + 1), 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $array_options, $fk_unit, '', 0, $pu_ht_devise);
Line 1073 in /commande/card.php modified to
if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS)) && ($price_min && ((float)price2num($pu_ht) * (1 - $remise_percent / 100) < (float)price2num($price_min)))) {
casting
price2num
to float solved the problem for me. Any comments?
After the above partial fix now the problem is as follows: Creating a new line in the sales order with second currency activated AND entering the price in that second currency will result in the Amount entered in the second currency not being saved (Multicurrency_price_HT not saved). values are all 00 (zero) Modifying the price in the second currency in that saved line will result in the value being saved (Multicurrency_subprice). Entering a new product line and fill in the price in original currency will be saved.
Hello,
It is still the case with V18 ?
Bug
When updating the U.P (net) (currency) in a purchase order, there is an error in htdocs/fourn/commande/card.php:778 The reason is that price_ttc is not set and line 778 tries to divide the vat rate with an empty number. I would suggest to add elseif (GETPOST('price_ttc') != '') in line 769 in place of the else. This solves the issue.
Environment Version
16
Environment OS
ubuntu 22.04
Environment Web server
nginx
Environment PHP
8
Environment Database
MariaDB
Environment URL(s)
No response
Expected and actual behavior
No response
Steps to reproduce the behavior
No response
Attached files
No response