[ Index ] |
|
Code source de Dolibarr 2.0.1 |
1 <?php 2 /* Copyright (C) 2002-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation; either version 2 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 * 18 * $Id: price.lib.php,v 1.10 2005/10/08 15:54:09 eldy Exp $ 19 * $Source: /cvsroot/dolibarr/dolibarr/htdocs/lib/price.lib.php,v $ 20 * 21 */ 22 23 /*! \file htdocs/lib/price.lib.php 24 \brief librairie contenant les fonctions pour calculer un prix. 25 \author Rodolphe Quiedeville. 26 \version $Revision: 1.10 $ 27 28 Ensemble des fonctions permettant de calculer un prix. 29 */ 30 31 32 /*! 33 \brief permet de calculer un prix. 34 \param products 35 \param remise_percent 36 \return result 37 */ 38 39 function calcul_price($products, $remise_percent) 40 { 41 $total_ht = 0; 42 $amount_ht = 0; 43 $total_tva = 0; 44 $total_ttc = 0; 45 $total_remise = 0; 46 $result[5] = array(); 47 48 if ( sizeof( $products ) ) 49 { 50 foreach ($products as $product) 51 { 52 $prod_price = $product[0]; 53 $prod_qty = $product[1]; 54 $prod_txtva = $product[2]; 55 56 // montant total HT de la ligne 57 $line_price_ht = $prod_qty * $prod_price; 58 59 // incrémentation montant HT hors remise de l'ensemble 60 $amount_ht += $line_price_ht; 61 62 // si une remise est consentie sur l'ensemble 63 if ($remise_percent > 0) 64 { 65 // calcul de la remise sur la ligne 66 $line_remise = ($line_price_ht * $remise_percent / 100); 67 // soustraction de cette remise au montant HT de la ligne 68 $line_price_ht -= $line_remise; 69 // incrémentation du montant total de remise sur l'ensemble 70 $total_remise += $line_remise; 71 } 72 // incrémentation du montant HT remisé de l'ensemble 73 $total_ht += $line_price_ht; 74 75 // calcul de la TVA sur la ligne 76 $line_tva = ($line_price_ht * (abs($prod_txtva) / 100)); 77 78 // incrémentation du montant TTC de la valeur HT, on traite la TVA ensuite 79 $total_ttc += $line_price_ht; 80 // traitement de la tva non perçue récupérable 81 if ( $prod_txtva >= 0 ) 82 { 83 // ce n'est pas une TVA non perçue récupérable, 84 // donc on incrémente le total TTC de l'ensemble, de la valeur de TVA de la ligne 85 $total_ttc += $line_tva; 86 } 87 // dans tous les cas, on incrémente le total de TVA 88 $total_tva += $line_tva; 89 // on incrémente le tableau de différentiation des taux de TVA 90 // s'il faut rassembler les tva facturables ou non, du même taux 91 // dans un même ligne du tableau, remplacer la ligne suivante par : 92 // $result[5][abs($prod_txtva)] += $line_tva; 93 $result[5][$prod_txtva] += $line_tva; 94 95 $i++; 96 } 97 } 98 /* 99 * arrondis 100 */ 101 $total_ht = round($total_ht, 2); 102 $total_tva = round($total_tva, 2); 103 104 /* 105 * 106 */ 107 $result[0] = $total_ht; 108 $result[1] = $total_tva; 109 $result[2] = $total_ttc; 110 $result[3] = $total_remise; 111 $result[4] = $amount_ht; 112 113 return $result; 114 } 115
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 12:29:37 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |