Class: Eboshi::InvoicesController
Instance Method Summary
collapse
#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
#create ⇒ Object
29
30
31
32
33
34
35
36
37
|
# File 'app/controllers/eboshi/invoices_controller.rb', line 29
def create
@invoice = @client.invoices.build
@invoice.attributes = params[:invoice]
if @invoice.save
redirect_to invoices_path(@client), notice: "Invoice successfully created."
else
render :new
end
end
|
#destroy ⇒ Object
52
53
54
55
56
|
# File 'app/controllers/eboshi/invoices_controller.rb', line 52
def destroy
@invoice = @client.invoices.find(params[:id])
@invoice.destroy
redirect_to invoices_path(@client)
end
|
#edit ⇒ Object
39
40
41
|
# File 'app/controllers/eboshi/invoices_controller.rb', line 39
def edit
@invoice = @client.invoices.find(params[:id])
end
|
#index ⇒ Object
5
6
7
8
9
10
11
12
|
# File 'app/controllers/eboshi/invoices_controller.rb', line 5
def index
@invoices = @client.invoices_with_unbilled
current_user.update_attribute(:last_client, @client)
respond_to do |wants|
wants.html
wants.js { render @client.invoices.paid }
end
end
|
#new ⇒ Object
25
26
27
|
# File 'app/controllers/eboshi/invoices_controller.rb', line 25
def new
@invoice = @client.build_invoice_from_unbilled(params[:line_item_ids])
end
|
#show ⇒ Object
14
15
16
17
18
19
20
21
22
23
|
# File 'app/controllers/eboshi/invoices_controller.rb', line 14
def show
@invoice = @client.invoices.find(params[:id])
respond_to do |wants|
wants.html { render partial: params.fetch(:type, "full"), locals: { invoice: @invoice } }
wants.pdf do
filename = "#{current_user.business_name_or_name.parameterize}_invoice-\##{@invoice.id}.pdf"
render pdf: filename, show_as_html: params[:debug].present?
end
end
end
|
#update ⇒ Object
43
44
45
46
47
48
49
50
|
# File 'app/controllers/eboshi/invoices_controller.rb', line 43
def update
@invoice = @client.invoices.find(params[:id])
if @invoice.update(params[:invoice])
redirect_to invoices_path(@client), notice: "Invoice successfully updated."
else
render :edit
end
end
|