Skip to content

Commit

Permalink
Merge branch 'feature/reporting'
Browse files Browse the repository at this point in the history
  • Loading branch information
mbulat committed Jul 28, 2015
2 parents 5f6fd98 + f506d3d commit a45a479
Show file tree
Hide file tree
Showing 16 changed files with 136 additions and 155 deletions.
3 changes: 3 additions & 0 deletions app/assets/javascripts/plutus/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,7 @@
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery
//= require jquery_ujs
//= require jquery.ui.datepicker
//= require_tree .
2 changes: 2 additions & 0 deletions app/assets/javascripts/plutus/reports.js.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
jQuery ->
$('.datepicker').datepicker dateFormat: "yy-mm-dd"
1 change: 1 addition & 0 deletions app/assets/stylesheets/plutus/application.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*= require_tree .
*= require bootstrap.min
*= require bootstrap-theme.min
*= require jquery.ui.datepicker
*= require_self
*/
body { padding-top: 60px; }
15 changes: 0 additions & 15 deletions app/controllers/plutus/accounts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,5 @@ def index
format.json { render :json => @accounts }
end
end

# @example
# GET /accounts/1
# GET /accounts/1.xml
# GET /accounts/1.json
def show
@account = Account.find(params[:id])

respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @account }
format.json { render :json => @account }
end
end

end
end
17 changes: 1 addition & 16 deletions app/controllers/plutus/entries_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,13 @@ class EntriesController < Plutus::ApplicationController
# GET /entries.xml
# GET /entries.json
def index
@entries = Entry.all
@entries = Entry.limit(100).order('date DESC')

respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @entries }
format.json { render :json => @entries }
end
end

# @example
# GET /entries/1
# GET /entries/1.xml
# GET /entries/1.json
def show
@entry = Entry.find(params[:id])

respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @entry }
format.json { render :json => @entry }
end
end

end
end
39 changes: 39 additions & 0 deletions app/controllers/plutus/reports_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
module Plutus
# == Security:
# Only GET requests are supported. You should ensure that your application
# controller enforces its own authentication and authorization, which this
# controller will inherit.
#
# @author Michael Bulat
class ReportsController < Plutus::ApplicationController
unloadable

# @example
# GET /reports/balance_sheet
def balance_sheet
@from_date = Plutus::Entry.order('date ASC').first.date
@to_date = params[:date] ? Date.parse(params[:date]) : Date.today
@assets = Plutus::Asset.all
@liabilities = Plutus::Liability.all
@equity = Plutus::Equity.all

respond_to do |format|
format.html # index.html.erb
end
end

# @example
# GET /reports/income_statement
def income_statement
@from_date = params[:from_date] ? Date.parse(params[:from_date]) : Date.today.at_beginning_of_month
@to_date = params[:to_date] ? Date.parse(params[:to_date]) : Date.today
@revenues = Plutus::Revenue.all
@expenses = Plutus::Expense.all

respond_to do |format|
format.html # index.html.erb
end
end

end
end
5 changes: 4 additions & 1 deletion app/views/layouts/plutus/_navigation_links.html.erb
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
<%# add navigation links to this file %>
<li><%= link_to "Dashboard", root_path%></li>
<li><%= link_to "Balance Sheet", reports_balance_sheet_path%></li>
<li><%= link_to "Income Statement", reports_income_statement_path%></li>
<li><%= link_to "General Ledger", accounts_path%></li>
<li><%= link_to "Journal", entries_path%></li>
11 changes: 4 additions & 7 deletions app/views/plutus/accounts/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<div class="container">
<h1>Listing Accounts</h1>
<center>
<h1>General Ledger</h1>
<br>
</center>

<table class="table table-striped table-hover">
<tr>
<th class="nobg">ID</th>
<th>Name</th>
<th>Type</th>
<th>Credit Balance</th>
Expand All @@ -13,7 +15,6 @@

<% @accounts.each do |account| %>
<tr class="<%= cycle("even", "odd") -%>">
<td><%=link_to(account.id, account_path(account.id)) %></td>
<td><%=h account.name %></td>
<td><%=h account.type.sub('Plutus::','') %></td>
<td><%=h account.credits_balance %></td>
Expand All @@ -22,8 +23,4 @@
</tr>
<% end %>
</table>

<br />

<h3>Go to <%= link_to 'Entries', entries_path %></h3>
</div>
59 changes: 0 additions & 59 deletions app/views/plutus/accounts/show.html.erb

This file was deleted.

18 changes: 10 additions & 8 deletions app/views/plutus/entries/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<div class="container">
<h1>Entries</h1>
<center>
<h1>Journal</h1>
<br>
</center>

