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? @credit_notes = Sale.where('payment_status = ?', Sale::SALE_STATUS_OUTSTANDING) @credit_notes = Kaminari.paginate_array(@credit_notes).page(params[:page]).per(20) else sale = Sale.search_credit_sales(customer,filter,from,to) if sale.count > 0 @credit_notes = sale @credit_notes = Kaminari.paginate_array(@credit_notes).page(params[:page]).per(20) else @credit_notes = 0 end end puts "sssssssssssss" puts @credit_notes.to_json respond_to do |format| format.html # index.html.erb format.json { render json: @credit_notes } end end end