| 1234567891011121314151617181920212223242526272829303132333435363738 |
- 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.nil? ? (detail.product.price_base * detail.quantity) : 0
- end
- total
- end
- def pre_sale_haggle_type(pre_sale)
- type = !pre_sale.haggle.zero? ? number_to_currency(pre_sale.haggle, precision: 2) : "#{pre_sale.haggle_percent}%"
- content_tag(:i, "", { class: "fa fa-question-circle tooltips font-blue", title: "Se aplicó #{type} de regateo" })
- end
- end
|