예제 #1
0
 def create_couple(self, sal_chef, sal_part, housing = None):
     '''
     Creates the united couples with and without children
     
     Parameters
     ----------
     sal_chef : float
                Salary of the non custodian parent
     sal_part : float
                Salary of the custodian parent
     '''
      
     scenario = self.scenario
     scenario_seuls = self.scenario_seuls
     
     scenario.addIndiv(1, datetime.strptime("1975-01-01" ,"%Y-%m-%d").date(), "conj", "part")
     scenario_seuls.addIndiv(1, datetime.strptime("1975-01-01" ,"%Y-%m-%d").date(), "conj", "part")
         
     for noi, child in self.children.iteritems():
         scenario.addIndiv(noi, child['birth'], "pac", "enf" )  
     
     scenario.indiv[0].update({ 'sali': sal_chef })
     scenario_seuls.indiv[0].update({ 'sali': sal_chef })
     if sal_chef >= 1072*12:  # TODO: for 2011
         scenario.indiv[0].update({"ppe_tp_sa":True})
         scenario_seuls.indiv[0].update({"ppe_tp_sa":True})
     else:
         duree = round(1607*sal_chef/(1072*12))
         scenario.indiv[0].update({"ppe_du_sa": duree })   # 1607h fonction publique
         scenario_seuls.indiv[0].update({"ppe_du_sa": duree})
     
     scenario.indiv[1].update({ 'sali': sal_part})
     scenario_seuls.indiv[1].update({ 'sali': sal_part})
     if sal_part >= 1072*12:  # TODO: for 2011
         scenario.indiv[1].update({"ppe_tp_sa":True})
         scenario_seuls.indiv[1].update({"ppe_tp_sa":True})
     else:
         duree = round(1607*sal_part/(1072*12))
         scenario.indiv[1].update({"ppe_du_sa": duree })   # 1607h fonction publique
         scenario_seuls.indiv[1].update({"ppe_du_sa": duree})
     
     if housing is None:
         scenario.menage[0].update({'loyer' : get_loyer(scenario)})
         scenario_seuls.menage[0].update({'loyer' : get_loyer(scenario_seuls)})
     else:
         for key, val in housing.iteritems:
             scenario.menage[0].update({key: val})
             scenario_seuls.menage[0].update({key: val})
