Commit cdb742f7 authored by Antony Le Courtes's avatar Antony Le Courtes
Browse files

Correction proratisation des imputations budgétaire siham pour tenir compte des codes indémnités

parent 0ae8b99f
Loading
Loading
Loading
Loading
+13 −7
Changes for data/ddl/view/V_IMPUTATION_BUDGETAIRE_SIHAM.sql: 13 added lines, 7 removed lines.
Original line number Diff line number Diff line
CREATE OR REPLACE FORCE VIEW V_IMPUTATION_BUDGETAIRE_SIHAM AS
--CREATE OR REPLACE FORCE VIEW V_IMPUTATION_BUDGETAIRE_SIHAM AS
SELECT
	type,
	uo,
@@ -13,7 +13,7 @@ SELECT
	poste_reservation_credit,
	--On impact le potentiel écart de pourcentage détecté pour s'assurer que la somme des pourcentages fasse 100%
 	CASE
	    WHEN rank() OVER (PARTITION BY periode_id, intervenant_id   ORDER BY operation,centre_cout, pourcentage) = 1
	    WHEN rank() OVER (PARTITION BY periode_id, intervenant_id,code_indemnite   ORDER BY operation,centre_cout, pourcentage) = 1
	    THEN pourcentage + pourc_ecart
	    ELSE pourcentage END    	                                                                                          pourcentage,
     nombres_heures,
