diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index a800157dc0e..895d9452039 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -823,10 +823,14 @@ class CommandeFournisseur extends Commande include_once(DOL_DOCUMENT_ROOT.'/lib/price.lib.php'); // Clean parameters - $remise_percent=price2num($remise_percent); - $qty=price2num($qty); if (! $qty) $qty=1; if (! $info_bits) $info_bits=0; + if (empty($txtva)) $txtva=0; + if (empty($txlocaltax1)) $txlocaltax1=0; + if (empty($txlocaltax2)) $txlocaltax2=0; + + $remise_percent=price2num($remise_percent); + $qty=price2num($qty); $pu_ht=price2num($pu_ht); $pu_ttc=price2num($pu_ttc); $txtva = price2num($txtva); @@ -841,9 +845,7 @@ class CommandeFournisseur extends Commande $pu=$pu_ttc; } $desc=trim($desc); - if (empty($txtva)) $txtva=0; - if (empty($txlocaltax1)) $txlocaltax1=0; - if (empty($txlocaltax2)) $txlocaltax2=0; + // Check parameters if ($qty < 1 && ! $fk_product) diff --git a/htdocs/fourn/commande/fiche.php b/htdocs/fourn/commande/fiche.php index 3964a94fcb5..dccd6a82174 100644 --- a/htdocs/fourn/commande/fiche.php +++ b/htdocs/fourn/commande/fiche.php @@ -130,6 +130,14 @@ if ($_POST['action'] == 'addline' && $user->rights->fournisseur->commande->creer $product = new ProductFournisseur($db); $idprod=$product->get_buyprice($_POST['idprodfournprice'], $qty); + + //$societe=''; + if ($commande->socid) + { + $societe=new Societe($db); + $societe->fetch($commande->socid); + } + if ($idprod > 0) { $res=$product->fetch($idprod); @@ -138,13 +146,6 @@ if ($_POST['action'] == 'addline' && $user->rights->fournisseur->commande->creer // $label = '['.$nv_prod->ref.'] - '. $nv_prod->libelle; $label = $product->libelle; - $societe=''; - if ($commande->socid) - { - $societe=new Societe($db); - $societe->fetch($commande->socid); - } - $desc = $product->description; $desc.= $product->description && $_POST['np_desc'] ? "\n" : ""; $desc.= $_POST['np_desc']; @@ -186,12 +187,6 @@ if ($_POST['action'] == 'addline' && $user->rights->fournisseur->commande->creer $desc=$_POST['dp_desc']; $tva_tx = price2num($_POST['tva_tx']); - $societe=''; - if ($commande->socid) - { - $societe=new Societe($db); - $societe->fetch($commande->socid); - } // Local Taxes $localtax1_tx= get_localtax($tva_tx, 1, $societe); $localtax2_tx= get_localtax($tva_tx, 2, $societe); diff --git a/htdocs/includes/modules/supplier_order/pdf/pdf_muscadet.modules.php b/htdocs/includes/modules/supplier_order/pdf/pdf_muscadet.modules.php index 9a9e2e85792..4f12914a118 100644 --- a/htdocs/includes/modules/supplier_order/pdf/pdf_muscadet.modules.php +++ b/htdocs/includes/modules/supplier_order/pdf/pdf_muscadet.modules.php @@ -281,10 +281,20 @@ class pdf_muscadet extends ModelePDFSuppliersOrders // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva $tvaligne=$object->lines[$i]->total_tva; + + $localtax1ligne=$object->lines[$i]->total_localtax1; + $localtax2ligne=$object->lines[$i]->total_localtax2; + if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100; + $vatrate=(string) $object->lines[$i]->tva_tx; + $localtax1rate=(string) $object->lines[$i]->localtax1_tx; + $localtax2rate=(string) $object->lines[$i]->localtax2_tx; + if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*'; $this->tva[$vatrate] += $tvaligne; + $this->localtax1[$localtax1rate]+=$localtax1ligne; + $this->localtax2[$localtax2rate]+=$localtax2ligne; $nexY+=2; // Passe espace entre les lignes @@ -381,6 +391,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders */ function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs) { + global $conf,$mysoc; $default_font_size = pdf_getPDFFontSize($outputlangs); $tab2_top = $posy; @@ -439,8 +450,87 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $index++; $pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalVAT"), 0, 'L', 1); + $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_tva), 0, 'R', 1); + + // Total LocalTax1 + if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on' && $object->total_localtax1>0) + { + $index++; + $pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalLT1".$mysoc->pays_code), $useborder, 'L', 1); + $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax1), $useborder, 'R', 1); + } + + // Total LocalTax2 + if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on' && $object->total_localtax2>0) + { + $index++; + $pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalLT2".$mysoc->pays_code), $useborder, 'L', 1); + $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax2), $useborder, 'R', 1); + } + } + else + { + //Local tax 1 + if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on') + { + foreach( $this->localtax1 as $tvakey => $tvaval ) + { + if ($tvakey>0) // On affiche pas taux 0 + { + //$this->atleastoneratenotnull++; + + $index++; + $pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index); + + $tvacompl=''; + if (preg_match('/\*/',$tvakey)) + { + $tvakey=str_replace('*','',$tvakey); + $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; + } + $totalvat =$outputlangs->transnoentities("TotalLT1".$mysoc->pays_code).' '; + $totalvat.=vatrate($tvakey,1).$tvacompl; + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); + + $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1); + } + } + } + + //Local tax 2 + if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on') + { + foreach( $this->localtax2 as $tvakey => $tvaval ) + { + if ($tvakey>0) // On affiche pas taux 0 + { + //$this->atleastoneratenotnull++; + + $index++; + $pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index); + + $tvacompl=''; + if (preg_match('/\*/',$tvakey)) + { + $tvakey=str_replace('*','',$tvakey); + $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; + } + $totalvat =$outputlangs->transnoentities("TotalLT2".$mysoc->pays_code).' '; + $totalvat.=vatrate($tvakey,1).$tvacompl; + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); + + $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1); + } + } + } } $useborder=0;