Sha256: 976a8d8686d21a17c1360c04fd40410638f1f9f6261b7f6a58e676ed879ec64e

Contents?: true

Size: 1.41 KB

Versions: 35

Compression:

Stored size: 1.41 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,
                :quantity,
                :price,
                :total_price,
                :delivery_date,
                :canceled,
                :product_id,
                :customer_order_id,
                :unit_id
              )
      end
    end
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
comee_core-0.3.33 app/controllers/comee/core/customer_order_items_controller.rb
comee_core-0.3.32 app/controllers/comee/core/customer_order_items_controller.rb
comee_core-0.3.31 app/controllers/comee/core/customer_order_items_controller.rb
comee_core-0.3.30 app/controllers/comee/core/customer_order_items_controller.rb
comee_core-0.3.29 app/controllers/comee/core/customer_order_items_controller.rb
comee_core-0.3.28 app/controllers/comee/core/customer_order_items_controller.rb
comee_core-0.3.27 app/controllers/comee/core/customer_order_items_controller.rb
comee_core-0.3.26 app/controllers/comee/core/customer_order_items_controller.rb
comee_core-0.3.25 app/controllers/comee/core/customer_order_items_controller.rb
comee_core-0.3.24 app/controllers/comee/core/customer_order_items_controller.rb
comee_core-0.3.23 app/controllers/comee/core/customer_order_items_controller.rb
comee_core-0.3.22 app/controllers/comee/core/customer_order_items_controller.rb
comee_core-0.3.21 app/controllers/comee/core/customer_order_items_controller.rb
comee_core-0.3.20 app/controllers/comee/core/customer_order_items_controller.rb
comee_core-0.3.19 app/controllers/comee/core/customer_order_items_controller.rb
comee_core-0.3.18 app/controllers/comee/core/customer_order_items_controller.rb
comee_core-0.3.17 app/controllers/comee/core/customer_order_items_controller.rb
comee_core-0.3.16 app/controllers/comee/core/customer_order_items_controller.rb
comee_core-0.3.15 app/controllers/comee/core/customer_order_items_controller.rb
comee_core-0.3.14 app/controllers/comee/core/customer_order_items_controller.rb