Class: InvoiceBar::ReceiptTemplatesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- InvoiceBar::ReceiptTemplatesController
- Defined in:
- app/controllers/invoice_bar/receipt_templates_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
POST /receipt_templates/1 POST /receipt_templates/1.json.
-
#destroy ⇒ Object
DELETE /receipt_templates/1 DELETE /receipt_templates/1.json.
-
#edit ⇒ Object
GET /invoice_receipts/1/edit.
-
#index ⇒ Object
GET /receipt_templates GET /receipt_templates.json.
-
#new ⇒ Object
GET /receipt_templates/new.
-
#show ⇒ Object
GET /receipt_templates/1 GET /receipt_templates/1.json.
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
POST /receipt_templates/1 POST /receipt_templates/1.json
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'app/controllers/invoice_bar/receipt_templates_controller.rb', line 37 def create flash[:notice], flash[:alert] = nil, nil @receipt_template = ReceiptTemplate.new(receipt_template_params) fill_in_contact if params[:fill_in_contact] if params[:tax_id] if (@receipt_template.load_contact_from_tax_id(@receipt_template.contact_tax_id)) flash[:notice] = I18n.t('messages.tax_id_loaded') else flash[:alert] = I18n.t('messages.cannot_load_tax_id') end end if params[:fill_in_contact] || params[:tax_id] respond_on_new @receipt_template else current_user.receipt_templates << @receipt_template respond_on_create @receipt_template end end |
#destroy ⇒ Object
DELETE /receipt_templates/1 DELETE /receipt_templates/1.json
88 89 90 91 |
# File 'app/controllers/invoice_bar/receipt_templates_controller.rb', line 88 def destroy @receipt_template.destroy respond_on_destroy @receipt_template, receipt_templates_url end |
#edit ⇒ Object
GET /invoice_receipts/1/edit
61 62 63 64 |
# File 'app/controllers/invoice_bar/receipt_templates_controller.rb', line 61 def edit @receipt_template.build_address unless @receipt_template.address respond_on_edit @receipt_template end |
#index ⇒ Object
GET /receipt_templates GET /receipt_templates.json
10 11 12 13 |
# File 'app/controllers/invoice_bar/receipt_templates_controller.rb', line 10 def index @receipt_templates = current_user.receipt_templates.page(params[:page]) respond_on_index @receipt_templates end |
#new ⇒ Object
GET /receipt_templates/new
28 29 30 31 32 33 |
# File 'app/controllers/invoice_bar/receipt_templates_controller.rb', line 28 def new @receipt_template = ReceiptTemplate.new @receipt_template.items.build @receipt_template.build_address respond_on_new @receipt_template end |
#show ⇒ Object
GET /receipt_templates/1 GET /receipt_templates/1.json
17 18 19 20 21 22 23 24 25 |
# File 'app/controllers/invoice_bar/receipt_templates_controller.rb', line 17 def show @address = @receipt_template.address unless @receipt_template.account_id or current_user.accounts @account = current_user.accounts.find(@receipt_template.account_id) end respond_on_show @receipt_template end |
#update ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'app/controllers/invoice_bar/receipt_templates_controller.rb', line 66 def update flash[:notice], flash[:alert] = nil, nil fill_in_contact if params[:fill_in_contact] if params[:tax_id] if (@receipt_template.load_contact_from_tax_id(@receipt_template.contact_tax_id)) flash[:notice] = I18n.t('messages.tax_id_loaded') else flash[:alert] = I18n.t('messages.cannot_load_tax_id') end end if params[:fill_in_contact] || params[:tax_id] respond_on_edit @receipt_template else respond_on_update @receipt_template, receipt_template_params end end |