Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
redesign, refactor, rebuild
  • Loading branch information
SelenaSmall committed Sep 17, 2015
1 parent de65856 commit a6ff04a
Show file tree
Hide file tree
Showing 34 changed files with 434 additions and 263 deletions.
2 changes: 1 addition & 1 deletion app/assets/stylesheets/application.scss
Expand Up @@ -4,4 +4,4 @@

@import "rails_bootstrap_forms.css";

@import "income";
@import "mybudget";
80 changes: 0 additions & 80 deletions app/assets/stylesheets/income.scss
@@ -1,80 +0,0 @@
.application {
background-color: #D6EAFF;
padding-top: 15px;
h1 {
font-size: 60px;
font-weight: bolder;
font-family: monospace;
color: black;
}
}

.navbar-default {
margin-bottom: 0px;
background-color: #D6EAFF;
border: none;
.dropdown-toggle {
padding: inherit;
padding-top: 20px;
padding-right: 20px;
}

}

.col-md-12 {
padding-left: 80px;
padding-right: 80px;
}

.col-md-8 {
margin: 15px;
}

.bordered-form {
margin-left: 50;
padding: 20px;
padding-left: 40px;
padding-right: 40px;
background-color: #ADD6FF;
border-radius: 15px;
width: 750px;

.field-name {
padding-left: 40px;
}

.field {
padding: 10px;
padding-left: 250px;

#income_other_income {
text-align: right;
}
#income_wages {
text-align: right;
}
}

.total-output {
text-align: right;
padding-right: 20px;
font-style: bold;
font-size: 40px
}

.actions {
padding-left: 472px;
font-size: 18px;
}

h1 {
font-size: 40px;
font-weight: inherit;
border-bottom: solid black 1px;
}
}

#total-field-name {
font-size: 25px;
color: #1F3D99;
}
102 changes: 99 additions & 3 deletions app/assets/stylesheets/mybudget.scss
@@ -1,3 +1,99 @@
// Place all the styles related to the mybudget controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
.application {
background-color: #D6EAFF;
padding-top: 15px;
h1 {
font-size: 60px;
font-weight: bolder;
font-family: monospace;
color: black;
}

.summary-row {
margin-left: 50px;
margin-top: 20px;
margin-bottom: 20px;

.total-field {
text-align: right;
margin-right: 20px;
padding-left: 200px;
font-style: bold;
font-size: 40px
}

#total-field-name {
font-size: 25px;
color: #1F3D99;
}
}
}

.navbar-default {
margin-bottom: 0px;
background-color: #D6EAFF;
border: none;
.dropdown-toggle {
padding: inherit;
padding-top: 20px;
padding-right: 20px;
}

}

.col-md-12 {
padding-left: 80px;
padding-right: 80px;
}

.col-md-8 {
margin: 15px;
}

.bordered-form {
margin-left: 50px;
margin-top: 20px;
margin-bottom: 20px;
padding: 20px;
padding-left: 40px;
padding-right: 40px;
background-color: #ADD6FF;
border-radius: 15px;
width: 750px;

.field-name {
padding-left: 40px;
}

.table {
padding: 10px;
padding-left: 250px;
}

.amount {
text-align: right;
}

.table-items {
text-align: right;
}

.total-output {
text-align: right;
padding-right: 20px;
font-style: bold;
font-size: 40px
}

.actions {
padding-left: 472px;
font-size: 18px;
}

h2 {
font-size: 40px;
font-weight: inherit;
border-bottom: solid black 1px;
text-align: left;
}

}
31 changes: 21 additions & 10 deletions app/controllers/expenses_controller.rb
@@ -1,20 +1,27 @@
class ExpensesController < ApplicationController
before_action :set_mybudget
before_action :set_expense, only: [:show, :edit, :update, :destroy]

#def new
# @expense = Expense.new
#end
def index
@expenses = @mybudget.expenses.all
end

def edit
def new
@expense = @mybudget.expenses.build
end

