Combine the labor settings into Labor products/services

The estimate item codes and "Replaced by imported time" become one list of products/services
(RedmineQboBilling::LaborItems), used to create issues from an estimate's labor lines (and an
appointment's minimum hours), to offer an invoice's labor lines to be replaced by imported time, and
to total the hours on estimates and invoices for the business report. While none are chosen,
products/services named Labor are used. The old settings and redmine_qbo_calendar's fallbacks are no
longer read.

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 08:22:32 -04:00
1 parent 616ee13725
commit 4732c32409
12 files changed
+120 -83

No files matched your search

+1 -1
View File
@@ -27,7 +27,7 @@ class EstimateSyncService < SyncServiceBase
map_attributes :doc_number, :txn_date
map_attribute :total_amount, :total
# Man-hours: quantities of the products/services set as "Replaced by imported time"
# Man-hours: quantities of the labor products/services (plugin settings)
map_attribute(:hours) { |remote| RedmineQboBilling::ManHours.hours(remote) }
map_belongs_to :customer
+1 -1
View File
@@ -24,7 +24,7 @@ class InvoiceSyncService < SyncServiceBase
map_attributes :balance, :doc_number, :due_date, :txn_date
map_attribute :total_amount, :total
# Man-hours: quantities of the products/services set as "Replaced by imported time"
# Man-hours: quantities of the labor products/services (plugin settings)
map_attribute(:hours) { |remote| RedmineQboBilling::ManHours.hours(remote) }
map_attribute :qbo_updated_at, "meta_data.last_updated_time"
map_belongs_to :customer
+8 -12
View File
@@ -5,26 +5,22 @@
min: 0, step: 1, size: 6 %>
<em class="info"><%= l(:text_estimate_expiration_days) %></em>
</p>
<%# Labor: issues from estimates, lines imported time replaces on invoices, and hours for the business report.
While none are chosen, items named "Labor" are used and shown selected. %>
<p>
<label for="settings_replaceable_item_ids"><%= l(:label_replaceable_items) %></label>
<%= hidden_field_tag 'settings[replaceable_item_ids][]', '', id: nil %>
<%= select_tag 'settings[replaceable_item_ids][]',
<label for="settings_labor_item_ids"><%= l(:label_labor_items) %></label>
<%= hidden_field_tag 'settings[labor_item_ids][]', '', id: nil %>
<%= select_tag 'settings[labor_item_ids][]',
options_from_collection_for_select(Item.where(active: true).order(:name), :id, :name,
Array(@settings['replaceable_item_ids']).map(&:to_s)),
multiple: true, size: 8, id: 'settings_replaceable_item_ids' %>
<em class="info"><%= l(:text_replaceable_items) %></em>
RedmineQboBilling::LaborItems.item_ids),
multiple: true, size: 8, id: 'settings_labor_item_ids' %>
<em class="info"><%= l(:text_labor_items) %></em>
</p>
</div>
<%# Issues from estimates (moved from redmine_qbo_calendar; its old values are shown until these are saved) %>
<% issue_builder = RedmineQboBilling::EstimateIssueBuilder %>
<fieldset class="box tabular">
<legend><%= l(:label_estimate_issue_settings) %></legend>
<p>
<label for="settings_issue_item_codes"><%= l(:label_estimate_item_codes) %></label>
<%= text_area_tag 'settings[issue_item_codes]', issue_builder.item_codes.join("\n"), rows: 5, cols: 30, id: 'settings_issue_item_codes' %>
<em class="info"><%= l(:text_estimate_item_codes_info) %></em>
</p>
<p>
<label for="settings_issue_default_project_id"><%= l(:label_default_project) %></label>
<%= select_tag 'settings[issue_default_project_id]',
+1 -1
View File
@@ -26,7 +26,7 @@
data: {
document: form.document,
import_url: (import_options_qbo_invoices_path if invoice),
replaceable_item_ids: (RedmineQboBilling::InvoiceWriter.replaceable_item_ids if invoice),
labor_item_ids: (RedmineQboBilling::LaborItems.item_ids if invoice),
items_url: items_qbo_estimates_path,
customer_info_url: customer_info_qbo_estimates_path,
saved_subtotal: (form.persisted? ? form.subtotal.to_s('F') : ''),
+3 -3
View File
@@ -414,9 +414,9 @@ $(function () {
};
// The invoice's lines, for ticking the ones the time replaces (e.g. the estimate's labor lines).
// When products/services are set as replaceable by time in the plugin settings, only lines with one of
// them are offered; with none set, every line is.
var replaceable = ($form.data('replaceableItemIds') || []).map(String);
// Only lines with one of the labor products/services (plugin settings) are offered; if none are known,
// every line is.
var replaceable = ($form.data('laborItemIds') || []).map(String);
var fillReplaceList = function () {
var $list = $('#qbo-import-replace').empty();
rows().each(function () {
@@ -45,7 +45,7 @@
<% if proposals.empty? %>
<p class="nodata">
<%= l(:error_no_labor_lines_found) %>
(<%= l(:label_estimate_item_codes) %>: <%= RedmineQboBilling::EstimateIssueBuilder.item_codes.join(', ') %>)
(<%= l(:label_labor_items) %>: <%= RedmineQboBilling::LaborItems.names.join(', ') %>)
<% if User.current.admin? %>
&middot; <%= link_to l(:label_settings), plugin_settings_path(id: 'redmine_qbo') %>
<% end %>