Sha256: c65393a15b2f3a7d72cddfbd246f41b0aea57fffa262d756e6b1a679480cdd05

Contents?: true

Size: 1.32 KB

Versions: 16

Compression:

Stored size: 1.32 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(
                :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

16 entries across 16 versions & 1 rubygems

Version Path
comee_core-0.2.70 app/controllers/comee/core/customer_order_items_controller.rb
comee_core-0.2.69 app/controllers/comee/core/customer_order_items_controller.rb
comee_core-0.2.68 app/controllers/comee/core/customer_order_items_controller.rb
comee_core-0.2.67 app/controllers/comee/core/customer_order_items_controller.rb
comee_core-0.2.66 app/controllers/comee/core/customer_order_items_controller.rb
comee_core-0.2.65 app/controllers/comee/core/customer_order_items_controller.rb
comee_core-0.2.64 app/controllers/comee/core/customer_order_items_controller.rb
comee_core-0.2.63 app/controllers/comee/core/customer_order_items_controller.rb
comee_core-0.2.62 app/controllers/comee/core/customer_order_items_controller.rb
comee_core-0.2.61 app/controllers/comee/core/customer_order_items_controller.rb
comee_core-0.2.60 app/controllers/comee/core/customer_order_items_controller.rb
comee_core-0.2.59 app/controllers/comee/core/customer_order_items_controller.rb
comee_core-0.2.58 app/controllers/comee/core/customer_order_items_controller.rb
comee_core-0.2.57 app/controllers/comee/core/customer_order_items_controller.rb
comee_core-0.2.56 app/controllers/comee/core/customer_order_items_controller.rb
comee_core-0.2.55 app/controllers/comee/core/customer_order_items_controller.rb