mirror of
https://github.com/rickbarrette/redmine_qbo.git
synced 2026-11-17 18:20:36 -05:00
Cost performance index on the business report
CPI = invoiced hours / spent hours, for the period and for each month, colour-coded: green at 1.00 or more, yellow below 1, red below 0.80. It replaces the invoiced-vs-spent percentage (the same figure). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BiwYMjhoQvL7XsKKfRz4pM
This commit is contained in:
4 files changed
+45
-3
No files matched your search
@@ -142,7 +142,7 @@ Estimates and invoices keep their number, date, customer, total and **man-hours*
|
||||
**Business report** in the top menu compares, for a period (this or last month, quarter or year, or custom dates):
|
||||
|
||||
* **Sales**: estimates written, invoices written and payments received (totals and counts), invoiced vs. estimated, collected vs. invoiced, and what's still owed on those invoices.
|
||||
* **Hours**: estimated hours on estimates, issues' estimated time, invoiced hours on invoices and time spent, with invoiced vs. spent and spent vs. estimated.
|
||||
* **Hours**: estimated hours on estimates, issues' estimated time, invoiced hours on invoices and time spent, with spent vs. estimated, and the **cost performance index** (CPI = invoiced hours ÷ spent hours): green at 1.00 or more, yellow below 1, red below 0.80. Each month shows its CPI too.
|
||||
* **By month**: every figure month by month, with totals.
|
||||
|
||||
Estimates, invoices and payments count by their QuickBooks date. Issues' estimated time counts issues created in the period, leaving out parents so subtasks aren't counted twice. Spent time counts time logged in the period. While estimates, invoices or payments are syncing, the report says so (with how many have been read) and refreshes every 30 seconds; the settings page's Synchronization table shows the same per type. Estimates and invoices synced before these figures were added have no total or hours until a full sync (the report says how many); run one again after changing the labor products/services.
|
||||
|
||||
@@ -91,8 +91,16 @@
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<% cpi_badge = lambda do |cpi|
|
||||
level = RedmineQboBilling::BusinessReport.cpi_level(cpi)
|
||||
content_tag(:span, cpi.nil? ? '–' : format('%.2f', cpi), class: "qbo-cpi qbo-cpi-#{level || 'none'}")
|
||||
end %>
|
||||
<p class="qbo-report-cpi">
|
||||
<span class="qbo-cpi-label" title="<%= l(:text_report_cpi) %>"><%= l(:label_report_cpi) %></span>
|
||||
<%= cpi_badge.call(@report.cpi) %>
|
||||
<em class="info"><%= l(:text_report_cpi) %></em>
|
||||
</p>
|
||||
<p class="qbo-report-ratios">
|
||||
<%= l(:label_report_invoiced_of_spent) %>: <strong><%= pct.call(ratios[:invoiced_of_spent]) %></strong><br />
|
||||
<%= l(:label_report_spent_of_estimated) %>: <strong><%= pct.call(ratios[:spent_of_estimated]) %></strong>
|
||||
</p>
|
||||
</div>
|
||||
@@ -111,6 +119,7 @@
|
||||
<th><%= l(:label_report_issue_hours) %></th>
|
||||
<th><%= l(:label_report_invoice_hours) %></th>
|
||||
<th><%= l(:label_report_spent_hours) %></th>
|
||||
<th class="cpi"><%= l(:label_report_cpi_short) %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -124,6 +133,7 @@
|
||||
<td><%= fmt_hours.call(row[:issue_hours]) %></td>
|
||||
<td><%= fmt_hours.call(row[:invoice_hours]) %></td>
|
||||
<td><%= fmt_hours.call(row[:spent_hours]) %></td>
|
||||
<td class="cpi"><%= cpi_badge.call(RedmineQboBilling::BusinessReport.cpi(row[:invoice_hours], row[:spent_hours])) %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
@@ -137,6 +147,7 @@
|
||||
<td><strong><%= fmt_hours.call(hours[:issue_hours]) %></strong></td>
|
||||
<td><strong><%= fmt_hours.call(hours[:invoice_hours]) %></strong></td>
|
||||
<td><strong><%= fmt_hours.call(hours[:spent_hours]) %></strong></td>
|
||||
<td class="cpi"><%= cpi_badge.call(@report.cpi) %></td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
@@ -154,6 +165,15 @@
|
||||
.qbo-bar-payments, .qbo-bar-spent_hours { background: #5aa05a; }
|
||||
.qbo-bar-issue_hours { background: #9b7fc0; }
|
||||
.qbo-report-ratios { margin: 8px 4px; line-height: 1.7; }
|
||||
.qbo-report-cpi { margin: 10px 4px 4px; }
|
||||
.qbo-report-cpi .qbo-cpi-label { font-weight: 600; margin-right: 6px; }
|
||||
.qbo-report-cpi .qbo-cpi { font-size: 1.3em; padding: 3px 12px; }
|
||||
.qbo-report-cpi em.info { display: block; margin-top: 4px; }
|
||||
.qbo-cpi { display: inline-block; font-weight: 700; padding: 1px 8px; border-radius: 10px; background: #eceef1; color: #393a3d; }
|
||||
.qbo-cpi-poor { background: #fdecea; color: #b71c1c; }
|
||||
.qbo-cpi-under { background: #fff4d6; color: #8a6100; }
|
||||
.qbo-cpi-good { background: #e6f4e4; color: #108000; }
|
||||
table.qbo-report-months td.cpi, table.qbo-report-months th.cpi { text-align: center; }
|
||||
.qbo-report-range { color: #666; margin: 4px 0 10px; }
|
||||
.qbo-report-syncing ul { display: inline-block; text-align: left; margin: 6px 0 0; }
|
||||
table.qbo-report-months td, table.qbo-report-months th { text-align: right; white-space: nowrap; }
|
||||
|
||||
@@ -326,7 +326,9 @@ en:
|
||||
label_report_invoiced_of_estimated: "Invoiced vs. estimated"
|
||||
label_report_collected_of_invoiced: "Collected vs. invoiced"
|
||||
label_report_open_balance: "Still owed on these invoices"
|
||||
label_report_invoiced_of_spent: "Invoiced vs. spent hours"
|
||||
label_report_cpi: "Cost performance index (CPI)"
|
||||
label_report_cpi_short: "CPI"
|
||||
text_report_cpi: "Invoiced hours ÷ spent hours. 1.00 or more (green): every hour worked was billed; below 1 (yellow): some time wasn't billed; below 0.80 (red): a fifth or more wasn't."
|
||||
label_report_spent_of_estimated: "Spent vs. issues' estimated hours"
|
||||
text_report_syncing: "QuickBooks is still syncing, so these figures are incomplete until it finishes. This page refreshes every 30 seconds."
|
||||
text_qbo_sync_running: "syncing, %{count} read so far (started %{time})"
|
||||
|
||||
@@ -79,6 +79,26 @@ module RedmineQboBilling
|
||||
}
|
||||
end
|
||||
|
||||
# Cost performance index: invoiced hours / spent hours (e.g. 0.85), or nil without spent time. Below
|
||||
# CPI_WARNING (0.8) is poor, below 1 is under, 1 or more is on or over (more billed than worked).
|
||||
CPI_WARNING = 0.8
|
||||
|
||||
def self.cpi(invoice_hours, spent_hours)
|
||||
spent = spent_hours.to_f
|
||||
spent.positive? ? (invoice_hours.to_f / spent).round(2) : nil
|
||||
end
|
||||
|
||||
# :poor (below 0.8), :under (below 1) or :good (1 or more); nil without a CPI
|
||||
def self.cpi_level(cpi)
|
||||
return nil if cpi.nil?
|
||||
return :poor if cpi < CPI_WARNING
|
||||
cpi < 1 ? :under : :good
|
||||
end
|
||||
|
||||
def cpi
|
||||
self.class.cpi(hours[:invoice_hours], hours[:spent_hours])
|
||||
end
|
||||
|
||||
# Percentages comparing the figures (nil when there's nothing to compare against)
|
||||
def ratios
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user