Class: Dorsale::BillingMachine::QuotationsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- ApplicationController
- Dorsale::BillingMachine::QuotationsController
- Defined in:
- app/controllers/dorsale/billing_machine/quotations_controller.rb
Instance Method Summary collapse
- #copy ⇒ Object
- #create ⇒ Object
- #create_invoice ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Methods inherited from ApplicationController
Instance Method Details
#copy ⇒ Object
92 93 94 95 96 97 98 99 100 101 |
# File 'app/controllers/dorsale/billing_machine/quotations_controller.rb', line 92 def copy @quotation, :copy? @original = @quotation @quotation = Dorsale::BillingMachine::Quotation::Copy.(@original) flash[:notice] = t("messages.quotations.copy_ok") redirect_to dorsale.edit_billing_machine_quotation_path(@quotation) end |
#create ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'app/controllers/dorsale/billing_machine/quotations_controller.rb', line 35 def create # callback in BillingMachine::ApplicationController @quotation ||= scope.new(quotation_params_for_create) @quotation, :create? if @quotation.save Dorsale::BillingMachine::PdfFileGenerator.(@quotation) flash[:notice] = t("messages.quotations.create_ok") redirect_to default_back_url else render :edit end end |
#create_invoice ⇒ Object
103 104 105 106 107 108 109 110 |
# File 'app/controllers/dorsale/billing_machine/quotations_controller.rb', line 103 def create_invoice @quotation, :read? ::Dorsale::BillingMachine::Invoice, :create? @invoice = Dorsale::BillingMachine::Quotation::ToInvoice.(@quotation) render "dorsale/billing_machine/invoices/new" end |
#destroy ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'app/controllers/dorsale/billing_machine/quotations_controller.rb', line 79 def destroy # callback in BillingMachine::ApplicationController @quotation, :delete? if @quotation.destroy flash[:notice] = t("messages.quotations.update_ok") else flash[:alert] = t("messages.quotations.update_error") end redirect_to url_for(action: :index, id: nil) end |
#edit ⇒ Object
56 57 58 59 60 61 62 63 64 |
# File 'app/controllers/dorsale/billing_machine/quotations_controller.rb', line 56 def edit # callback in BillingMachine::ApplicationController @quotation, :update? if ::Dorsale::BillingMachine.vat_mode == :single @quotation.lines.build(vat_rate: @quotation.vat_rate) if @quotation.lines.empty? else @quotation.lines.build if @quotation.lines.empty? end end |
#index ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/controllers/dorsale/billing_machine/quotations_controller.rb', line 11 def index # callback in BillingMachine::ApplicationController model, :list? @quotations ||= scope.all.preload(:customer) @filters ||= ::Dorsale::BillingMachine::SmallData::FilterForQuotations.new() @quotations = @filters.apply(@quotations) @quotations_without_pagination = @quotations # All filtered quotations (not paginated) @quotations = @quotations.page(params[:page]).per(50) @statistics = ::Dorsale::BillingMachine::Invoice::Statistics.new(@quotations_without_pagination) end |
#new ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'app/controllers/dorsale/billing_machine/quotations_controller.rb', line 25 def new # callback in BillingMachine::ApplicationController @quotation ||= scope.new @quotation.lines.build if @quotation.lines.empty? @quotation.id_card = @id_cards.first if @id_cards.one? @quotation, :create? end |
#show ⇒ Object
50 51 52 53 54 |
# File 'app/controllers/dorsale/billing_machine/quotations_controller.rb', line 50 def show # callback in BillingMachine::ApplicationController @quotation, :read? @quotation, :download? if request.format.pdf? end |
#update ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'app/controllers/dorsale/billing_machine/quotations_controller.rb', line 66 def update # callback in BillingMachine::ApplicationController @quotation, :update? if @quotation.update(quotation_params_for_update) Dorsale::BillingMachine::PdfFileGenerator.(@quotation) flash[:notice] = t("messages.quotations.update_ok") redirect_to default_back_url else render :edit end end |