src: |
  SELECT p_presence_salaries.salarie_id,
      p_presence_salaries.mois_paie,
      p_presence_salaries.etablissement_id AS rhp_etablissement_id,
      p_presence_salaries.present_paie,
      p_presence_salaries.present_planning,
      p_presence_salaries.presence_contrat,
      p_presence_salaries.est_interimaire,
      base.cti_last_day(to_date(p_presence_salaries.mois_paie::text, 'YYYYMM'::text)) AS date_paie,
      0::bigint AS rhp_pole_id,
      p_contrats.oid AS contrat_id,
      p_contrats_mois.oid AS contrat_mois_id,
      p_contrats.numero_contrat AS contrat_code,
      p_contrats_mois.date_debut AS date_debut_activite,
      p_contrats_mois.date_fin AS date_fin_activite,
      p_profil_contrat_mois.profil_id AS rhp_profil_id,
      p_contrats_mois.age_id AS rhp_age_id,
      p_salaries.nationalite_id AS rhp_nationalite_id,
      p_salaries.code_postal_id AS rhp_code_postal_id,
      p_salaries.situation_famille_id AS rhp_situation_famille_id
     FROM rh.p_presence_salaries
       JOIN rh.p_contrats_mois ON p_contrats_mois.salarie_id = p_presence_salaries.salarie_id AND p_contrats_mois.mois_activite = p_presence_salaries.mois_paie::numeric
       JOIN rh.p_contrats ON p_contrats.oid = p_contrats_mois.contrat_id
       JOIN rh.p_profil_contrat_mois ON p_profil_contrat_mois.contrat_mois_id = p_contrats_mois.oid
       JOIN rh.p_salaries ON p_salaries.oid = p_presence_salaries.salarie_id;