Skip to content
This repository has been archived by the owner on Nov 16, 2022. It is now read-only.

Commit

Permalink
Rough in a framework for financial reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
chadwhitacre committed Nov 4, 2015
1 parent 326cb50 commit 433e648
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 5 deletions.
13 changes: 13 additions & 0 deletions scss/_pages/finances.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.finances {
tr {
border: 1px solid $light-brown;
border-style: solid none;
}
td {
vertical-align: top;
padding: 10px 10px 10px 0;
li:last-child {
margin-bottom: 0;
}
}
}
1 change: 1 addition & 0 deletions scss/inside.gratipay.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@

@import "_pages/homepage";
@import "_pages/brand-guidelines";
@import "_pages/finances";
@import "_pages/product-overview";
@import "_pages/iframed";
5 changes: 0 additions & 5 deletions www/appendices/finances.spt

This file was deleted.

94 changes: 94 additions & 0 deletions www/appendices/finances/%year.int/index.spt
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
import re
import os
import calendar
import datetime
from collections import defaultdict, namedtuple

Report = namedtuple('Report', ['name', 'filename', 'ext'])

current_dir = os.path.dirname(__file__)
reports_dir = os.path.join(current_dir, '..', 'reports')
budgets_dir = os.path.join(current_dir, '..', 'budgets')

nav_title = 'Finances'
[---]
year = request.path['year']
assert 2100 > year > 2000, year

available_years = reversed(sorted(os.listdir(reports_dir)))
available_months = calendar.month_name[:0:-1]
available_budgets = reversed(sorted(os.listdir(budgets_dir)))

today = datetime.datetime.today()
if year == today.year:
available_months = available_months[-today.month+1:]
elif year == 2012:
available_months = available_months[:-5]

budgets_this_year = [b for b in available_budgets if b.startswith(str(year))]
def format_budget_date(filename):
date = filename.split('.')[0]
year, month, day = map(int, date.split('-'))
return '{} {}'.format(calendar.month_name[month], day)

reports_by_month = defaultdict(list)
available_reports = sorted(os.listdir(os.path.join(reports_dir, str(year))))
for filename in available_reports:
'2015-10.balance-sheet.pdf' # e.g.
date, namey_thing, ext = filename.split('.')
year, month = map(int, date.split('-'))
name = namey_thing.replace('-', ' ').title()
report = Report(name, filename, ext)
reports_by_month[calendar.month_name[month]].append(report)

[---] text/html via jinja2
{% extends "templates/page.html" %}
{% block content %}

<h2>Available Years</h2>

<ul>
{% for year in available_years %}
<li><a href="../{{ year }}/">{{ year }}</a></li>
{% endfor %}
</ul>


<h2>Budgets</h2>

{% if budgets_this_year %}
<ul>
{% for filename in budgets_this_year %}
<li><a href="../budgets/{{ filename }}">{{ format_budget_date(filename) }}</a></li>
{% endfor %}
</ul>
{% else %}
<p><i>No budgets this year.</i></p>
{% endif %}


<h2>Reports</h2>

<table class="finances">
{% for month in available_months %}
<tr>
<td>{{ month }}</td>
<td>
{% if reports_by_month[month] %}
<ul>
{% for report in reports_by_month[month] %}
<li><a href="/reports/{{ year }}/{{ report.filename }}">{{ report.name }}</a>
({{ report.ext }})</li>
{% endfor %}
</ul>
{% else %}
<ul>
<li><i>No reports for this month.</i></li>
</ul>
{% endif %}
</td>
</tr>
{% endfor %}
</table>

{% endblock %}
4 changes: 4 additions & 0 deletions www/appendices/finances/index.spt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
nav_title = 'Finances'
[---]
request.redirect('./2015')
[---] text/html via markdown

0 comments on commit 433e648

Please sign in to comment.