module TransfersHelper def transfer_status(transfer) case transfer.status when "cancelled" then content_tag(:span, "CANCELADO", class: "label label-danger", style: "font-size:85%") when "pending" then content_tag(:span, "PENDIENTE DE RECEPCIÓN", class: "label label-warning", style: "font-size:85%") when "received" then content_tag(:span, "RECIBIDO", class: "label label-info", style: "font-size:85%") end end def transfer_details(transfer) transfer_detail = transfer.transfer_details has_looses = transfer_detail.where(has_looses: true) has_surplus = transfer_detail.where(has_surplus: true) if !has_looses.blank? && has_surplus.blank? # has loses but not surplus content_tag(:span, "CON PÉRDIDAS", class: "label label-warning", style: "font-size:85%") elsif !has_surplus.blank? && has_looses.blank? # has surplus but not loses content_tag(:span, "CON EXCEDENTE", class: "label label-warning", style: "font-size:85%") elsif !has_surplus.blank? && !has_looses.blank? # has surplus and loses content_tag(:span, "CON INCONSISTENCIAS", class: "label label-danger", style: "font-size:85%") elsif transfer.received? content_tag(:i, "", class: "fa fa-check fa-2 font-green") end end def transfer_details_status(detail) if detail.has_looses? content_tag(:span, "Con pérdidas", class: "label label-warning", style: "font-size:85%") elsif detail.has_surplus? content_tag(:span, "Con excedente", class: "label label-warning", style: "font-size:85%") else content_tag(:i, "", class: "fa fa-check fa-2 font-green") end end end