示例#1
0
    def setUp(self):
        active_client = ActiveClientFactory(
            birthday=datetime.datetime(1967, 1, 1))
        financial_planning = FinancialPlanningFactory(
            cdi=0.1213, ipca=0.075, active_client=active_client)
        self.protection_manager = ProtectionManagerFactory(
            financial_planning=financial_planning)
        self.protection_manager.private_pensions.all().update(
            value=20000, annual_investment=2000)
        for life_insurance in self.protection_manager.life_insurances.all():
            life_insurance.delete()

        for private_pension in self.protection_manager.private_pensions.all():
            private_pension.delete()

        life_insurances = [
            {'value_to_pay_annual': 2000, 'has_year_end': False},
            {'value_to_pay_annual': 2000, 'has_year_end': True,
                'year_end': 2020, },
            {'value_to_pay_annual': 1000, 'has_year_end': True,
                'year_end': 2023, }]

        for life_insurance in life_insurances:
            LifeInsuranceFactory(**life_insurance,
                                 protection_manager=self.protection_manager)

        private_pensions = [
            {'annual_investment': 5000}, {'annual_investment': 3000},
            {'annual_investment': 2000}, {'annual_investment': 8000},
        ]

        for private_pension in private_pensions:
            PrivatePensionFactory(protection_manager=self.protection_manager,
                                  **private_pension)
示例#2
0
 def setUp(self):
     active_client = ActiveClientFactory(
         birthday=datetime.datetime(1977, 1, 1))
     financial_planning = FinancialPlanningFactory(
         active_client=active_client)
     self.goal_manager = financial_planning.goal_manager
     goal_type1 = GoalTypeFactory(name='Imóvel')
     goal_type2 = GoalTypeFactory(name='Vestuário')
     self.goal_hasnt_end_date = GoalFactory(has_end_date=False,
                                            goal_type=goal_type1,
                                            init_year=2021,
                                            periodicity=3,
                                            value=50000,
                                            goal_manager=self.goal_manager)
     self.goal_has_end_date = GoalFactory(has_end_date=True,
                                          goal_type=goal_type2,
                                          init_year=2021,
                                          periodicity=3,
                                          value=50000,
                                          end_year=2031,
                                          goal_manager=self.goal_manager)
     self.array_flow_without_date = [
         0, 0, 0, 0, 50000, 0, 0, 50000, 0, 0, 50000, 0, 0, 50000, 0, 0,
         50000, 0, 0, 50000
     ]
     self.array_flow_with_date = [
         0, 0, 0, 0, 50000, 0, 0, 50000, 0, 0, 50000, 0, 0, 50000, 0, 0, 0,
         0, 0, 0
     ]
示例#3
0
    def setUp(self):
        self.cost_manager = CostManagerFactory()
        active_client = ActiveClientFactory(
            birthday=datetime.datetime(1967, 1, 1))
        self.patrimony = PatrimonyFactory()
        self.patrimony.incomes.all().update(value_monthly=55000,
                                            thirteenth=False,
                                            vacation=False)

        for active in self.patrimony.activemanager.actives.all():
            active.delete()

        data = [{
            'value': 30000.00,
            'rate': 1.1879
        }, {
            'value': 321200.00,
            'rate': 0.7500
        }, {
            'value': 351200.00,
            'rate': 0.7500
        }]

        for active in data:
            ActiveFactory(**active,
                          active_manager=self.patrimony.activemanager)

        ArrearageFactory(patrimony=self.patrimony, value=351200.00)
        self.goal_manager = GoalManagerFactory()
        GoalFactory.create_batch(4,
                                 goal_manager=self.goal_manager,
                                 init_year=2017,
                                 end_year=2027,
                                 value=2500,
                                 periodicity=1)
        self.financial_independence = FinancialIndependenceFactory(
            duration_of_usufruct=35,
            remain_patrimony=30000,
        )
        self.financial_planning = FinancialPlanningFactory(
            active_client=active_client,
            cost_manager=self.cost_manager,
            patrimony=self.patrimony,
            financial_independence=self.financial_independence,
            goal_manager=self.goal_manager,
            cdi=0.1213,
        )
        protection_manager = ProtectionManagerFactory(
            financial_planning=self.financial_planning)

        for private_pension in protection_manager.private_pensions.all():
            private_pension.delete()

        for life_insurance in protection_manager.life_insurances.all():
            life_insurance.delete()

        LifeInsuranceFactory(protection_manager=protection_manager,
                             value_to_pay_annual=2000,
                             has_year_end=False)
