transfers_helper.rb 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. module TransfersHelper
  2. def transfer_status(transfer)
  3. case transfer.status
  4. when "cancelled" then
  5. content_tag(:span, "CANCELADO", class: "label label-danger", style: "font-size:85%")
  6. when "pending" then
  7. content_tag(:span, "PENDIENTE DE RECEPCIÓN", class: "label label-warning", style: "font-size:85%")
  8. when "received" then
  9. content_tag(:span, "RECIBIDO", class: "label label-info", style: "font-size:85%")
  10. end
  11. end
  12. def transfer_details(transfer)
  13. transfer_detail = transfer.transfer_details
  14. has_looses = transfer_detail.where(has_looses: true)
  15. has_surplus = transfer_detail.where(has_surplus: true)
  16. if !has_looses.blank? && has_surplus.blank? # has loses but not surplus
  17. content_tag(:span, "CON PÉRDIDAS", class: "label label-warning", style: "font-size:85%")
  18. elsif !has_surplus.blank? && has_looses.blank? # has surplus but not loses
  19. content_tag(:span, "CON EXCEDENTE", class: "label label-warning", style: "font-size:85%")
  20. elsif !has_surplus.blank? && !has_looses.blank? # has surplus and loses
  21. content_tag(:span, "CON INCONSISTENCIAS", class: "label label-danger", style: "font-size:85%")
  22. elsif transfer.received?
  23. content_tag(:i, "", class: "fa fa-check fa-2 font-green")
  24. end
  25. end
  26. def transfer_details_status(detail)
  27. if detail.has_looses?
  28. content_tag(:span, "Con pérdidas", class: "label label-warning", style: "font-size:85%")
  29. elsif detail.has_surplus?
  30. content_tag(:span, "Con excedente", class: "label label-warning", style: "font-size:85%")
  31. else
  32. content_tag(:i, "", class: "fa fa-check fa-2 font-green")
  33. end
  34. end
  35. end