Sha256: c31c952d9408850565970fd9b81a4614a2a73a8cb09c6503cac8a08f74d48bae

Contents?: true

Size: 1.44 KB

Versions: 18

Compression:

Stored size: 1.44 KB

Contents

module Comee
  module Core
    class SalesOrderItemsController < ApplicationController
      include Common

      def index
        super do
          SalesOrderItem.includes(
            :sales_order,
            :customer_order_item,
            :source,
            :product,
            :unit
          ).where(sales_order_id: params[:id])
        end
      end

      def suggest_values
        service = CustomerOrderService.new
        result = service.suggest_values(params[:id], suggest_params[:unit_id])
        render json: {success: true, data: result}
      end

      def cancel
        item = set_object
        item.update(canceled: true)
        render_content(item)
      end

      def activate
        item = set_object
        item.update(canceled: false)
        render_content(item)
      end

      def destroy
        Comee::Core::SalesOrderItem.destroy(params[:id])
        render json: {success: true}
      end

      private

      def suggest_params
        params.permit(:unit_id, :quantity)
      end

      def model_params
        params.require(:payload).permit(:sales_order_id, :customer_order_item_id, :product_id, :unit_id, :quantity, :quantity_delivered,
                                        :customer_item_no, :customer_item_description, :price, :handover_date, :delivery_date,
                                        :eb_number, :lead_time, :comment, :action_note, :po_reference, :pallet_no, :source_id)
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
comee_core-0.2.34 app/controllers/comee/core/sales_order_items_controller.rb
comee_core-0.2.33 app/controllers/comee/core/sales_order_items_controller.rb
comee_core-0.2.32 app/controllers/comee/core/sales_order_items_controller.rb
comee_core-0.2.31 app/controllers/comee/core/sales_order_items_controller.rb
comee_core-0.2.30 app/controllers/comee/core/sales_order_items_controller.rb
comee_core-0.2.29 app/controllers/comee/core/sales_order_items_controller.rb
comee_core-0.2.28 app/controllers/comee/core/sales_order_items_controller.rb
comee_core-0.2.27 app/controllers/comee/core/sales_order_items_controller.rb
comee_core-0.2.26 app/controllers/comee/core/sales_order_items_controller.rb
comee_core-0.2.25 app/controllers/comee/core/sales_order_items_controller.rb
comee_core-0.2.24 app/controllers/comee/core/sales_order_items_controller.rb
comee_core-0.2.23 app/controllers/comee/core/sales_order_items_controller.rb
comee_core-0.2.22 app/controllers/comee/core/sales_order_items_controller.rb
comee_core-0.2.21 app/controllers/comee/core/sales_order_items_controller.rb
comee_core-0.2.20 app/controllers/comee/core/sales_order_items_controller.rb
comee_core-0.2.19 app/controllers/comee/core/sales_order_items_controller.rb
comee_core-0.2.18 app/controllers/comee/core/sales_order_items_controller.rb
comee_core-0.2.17 app/controllers/comee/core/sales_order_items_controller.rb