Record keeping: 43.9/43.11 sign-off fields, AD method, status report

- Logbook entries record the signer's kind of certificate and number and
  an inspection's result; maintenance and inspection entries list what
  43.9 / 43.11 needs that's missing (flagged, not enforced). Transcription
  reads the certificate details too
- AD compliance records the method (inspection, terminating action, AMOC,
  not applicable) and the AD revision complied with, filled in from the AD
  when blank; the method sets the permanent / N/A flags
- Maintenance status report (91.417(a)(2)): total times, life-limited
  parts, time since overhaul, inspection and AD status, major alterations,
  open discrepancies; print or save as PDF; on maintenance share links too
- Archives carry the new fields

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rickyandClaude Opus 5.5 committed 2026-11-07 10:14:21 -05:00
1 parent a4b72cf2c1
commit a4ec7a691e
30 files changed
+515 -26

No files matched your search

+4 -2
View File
@@ -7,7 +7,8 @@ class AdCompliancesController < ApplicationController
ad = @aircraft.applicable_ads.find_by(id: params[:ad_id])
@compliance = AdCompliance.new(aircraft: @aircraft, airworthiness_directive: ad, date_complied: Date.current,
aircraft_hours_at_compliance: @aircraft.current_hours,
not_applicable: params[:not_applicable] == "1")
compliance_method: params[:not_applicable] == "1" ? "not_applicable" : "inspection")
@compliance.apply_method
@compliance.compliance_notes = "Not applicable: " if @compliance.not_applicable?
@compliance.fill_next_due
end
@@ -46,7 +47,8 @@ class AdCompliancesController < ApplicationController
def compliance_params
p = params.require(:ad_compliance).permit(
:airworthiness_directive_id, :date_complied, :compliance_notes, :permanent, :next_due_at_time,
:aircraft_hours_at_compliance, :logbook_entry_id, :inspection_record_id, :component_id, :not_applicable
:aircraft_hours_at_compliance, :logbook_entry_id, :inspection_record_id, :component_id,
:compliance_method, :ad_revision
)
p[:airworthiness_directive_id] = scoped_id(@aircraft.applicable_ads, p[:airworthiness_directive_id])
p[:logbook_entry_id] = scoped_id(@aircraft.logbook_entries, p[:logbook_entry_id])
@@ -50,7 +50,8 @@ class LogbookEntriesController < ApplicationController
def entry_params
p = params.require(:logbook_entry).permit(:log_type, :entry_type, :date, :text, :signoff_person,
:signoff_location, :aircraft_hours_at_entry, :document_id, :page_number)
:signoff_location, :aircraft_hours_at_entry, :document_id, :page_number,
:signoff_certificate_type, :signoff_certificate_number, :inspection_result)
p[:document_id] = scoped_id(@aircraft.documents, p[:document_id])
p
end
@@ -0,0 +1,10 @@
# Printable maintenance status report (Print / Save as PDF in the browser).
class MaintenanceReportsController < ApplicationController
include AircraftScoped
def show
@report = MaintenanceReport.new(@aircraft)
log_event("aircraft", "Maintenance status report viewed") if params[:print]
render layout: "report"
end
end
+9
View File
@@ -5,6 +5,15 @@ class SharedController < ApplicationController
skip_before_action :redirect_to_setup
layout "public"
# The maintenance status report, for "Maintenance Detail" links (mechanics,
# inspectors, buyers).
def report
@share = ShareToken.find_active(params[:token]) or raise ActiveRecord::RecordNotFound
raise ActiveRecord::RecordNotFound unless @share.maintenance?
@report = MaintenanceReport.new(@share.aircraft)
render "maintenance_reports/show", layout: "report"
end
def show
@share = ShareToken.find_active(params[:token]) or raise ActiveRecord::RecordNotFound
@aircraft = @share.aircraft
+4
View File
@@ -56,3 +56,7 @@ document.addEventListener("click", (event) => {
document.addEventListener("change", (event) => {
if (event.target.matches?.("[data-submit-on-change]")) event.target.form?.requestSubmit()
})
document.addEventListener("click", (event) => {
if (event.target.closest?.("[data-print]")) window.print()
})
@@ -60,6 +60,7 @@ export default class extends Controller {
}
get isPermanent() {
return this.permanentTargets.some((el) => el.checked)
// A checkbox ticked, or the method select on terminating action / N/A.
return this.permanentTargets.some((el) => el.tagName === "SELECT" ? [ "terminating", "not_applicable" ].includes(el.value) : el.checked)
}
}
+2
View File
@@ -121,6 +121,8 @@ class LogbookTranscriptionJob < ApplicationJob
date: date, text: text, log_type: log_type,
entry_type: LogbookEntry::ENTRY_TYPES.key?(entry["entry_type"]) ? entry["entry_type"] : "OTHER",
signoff_person: entry["signoff_person"].presence, signoff_location: entry["signoff_location"].presence,
signoff_certificate_type: LogbookEntry::CERTIFICATE_TYPES.key?(entry["signoff_certificate_type"]) ? entry["signoff_certificate_type"] : nil,
signoff_certificate_number: entry["signoff_certificate_number"].to_s.strip.first(40).presence,
aircraft_hours_at_entry: entry["aircraft_hours"].is_a?(Numeric) && entry["aircraft_hours"] >= 0 ? entry["aircraft_hours"] : nil,
document: @document, page_number: page_number
)
+30 -2
View File
@@ -1,4 +1,12 @@
class AdCompliance < ApplicationRecord
# Method of compliance, recorded per 91.417(a)(2)(v).
METHODS = {
"inspection" => "Inspection",
"terminating" => "Terminating action (no further action)",
"amoc" => "Alternative method of compliance (AMOC)",
"not_applicable" => "Not applicable to this aircraft"
}.freeze
belongs_to :airworthiness_directive
belongs_to :aircraft, optional: true
belongs_to :component, optional: true
@@ -6,6 +14,9 @@ class AdCompliance < ApplicationRecord
belongs_to :inspection_record, optional: true
validates :date_complied, :compliance_notes, presence: true
validates :compliance_method, inclusion: { in: METHODS.keys }
before_validation :apply_method
before_validation :fill_revision
validate { errors.add(:base, "Must belong to an aircraft or component") unless aircraft_id || component_id }
validate :next_due_is_a_future_reading
before_validation :fill_next_due, if: -> { next_due_at_time.to_d.zero? }
@@ -21,6 +32,23 @@ class AdCompliance < ApplicationRecord
self.next_due_at_time = due[:hours] if due[:hours]
end
def method_label = METHODS[compliance_method]
# The method decides the closing flags (kept for archives shared with the
# original app): terminating action is permanent, N/A is not applicable.
def apply_method
self.compliance_method ||= not_applicable? ? "not_applicable" : (permanent? ? "terminating" : "inspection")
self.not_applicable = compliance_method == "not_applicable"
self.permanent = true if compliance_method == "terminating"
end
# The AD number and revision date complied with, from the AD if left blank.
def fill_revision
return if ad_revision.present? || airworthiness_directive.nil?
ad = airworthiness_directive
self.ad_revision = [ ad.name, ("effective #{ad.effective_date.iso8601}" if ad.effective_date) ].compact.join(", ")
end
# Permanent compliance or a not-applicable determination: never due again.
def closed? = permanent? || not_applicable?
@@ -30,14 +58,14 @@ class AdCompliance < ApplicationRecord
private
# next_due_at_time is an absolute tach reading, not an interval. Catch the
# next_due_at_time is an absolute clock reading, not an interval. Catch the
# easy mistake of entering "100" for "every 100 hours".
def next_due_is_a_future_reading
due = next_due_at_time.to_d
return if closed? || due <= 0
base = aircraft_hours_at_compliance || aircraft&.current_hours
return unless base && due <= base
errors.add(:next_due_at_time, "must be a tach reading after the compliance hours (#{base}). " \
errors.add(:next_due_at_time, "must be a #{aircraft&.time_basis || 'tach'} reading after the compliance hours (#{base}). " \
"For “every 100 hours” enter #{base + 100}, not 100")
end
end
+36
View File
@@ -5,6 +5,20 @@ class LogbookEntry < ApplicationRecord
"HOURS_UPDATE" => "Hours Update", "OTHER" => "Other"
}.freeze
# Kind of certificate of the person approving return to service (43.9(a)(4)).
CERTIFICATE_TYPES = {
"AP" => "A&P mechanic", "IA" => "A&P with Inspection Authorization", "A" => "Mechanic, airframe only",
"P" => "Mechanic, powerplant only", "REPAIR_STATION" => "Repair station", "REPAIRMAN" => "Repairman",
"PILOT" => "Pilot (preventive maintenance)", "OTHER" => "Other"
}.freeze
# An inspection entry ends with one of these (43.11(a)(5)).
INSPECTION_RESULTS = {
"approved" => "Airworthy, approved for return to service",
"discrepancies" => "Not approved: discrepancy list given to the owner"
}.freeze
# Entries that 43.9 / 43.11 set requirements for.
RECORD_TYPES = %w[MAINTENANCE INSPECTION].freeze
belongs_to :aircraft
belongs_to :document, optional: true
has_many :inspection_records, dependent: :nullify
@@ -13,6 +27,9 @@ class LogbookEntry < ApplicationRecord
validates :date, :text, presence: true
validates :log_type, inclusion: { in: LOG_TYPES.keys }
validates :entry_type, inclusion: { in: ENTRY_TYPES.keys }
validates :signoff_certificate_type, inclusion: { in: CERTIFICATE_TYPES.keys }, allow_blank: true
validates :inspection_result, inclusion: { in: INSPECTION_RESULTS.keys }, allow_blank: true
normalizes :signoff_certificate_type, :inspection_result, :signoff_certificate_number, with: ->(v) { v.strip.presence }
scope :recent_first, -> { order(date: :desc, created_at: :desc) }
@@ -23,4 +40,23 @@ class LogbookEntry < ApplicationRecord
end
def to_s = "#{date} — #{LOG_TYPES[log_type]}"
def certificate_label = CERTIFICATE_TYPES[signoff_certificate_type]
def inspection_result_label = INSPECTION_RESULTS[inspection_result]
# What a maintenance (43.9) or inspection (43.11) entry is missing. Not
# enforced: older and transcribed entries often lack these, and the signed
# logbook is the record of truth. Shown so gaps can be filled in.
def missing_record_items
return [] unless RECORD_TYPES.include?(entry_type)
missing = []
missing << "description of the work" if text.blank?
missing << "signer's name" if signoff_person.blank?
missing << "kind of certificate" if signoff_certificate_type.blank?
missing << "certificate number" if signoff_certificate_number.blank?
if entry_type == "INSPECTION"
missing << "aircraft time in service" if aircraft_hours_at_entry.blank?
missing << "airworthiness result" if inspection_result.blank?
end
missing
end
end
+4 -1
View File
@@ -66,6 +66,7 @@ module AircraftArchive
ads: ads.map { ad_hash(_1, component_ids) },
ad_compliances: a.ad_compliances.map do |c|
{ id: id(c), ad_id: id(c.airworthiness_directive_id), date_complied: c.date_complied&.iso8601, compliance_notes: c.compliance_notes,
compliance_method: c.compliance_method, ad_revision: c.ad_revision,
permanent: c.permanent, next_due_at_time: dec(c.next_due_at_time), aircraft_hours_at_compliance: dec(c.aircraft_hours_at_compliance),
logbook_entry_id: id(c.logbook_entry_id), inspection_record_id: id(c.inspection_record_id), aircraft_id: id(a),
component_id: id(c.component_id), not_applicable: c.not_applicable }
@@ -136,7 +137,9 @@ module AircraftArchive
def logbook_hash(e)
{ id: id(e), aircraft_id: id(e.aircraft_id), log_type: e.log_type, date: e.date&.iso8601, text: e.text,
signoff_person: e.signoff_person, signoff_location: e.signoff_location, log_image_id: id(e.document_id),
signoff_person: e.signoff_person, signoff_location: e.signoff_location,
signoff_certificate_type: e.signoff_certificate_type, signoff_certificate_number: e.signoff_certificate_number,
inspection_result: e.inspection_result, log_image_id: id(e.document_id),
aircraft_hours_at_entry: dec(e.aircraft_hours_at_entry), component_hours: {}, entry_type: e.entry_type,
page_number: e.page_number, components: [], related_documents: [] }
end
@@ -223,6 +223,9 @@ module AircraftArchive
entry_type: LogbookEntry::ENTRY_TYPES.key?(data["entry_type"]) ? data["entry_type"] : LogbookEntry::ENTRY_TYPES.keys.first,
date: date(data["date"]) || Date.new(1900, 1, 1), text: data["text"].to_s.presence || "—",
signoff_person: data["signoff_person"], signoff_location: data["signoff_location"],
signoff_certificate_type: LogbookEntry::CERTIFICATE_TYPES.key?(data["signoff_certificate_type"]) ? data["signoff_certificate_type"] : nil,
signoff_certificate_number: data["signoff_certificate_number"].to_s.presence,
inspection_result: LogbookEntry::INSPECTION_RESULTS.key?(data["inspection_result"]) ? data["inspection_result"] : nil,
aircraft_hours_at_entry: num(data["aircraft_hours_at_entry"]), page_number: data["page_number"],
document_id: @map[:document][data["log_image_id"].to_s]
)
@@ -318,11 +321,14 @@ module AircraftArchive
c = @aircraft.ad_compliances.new(
airworthiness_directive_id: ad_id, date_complied: date(data["date_complied"]) || Date.new(1900, 1, 1),
compliance_notes: data["compliance_notes"].to_s, permanent: data["permanent"] == true,
compliance_method: AdCompliance::METHODS.key?(data["compliance_method"]) ? data["compliance_method"] : nil,
ad_revision: data["ad_revision"].to_s.presence,
next_due_at_time: num(data["next_due_at_time"]) || 0, aircraft_hours_at_compliance: num(data["aircraft_hours_at_compliance"]),
logbook_entry_id: @map[:logbook][data["logbook_entry_id"].to_s],
inspection_record_id: @map[:inspection_record][data["inspection_record_id"].to_s],
component_id: @map[:component][data["component_id"].to_s], not_applicable: data["not_applicable"] == true
)
c.apply_method # older archives have only the permanent / not-applicable flags
c.save!(validate: false)
tick("ad_compliances")
end
+5 -1
View File
@@ -26,7 +26,11 @@ Fields:
- log_type: AC (airframe), ENG (engine), PROP (propeller), or OTHER
- text: the entry text verbatim, or a close paraphrase where wording is unclear; write [?] for illegible words
- aircraft_hours: the tach/total time the entry records (a number), or null if none is written
- signoff_person / signoff_location: a string, or null
- signoff_person / signoff_location: a string, or null (the person's name only; certificate details go below)
- signoff_certificate_type: the kind of certificate written with the signature: AP (A&P), IA (A&P with
Inspection Authorization), A (airframe only), P (powerplant only), REPAIR_STATION (repair station
number), REPAIRMAN, PILOT (pilot certificate, for owner preventive maintenance), OTHER, or null
- signoff_certificate_number: the certificate or repair station number exactly as written, or null
- page_start / page_end: page indices within this request
- confidence: high (clearly legible), medium (some guesswork), low (mostly illegible)
- unparseable_pages: pages too illegible to extract anything from
+3 -1
View File
@@ -13,12 +13,14 @@
"aircraft_hours": { "type": ["number", "null"] },
"signoff_person": { "type": ["string", "null"] },
"signoff_location": { "type": ["string", "null"] },
"signoff_certificate_type": { "type": ["string", "null"], "description": "AP, IA, A, P, REPAIR_STATION, REPAIRMAN, PILOT, OTHER, or null" },
"signoff_certificate_number": { "type": ["string", "null"] },
"page_start": { "type": "integer" },
"page_end": { "type": "integer" },
"confidence": { "type": "string", "enum": ["high", "medium", "low"] }
},
"required": ["date", "log_type", "entry_type", "text", "aircraft_hours", "signoff_person", "signoff_location",
"page_start", "page_end", "confidence"],
"signoff_certificate_type", "signoff_certificate_number", "page_start", "page_end", "confidence"],
"additionalProperties": false
}
},
+39
View File
@@ -0,0 +1,39 @@
# The aircraft's maintenance status as 14 CFR 91.417(a)(2) lists it:
# total time in service (airframe, engines, propellers), life-limited parts,
# time since overhaul, inspection status, AD status and major alterations.
class MaintenanceReport
attr_reader :aircraft, :generated_at
def initialize(aircraft)
@aircraft = aircraft
@generated_at = Time.current
end
def time_in_service = aircraft.current_hours
# Engines and propellers, by component type name.
def engines = major_components(/engine/i)
def propellers = major_components(/propell?er|\bprop\b/i)
# Parts with a mandatory replacement time (life limits).
def life_limited
in_use.select { |c| c.replacement_critical? && (c.replacement_hours || c.replacement_days) }
end
# Items overhauled on a time basis.
def overhaul_items
in_use.select { |c| c.tbo_hours || c.tbo_days }
end
def inspections = @inspections ||= Compliance.inspection_rows(aircraft)
def ads = @ads ||= Compliance.ad_rows(aircraft)
def major_records = aircraft.major_records.recent_first.includes(:component, :form_337_document, :stc_document)
def open_squawks = aircraft.squawks.active.by_priority.includes(:component)
def airworthiness = aircraft.airworthiness
private
def in_use = @in_use ||= aircraft.components.in_use.includes(:component_type).order(:install_location).to_a
def major_components(pattern) = in_use.select { |c| c.component_type&.name.to_s.match?(pattern) }
end
+12 -7
View File
@@ -7,21 +7,26 @@
data: { next_due_target: "rule", action: "change->next-due#changed" } %>
<div class="grid gap-4 sm:grid-cols-2">
<%= f.field :date_complied, as: :date, data: { next_due_target: "date", action: "change->next-due#changed" } %>
<%= f.field :aircraft_hours_at_compliance, as: :number, step: 0.1, label: "Aircraft hours (tach)",
<%= f.field :aircraft_hours_at_compliance, as: :number, step: 0.1, label: "Aircraft hours (#{aircraft.time_basis_label.downcase})",
data: { next_due_target: "hours", action: "input->next-due#changed" } %>
<%= f.field :next_due_at_time, as: :number, step: 0.1, label: "Next due at tach reading",
<%= f.field :next_due_at_time, as: :number, step: 0.1, label: "Next due at #{aircraft.time_basis_label.downcase} reading",
hint: "Calculated from the AD's recurrence; you can override it. Leave 0 if not hour-based.",
data: { next_due_target: "dueHours", action: "input->next-due#markManual" } %>
<%= f.field :component_id, as: :select, label: "Component", collection: component_options(aircraft) %>
<%= f.field :logbook_entry_id, as: :select, label: "Logbook entry", collection: logbook_options(aircraft) %>
</div>
<p class="rounded-md bg-sky-50 px-3 py-2 text-sm text-sky-900 ring-1 ring-sky-200" data-next-due-target="preview" hidden></p>
<%= f.field :permanent, as: :checkbox, label: "Permanently complied (terminating action)",
<div class="grid gap-4 sm:grid-cols-2">
<%= f.field :compliance_method, as: :select, label: "Method of compliance", collection: AdCompliance::METHODS.invert,
data: { next_due_target: "permanent", action: "change->next-due#changed" } %>
<%= f.field :ad_revision, label: "AD revision complied with", placeholder: "e.g. 2011-10-09 R1, effective 2011-06-01",
hint: "AD number and revision or effective date (91.417(a)(2)(v)). Left blank, it's taken from the AD." %>
</div>
<%= f.field :permanent, as: :checkbox, label: "No further action required (ends the recurring requirement)",
hint: "Set automatically for terminating action; tick it for an AMOC that ends the recurrence.",
data: { next_due_target: "permanent", action: "change->next-due#changed" } %>
<%= f.field :not_applicable, as: :checkbox, label: "Not applicable to this aircraft",
hint: "E.g. serial number outside the affected range, or the equipment isn't installed. Record why below.",
data: { next_due_target: "permanent", action: "change->next-due#changed" } %>
<%= f.field :compliance_notes, as: :textarea, label: "Method of compliance / reason", rows: 3, required: true %>
<%= f.field :compliance_notes, as: :textarea, label: "Details", rows: 3, required: true,
hint: "What was done and per which paragraph of the AD; for not applicable, why (e.g. serial number outside the affected range, equipment not installed)." %>
<div class="flex gap-2"><%= f.submit "Save" %><%= link_to "Cancel", aircraft_airworthiness_directives_path(aircraft), class: "btn-secondary" %></div>
<% end %>
<% if compliance.persisted? %><div class="mt-4"><%= delete_button "Delete record", aircraft_ad_compliance_path(aircraft, compliance) %></div><% end %>
+4 -1
View File
@@ -6,7 +6,10 @@
<section class="card">
<div class="card-header">
<h2 class="card-title">Airworthiness</h2>
<%= airworthiness_badge(@airworthiness, large: true) %>
<div class="flex items-center gap-2">
<%= link_to "Status report", aircraft_report_path(@aircraft), class: "btn-secondary btn-sm", title: "Printable maintenance status (91.417)" %>
<%= airworthiness_badge(@airworthiness, large: true) %>
</div>
</div>
<div class="card-body">
<% if @airworthiness.issues.empty? %>
@@ -69,6 +69,7 @@
<td class="text-right"><%= hours(c.aircraft_hours_at_compliance) %></td>
<td><%= c.not_applicable? ? "N/A" : c.permanent? ? "Permanent" : (c.next_due_at_time.to_f > 0 ? hours(c.next_due_at_time) : "—") %></td>
<td class="max-w-md text-xs">
<div class="font-medium text-slate-700"><%= c.method_label %><%= " · #{c.ad_revision}" if c.ad_revision.present? %></div>
<%= c.compliance_notes %>
<% if c.logbook_entry || c.inspection_record %>
<div class="mt-1 flex flex-wrap gap-x-3">
+2 -1
View File
@@ -31,7 +31,8 @@
<%= f.field :tbo_hours, as: :number, label: "TBO (hrs)" %>
<%= f.field :tbo_days, as: :number, label: "TBO (days)" %>
<div class="space-y-2">
<%= f.field :tbo_critical, as: :checkbox, label: "TBO critical" %>
<%= f.field :tbo_critical, as: :checkbox, label: "Treat TBO as a hard limit",
hint: "Under Part 91, TBO is usually the manufacturer's recommendation, unless an AD or the Airworthiness Limitations make it mandatory." %>
<%= f.field :on_condition, as: :checkbox, label: "On condition (Part 91)" %>
</div>
<%= f.field :inspection_hours, as: :number, label: "Inspect every (hrs)" %>
+20
View File
@@ -0,0 +1,20 @@
<!DOCTYPE html>
<html class="bg-white" data-theme="light">
<head>
<title><%= [content_for(:title), "Simple Aircraft Manager"].compact.join(" · ") %></title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="robots" content="noindex, nofollow">
<%= csrf_meta_tags %>
<%= csp_meta_tag %>
<link rel="icon" href="/favicon.svg" type="image/svg+xml">
<%= stylesheet_link_tag :app, "data-turbo-track": "reload" %>
<%= javascript_importmap_tags %>
<style>
html, body { background: #fff; }
@page { margin: 0.5in; }
</style>
</head>
<body class="bg-white text-slate-900 report">
<main class="mx-auto max-w-5xl px-4 py-6 print:max-w-none print:p-0"><%= yield %></main>
</body>
</html>
+9 -1
View File
@@ -7,8 +7,16 @@
<%= f.field :aircraft_hours_at_entry, as: :number, step: 0.1, label: "Aircraft hours" %>
</div>
<%= f.field :text, as: :textarea, label: "Entry text", rows: 8 %>
<p class="hint !mt-1">A maintenance entry needs a description of the work, the date, and the name, signature, certificate number and kind of certificate of whoever approved the return to service (14 CFR 43.9). An inspection entry also needs the type and extent of the inspection, the aircraft's time in service, and the result (43.11).</p>
<div class="grid gap-4 sm:grid-cols-3">
<%= f.field :signoff_person, label: "Signed off by", placeholder: "Name" %>
<%= f.field :signoff_certificate_type, as: :select, label: "Kind of certificate", include_blank: "—",
collection: LogbookEntry::CERTIFICATE_TYPES.invert %>
<%= f.field :signoff_certificate_number, label: "Certificate number", placeholder: "e.g. 1234567" %>
</div>
<div class="grid gap-4 sm:grid-cols-2">
<%= f.field :signoff_person, label: "Signed off by", placeholder: "Name, A&P/IA #" %>
<%= f.field :inspection_result, as: :select, label: "Inspection result", include_blank: "— Not an inspection —",
collection: LogbookEntry::INSPECTION_RESULTS.invert, hint: "For inspection entries (43.11)." %>
<%= f.field :signoff_location, label: "Location / shop" %>
<%= f.field :document_id, as: :select, label: "Scanned page document", collection: document_options(aircraft) %>
<%= f.field :page_number, as: :number, label: "Page # in document" %>
+2 -1
View File
@@ -24,7 +24,8 @@
<td class="text-xs"><%= LogbookEntry::ENTRY_TYPES[e.entry_type] %></td>
<td class="text-right tabular-nums"><%= hours(e.aircraft_hours_at_entry) %></td>
<td class="max-w-xl"><%= e.text.truncate(220) %> <%= "📄" if e.document %></td>
<td class="text-xs text-slate-500"><%= e.signoff_person %><% if e.signoff_location.present? %><br><%= e.signoff_location %><% end %></td>
<td class="text-xs text-slate-500"><%= e.signoff_person %><%= " ##{e.signoff_certificate_number}" if e.signoff_certificate_number %><% if e.signoff_location.present? %><br><%= e.signoff_location %><% end %>
<% if (missing = e.missing_record_items).any? %><br><span class="badge-orange" title="Missing: <%= missing.to_sentence %>">Incomplete</span><% end %></td>
</tr>
<% end %>
</tbody>
+13 -1
View File
@@ -10,7 +10,19 @@
<span>Aircraft hours: <%= hours(@entry.aircraft_hours_at_entry) %></span>
</div>
<div class="whitespace-pre-wrap rounded bg-slate-50 p-3 font-mono text-sm"><%= @entry.text %></div>
<div class="text-sm text-slate-600">Signed off: <%= @entry.signoff_person.presence || "—" %> <%= "(#{@entry.signoff_location})" if @entry.signoff_location.present? %></div>
<div class="text-sm text-slate-600">
Signed off: <%= @entry.signoff_person.presence || "—" %>
<%= ", #{@entry.certificate_label}" if @entry.certificate_label %><%= " ##{@entry.signoff_certificate_number}" if @entry.signoff_certificate_number %>
<%= "(#{@entry.signoff_location})" if @entry.signoff_location.present? %>
</div>
<% if @entry.inspection_result %><div class="text-sm text-slate-600">Result: <%= @entry.inspection_result_label %></div><% end %>
<% if (missing = @entry.missing_record_items).any? %>
<p class="rounded-md bg-amber-50 px-3 py-2 text-sm text-amber-900 ring-1 ring-amber-200">
Missing for <%= @entry.entry_type == "INSPECTION" ? "43.11" : "43.9" %>: <%= missing.to_sentence %>.
<%= link_to("Fill in", edit_aircraft_logbook_entry_path(@aircraft, @entry), class: "link") if owner? %>
(Check against the signed logbook.)
</p>
<% end %>
<% if @entry.document %>
<p class="text-sm">Scan: <%= link_to @entry.document.name, aircraft_document_path(@aircraft, @entry.document, page: @entry.page_number), class: "link" %><%= " (page #{@entry.page_number})" if @entry.page_number %></p>
<% end %>
+151
View File
@@ -0,0 +1,151 @@
<% a = @report.aircraft %>
<% clock = a.time_basis_label.downcase %>
<% content_for :title, "#{a.tail_number} Maintenance Status" %>
<% section = "mt-6 break-inside-avoid-page" %>
<% th = "border-b border-slate-300 py-1 pr-3 text-left text-[11px] font-semibold uppercase tracking-wide text-slate-500" %>
<% td = "border-b border-slate-100 py-1 pr-3 align-top" %>
<div class="mb-4 flex flex-wrap items-center justify-between gap-2 print:hidden">
<% back = @share ? shared_path(@share.token) : aircraft_path(a) %>
<%= link_to "← Back", back, class: "link text-sm" %>
<button type="button" class="btn-primary" data-print>Print or save as PDF</button>
</div>
<header class="flex flex-wrap items-end justify-between gap-4 border-b-2 border-slate-800 pb-3">
<div>
<p class="text-xs uppercase tracking-wide text-slate-500">Maintenance status · 14 CFR 91.417(a)(2)</p>
<h1 class="text-2xl font-bold"><%= a.tail_number %> <span class="text-lg font-normal text-slate-600"><%= [ a.make, a.model ].compact_blank.join(" ") %></span></h1>
<p class="text-sm text-slate-600">Serial number <%= a.serial_number.presence || "—" %></p>
</div>
<dl class="grid grid-cols-2 gap-x-6 text-sm">
<dt class="text-slate-500">Prepared</dt><dd><%= l(@report.generated_at.to_date, format: :long) %></dd>
<dt class="text-slate-500">Airframe time in service</dt><dd class="font-semibold"><%= hours(@report.time_in_service) %> hrs (<%= clock %>)</dd>
<dt class="text-slate-500">Tach / Hobbs</dt><dd><%= hours(a.tach_time) %> / <%= hours(a.hobbs_time) %></dd>
<dt class="text-slate-500">Status</dt><dd><%= airworthiness_badge(@report.airworthiness) %></dd>
</dl>
</header>
<section class="<%= section %>">
<h2 class="text-base font-semibold">Total time in service: engines and propellers</h2>
<% majors = @report.engines + @report.propellers %>
<% if majors.any? %>
<table class="mt-2 w-full text-sm">
<thead><tr><th class="<%= th %>">Item</th><th class="<%= th %>">Make / model</th><th class="<%= th %>">Serial</th><th class="<%= th %> text-right">Total time</th><th class="<%= th %> text-right">Since overhaul</th><th class="<%= th %>">Overhauled</th></tr></thead>
<tbody>
<% majors.each do |c| %>
<tr><td class="<%= td %>"><%= c %></td><td class="<%= td %>"><%= [ c.manufacturer, c.model ].compact_blank.join(" ") %></td><td class="<%= td %>"><%= c.serial_number.presence || "—" %></td>
<td class="<%= td %> text-right tabular-nums"><%= hours(c.hours_in_service) %></td><td class="<%= td %> text-right tabular-nums"><%= hours(c.hours_since_overhaul) %></td><td class="<%= td %>"><%= c.overhaul_date || "—" %></td></tr>
<% end %>
</tbody>
</table>
<% else %><p class="mt-1 text-sm text-slate-500">No engines or propellers recorded as components.</p><% end %>
</section>
<section class="<%= section %>">
<h2 class="text-base font-semibold">Life-limited parts</h2>
<% if @report.life_limited.any? %>
<table class="mt-2 w-full text-sm">
<thead><tr><th class="<%= th %>">Part</th><th class="<%= th %>">Serial</th><th class="<%= th %>">Limit</th><th class="<%= th %> text-right">Used</th><th class="<%= th %>">Remaining</th><th class="<%= th %>">Status</th></tr></thead>
<tbody>
<% @report.life_limited.each do |c| %>
<tr><td class="<%= td %>"><%= c %> <span class="text-slate-500"><%= c.model %></span></td><td class="<%= td %>"><%= c.serial_number.presence || "—" %></td>
<td class="<%= td %>"><%= [ (c.replacement_hours && "#{hours(c.replacement_hours)} hrs"), (c.replacement_days && "#{c.replacement_days} days") ].compact.join(" / ") %></td>
<td class="<%= td %> text-right tabular-nums"><%= hours(c.hours_since_overhaul) %> hrs</td>
<td class="<%= td %>"><%= [ (c.hours_to_replacement && "#{hours(c.hours_to_replacement)} hrs"), (c.next_replacement_date && "by #{c.next_replacement_date}") ].compact.join(", ") %></td>
<td class="<%= td %>"><%= life_badge(c.life_status) %></td></tr>
<% end %>
</tbody>
</table>
<% else %><p class="mt-1 text-sm text-slate-500">None recorded.</p><% end %>
</section>
<section class="<%= section %>">
<h2 class="text-base font-semibold">Time since overhaul</h2>
<% if @report.overhaul_items.any? %>
<table class="mt-2 w-full text-sm">
<thead><tr><th class="<%= th %>">Item</th><th class="<%= th %>">Serial</th><th class="<%= th %>">Overhaul interval</th><th class="<%= th %> text-right">Since overhaul</th><th class="<%= th %>">Remaining</th><th class="<%= th %>">Tracked as</th></tr></thead>
<tbody>
<% @report.overhaul_items.each do |c| %>
<tr><td class="<%= td %>"><%= c %> <span class="text-slate-500"><%= c.model %></span></td><td class="<%= td %>"><%= c.serial_number.presence || "—" %></td>
<td class="<%= td %>"><%= [ (c.tbo_hours && "#{hours(c.tbo_hours)} hrs"), (c.tbo_days && "#{c.tbo_days} days") ].compact.join(" / ") %></td>
<td class="<%= td %> text-right tabular-nums"><%= hours(c.hours_since_overhaul) %> hrs</td>
<td class="<%= td %>"><%= c.on_condition? ? "On condition" : (c.hours_to_tbo ? "#{hours(c.hours_to_tbo)} hrs" : "—") %></td>
<td class="<%= td %> text-xs"><%= c.tbo_critical? ? "Hard limit" : "Recommended" %></td></tr>
<% end %>
</tbody>
</table>
<% else %><p class="mt-1 text-sm text-slate-500">None recorded.</p><% end %>
</section>
<section class="<%= section %>">
<h2 class="text-base font-semibold">Inspection status</h2>
<% if @report.inspections.any? %>
<table class="mt-2 w-full text-sm">
<thead><tr><th class="<%= th %>">Inspection</th><th class="<%= th %>">Interval</th><th class="<%= th %>">Last done</th><th class="<%= th %> text-right">Since</th><th class="<%= th %>">Next due</th><th class="<%= th %>">Status</th></tr></thead>
<tbody>
<% @report.inspections.each do |row| %>
<% last = row.latest %>
<tr><td class="<%= td %>"><%= row.type.name %><% if row.type.satisfies %><div class="text-xs text-slate-500">Also counts as <%= row.type.satisfies.name %></div><% end %></td>
<td class="<%= td %> text-xs"><%= row.type.interval_description %></td>
<td class="<%= td %>"><%= last ? "#{last.date}#{" @ #{hours(last.hours_at_inspection)}" if last.hours_at_inspection}" : "Never" %><%= " (#{last.inspection_type.name})" if last && last.inspection_type != row.type %></td>
<td class="<%= td %> text-right tabular-nums"><%= last&.hours_at_inspection ? "#{hours(@report.time_in_service - last.hours_at_inspection)} hrs" : "—" %></td>
<td class="<%= td %>"><%= [ row.next_due_date&.to_s, row.next_due_hours && "#{hours(row.next_due_hours)} hrs" ].compact.join(" / ").presence || "—" %></td>
<td class="<%= td %>"><%= compliance_badge(row.status) %></td></tr>
<% end %>
</tbody>
</table>
<% else %><p class="mt-1 text-sm text-slate-500">No inspections tracked.</p><% end %>
</section>
<section class="<%= section %>">
<h2 class="text-base font-semibold">Airworthiness directives</h2>
<% if @report.ads.any? %>
<table class="mt-2 w-full text-sm">
<thead><tr><th class="<%= th %>">AD</th><th class="<%= th %>">Revision complied with</th><th class="<%= th %>">Method of compliance</th><th class="<%= th %>">Complied</th><th class="<%= th %>">Recurring / next due</th><th class="<%= th %>">Status</th></tr></thead>
<tbody>
<% @report.ads.each do |row| %>
<% c = row.latest %>
<tr><td class="<%= td %>"><span class="font-medium"><%= row.ad.name %></span><div class="text-xs text-slate-500"><%= row.ad.short_description.to_s.truncate(70) %></div></td>
<td class="<%= td %> text-xs"><%= c&.ad_revision.presence || "—" %></td>
<td class="<%= td %> text-xs"><%= c ? c.method_label : "—" %><% if c&.compliance_notes.present? %><div class="text-slate-500"><%= c.compliance_notes.truncate(90) %></div><% end %></td>
<td class="<%= td %>"><%= c ? "#{c.date_complied}#{" @ #{hours(c.aircraft_hours_at_compliance)}" if c.aircraft_hours_at_compliance}" : "—" %></td>
<td class="<%= td %> text-xs"><%= if c&.closed? then "No further action"
elsif row.ad.recurring? then [ row.next_due_date&.to_s, row.next_due_hours && "#{hours(row.next_due_hours)} hrs" ].compact.join(" / ").presence || "Recurring"
else "One-time" end %></td>
<td class="<%= td %>"><%= compliance_badge(row.status) %></td></tr>
<% end %>
</tbody>
</table>
<% else %><p class="mt-1 text-sm text-slate-500">No ADs tracked.</p><% end %>
</section>
<section class="<%= section %>">
<h2 class="text-base font-semibold">Major repairs and alterations</h2>
<% if (majors = @report.major_records.to_a).any? %>
<table class="mt-2 w-full text-sm">
<thead><tr><th class="<%= th %>">Date</th><th class="<%= th %>">Type</th><th class="<%= th %>">Description</th><th class="<%= th %>">STC</th><th class="<%= th %>">Form 337</th></tr></thead>
<tbody>
<% majors.each do |m| %>
<tr><td class="<%= td %>"><%= m.date_performed %></td><td class="<%= td %> text-xs"><%= m.type_label %></td>
<td class="<%= td %>"><%= m.title %><%= " · #{m.component}" if m.component %></td>
<td class="<%= td %> text-xs"><%= [ m.stc_number, m.stc_holder ].compact_blank.join(", ").presence || "—" %></td>
<td class="<%= td %> text-xs"><%= m.form_337_document ? "On file" : "—" %></td></tr>
<% end %>
</tbody>
</table>
<% else %><p class="mt-1 text-sm text-slate-500">None recorded.</p><% end %>
</section>
<section class="<%= section %>">
<h2 class="text-base font-semibold">Open discrepancies</h2>
<% if (squawks = @report.open_squawks.to_a).any? %>
<ul class="mt-2 space-y-1 text-sm">
<% squawks.each do |s| %><li><%= squawk_priority_badge(s) %> <%= s.issue_reported %><%= " · #{s.component}" if s.component %> <span class="text-xs text-slate-500">(<%= s.created_at.to_date %>)</span></li><% end %>
</ul>
<% else %><p class="mt-1 text-sm text-slate-500">None open.</p><% end %>
</section>
<footer class="mt-8 border-t border-slate-300 pt-2 text-xs text-slate-500">
Prepared <%= l(@report.generated_at, format: :long) %> from the records kept in Simple Aircraft Manager. Times are in hours of <%= clock %> time.
This summary doesn't replace the aircraft's signed maintenance records. <%= Airworthiness::DISCLAIMER %>
</footer>
+2 -1
View File
@@ -15,7 +15,8 @@
<div class="space-y-5">
<section class="card">
<div class="card-header"><h2 class="card-title">Airworthiness</h2><%= airworthiness_badge(@airworthiness, large: true) %></div>
<div class="card-header"><h2 class="card-title">Airworthiness</h2>
<div class="flex items-center gap-2"><% if @share.maintenance? %><%= link_to "Status report", shared_report_path(@share.token), class: "btn-secondary btn-sm" %><% end %><%= airworthiness_badge(@airworthiness, large: true) %></div></div>
<div class="card-body">
<% if @airworthiness.issues.empty? %><p class="text-sm text-emerald-700">Nothing overdue or due soon.</p><% else %>
<ul class="space-y-1 text-sm"><% @airworthiness.issues.each do |i| %><li><span class="<%= issue_badge_class(i) %>"><%= i.category %></span> <%= i.title %> <span class="text-xs text-slate-500"><%= i.description %></span></li><% end %></ul>
+2
View File
@@ -78,6 +78,7 @@ Rails.application.routes.draw do
resources :aircraft_roles, path: "access", only: %i[index create update destroy]
resources :share_tokens, only: %i[create destroy]
resource :export, controller: "aircraft_exports", only: :show
resource :report, controller: "maintenance_reports", only: :show
resources :events, only: :index
end
@@ -85,6 +86,7 @@ Rails.application.routes.draw do
# Public read-only share links (no login).
get "shared/:token", to: "shared#show", as: :shared
get "shared/:token/report", to: "shared#report", as: :shared_report
namespace :admin do
get "about", to: "about#show"
@@ -0,0 +1,24 @@
# What 14 CFR 43.9 / 43.11 and 91.417(a)(2)(v) want in the records:
# the signer's certificate (kind and number), an inspection's outcome, and
# each AD's method of compliance and the revision complied with.
class AddRecordKeepingFields < ActiveRecord::Migration[8.1]
def up
add_column :logbook_entries, :signoff_certificate_type, :string
add_column :logbook_entries, :signoff_certificate_number, :string
add_column :logbook_entries, :inspection_result, :string
add_column :ad_compliances, :compliance_method, :string
add_column :ad_compliances, :ad_revision, :string
execute "UPDATE ad_compliances SET compliance_method = 'not_applicable' WHERE not_applicable = 1"
execute "UPDATE ad_compliances SET compliance_method = 'terminating' WHERE compliance_method IS NULL AND permanent = 1"
execute "UPDATE ad_compliances SET compliance_method = 'inspection' WHERE compliance_method IS NULL"
end
def down
remove_column :logbook_entries, :signoff_certificate_type
remove_column :logbook_entries, :signoff_certificate_number
remove_column :logbook_entries, :inspection_result
remove_column :ad_compliances, :compliance_method
remove_column :ad_compliances, :ad_revision
end
end
Generated
+6 -1
View File
@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[8.1].define(version: 2026_11_07_190000) do
ActiveRecord::Schema[8.1].define(version: 2026_11_07_200000) do
create_table "active_storage_attachments", force: :cascade do |t|
t.string "name", null: false
t.string "record_type", null: false
@@ -53,6 +53,8 @@ ActiveRecord::Schema[8.1].define(version: 2026_11_07_190000) do
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.boolean "not_applicable", default: false, null: false
t.string "compliance_method"
t.string "ad_revision"
t.index ["aircraft_id"], name: "index_ad_compliances_on_aircraft_id"
t.index ["airworthiness_directive_id"], name: "index_ad_compliances_on_airworthiness_directive_id"
t.index ["component_id"], name: "index_ad_compliances_on_component_id"
@@ -416,6 +418,9 @@ ActiveRecord::Schema[8.1].define(version: 2026_11_07_190000) do
t.integer "page_number"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "signoff_certificate_type"
t.string "signoff_certificate_number"
t.string "inspection_result"
t.index ["aircraft_id"], name: "index_logbook_entries_on_aircraft_id"
t.index ["document_id"], name: "index_logbook_entries_on_document_id"
end
+2 -2
View File
@@ -38,9 +38,9 @@ class AdImportFlowTest < ActionDispatch::IntegrationTest
ad.aircraft << @aircraft
sign_in @owner
get new_aircraft_ad_compliance_path(@aircraft, ad_id: ad.id, not_applicable: 1)
assert_select "input[name='ad_compliance[not_applicable]'][checked]"
assert_select "select[name='ad_compliance[compliance_method]'] option[selected][value=not_applicable]"
post aircraft_ad_compliances_path(@aircraft), params: { ad_compliance: {
airworthiness_directive_id: ad.id, date_complied: Date.current, not_applicable: "1",
airworthiness_directive_id: ad.id, date_complied: Date.current, compliance_method: "not_applicable",
compliance_notes: "Not applicable: no BRS parachute installed" } }
assert_equal "GREEN", @aircraft.reload.airworthiness.status
end
+3 -1
View File
@@ -29,7 +29,8 @@ class LogbookImportFlowTest < ActionDispatch::IntegrationTest
def entry(text, page_start, page_end = page_start, **extra)
{ date: "2026-01-05", log_type: "ENG", entry_type: "MAINTENANCE", text: text, aircraft_hours: 1990.5,
signoff_person: "J. Mechanic A&P 1234567", signoff_location: "KOQU", page_start: page_start, page_end: page_end,
signoff_person: "J. Mechanic", signoff_location: "KOQU", signoff_certificate_type: "AP",
signoff_certificate_number: "1234567", page_start: page_start, page_end: page_end,
confidence: "high" }.merge(extra)
end
@@ -93,6 +94,7 @@ class LogbookImportFlowTest < ActionDispatch::IntegrationTest
entries = @a.logbook_entries.order(:id)
assert_equal [ "Changed oil", "Annual inspection, found airworthy", "[date unreadable] Replaced [?] gasket" ], entries.map(&:text)
assert_equal [ "J. Mechanic", "AP", "1234567" ], entries.first.then { [ _1.signoff_person, _1.signoff_certificate_type, _1.signoff_certificate_number ] }
assert_equal [ 1, 2, 3 ], entries.map(&:page_number)
assert entries.all? { _1.document == document && _1.log_type == "ENG" }
assert_equal [ "MAINTENANCE", "INSPECTION", "MAINTENANCE" ], entries.map(&:entry_type)
+106
View File
@@ -0,0 +1,106 @@
require "test_helper"
# 43.9 / 43.11 logbook fields, structured AD compliance (91.417(a)(2)(v)) and
# the maintenance status report (91.417(a)(2)).
class RecordKeepingTest < ActionDispatch::IntegrationTest
setup do
@owner = create_user("owner@example.com")
@pilot = create_user("pilot@example.com")
@a = create_aircraft(owner: @owner, pilot: @pilot, serial_number: "17200001", make: "Cessna", model: "172N")
end
test "logbook entries record the signer's certificate and an inspection's result, and show what's missing" do
sign_in @owner
post aircraft_logbook_entries_path(@a), params: { logbook_entry: {
date: "2026-10-01", log_type: "AC", entry_type: "INSPECTION", text: "Annual inspection IAW Part 43 App. D",
aircraft_hours_at_entry: 1000, signoff_person: "Jane Mechanic" } }
entry = @a.logbook_entries.last
assert_equal [ "kind of certificate", "certificate number", "airworthiness result" ], entry.missing_record_items
get aircraft_logbook_entries_path(@a)
assert_select ".badge-orange[title*='certificate number']", text: "Incomplete"
get aircraft_logbook_entry_path(@a, entry)
assert_includes response.body, "Missing for 43.11: kind of certificate, certificate number, and airworthiness result."
patch aircraft_logbook_entry_path(@a, entry), params: { logbook_entry: {
signoff_certificate_type: "IA", signoff_certificate_number: " 1234567 ", inspection_result: "approved" } }
entry.reload
assert_equal [ [], "1234567", "A&P with Inspection Authorization" ], [ entry.missing_record_items, entry.signoff_certificate_number, entry.certificate_label ]
get aircraft_logbook_entry_path(@a, entry)
assert_includes response.body, "Airworthy, approved for return to service"
flight = @a.logbook_entries.create!(date: Date.current, text: "Test flight", entry_type: "FLIGHT")
assert_empty flight.missing_record_items # 43.9 / 43.11 don't cover these
refute @a.logbook_entries.new(date: Date.current, text: "x", signoff_certificate_type: "BOGUS").valid?
end
test "AD compliance records the method and the revision; the method sets the closing flags" do
ad = AirworthinessDirective.create!(name: "2011-10-09", short_description: "Seat rails", recurring: true, recurring_hours: 100,
effective_date: Date.new(2011, 6, 1))
ad.aircraft << @a
sign_in @owner
post aircraft_ad_compliances_path(@a), params: { ad_compliance: {
airworthiness_directive_id: ad.id, date_complied: "2026-10-01", aircraft_hours_at_compliance: 1000,
compliance_method: "terminating", compliance_notes: "Installed secondary seat stop P/N 123 per para (g)" } }
c = @a.ad_compliances.last
assert_equal [ "terminating", true, false, "2011-10-09, effective 2011-06-01" ],
[ c.compliance_method, c.permanent?, c.not_applicable?, c.ad_revision ]
get new_aircraft_ad_compliance_path(@a, ad_id: ad.id, not_applicable: 1)
assert_select "select[name='ad_compliance[compliance_method]'] option[selected][value=not_applicable]"
na = @a.ad_compliances.create!(airworthiness_directive: ad, date_complied: Date.current, compliance_method: "not_applicable",
compliance_notes: "S/N outside effectivity", ad_revision: "2011-10-09 R1")
assert [ na.not_applicable?, na.closed? ].all?
assert_equal "2011-10-09 R1", na.ad_revision
legacy = @a.ad_compliances.new(airworthiness_directive: ad, date_complied: Date.current, compliance_notes: "x", permanent: true)
legacy.valid?
assert_equal "terminating", legacy.compliance_method # inferred from the old flags
get aircraft_airworthiness_directives_path(@a)
assert_includes response.body, "Terminating action (no further action) · 2011-10-09, effective 2011-06-01"
end
test "the maintenance status report covers 91.417(a)(2), for crew and maintenance share links only" do
engine = create_component(@a, component_type: component_type("Engine"), serial_number: "L-12345-27A",
hours_in_service: 3200, hours_since_overhaul: 850, tbo_hours: 2000, tbo_critical: false,
overhaul_date: Date.new(2019, 5, 1))
create_component(@a, component_type: component_type("ELT Battery"), model: "E-04", manufacturer: "ACK",
replacement_critical: true, replacement_days: 730, overhaul_date: 1.year.ago.to_date)
annual = InspectionType.create!(name: "Annual", recurring: true, recurring_months: 12).tap { _1.aircraft << @a }
@a.inspection_records.create!(inspection_type: annual, date: 2.months.ago.to_date, aircraft_hours: 990)
ad = AirworthinessDirective.create!(name: "2020-01-01", short_description: "Muffler inspection", recurring: true, recurring_hours: 100)
ad.aircraft << @a
@a.ad_compliances.create!(airworthiness_directive: ad, date_complied: 1.month.ago.to_date, aircraft_hours_at_compliance: 995,
compliance_method: "inspection", compliance_notes: "Inspected muffler, no cracks")
@a.major_records.create!(record_type: "alteration", title: "Garmin GTX 345 installed", date_performed: Date.new(2024, 3, 1),
stc_number: "SA01234WI", form_337_document: @a.documents.create!(name: "337", doc_type: "ALTER"))
sign_in @pilot
get aircraft_path(@a)
assert_select "a[href='#{aircraft_report_path(@a)}']", text: "Status report"
get aircraft_report_path(@a)
assert_response :success
body = response.body
[ "Maintenance status · 14 CFR 91.417(a)(2)", "17200001", "L-12345-27A", "3,200.0", "850.0", "Recommended",
"ELT Battery", "Annual", "Revision complied with", "Inspection", "Inspected muffler", "1,095.0 hrs",
"Garmin GTX 345 installed", "SA01234WI", "On file", "This summary doesn't replace the aircraft's signed maintenance records" ].each do |text|
assert_includes body, text, "missing: #{text}"
end
assert_select "button[data-print]", text: "Print or save as PDF"
assert_equal engine, MaintenanceReport.new(@a).engines.sole
sign_in create_user
get aircraft_report_path(@a)
assert_response :not_found
status_link = @a.share_tokens.create!(privilege: "status")
detail_link = @a.share_tokens.create!(privilege: "maintenance")
delete session_path
get shared_report_path(status_link.token)
assert_response :not_found
get shared_path(detail_link.token)
assert_select "a[href='#{shared_report_path(detail_link.token)}']"
get shared_report_path(detail_link.token)
assert_response :success
assert_includes response.body, "L-12345-27A"
end
end