Sha256: 788415ea7e363873e6c036f539a49ab1568a06ed0b1c2b7beabaa8a0e3663010
Contents?: true
Size: 1.21 KB
Versions: 14
Compression:
Stored size: 1.21 KB
Contents
<% @query = query do %> select month as "Month", income as "Income", expenses as "Expenses", rate as "Savings Rate", rate_12 as "Prev Year", rate_24 as "Two Years" from ( select month, income, expenses, rate, lead(rate, 12) over() as rate_12, lead(rate, 24) over() as rate_24 from ( select month, income, expenses, income - expenses as savings, round(case when income = 0 then null else (income - expenses) / income * 100 end, 2) as rate from ( select date_trunc('month', xtn_date)::date as month, 0 - sum(case when account ~ 'Income' then amount else 0 end) as income, sum(case when account ~ 'Expenses' then amount else 0 end) as expenses from ledger group by date_trunc('month', xtn_date)::date ) x order by month desc ) x ) x where month <= :to and month >= :from <% end %> <div class="page-header"> <h1>Savings Rate</h1> </div> <div class="row"> <div class="span16"> <%= table @query %> </div> </div>
Version data entries
14 entries across 14 versions & 1 rubygems