示例#4
0
 def setUp(self):
     self.cost_manager = CostManagerFactory()
     active_client = ActiveClientFactory(
         birthday=datetime.datetime(1967, 1, 1))
     self.financial_planning = FinancialPlanningFactory(
         active_client=active_client,
         cost_manager=self.cost_manager,
     )
示例#5
0
 def setUp(self):
     active_client = ActiveClientFactory(
         birthday=datetime.datetime(1967, 1, 1))
     self.financial_planning = FinancialPlanningFactory(
         active_client=active_client,
         target_profitability=1.10,
         cdi=0.1213,
         ipca=0.075)
示例#6
0
 def setUp(self):
     self.financial_independence = FinancialIndependenceFactory(
         duration_of_usufruct=35,
         remain_patrimony=30000,
     )
     active_client = ActiveClientFactory(
         birthday=datetime.datetime(1967, 1, 1))
     self.financial_planning = FinancialPlanningFactory(
         active_client=active_client,
         financial_independence=self.financial_independence,
     )
示例#7
0
    def setUp(self):
        self.employee = EmployeeMainFactory()
        self.financial_adviser = FinancialAdviserMainFactory()
        self.active_client = ActiveClientFactory()
        self.client_test = ClientTest()

        jwt_payload_handler = api_settings.JWT_PAYLOAD_HANDLER
        jwt_encode_handler = api_settings.JWT_ENCODE_HANDLER

        payload = jwt_payload_handler(self.employee)
        self.token = jwt_encode_handler(payload)
示例#8
0
    def test_get_related_many(self):
        second_client = ActiveClientFactory()

        self.financial_adviser.clients.add(self.active_client, second_client)

        relationship = Relationship(self.financial_adviser,
                                    related_name='clients')

        related = relationship.get_related()

        self.assertEqual(related, second_client)
示例#9
0
    def setUp(self):
        active_client = ActiveClientFactory(
            birthday=datetime.datetime(1967, 1, 1))
        financial_planning = FinancialPlanningFactory(
            active_client=active_client)
        goal_manager = financial_planning.goal_manager
        self.financial_independence = financial_planning.financial_independence
        self.financial_independence.rate = 0.02

        goals_type = [{
            'name': 'Casa Extra'
        }, {
            'name': 'Compra De Cotas Societárias'
        }, {
            'name': 'Moradia'
        }, {
            'name': 'Reforma e Manutenção Da Casa'
        }, {
            'name': 'Viagens'
        }]

        data_goal_type = []
        for goal_type in goals_type:
            data_goal_type.append(GoalTypeFactory(**goal_type))

        goals = [{
            'value': 200000,
            'init_year': 2018,
            'end_year': 2018
        }, {
            'value': 500000,
            'init_year': 2022,
            'end_year': 2022
        }, {
            'value': 1000000,
            'init_year': 2021,
            'end_year': 2021
        }, {
            'value': 140000,
            'init_year': 2025,
            'end_year': 2025
        }, {
            'value': 50000,
            'init_year': 2023,
            'end_year': 2023
        }]

        self.data_goals = []
        for goal_type, goal in zip(data_goal_type, goals):
            self.data_goals.append(
                GoalFactory(**goal,
                            goal_type=goal_type,
                            goal_manager=goal_manager))
示例#10
0
    def setUp(self):
        active_client = ActiveClientFactory(
            birthday=datetime.datetime(1967, 1, 1))
        financial_planning = FinancialPlanningFactory(
            active_client=active_client, ipca=0.075)
        protection_manager = ProtectionManagerFactory(
            financial_planning=financial_planning)
        reserve_in_lack = _create_reserve_in_lack()
        protection_manager = reserve_in_lack.protection_manager
        protection_manager.financial_planning = financial_planning

        for private_pension in protection_manager.private_pensions.all():
            private_pension.delete()

        for life_insurance in protection_manager.life_insurances.all():
            life_insurance.delete()

        private_pensions = [
            {'value': 20000, 'annual_investment': 2000, 'rate': 0.1213},
            {'value': 4000, 'annual_investment': 200, 'rate': 0.09},
            {'value': 4000, 'annual_investment': 200, 'rate': 0.09},
        ]

        self.private_pensions_array = []

        for private_pension in private_pensions:
            element = PrivatePensionFactory(
                **private_pension, protection_manager=protection_manager)
            self.private_pensions_array.append(element)

        life_insurances = [
            {'value_to_pay_annual': 2000, 'value_to_recive': 500000,
                'actual': True},
            {'value_to_pay_annual': 2000, 'value_to_recive': 200000,
                'actual': False},
            {'value_to_pay_annual': 1000, 'value_to_recive': 300000,
                'actual': True},
            {'value_to_pay_annual': 1000, 'value_to_recive': 300000,
                'actual': True},
        ]

        for life_insurance in life_insurances:
            LifeInsuranceFactory(**life_insurance,
                                 protection_manager=protection_manager)

        self.future_patrimony_succession =\
            protection_manager.future_patrimony_succession
        self.future_patrimony_succession.itcmd_tax = 0.06
        self.future_patrimony_succession.oab_tax = 0.05
        self.future_patrimony_succession.other_taxes = 0.02
        self.protection_manager = protection_manager
