internetee/registry

View on GitHub
app/views/admin/invoices/index.haml

Summary

Maintainability
Test Coverage
- content_for :actions do
  = link_to(t(:add), new_admin_invoice_path, class: 'btn btn-primary')
= render 'shared/title', name: t(:invoices)
= render 'admin/invoices/partials/search_form'

.row
  .col-md-12
    .table-responsive
      %table.table.table-hover.table-bordered.table-condensed
        %thead
          %tr
            %th{class: 'col-xs-3'}
              = sort_link(@q, :number)
            %th{class: 'col-xs-3'}
              = sort_link(@q, :buyer_name, "Buyer")
            %th{class: 'col-xs-3'}
              = sort_link(@q, :sort_due_date, "Due date")
            %th{class: 'col-xs-3'}
              = sort_link(@q, :sort_receipt_date, "Receipt date")
        %tbody
          - @invoices.each do |invoice|
            %tr
              %td= link_to(invoice, [:admin, invoice])
              %td= link_to(invoice.buyer_name, admin_registrar_path(invoice.buyer_id))
              - if invoice.cancelled?
                %td.text-grey= t(:cancelled)
              - else
                %td= l invoice.due_date

              - if invoice.paid?
                %td= l invoice.receipt_date
              - elsif invoice.cancelled?
                %td.text-grey= t(:cancelled)
              - elsif invoice.monthly_invoice
                %td= l invoice.issue_date
              - else
                %td.text-danger= t(:unpaid)

.row
  .col-md-6
    = paginate @invoices
  .col-md-6.text-right
    .pagination
      = t(:result_count, count: @q.result.count)