module SalesHelper def sale_type(sale) case sale.saletype when "cash" then "Contado" when "credit" then sale.credit_note.present? ? "Crédito/Vale" : "Crédito" when "reserved" then "Apartado" end end def sale_status(sale) case sale.status when "paid" then content_tag(:span, "PAGADA", class: "label label-success") when "cancelled" then content_tag(:span, "CANCELADA", class: "label label-danger") when "parcial" then content_tag(:span, "ABONADA", class: "label label-warning") when "notpaid" then content_tag(:span, "PAGO PENDIENTE", class: "label label-default") end end def sale_utility(details) total = 0 details.each do |detail| total += (detail.product.price_base * detail.quantity) end total end end