Deferrals, expirations, standard inspections, reminders, squawk fixes

- Squawks: defer an inoperative item under 91.213(d) once each condition
  is confirmed (pilots may too); deferred items stop grounding and are
  listed for awareness. Resolving can record the fix as a logbook entry
  (43.9 fields) or link an existing one
- Expiration dates on components (ELT battery, 91.207(c)) and documents;
  new document types (registration, airworthiness certificate, insurance,
  radio license). Expired replacement-critical parts and an expired
  registration (91.203) ground; others warn; registration warns 90 days out
- Standard inspections: one click adds annual, 100-hour, 91.411, 91.413,
  ELT (91.207(d)) and VOR (91.171) checks with the right rules, skipping
  ones already tracked and linking annual to 100-hour
- Weekly Monday reminder email to owners when something needs attention;
  profile opt-out; admin "send me this week's reminder"
- README feature table updated

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rickyandClaude Opus 5.5 committed 2026-11-07 10:24:33 -05:00
1 parent a4ec7a691e
commit 61c3749793
41 files changed
+649 -48

No files matched your search

+2 -2
View File
@@ -50,7 +50,7 @@ module AircraftArchive
end,
documents: a.documents.map do |d|
{ id: id(d), aircraft_id: id(a), collection_id: id(d.document_collection_id), doc_type: d.doc_type, name: d.name,
description: d.description, visibility: d.visibility, components: [] }
description: d.description, visibility: d.visibility, expires_on: d.expires_on&.iso8601, components: [] }
end,
document_images: a.documents.includes(pages_attachments: :blob).flat_map do |d|
d.pages.map { |page| { id: id(page), document_id: id(d), notes: "", image: file(page, "health/documents") } }
@@ -128,7 +128,7 @@ module AircraftArchive
def component_hash(c)
{ id: id(c), aircraft_id: id(c.aircraft_id), parent_component_id: id(c.parent_component_id), component_type_id: id(c.component_type_id),
manufacturer: c.manufacturer, model: c.model, serial_number: c.serial_number, install_location: c.install_location,
notes: c.notes, status: c.status, date_in_service: c.date_in_service&.iso8601, hours_in_service: dec(c.hours_in_service),
expires_on: c.expires_on&.iso8601, notes: c.notes, status: c.status, date_in_service: c.date_in_service&.iso8601, hours_in_service: dec(c.hours_in_service),
hours_since_overhaul: dec(c.hours_since_overhaul), overhaul_date: c.overhaul_date&.iso8601, tbo_hours: c.tbo_hours,
tbo_days: c.tbo_days, inspection_hours: c.inspection_hours, inspection_days: c.inspection_days,
replacement_hours: c.replacement_hours, replacement_days: c.replacement_days, tbo_critical: c.tbo_critical,
+3 -2
View File
@@ -177,7 +177,7 @@ module AircraftArchive
c = @aircraft.components.new(
component_type_id: type_id, parent_component_id: @map[:component][data["parent_component_id"].to_s],
manufacturer: data["manufacturer"].to_s, model: data["model"].to_s, serial_number: data["serial_number"].to_s,
install_location: data["install_location"].to_s, notes: data["notes"].to_s,
install_location: data["install_location"].to_s, notes: data["notes"].to_s, expires_on: date(data["expires_on"]),
status: Component::STATUSES.key?(data["status"]) ? data["status"] : "SPARE",
date_in_service: date(data["date_in_service"]) || Date.new(1900, 1, 1), hours_in_service: num(data["hours_in_service"]) || 0,
hours_since_overhaul: num(data["hours_since_overhaul"]) || 0, overhaul_date: date(data["overhaul_date"]),
@@ -201,7 +201,8 @@ module AircraftArchive
m("documents").each do |data|
d = @aircraft.documents.new(name: data["name"].to_s.presence || "Untitled", description: data["description"].to_s,
doc_type: data["doc_type"].presence, visibility: visibility(data["visibility"]),
document_collection_id: @map[:collection][data["collection_id"].to_s])
document_collection_id: @map[:collection][data["collection_id"].to_s],
expires_on: date(data["expires_on"]))
d.doc_type = "OTHER" unless Document::TYPES.key?(d.doc_type)
d.save!(validate: false)
@map[:document][data["id"].to_s] = d.id
+39 -7
View File
@@ -15,6 +15,7 @@ class Airworthiness
RED = "RED"
LIMITED = "LIMITED"
INFO = "INFO" # listed for awareness; doesn't change the status (a deferred inoperative item)
ORANGE = "ORANGE"
GREEN = "GREEN"
DISCLAIMER = "Based on the records in this app. Before each flight the pilot in command decides whether the aircraft is airworthy (14 CFR 91.7)."
@@ -52,6 +53,7 @@ class Airworthiness
check_grounding_squawks
check_inspections
check_components
check_documents
status =
if @issues.any? { _1.severity == RED } then RED
@@ -84,9 +86,13 @@ class Airworthiness
end
def check_grounding_squawks
@aircraft.squawks.active.where(priority: 0).find_each do |squawk|
@aircraft.squawks.active.where(priority: 0, deferred_at: nil).find_each do |squawk|
add("SQUAWK", RED, "Grounding Squawk", squawk.issue_reported.to_s.truncate(100).presence || "No description", squawk)
end
@aircraft.squawks.deferred.find_each do |squawk|
add("DEFERRED", INFO, "Inoperative: #{squawk.issue_reported.to_s.truncate(80)}",
"Deferred under 91.213(d) on #{squawk.deferred_at.to_date} by #{squawk.deferred_by_name}. Fix at the next inspection.", squawk)
end
end
def check_inspections
@@ -120,13 +126,26 @@ class Airworthiness
end
end
def check_documents
@aircraft.documents.expiring.find_each do |doc|
grounds = Document::GROUNDING_EXPIRY_TYPES.include?(doc.doc_type)
if doc.expired?(@today)
add("DOCUMENT", grounds ? RED : ORANGE, "#{doc.name} - Expired",
"#{doc.type_label} expired #{doc.expires_on}.#{' The aircraft may not be flown without a current registration (91.203).' if grounds}", doc)
elsif @today + doc.expiry_warning_days >= doc.expires_on
add("DOCUMENT", ORANGE, "#{doc.name} - Expires Soon", "#{doc.type_label} expires #{doc.expires_on}.", doc)
end
end
end
def check_components
@aircraft.components.in_use.where(replacement_critical: true).includes(:component_type).find_each do |c|
scope = @aircraft.components.in_use.where(replacement_critical: true).or(@aircraft.components.in_use.where.not(expires_on: nil))
scope.includes(:component_type).find_each do |c|
overdue = false
approaching = false
desc = ""
if c.replacement_hours
if c.replacement_critical? && c.replacement_hours
if c.hours_since_overhaul >= c.replacement_hours
overdue = true
desc = "Replace every #{c.replacement_hours} hrs. Current: #{c.hours_since_overhaul} hrs."
@@ -136,7 +155,7 @@ class Airworthiness
end
end
if (due = c.next_replacement_date)
if c.replacement_critical? && (due = c.next_replacement_date)
if @today >= due
overdue = true
desc = "Replace every #{c.replacement_days} days. Last serviced #{c.overhaul_date}."
@@ -146,10 +165,23 @@ class Airworthiness
end
end
if overdue
add("COMPONENT", RED, "#{c} - Replacement Overdue", desc, c)
expired = false
if c.expires_on
if c.expired?(@today)
expired = true
desc = "Expired #{c.expires_on}."
elsif @today + DAYS_WARNING >= c.expires_on
approaching = true
desc = "Expires #{c.expires_on}."
end
end
if overdue || (expired && c.replacement_critical?)
add("COMPONENT", RED, "#{c} - #{expired ? 'Expired' : 'Replacement Overdue'}", desc, c)
elsif expired
add("COMPONENT", ORANGE, "#{c} - Expired", desc, c)
elsif approaching
add("COMPONENT", ORANGE, "#{c} - Replacement Due Soon", desc, c)
add("COMPONENT", ORANGE, "#{c} - #{c.expires_on && desc.start_with?('Expires') ? 'Expires Soon' : 'Replacement Due Soon'}", desc, c)
end
end
end
+1 -1
View File
@@ -17,7 +17,7 @@ class MaintenanceReport
# Parts with a mandatory replacement time (life limits).
def life_limited
in_use.select { |c| c.replacement_critical? && (c.replacement_hours || c.replacement_days) }
in_use.select { |c| (c.replacement_critical? && (c.replacement_hours || c.replacement_days)) || c.expires_on }
end
# Items overhauled on a time basis.