diff --git a/app/controllers/api/v1/aircraft_controller.rb b/app/controllers/api/v1/aircraft_controller.rb index 4d9a0ba..aa308d6 100644 --- a/app/controllers/api/v1/aircraft_controller.rb +++ b/app/controllers/api/v1/aircraft_controller.rb @@ -36,7 +36,7 @@ module Api render json: { data: Compliance.ad_rows(aircraft).map { ApiPresenter.ad(_1) } } end - # Logbook entries, oldest first (paged); ?log=AC|ENG|PROP|OTHER, ?signed=true|false. + # Logbook entries, oldest first (paged); ?log=AC|ENG|PROP|AVIONICS|OTHER, ?signed=true|false. def logbook_entries aircraft = find_aircraft(params[:id]) scope = aircraft.logbook_entries.includes(:signature) diff --git a/app/models/logbook_entry.rb b/app/models/logbook_entry.rb index 78143bb..942dd24 100644 --- a/app/models/logbook_entry.rb +++ b/app/models/logbook_entry.rb @@ -1,6 +1,6 @@ class LogbookEntry < ApplicationRecord include Versioned - LOG_TYPES = LabelSet.new("logbook_entry.log_types", %w[AC ENG PROP OTHER]) + LOG_TYPES = LabelSet.new("logbook_entry.log_types", %w[AC ENG PROP AVIONICS OTHER]) ENTRY_TYPES = LabelSet.new("logbook_entry.entry_types", %w[MAINTENANCE INSPECTION FLIGHT HOURS_UPDATE OTHER]) # Kind of certificate of the person approving return to service (43.9(a)(4)). diff --git a/app/services/logbook_transcriber/prompt.txt b/app/services/logbook_transcriber/prompt.txt index 603e487..2da94fd 100644 --- a/app/services/logbook_transcriber/prompt.txt +++ b/app/services/logbook_transcriber/prompt.txt @@ -23,7 +23,7 @@ Entry types: - OTHER: administrative entries, certifications Fields: -- log_type: AC (airframe), ENG (engine), PROP (propeller), or OTHER +- log_type: AC (airframe), ENG (engine), PROP (propeller), AVIONICS (a separate avionics logbook: radios, transponder, autopilot, GPS…), 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 (the person's name only; certificate details go below) diff --git a/app/services/logbook_transcriber/schema.json b/app/services/logbook_transcriber/schema.json index e2f12a7..9483e36 100644 --- a/app/services/logbook_transcriber/schema.json +++ b/app/services/logbook_transcriber/schema.json @@ -7,7 +7,7 @@ "type": "object", "properties": { "date": { "type": ["string", "null"], "description": "YYYY-MM-DD, or null if unreadable" }, - "log_type": { "type": "string", "enum": ["AC", "ENG", "PROP", "OTHER"] }, + "log_type": { "type": "string", "enum": ["AC", "ENG", "PROP", "AVIONICS", "OTHER"] }, "entry_type": { "type": "string", "enum": ["MAINTENANCE", "INSPECTION", "FLIGHT", "HOURS_UPDATE", "OTHER"] }, "text": { "type": "string" }, "aircraft_hours": { "type": ["number", "null"] }, diff --git a/config/locales/en.yml b/config/locales/en.yml index 84555ad..95d7bb6 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -73,6 +73,7 @@ en: AC: Aircraft ENG: Engine PROP: Propeller + AVIONICS: Avionics OTHER: Other entry_types: MAINTENANCE: Maintenance diff --git a/docs/guide/api.md b/docs/guide/api.md index 4a28592..a3fb300 100644 --- a/docs/guide/api.md +++ b/docs/guide/api.md @@ -63,7 +63,7 @@ Squawks have an `external_ref`: your own id for them, such as `redmine:issue:451 | `GET /aircraft/:id/due` | Everything coming due, soonest first; items due by hours get a projected date | | `GET /aircraft/:id/inspections` | Each inspection's status and next due date and hours | | `GET /aircraft/:id/ads` | Each AD's status and next due date and hours | -| `GET /aircraft/:id/logbook_entries` | Logbook entries, with their signatures (`?log=AC`, `ENG`, `PROP` or `OTHER`; `?signed=true` or `false`) | +| `GET /aircraft/:id/logbook_entries` | Logbook entries, with their signatures (`?log=AC`, `ENG`, `PROP`, `AVIONICS` or `OTHER`; `?signed=true` or `false`) | | `GET /aircraft/:id/squawks` | Squawks (`?status=open`, the default, or `resolved` or `all`) | | `POST /aircraft/:id/squawks` | Report a squawk | | `GET /squawks?external_ref=…` | Find squawks by your id for them | @@ -120,7 +120,7 @@ POST /api/v1/aircraft/12/draft_batches } } ``` -- **One entry per logbook.** Items are grouped by `log` (`AC`, `ENG`, `PROP` or `OTHER`) into one unsigned entry each, their texts in order, so a visit that touched the engine and the airframe makes two entries, signed one after the other. +- **One entry per logbook.** Items are grouped by `log` (`AC`, `ENG`, `PROP`, `AVIONICS` or `OTHER`) into one unsigned entry each, their texts in order, so a visit that touched the engine and the airframe makes two entries, signed one after the other. - **Inspections** (`completes_inspections`): each needs its `result`, `approved` (airworthy) or `discrepancies` (a list was given to the owner), and the draft needs `aircraft_hours`. The entry recording it is an inspection entry, in the logbook named by `log`, else the airframe log if an item is for it. - **Nothing is resolved until it's signed.** The squawks the items resolve and the inspections they complete are held until **every** entry of the draft is signed; then they're resolved and recorded, attributed to the person who signed last, and linked to the entry that described the work. A draft never clears a squawk on its own. The signer sees what signing will do before they sign. - **The signer.** Anyone with access to the aircraft and a certificate in their profile can sign, from each entry's `sign_url`. Give `signer.email` for someone else (a mechanic who isn't on the aircraft): each entry then gets an `invitation_url`, a link that lets that person sign that entry with their account for that address, for 14 days. When the integration acts for an Owner of the aircraft, the link also lets them create that account; otherwise they need one first. Pass the link on yourself (for example inside Redmine), or set `send_email: true` to have SAM email it. diff --git a/docs/guide/logbook.md b/docs/guide/logbook.md index 221993d..7b1f8ef 100644 --- a/docs/guide/logbook.md +++ b/docs/guide/logbook.md @@ -7,7 +7,7 @@ The **Logbook** tab holds the maintenance record entries. Owners and Mechanics w **+ New Entry**: 1. Choose a **Template** to start the wording if one fits, and fill in its blanks (`__`). The built-in ones are for a pilot doing preventive maintenance on an aircraft they own or operate (14 CFR 43.3(g)); admins can add their own. -2. Fill in the date, the **logbook** (aircraft, engine, propeller or other), the **entry type** (usually maintenance or inspection) and the **airframe total time**. +2. Fill in the date, the **logbook** (aircraft, engine, propeller, avionics or other), the **entry type** (usually maintenance or inspection) and the **airframe total time**. 3. For an engine or propeller entry, pick the component: its total time and time since overhaul at the entry fill in from the airframe time. Tick any **sub-components** included in the work (an oil filter on the engine) to record their times as well. On a new entry, set a sub-component to **Serviced** or **Replaced** to record that on the Components tab at the same time (an oil and filter change resets their time since service), dated to the entry. Its time since service then counts from the airframe time on the entry. Under **Inspections completed**, tick any inspection the work completes (an Oil Change): it's recorded as done on the Inspections tab at the entry's date and airframe time, linked to the entry. diff --git a/docs/guide/records.md b/docs/guide/records.md index 23cece9..a5e46bd 100644 --- a/docs/guide/records.md +++ b/docs/guide/records.md @@ -4,7 +4,7 @@ These are the instructions for everyone who keeps or signs maintenance records h ## Writing an entry -On the aircraft's **Logbook** tab, choose **+ New Entry** (Owners and Mechanics: the **Write logbook entries** permission). Give the date, the logbook (aircraft, engine, propeller), the airframe total time and what was done. For an engine or propeller entry, pick the component (its times fill in) and tick any sub-components. A template can start the wording. An entry isn't a signed record until it's signed. See [The logbook](logbook.md). +On the aircraft's **Logbook** tab, choose **+ New Entry** (Owners and Mechanics: the **Write logbook entries** permission). Give the date, the logbook (aircraft, engine, propeller, avionics or other), the airframe total time and what was done. For an engine or propeller entry, pick the component (its times fill in) and tick any sub-components. A template can start the wording. An entry isn't a signed record until it's signed. See [The logbook](logbook.md). ## Signing diff --git a/test/integration/avionics_logbook_test.rb b/test/integration/avionics_logbook_test.rb new file mode 100644 index 0000000..39dc19d --- /dev/null +++ b/test/integration/avionics_logbook_test.rb @@ -0,0 +1,30 @@ +require "test_helper" + +# Aircraft with a separate avionics logbook file their radio, transponder +# and autopilot work under it. +class AvionicsLogbookTest < ActionDispatch::IntegrationTest + setup do + @owner = create_user("owner@example.com") + @a = create_aircraft(owner: @owner, tail_number: "N12345") + sign_in @owner + end + + test "an entry can be written to the avionics logbook and the list filtered to it" do + post aircraft_logbook_entries_path(@a), params: { logbook_entry: { date: "2026-10-01", log_type: "AVIONICS", entry_type: "MAINTENANCE", + text: "Replaced Comm 2 radio; operational check normal." } } + entry = @a.logbook_entries.sole + assert_equal "AVIONICS", entry.log_type + @a.logbook_entries.create!(date: Date.new(2026, 10, 2), log_type: "AC", entry_type: "MAINTENANCE", text: "Lubricated door hinges.") + + get aircraft_logbook_entries_path(@a, log_type: "AVIONICS") + assert_response :success + assert_includes response.body, "Replaced Comm 2 radio" + assert_not_includes response.body, "Lubricated door hinges" + assert_includes response.body, ">Avionics<" + end + + test "logbook transcription and the drafts API know the avionics logbook" do + assert LogbookEntry::LOG_TYPES.key?("AVIONICS") + assert_includes JSON.parse(Rails.root.join("app/services/logbook_transcriber/schema.json").read).to_s, "AVIONICS" + end +end