sales_helper.rb 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. module SalesHelper
  2. def sale_type(sale)
  3. case sale.saletype
  4. when "cash" then
  5. "Contado"
  6. when "credit" then
  7. sale.credit_note.present? ? "Crédito/Vale" : "Crédito"
  8. when "reserved" then
  9. "Apartado"
  10. end
  11. end
  12. def sale_status(sale)
  13. case sale.status
  14. when "paid" then
  15. content_tag(:span, "PAGADA", class: "label label-success")
  16. when "cancelled" then
  17. content_tag(:span, "CANCELADA", class: "label label-danger")
  18. when "parcial" then
  19. content_tag(:span, "ABONADA", class: "label label-warning")
  20. when "notpaid" then
  21. content_tag(:span, "PAGO PENDIENTE", class: "label label-default")
  22. end
  23. end
  24. def sale_utility(details)
  25. total = 0
  26. details.each do |detail|
  27. total += !detail.product.price_base.nil? ? (detail.product.price_base * detail.quantity) : 0
  28. end
  29. total
  30. end
  31. def pre_sale_haggle_type(pre_sale)
  32. type = !pre_sale.haggle.zero? ? number_to_currency(pre_sale.haggle, precision: 2) : "#{pre_sale.haggle_percent}%"
  33. content_tag(:i, "", { class: "fa fa-question-circle tooltips font-blue", title: "Se aplicó #{type} de regateo" })
  34. end
  35. end