Esempio n. 1
0
    def test03_FixeCRD(self):
        cred = Credit(10000, 36, 0.02, Credit.taux_e.periodique, 0.0030, Credit.mode_e.fixe_CRD, 0, 0)

        start = 1
        self.assertAlmostEqual(cred.get_capital_restant(start), 9731.43, 2)
        self.assertAlmostEqual(cred.get_amortissement(start), 268.57, 2)
        self.assertAlmostEqual(cred.get_interet(start), 16.67, 2)
        self.assertAlmostEqual(cred.get_mensualite_assurance(start), 2.50, 2)
        self.assertAlmostEqual(cred.get_mensualite_hors_assurance(start), 285.24, 2)
        self.assertAlmostEqual(cred.get_mensualite_avec_assurance(start), 287.74, 2)

        start = 2
        self.assertAlmostEqual(cred.get_capital_restant(start), 9462.34, 2)
        self.assertAlmostEqual(cred.get_amortissement(start), 269.09, 2)
        self.assertAlmostEqual(cred.get_interet(start), 16.22, 2)
        self.assertAlmostEqual(cred.get_mensualite_assurance(start), 2.43, 2)
        self.assertAlmostEqual(cred.get_mensualite_hors_assurance(start), 285.30, 2)
        self.assertAlmostEqual(cred.get_mensualite_avec_assurance(start), 287.74, 2)

        start = 36
        self.assertAlmostEqual(cred.get_amortissement(start), 287.19, 2)  # 268.5706
        self.assertAlmostEqual(cred.get_interet(start), 0.48, 2)
        self.assertAlmostEqual(cred.get_mensualite_assurance(start), 0.07, 2)
        self.assertAlmostEqual(cred.get_mensualite_avec_assurance(start), 287.74, 2)

        self.assertAlmostEqual(cred.get_amortissement_total(), 10000, 2)
        self.assertAlmostEqual(cred.get_montant_interet_total(), 311.78, 2)
        self.assertAlmostEqual(cred.get_montant_assurance_total(), 46.77, 2)
        self.assertAlmostEqual(cred.get_mensualite_hors_assurance_total(), 10311.78, 2)
        self.assertAlmostEqual(cred.get_mensualite_avec_assurance_total(), 10358.54, 2)
    def testExemple2(self):
        '''
        www.lacentraledefinancement.fr
        '''

        credit = Credit(10000, 60, 0.01, Credit.taux_e.periodique, 0.0020, Credit.mode_e.fixe_CRD, 0, 0)

#         self.assertAlmostEqual(credit.get_montant_interet_total(), 308, 0)
#         self.assertAlmostEqual(credit.get_montant_assurance_total(), 100, 0)
        self.assertAlmostEqual(credit.get_cout_total(), 308, 2)

        mois = 1
        self.assertAlmostEqual(credit.get_capital_restant(mois), 9838.20, 2)
        self.assertAlmostEqual(credit.get_amortissement(mois), 161.80, 2)
        self.assertAlmostEqual(credit.get_interet(mois), 8.33, 2)
        self.assertAlmostEqual(credit.get_mensualite_assurance(mois), 1.67, 2)
        self.assertAlmostEqual(credit.get_mensualite_hors_assurance(mois), 170.13, 2)
        self.assertAlmostEqual(credit.get_mensualite_avec_assurance(mois), 171.80, 2)

        mois = 2
        self.assertAlmostEqual(credit.get_capital_restant(mois), 9676.24, 2)
        self.assertAlmostEqual(credit.get_amortissement(mois), 161.96, 2)
        self.assertAlmostEqual(credit.get_interet(mois), 8.20, 2)
        self.assertAlmostEqual(credit.get_mensualite_assurance(mois), 1.64, 2)
        self.assertAlmostEqual(credit.get_mensualite_hors_assurance(mois), 170.16, 2)
        self.assertAlmostEqual(credit.get_mensualite_avec_assurance(mois), 171.80, 2)

        mois = 13
        self.assertAlmostEqual(credit.get_capital_restant(mois), 7883.93, 2)
        self.assertAlmostEqual(credit.get_amortissement(mois), 163.75, 2)
        self.assertAlmostEqual(credit.get_interet(mois), 6.71, 2)
        self.assertAlmostEqual(credit.get_mensualite_assurance(mois), 1.34, 2)
        self.assertAlmostEqual(credit.get_mensualite_hors_assurance(mois), 170.46, 2)
        self.assertAlmostEqual(credit.get_mensualite_avec_assurance(mois), 171.80, 2)