mirror of
https://github.com/rickbarrette/simple-aircraft-manager-rails.git
synced 2026-11-17 23:50:36 -05:00
- Inspection types say what overdue means: grounds the aircraft, no IFR
(91.411), no transponder (91.413) or advisory. Overdue limitations show
as a new LIMITED status ("VFR only", "No transponder") and don't block
flights under airworthiness enforcement
- "Also counts as": an annual satisfies the 100-hour (91.409(b))
- Overrun allowance: a 100-hour done within 10 hrs of due counts the next
one from when it was due; done early, from when it was done
- Per-aircraft maintenance clock (tach or Hobbs) for time in service; new
records default to it (fixes the tach-offset mismatch)
- Status labels Current / Due soon / limitation / Grounded, with the
91.7 pilot-in-command note
- Migration converts existing types by name; archives carry the new fields
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
60 lines
2.0 KiB
Ruby
60 lines
2.0 KiB
Ruby
class MajorRecordsController < ApplicationController
|
|
include AircraftScoped
|
|
before_action :require_owner!, except: %i[index show]
|
|
before_action :set_record, only: %i[show edit update destroy]
|
|
|
|
def index
|
|
@records = @aircraft.major_records.recent_first.includes(:component)
|
|
end
|
|
|
|
def show; end
|
|
|
|
def new
|
|
@record = @aircraft.major_records.new(record_type: params[:type] || "repair", date_performed: Date.current,
|
|
aircraft_hours: @aircraft.current_hours)
|
|
end
|
|
|
|
def create
|
|
@record = @aircraft.major_records.new(record_params)
|
|
if @record.save
|
|
log_event("major_record", "#{@record.type_label} added: #{@record.title}")
|
|
redirect_to aircraft_major_records_path(@aircraft), notice: "Record added."
|
|
else
|
|
render :new, status: :unprocessable_entity
|
|
end
|
|
end
|
|
|
|
def edit; end
|
|
|
|
def update
|
|
if @record.update(record_params)
|
|
log_event("major_record", "#{@record.type_label} updated: #{@record.title}")
|
|
redirect_to aircraft_major_record_path(@aircraft, @record), notice: "Record updated."
|
|
else
|
|
render :edit, status: :unprocessable_entity
|
|
end
|
|
end
|
|
|
|
def destroy
|
|
@record.destroy!
|
|
log_event("major_record", "#{@record.type_label} deleted: #{@record.title}")
|
|
redirect_to aircraft_major_records_path(@aircraft), notice: "Record deleted."
|
|
end
|
|
|
|
private
|
|
|
|
def set_record = @record = @aircraft.major_records.find(params[:id])
|
|
|
|
def record_params
|
|
p = params.require(:major_record).permit(
|
|
:record_type, :title, :description, :date_performed, :performed_by, :component_id,
|
|
:form_337_document_id, :stc_number, :stc_holder, :stc_document_id, :logbook_entry_id,
|
|
:aircraft_hours, :has_ica, :ica_notes, :notes
|
|
)
|
|
p[:component_id] = scoped_id(@aircraft.components, p[:component_id])
|
|
p[:logbook_entry_id] = scoped_id(@aircraft.logbook_entries, p[:logbook_entry_id])
|
|
%i[form_337_document_id stc_document_id].each { |k| p[k] = scoped_id(@aircraft.documents, p[k]) }
|
|
p
|
|
end
|
|
end
|