def test_revisions_to_fees(self): rentRevision1 = RentRevision(start_date=date(2011, 1, 1), end_date=date(2011, 3, 1), rent=200, provision=100) rentRevision2 = RentRevision(start_date=date(2011, 3, 1), end_date=date(2011, 5, 1), rent=300, provision=200) self.assertEqual( 0, sum([ f.amount for f in revisions_to_cashflows( date(1990, 1, 1), [rentRevision1, rentRevision2]) ])) self.assertEqual( -300, sum([ f.amount for f in revisions_to_cashflows( date(2011, 1, 15), [rentRevision1, rentRevision2]) ])) self.assertEqual( -1100, sum([ f.amount for f in revisions_to_cashflows( date(2011, 3, 15), [rentRevision1, rentRevision2]) ])) self.assertEqual( -1600, sum([ f.amount for f in revisions_to_cashflows( date(2011, 8, 15), [rentRevision1, rentRevision2]) ]))
def test_revisions_to_fees(self): rentRevision1 = RentRevision( start_date=date(2011, 1, 1), end_date=date(2011, 3, 1), rent=200, provision=100) rentRevision2 = RentRevision( start_date=date(2011, 3, 1), end_date=date(2011, 5, 1), rent=300, provision=200) self.assertEqual(0, sum([f.amount for f in revisions_to_cashflows( date(1990, 1, 1), [rentRevision1, rentRevision2])])) self.assertEqual(-300, sum([f.amount for f in revisions_to_cashflows( date(2011, 1, 15), [rentRevision1, rentRevision2])])) self.assertEqual(-1100, sum([f.amount for f in revisions_to_cashflows( date(2011, 3, 15), [rentRevision1, rentRevision2])])) self.assertEqual(-1600, sum([f.amount for f in revisions_to_cashflows( date(2011, 8, 15), [rentRevision1, rentRevision2])]))
def test_revisions_to_fees(self): rentRevision1 = RentRevision( start_date=date(2011, 1, 1), end_date=date(2011, 2, 28), rent=200, provision=100) rentRevision2 = RentRevision( start_date=date(2011, 3, 1), end_date=date(2011, 4, 30), rent=300, provision=200) self.assertEqual(0, sum([f.amount for f in revisions_to_cashflows( date(1990, 1, 1), [rentRevision1, rentRevision2])])) self.assertEqual(-300, sum([f.amount for f in revisions_to_cashflows( date(2011, 1, 15), [rentRevision1, rentRevision2])])) self.assertEqual(-1100, sum([f.amount for f in revisions_to_cashflows( date(2011, 3, 15), [rentRevision1, rentRevision2])])) self.assertEqual(-1600, sum([f.amount for f in revisions_to_cashflows( date(2011, 8, 15), [rentRevision1, rentRevision2])])) #partial_months-revisions rentRevision_partial_1 = RentRevision( start_date=date(2010, 11, 26), end_date=date(2011, 1, 25), rent=200.0, provision=100.0)# 591,935483871 fee rentRevision_partial_2 = RentRevision( start_date=date(2011, 1, 26), end_date=date(2011, 2, 6), rent=300.0, provision=200.0) #203,917050691 fee #sum fees = 795,852534562 self.assertEqual(-795.86, round(sum([f.amount for f in revisions_to_cashflows( date(2011, 2, 6), [rentRevision_partial_1,rentRevision_partial_2])]),2)) self.assertEqual(-591.94, sum([f.amount for f in revisions_to_cashflows( date(2011, 2, 6), [rentRevision_partial_1])]))