-
Notifications
You must be signed in to change notification settings - Fork 2
/
report.py
132 lines (109 loc) · 4.47 KB
/
report.py
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#!/usr/bin/env python
import math
import pylink
def comma(v, dec=True, n=13, white=True):
if dec:
retval = '%*s' % (n, '{:,}'.format(round(float(v), 2)))
if not (10*v % 1):
retval = retval[1:] + '0'
else:
retval = '%*s' % (n, '{:,}'.format(int(v)))
if not white: retval = retval.replace(' ', '')
return retval
TAX_FMT = """%%T: Rate vs the taxable income
%%A: Rate vs the ACTUAL (in your bank) income
=== State Taxes ===
Taxable Income: %(state_taxable_income)s $
Actual Income: %(total_income)s $
Reg Taxes: %(var_state_reg)s
SDI Taxes: %(var_state_sdi)s
State Taxes: %(var_state_tot)s
Cash Withheld: %(var_state_with)s
RSU Withheld: %(var_state_rsu_with)s
Outstanding: %(var_state_out)s
=== Federal Taxes ===
Fed Taxable Income: %(fed_taxable_income)s $
Actual Income: %(total_income)s $
Reg Taxes: %(var_fed_reg)s
SS Taxes: %(var_fed_ss)s
Medicare Taxes: %(var_fed_med)s
AMT Taxable Income: %(amt_taxable_income)s $
AMT Exemption: %(var_amt_exempt)s
AMT Taxes: %(var_amt)s
Federal Taxes: %(var_fed_tot)s
Cash Withheld: %(var_fed_with)s
RSU Withheld: %(var_fed_rsu_with)s
Outstanding: %(var_fed_out)s
=== Overall ===
Actual Income: %(total_income)s $
State Taxes: %(var_state_tot)s
Federal Taxes: %(var_fed_tot)s
Total Taxes: %(var_tot)s
Outstanding: %(var_tot_out)s
"""
class Report(object):
def __init__(self, m):
self.m = m
def print_tax_summary(self):
m = self.m
args = {}
def __a(name, val, real_only=False):
ri = round(((100.0 * float(val)) / float(m.total_income_usd)), 1)
if real_only:
s = '%s $ ( %5.1f%%A )' % (comma(val, dec=False), ri)
else:
if taxable_income:
rt = round(((100.0 * float(val)) / float(taxable_income)), 1)
else:
rt = 0.0
s = '%s $ ( %5.1f%%A %5.1f%%T )' % (comma(val, dec=False), ri, rt)
args['var_'+name] = s
args['total_income'] = comma(m.total_income_usd, dec=False)
taxable_income = m.state_taxable_income_usd
args['state_taxable_income'] = comma(m.state_taxable_income_usd, dec=False)
__a('state_reg', m.state_reg_income_taxes_usd)
__a('state_sdi', m.state_sdi_taxes_usd)
__a('state_tot', m.state_taxes_usd)
__a('state_with', m.state_withheld_usd)
__a('state_rsu_with', m.shares_withheld_rsu_state_usd)
__a('state_out', m.state_outstanding_taxes_usd)
args['fed_taxable_income'] = comma(m.fed_taxable_income_usd, dec=False)
args['amt_taxable_income'] = comma(m.amt_taxable_income_usd, dec=False)
taxable_income = m.amt_taxable_income_usd
__a('amt', m.amt_taxes_usd)
__a('amt_exempt', m.amt_exemption_usd)
taxable_income = m.fed_taxable_income_usd
__a('fed_reg', m.fed_reg_income_taxes_usd)
__a('fed_ss', m.fed_ss_taxes_usd)
__a('fed_med', m.fed_medicare_taxes_usd)
__a('fed_tot', m.fed_taxes_usd)
__a('fed_with', m.fed_withheld_usd)
__a('fed_rsu_with', m.shares_withheld_rsu_fed_usd)
__a('fed_out', m.fed_outstanding_taxes_usd)
__a('tot', m.tax_burden_usd, real_only=True)
__a('tot_out', m.outstanding_taxes_usd, real_only=True)
print(TAX_FMT % args)
def print_grants(self):
m = self.m
print("="*60)
print("Cap Table")
print("="*60)
start_lst = m.grants_lst
end_lst = m.rem_grants_lst
print(' ID Type Strike Vested Withheld Sold Remaining')
row_fmt = '%(name)15s %(vehicle)s %(strike)6s %(vested)15s %(withheld)15s %(sold)15s %(rem)15s'
for i in range(len(start_lst)):
start = start_lst[i]
end = end_lst[i]
assert(start.name == end.name)
kwargs = {
'name': start.name,
'vehicle': start.vehicle,
'strike': '%5.1f' % start.strike_usd,
'vested': comma(start.vested(m.query_date), dec=False),
'sold': comma(end.sold - start.sold, dec=False),
'withheld': comma(end.withheld, dec=False),
'rem': comma(end.vested_unliquidated(m.query_date), dec=False),
}
print(row_fmt % kwargs)
print()