Modifie addline pour calculer en TTC
This commit is contained in:
parent
158b3a9a6b
commit
f202e5b7a1
@ -88,7 +88,6 @@ class Facture extends CommonObject
|
|||||||
var $specimen;
|
var $specimen;
|
||||||
var $error;
|
var $error;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Constructeur de la classe
|
* \brief Constructeur de la classe
|
||||||
* \param DB handler accès base de données
|
* \param DB handler accès base de données
|
||||||
@ -1269,16 +1268,16 @@ class Facture extends CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Ajoute une ligne dans le tableau products
|
\brief Ajoute une ligne dans le tableau products
|
||||||
* \param idproduct Id du produit a ajouter
|
\param idproduct Id du produit a ajouter
|
||||||
* \param qty Quantité
|
\param qty Quantité
|
||||||
* \param remise_percent Remise relative effectuée sur le produit
|
\param remise_percent Remise relative effectuée sur le produit
|
||||||
* \param date_start
|
\param date_start
|
||||||
* \param date_end
|
\param date_end
|
||||||
* \return void
|
\return void
|
||||||
* \remarks $this->client doit etre chargé
|
\remarks $this->client doit etre chargé
|
||||||
* \TODO Remplacer les appels a cette fonction par generation objet Ligne
|
\TODO Remplacer les appels a cette fonction par generation objet Ligne
|
||||||
* inséré dans tableau $this->products
|
inséré dans tableau $this->products
|
||||||
*/
|
*/
|
||||||
function add_product($idproduct, $qty, $remise_percent, $date_start='', $date_end='')
|
function add_product($idproduct, $qty, $remise_percent, $date_start='', $date_end='')
|
||||||
{
|
{
|
||||||
@ -1300,12 +1299,12 @@ class Facture extends CommonObject
|
|||||||
|
|
||||||
$line=new FactureLigne($this->db);
|
$line=new FactureLigne($this->db);
|
||||||
$line->rowid = $idproduct;
|
$line->rowid = $idproduct;
|
||||||
$line->fk_product=$idproduct;
|
$line->fk_product = $idproduct;
|
||||||
$line->desc=$prod->description;
|
$line->desc = $prod->description;
|
||||||
$line->qty = $qty;
|
$line->qty = $qty;
|
||||||
$line->subprice=$price;
|
$line->subprice = $price;
|
||||||
$line->remise_percent = $remise_percent;
|
$line->remise_percent = $remise_percent;
|
||||||
$line->tva_tx=$tva_tx;
|
$line->tva_tx = $tva_tx;
|
||||||
if ($date_start) { $line->date_start = $date_start; }
|
if ($date_start) { $line->date_start = $date_start; }
|
||||||
if ($date_end) { $line->date_end = $date_end; }
|
if ($date_end) { $line->date_end = $date_end; }
|
||||||
|
|
||||||
@ -1331,10 +1330,10 @@ class Facture extends CommonObject
|
|||||||
* par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,taux_produit)
|
* par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,taux_produit)
|
||||||
* et le desc doit deja avoir la bonne valeur (a l'appelant de gerer le multilangue)
|
* et le desc doit deja avoir la bonne valeur (a l'appelant de gerer le multilangue)
|
||||||
*/
|
*/
|
||||||
function addline($facid, $desc, $pu, $qty, $txtva, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits='', $fk_remise_except='')
|
function addline($facid, $desc, $pu, $qty, $txtva, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits='', $fk_remise_except='', $price_base_type='HT', $pu_ttc=0)
|
||||||
{
|
{
|
||||||
global $conf;
|
global $conf;
|
||||||
dolibarr_syslog("facture.class.php::addline($facid,$desc,$pu,$qty,$txtva,$fk_product,$remise_percent,$date_start,$date_end,$ventil,$info_bits)");
|
dolibarr_syslog("Facture::Addline($facid,$desc,$pu,$qty,$txtva,$fk_product,$remise_percent,$date_start,$date_end,$ventil,$info_bits)");
|
||||||
include_once(DOL_DOCUMENT_ROOT.'/lib/price.lib.php');
|
include_once(DOL_DOCUMENT_ROOT.'/lib/price.lib.php');
|
||||||
|
|
||||||
if ($this->brouillon)
|
if ($this->brouillon)
|
||||||
@ -1354,7 +1353,7 @@ class Facture extends CommonObject
|
|||||||
// qty, pu, remise_percent et txtva
|
// qty, pu, remise_percent et txtva
|
||||||
// TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker
|
// 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.
|
// 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);
|
$tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, 0, $price_base_type, $pu_ttc);
|
||||||
$total_ht = $tabprice[0];
|
$total_ht = $tabprice[0];
|
||||||
$total_tva = $tabprice[1];
|
$total_tva = $tabprice[1];
|
||||||
$total_ttc = $tabprice[2];
|
$total_ttc = $tabprice[2];
|
||||||
@ -1511,8 +1510,10 @@ class Facture extends CommonObject
|
|||||||
* \brief Supprime une ligne facture de la base
|
* \brief Supprime une ligne facture de la base
|
||||||
* \param rowid Id de la ligne de facture a supprimer
|
* \param rowid Id de la ligne de facture a supprimer
|
||||||
*/
|
*/
|
||||||
function deleteline($rowid)
|
function deleteline($rowid, $user='')
|
||||||
{
|
{
|
||||||
|
global $langs, $conf;
|
||||||
|
|
||||||
dolibarr_syslog("Facture.class::deleteline rowid=".$rowid." ".$this->brouillon);
|
dolibarr_syslog("Facture.class::deleteline rowid=".$rowid." ".$this->brouillon);
|
||||||
|
|
||||||
if ($this->brouillon)
|
if ($this->brouillon)
|
||||||
@ -1542,6 +1543,12 @@ class Facture extends CommonObject
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Appel des triggers
|
||||||
|
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
|
||||||
|
$interface=new Interfaces($this->db);
|
||||||
|
$result = $interface->run_triggers('LINEBILL_DELETE',$this,$user,$langs,$conf);
|
||||||
|
// Fin appel triggers
|
||||||
|
|
||||||
$result=$this->update_price($this->id);
|
$result=$this->update_price($this->id);
|
||||||
|
|
||||||
$this->db->commit();
|
$this->db->commit();
|
||||||
@ -2721,7 +2728,6 @@ class FactureLigne
|
|||||||
$this->db= $DB ;
|
$this->db= $DB ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Recupére l'objet ligne de facture
|
* \brief Recupére l'objet ligne de facture
|
||||||
* \param rowid id de la ligne de facture
|
* \param rowid id de la ligne de facture
|
||||||
@ -2784,7 +2790,7 @@ class FactureLigne
|
|||||||
*/
|
*/
|
||||||
function insert()
|
function insert()
|
||||||
{
|
{
|
||||||
dolibarr_syslog("FactureLigne.class::insert rang=".$this->rang);
|
dolibarr_syslog("FactureLigne::Insert rang=".$this->rang);
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
$rangtouse=$this->rang;
|
$rangtouse=$this->rang;
|
||||||
@ -2852,8 +2858,6 @@ class FactureLigne
|
|||||||
$result = $interface->run_triggers('LINEBILL_INSERT',$this,$user,$langs,$conf);
|
$result = $interface->run_triggers('LINEBILL_INSERT',$this,$user,$langs,$conf);
|
||||||
// Fin appel triggers
|
// Fin appel triggers
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$this->db->commit();
|
$this->db->commit();
|
||||||
return $this->rowid;
|
return $this->rowid;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user