Page principale | Liste alphabétique | Liste des classes | Liste des fichiers | Membres de classe | Membres de fichier

htdocs/lib/price.lib.php

Aller à la documentation de ce fichier.
00001 <?PHP 00002 /* Copyright (C) 2002-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org> 00003 * 00004 * This program is free software; you can redistribute it and/or modify 00005 * it under the terms of the GNU General Public License as published by 00006 * the Free Software Foundation; either version 2 of the License, or 00007 * (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software 00016 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00017 * 00018 * $Id$ 00019 * $Source$ 00020 * 00021 */ 00022 00038 function calcul_price($products, $remise_percent) 00039 { 00040 $total_ht = 0; 00041 $amount_ht = 0; 00042 $tva = array(); 00043 $total_tva = 0; 00044 $total_remise = 0; 00045 00046 $num = sizeof($products); 00047 $i = 0; 00048 00049 while ($i < $num) 00050 { 00051 $prod_price = $products[$i][0]; 00052 $prod_qty = $products[$i][1]; 00053 $prod_txtva = $products[$i][2]; 00054 00055 $lprice = $prod_qty * $prod_price; 00056 00057 $amount_ht = $amount_ht + $lprice; 00058 00059 if ($remise_percent > 0) 00060 { 00061 $lremise = ($lprice * $remise_percent / 100); 00062 $lprice = $lprice - $lremise; 00063 $total_remise = $total_remise + $lremise; 00064 } 00065 00066 $total_ht = $total_ht + $lprice; 00067 00068 $ligne_tva = ($lprice * ($prod_txtva / 100)); 00069 00070 $tva[$prod_txtva] = $tva[$prod_txtva] + $ligne_tva; 00071 $i++; 00072 } 00073 00074 /* 00075 * Sommes et arrondis 00076 */ 00077 $j=0; 00078 $result[5] = array(); 00079 00080 foreach ($tva as $key => $value) 00081 { 00082 $tva[$key] = round($tva[$key], 2); 00083 $total_tva = $total_tva + $tva[$key]; 00084 $result[5][$key] = $tva[$key]; 00085 $j++; 00086 } 00087 00088 $total_ht = round($total_ht, 2); 00089 $total_tva = round($total_tva, 2); 00090 00091 $total_ttc = $total_ht + $total_tva; 00092 00093 /* 00094 * 00095 */ 00096 $result[0] = $total_ht; 00097 $result[1] = $total_tva; 00098 $result[2] = $total_ttc; 00099 $result[3] = $total_remise; 00100 $result[4] = $amount_ht; 00101 00102 return $result; 00103 }

Généré le Thu Jul 15 20:50:38 2004 pour dolibarr par doxygen 1.3.7