Sha256: c53b5b3860353d53c95aec42113c0d330e65f03a0e7196d8f7958e4c1c18b206

Contents?: true

Size: 1.37 KB

Versions: 36

Compression:

Stored size: 1.37 KB

Contents

class Dorsale::BillingMachine::PaymentTermsController < ::Dorsale::BillingMachine::ApplicationController
  before_action :set_objects, only: [:edit, :update]

  def index
    authorize model, :list?

    @payment_terms ||= scope.all
  end

  def new
    @payment_term ||= scope.new

    authorize @payment_term, :create?
  end

  def create
    @payment_term ||= scope.new(payment_term_params_for_create)

    authorize @payment_term, :create?
    if @payment_term.save

      flash[:notice] = t("payment_terms.create_ok")
      redirect_to back_url
    else
      render action: :new
    end
  end

  def edit
    authorize @payment_term, :update?
  end

  def update
    authorize @payment_term, :update?

    if @payment_term.update(payment_term_params_for_update)
      flash[:notice] = t("payment_terms.update_ok")
      redirect_to back_url
    else
      render action: :edit
    end
  end

  private

  def set_objects
    @payment_term ||= scope.find(params[:id])
  end

  def model
    ::Dorsale::BillingMachine::PaymentTerm
  end

  def back_url
    url_for(action: :index, id: nil)
  end

  def permitted_params
    [
      :label,
    ]
  end

  def payment_term_params
    params.fetch(:billing_machine_payment_term, {}).permit(permitted_params)
  end

  def payment_term_params_for_create
    payment_term_params
  end

  def payment_term_params_for_update
    payment_term_params
  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
dorsale-4.0.0 app/controllers/dorsale/billing_machine/payment_terms_controller.rb
dorsale-3.20.0 app/controllers/dorsale/billing_machine/payment_terms_controller.rb
dorsale-3.19.1 app/controllers/dorsale/billing_machine/payment_terms_controller.rb
dorsale-3.19.0 app/controllers/dorsale/billing_machine/payment_terms_controller.rb
dorsale-3.18.0 app/controllers/dorsale/billing_machine/payment_terms_controller.rb
dorsale-3.17.0 app/controllers/dorsale/billing_machine/payment_terms_controller.rb
dorsale-3.16.0 app/controllers/dorsale/billing_machine/payment_terms_controller.rb
dorsale-3.15.0 app/controllers/dorsale/billing_machine/payment_terms_controller.rb
dorsale-3.14.11 app/controllers/dorsale/billing_machine/payment_terms_controller.rb
dorsale-3.14.10 app/controllers/dorsale/billing_machine/payment_terms_controller.rb
dorsale-3.14.9 app/controllers/dorsale/billing_machine/payment_terms_controller.rb
dorsale-3.14.8 app/controllers/dorsale/billing_machine/payment_terms_controller.rb
dorsale-3.14.7 app/controllers/dorsale/billing_machine/payment_terms_controller.rb
dorsale-3.14.6 app/controllers/dorsale/billing_machine/payment_terms_controller.rb
dorsale-3.14.5 app/controllers/dorsale/billing_machine/payment_terms_controller.rb
dorsale-3.14.4 app/controllers/dorsale/billing_machine/payment_terms_controller.rb
dorsale-3.14.3 app/controllers/dorsale/billing_machine/payment_terms_controller.rb
dorsale-3.14.2 app/controllers/dorsale/billing_machine/payment_terms_controller.rb
dorsale-3.14.1 app/controllers/dorsale/billing_machine/payment_terms_controller.rb
dorsale-3.14.0 app/controllers/dorsale/billing_machine/payment_terms_controller.rb