Skip to content

Commit

Permalink
Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into d…
Browse files Browse the repository at this point in the history
…evelop
  • Loading branch information
eldy committed Sep 11, 2013
2 parents fd17280 + 418457e commit e361566
Showing 1 changed file with 26 additions and 6 deletions.
32 changes: 26 additions & 6 deletions htdocs/contrat/class/contrat.class.php
Expand Up @@ -4,7 +4,7 @@
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
* Copyright (C) 2008 Raphael Bertrand <raphael.bertrand@resultic.fr>
* Copyright (C) 2010-2011 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2010-2013 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2013 Christophe Battarel <christophe.battarel@altairis.fr>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
*
Expand Down Expand Up @@ -901,7 +901,7 @@ function delete($user)
*/
function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $remise_percent, $date_start, $date_end, $price_base_type='HT', $pu_ttc=0, $info_bits=0, $fk_fournprice=null, $pa_ht = 0)
{
global $user, $langs, $conf;
global $user, $langs, $conf, $mysoc;

dol_syslog(get_class($this)."::addline $desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $remise_percent, $date_start, $date_end, $price_base_type, $pu_ttc, $info_bits");

Expand Down Expand Up @@ -936,12 +936,19 @@ function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_pr
// 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, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, 1);

$localtaxes_type=getLocalTaxesFromRate($txtva,0,$mysoc);

$tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, 1,'', $localtaxes_type);
$total_ht = $tabprice[0];
$total_tva = $tabprice[1];
$total_ttc = $tabprice[2];
$total_localtax1= $tabprice[9];
$total_localtax2= $tabprice[10];

$localtax1_type=$localtaxes_type[0];
$localtax2_type=$localtaxes_type[2];

// TODO A virer
// Anciens indicateurs: $price, $remise (a ne plus utiliser)
$remise = 0;
Expand All @@ -963,7 +970,7 @@ function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_pr
// Insertion dans la base
$sql = "INSERT INTO ".MAIN_DB_PREFIX."contratdet";
$sql.= " (fk_contrat, label, description, fk_product, qty, tva_tx,";
$sql.= " localtax1_tx, localtax2_tx, remise_percent, subprice,";
$sql.= " localtax1_tx, localtax2_tx, localtax1_type, localtax2_type, remise_percent, subprice,";
$sql.= " total_ht, total_tva, total_localtax1, total_localtax2, total_ttc,";
$sql.= " info_bits,";
$sql.= " price_ht, remise, fk_product_fournisseur_price, buy_price_ht";
Expand All @@ -975,6 +982,8 @@ function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_pr
$sql.= " '".$txtva."',";
$sql.= " '".$txlocaltax1."',";
$sql.= " '".$txlocaltax2."',";
$sql.= " '".$localtax1_type."',";
$sql.= " '".$localtax2_type."',";
$sql.= " ".price2num($remise_percent).",".price2num($pu_ht).",";
$sql.= " ".price2num($total_ht).",".price2num($total_tva).",".price2num($total_localtax1).",".price2num($total_localtax2).",".price2num($total_ttc).",";
$sql.= " '".$info_bits."',";
Expand Down Expand Up @@ -1043,7 +1052,7 @@ function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_pr
*/
function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $tvatx, $localtax1tx=0, $localtax2tx=0, $date_debut_reel='', $date_fin_reel='', $price_base_type='HT', $info_bits=0, $fk_fournprice=null, $pa_ht = 0)
{
global $user, $conf, $langs;
global $user, $conf, $langs, $mysoc;

// Nettoyage parametres
$qty=trim($qty);
Expand Down Expand Up @@ -1075,12 +1084,19 @@ function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $dat
// 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, $tvatx, $localtaxtx1, $txlocaltaxtx2, 0, $price_base_type, $info_bits, 1);

$localtaxes_type=getLocalTaxesFromRate($txtva,0,$mysoc);

$tabprice=calcul_price_total($qty, $pu, $remise_percent, $tvatx, $localtaxtx1, $txlocaltaxtx2, 0, $price_base_type, $info_bits, 1, '', $localtaxes_type );
$total_ht = $tabprice[0];
$total_tva = $tabprice[1];
$total_ttc = $tabprice[2];
$total_localtax1= $tabprice[9];
$total_localtax2= $tabprice[10];

$localtax1_type=$localtaxes_type[0];
$localtax2_type=$localtaxes_type[2];

// TODO A virer
// Anciens indicateurs: $price, $remise (a ne plus utiliser)
$remise = 0;
Expand Down Expand Up @@ -1108,6 +1124,8 @@ function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $dat
$sql.= ",tva_tx='". price2num($tvatx)."'";
$sql.= ",localtax1_tx='". price2num($localtax1tx)."'";
$sql.= ",localtax2_tx='". price2num($localtax2tx)."'";
$sql.= ",localtax1_type='".$localtax1_type."'";
$sql.= ",localtax2_type='".$localtax2_type."'";
$sql.= ", total_ht='". price2num($total_ht)."'";
$sql.= ", total_tva='". price2num($total_tva)."'";
$sql.= ", total_localtax1='".price2num($total_localtax1)."'";
Expand Down Expand Up @@ -1666,6 +1684,8 @@ class ContratLigne
var $tva_tx;
var $localtax1_tx;
var $localtax2_tx;
var $localtax1_type; // Local tax 1 type
var $localtax2_type; // Local tax 2 type
var $qty;
var $remise_percent;
var $remise;
Expand Down

0 comments on commit e361566

Please sign in to comment.