armandofox/audience1st

View on GitHub
app/views/txns/index.html.haml

Summary

Maintainability
Test Coverage
%h2= @header

- unless @txns.empty?
  %br
  .pagination-container
    .pagination
      = will_paginate @txns,:previous_label => '«', :next_label => '»', :container => false
      = form_tag txns_path, :method => :get do
         •  
        %b #{@txns.offset+1}-#{@txns.offset+@txns.length}
        of 
        %b #{@txns.total_entries}
         •  Jump to page:
        = text_field_tag 'page', '', :size => 4
        = hidden_field_tag 'txn_filter', @txn_filter
        = submit_tag 'Go', :class => 'btn btn-outline-primary btn-sm'

  %br
  %table.a1-table
    %tr.tableHeading
      - ["Date", "Proc'd by", "Customer", "Txn Type", "Purch.method", "Amt", "Show", "Perf date", "Voucher ID", "Comments"].each do |c|
        %th= c
    - @txns.each do |t|
      - c = Customer.find_by_id(t.customer_id)  
      - s = Customer.find_by_id(t.entered_by_id)
      - v = Voucher.find_by_id(t.voucher_id)
      %tr
        %td= t.txn_date
        %td= staff_name(s)
        %td= link_to_customer(c)
        %td= t.desc 
        %td= Purchasemethod.get(v.order.purchasemethod).description if v && t.is_purchase?
        %td= number_to_currency(t.dollar_amount) if t.is_purchase?
        %td= t.show.try(:name)
        %td= t.showdate.try(:thedate)
        %td= t.voucher_id 
        %td= t.comments