fix statistique
This commit is contained in:
parent
7336189871
commit
4b685628d7
@ -1995,14 +1995,33 @@ class Bdd {
|
||||
* Annual turnover per month without VAT
|
||||
*/
|
||||
public function getAnnualTurnoverPerMonthNoVat($idNextcloud){
|
||||
$sql = "SELECT EXTRACT(YEAR FROM ".$this->tableprefix."facture.date_paiement) as y,
|
||||
EXTRACT(MONTH FROM ".$this->tableprefix."facture.date_paiement) as m,
|
||||
sum(".$this->tableprefix."produit.prix_unitaire * ".$this->tableprefix."produit_devis.quantite) as total
|
||||
FROM `".$this->tableprefix."facture`, `".$this->tableprefix."produit_devis`, `".$this->tableprefix."produit`
|
||||
WHERE ".$this->tableprefix."facture.id_devis = ".$this->tableprefix."produit_devis.devis_id
|
||||
AND ".$this->tableprefix."produit_devis.produit_id = ".$this->tableprefix."produit.id
|
||||
GROUP BY EXTRACT(YEAR FROM ".$this->tableprefix."facture.date_paiement), EXTRACT(MONTH FROM ".$this->tableprefix."facture.date_paiement)
|
||||
ORDER BY EXTRACT(YEAR FROM ".$this->tableprefix."facture.date_paiement) DESC, EXTRACT(MONTH FROM ".$this->tableprefix."facture.date_paiement);";
|
||||
$sql = "SELECT
|
||||
EXTRACT(YEAR FROM facture.date_paiement) AS y,
|
||||
EXTRACT(MONTH FROM facture.date_paiement) AS m,
|
||||
SUM(
|
||||
COALESCE(client_group_discount.ht_amount,produit.prix_unitaire)
|
||||
* produit_devis.quantite
|
||||
) AS total
|
||||
FROM ".$this->tableprefix."facture AS facture
|
||||
JOIN ".$this->tableprefix."produit_devis AS produit_devis
|
||||
ON facture.id_devis = produit_devis.devis_id
|
||||
JOIN ".$this->tableprefix."produit AS produit
|
||||
ON produit_devis.produit_id = produit.id
|
||||
JOIN ".$this->tableprefix."devis AS devis
|
||||
ON facture.id_devis = devis.id
|
||||
JOIN ".$this->tableprefix."client AS client
|
||||
ON devis.id_client = client.id
|
||||
LEFT JOIN ".$this->tableprefix."client_group AS client_group
|
||||
ON client.fk_client_group_id = client_group.id
|
||||
LEFT JOIN ".$this->tableprefix."client_group_discount AS client_group_discount
|
||||
ON client_group.id = client_group_discount.fk_client_group_id
|
||||
AND produit.id = client_group_discount.fk_produit_id
|
||||
GROUP BY
|
||||
EXTRACT(YEAR FROM facture.date_paiement),
|
||||
EXTRACT(MONTH FROM facture.date_paiement)
|
||||
ORDER BY
|
||||
EXTRACT(YEAR FROM facture.date_paiement) DESC,
|
||||
EXTRACT(MONTH FROM facture.date_paiement);";
|
||||
return $this->execSQL($sql, array());
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user