Overview shows coming due and the last flight; intervals in days, months or years

- Overview: "Coming due" (next 30 days or 10 hours) and "Last flight" (the
  most recent day's legs, meters at the end, fuel and oil left).
- Component replace / TBO / inspect intervals, inspection types and ADs take
  a number and a days / months / years choice (CalendarInterval). Components
  gain month columns (years stored as 12 months; months land on the same
  date); inspection types and ADs keep end-of-month. ADs now honour days.
- Due list: hours already run out count as overdue; a component covered by
  an inspection type no longer gets its own "Inspect every" item.
- Loading calculator moved to a partial; no limit warnings until a load is
  entered. Header buttons don't wrap on phones.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rickyandClaude Opus 5.5 committed 2026-11-11 21:40:14 -05:00
1 parent 215efe6814
commit 31ac991bab
37 files changed
+385 -75

No files matched your search

+6 -1
View File
@@ -1,10 +1,15 @@
class Component < ApplicationRecord
include Versioned
include CalendarInterval
STATUSES = { "SPARE" => "Spare Part", "IN-USE" => "In Service", "DISPOSED" => "Disposed" }.freeze
# What "since overhaul" counts from, and how logbooks abbreviate it.
OVERHAUL_KINDS = { "major" => "Major overhaul", "factory_overhaul" => "Factory overhaul", "factory_new" => "Factory new or rebuilt (zero time)" }.freeze
OVERHAUL_ABBREVIATIONS = { "major" => "SMOH", "factory_overhaul" => "SFOH", "factory_new" => "SNEW" }.freeze
calendar_interval :replacement, days: :replacement_days, months: :replacement_months
calendar_interval :tbo, days: :tbo_days, months: :tbo_months
calendar_interval :inspection, days: :inspection_days, months: :inspection_months
belongs_to :aircraft, optional: true
belongs_to :parent_component, class_name: "Component", optional: true
belongs_to :component_type
@@ -66,7 +71,7 @@ class Component < ApplicationRecord
def expired?(today = Date.current) = expires_on.present? && today > expires_on
def next_replacement_date
overhaul_date + replacement_days.days if replacement_days && overhaul_date
replacement_after(overhaul_date)
end
# :overdue / :due_soon / :ok / nil (not tracked) for display on the components tab.