示例#1
0
 def test_amount(self):
     """
     amount should always be a decimal or None
     """
     e = Event()
     e.amount = None
     assert e.amount is None
     e.amount = 1
示例#2
0
 def test_amount(self):
     """
     amount should always be a fixedpoint or None
     """
     e = Event()
     e.amount = None
     assert e.amount is None # make sure no error trying FixedPoint(None)
     e.amount = 1
示例#3
0
 def test_amount(self):
     """
     amount should always be a decimal or None
     """
     e = Event()
     e.amount = None
     assert e.amount is None
     e.amount = 1
    def testVesting(self):
        "ensure charges are slowly 'earned' over time"
        e = Event(event="charge",
                  amount="50",
                  posted="1/1/2000",
                  maturity="11/1/2000")
        assert e.percentVested(e.posted) == 0
        assert e.percentVested(e.posted - 1) == 0
        assert e.percentVested(e.maturity) == 100
        assert e.percentVested(e.maturity + 1) == 100

        #@TODO: paramaterize number of decimal places ?

        # In a single month, we're fully vested at the end of the month.
        # With a yearly charge, the vesting happens slowly over time.
        d = Decimal
        self.assertEquals(e.percentVested(Date("2/1/2000")), d('10.16'))
        self.assertEquals(e.percentVested(Date("5/1/2000")), d('39.67'))
        self.assertEquals(e.percentVested(Date("7/1/2000")), d('59.67'))
        self.assertEquals(e.percentVested(Date("10/1/2000")), d('89.84'))
        self.assertEquals(e.percentVested(Date("10/31/2000")), d('99.67'))
        self.assertEquals(e.percentVested(Date("11/1/2000")), d('100.00'))
        self.assertEquals(e.percentVested(Date("12/1/2000")), d('100.00'))

        # valueOn should multiply by amount
        e.amount = 200
        self.assertEquals(e.valueOn(Date("2/1/2000")), d('20.32'))
示例#5
0
 def test_NoneAmount(self):
     e = Event()
     e.amount = None
     assert e.value == 0