diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb
new file mode 100644
index 0000000..40ce240
--- /dev/null
+++ b/app/controllers/dashboard_controller.rb
@@ -0,0 +1,7 @@
+class DashboardController < ApplicationController
+ def show
+ @incomes = Income.includes(:member).all
+ @expenses = Expense.all
+ @members = Member.all
+ end
+end
diff --git a/app/models/member.rb b/app/models/member.rb
index cfa4796..4e713a3 100644
--- a/app/models/member.rb
+++ b/app/models/member.rb
@@ -10,14 +10,14 @@ class Member < ApplicationRecord
end
def others_included_income
- Income.where(included: true) - included_income
+ Income.where(included: true).sum(&:amount) - included_income
end
def burden_percent
- (Income.total - others_included_income) / Income.total
+ ((Income.total - others_included_income) / Income.total).round(2)
end
def burden_amount
- burden_percent * Expense.total
+ burden_percent * Expense.all.map(&:monthly).sum.round(2)
end
end
diff --git a/app/views/dashboard/show.html.erb b/app/views/dashboard/show.html.erb
new file mode 100644
index 0000000..7edbc72
--- /dev/null
+++ b/app/views/dashboard/show.html.erb
@@ -0,0 +1,70 @@
+
+
+
+
+
+ Member |
+ Burden Percent |
+ Burden Amount |
+
+
+
+ <% @members.each do |member| %>
+
+ <%= member.name %> |
+ <%= member.burden_percent * 100 %>% |
+ <%= number_to_currency(member.burden_amount) %> |
+
+ <% end %>
+
+
+
+
+
+
+ Member |
+ For |
+ Amount |
+ Included |
+
+
+
+ <% @incomes.each do |income| %>
+
+ <%= income.member.name %> |
+ <%= income.description %> |
+ <%= number_to_currency(income.amount) %> |
+ <%= income.included %> |
+
+ <% end %>
+
+
+
+
+
+
+
+
+ Bill |
+ Payment |
+ Period |
+ Montly |
+ Autopaid |
+ Estimated |
+
+
+
+ <% @expenses.each do |expense| %>
+
+ <%= expense.description %> |
+ <%= number_to_currency(expense.payment) %> |
+ <%= expense.period %> |
+ <%= number_to_currency(expense.monthly) %> |
+ <%= expense.autopaid %> |
+ <%= expense.estimated %> |
+
+ <% end %>
+
+
+
+
diff --git a/config/routes.rb b/config/routes.rb
index 1b25320..7d04545 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,9 +1,10 @@
Rails.application.routes.draw do
+ resource :dashboard, only: :show
resources :incomes
resources :members
resources :expenses
# Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html
# Defines the root path route ("/")
- # root "articles#index"
+ root "dashboard#show"
end