Sha256: cec8cd5c089fe6c544d6352103767911f2dbe85fd895a8c012ee3589b6197ee8

Contents?: true

Size: 1.07 KB

Versions: 76

Compression:

Stored size: 1.07 KB

Contents

module Comee
  module Core
    class BackOrdersController < ApplicationController
      include Common
      before_action :set_object, only: %i[show update submit]

      def index
        super do
          Comee::Core::BackOrder.includes(:back_order_items, :supplier)
        end
      end

      def submit
        ActiveRecord::Base.transaction do
          @obj.submit
          Comee::Core::BackOrderNotification.with(back_order: @obj).deliver(@obj.supplier.user)
          render json: {success: true, data: serialize(@obj.reload)}
        end
      rescue StandardError => e
        render json: {success: false, error: e.message}
      end

      def filter
        query = Comee::Core::BackOrder.ransack(params[:q])
        render json: {success: true, data: serialize(query.result.includes(:back_order_items, :supplier))}
      end

      def model_params
        params.require(:payload).permit(:order_number, :order_date, :delivery_date, :supplier_id, :terms,
                                        :delivery_address, :invoice_address, :status, :remark)
      end
    end
  end
end

Version data entries

76 entries across 76 versions & 1 rubygems

Version Path
comee_core-0.1.39 app/controllers/comee/core/back_orders_controller.rb
comee_core-0.1.38 app/controllers/comee/core/back_orders_controller.rb
comee_core-0.1.37 app/controllers/comee/core/back_orders_controller.rb
comee_core-0.1.36 app/controllers/comee/core/back_orders_controller.rb
comee_core-0.1.35 app/controllers/comee/core/back_orders_controller.rb
comee_core-0.1.34 app/controllers/comee/core/back_orders_controller.rb
comee_core-0.1.33 app/controllers/comee/core/back_orders_controller.rb
comee_core-0.1.32 app/controllers/comee/core/back_orders_controller.rb
comee_core-0.1.31 app/controllers/comee/core/back_orders_controller.rb
comee_core-0.1.30 app/controllers/comee/core/back_orders_controller.rb
comee_core-0.1.29 app/controllers/comee/core/back_orders_controller.rb
comee_core-0.1.28 app/controllers/comee/core/back_orders_controller.rb
comee_core-0.1.27 app/controllers/comee/core/back_orders_controller.rb
comee_core-0.1.26 app/controllers/comee/core/back_orders_controller.rb
comee_core-0.1.25 app/controllers/comee/core/back_orders_controller.rb
comee_core-0.1.24 app/controllers/comee/core/back_orders_controller.rb