Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Intégration de la réduction de loyer solidarité (RLS) dans la formule de calcul de l’aide personnalisée au logement (APL) #1058

Merged
merged 1 commit into from
Aug 17, 2018

Conversation

mtifarine
Copy link
Contributor

@mtifarine mtifarine commented Aug 1, 2018

  • Évolution du système socio-fiscal.

  • Périodes concernées : toutes.

  • Zones impactées :

    • model\prestations\aides_logement
    • parameters\prestations\reduction_loyer_solidarite
  • Détails :

    • Intégration de la réduction du loyer de solidarité dans la formule de calcul de l'APL.

Ces changements :

  • Corrigent ou améliorent un calcul déjà existant.

@mtifarine
Copy link
Contributor Author

bonjour,
Mohamed je viens d’intégrer l’équipe avec @frtomas et c'est ma première PR.
Cette PR est tjrs en cours, je ferai une demande review quand il sera terminé.

Merci,

@mtifarine mtifarine changed the title Fiabilisation des bases ressources des aides CMU-c et ACS – Intégration de la ressource « Rente d’accident du travail Intégration de la réduction de loyer solidarité (RLS) dans la formule de calcul de l’aide personnalisée au logement (APL) Aug 1, 2018
@jmdallais jmdallais added the contrib:msa Identification des sujets MSA label Aug 2, 2018
@jmdallais
Copy link

@mtifarine , juste faire attention de bien poser le label contrib. MSA stp.

@guillett
Copy link
Member

guillett commented Aug 2, 2018

Le calcul de la RLS a comencé à être implémenté fin mai et a été mergé en production la semaine dernière cf #998.

De nombreuses modifications dans cette PR sont des modifications de style (espace, indentation, etc.), cela rend la relecture du développement compliquée.
@mtifarine peux-tu voir si les paramètres de ton éditeur peuvent être modifiés ?

@mtifarine
Copy link
Contributor Author

Oui, on a remarqué ça retard, mais il reste la partie d’intégration de RLS dans la formule de calcul de l'APL.
Ok @guillett, je vais vérifier les paramètres de mon éditeur concernant les modifications de style.

merci

@mtifarine mtifarine force-pushed the msa_rls branch 3 times, most recently from 286740b to da872ea Compare August 3, 2018 08:59
Copy link
Member

@guillett guillett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merci pour cette PR.

J'ai mis quelques remarques.

Attention, j'ai l'impression que tu fais des git push --force sur une PR ouverte ce n'est pas idéal.

Tu peux toujours créer des commits avec le prefix 'fixup!' suivi du nom du commit auquel tu voudras ajouter le commit.

Une fois les échanges sur la PR terminés tu pourrais git rebase --interactive --autosquash origin/master pour regrouper les développements.

@@ -0,0 +1,2 @@
description: reduction de loyer solidarité
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pourquoi avoir rajouté ce fichier ?

@@ -0,0 +1,6 @@
description: Taux de rls
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Le nom de ce fichier ; et donc du paramètre associé ; ne me parait pas idéal. fraction_baisse_aide_logement ? @Anna-Livia ton avis sur ce point m'intéresse :)

@@ -726,8 +726,10 @@ def formula(famille, period, parameters):
montant_accedants = famille('aides_logement_primo_accedant', period)

montant = select([locataire, accedant], [montant_locataire, montant_accedants])
# suppression du montant minimal de versement
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Une telle modification nécessite des références législatives et des tests, non ? D'où vient cette modification ?

CHANGELOG.md Outdated
@@ -1,4 +1,12 @@
# Changelog
### 22.5.1 [#1050](https://github.com/openfisca/openfisca-france/pull/1058)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Il faudrait un saut de ligne avec cette section.

@mtifarine
Copy link
Contributor Author

Bonjour @guillett,
J'ai corrigé le code selon les remarques que vous avez faites,
On a les deux erreurs ( first_node = nodes[0] IndexError: list index out of range) qu'on sais pas d'où ils viennent.

definition_period = MONTH