@@ -28,9 +28,9 @@ SELECT
     FROM(
SELECT
	imputation2.*,
	SUM(pourcentage) OVER ( PARTITION BY periode_id, intervenant_id)   somme,
	SUM(pourcentage) OVER ( PARTITION BY periode_id, intervenant_id, code_indemnite)   somme,
	--On regarde si la somme des pourcentages est égale à 100% sinon on calcule l'écart qu'il faudra redistribuer ou retirer
	100 - SUM(pourcentage) OVER ( PARTITION BY periode_id, intervenant_id)  pourc_ecart
	100 - SUM(pourcentage) OVER ( PARTITION BY periode_id, intervenant_id,code_indemnite)  pourc_ecart
FROM (
	SELECT 'P'                                                                                										type,
		   NULL																				  										uo,
@@ -44,7 +44,7 @@ FROM (
	       NULL                                                                               										fonds,
	       NULL                                                                               										poste_reservation_credit,
	       CASE WHEN montant_hetd > 0
	       	    THEN ROUND(montant_hetd / SUM(montant_hetd) OVER( PARTITION BY periode_id,intervenant_id)*100,2)
	       	    THEN ROUND(montant_hetd / SUM(montant_hetd) OVER( PARTITION BY periode_id,intervenant_id,code_indemnite)*100,2)
	       	    ELSE 0  END																											pourcentage,
	       CASE WHEN hetd >= 100 THEN FLOOR(hetd) || ':' || lpad(FLOOR((hetd - FLOOR(hetd)) * 60), 2, 0)
	       ELSE (lpad(FLOOR(hetd), 2, '0')) || ':' || lpad(FLOOR((hetd - FLOOR(hetd)) * 60), 2, 0) END         						nombres_heures,
@@ -68,9 +68,9 @@ FROM(
		       MAX(TRIM(to_char(last_day(add_months(a.date_debut, p.ecart_mois)),'dd/mm/yyyy')))             date_fin,
		       CASE
		          WHEN MAX(th.code) = 'fc_majorees'  THEN '1542'
		          WHEN MAX(mis.mission_id) IS NOT NULL THEN '0125'
		          WHEN MAX(mis.mission_id) IS NOT NULL THEN '="0125"'
		          ELSE
		             CASE WHEN MAX(ti.code) = 'P' THEN '="0204"' ELSE '="2251"' END
		             CASE WHEN MAX(ti.code) = 'P' THEN '="0204"' ELSE '2251' END
		          END                                                                                        code_indemnite,
		       MAX(CASE WHEN cc.parent_id IS NULL THEN cc.source_code ELSE cc2.source_code END)              centre_cout_code,
			   MAX(CASE WHEN cc.parent_id IS NULL THEN cc.id ELSE cc2.id END)                                centre_cout_id,
@@ -106,6 +106,12 @@ FROM(
			GROUP BY
				i.id,
			   	p.id,
			   	CASE
		          WHEN th.code = 'fc_majorees'  THEN '1542'
		          WHEN mis.mission_id IS NOT NULL THEN '="0125"'
		          ELSE
		             CASE WHEN ti.code = 'P' THEN '="0204"' ELSE '2251' END
		          END,
			   	CASE WHEN cc.parent_id IS NULL THEN cc.id ELSE cc2.id END,
			   	CASE WHEN cc.parent_id IS NOT NULL THEN cc.id ELSE NULL END
			 ORDER BY i.id, p.id) imputation) imputation2) imputation3
+12 −6
Changes for data/ddl/view/V_IMPUTATION_BUDGETAIRE_SIHAM_ETUDIANT.sql: 12 added lines, 6 removed lines.
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@ SELECT
	poste_reservation_credit,
	--On impact le potentiel écart de pourcentage détecté pour s'assurer que la somme des pourcentages fasse 100%
    CASE
        WHEN rank() OVER (PARTITION BY periode_id, intervenant_id   ORDER BY operation,centre_cout, pourcentage) = 1
        WHEN rank() OVER (PARTITION BY periode_id, intervenant_id,code_indemnite   ORDER BY operation,centre_cout, pourcentage) = 1
        THEN pourcentage + pourc_ecart
        ELSE pourcentage END                                                                                        pourcentage,
     nombres_heures,
@@ -42,9 +42,9 @@ SELECT
FROM(
SELECT
	imputation2.*,
	SUM(pourcentage) OVER ( PARTITION BY periode_id, intervenant_id)   somme,
	SUM(pourcentage) OVER ( PARTITION BY periode_id, intervenant_id,code_indemnite)   somme,
	--On regarde si la somme des pourcentages est égale à 100% sinon on calcule l'écart qu'il faudra redistribuer ou retirer
	100 - SUM(pourcentage) OVER ( PARTITION BY periode_id, intervenant_id)  pourc_ecart
	100 - SUM(pourcentage) OVER ( PARTITION BY periode_id, intervenant_id,code_indemnite)  pourc_ecart
FROM (
	SELECT 'P'                                                                                										type,
		   NULL																				  										uo,
@@ -58,7 +58,7 @@ FROM (
	       NULL                                                                               										fonds,
	       NULL                                                                               										poste_reservation_credit,
	       CASE WHEN montant_hetd > 0
	       	    THEN ROUND(montant_hetd / SUM(montant_hetd) OVER( PARTITION BY periode_id,intervenant_id)*100,2)
	       	    THEN ROUND(montant_hetd / SUM(montant_hetd) OVER( PARTITION BY periode_id,intervenant_id,code_indemnite)*100,2)
	       	    ELSE 0  END																											pourcentage,
	       CASE WHEN hetd >= 100 THEN FLOOR(hetd) || ':' || lpad(FLOOR((hetd - FLOOR(hetd)) * 60), 2, 0)
	       ELSE (lpad(FLOOR(hetd), 2, '0')) || ':' || lpad(FLOOR((hetd - FLOOR(hetd)) * 60), 2, 0) END         						nombres_heures,
@@ -81,9 +81,9 @@ FROM (
		       MAX(TRIM(to_char(last_day(add_months(a.date_debut, p.ecart_mois)),'dd/mm/yyyy')))             date_fin,
		       CASE
		          WHEN MAX(th.code) = 'fc_majorees'  THEN '1542'
		          WHEN MAX(mis.mission_id) IS NOT NULL THEN '0125'
		          WHEN MAX(mis.mission_id) IS NOT NULL THEN '="0125"'
		          ELSE
		             CASE WHEN MAX(ti.code) = 'P' THEN '="0204"' ELSE '="2251"' END
		             CASE WHEN MAX(ti.code) = 'P' THEN '="0204"' ELSE '2251' END
		          END                                                                                        code_indemnite,
		       MAX(CASE WHEN cc.parent_id IS NULL THEN cc.source_code ELSE cc2.source_code END)              centre_cout_code,
			   MAX(CASE WHEN cc.parent_id IS NULL THEN cc.id ELSE cc2.id END)                                centre_cout_id,
@@ -119,6 +119,12 @@ FROM (
			GROUP BY
				i.id,
			   	p.id,
			   	CASE
		          WHEN th.code = 'fc_majorees'  THEN '1542'
		          WHEN mis.mission_id IS NOT NULL THEN '="0125"'
		          ELSE
		             CASE WHEN ti.code = 'P' THEN '="0204"' ELSE '2251' END
		          END,
				CASE WHEN cc.parent_id IS NULL THEN cc.id ELSE cc2.id END,
			   	CASE WHEN cc.parent_id IS NOT NULL THEN cc.id ELSE NULL END
			 ORDER BY i.id, p.id) imputation) imputation2) imputation3