% html_title l(:label_business_report) %> <% money = @report.money %> <% hours = @report.hours %> <% ratios = @report.ratios %> <% max_money = [money[:estimates][:total], money[:invoices][:total], money[:payments][:total]].max.to_f %> <% max_hours = hours.values.max.to_f %> <% bar = ->(value, max) { max > 0 ? (value.to_f / max * 100).round(1) : 0 } %> <% fmt_hours = ->(h) { format('%.1f', h.to_f) } %> <% pct = ->(v) { v.nil? ? '–' : "#{v}%" } %>
<%= format_date(@report.from) %> – <%= format_date(@report.to) %>
<% if Array(@syncing).any? %> <% sync_labels = { 'Estimate' => l(:label_estimates), 'Invoice' => l(:label_invoices), 'Payment' => l(:label_payments) } %><%= l(:text_report_needs_sync, count: @report.unsynced_count) %>
<% end %>| <%= label %> (<%= money[key][:count] %>) | <%= number_to_currency(money[key][:total]) %> |
<%= l(:label_report_invoiced_of_estimated) %>: <%= pct.call(ratios[:invoiced_of_estimated]) %>
<%= l(:label_report_collected_of_invoiced) %>: <%= pct.call(ratios[:collected_of_invoiced]) %>
<%= l(:label_report_open_balance) %>: <%= number_to_currency(money[:invoices][:balance]) %>
| <%= label %> | <%= fmt_hours.call(hours[key]) %> |
<%= l(:label_report_cpi) %> <%= cpi_badge.call(@report.cpi) %> <%= l(:text_report_cpi) %>
<%= l(:label_report_spent_of_estimated) %>: <%= pct.call(ratios[:spent_of_estimated]) %>
| <%= l(:label_month) %> | <%= l(:label_report_estimates_written) %> | <%= l(:label_report_invoices_written) %> | <%= l(:label_report_payments_received) %> | <%= l(:label_report_estimate_hours) %> | <%= l(:label_report_issue_hours) %> | <%= l(:label_report_invoice_hours) %> | <%= l(:label_report_spent_hours) %> | <%= l(:label_report_cpi_short) %> |
|---|---|---|---|---|---|---|---|---|
| <%= ::I18n.t('date.abbr_month_names')[row[:month].month] %> <%= row[:month].year %> | <%= number_to_currency(row[:estimates]) %> | <%= number_to_currency(row[:invoices]) %> | <%= number_to_currency(row[:payments]) %> | <%= fmt_hours.call(row[:estimate_hours]) %> | <%= fmt_hours.call(row[:issue_hours]) %> | <%= fmt_hours.call(row[:invoice_hours]) %> | <%= fmt_hours.call(row[:spent_hours]) %> | <%= cpi_badge.call(RedmineQboBilling::BusinessReport.cpi(row[:invoice_hours], row[:spent_hours])) %> |
| <%= l(:label_total) %> | <%= number_to_currency(money[:estimates][:total]) %> | <%= number_to_currency(money[:invoices][:total]) %> | <%= number_to_currency(money[:payments][:total]) %> | <%= fmt_hours.call(hours[:estimate_hours]) %> | <%= fmt_hours.call(hours[:issue_hours]) %> | <%= fmt_hours.call(hours[:invoice_hours]) %> | <%= fmt_hours.call(hours[:spent_hours]) %> | <%= cpi_badge.call(@report.cpi) %> |
<%= l(:text_report_notes) %>
<%= javascript_tag do %> $(function() { var $period = $('#qbo-report-period'), $dates = $('#qbo-report-from, #qbo-report-to'); // Picking a preset fills its dates on Apply; changing a date switches to Custom $dates.on('change', function() { $period.val('custom'); }); $period.on('change', function() { if ($period.val() !== 'custom') { $('#qbo-report-form').submit(); } }); }); <% end %>