diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php index 98b0713a20a..58cc37b48e7 100644 --- a/htdocs/fourn/facture/fiche.php +++ b/htdocs/fourn/facture/fiche.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2007 Laurent Destailleur * Copyright (C) 2004 Christophe Combelles * Copyright (C) 2005 Marc Barilley / Ocebo + * Copyright (C) 2005-2007 Regis Houssin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -246,31 +247,32 @@ if ($_GET['action'] == 'add_ligne') if ($_POST['idprod']) { - $nv_prod = new Product($db); - $nv_prod->fetch($_POST['idprod']); + $nv_prod = new Product($db); + $nv_prod->fetch($_POST['idprod']); + + // cas spécial pour lequel on a les meme référence que le fournisseur + // $label = '['.$nv_prod->ref.'] - '. $nv_prod->libelle; + $label = $nv_prod->libelle; + + $result=$nv_prod->get_buyprice($_POST['socid'], $_POST['qty']); + if ($result > 0) + { + $societe=''; + if ($_POST['socid']) + { + $societe=new Societe($db); + $societe->fetch($_POST['socid']); + } - // cas spécial pour lequel on a les meme référence que le fournisseur - // $label = '['.$nv_prod->ref.'] - '. $nv_prod->libelle; - $label = $nv_prod->libelle; + $tvatx=get_default_tva($societe,$mysoc,$nv_prod->tva_tx); - $result=$nv_prod->get_buyprice($_POST['socid'], $_POST['qty']); - if ($result > 0) - { - $societe=''; - if ($_POST['socid']) - { - $societe=new Societe($db); - $societe->fetch($_POST['socid']); - } - - $tvatx=get_default_tva($societe,$mysoc,$nv_prod->tva_tx); - $facfou->addline($label, $nv_prod->fourn_pu, $tvatx, $_POST['qty'], $_POST['idprod']); - } - if ($result == -1) - { - // Quantité insuffisante - $mesg='
'.$langs->trans("ErrorQtyTooLowForThisSupplier").'
'; - } + $facfou->addline($label, $nv_prod->fourn_pu, $tvatx, $_POST['qty'], $_POST['idprod']); + } + if ($result == -1) + { + // Quantité insuffisante + $mesg='
'.$langs->trans("ErrorQtyTooLowForThisSupplier").'
'; + } } else { @@ -788,8 +790,8 @@ else { print '
'; print ''; - print ''; - print ''; + print ''; + print ''; $var=! $var; print ''; print ''; diff --git a/htdocs/lib/functions.inc.php b/htdocs/lib/functions.inc.php index 98abeeed1c3..52cf348ef1f 100644 --- a/htdocs/lib/functions.inc.php +++ b/htdocs/lib/functions.inc.php @@ -1912,7 +1912,7 @@ function get_default_tva($societe_vendeuse, $societe_acheteuse, $taux_produit) if (! is_numeric($societe_vendeuse->tva_assuj) && $societe_vendeuse->tva_assuj=='franchise') return 0; // Si le (pays vendeur = pays acheteur) alors la TVA par défaut=TVA du produit vendu. Fin de règle. - if (is_object($societe_acheteuse) && ($societe_vendeuse->pays_id == $societe_acheteuse->pays_id) && $societe_acheteuse->tva_assuj == 1) + if (is_object($societe_acheteuse) && ($societe_vendeuse->pays_id == $societe_acheteuse->pays_id) && $societe_vendeuse->tva_assuj == 1) { return $taux_produit; }