Class: Eboshi::AdjustmentsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/eboshi/adjustments_controller.rb

Instance Method Summary collapse

Methods included from ShallowRouteHelper

#assignment_path, #assignments_path, #convert_work_path, #edit_adjustment_path, #edit_invoice_path, #edit_work_path, #invoice_path, #invoices_path, #line_item_path, #merge_works_path, #new_adjustment_path, #new_assignment_path, #new_invoice_path, #new_payment_path, #payments_path, #work_path

Instance Method Details

#createObject



13
14
15
16
17
18
19
20
21
# File 'app/controllers/eboshi/adjustments_controller.rb', line 13

def create
  @adjustment = @client.adjustments.build params[:adjustment]
  if @adjustment.save
    flash[:notice] = "Adjustment successfully created."
    redirect_to invoices_path(@client)
  else
    render :new
  end
end

#destroyObject



40
41
42
43
44
45
46
47
# File 'app/controllers/eboshi/adjustments_controller.rb', line 40

def destroy
  get_adjustment
  @adjustment.destroy
  respond_to do |wants|
    wants.html { redirect_to invoices_path(@client) }
    wants.js { render json: @adjustment.invoice_total }
  end
end

#editObject



23
24
25
# File 'app/controllers/eboshi/adjustments_controller.rb', line 23

def edit
  get_adjustment
end

#newObject



9
10
11
# File 'app/controllers/eboshi/adjustments_controller.rb', line 9

def new
  @adjustment = @client.adjustments.build
end

#updateObject



27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/controllers/eboshi/adjustments_controller.rb', line 27

def update
  get_adjustment
  if @adjustment.update params[:adjustment]
    flash[:notice] = "Successfully updated Adjustment."
    respond_to do |wants|
      wants.html { redirect_to invoices_path(@client) }
      wants.js { head :ok }
    end
  else
    render :edit
  end
end