Exemplo n.º 1
0
def myreport(month=None,year=None):
	if month and year:
		dr = to_date_range(month,year)
	else:
		dr = to_date_range()
	ft_url = "http://localhost:8001/api/transactions/fifth-third/?from=%s&to=%s" % (dr[0],dr[1])
	cu_url = "http://localhost:8001/api/transactions/chase-united/?from=%s&to=%s" % (dr[0],dr[1])

	payload = GroupByWordList(ft_url,WordList.FIXED_LIST)
	payload = GroupByWordList(cu_url,WordList.VARIABLE_LIST)

	dd = WordList.DEFAULT_DIR

	ft_loc = "%s/fifth-third-%s.csv" % (dd,today())
	cu_loc = "%s/chase-united-%s.csv" % (dd,today())

	payload.run().to_csv(ft_loc)
	payload.run().to_csv(cu_loc)
else:
	
	if len(args) == 4:
		action = args[0]
		account = args[1]
		from_date = args[2]
		to_date = args[3]

		if action == 'report':
			
			if account == 'all':
				url = "http://localhost:8001/api/transactions/?from=%s&to=%s" % (from_date,to_date)

				if options.wordlist:
					wordlist = options.wordlist.split(',')
					x = GroupByWordList(url,wordlist)
					if options.filename and action == 'report':
						x.run().to_csv(str(options.filename))
					else:
						print 'ok here i am'
						x.run().show()
				
			else:

				url = "http://localhost:8001/api/transactions/%s/?from=%s&to=%s" % (account,from_date,to_date)
				if options.wordlist:
					wordlist = options.wordlist.split(',')
					x = GroupByWordList(url,wordlist)
					if options.filename and action == 'report':
						x.run().to_csv(str(options.filename))
					else: