<commit_before>- if @md

  Payments collected by 
  = select :name => "payment[received_by]", :collection => staff_members_collection, :selected => @center.manager.id.to_s, :id => 'payments_received_by'

  %table.report.nojs
    %thead
      %tr{:style => "font-size: 0.85em;"}
        %th name
        %th id
        %th amount
        %th outstanding
        %th disbursed on
        %th installment
        %th principal due
        %th interest due
        %th total due
        %th paid
        %th repayment type
        %th attendance
          
    %tbody{:style => "text-align:left;" }
      - @branch||=@center.branch
      - tot_amount, tot_outstanding, tot_installments, tot_principal, tot_interest, tot_fees, tot_total = 0, 0, 0, 0, 0, 0, 0
      - clients = Client.all(:center_id => @center.id, :fields => [:id, :name, :client_group_id, :center_id])
      - atts = Attendance.all(:client_id => clients.map{|x| x.id}, :date => @date).map{|x| [x.client_id,x]}.to_hash
      - loans = @loans||Loan.all(:client_id => clients.map{|x| x.id})
      - histories = LoanHistory.all(:loan_id => loans.map{|x| x.id}, :date => @date)
      - clients.group_by{|x| x.client_group}.sort_by{|x| x[0] ? x[0].name : "none"}.each do |group, clients_grouped|
        %tr.group
          %td{:colspan => 12}
            =group ? group.name : "none"
        -clients_grouped.sort_by{|x| x.name}.each do |client|
          - loan_row_count = 0
          - loans.find_all{|l| l.client_id == client.id and l.disbursal_date}.each do |loan|
            - lh = histories.find_all{|x| x.loan_id==loan.id}.sort_by{|x| x.created_at}[-1]
            - next if not lh
            - next if LOANS_NOT_PAYABLE.include? lh.status
            - loan_row_count += 1
            %tr{ :class => cycle('odd','') }
              %td.text
                %b= link_to client.name, resource(@branch, @center, client)
              %td.number
                = loan.id
              %td.number
                - amt = loan.amount
                %b= amt.to_currency
                - tot_amount += amt
              %td.number
                - p = lh.nil? ? 0 : lh.actual_outstanding_principal
                %b= p.to_currency
                - tot_outstanding += p
              %td.text
                = loan.disbursal_date.to_s
              %td.number
                - ins = loan.number_of_installments_before(@date)
                = ins
                - tot_installments += ins
              %td.number
                - p = lh.nil? ? 0 : [lh.principal_due, 0].max.round(2)
                = p.to_currency
                - tot_principal += p
              %td.number
                - i = lh.nil? ? 0 : [lh.interest_due,0].max.round(2)
                = i.to_currency
                - tot_interest += i
              %td.number
                - a = p + i
                = a.to_currency
                - tot_total += a
              %td.number
                = text_field :name => "paid[loan][#{loan.id}]", :value => [a,0].max.round(2), :cols => "5", :style => "width:50px;" 
              %td 
                = select :name => "payment_style[#{loan.id}]", :collection => [["prorata","pro rata"],["normal","fees=>int=>prin"]]
              %td
                - att = atts[client.id]
                = select :name => "attendance[#{client.id}]", :collection => Attendance.attendancy_states, :value_method => :to_s, :selected => (att ? att.status.to_s : "present")
          - if loan_row_count == 0
            %tr{ :class => cycle('odd','') }
              %td.text
                %b= link_to client.name, resource(@branch, @center, client)
              %td{ :colspan => 10 }
                %i nothing outstanding
              %td
                - att = atts[client.id]
                = select :name => "attendance[#{client.id}]", :collection => Attendance.attendancy_states, :value_method => :to_s, :selected => (att ? att.status.to_s : "present")<commit_msg>Fixed payment rounded figures in form<commit_after>- if @md

  Payments collected by 
  = select :name => "payment[received_by]", :collection => staff_members_collection, :selected => @center.manager.id.to_s, :id => 'payments_received_by'

  %table.report.nojs
    %thead
      %tr{:style => "font-size: 0.85em;"}
        %th name
        %th id
        %th amount
        %th outstanding
        %th disbursed on
        %th installment
        %th principal due
        %th interest due
        %th total due
        %th paid
        %th repayment type
        %th attendance
          
    %tbody{:style => "text-align:left;" }
      - @branch||=@center.branch
      - tot_amount, tot_outstanding, tot_installments, tot_principal, tot_interest, tot_fees, tot_total = 0, 0, 0, 0, 0, 0, 0
      - clients = Client.all(:center_id => @center.id, :fields => [:id, :name, :client_group_id, :center_id])
      - atts = Attendance.all(:client_id => clients.map{|x| x.id}, :date => @date).map{|x| [x.client_id,x]}.to_hash
      - loans = @loans||Loan.all(:client_id => clients.map{|x| x.id})
      - histories = LoanHistory.all(:loan_id => loans.map{|x| x.id}, :date => @date)
      - clients.group_by{|x| x.client_group}.sort_by{|x| x[0] ? x[0].name : "none"}.each do |group, clients_grouped|
        %tr.group
          %td{:colspan => 12}
            =group ? group.name : "none"
        -clients_grouped.sort_by{|x| x.name}.each do |client|
          - loan_row_count = 0
          - loans.find_all{|l| l.client_id == client.id and l.disbursal_date}.each do |loan|
            - lh = histories.find_all{|x| x.loan_id==loan.id}.sort_by{|x| x.created_at}[-1]
            - next if not lh
            - next if LOANS_NOT_PAYABLE.include? lh.status
            - loan_row_count += 1
            %tr{ :class => cycle('odd','') }
              %td.text
                %b= link_to client.name, resource(@branch, @center, client)
              %td.number
                = loan.id
              %td.number
                - amt = loan.amount
                %b= amt.to_currency
                - tot_amount += amt
              %td.number
                - p = lh.nil? ? 0 : lh.actual_outstanding_principal
                %b= p.to_currency
                - tot_outstanding += p
              %td.text
                = loan.disbursal_date.to_s
              %td.number
                - ins = loan.number_of_installments_before(@date)
                = ins
                - tot_installments += ins
              %td.number
                - p = lh.nil? ? 0 : [lh.principal_due, 0].max
                = p.round(2)
                - tot_principal += p
              %td.number
                - i = lh.nil? ? 0 : [lh.interest_due,0].max
                = i.round(2)
                - tot_interest += i
              %td.number
                - a = p + i
                = a.round(2)
                - tot_total += a
              %td.number
                = text_field :name => "paid[loan][#{loan.id}]", :value => [a,0].max.round(2), :cols => "5", :style => "width:50px;" 
              %td 
                = select :name => "payment_style[#{loan.id}]", :collection => [["prorata","pro rata"],["normal","fees=>int=>prin"]]
              %td
                - att = atts[client.id]
                = select :name => "attendance[#{client.id}]", :collection => Attendance.attendancy_states, :value_method => :to_s, :selected => (att ? att.status.to_s : "present")
          - if loan_row_count == 0
            %tr{ :class => cycle('odd','') }
              %td.text
                %b= link_to client.name, resource(@branch, @center, client)
              %td{ :colspan => 10 }
                %i nothing outstanding
              %td
                - att = atts[client.id]
                = select :name => "attendance[#{client.id}]", :collection => Attendance.attendancy_states, :value_method => :to_s, :selected => (att ? att.status.to_s : "present")
{'fraction_non_alphanumeric': 0.14938599822762375, 'fraction_numerical': 0.00822888973287758, 'mean_word_length': 1.6671168129642133, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 69, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7140206', 'n_tokens_mistral': 2667, 'n_tokens_neox': 2522, 'n_words': 516}