Fix: Creation facture depuis contrat
This commit is contained in:
parent
d7edb59b09
commit
f6b5a508ad
@ -330,19 +330,19 @@ class Contrat extends CommonObject
|
|||||||
*/
|
*/
|
||||||
function fetch_lignes()
|
function fetch_lignes()
|
||||||
{
|
{
|
||||||
dolibarr_syslog("Contrat.class.php::fetch_lignes");
|
|
||||||
$this->lignes = array();
|
$this->lignes = array();
|
||||||
|
|
||||||
// Selectionne les lignes contrats liées à un produit
|
// Selectionne les lignes contrats liées à un produit
|
||||||
$sql = "SELECT p.label, p.description as product_desc, p.ref,";
|
$sql = "SELECT p.label, p.description as product_desc, p.ref,";
|
||||||
$sql.= " d.rowid, d.statut, d.description, d.price_ht, d.tva_tx, d.qty, d.remise_percent, d.subprice,";
|
$sql.= " d.rowid, d.statut, d.description, d.price_ht, d.tva_tx, d.qty, d.remise_percent, d.subprice,";
|
||||||
$sql.= " d.info_bits, d.fk_product";
|
$sql.= " d.info_bits, d.fk_product,";
|
||||||
$sql.= " d.date_ouverture_prevue, d.date_ouverture,";
|
$sql.= " d.date_ouverture_prevue, d.date_ouverture,";
|
||||||
$sql.= " d.date_fin_validite, d.date_cloture";
|
$sql.= " d.date_fin_validite, d.date_cloture";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."contratdet as d, ".MAIN_DB_PREFIX."product as p";
|
$sql.= " FROM ".MAIN_DB_PREFIX."contratdet as d, ".MAIN_DB_PREFIX."product as p";
|
||||||
$sql.= " WHERE d.fk_contrat = ".$this->id ." AND d.fk_product = p.rowid";
|
$sql.= " WHERE d.fk_contrat = ".$this->id ." AND d.fk_product = p.rowid";
|
||||||
$sql.= " ORDER by d.rowid ASC";
|
$sql.= " ORDER by d.rowid ASC";
|
||||||
|
|
||||||
|
dolibarr_syslog("Contrat.class.php::fetch_lignes sql=".$sql);
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
if ($result)
|
if ($result)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1267,50 +1267,53 @@ 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='')
|
||||||
{
|
{
|
||||||
global $conf, $mysoc;
|
global $conf, $mysoc;
|
||||||
|
|
||||||
|
// Nettoyage parametres
|
||||||
|
if (! $qty) $qty = 1;
|
||||||
|
|
||||||
|
dolibarr_syslog("Facture.class::add_product $idproduct, $qty, $remise_percent, $date_start, $date_end");
|
||||||
|
|
||||||
if (! $qty) $qty = 1;
|
if ($idproduct > 0)
|
||||||
|
{
|
||||||
if ($idproduct > 0)
|
$prod=new Product($this->db);
|
||||||
{
|
$prod->fetch($idproduct);
|
||||||
$prod=new Product($this->db);
|
|
||||||
$prod->fetch($idproduct);
|
$tva_tx = get_default_tva($mysoc,$this->client,$prod->tva_tx);
|
||||||
|
// multiprix
|
||||||
$tva_tx = get_default_tva($mysoc,$this->client,$prod->tva_tx);
|
if($conf->global->PRODUIT_MULTIPRICES == 1)
|
||||||
// multiprix
|
$price = $prod->multiprices[$this->client->price_level];
|
||||||
if($conf->global->PRODUIT_MULTIPRICES == 1)
|
else
|
||||||
$price = $prod->multiprices[$this->client->price_level];
|
$price = $prod->price;
|
||||||
else
|
|
||||||
$price = $prod->price;
|
$line=new FactureLigne($this->db);
|
||||||
|
$line->rowid = $idproduct;
|
||||||
$line=new FactureLigne($this->db);
|
$line->fk_product = $idproduct;
|
||||||
$line->rowid = $idproduct;
|
$line->desc = $prod->description;
|
||||||
$line->fk_product = $idproduct;
|
$line->qty = $qty;
|
||||||
$line->desc = $prod->description;
|
$line->subprice = $price;
|
||||||
$line->qty = $qty;
|
$line->remise_percent = $remise_percent;
|
||||||
$line->subprice = $price;
|
$line->tva_tx = $tva_tx;
|
||||||
$line->remise_percent = $remise_percent;
|
if ($date_start) { $line->date_start = $date_start; }
|
||||||
$line->tva_tx = $tva_tx;
|
if ($date_end) { $line->date_end = $date_end; }
|
||||||
if ($date_start) { $line->date_start = $date_start; }
|
|
||||||
if ($date_end) { $line->date_end = $date_end; }
|
$this->products[]=$line;
|
||||||
|
}
|
||||||
$this->products[]=$line;
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Ajoute une ligne de facture (associé à un produit/service prédéfini ou non)
|
* \brief Ajoute une ligne de facture (associé à un produit/service prédéfini ou non)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user