def formula(famille, period):
def formula(famille, period, parameters):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ta nouvelle implémentation n'est valable qu'à partir du 1/1/18.

Il ne faut donc pas modifier la formule mais ajouter une formule à la variable valable à partir du 1/1/18 :

    def formula_2018(famille, period, parameters):
        rls = parameters(period).prestations.reduction_loyer_solidarite
        aide_logement_montant_brut = famille('aide_logement_montant_brut', period)
        reduction_loyer_solidarite = famille('reduction_loyer_solidarite', period)
        statut_occupation_logement = famille.demandeur.menage('statut_occupation_logement', period)

        taux_rls = rls.taux_rls
        rls_apl = reduction_loyer_solidarite * taux_rls * (statut_occupation_logement == TypesStatutOccupationLogement.locataire_hlm)
        aide_logement_montant_brut_rls = max_(0, (aide_logement_montant_brut - rls_apl))
        crds_logement = famille('crds_logement', period)
        montant = max_(0, round_(aide_logement_montant_brut_rls + crds_logement, 2))

        return montant

@guillett
Copy link
Member

guillett commented Aug 8, 2018

@mtifarine le message d'erreur devrait être amélioré.

Avec l'implémentation actuelle tu essaies d'utiliser les paramètres spécifiques de la RLS en 2013 alors qu'ils ne sont définis qu'à partir du 2018.

Mon commentaire devrait te donner des pistes pour la résolution du problème.

Au fait arrives-tu à lancer les tests en local ? Par exemple nosetests tests/reforms/test_landais_piketty_saez.py ?

@mtifarine
Copy link
Contributor Author

Bonjour @guillett,

C'est bon j'ai corrigé les deux erreurs, ou j'ai ajouté une nouvelle formule pour la suppression du seuil de non versement de l’APL au lieux de modifier la formule qui existe.

J'ai renommé le fichier du paramètre taux du montant de la réduction de loyer de solidarité : fraction_baisse_aide_logement.

Copy link
Member

@guillett guillett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merci beaucoup @mtifarine pour ces modifications. J'ai apporté de nouveaux commentaires.

@@ -726,8 +727,29 @@ def formula(famille, period, parameters):
montant_accedants = famille('aides_logement_primo_accedant', period)

montant = select([locataire, accedant], [montant_locataire, montant_accedants])
montant = montant * (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pourquoi as-tu modifié la formule précédente ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

non je l'ai pas modifié, j'ai ajouté une nouvelle formule "formula_2018_03_01"


montant = montant * (montant >= al.al_min.montant_min_mensuel.montant_min_apl_al) # Montant minimal de versement
def formula_2018_03_01(famille, period, parameters):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

La suppression du seuil de versement s'applique-t-il uniquement aux APL ou bien aussi à ALF et à ALS ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oui c vrai il s'applique uniquement aux APL , donc j'ai rajouté la condition:
(statut_occupation_logement != TypesStatutOccupationLogement.locataire_hlm) au lieux de supprimer la ligne.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 une autre possibilité est d'ajouter une nouvelle formule à la variable apl. Ça me parait plus propre. Qu'en penses-tu ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On ne peut pas faire ce que je raconte.

@@ -936,7 +972,6 @@ def formula(famille, period):
apl = famille('apl', period)
als = famille('als', period)
alf = famille('alf', period)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pourquoi avoir supprimé cette ligne ?

@@ -317,7 +317,6 @@ def formula(famille, period, parameters):
heberge_titre_gratuit = (statut_occupation_logement == TypesStatutOccupationLogement.loge_gratuitement)
forfait_logement = ((proprietaire + heberge_titre_gratuit) * cmu_forfait_logement_base +
cmu_forfait_logement_al)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pourquoi avoir supprimé cette ligne ?

@@ -385,7 +384,6 @@ def formula(famille, period):
acs_montant = famille('acs_montant', period)
residence_mayotte = famille.demandeur.menage('residence_mayotte', period)
cmu_acs_eligibilite = famille('cmu_acs_eligibilite', period)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pourquoi avoir supprimé cette ligne ?

@@ -17,6 +17,7 @@ class rsa_base_ressources(Variable):

def formula_2017_01_01(famille, mois_demande, parameters, mois_courant):
rsa_base_ressources_prestations_familiales = famille('rsa_base_ressources_prestations_familiales', mois_demande, extra_params = [mois_courant])

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pourquoi avoir ajouté cette ligne ?

@@ -33,7 +34,11 @@ def formula_2017_01_01(famille, mois_demande, parameters, mois_courant):
(not_(enfant_i) + rsa_enfant_a_charge_i) * ressources_individuelles_i
)