예제 #2
0
    def break_union(self, housing_custodian = None, housing_non_custodian = None):
        """
        Break union
        
        Parameters
        ----------
        
        housing_custodian     : dict
                             housing parameters for the custodian parent
        housing_non_custodian : dict
                             housing parameters for the non-custodian parent
        """

        scenario = self.scenario
        scenario_chef = self.Scenario()
        scenario_part = self.Scenario()
        scenario_chef_seul = self.Scenario()
        scenario_part_seul = self.Scenario()
        
        scenario_chef.year = self.datesim.year

        for scenar in [ self.scenario_seuls, scenario_chef, scenario_part, 
                         scenario_chef_seul, scenario_part_seul ]:
            scenar.year = self.datesim.year
            scenar.nmen = 1


        sal_chef = scenario.indiv[0]['sali']   # TODO: Should be more general

        scenario_chef.indiv[0].update({'sali': sal_chef })
        scenario_chef_seul.indiv[0].update({'sali': sal_chef })
        for variable in ["ppe_tp_sa", "ppe_du_sa"]:
            scenario_chef.indiv[0].update({variable: scenario.indiv[0][variable] })
            scenario_chef_seul.indiv[0].update({variable: scenario.indiv[0][variable] })

        sal_part = scenario.indiv[1]['sali']   # Could be more general
        scenario_part.indiv[0].update({'sali': sal_part })
        scenario_part_seul.indiv[0].update({'sali': sal_part })

        for variable in ["ppe_tp_sa", "ppe_du_sa"]:
            scenario_chef.indiv[0].update({variable: scenario.indiv[0][variable] })
            scenario_chef_seul.indiv[0].update({variable: scenario.indiv[0][variable] })
            scenario_part.indiv[0].update({variable: scenario.indiv[1][variable] })
            scenario_part_seul.indiv[0].update({variable: scenario.indiv[1][variable] })

        # TODO: get more infos from couple scenario

        noi_enf_part = 1 
        noi_enf_chef = 1
        alv_chef = 0
        alv_part = 0
        alr_chef = 0
        alr_part = 0
        
        for noi, val in self.children.iteritems(): 

            non_custodian = val['non_custodian']
            temps_garde = val['temps_garde']
            pension_alim = val['pension_alim']
            birth = scenario.indiv[noi]['birth']
            
            if temps_garde in ['classique', 'reduite']:

                if non_custodian == 'chef':
                    scenario_part.addIndiv(noi_enf_part, birth, 'pac', 'enf')
                    scenario_part.indiv[noi_enf_part].update({'quimen': 'enf'+str(noi_enf_part)})
                    noi_enf_part += 1
                    alv_chef += pension_alim
                    alr_part += pension_alim
                    scenario_part.declar[0]['caseT'] = True
                elif non_custodian == 'part':
                    scenario_chef.addIndiv(noi_enf_chef, birth, 'pac', 'enf') 
                    scenario_chef.indiv[noi_enf_part].update({'quimen': 'enf'+str(noi_enf_part)})
                    noi_enf_chef += 1
                    alv_part += pension_alim
                    alr_chef += pension_alim
                    scenario_chef.declar[0]['caseT'] = True
               
            elif temps_garde == 'alternee_pension_non_decl':# garde alternée fiscale = pas de pension alimentaire déclarée aux impots mais partage du QF
                scenario_part.addIndiv(noi_enf_part, birth, 'pac', 'enf')
                scenario_part.indiv[noi_enf_part].update({'alt': 1, 'quimen': 'enf'+str(noi_enf_part)})
                scenario_part.declar[0]['caseT'] = True
                noi_enf_part += 1

                scenario_chef.addIndiv(noi_enf_chef, birth, 'pac', 'enf')
                scenario_chef.indiv[noi_enf_chef].update({'alt': 1})
                scenario_chef.declar[0]['caseT'] = True
                noi_enf_chef += 1

                
            elif temps_garde == 'alternee_pension_decl':# TODO: garde alternée pas de pension alimentaire ?
                                            # garde alternée juridique ou pas

                if non_custodian == 'chef':
                    scenario_part.addIndiv(noi_enf_part, birth, 'pac', 'enf')
                    scenario_part.declar[0]['caseT'] = True
                    noi_enf_part += 1
                    alv_chef += pension_alim
                    alr_part += pension_alim
                elif non_custodian == 'part':
                    scenario_chef.addIndiv(noi_enf_chef, birth, 'pac', 'enf') 
                    scenario_chef.declar[0]['caseT'] = True
                    noi_enf_chef += 1
                    alv_part += pension_alim
                    alr_chef += pension_alim 
                    
            else:
                raise Exception('break_union: Error somewhere')
                
        # Updating pension alimentaire
        # Beware : received pension alim. are attributed for individuals
        #          paid pension alim. are "charges déductibes" on foyers' declarations  
        alv_net_chef = alv_chef - alr_chef
        if alv_net_chef >= 0:   
            scenario_chef.declar[0].update({'f6gu': alv_net_chef}) # TODO: pas forcément en 6gu 
            scenario_part.indiv[0].update({'alr': alv_net_chef})
        else:
            scenario_chef.indiv[0].update({'alr': -alv_net_chef})
            scenario_part.declar[0].update({'f6gu': -alv_net_chef})

        self.scenario_chef = scenario_chef
        self.scenario_part = scenario_part

        self.scenario_chef_seul = scenario_chef_seul
        self.scenario_part_seul = scenario_part_seul

        # Updating households
        
        pension_alim_tot = sum([ var['pension_alim'] for var in self.children.values()])


        for scenar in [ self.scenario, self.scenario_seuls, scenario_chef, scenario_part, 
                         scenario_chef_seul, scenario_part_seul ]:
            scenar.genNbEnf()

        if housing_non_custodian is None:
            housing_non_custodian = {'loyer': get_loyer(scenario_chef)}
            housing_non_custodian_seul = {'loyer': get_loyer(scenario_chef_seul) }

        for key, val in housing_non_custodian.iteritems():
            scenario_chef.menage[0].update({key: val}) 

        for key, val in housing_non_custodian_seul.iteritems():
            scenario_chef_seul.menage[0].update({key: val})


        if housing_custodian is None:
            housing_custodian = {'loyer': get_loyer(scenario_part)}
            housing_custodian_seul = {'loyer': get_loyer(scenario_part_seul)}

        for key, val in housing_custodian.iteritems():
            scenario_part.menage[0].update({key: val})
            
        for key, val in housing_custodian_seul.iteritems():
            scenario_part_seul.menage[0].update({key: val})