json.extract! @customer, :id, :nick_name, :credit ,:credit_limit, :created_at, :updated_at, :status

	json.customer_debiting do
		debiting = 0

		 @customer.credits.activos.each do |credit|
		 	debiting = debiting + credit.rest
		 end

		json.customer_debiting debiting
	end

	json.customer_payment do
		payment = CreditPayment.where(:customer_id => @customer.id).order("date_payment DESC").first
		if !payment.blank?
			json.customer_payment payment.date_payment.strftime("%d/%m/%Y")
		end
	end