I'm writing an expense tracking program. At the moment I have three class
Lineitem stores the attributes for individual transactions and has methods format a transaction for output (payee, amount date), etc. Each lineitem is one transaction.
Account is a collection of lineitems and has methods to add a lineitem, list its lineitems, determine the value of all of its lineitems, etc.
Journal is a collection of accounts and has methods to add a new account, list its accounts, format a list of accounts, etc.
1) Does this seem a sensible way of organizing classes?
2) I'm adding a method to only look at transactions between a run-time specified start_date and end_date. The best way might be to store start_date and end_date somewhere, then modify Account to change some methods to receive start_date and end_date parameters and then examine lineitem dates when totaling or listing its linetimes. Are there other approaches I should be considering?
EDIT: method in accounts to implement the date check. self.lineitems is a list of lineitems. start_date and end_date are set and runtime and may not be set or may be set more than once.
def get_lineitems(self, start_date, end_date):
if start_date and end_date:
for lineitem in self.lineitems:
if start_date <= lineitem.date <= end_date:
yield lineitem
else:
for lineitem in self.lineitems:
yield lineitem