class Transactions::CreditNotesController < ApplicationController before_action :set_transactions_sale, only: [:show, :edit, :update, :destroy] # GET /transactions/sales # GET /transactions/sales.json def index @customers = Customer.all filter = params[:filter] customer = params[:customer] from = params[:from] to = params[:to] if filter.nil? && from.nil? && to.nil? && customer.nil? @sales = Sale.where('payment_status = ?', Sale::SALE_STATUS_OUTSTANDING) puts "cccccccccccc" else sale = Sale.search_credit_sales(customer,filter,from,to) if sale.count > 0 @sales = sale @sales = Kaminari.paginate_array(@sales).page(params[:page]).per(50) else @sales = 0 end end respond_to do |format| format.html # index.html.erb format.json { render json: @sales } end end end