def test_whenLastStatementPosted(self): """ This should find the statement with the latest 'posted' time. """ acc = fakeAccount() acc.opened = Date("1/1/2001") assert acc.whenLastStatementPosted() == Date("1/1/2001") assert len(acc.events) == 0 acc.events << duckbill.newEvent("statement", posted="2/1/2001") acc.events << duckbill.newEvent("statement", posted="5/1/2001") acc.events << duckbill.newEvent("statement", posted="3/1/2001") acc.events << duckbill.newEvent("statement", posted="1/1/2001") assert acc.whenLastStatementPosted() == Date("5/1/2001")
def test_openBalance(self): assert Statement(self.acc).openBal == 0 assert Statement(self.acc).closeBal == 0 self.acc.events << duckbill.newEvent("charge", amount=5, posted=DateTime("now")) assert Statement(self.acc).openBal == 0, \ "Expected opening balance of 0, got %s" % Statement(self.acc).openBal assert Statement(self.acc, start=Date("today"), end=Date("today")+1).closeBal == 5, \ "Expected closing balance of 5, got %s" \ % Statement(self.acc, end=Date("today")+1).closeBal
def test_openBalance(self): assert Statement(self.acc).openBal == 0 assert Statement(self.acc).closeBal == 0 self.acc.events << duckbill.newEvent( "charge", amount=5, posted=DateTime("now")) assert Statement(self.acc).openBal == 0, \ "Expected opening balance of 0, got %s" % Statement(self.acc).openBal assert Statement(self.acc, start=Date("today"), end=Date("today")+1).closeBal == 5, \ "Expected closing balance of 5, got %s" \ % Statement(self.acc, end=Date("today")+1).closeBal
def test_eventsBetween(self): acc = fakeAccount() then = Date("1/1/2001") now = Date("5/1/2001") # not really :) # start with nothing. assert len(acc.eventsBetween(then, now)) == 0 # include the front date: acc.events << duckbill.newEvent("payment", posted="1/1/2001") assert len(acc.eventsBetween(then, now)) == 1, "start" # exclude the end date: acc.events << duckbill.newEvent("note", posted="5/1/2001") assert len(acc.eventsBetween(then, now)) == 1, "end" # include the middle: acc.events << duckbill.newEvent("charge", posted="2/1/2001") acc.events << duckbill.newEvent("credit", posted="4/1/2001") l = len(acc.eventsBetween(then, now)) assert l == 3, \ "middle should have 3 events, actually has %d" % l