diff --git a/htdocs/ai/tools/crud_objects.class.php b/htdocs/ai/tools/crud_objects.class.php index 9b5f25e1fda..61933736148 100644 --- a/htdocs/ai/tools/crud_objects.class.php +++ b/htdocs/ai/tools/crud_objects.class.php @@ -621,7 +621,14 @@ If user says 'order' without any qualifier, they mean a SALES ORDER - use this t $res = $object->addline($desc, $price, $qty, $vat, 0, 0, $fkProduct, $discount, 'HT', 0, 0, $prodType); } elseif ($docType === 'supplier_invoice') { /** @var FactureFournisseur $object */ - $res = $object->addline($desc, $price, $qty, $vat, 0, 0, $fkProduct, $discount, 0, 0, '', 0, 'HT', 0, $prodType); + // IMPORTANT: FactureFournisseur::addline() does NOT share the same signature + // as Facture::addline(). Its parameter order is: + // ($desc, $pu, $txtva, $txlocaltax1, $txlocaltax2, $qty, $fk_product, $remise_percent, ...) + // i.e. $qty is in position 6, not 3 (unlike customer Facture / Commande / Propal). + // The previous call passed our $qty as $txtva (-> a 1% VAT rate) and our $vat + // as $txlocaltax1, and position 6 ended up being a hardcoded 0 -> a line was + // inserted with qty=0, which Dolibarr silently dropped from the visible totals. + $res = $object->addline($desc, $price, $vat, 0, 0, $qty, $fkProduct, $discount, '', '', 0, 0, 'HT', $prodType); } elseif ($docType === 'supplier_order') { /** @var CommandeFournisseur $object */ $res = $object->addline($desc, $price, $qty, $vat, 0, 0, $fkProduct, $discount, 0, 0, 'HT', 0, '', '', $prodType);