diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 292466ea0d8..8580bec8cd9 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1436,6 +1436,12 @@ class FactureFournisseur extends CommonInvoice // Check parameters if ($type < 0) return -1; + if ($rang < 0) + { + $rangmax = $this->line_max(); + $rang = $rangmax + 1; + } + // Insert line $this->line=new SupplierInvoiceLine($this->db); diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 0fc05bd7627..cc9164b753f 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -265,7 +265,7 @@ if (empty($reshook)) $action=''; } } - + elseif ($action == 'confirm_paid' && $confirm == 'yes' && $user->rights->fournisseur->facture->creer) { $object->fetch($id); @@ -999,6 +999,8 @@ if (empty($reshook)) $type = $productsupplier->type; $price_base_type = 'HT'; + $rang = $object->line_max() +1; + $result=$object->addline( $desc, $productsupplier->fourn_pu, @@ -1014,7 +1016,7 @@ if (empty($reshook)) $tva_npr, $price_base_type, $type, - -1, + $rang, 0, $array_options, $productsupplier->fk_unit,