Sha256: e1717bea4aaa2b6dbcd768e0ad5574ba88ca39ea0b61e5a904a890e24e1b40aa

Contents?: true

Size: 1.42 KB

Versions: 1

Compression:

Stored size: 1.42 KB

Contents

module Comee
  module Core
    class SalesOrdersController < ApplicationController
      include Common
      before_action :set_object, only: %i[show update confirm cancel]

      def confirm
        @obj.confirm
        render json: {success: true, data: serialize(@obj.reload)}
      rescue StandardError => e
        render json: {success: false, error: e.message}
      end

      def cancel
        @obj.cancel
        render json: {success: true, data: serialize(@obj.reload)}
      rescue StandardError => e
        render json: {success: false, error: e.message}
      end

      def index
        super do
          Comee::Core::SalesOrder.includes(:sales_order_items).all
        end
      end

      def filter
        @sales_order = Comee::Core::SalesOrder.ransack(params[:q]).result
        render json: {success: true, data: serialize(@sales_order)}
      end

      private

      def model_params
        params.require(:payload).permit(:order_number, :customer_order_id, :payment_penalty, :status,
                                        :total_price, :amount_paid, :pallete_note, :handover_date, :remark)
      end

      def back_order_params
        params.permit(payload: [:supplier_id, :order_number, :order_date, :delivery_date, :delivery_address, :invoice_address,
                                back_order_items: %i[product_id requested_quantity requested_price supplier_quantity delivery_date]])
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
comee_core-0.1.41 app/controllers/comee/core/sales_orders_controller.rb