mirror of
https://github.com/rickbarrette/redmine_qbo_calendar.git
synced 2026-11-17 21:50:37 -05:00
Relate issues created together from an estimate
Every issue created in one batch from the estimate preview is now
related ("Related to") to every other issue in that batch. Relations
are added without journals, so no history entries or update emails
are generated; a relation that fails is logged and doesn't block
issue creation.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BiwYMjhoQvL7XsKKfRz4pM
This commit is contained in:
2 files changed
+19
-2
No files matched your search
@@ -104,7 +104,7 @@ en:
|
||||
permission_view_customer_appointments: "View customer appointments"
|
||||
text_default_tracker_info: "Pre-selected for each proposed issue. Leave blank to use the project's first tracker."
|
||||
text_estimate_issue_fields_info: "Entered once and applied to every created issue whose tracker uses the field. Fields marked * are required by the selected trackers."
|
||||
text_estimate_issues_hint: "The subject comes from the estimate line's description and estimated hours from its quantity. Edit anything before creating."
|
||||
text_estimate_issues_template_hint: "The subject comes from the estimate line's description and estimated hours from its quantity. A template supplies the issue's description."
|
||||
text_estimate_issues_hint: "The subject comes from the estimate line's description and estimated hours from its quantity. Edit anything before creating. Issues created together are related to each other."
|
||||
text_estimate_issues_template_hint: "The subject comes from the estimate line's description and estimated hours from its quantity. A template supplies the issue's description. Issues created together are related to each other."
|
||||
text_estimate_item_codes_info: "QBO item names that can become issues, one per line (e.g. Labor, Alignments). Matches the full item name or any part of a Category:Item name, ignoring case."
|
||||
title_customer_appointments: Customer Appointments
|
||||
@@ -16,6 +16,7 @@ module RedmineQboCalendar
|
||||
# - Subject = the line's description; estimated hours = the line's quantity
|
||||
# - Lines already turned into issues are shown but can't be created again
|
||||
# - Creation is all-or-nothing: if any issue fails validation, none are saved
|
||||
# - Issues created together are all related to each other
|
||||
class EstimateIssueBuilder
|
||||
include Redmine::I18n
|
||||
|
||||
@@ -105,6 +106,8 @@ module RedmineQboCalendar
|
||||
issue: issue
|
||||
)
|
||||
end
|
||||
|
||||
relate_issues(built.map(&:last))
|
||||
end
|
||||
|
||||
@errors.any? ? [] : built.map(&:last)
|
||||
@@ -154,6 +157,20 @@ module RedmineQboCalendar
|
||||
key.to_s
|
||||
end
|
||||
|
||||
# Relates every issue in the batch to every other one ("Related to"), since they're work on the
|
||||
# same estimate done at the same time. New issues have no open journal, so this adds no history
|
||||
# entries and sends no "issue updated" emails. A failed relation is logged, not fatal.
|
||||
def relate_issues(issues)
|
||||
issues.combination(2).each do |issue_from, issue_to|
|
||||
relation = IssueRelation.new(issue_from: issue_from, issue_to: issue_to,
|
||||
relation_type: IssueRelation::TYPE_RELATES)
|
||||
next if relation.save
|
||||
|
||||
Rails.logger.warn "[EstimateIssueBuilder] Could not relate ##{issue_from.id} and ##{issue_to.id}: " \
|
||||
"#{relation.errors.full_messages.join(', ')}"
|
||||
end
|
||||
end
|
||||
|
||||
def build_issue(proposal, row, project, author, allowed_trackers, custom_field_values)
|
||||
issue = Issue.new(project: project, author: author)
|
||||
issue.tracker = allowed_trackers.detect { |t| t.id == row['tracker_id'].to_i }
|
||||
|
||||
Reference in new issue
Block a user