Prepare for floating-point values in ledger

This commit is contained in:
Nelson Elhage 2010-05-23 21:29:04 -04:00
parent 4d44325493
commit e66cf1bdbe
3 changed files with 7 additions and 7 deletions

View File

@ -71,7 +71,7 @@ def render_template(path, week=None):
'-n', 'balance', acct], '-n', 'balance', acct],
stdout=subprocess.PIPE) stdout=subprocess.PIPE)
(out, _) = p.communicate() (out, _) = p.communicate()
return int(out.split()[0][1:]) return float(out.split()[0][1:])
p = subprocess.Popen(['ledger', '-f', os.path.join(HERE,'ledger'), p = subprocess.Popen(['ledger', '-f', os.path.join(HERE,'ledger'),
'-n', 'balance', 'Pool:Owed:'], '-n', 'balance', 'Pool:Owed:'],
@ -82,7 +82,7 @@ def render_template(path, week=None):
if not line: continue if not line: continue
(val, acct) = line.split() (val, acct) = line.split()
user = acct[len("Pool:Owed:"):] user = acct[len("Pool:Owed:"):]
val = int(val[len("$"):]) val = float(val[len("$"):])
debts.append((user, val)) debts.append((user, val))
return Template(filename=path, output_encoding='utf-8').render( return Template(filename=path, output_encoding='utf-8').render(

View File

@ -20,8 +20,8 @@ People who have not yet started:
Beer pool: Beer pool:
This week: $${5 * len(lame)}.00 This week: $${5 * len(lame)}.00
Total: $${pool}.00 Total: $${pool}
Paid: $${paid}.00 Paid: $${paid}
Individual debts: Individual debts:
% for (u, v) in sorted(debts, key=lambda p:p[1], reverse=True): % for (u, v) in sorted(debts, key=lambda p:p[1], reverse=True):

View File

@ -31,9 +31,9 @@ Results for week beginning ${week_start.strftime("%F")}
<h2>Beer pool:</h2> <h2>Beer pool:</h2>
<table> <table>
<tr> <td> This week: </td> <td> $${5 * len(lame)}.00 </td> </tr> <tr> <td> This week: </td> <td> $${5 * len(lame)} </td> </tr>
<tr> <td> Total: </td> <td> $${pool}.00 </td> </tr> <tr> <td> Total: </td> <td> $${pool} </td> </tr>
<tr> <td> Paid: </td> <td> $${paid}.00 </td> </tr> <tr> <td> Paid: </td> <td> $${paid} </td> </tr>
</table> </table>
<h2>Debts:</h2> <h2>Debts:</h2>