def testCharges(self): bi = Bien_Immo(50000, 0, 0, 0, 0) lot1 = Lot("T2", 50, 500) bi.add_lot(lot1) lot2 = Lot("T2", 50, 500) charge = Charge(lot2, None) charge.add(Charge.charge_e.copropriete, 51 * 12) charge.add(Charge.charge_e.prime_assurance, 90) charge.add(Charge.charge_e.vacance_locative, 1 / 12) charge.add(Charge.charge_e.agence_immo, 0.05) lot2.charge = charge bi.add_lot(lot2) self.assertEqual(bi.financement_total, 50000) self.assertEqual(bi.loyer_nu_brut_mensuel, 1000) self.assertEqual(bi.loyer_nu_brut_annuel, 12000) self.assertEqual(bi.loyer_nu_net_annuel, 11500) self.assertAlmostEqual(bi.loyer_nu_net_mensuel, 958.33, 2) self.assertEqual(bi.charges + bi.provisions, 1002) self.assertEqual(bi.get_charge(Charge.charge_e.taxe_fonciere), 0) self.assertEqual(bi.get_charge(Charge.charge_e.provision_travaux), 0) self.assertEqual(bi.get_charge(Charge.charge_e.vacance_locative), 500) self.assertEqual(bi.get_charge(Charge.charge_e.prime_assurance), 90) self.assertEqual(bi.get_charge(Charge.charge_e.agence_immo), 25 * 12) self.assertEqual(bi.get_charge(Charge.charge_e.copropriete), 51 * 12)
def make_bien_immo(achat_data, lots_data, defaut=Defaut(0, 0, 0, 0)): bien_immo = Bien_Immo(achat_data['prix_net_vendeur'], achat_data['frais_agence'], achat_data['frais_notaire'], achat_data['budget_travaux'], achat_data['apport']) for lot_data in lots_data: lot = Lot(lot_data['type'], lot_data['surface'], lot_data['loyer_nu_mensuel']) charges_data = lot_data['charges'] charge = Charge(lot, defaut) charge.add(Charge.charge_e.charge_locative, charges_data['provision_charge_mensuel']) charge.add(Charge.charge_e.copropriete, charges_data['copropriete']) charge.add(Charge.charge_e.taxe_fonciere, charges_data['taxe_fonciere']) charge.add(Charge.charge_e.prime_assurance, charges_data['PNO']) charge.add(Charge.charge_e.agence_immo, charges_data['agence_immo']) charge.add(Charge.charge_e.provision_travaux, charges_data['travaux_provision_taux']) charge.add(Charge.charge_e.vacance_locative, charges_data['vacance_locative_taux']) lot.charge = charge bien_immo.add_lot(lot) return bien_immo
def testBaseImpossable(self): bien_immo = Bien_Immo(0, 0, 0, 0, 0) lot = Lot("", 0, 500) bien_immo.add_lot(lot) irr = Annexe_2044(self._database, bien_immo, self.credit, 0) # Pas de charges self.assertAlmostEqual(irr.base_impossable, 6000) charge = Charge(lot) lot.charge = charge # Copropriete charge.add(charge.deductible_e.copropriete, 1000) self.assertAlmostEqual(irr.base_impossable, 5000) # Taxe fonciere charge.add(charge.deductible_e.copropriete, 800) self.assertAlmostEqual(irr.base_impossable, 4200) # PNO charge.add(charge.deductible_e.prime_assurance, 100) self.assertAlmostEqual(irr.base_impossable, 4100) # Autres charge.add(Charge.charge_e.provision_travaux, 0.01) charge.add(Charge.charge_e.vacance_locative, 1 / 12) self.assertAlmostEqual(irr.base_impossable, 4100) # Gestion agence locative charge.add(Charge.charge_e.agence_immo, 0.05) self.assertAlmostEqual(irr.base_impossable, 3800)
def testLoyerBrutMensuelTotal(self): bi = Bien_Immo(0, 0, 0, 0, 0) bi.add_lot(Lot("T2", 50, 500)) self.assertEqual(bi.loyer_nu_brut_mensuel, 500) bi.add_lot(Lot("T2", 50, 450)) self.assertEqual(bi.loyer_nu_brut_mensuel, 950)
def testLotCount(self): bi = Bien_Immo(130000, 0, 0, 0, 0) bi.add_lot(Lot("T2", 65, 0)) self.assertEqual(bi.lot_count, 1) bi.add_lot(Lot("T1", 30, 0)) bi.add_lot(Lot("T2", 50, 0)) self.assertEqual(bi.lot_count, 3)
def testSurfacePrix(self): bi = Bien_Immo(130000, 0, 0, 0, 0) bi.add_lot(Lot("T2", 65, 0)) self.assertEqual(bi.rapport_surface_prix, 2000) bi = Bien_Immo(130000, 0, 0, 0, 0) bi.add_lot(Lot("T2", 0, 0)) self.assertEqual(bi.rapport_surface_prix, 0)
def testLoyerNetMensuel(self): lot = Lot('T1', 30, 360) self.assertEqual(lot.loyer_nu_net_mensuel, 360) charge = Charge(lot, self.defaut) charge.add(Charge.charge_e.vacance_locative, 1) lot.charge = charge self.assertEqual(lot.loyer_nu_net_mensuel, 330.12)
def testImpotTotal(self): bien_immo = Bien_Immo(0, 0, 0, 0, 0) lot = Lot("", 0, 500) bien_immo.add_lot(lot) charge = Charge(lot) lot.charge = charge irr = Annexe_2044(self._database, bien_immo, self.credit, 0.11) self.assertAlmostEqual(irr.impot_total, 1032 + 660) charge.add(charge.deductible_e.copropriete, 1000) self.assertAlmostEqual(irr.impot_total, 860 + 550)
def testPrelevementSociaux(self): bien_immo = Bien_Immo(0, 0, 0, 0, 0) lot = Lot("", 0, 500) bien_immo.add_lot(lot) charge = Charge(lot) lot.charge = charge irr = Annexe_2044(self._database, bien_immo, self.credit, 0.11) self.assertAlmostEqual(irr.prelevement_sociaux_montant, 1032) charge.add(charge.deductible_e.copropriete, 1000) self.assertAlmostEqual(irr.prelevement_sociaux_montant, 860)
def testRevenuFoncierImpossableA(self): bien_immo = Bien_Immo(0, 0, 0, 0, 0) lot = Lot("", 0, 500) bien_immo.add_lot(lot) charge = Charge(lot) lot.charge = charge irr = Annexe_2044(self._database, bien_immo, self.credit, 0) self.assertAlmostEqual(irr.revenu_foncier_impossable, 0) irr = Annexe_2044(self._database, bien_immo, self.credit, 0.11) self.assertAlmostEqual(irr.revenu_foncier_impossable, 660) charge.add(charge.deductible_e.copropriete, 1000) self.assertAlmostEqual(irr.revenu_foncier_impossable, 550)
def testAddMissingDefaut(self): lot = Lot('T2', 45, 500) charge = Charge(lot, self.defaut) type_ = Charge.charge_e.copropriete with self.assertRaises(LookupError): charge.add(type_, 1)
def testAdd0(self): lot = Lot('T2', 45, 450) charge = Charge(lot) type_ = Charge.charge_e.taxe_fonciere charge.add(type_, 0) self.assertEqual(charge.get_montant_annuel(type_), 0)
def testAddVacanceLocative0(self): lot = Lot('T2', 45, 450) charge = Charge(lot) type_ = Charge.charge_e.vacance_locative charge.add(type_, 0) self.assertEqual(charge.get_montant_annuel(type_), 0)
def testRendementMethodeLarcher(self): bi = Bien_Immo(50000, 0, 0, 0, 0) bi.add_lot(Lot("T2", 50, 500)) rdt = Rendement(bi) self.assertEqual(rdt.rendement_methode_larcher, 0.09) bi = Bien_Immo(0, 0, 0, 0, 0) rdt = Rendement(bi) self.assertEqual(rdt.rendement_methode_larcher, 0)
def testRendementBrut(self): bi = Bien_Immo(50000, 0, 0, 0, 0) bi.add_lot(Lot("T2", 50, 500)) rdt = Rendement(bi) self.assertEqual(rdt.rendement_brut, 0.12) bi = Bien_Immo(0, 0, 0, 0, 0) rdt = Rendement(bi) self.assertEqual(rdt.rendement_brut, 0)
def testAddTravauxProvision(self): '''default''' lot = Lot('T2', 45, 500) charge = Charge(lot, self.defaut) type_ = Charge.charge_e.provision_travaux charge.add(type_, 1) self.assertEqual(charge.get_taux(type_), 0.01) self.assertEqual(charge.get_montant_annuel(type_), 60)
def testRendementNet(self): bi = Bien_Immo(0, 0, 0, 0, 0) rdt = Rendement(bi) self.assertEqual(rdt.rendement_net, 0) bi = Bien_Immo(50000, 0, 0, 0, 0) bi.add_lot(Lot("T2", 50, 500)) rdt = Rendement(bi) self.assertEqual(rdt.rendement_net, 0.12) lot = Lot("T2", 50, 500) charge = Charge(lot, None) charge.add(Charge.charge_e.copropriete, 51 * 12) charge.add(Charge.charge_e.prime_assurance, 90) charge.add(Charge.charge_e.vacance_locative, 1 / 12) charge.add(Charge.charge_e.agence_immo, 0.05) lot.charge = charge bi.add_lot(lot) self.assertAlmostEqual(bi.charges + bi.provisions, 1002, 2) self.assertAlmostEqual(rdt.rendement_net, 0.21, 2)
def testCashflow(self): bi = Bien_Immo(50000, 0, 0, 0, 0) lot1 = Lot("T2", 50, 500) bi.add_lot(lot1) cr = Credit(50000, 240, 0.02, Credit.taux_e.periodique, 0, Credit.mode_e.fixe_CI, 0, 0) rdt = Rendement(bi, cr) self.assertAlmostEqual(rdt.cashflow_net_mensuel, 247.06, 2) lot2 = Lot("T2", 50, 500) charge = Charge(lot2, None) charge.add(Charge.charge_e.copropriete, 51 * 12) charge.add(Charge.charge_e.prime_assurance, 90) charge.add(Charge.charge_e.vacance_locative, 1 / 12) charge.add(Charge.charge_e.agence_immo, 0.05) lot2.charge = charge bi.add_lot(lot2) self.assertAlmostEqual(bi.loyer_nu_brut_annuel, 12000, 2) self.assertAlmostEqual(bi.charges + bi.provisions, 1002, 2) self.assertAlmostEqual(cr.get_mensualite_avec_assurance(), 252.94, 2) self.assertAlmostEqual(rdt.cashflow_net_mensuel, 621.89, 2) self.assertAlmostEqual(rdt.cashflow_net_annuel, 7462.70, 2)
def testSurfaceTotal(self): bi = Bien_Immo(0, 0, 0, 0, 0) bi.add_lot(Lot("T2", 65, 0)) bi.add_lot(Lot("T2", 51, 0)) self.assertEqual(bi.surface_total, 116)
def testInit(self): _ = Lot('T1', 30, 350)
def testLoyerBrutAnnuelTotal(self): bi = Bien_Immo(0, 0, 0, 0, 0) bi.add_lot(Lot("T2", 50, 200)) bi.add_lot(Lot("T2", 50, 300)) self.assertEqual(bi.loyer_nu_brut_annuel, 500 * 12)
def testAddVacanceLocative1B(self): lot = Lot('T2', 45, 450) charge = Charge(lot, self.defaut) type_ = Charge.charge_e.vacance_locative charge.add(type_, 1)