<table class="table table-striped table-hover">
<thead>
<tr>
<th class="nobg">ID</th>
<th>Description</th>
<th>Debits</th>
<th>Credits</th>
Expand All @@ -14,15 +16,13 @@
<tbody>
<% @entries.each do |entry| %>
<tr class="<%= cycle("even", "odd") -%>">
<td><%=link_to(entry.id, entry_path(entry)) %></td>
<td><%=h entry.description %></td>
<td></td>
<td></td>
<td><%=h entry.created_at %></td>
</tr>
<% entry.debit_amounts.each do |debit_amount| %>
<tr class="<%= cycle("odd", "odd") -%>">
<td></td>
<td>&nbsp;&nbsp;&nbsp;&nbsp;<%=h "#{debit_amount.account.name}" %></td>
<td><%=h debit_amount.amount %></td>
<td></td>
Expand All @@ -31,18 +31,20 @@
<% end %>
<% entry.credit_amounts.each do |credit_amount| %>
<tr class="<%= cycle("odd", "odd") -%>">
<td></td>
<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<%=h "#{credit_amount.account.name}" %></td>
<td></td>
<td><%=h credit_amount.amount %></td>
<td></td>
</tr>
<% end %>
<tr class="<%= cycle("odd", "odd") -%>">
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<% end %>
</tbody>
</table>

<br />

<h3>Go to <%= link_to 'Accounts', accounts_path %></h3>
</div>
46 changes: 0 additions & 46 deletions app/views/plutus/entries/show.html.erb

This file was deleted.

19 changes: 19 additions & 0 deletions app/views/plutus/reports/_account.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<table class="table table-striped table-hover">
<caption class="text-left"><b><%=name%></b></caption>
<thead>
<tr>
<th></th>
<th></th>
</tr>
</thead>
<% if accounts.count > 0%>
<tbody>
<% accounts.each do |account| %>
<tr class="<%= cycle("even", "odd") -%>">
<td><%=h account.name %></td>
<td><%=h account.balance(:from_date => @from_date, :to_date => @to_date) %></td>
</tr>
<% end %>
</tbody>
<% end %>
</table>
21 changes: 21 additions & 0 deletions app/views/plutus/reports/balance_sheet.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<div class="container">
<center>
<h1>Balance Sheet</h1>

<%= form_tag({:action => 'balance_sheet'}, {:method => :get, :class => 'form-inline'}) do%>
<div class="form-group">
<%= label_tag :date, nil, class: 'sr-only'%>
<%= text_field_tag :date, @to_date, :class => 'datepicker form-control' %>
</div>
<button type="submit" class="btn btn-default">Get Report</button>
<% end %>
</center>

<br>

<%= render 'account', :name => "Assets", :accounts => @assets %>
<%= render 'account', :name => "Liabilities", :accounts => @liabilities %>
<%= render 'account', :name => "Equity", :accounts => @equity %>


</div>
24 changes: 24 additions & 0 deletions app/views/plutus/reports/income_statement.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<div class="container">
<center>
<h1>Income Statement</h1>

<%= form_tag({:action => 'income_statement'}, {:method => :get, :class => 'form-inline'}) do%>
<div class="form-group">
<%= label_tag :from_date, nil, class: 'sr-only'%>
<%= text_field_tag :from_date, @from_date, :class => 'datepicker form-control', :placeholder => "Date" %>
</div>
<div class="form-group">
<%= label_tag :to_date, nil, class: 'sr-only'%>
<%= text_field_tag :to_date, @to_date, :class => 'datepicker form-control', :placeholder => "Date" %>
</div>
<button type="submit" class="btn btn-default">Get Report</button>
<% end %>
</center>

<br>

<%= render 'account', :name => "Revenues", :accounts => @revenues %>
<%= render 'account', :name => "Expenses", :accounts => @expenses %>


</div>
9 changes: 6 additions & 3 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
Plutus::Engine.routes.draw do
root :to => "accounts#index"
root :to => 'reports#balance_sheet'

resources :accounts, only: [:show, :index]
resources :entries, only: [:show, :index]
get 'reports/balance_sheet' => 'reports#balance_sheet'
get 'reports/income_statement' => 'reports#income_statement'

resources :accounts, only: [:index]
resources :entries, only: [:index]
end
2 changes: 2 additions & 0 deletions plutus.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ Gem::Specification.new do |s|
"README.markdown"
]
s.add_dependency("rails", "~> 4.0")
s.add_dependency("jquery-rails", "~> 3.0")
s.add_dependency("jquery-ui-rails", "~> 4.0")
s.add_development_dependency("yard")
s.files = Dir["{app,config,db,lib}/**/*"] + ["LICENSE", "Rakefile", "README.markdown"]
s.homepage = %q{http://github.com/mbulat/plutus}
Expand Down

0 comments on commit a45a479

Please sign in to comment.