Ejemplo 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)
Ejemplo n.º 3
0
    def test01_FixeCI1(self):
        cred = Credit(10000, 36, 0.02, Credit.taux_e.periodique, 0, Credit.mode_e.fixe_CI, 0, 0)

        self.assertAlmostEqual(cred.capital, 10000, 2)
        self.assertAlmostEqual(cred.get_amortissement(), 269.76, 2)
        self.assertAlmostEqual(cred.get_interet(), 16.67, 2)
        self.assertAlmostEqual(cred.get_mensualite_assurance(), 0, 2)
        self.assertAlmostEqual(cred.get_mensualite_avec_assurance(), 286.43, 2)

        start = 36
        self.assertAlmostEqual(cred.get_amortissement(start), 285.95, 2)
        self.assertAlmostEqual(cred.get_interet(start), 0.48, 2)
        self.assertAlmostEqual(cred.get_mensualite_assurance(start), 0, 2)
        self.assertAlmostEqual(cred.get_mensualite_avec_assurance(start), 286.43, 2)
Ejemplo n.º 4
0
class TestCredit_FixeCRD(unittest.TestCase):
    def setUp(self):

        self.credit = Credit(50000, 240, 0.0115, Credit.taux_e.periodique,
                             0.0026, Credit.mode_e.fixe_CRD, 0, 0)

    def testTotal(self):
        self.assertAlmostEqual(self.credit.get_montant_interet_total(),
                               6043.69, 2)
        self.assertAlmostEqual(self.credit.get_montant_assurance_total(),
                               1366.40, 2)
        self.assertAlmostEqual(self.credit.get_amortissement_total(), 50000, 2)
        self.assertAlmostEqual(
            self.credit.get_mensualite_hors_assurance_total(), 56043.69, 2)
        self.assertAlmostEqual(
            self.credit.get_mensualite_avec_assurance_total(), 57410.09, 2)
        self.assertAlmostEqual(self.credit.get_cout_total(), 7410.09, 2)

    def testRangeNone(self):
        self.assertAlmostEqual(self.credit.get_amortissement(), 180.46, 2)
        self.assertAlmostEqual(self.credit.get_interet(), 47.92, 2)
        self.assertAlmostEqual(self.credit.get_mensualite_assurance(), 10.83,
                               2)
        self.assertAlmostEqual(self.credit.get_mensualite_hors_assurance(),
                               228.38, 2)
        self.assertAlmostEqual(self.credit.get_mensualite_avec_assurance(),
                               239.21, 2)

    def testRange1(self):
        self.assertAlmostEqual(self.credit.get_amortissement(1), 180.46, 2)
        self.assertAlmostEqual(self.credit.get_interet(1), 47.92, 2)
        self.assertAlmostEqual(self.credit.get_mensualite_assurance(1), 10.83,
                               2)
        self.assertAlmostEqual(self.credit.get_mensualite_hors_assurance(1),
                               228.38, 2)
        self.assertAlmostEqual(self.credit.get_mensualite_avec_assurance(1),
                               239.21, 2)

    def testRange2(self):
        start = 2
        self.assertAlmostEqual(self.credit.get_amortissement(start), 180.67, 2)
        self.assertAlmostEqual(self.credit.get_interet(start), 47.74, 2)
        self.assertAlmostEqual(self.credit.get_mensualite_assurance(start),
                               10.79, 2)
        self.assertAlmostEqual(
            self.credit.get_mensualite_hors_assurance(start), 228.41, 2)
        self.assertAlmostEqual(
            self.credit.get_mensualite_avec_assurance(start), 239.21, 2)

    def testRange12(self):
        start = 12
        self.assertAlmostEqual(self.credit.get_amortissement(start), 182.80, 2)
        self.assertAlmostEqual(self.credit.get_interet(start), 46, 2)
        self.assertAlmostEqual(self.credit.get_mensualite_assurance(start),
                               10.40, 2)
        self.assertAlmostEqual(
            self.credit.get_mensualite_hors_assurance(start), 228.81, 2)
        self.assertAlmostEqual(
            self.credit.get_mensualite_avec_assurance(start), 239.21, 2)

    def testRange228(self):
        start = 228
        self.assertAlmostEqual(self.credit.get_amortissement(start), 235.58, 2)
        self.assertAlmostEqual(self.credit.get_interet(start), 2.96, 2)
        self.assertAlmostEqual(self.credit.get_mensualite_assurance(start),
                               0.67, 2)
        self.assertAlmostEqual(
            self.credit.get_mensualite_hors_assurance(start), 238.54, 2)
        self.assertAlmostEqual(
            self.credit.get_mensualite_avec_assurance(start), 239.21, 2)

    def testRange240(self):
        start = 240
        self.assertAlmostEqual(self.credit.get_amortissement(start), 238.93, 2)
        self.assertAlmostEqual(self.credit.get_interet(start), 0.23, 2)
        self.assertAlmostEqual(self.credit.get_mensualite_assurance(start),
                               0.05, 2)
        self.assertAlmostEqual(
            self.credit.get_mensualite_hors_assurance(start), 239.16, 2)
        self.assertAlmostEqual(
            self.credit.get_mensualite_avec_assurance(start), 239.21, 2)

    def testRange1_2(self):
        start = 1
        stop = 2
        self.assertAlmostEqual(self.credit.get_amortissement(start, stop),
                               180.46 + 180.67, 2)
        self.assertAlmostEqual(self.credit.get_interet(start, stop),
                               47.92 + 47.74, 2)
        self.assertAlmostEqual(
            self.credit.get_mensualite_assurance(start, stop), 10.83 + 10.80,
            2)
        self.assertAlmostEqual(
            self.credit.get_mensualite_hors_assurance(start, stop),
            228.38 + 228.41, 2)
        self.assertAlmostEqual(
            self.credit.get_mensualite_avec_assurance(start, stop),
            239.21 + 239.21, 2)

    def testRange1_240(self):
        start = 1
        stop = 240
        self.assertAlmostEqual(self.credit.get_amortissement(start, stop),
                               50000, 2)
        self.assertAlmostEqual(self.credit.get_interet(start, stop), 6043.69,
                               2)
        self.assertAlmostEqual(
            self.credit.get_mensualite_assurance(start, stop), 1366.40, 2)
        self.assertAlmostEqual(
            self.credit.get_mensualite_hors_assurance(start, stop), 56043.69,
            2)
        self.assertAlmostEqual(
            self.credit.get_mensualite_avec_assurance(start, stop), 57410.09,
            2)