Exclude only replaced (duplicated) invoices.

This commit is contained in:
Laurent Destailleur 2009-11-29 13:13:02 +00:00
parent ccb14879e8
commit 957318f9d2

View File

@ -35,13 +35,13 @@ include_once DOL_DOCUMENT_ROOT . "/fourn/fournisseur.facture.class.php";
class FactureStats extends Stats class FactureStats extends Stats
{ {
var $db ; var $db ;
var $socid; var $socid;
var $where; var $where;
var $table_element; var $table_element;
var $field; var $field;
/** /**
* Constructor * Constructor
* *
@ -53,7 +53,7 @@ class FactureStats extends Stats
function FactureStats($DB, $socid=0, $mode) function FactureStats($DB, $socid=0, $mode)
{ {
global $conf; global $conf;
$this->db = $DB; $this->db = $DB;
if ($mode == 'customer') if ($mode == 'customer')
{ {
@ -67,16 +67,16 @@ class FactureStats extends Stats
$this->from = MAIN_DB_PREFIX.$object->table_element; $this->from = MAIN_DB_PREFIX.$object->table_element;
$this->field='total_ht'; $this->field='total_ht';
} }
$this->socid = $socid; $this->socid = $socid;
$this->where =" fk_statut > 0"; $this->where = " fk_statut > 0";
$this->where.= " AND entity = ".$conf->entity; $this->where.= " AND entity = ".$conf->entity;
if ($mode == 'customer') $this->where.=" AND fk_statut != 3"; // Exclude replaced invoices if ($mode == 'customer') $this->where.=" AND (fk_statut != 3 OR close_code != 'replaced')"; // Exclude replaced invoices as they are duplicated (we count closed invoices for other reasons)
if ($this->socid) if ($this->socid)
{ {
$this->where.=" AND fk_soc = ".$this->socid; $this->where.=" AND fk_soc = ".$this->socid;
} }
} }
@ -90,11 +90,11 @@ class FactureStats extends Stats
$sql.= " FROM ".$this->from; $sql.= " FROM ".$this->from;
$sql.= " GROUP BY dm DESC"; $sql.= " GROUP BY dm DESC";
$sql.= " WHERE ".$this->where; $sql.= " WHERE ".$this->where;
return $this->_getNbByYear($sql); return $this->_getNbByYear($sql);
} }
/** /**
* \brief Renvoie le nombre de facture par mois pour une annee donnee * \brief Renvoie le nombre de facture par mois pour une annee donnee
* \param year Year to scan * \param year Year to scan
@ -133,7 +133,7 @@ class FactureStats extends Stats
} }
/** /**
* \brief Return average amount * \brief Return average amount
* \param year Year to scan * \param year Year to scan
* \return array Array of values * \return array Array of values
*/ */
@ -147,9 +147,9 @@ class FactureStats extends Stats
return $this->_getAverageByMonth($year, $sql); return $this->_getAverageByMonth($year, $sql);
} }
/** /**
* \brief Return nb, total and average * \brief Return nb, total and average
* \return array Array of values * \return array Array of values
*/ */
function getAllByYear() function getAllByYear()
@ -160,7 +160,7 @@ class FactureStats extends Stats
$sql.= " GROUP BY year DESC"; $sql.= " GROUP BY year DESC";
return $this->_getAllByYear($sql); return $this->_getAllByYear($sql);
} }
} }
?> ?>