Merge branch 'fixes/fix-annual-stat' into staging
This commit is contained in:
commit
0150e65895
@ -1995,14 +1995,33 @@ class Bdd {
|
|||||||
* Annual turnover per month without VAT
|
* Annual turnover per month without VAT
|
||||||
*/
|
*/
|
||||||
public function getAnnualTurnoverPerMonthNoVat($idNextcloud){
|
public function getAnnualTurnoverPerMonthNoVat($idNextcloud){
|
||||||
$sql = "SELECT EXTRACT(YEAR FROM ".$this->tableprefix."facture.date_paiement) as y,
|
$sql = "SELECT
|
||||||
EXTRACT(MONTH FROM ".$this->tableprefix."facture.date_paiement) as m,
|
EXTRACT(YEAR FROM facture.date_paiement) AS y,
|
||||||
sum(".$this->tableprefix."produit.prix_unitaire * ".$this->tableprefix."produit_devis.quantite) as total
|
EXTRACT(MONTH FROM facture.date_paiement) AS m,
|
||||||
FROM `".$this->tableprefix."facture`, `".$this->tableprefix."produit_devis`, `".$this->tableprefix."produit`
|
SUM(
|
||||||
WHERE ".$this->tableprefix."facture.id_devis = ".$this->tableprefix."produit_devis.devis_id
|
COALESCE(client_group_discount.ht_amount,produit.prix_unitaire)
|
||||||
AND ".$this->tableprefix."produit_devis.produit_id = ".$this->tableprefix."produit.id
|
* produit_devis.quantite
|
||||||
GROUP BY EXTRACT(YEAR FROM ".$this->tableprefix."facture.date_paiement), EXTRACT(MONTH FROM ".$this->tableprefix."facture.date_paiement)
|
) AS total
|
||||||
ORDER BY EXTRACT(YEAR FROM ".$this->tableprefix."facture.date_paiement) DESC, EXTRACT(MONTH FROM ".$this->tableprefix."facture.date_paiement);";
|
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());
|
return $this->execSQL($sql, array());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user