Works on enhancement of local taxes. Changes in calcul_price_total

This commit is contained in:
Juanjo Menent 2010-04-12 09:53:49 +00:00
parent 7850c536a1
commit 30dcda109e
11 changed files with 37 additions and 23 deletions

View File

@ -1,6 +1,7 @@
<?php
/* Copyright (C) 2007-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2009 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
*
* 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
@ -173,35 +174,35 @@ else
print '<b>'.$langs->trans("ExamplesWithCurrentSetup").":</b><br>\n";
$s=2/7;$qty=1;$vat=0;
$tmparray=calcul_price_total(1,$qty*price2num($s,'MU'),0,$vat,0,'HT',0);
$tmparray=calcul_price_total(1,$qty*price2num($s,'MU'),0,$vat,0,0,0,'HT',0);
print $langs->trans("UnitPriceOfProduct").": ".price2num($s,'MU');
print " x ".$langs->trans("Quantity").": ".$qty;
print " - ".$langs->trans("VAT").": ".$vat.'%';
print " &nbsp; -> &nbsp; ".$langs->trans("TotalPriceAfterRounding").": ".$tmparray[2]."<br>\n";
$s=10/3;$qty=1;$vat=0;
$tmparray=calcul_price_total(1,$qty*price2num($s,'MU'),0,$vat,0,'HT',0);
$tmparray=calcul_price_total(1,$qty*price2num($s,'MU'),0,$vat,0,0,0,'HT',0);
print $langs->trans("UnitPriceOfProduct").": ".price2num($s,'MU');
print " x ".$langs->trans("Quantity").": ".$qty;
print " - ".$langs->trans("VAT").": ".$vat.'%';
print " &nbsp; -> &nbsp; ".$langs->trans("TotalPriceAfterRounding").": ".$tmparray[2]."<br>\n";
$s=10/3;$qty=2;$vat=0;
$tmparray=calcul_price_total(1,$qty*price2num($s,'MU'),0,$vat,0,'HT',0);
$tmparray=calcul_price_total(1,$qty*price2num($s,'MU'),0,$vat,0,0,0,'HT',0);
print $langs->trans("UnitPriceOfProduct").": ".price2num($s,'MU');
print " x ".$langs->trans("Quantity").": ".$qty;
print " - ".$langs->trans("VAT").": ".$vat.'%';
print " &nbsp; -> &nbsp; ".$langs->trans("TotalPriceAfterRounding").": ".$tmparray[2]."<br>\n";
$s=10/3;$qty=1;$vat=10;
$tmparray=calcul_price_total(1,$qty*price2num($s,'MU'),0,$vat,0,'HT',0);
$tmparray=calcul_price_total(1,$qty*price2num($s,'MU'),0,$vat,0,0,0,'HT',0);
print $langs->trans("UnitPriceOfProduct").": ".price2num($s,'MU');
print " x ".$langs->trans("Quantity").": ".$qty;
print " - ".$langs->trans("VAT").": ".$vat.'%';
print " &nbsp; -> &nbsp; ".$langs->trans("TotalPriceAfterRounding").": ".$tmparray[2]."<br>\n";
$s=10/3;$qty=2;$vat=10;
$tmparray=calcul_price_total(1,$qty*price2num($s,'MU'),0,$vat,0,'HT',0);
$tmparray=calcul_price_total(1,$qty*price2num($s,'MU'),0,$vat,0,0,0,'HT',0);
print $langs->trans("UnitPriceOfProduct").": ".price2num($s,'MU');
print " x ".$langs->trans("Quantity").": ".$qty;
print " - ".$langs->trans("VAT").": ".$vat.'%';

View File

@ -1,6 +1,7 @@
<?php
/* Copyright (C) 2007-2008 Jeremie Ollivier <jeremie.o@laposte.net>
* Copyright (C) 2008 Laurent Destailleur <eldy@uers.sourceforge.net>
* Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
*
* 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
@ -106,7 +107,7 @@ class Facturation {
// Define part of HT, VAT, TTC
$resultarray=calcul_price_total($this->qte,$this->prix(),$this->remise_percent(),$vat_rate,0,'HT',0);
$resultarray=calcul_price_total($this->qte,$this->prix(),$this->remise_percent(),$vat_rate,0,0,0,'HT',0);
// Calcul du total ht sans remise
$total_ht = $resultarray[0];

View File

@ -6,6 +6,7 @@
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
* Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr>
* Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
*
* 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
@ -307,7 +308,7 @@ class Propal extends CommonObject
// qty, pu, remise_percent et txtva
// TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker
// la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva.
$tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, 0, $price_base_type, $info_bits);
$tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, 0, 0, 0, $price_base_type, $info_bits);
$total_ht = $tabprice[0];
$total_tva = $tabprice[1];
$total_ttc = $tabprice[2];
@ -420,7 +421,7 @@ class Propal extends CommonObject
// qty, pu, remise_percent et txtva
// TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker
// la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva.
$tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, 0, $price_base_type, $info_bits);
$tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, 0, 0, 0, $price_base_type, $info_bits);
$total_ht = $tabprice[0];
$total_tva = $tabprice[1];
$total_ttc = $tabprice[2];

View File

@ -3,6 +3,7 @@
* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
* Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
*
* 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
@ -841,7 +842,7 @@ class Commande extends CommonObject
// qty, pu, remise_percent et txtva
// TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker
// la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva.
$tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, 0, $price_base_type, $info_bits);
$tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, 0 ,0, 0, $price_base_type, $info_bits);
$total_ht = $tabprice[0];
$total_tva = $tabprice[1];
$total_ttc = $tabprice[2];
@ -1842,7 +1843,7 @@ class Commande extends CommonObject
// qty, pu, remise_percent et txtva
// TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker
// la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva.
$tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, 0, $price_base_type, $info_bits);
$tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, 0, 0, 0, $price_base_type, $info_bits);
$total_ht = $tabprice[0];
$total_tva = $tabprice[1];
$total_ttc = $tabprice[2];

View File

@ -2,6 +2,7 @@
/* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2009 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
*
* 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
@ -426,7 +427,7 @@ class FactureRec extends Facture
// qty, pu, remise_percent et txtva
// TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker
// la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva.
$tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, 0, $price_base_type, $info_bits);
$tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, 0, 0, 0, $price_base_type, $info_bits);
$total_ht = $tabprice[0];
$total_tva = $tabprice[1];
$total_ttc = $tabprice[2];

View File

@ -7,6 +7,7 @@
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
* Copyright (C) 2007 Franky Van Liedekerke <franky.van.liedekerke@telenet.be>
* Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
*
* 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
@ -1611,7 +1612,7 @@ class Facture extends CommonObject
// qty, pu, remise_percent et txtva
// TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker
// la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva.
$tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, 0, $price_base_type, $info_bits);
$tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, 0, 0, 0, $price_base_type, $info_bits);
$total_ht = $tabprice[0];
$total_tva = $tabprice[1];
$total_ttc = $tabprice[2];
@ -1725,7 +1726,7 @@ class Facture extends CommonObject
// qty, pu, remise_percent et txtva
// TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker
// la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva.
$tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, 0, $price_base_type, $info_bits);
$tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, 0, 0, 0, $price_base_type, $info_bits);
$total_ht = $tabprice[0];
$total_tva = $tabprice[1];
$total_ttc = $tabprice[2];

View File

@ -4,6 +4,8 @@
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
* Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr>
* Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
@ -814,7 +816,7 @@ class Contrat extends CommonObject
// qty, pu, remise_percent et txtva
// TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker
// la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva.
$tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, 0, $price_base_type, $info_bits);
$tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, 0, 0, 0, $price_base_type, $info_bits);
$total_ht = $tabprice[0];
$total_tva = $tabprice[1];
$total_ttc = $tabprice[2];

View File

@ -3,6 +3,7 @@
* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2007 Franky Van Liedekerke <franky.van.liedekerke@telenet.be>
* Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
*
* 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
@ -864,7 +865,7 @@ class CommandeFournisseur extends Commande
// qty, pu, remise_percent et txtva
// TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker
// la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva.
$tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, 0, $price_base_type, $info_bits);
$tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, 0, 0, 0, $price_base_type, $info_bits);
$total_ht = $tabprice[0];
$total_tva = $tabprice[1];
$total_ttc = $tabprice[2];
@ -1309,7 +1310,7 @@ class CommandeFournisseur extends Commande
// qty, pu, remise_percent et txtva
// TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker
// la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva.
$tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $price_base_type, $info_bits);
$tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, 0, 0, $price_base_type, $info_bits);
$total_ht = $tabprice[0];
$total_tva = $tabprice[1];
$total_ttc = $tabprice[2];

View File

@ -4,6 +4,7 @@
* Copyright (C) 2004 Christophe Combelles <ccomb@free.fr>
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
*
* 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
@ -773,7 +774,7 @@ class FactureFournisseur extends Facture
// qty, pu, remise_percent et txtva
// TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker
// la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva.
$tabprice = calcul_price_total($qty, $pu, 0, $tauxtva, 0, $price_base_type, $info_bits);
$tabprice = calcul_price_total($qty, $pu, 0, $tauxtva, 0,0, 0, $price_base_type, $info_bits);
$total_ht = $tabprice[0];
$total_tva = $tabprice[1];
$total_ttc = $tabprice[2];

View File

@ -2,6 +2,7 @@
/* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* Copyright (C) 2005-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
*
* 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
@ -1157,7 +1158,7 @@ function migrate_price_facture($db,$langs,$conf)
$facligne= new FactureLigne($db);
$facligne->fetch($rowid);
$result=calcul_price_total($qty,$pu,$remise_percent,$txtva,$remise_percent_global,'HT',$info_bits);
$result=calcul_price_total($qty,$pu,$remise_percent,$txtva, 0, 0,$remise_percent_global,'HT',$info_bits);
$total_ht = $result[0];
$total_tva = $result[1];
$total_ttc = $result[2];
@ -1264,7 +1265,7 @@ function migrate_price_propal($db,$langs,$conf)
$propalligne= new PropaleLigne($db);
$propalligne->fetch($rowid);
$result=calcul_price_total($qty,$pu,$remise_percent,$txtva,$remise_percent_global,'HT',$info_bits);
$result=calcul_price_total($qty,$pu,$remise_percent,$txtva,0,0,$remise_percent_global,'HT',$info_bits);
$total_ht = $result[0];
$total_tva = $result[1];
$total_ttc = $result[2];
@ -1368,7 +1369,7 @@ function migrate_price_contrat($db,$langs,$conf)
//$contratligne->fetch($rowid); Non requis car le update_total ne met a jour que chp redefinis
$contratligne->rowid=$rowid;
$result=calcul_price_total($qty,$pu,$remise_percent,$txtva,$remise_percent_global,'HT',$info_bits);
$result=calcul_price_total($qty,$pu,$remise_percent,$txtva,0,0,$remise_percent_global,'HT',$info_bits);
$total_ht = $result[0];
$total_tva = $result[1];
$total_ttc = $result[2];
@ -1471,7 +1472,7 @@ function migrate_price_commande($db,$langs,$conf)
$commandeligne= new OrderLine($db);
$commandeligne->fetch($rowid);
$result=calcul_price_total($qty,$pu,$remise_percent,$txtva,$remise_percent_global,'HT',$info_bits);
$result=calcul_price_total($qty,$pu,$remise_percent,$txtva,0,0,$remise_percent_global,'HT',$info_bits);
$total_ht = $result[0];
$total_tva = $result[1];
$total_ttc = $result[2];
@ -1583,7 +1584,7 @@ function migrate_price_commande_fournisseur($db,$langs,$conf)
$commandeligne= new CommandeFournisseurLigne($db);
$commandeligne->fetch($rowid);
$result=calcul_price_total($qty,$pu,$remise_percent,$txtva,$remise_percent_global,'HT',$info_bits);
$result=calcul_price_total($qty,$pu,$remise_percent,$txtva,0,0,$remise_percent_global,'HT',$info_bits);
$total_ht = $result[0];
$total_tva = $result[1];
$total_ttc = $result[2];

View File

@ -1,6 +1,7 @@
<?php
/* Copyright (C) 2002-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2006-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
*
* 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
@ -30,12 +31,14 @@
* \param pu Unit price (HT or TTC selon price_base_type)
* \param remise_percent_ligne Discount for line
* \param txtva Vat rate
* \param txlocaltax1 Localtax1 rate
* \param txlocaltax2 Localtax2 rate
* \param remise_percent_global 0
* \param price_base_type HT=on calcule sur le HT, TTC=on calcule sur le TTC
* \param info_bits Miscellanous informations on line
* \return result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount)
*/
function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $remise_percent_global=0, $price_base_type='HT', $info_bits=0)
function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $txlocaltax1, $txlocaltax2, $remise_percent_global=0, $price_base_type='HT', $info_bits=0)
{
global $conf;