diff --git a/app/assets/javascripts/plutus/application.js b/app/assets/javascripts/plutus/application.js index 8913b40f..9da3dcbd 100644 --- a/app/assets/javascripts/plutus/application.js +++ b/app/assets/javascripts/plutus/application.js @@ -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 . diff --git a/app/assets/javascripts/plutus/reports.js.coffee b/app/assets/javascripts/plutus/reports.js.coffee new file mode 100644 index 00000000..fab24e21 --- /dev/null +++ b/app/assets/javascripts/plutus/reports.js.coffee @@ -0,0 +1,2 @@ +jQuery -> + $('.datepicker').datepicker dateFormat: "yy-mm-dd" diff --git a/app/assets/stylesheets/plutus/application.css b/app/assets/stylesheets/plutus/application.css index 160b5510..ac26e950 100644 --- a/app/assets/stylesheets/plutus/application.css +++ b/app/assets/stylesheets/plutus/application.css @@ -13,6 +13,7 @@ *= require_tree . *= require bootstrap.min *= require bootstrap-theme.min + *= require jquery.ui.datepicker *= require_self */ body { padding-top: 60px; } diff --git a/app/controllers/plutus/reports_controller.rb b/app/controllers/plutus/reports_controller.rb new file mode 100644 index 00000000..c919fb7d --- /dev/null +++ b/app/controllers/plutus/reports_controller.rb @@ -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 diff --git a/app/views/plutus/reports/_account.html.erb b/app/views/plutus/reports/_account.html.erb new file mode 100644 index 00000000..c0e222d1 --- /dev/null +++ b/app/views/plutus/reports/_account.html.erb @@ -0,0 +1,19 @@ +<% if accounts.count > 0%> + + + + + + + + + + <% accounts.each do |account| %> + "> + + + + <% end %> + +
<%=name%>
<%=h account.name %><%=h account.balance %>
+<% end %> diff --git a/app/views/plutus/reports/balance_sheet.html.erb b/app/views/plutus/reports/balance_sheet.html.erb new file mode 100644 index 00000000..5b28156e --- /dev/null +++ b/app/views/plutus/reports/balance_sheet.html.erb @@ -0,0 +1,21 @@ +
+
+

Balance Sheet

+ + <%= form_tag({:action => 'balance_sheet'}, {:method => :get, :class => 'form-inline'}) do%> +
+ <%= label_tag :date, nil, class: 'sr-only'%> + <%= text_field_tag :date, @date, :class => 'datepicker form-control', :placeholder => "Date" %> +
+ + <% end %> +
+ +
+ + <%= render 'account', :name => "Assets", :accounts => @assets %> + <%= render 'account', :name => "Liabilities", :accounts => @liabilities %> + <%= render 'account', :name => "Equity", :accounts => @equity %> + + +
diff --git a/config/routes.rb b/config/routes.rb index 17e81d2e..2cc15109 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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 diff --git a/plutus.gemspec b/plutus.gemspec index f86be007..e3efddf8 100644 --- a/plutus.gemspec +++ b/plutus.gemspec @@ -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}