def create
@expense = Expense.new(expense_params)
@expense = @mybudget.expenses.build(expense_params)

respond_to do |format|
if @expense.save
format.html { redirect_to edit_expense_path(@expense)}
end
end
if @expense.save
format.html { redirect_to [@mybudget, @expenses], notice: 'expense was successfully created.' }
format.json { render :show, status: :created, location: @expense }
else
format.html { render :new }
format.json { render json: @expense.errors, status: :unprocessable_entity }
end
end
end

def update
Expand All @@ -26,11 +33,15 @@ def update
end

private
def set_mybudget
@mybudget = Mybudget.find(params[:mybudget_id])
end

def set_expense
@expense = Expense.find(params[:id])
end

def expense_params
params.require(:expense).permit(:outgoing, :oneoff)
params.require(:expense).permit(:expense, :amount)
end
end
32 changes: 23 additions & 9 deletions app/controllers/incomes_controller.rb
@@ -1,20 +1,30 @@
class IncomesController < ApplicationController
before_action :set_mybudget
before_action :set_income, only: [:show, :edit, :update, :destroy]

#def new
# @income = Income.new
#end
def index
@incomes = @mybudget.incomes.all
end

def new
@income = @mybudget.incomes.build
end

def edit
end

def create
@income = Income.new(income_params)
@income = @mybudget.incomes.build(income_params)

respond_to do |format|
if @income.save
format.html { redirect_to edit_income_path(@income)}
end
end
if @income.save
format.html { redirect_to [@mybudget, @incomes], notice: 'income was successfully created.' }
format.json { render :show, status: :created, location: @income }
else
format.html { render :new }
format.json { render json: @income.errors, status: :unprocessable_entity }
end
end
end

def update
Expand All @@ -26,11 +36,15 @@ def update
end

private
def set_mybudget
@mybudget = Mybudget.find(params[:mybudget_id])
end

def set_income
@income = Income.find(params[:id])
end

def income_params
params.require(:income).permit(:wages, :other_income)
params.require(:income).permit(:income, :amount)
end
end
7 changes: 0 additions & 7 deletions app/controllers/mybudget_controller.rb

This file was deleted.

51 changes: 51 additions & 0 deletions app/controllers/mybudgets_controller.rb
@@ -0,0 +1,51 @@
class MybudgetsController < ApplicationController
before_action :set_mybudget, only: [:show, :edit, :update, :destroy]

def index
@mybudget = Mybudget.all
end

def new
@mybudget = Mybudget.new
end

def show
end

def edit
end

def create
@mybudget = Mybudget.new(mybudget_params)

respond_to do |format|
if @mybudget.save
format.html { redirect_to mybudget_path(@mybudget), notice: 'mybudget was successfully created.' }
format.json { render :show, status: :created, location: @mybudget }
else
format.html { render :new }
format.json { render json: @mybudget.errors, status: :unprocessable_entity }
end
end
end

def update
end

def destroy
@mybudget.destroy
respond_to do |format|
format.html { redirect_to mybudgets_home_path(@mybudget), notice: 'mybudget was successfully destroyed.' }
format.json { head :no_content }
end
end

private
def set_mybudget
@mybudget = Mybudget.find(params[:id])
end

def mybudget_params
params.require(:mybudget).permit(:name, :open_bal)
end
end
4 changes: 1 addition & 3 deletions app/models/expense.rb
@@ -1,5 +1,3 @@
class Expense < ActiveRecord::Base
def total_expense
outgoing.to_d + oneoff.to_d
end
belongs_to :mybudget
end
4 changes: 0 additions & 4 deletions app/models/income.rb
@@ -1,7 +1,3 @@
class Income < ActiveRecord::Base
belongs_to :mybudget

def total_income
wages.to_d + other_income.to_d
end
end
4 changes: 4 additions & 0 deletions app/models/mybudget.rb
@@ -0,0 +1,4 @@
class Mybudget < ActiveRecord::Base
has_many :incomes
has_many :expenses
end

0 comments on commit a6ff04a

Please sign in to comment.