Skip to content

Commit

Permalink
starting balance sheet
Browse files Browse the repository at this point in the history
  • Loading branch information
mbulat committed Jul 28, 2015
1 parent 5f6fd98 commit b17b746
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 0 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; }
25 changes: 25 additions & 0 deletions app/controllers/plutus/reports_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
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
@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

end
end
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 @@
<% if accounts.count > 0%>
<table class="table table-striped table-hover">
<caption class="text-left"><b><%=name%></b></caption>
<thead>
<tr>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<% accounts.each do |account| %>
<tr class="<%= cycle("even", "odd") -%>">
<td><%=h account.name %></td>
<td><%=h account.balance %></td>
</tr>
<% end %>
</tbody>
</table>
<% end %>
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, @date, :class => 'datepicker form-control', :placeholder => "Date" %>
</div>
<button type="submit" class="btn btn-default">Set Date</button>
<% end %>
</center>

<br>

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


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

get 'reports/balance_sheet' => 'reports#balance_sheet'

resources :accounts, only: [:show, :index]
resources :entries, only: [:show, :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 b17b746

Please sign in to comment.