Sha256: b16bcd90e710c8acc3a25e56d6341067200e438b057bab1d4c786c6a3fa395f3
Contents?: true
Size: 1.32 KB
Versions: 10
Compression:
Stored size: 1.32 KB
Contents
module Comee module Core class ClientPricesController < ApplicationController include Comee::Core::Common def index super do client_prices = Comee::Core::ClientPrice.all client_prices.then(&paginate) end end def fetch_for_client client = Comee::Core::Client.find(params[:id]) client_id = client.parent_id || client.id prices = Comee::Core::ClientPrice.includes(:client, :product, :unit, :product_lookup) .where(client_id: client_id) total = prices.count prices = prices.then(&paginate) render json: {success: true, data: serialize(prices), page: params[:page], total: total} end def filter prices = Comee::Core::ClientPrice.includes(:client, :product, :unit, :product_lookup) .ransack(params[:q]).result total = prices.count prices = prices.then(&paginate) render json: {success: true, data: serialize(prices), page: params[:page], total: total} end private def model_params params.require(:payload).permit(:valid_from, :valid_to, :price, :product_id, :margin, :margin_type, :client_id, :previous_price, :unit_id) end end end end
Version data entries
10 entries across 10 versions & 1 rubygems