Sha256: 862bc7bec21f574bd01244d94fb8810becd699a4fb5fea91649bff51d473a94e

Contents?: true

Size: 1.48 KB

Versions: 28

Compression:

Stored size: 1.48 KB

Contents

module Comee
  module Core
    class CustomerOrderItemsController < ApplicationController
      include Common

      def index
        super do
          [
            CustomerOrderItem.includes(:product, :unit).all,
            include: ["unit"]
          ]
        end
      end

      def cancel
        CustomerOrderItem.where(id: params[:ids]).update_all(canceled: true)
        render json: {success: true}
      end

      def filter
        data = CustomerOrderItem.includes(:product, :unit)
                                .ransack(params[:q])
                                .result
        render_content(data, {include: ["unit"]})
      end

      def destroy
        item = CustomerOrderItem.find(params[:id])

        if item.customer_order.draft?
          item.destroy
          render json: {success: true}
        else
          render json: {success: false, error: "Customer order should be in draft state."}, status: :forbidden
        end
      end

      private

      def model_params
        params.require(:payload)
              .permit(
                :serial_no,
                :customer_item_no,
                :customer_item_description,
                :customer_item_alias,
                :quantity,
                :price,
                :total_price,
                :delivery_date,
                :canceled,
                :product_id,
                :customer_order_id,
                :unit_id,
                :use_alias
              )
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
comee_core-0.3.62 app/controllers/comee/core/customer_order_items_controller.rb
comee_core-0.3.61 app/controllers/comee/core/customer_order_items_controller.rb
comee_core-0.3.60 app/controllers/comee/core/customer_order_items_controller.rb
comee_core-0.3.59 app/controllers/comee/core/customer_order_items_controller.rb
comee_core-0.3.58 app/controllers/comee/core/customer_order_items_controller.rb
comee_core-0.3.57 app/controllers/comee/core/customer_order_items_controller.rb
comee_core-0.3.56 app/controllers/comee/core/customer_order_items_controller.rb
comee_core-0.3.55 app/controllers/comee/core/customer_order_items_controller.rb
comee_core-0.3.54 app/controllers/comee/core/customer_order_items_controller.rb
comee_core-0.3.53 app/controllers/comee/core/customer_order_items_controller.rb
comee_core-0.3.51 app/controllers/comee/core/customer_order_items_controller.rb
comee_core-0.3.50 app/controllers/comee/core/customer_order_items_controller.rb
comee_core-0.3.49 app/controllers/comee/core/customer_order_items_controller.rb
comee_core-0.3.48 app/controllers/comee/core/customer_order_items_controller.rb
comee_core-0.3.47 app/controllers/comee/core/customer_order_items_controller.rb
comee_core-0.3.46 app/controllers/comee/core/customer_order_items_controller.rb
comee_core-0.3.45 app/controllers/comee/core/customer_order_items_controller.rb
comee_core-0.3.44 app/controllers/comee/core/customer_order_items_controller.rb
comee_core-0.3.43 app/controllers/comee/core/customer_order_items_controller.rb
comee_core-0.3.42 app/controllers/comee/core/customer_order_items_controller.rb