Skip to content
Snippets Groups Projects
Commit 37a921b6 authored by Laurent Lecluse's avatar Laurent Lecluse
Browse files

Plus de missions dans les paiements

parent dbf0454c
Branches
Tags
No related merge requests found
......@@ -153,98 +153,3 @@ FROM
LEFT JOIN mise_en_paiement mep ON mep.formule_res_service_ref_id = frs.id
AND mep.histo_destruction IS NULL
) t
\ No newline at end of file
UNION ALL
SELECT
t.annee_id,
NULL service_id,
NULL service_referentiel_id,
NULL formule_res_service_id,
NULL formule_res_service_ref_id,
t.mission_id,
t.intervenant_id,
t.structure_id,
mep.id mise_en_paiement_id,
mep.periode_paiement_id periode_paiement_id,
mep.domaine_fonctionnel_id domaine_fonctionnel_id,
t.heures_a_payer,
COUNT(*) OVER(PARTITION BY t.mission_id, t.taux_remu_id, t.taux_horaire) heures_a_payer_pond,
COALESCE(mep.heures,0) heures_demandees,
CASE WHEN mep.periode_paiement_id IS NULL THEN 0 ELSE mep.heures END heures_payees,
ROUND(t.heures_aa / t.heures_a_payer,2) pourc_exercice_aa,
1 - ROUND(t.heures_aa / t.heures_a_payer,2) pourc_exercice_ac,
t.heures_aa,
t.heures_ac,
t.taux_remu_id,
t.taux_horaire,
t.taux_conges_payes
FROM
(
SELECT
t.annee_id,
t.mission_id,
t.intervenant_id,
t.structure_id,
SUM(t.heures_a_payer) heures_a_payer,
--CASE WHEN t.aa = 1 THEN SUM(t.heures_a_payer) / SUM(t.heures_a_payer) ELSE 0 END pourc_exercice_aa,
-- SUM(t.heures_a_payer) / SUM(CASE WHEN t.aa = 0 THEN t.heures_a_payer ELSE 0 END) pourc_exercice_ac,
SUM(CASE WHEN t.aa = 1 THEN t.heures_a_payer ELSE 0 END) heures_aa,
SUM(CASE WHEN t.aa = 0 THEN t.heures_a_payer ELSE 0 END) heures_ac,
t.taux_remu_id,
t.taux_horaire,
t.taux_conges_payes
FROM
(
SELECT
tm.annee_id annee_id,
tm.mission_id mission_id,
tm.intervenant_id intervenant_id,
tm.structure_id structure_id,
vhm.heures heures_a_payer,
CASE WHEN to_number(TO_CHAR( vhm.horaire_debut, 'YYYY' )) = tm.annee_id THEN 1 ELSE 0 END aa,
CASE WHEN
TO_CHAR( vhm.horaire_debut, 'HH24:MI' ) >= ose_parametre.get_horaire_nocturne -- horaire nocturne
OR jf.id IS NOT NULL -- jour ferie
OR TO_CHAR(vhm.horaire_debut, 'DAY', 'NLS_DATE_LANGUAGE=FRENCH') = 'DIMANCHE' -- dimanche
THEN
COALESCE(m.taux_remu_majore_id, m.taux_remu_id)
ELSE
m.taux_remu_id
END taux_remu_id,
ose_paiement.get_taux_horaire(CASE WHEN
TO_CHAR( vhm.horaire_debut, 'HH24:MI' ) >= ose_parametre.get_horaire_nocturne -- horaire nocturne
OR jf.id IS NOT NULL -- jour ferie
OR TO_CHAR(vhm.horaire_debut, 'DAY', 'NLS_DATE_LANGUAGE=FRENCH') = 'DIMANCHE' -- dimanche
THEN
COALESCE(m.taux_remu_majore_id, m.taux_remu_id)
ELSE
m.taux_remu_id
END, vhm.horaire_debut) taux_horaire,
ose_parametre.get_taux_conges_payes+1 taux_conges_payes
FROM
tbl_mission tm
JOIN mission m ON m.id = tm.mission_id
JOIN volume_horaire_mission vhm ON vhm.histo_destruction IS NULL AND vhm.mission_id = tm.mission_id
JOIN type_volume_horaire tvh ON tvh.id = vhm.type_volume_horaire_id AND tvh.code ='REALISE'
LEFT JOIN validation_vol_horaire_miss vvhm ON vvhm.volume_horaire_mission_id = vhm.id
LEFT JOIN validation v ON v.id = vvhm.validation_id AND v.histo_destruction IS NULL
LEFT JOIN jour_ferie jf ON TO_CHAR( jf.date_jour, 'dd/mm/YYYY' ) = TO_CHAR( vhm.horaire_debut, 'dd/mm/YYYY' )
WHERE
tm.valide = 1
/*@INTERVENANT_ID=tm.intervenant_id*/ /*@ANNEE_ID=tm.annee_id*/
AND (vhm.auto_validation = 1 OR v.id IS NOT NULL)
ORDER BY
vhm.horaire_debut
) t
GROUP BY
t.annee_id,
t.mission_id,
t.intervenant_id,
t.structure_id,
t.taux_remu_id,
t.taux_horaire,
t.taux_conges_payes
) t
LEFT JOIN mise_en_paiement mep ON mep.mission_id = t.mission_id AND mep.histo_destruction IS NULL
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment