internetee/registry

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

Summary

Maintainability
Test Coverage
= render 'shared/title', name: t(:account_activities)
= render 'search_form'

.row
  .col-md-3
  .col-md-3
  .col-md-2
  .col-md-4{class: 'text-right'}
    = t(:starting_balance)  + " #{@sum.to_f} EUR"

%hr

.row
  .col-md-12
    .table-responsive
      %table.table.table-hover.table-condensed
        %thead
          %tr
            %th{class: 'col-xs-2'}
              = sort_link(@q, 'account_registrar_code', t(:registrar_name))
            %th{class: 'col-xs-3'}
              = sort_link(@q, 'description')
            %th{class: 'col-xs-2'}
              = sort_link(@q, 'activity_type')
            %th{class: 'col-xs-3'}
              = sort_link(@q, 'created_at', AccountActivity.human_attribute_name(:created_at))
            %th{class: 'col-xs-2'}
              = sort_link(@q, 'sum')
        %tbody
          -total = @sum.to_f
          - @account_activities.each do |x|
            %tr
              %td= x.account.registrar && link_to(x.account.registrar.try(:code), admin_registrar_path(x.account.registrar))
              %td= x.description.present? ? x.description : '-'
              %td= x.activity_type ? t(x.activity_type) : ''
              %td= l(x.created_at)
              - c = x.sum > 0.0 ? 'text-success' : 'text-danger'
              - s = x.sum > 0.0 ? "+#{x.sum} #{x.currency}" : "#{x.sum} #{x.currency}"
              -total += x.sum
              %td{class: c}= s
        - if @account_activities.count > 0
          %tr
            %td
            %td
            %td
            %td{class: 'text-right'}= t(:total)
            %td{class: total > 0 ? 'text-success' : 'text-danger'}= total > 0 ? "+#{total} EUR" : "#{total} EUR"
.row
  .col-md-6
    = paginate @account_activities
  .col-md-6.text-right
    .pagination
      = t(:result_count, count: @count)