foodsoft/app/views/finance/ordergroups/_ordergroups.html.haml
Philipp Rothmann cb6070c33c
All checks were successful
continuous-integration/drone/push Build is passing
feat(finance): show sum of ordergroup balances
2023-02-20 10:20:44 +01:00

33 lines
No EOL
1.4 KiB
Text

- if Ordergroup.count > 20
= items_per_page
= pagination_links_remote @ordergroups
%table.table.table-striped
%thead
%tr
%th= sort_link_helper heading_helper(Ordergroup, :name), "name", :per_page => @per_page
%th= heading_helper Ordergroup, :contact
- FinancialTransactionClass.sorted.each do |c|
- name = FinancialTransactionClass.has_multiple_classes ? c.display : heading_helper(Ordergroup, :account_balance)
%th.numeric= sort_link_helper name, "sum_of_class_#{c.id}"
%th
%tbody
- for ordergroup in @ordergroups
%tr
%td= ordergroup.name
%td= ordergroup.contact
- FinancialTransactionClass.sorted.each do |c|
- amount = ordergroup["sum_of_class_#{c.id}"]
%td.numeric
= format_currency amount
%td
= link_to t('.new_transaction'), new_finance_ordergroup_transaction_path(ordergroup), class: 'btn btn-mini'
= link_to t('.account_statement'), finance_ordergroup_transactions_path(ordergroup), class: 'btn btn-mini'
%thead
%tr
%th= t 'Total'
%th
- FinancialTransactionClass.sorted.each do |c|
- name = FinancialTransactionClass.has_multiple_classes ? c.display : heading_helper(Ordergroup, :account_balance)
%th.numeric= format_currency @total_balances[c.id]
%th.numeric
= format_currency @total_balances.values.reduce(:+)