with open('test_1.txt', 'w') as test_file:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

La présence de ce bout de code est intéressante car elle révèle des difficultés d'investigation avec le code OpenFisca.

Cela étant dit, il faudrait le supprimer.

@@ -580,7 +584,8 @@ def formula_2016_10(famille, mois_courant, parameters, mois_demande):

montant = rsa_socle - rsa_forfait_logement - rsa_base_ressources
montant = max_(montant, 0)

with open('test.txt', 'w') as file_test:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

La présence de ce bout de code est intéressante car elle révèle des difficultés d'investigation avec le code OpenFisca.

Cela étant dit, il faudrait le supprimer.

@mtifarine
Copy link
Contributor Author

Bonjour @guillett,
J'ai corrigé le code selon les remarques que vous avez faites :)

CHANGELOG.md Outdated
@@ -1,5 +1,14 @@
# Changelog

### 22.6.2 [#1050](https://github.com/openfisca/openfisca-france/pull/1058)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Le numéro de la PR est 1058 (et pas #1050).

montant = select([locataire, accedant], [montant_locataire, montant_accedants])

# Montant minimal de versement il s'applique sur l'ALS et l'ALF et non pas sur l'APL
montant = montant * (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Je pense qu'un test est nécessaire pour valider le comportement de cette formule. En effet, en l'état je pense que si statut_occupation_logement == TypesStatutOccupationLogement.locataire_hlm alors le résultat est toujours 0.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Il faudrait créer un fichier de test, par exemple tests/formulas/aides_logement_2018.yaml, avec:

- name: Montant d'aide au logement classique
  period: 2018-04
  relative_error_margin: 0.001
  input_variables:
    statut_occupation_logement: locataire_vide
    aide_logement_loyer_retenu: 400
    aide_logement_charges: 100
    aide_logement_participation_personnelle: 200
  output_variables:
    aide_logement_montant_brut_avant_degressivite: 300

- name: Conservation du montant minimal de versement pour les AL
  period: 2018-04
  relative_error_margin: 0.001
  input_variables:
    statut_occupation_logement: locataire_vide
    aide_logement_loyer_retenu: 100
    aide_logement_charges: 0
    aide_logement_participation_personnelle: 95
  output_variables:
    aide_logement_montant_brut_avant_degressivite: 0

- name: Pris en compte de la suppression du montant minimal de versement des APL
  period: 2018-04
  relative_error_margin: 0.001
  input_variables:
    statut_occupation_logement: locataire_hlm
    aide_logement_loyer_retenu: 100
    aide_logement_charges: 0
    aide_logement_participation_personnelle: 95
  output_variables:
    aide_logement_montant_brut_avant_degressivite: 5

Sauf erreur de ma part, le troisième test est en erreur.

rls_apl = reduction_loyer_solidarite * taux_rls * (
statut_occupation_logement == TypesStatutOccupationLogement.locataire_hlm)
aide_logement_montant_brut_rls = max_(0, (aide_logement_montant_brut - rls_apl))
crds_logement = famille('crds_logement', period)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Je pense que cette valeur est incorrecte en cas de RLS. L'assiette de la CRDS doit prendre en compte la RLS.

L'ajustement de la RLS devrait être fait dans aide_logement_montant_brut voire plutôt dans une nouvelle variable par exemple aide_logement_montant_brut_crds qui servirait de base au calcul de crds_logement et donc de aide_logement_montant mais ça ne va pas plaire à @benjello (l'ajout d'une variable).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

statut_occupation_logement: locataire_foyer
output_variables:
aide_logement_montant_brut_avant_degressivite: 0
- name: 2- le montant de l'aide personnalisée au logement est inférieur au montant min de versement et type de logement est hlm
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Des sauts de ligne entre les tests en faciliteraient la lecture.

aide_logement_participation_personnelle: 0
statut_occupation_logement: locataire_hlm
output_variables:
aide_logement_montant_brut_avant_degressivite: 250
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Il manque un saut de ligne à la fin du fichier.

@mtifarine
Copy link
Contributor Author

mtifarine commented Aug 14, 2018

@guillett d’après toi c'est ça se que je dois faire

  • création d'une nouvelle variable:
class aide_logement_montant_brut_crds(Variable):
    value_type = float
    entity = Famille
    label = u"Montant des aides au logement net de RLS et CRDS"
    reference = u"https://www.legifrance.gouv.fr/eli/decret/2018/2/27/2018-136/jo/article_1"
    definition_period = MONTH

    def formula(famille, period, parameters):
        return famille('aide_logement_montant_brut', period)

    def formula_2018(famille, period, parameters):
        rls = parameters(period).prestations.reduction_loyer_solidarite
        aide_logement_montant_brut = famille('aide_logement_montant_brut', period)
        reduction_loyer_solidarite = famille('reduction_loyer_solidarite', period)
        statut_occupation_logement = famille.demandeur.menage('statut_occupation_logement', period)

        taux_rls = rls.fraction_baisse_aide_logement
        rls_apl = reduction_loyer_solidarite * taux_rls * (
                statut_occupation_logement == TypesStatutOccupationLogement.locataire_hlm)
        montant = max_(0, (aide_logement_montant_brut - rls_apl))
        return montant
  • modifie le calcul de cdrs_logement
class crds_logement(Variable):
    calculate_output = calculate_output_add
    value_type = float
    entity = Famille
    label = u"CRDS des allocations logement"
    reference = u"http://vosdroits.service-public.fr/particuliers/F17585.xhtml"
    definition_period = MONTH

    def formula(famille, period, parameters):
        aide_logement_montant_brut_crds = famille('aide_logement_montant_brut_crds', period)
        crds = parameters(period).prestations.prestations_familiales.af.crds
        return -aide_logement_montant_brut_crds * crds

@guillett
Copy link
Member

J'ai fait des modifications à ton commentaire (car il n'y avait pas le formattage Python qui rendait la lecture compliquée.

Je pense que la variable aide_logement_montant_brut_crds doit avoir 2 implémentations avant et après la mise en place de la RLS. (cf. ton commentaire que j'ai modifié)

class aide_logement_montant(Variable):
value_type = float
entity = Famille
label = u"Montant des aides au logement net de CRDS"
label = u"Montant des aides au logement net de RLS et CRDS"
reference = u"https://www.legifrance.gouv.fr/eli/decret/2018/2/27/2018-136/jo/article_1"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cette référence ne me parait pas pertinente pour cette variable.


def formula_2018(famille, period, parameters):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cette nouvelle formule ne me parait pas nécessaire si la formule de base est modifiée pour faire référence à aide_logement_montant_brut_crds à la place de aide_logement_montant_brut.

@@ -948,6 +1002,11 @@ class crds_logement(Variable):
reference = u"http://vosdroits.service-public.fr/particuliers/F17585.xhtml"
definition_period = MONTH

def formula_2018(famille, period, parameters):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Même remarque.

Cette nouvelle formule ne me parait pas nécessaire si la formule de base est modifiée pour faire référence à aide_logement_montant_brut_crds à la place de aide_logement_montant_brut.

@guillett guillett force-pushed the msa_rls branch 2 times, most recently from bd929e4 to 206a8f0 Compare August 17, 2018 09:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contrib:msa Identification des sujets MSA
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants