!!! 5 %html %head %title Balances Report = wicked_pdf_stylesheet_link_tag 'pdf' %body - if [:summary, :both].include?(statement_type) %table.table %thead %tr %th.caption.text-muted Category %th.caption.text-muted.text-right Oustanding %th.caption.text-muted.text-right Unallocated %tbody - subcategories.each do |subcategory| - outstanding = total_by_subcategory[:outstanding][subcategory.id] - unallocated = total_by_subcategory[:unallocated][subcategory.id] - next if outstanding.zero? && unallocated.zero? %tr %td.caption= subcategory.decorate.title %td.caption.text-right= number_to_currency(outstanding) %td.caption.text-right= number_to_currency(unallocated) %tr %td.caption.font-weight-bold.text-right Total %td.caption.font-weight-bold.text-right = number_to_currency(total_by_subcategory[:totals][:outstanding]) %td.caption.font-weight-bold.text-right = number_to_currency(total_by_subcategory[:totals][:unallocated]) - if [:details, :both].include?(statement_type) - if group_by == :family %table.table %thead %tr %th %th.caption.text-muted Category %th.caption.text-muted.text-right Oustanding %th.caption.text-muted.text-right Unallocated %tbody - families.each do |family| - outstanding_total = group_by_totals[:outstanding][family.id][:total] - unallocated_total = group_by_totals[:unallocated][family.id][:total] - next if outstanding_total.zero? && unallocated_total.zero? %tr %td.caption{ colspan: 4 }= family.name - subcategories.each do |subcategory| - outstanding = group_by_totals[:outstanding][family.id][subcategory.id] - unallocated = group_by_totals[:unallocated][family.id][subcategory.id] - next if outstanding.zero? && unallocated.zero? %tr %td %td.caption= subcategory.decorate.title %td.caption.text-right= number_to_currency(outstanding) %td.caption.text-right= number_to_currency(unallocated) %tr %td.caption.font-weight-bold.text-right{ colspan: 2 } Total %td.caption.font-weight-bold.text-right= number_to_currency(outstanding_total) %td.caption.font-weight-bold.text-right= number_to_currency(unallocated_total) - else %table.table %thead %tr %th %th.caption.text-muted Family %th.caption.text-muted.text-right Oustanding %th.caption.text-muted.text-right Unallocated %tbody - subcategories.each do |subcategory| - outstanding_total = group_by_totals[:outstanding][subcategory.id][:total] - unallocated_total = group_by_totals[:unallocated][subcategory.id][:total] - next if outstanding_total.zero? && unallocated_total.zero? %tr %td.caption{ colspan: 4 }= subcategory.decorate.title - families.each do |family| - outstanding = group_by_totals[:outstanding][subcategory.id][family.id] - unallocated = group_by_totals[:unallocated][subcategory.id][family.id] - next if outstanding.zero? && unallocated.zero? %tr %td %td.caption= family.name %td.caption.text-right= number_to_currency(outstanding) %td.caption.text-right= number_to_currency(unallocated) %tr %td.caption.font-weight-bold.text-right{ colspan: 2 } Total %td.caption.font-weight-bold.text-right= number_to_currency(outstanding_total) %td.caption.font-weight-bold.text-right= number_to_currency(unallocated_total)