From 5f5b4570c4fc29c52e522d8b2885ff048ab2af43 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 18 Mar 2026 14:44:30 +0100 Subject: [PATCH] NEW Use the initAsSpecimen to generate the test invoice. --- htdocs/compta/facture/class/facture.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 66cadcf0158..7728128fcb1 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -5548,7 +5548,7 @@ class Facture extends CommonInvoice * Used to build previews or test instances. * id must be 0 if object instance is a specimen. * - * @param string $option ''=Create a specimen invoice with lines, 'nolines'=No lines, 'takepos'=Specimen for takepos module + * @param string $option ''=Create a specimen invoice with lines, 'nolines'=No lines, 'nonegativeup'=No negative unit price, 'takepos'=Specimen for takepos module * @return int */ public function initAsSpecimen($option = '') @@ -5626,7 +5626,7 @@ class Facture extends CommonInvoice $line->localtax1_tx = 0; $line->localtax2_tx = 0; $line->remise_percent = 0; - if ($xnbp == 1 && $option != 'takepos') { // Qty is negative (product line) + if ($xnbp == 1 && $option != 'takepos' && $option != 'nonegativeup') { // Qty is negative (product line) $prodid = mt_rand(1, $num_prods); if (isset($prodids[$prodid])) { $line->fk_product = $prodids[$prodid]; @@ -5638,7 +5638,7 @@ class Facture extends CommonInvoice $line->multicurrency_total_ht = -200; $line->multicurrency_total_ttc = -239.2; $line->multicurrency_total_tva = -39.2; - } elseif ($xnbp == 2 && $option != 'takepos') { // UP is negative (free line) + } elseif ($xnbp == 2 && $option != 'takepos' && $option != 'nonegativeup') { // UP is negative (free line) $line->subprice = -100; $line->total_ht = -100; $line->total_ttc = -119.6;