Skip to content

Commit

Permalink
aesthetic fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Syed Abbas authored and Syed Abbas committed Oct 6, 2018
1 parent 6373242 commit 7546eb0
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 44 deletions.
8 changes: 5 additions & 3 deletions bin/spendthrift
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ end
def get_transactions(start_date, end_date)
client = Spendthrift::PlaidGateway::PlaidClient.new
client.get_account_transactions start_date: start_date,
end_date: end_date,
account_type: :credit
end_date: end_date,
account_type: :credit
end

def sanitize_transactions(transactions)
Expand All @@ -86,7 +86,9 @@ def send_email_report(report_date, report)
end

def report_date_for_email(start_date, end_date)
start_date == end_date ? "Expense Report For: #{start_date}": "Report Date: #{start_date} to #{end_date}"
start_date = start_date.strftime "%b-%Y"
end_date = end_date.strftime "%b-%Y"
start_date == end_date ? "Expense Report: #{start_date}": "Expense Report: #{start_date} to #{end_date}"
end

def upload_report(report)
Expand Down
86 changes: 45 additions & 41 deletions lib/spendthrift/report_template.erb
Original file line number Diff line number Diff line change
@@ -1,44 +1,48 @@
<!DOCTYPE html>
<html>
<head>
<style>
#report {
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
border-collapse: collapse;
width: 100%;
}
#report td, #report th {
border: 1px solid #ddd;
padding: 8px;
}
#report tr:nth-child(even){background-color: #f2f2f2;}
#report tr:hover {background-color: #ddd;}
#report th {
padding-top: 12px;
padding-bottom: 12px;
text-align: left;
background-color: #4CAF50;
color: white;
}
</style>
</head>
<body>
<% data.each do |date, report| %>
<table id="report">
<tr>
<th>Category</th>
<th>Amount</th>
</tr>
<% report.each.sort_by{ |k, v| v }.reverse.each do |category, amount| %>
<caption> <%= date %> </caption>
<tr>
<td> <%= category %> </td>
<td> <%= amount %> </td>
</tr>
<% end %>
</table>
<br>
<br>
<% end %>
</body>
<head>
<style>
#report {
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
border-collapse: collapse;
width: 100%;
}
#report td, #report th {
border: 1px solid #ddd;
padding: 8px;
}
#report tr:nth-child(even){background-color: #f2f2f2;}
#report tr:hover {background-color: #ddd;}
#report th {
padding-top: 12px;
padding-bottom: 12px;
text-align: left;
background-color: #4CAF50;
color: white;
}
</style>
</head>
<body>
<% data.each do |date, report| %>
<h2> <%= Date.parse(date).strftime("%b-%Y") %> </h2>
<table id="report">
<tr>
<th>Category</th>
<th>Amount (USD)</th>
</tr>
<% report.each.sort_by{ |k, v| v }.reverse.each do |category, amount| %>
<tr>
<td> <%= category %> </td>
<td> <%= sprintf("%.2f", amount) %> </td>
</tr>
<% end %>
<tr bgcolor="#E8ADAA">
<td> TOTAL </td>
<td> <%= sprintf("%.2f", report.values.reduce(:+)) %> </td>
</tr>
</table>
<br>
<br>
<% end %>
</body>
</html>
1 change: 1 addition & 0 deletions spec/reporting_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@

it 'generates html tables' do
template = Spendthrift::Reporting.generate_html_report(@sample_data)
File.open('test.html', 'w') {|f| f.puts template}
expect(Nokogiri.HTML(template).search("table").length).to eq(2)
end
end
Expand Down

0 comments on commit 7546eb0

Please sign in to comment.