====== Requête d'extraction du volume de transaction à facturer aux clients de la fidélité ======
==== Oriba ====
-- pour determiner le volume carburant fidelite
SELECT
categorie_participant.libelle,
point_collecte.reference_externe,
point_collecte.numero_transaction_externe,
point_collecte.date_transaction,
point_collecte.date_collecte,
evenement.intitule,
point_collecte.valeur_achat,
point_collecte.valeur_achat / ((538 + 540) / 2) a_facturer, -- pour le niger avec 540f/l essence et 538f/l diesel type_unite.intitule,
point_collecte.reference_point_collecte
FROM
point_collecte,
campagne_participant,
evenement,
categorie_participant,
type_unite
WHERE
point_collecte. `campagne_participant_id` = campagne_participant. `id`
AND point_collecte. `evenement_id` = evenement. `id`
AND evenement.intitule in('Carburant - paiement carte', 'Carburant - paiement espece')
AND point_collecte. `campagne_participant_id` = campagne_participant. `id`
AND campagne_participant. `categorie_id` = categorie_participant.id
AND point_collecte. `campagne_id` = 2
AND point_collecte.type_unite_id = type_unite.id
AND reference_externe IS NOT NULL
AND point_collecte.date_collecte BETWEEN '2021-01-01' AND '2022-08-31'
ORDER BY
point_collecte.date_collecte;
==== Elton Dakar ====
-- pour determiner le volume carburant fidelite
SELECT
categorie_participant.libelle,
point_collecte.reference_externe,
point_collecte.numero_transaction_externe,
point_collecte.date_transaction,
point_collecte.date_collecte,
evenement.intitule,
point_collecte.valeur_achat,
point_collecte.valeur_achat / ((775 + 665) / 2) a_facturer, -- pour le senegal avec 775f/l essence et 665f/f diesel type_unite.intitule,
point_collecte.reference_point_collecte
FROM
point_collecte,
campagne_participant,
evenement,
categorie_participant,
type_unite
WHERE
point_collecte. `campagne_participant_id` = campagne_participant. `id`
AND point_collecte. `evenement_id` = evenement. `id`
AND evenement.intitule in('Carburant - paiement carte', 'Carburant - paiement espece')
AND point_collecte. `campagne_participant_id` = campagne_participant. `id`
AND campagne_participant. `categorie_id` = categorie_participant.id
AND point_collecte. `campagne_id` = 1
AND point_collecte.type_unite_id = type_unite.id
AND reference_externe IS NOT NULL
AND point_collecte.date_collecte BETWEEN '2021-01-01' AND '2022-08-31'
ORDER BY
point_collecte.date_collecte;