Class: DebitInvoicesController
- Inherits:
-
InvoicesController
- Object
- InheritedResources::Base
- AuthorizedController
- InvoicesController
- DebitInvoicesController
- Defined in:
- app/controllers/debit_invoices_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
-
#new ⇒ Object
Actions.
Methods inherited from InvoicesController
Methods inherited from AuthorizedController
Instance Method Details
#create ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'app/controllers/debit_invoices_controller.rb', line 29 def create invoice_params = { :state => 'booked' } invoice_params.merge!(params[:debit_invoice]) if params[:debit_invoice] @debit_invoice = DebitInvoice.new(invoice_params) if @debit_invoice.save @debit_invoice.build_booking.save end create! end |
#new ⇒ Object
Actions
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/controllers/debit_invoices_controller.rb', line 3 def new # Allow pre-seeding some parameters invoice_params = { :company_id => current_tenant.company.id, :value_date => Date.today, :due_date => Date.today.in(30.days).to_date, :title => "Rechnung " + Date.today.strftime('%B') } # Set default parameters invoice_params.merge!(params[:invoice]) if params[:invoice] @debit_invoice = DebitInvoice.new(invoice_params) @debit_invoice.line_items.build( :quantity => 1, :price => @debit_invoice.amount, :vat_rate => 'vat:full' ) # Prebuild an empty attachment instance @debit_invoice..build new! end |