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

json.customer_debiting do
	@debiting = @customer.credits.activos.sum(:rest)
	json.customer_debiting @debiting
end

json.available_credit do
	json.available_credit @customer.credit_limit - @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
