Sub-components on logbook entries (e.g. the oil filter on the engine)

- Once a component is chosen, its sub-components are offered on the entry
  form (and the squawk Resolve page); ticked ones are saved with their
  total time and time since service, worked out from the airframe total
  time like the component's (editable; blank before it was installed)
- Entry page and printed PDFs list each sub-component with its serial
  number and times; parts without an overhaul type read "Since service"
- Archives carry them: the original format's list of components per entry
  (first = the entry's component, the rest = sub-components)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rickyandClaude Opus 5.5 committed 2026-11-07 12:54:49 -05:00
1 parent 72e1d7760f
commit 7caa213e7a
16 files changed
+249 -22

No files matched your search

+15 -1
View File
@@ -15,6 +15,7 @@ class Component < ApplicationRecord
has_many :inspection_records, dependent: :nullify
has_many :major_records, dependent: :nullify
has_many :logbook_entries, dependent: :nullify
has_many :logbook_entry_parts, dependent: :destroy
has_and_belongs_to_many :inspection_types
has_and_belongs_to_many :airworthiness_directives
@@ -30,7 +31,20 @@ class Component < ApplicationRecord
end
def status_label = STATUSES[status]
def since_overhaul_abbreviation = OVERHAUL_ABBREVIATIONS.fetch(overhaul_kind, "TSO")
# SMOH / SFOH / SNEW when the overhaul type is known; engines and
# propellers otherwise "TSO", and other parts (filters…) "since service".
def since_overhaul_abbreviation
OVERHAUL_ABBREVIATIONS.fetch(overhaul_kind) { engine? || propeller? ? "TSO" : "Since service" }
end
# Its sub-components, and theirs.
def descendant_ids
child_components.flat_map { [ _1.id, *_1.descendant_ids ] }
end
def ancestor_ids
parent_component ? [ parent_component_id, *parent_component.ancestor_ids ] : []
end
def engine? = component_type&.name.to_s.match?(/engine/i)
def propeller? = component_type&.name.to_s.match?(/propell?er|\bprop\b/i)