示例#11
0
    def test_get_related_many_wrong_pk(self):
        second_client = ActiveClientFactory()

        self.financial_adviser.clients.add(self.active_client, second_client)

        wrong_pk = 12312312
        relationship = Relationship(self.financial_adviser,
                                    related_name='clients',
                                    pk=wrong_pk)

        with self.assertRaisesMessage(
                ObjectDoesNotExist, "Was not possible to get the object"
                " indicated by the information passed."
                " 'pk' not found."):
            relationship.get_related()
示例#12
0
    def test_not_save_active_client_with_repeated_cpf(self):
        active_client = ActiveClientFactory()
        active_client = ActiveClient.objects.last()

        active_client2 = ActiveClientFactory()
        active_client2 = ActiveClient.objects.last()
        active_client2.cpf = active_client.cpf

        with self.assertRaises(ValidationError):
            active_client2.save()
示例#13
0
 def setUp(self):
     active_client = ActiveClientFactory(
         birthday=datetime.datetime(1967, 1, 1))
     self.patrimony = PatrimonyFactory()
     self.patrimony.incomes.all().update(value_monthly=1212.2)
     FinancialPlanningFactory(active_client=active_client,
                              patrimony=self.patrimony)
     self.common_income = IncomeFactory(value_monthly=1200,
                                        thirteenth=False,
                                        patrimony=self.patrimony,
                                        vacation=False)
     self.income_with_thirteenth = IncomeFactory(value_monthly=1200.00,
                                                 thirteenth=True,
                                                 patrimony=self.patrimony,
                                                 vacation=False)
     self.income_with_vacation = IncomeFactory(value_monthly=1200,
                                               thirteenth=False,
                                               patrimony=self.patrimony,
                                               vacation=True)
     ArrearageFactory(patrimony=self.patrimony, value=351200.00, period=3)
     RealEstateFactory(patrimony=self.patrimony, salable=True)
示例#14
0
 def setUp(self):
     self.active_client = ActiveClientFactory()
     self.user = User.objects.last()
示例#15
0
 def test_not_save_active_client_with_account_number_wrong(self):
     self.active_client = ActiveClientFactory()
     bank_account = BankAccount.objects.last()
     bank_account.account = "1212-1"
     with self.assertRaises(ValidationError):
         bank_account.save()
示例#16
0
 def setUp(self):
     self.active_client = ActiveClientFactory()
     self.financial_planning = FinancialPlanningFactory()
     self.financial_adviser = FinancialAdviserFactory()
     self.patrimony = PatrimonyFactory()
示例#17
0
 def test_not_save_active_client_with_phone_number_wrong(self):
     self.active_client = ActiveClientFactory()
     active_client = ActiveClient.objects.last()
     active_client.telephone = "9999-9999"
     with self.assertRaises(ValidationError):
         active_client.save()
示例#18
0
 def test_not_save_active_client_with_cpf_wrong(self):
     self.active_client = ActiveClientFactory()
     active_client = ActiveClient.objects.last()
     active_client.cpf = "12345678901"
     with self.assertRaises(ValidationError):
         active_client.save()
示例#19
0
 def test_save_active_client_with_cpf_right(self):
     self.active_client = ActiveClientFactory()
     active_client = ActiveClient.objects.last()
     active_client.cpf = "85726391012"
     active_client.save()
     self.assertEqual(ActiveClient.objects.last(), active_client)
示例#20
0
 def setUp(self):
     self.active_client = ActiveClientFactory.build()
     self.client = ClientFactory.build()
示例#21
0
 def test_save_active_client_with_phone_number_right(self):
     self.active_client = ActiveClientFactory()
     active_client = ActiveClient.objects.last()
     active_client.telephone = "(61) 9999-9999"
     active_client.save()
     self.assertEqual(ActiveClient.objects.last(), active_client)
示例#22
0
 def test_save_active_client_with_account_number_right(self):
     self.active_client = ActiveClientFactory()
     bank_account = BankAccount.objects.last()
     bank_account.account = "12121-1"
     bank_account.save()
     self.assertEqual(BankAccount.objects.last(), bank_account)