-
Notifications
You must be signed in to change notification settings - Fork 0
/
debt
executable file
·55 lines (51 loc) · 1.6 KB
/
debt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/python
from __future__ import print_function
import afal_config
import afall
import cgitb
cgitb.enable()
date = afall.date_list[-1]
if afal_config.text:
header = \
'Debt summary as of {date}\n' \
'Character Receivable Payable Cash Net'.format(date = date)
neg = '({v})'
line = '{char:10} {r:14} {p:14} {c:14} {n:14}'
trailer = ''
else:
header = \
afall.html_header('AFAL Debt Summary') + \
' <h1>Anything For A Laugh</h1>\n' \
' <h2>Debt Summary Report as of {date}</h2>\n' \
' <table border="1"><tr><th>Character</th><th>Receivable</th><th>' \
'Payable</th><th>Cash</th><th>Net</th></tr>'.format(date = date)
neg = '<font color="red">({v})</font>'
line = \
' <tr><td><a href="{report}?todo=char.{char}">' \
'{char}</a></td><td>{r}</td><td>{p}</td><td>{c}</td><td>{n}</td></tr>'
trailer = \
' </table>\n' + afall.html_footer()
print(header)
for char in afall.character_list:
c = afall.get_char_data(char)['cash_cp']
if c is None:
continue
p = 0
for debt in afall.get_char_debts(char, "Payable"):
p += debt['amount_cp']
r = 0
for debt in afall.get_char_debts(char, "Receivable"):
r += debt['amount_cp']
if c + r > p:
n = afall.cp_to_str(c + r - p)
elif p > c + r:
n = neg.format(v = afall.cp_to_str(p - r - c))
else:
n = 'Flat Broke'
if p == 0 and r == 0 and c == 0:
continue
print(line.format(
char = char, r = afall.cp_to_str(r), p = afall.cp_to_str(p),
c = afall.cp_to_str(c), n = n, report = afal_config.report_url))
print(trailer)
afall.fini()