Jason R. Coombs avatar Jason R. Coombs committed de71a5e

Initial work on soliciting liabilities

Comments (0)

Files changed (1)

jaraco/financial/merchant.py

 		self.name = name
 		self.accounts = dict()
 		self.obligations = Obligations()
+		self.liabilities = list()
 
 	def __repr__(self):
 		return '{name} ({id})'.format(**vars(self))
 				for obl in agent.obligations[merchant]:
 					print('    ', obl)
 
+	def add_liabilities(self):
+		self._print_liabilities()
+		while True:
+			if raw_input('Add liabilities? ') != 'y':
+				break
+			agent_menu = ui.Menu(list(self))
+			agent = agent_menu.get_choice('which agent? ')
+			amount = raw_input('amount: ')
+			descriptor = raw_input('category: ')
+			payee = raw_input('payee: ')
+			start_date = raw_input('start date (blank for none)? ')
+			end_date = raw_input('end date (blank for none)? ')
+			limit = raw_input('limit (blank for none)? ')
+			designation = ledger.SimpleDesignation(
+				amount=parse_amount(amount),
+				descriptor=descriptor)
+			def parse_date(date_str):
+				if not date_str: return
+				return datetime.date(*map(int, date_str.split('/')))
+
+			agent.liabilities.add(Liability(payee, designation,
+				parse_date(start_date),
+				parse_date(end_date),
+				limit=float(limit) if limit else None,
+			))
+
 	def process_residuals(self):
 		for agent in self:
 			self._process_agent_residuals(agent)
 			portfolio.import_(tl_report)
 		portfolio.add_obligations()
 		portfolio.process_residuals()
+		portfolio.add_liabilities()
 		portfolio.pay_balances()
 		portfolio.save()
 		portfolio.export('portfolio.xlsx')
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.