Show when a QuickBooks sync is running

Syncs record their state in a new qbo_sync_statuses table: queued when asked for, running with how
many records have been read, removed when finished (stale rows are ignored after 6 hours). The
business report says when estimates, invoices or payments are still syncing and refreshes every 30
seconds until they finish; the settings page's Synchronization table shows the same per type.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BiwYMjhoQvL7XsKKfRz4pM
This commit is contained in:
Claude committed 2026-10-31 10:03:12 -04:00
1 parent bf7c7b0905
commit 28538d4c7f
11 files changed
+158 -4

No files matched your search

+12 -1
View File
@@ -45,6 +45,7 @@
[l(:label_items), Item, sync_items_path, items_path],
[l(:label_accounts), Account, sync_accounts_path, accounts_path]
] %>
<% sync_statuses = QboSyncStatus.by_entity %>
<h3><%= l(:label_management_and_sync) %></h3>
<div class="box">
<table class="list qbo-sync-table">
@@ -61,7 +62,16 @@
<tr>
<td class="name"><%= list_path ? link_to(label, list_path) : label %></td>
<td class="count"><%= model.count %></td>
<td class="updated"><%= model.last_sync %></td>
<td class="updated">
<% status = sync_statuses[model.name] %>
<% if status&.running? %>
<span class="icon icon-reload qbo-sync-busy"><%= l(:text_qbo_sync_running_short, count: number_with_delimiter(status.processed)) %></span>
<% elsif status %>
<span class="qbo-sync-busy"><%= l(:text_qbo_sync_queued) %></span>
<% else %>
<%= model.last_sync %>
<% end %>
</td>
<td class="buttons"><%= link_to sprite_icon('reload', l(:label_sync)), sync_path, class: 'icon icon-reload' %></td>
</tr>
<% end %>
@@ -88,6 +98,7 @@
table.qbo-sync-table td.updated { width: 14em; }
table.qbo-sync-table td.buttons { width: 6em; }
.qbo-sync-all .button { margin-left: 8px; }
.qbo-sync-busy { font-style: italic; color: #b06d00; }
</style>
<%# Billing: estimates, issues from estimates and invoices %>
+25
View File
@@ -27,6 +27,30 @@
<p class="qbo-report-range"><%= format_date(@report.from) %> &ndash; <%= format_date(@report.to) %></p>
<% if Array(@syncing).any? %>
<% sync_labels = { 'Estimate' => l(:label_estimates), 'Invoice' => l(:label_invoices), 'Payment' => l(:label_payments) } %>
<div class="warning qbo-report-syncing">
<%= l(:text_report_syncing) %>
<ul>
<% @syncing.each do |status| %>
<li>
<strong><%= sync_labels[status.entity] || status.entity %></strong>:
<% if status.running? %>
<%= l(:text_qbo_sync_running, count: number_with_delimiter(status.processed),
time: format_time(status.started_at)) %>
<% else %>
<%= l(:text_qbo_sync_queued) %>
<% end %>
</li>
<% end %>
</ul>
</div>
<%= javascript_tag do %>
// Refresh while QuickBooks is syncing, so the figures fill in
setTimeout(function () { window.location.reload(); }, 30000);
<% end %>
<% end %>
<% if @report.unsynced_count > 0 %>
<p class="warning"><%= l(:text_report_needs_sync, count: @report.unsynced_count) %></p>
<% end %>
@@ -131,6 +155,7 @@
.qbo-bar-issue_hours { background: #9b7fc0; }
.qbo-report-ratios { margin: 8px 4px; line-height: 1.7; }
.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; }
table.qbo-report-months .month { text-align: left; }
table.qbo-report-months .hours-start { border-left: 2px solid #ddd; }