diff --git a/config/locales/en.yml b/config/locales/en.yml
index 80ae640..6119a84 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -821,6 +821,7 @@ en:
flight_logs:
flight_already_logged: Flight already logged.
flight_logged_hrs: Flight logged (%{tach_time} hrs).
+ flight_corrected: Flight corrected.
choose_an_engine_data: Choose an engine data file.
engine_data_attached: Engine data attached.
engine_data_removed: Engine data removed.
@@ -2331,6 +2332,15 @@ en:
skipped: Skipped
warning: Warning
flight_logs:
+ edit:
+ correct_flight: Correct Flight
+ correct_the_flight_on: Correct the flight on %{date}
+ changing_the_readings: Changing the readings moves the aircraft's and its components' hours by the difference.
+ save: Save
+ cancel: Cancel
+ fields:
+ meters_locked_html: The readings can be corrected only on the latest flight, before the hours change again. To correct the hours, use %{link} on the Overview.
+ update_hours: Update Hours
days:
gps_track_attached: GPS track attached
engine_data_attached: Engine data attached
@@ -2437,6 +2447,7 @@ en:
flight_on_html: Flight on %{date}
delete_this_flight_log_aircraft: Delete this flight log? Aircraft and component hours will NOT be rolled back.
delete: Delete
+ edit: Edit
tach: Tach
hobbs: Hobbs
route: Route
@@ -3640,6 +3651,7 @@ en:
hours_notes: 'Previous: %{old}, delta: %{delta}'
consumable_added: "%{type} added: %{quantity} %{unit}"
flight_logged: 'Flight logged: %{hours} hrs'
+ flight_corrected: 'Flight corrected: %{date}'
flight_logged_route: 'Flight logged: %{hours} hrs (%{route})'
aircraft_grounded_error:
message: Aircraft is grounded and airworthiness enforcement is enabled
diff --git a/config/routes.rb b/config/routes.rb
index 83b894f..5f3e8bd 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -57,7 +57,7 @@ Rails.application.routes.draw do
resources :notes, except: :show do
post :preview, on: :collection
end
- resources :flight_logs, only: %i[index new create show destroy] do
+ resources :flight_logs, only: %i[index new create show edit update destroy] do
member do
get :engine_data, action: :engine_data_series
patch :engine_data, action: :attach_engine_data
diff --git a/docs/guide/flights.md b/docs/guide/flights.md
index f822159..0b1d4d2 100644
--- a/docs/guide/flights.md
+++ b/docs/guide/flights.md
@@ -17,6 +17,14 @@ On a phone or tablet with the app installed (see [Getting started](getting-start
Track and engine data files attached offline are kept and sent too.
+## Correct a flight
+
+Open the flight and choose **Edit**. Owners can correct any flight; a pilot, the flights they logged. The date, airports, route, notes, oil and fuel (its oil and fuel records follow), and the track and engine data files can always be changed.
+
+The meter readings can be changed only on the latest flight, and only until the hours change again (another flight, an hours update or an import). The aircraft and its installed components then move by the difference: fixing a tach in of 1001.4 to 1001.6 adds 0.2 hours. On earlier flights the readings are locked, since the flights after them started from those readings; correct the aircraft's hours with **Update Hours** instead.
+
+Deleting a flight (owners) doesn't take its hours back off; use **Update Hours** for that too.
+
## Update hours
When you don't log each flight, use **Update Hours** on the overview: enter the current meter readings and the difference is applied to every installed component. A reading lower than the current one is treated as a correction.
diff --git a/test/integration/flight_edit_test.rb b/test/integration/flight_edit_test.rb
new file mode 100644
index 0000000..5f069d3
--- /dev/null
+++ b/test/integration/flight_edit_test.rb
@@ -0,0 +1,111 @@
+require "test_helper"
+
+# Correcting a saved flight: everything can be fixed, but its meter readings
+# only on the latest flight (the aircraft and components then move by the
+# difference). Owners can correct any flight, a pilot the ones they logged.
+class FlightEditTest < ActionDispatch::IntegrationTest
+ setup do
+ @owner = create_user("owner@example.com")
+ @pilot = create_user("pilot@example.com")
+ @other = create_user("other@example.com")
+ @a = create_aircraft(owner: @owner, pilot: @pilot, tach_time: 1000)
+ @a.roles.create!(user: @other, role: "pilot")
+ @engine = create_component(@a, hours_in_service: 500, hours_since_overhaul: 100)
+ end
+
+ def log(user, tach_out:, tach_in:, **extra)
+ sign_in user
+ post aircraft_flight_logs_path(@a), params: { flight_log: { date: "2026-11-14", tach_out: tach_out, tach_in: tach_in, **extra } }
+ @a.flight_logs.order(:id).last
+ end
+
+ test "correcting the latest flight's reading moves the aircraft and components by the difference" do
+ flight = log(@owner, tach_out: 1000.0, tach_in: 1001.4)
+ assert_equal 1001.4, @a.reload.tach_time
+ assert_equal 501.4, @engine.reload.hours_in_service
+
+ get edit_aircraft_flight_log_path(@a, flight)
+ assert_select "fieldset[disabled]", 0
+ patch aircraft_flight_log_path(@a, flight), params: { flight_log: { tach_in: 1001.6, tach_time: 1.4, notes: "Fixed typo" } }
+ assert_redirected_to aircraft_flight_log_path(@a, flight)
+
+ flight.reload
+ assert_equal 1.6, flight.tach_time # worked out from the readings, not the stale duration
+ assert_equal "Fixed typo", flight.notes
+ assert_equal 1001.6, @a.reload.tach_time
+ assert_equal 501.6, @engine.reload.hours_in_service
+ assert_equal 101.6, @engine.hours_since_overhaul
+ assert_equal "Flight corrected: Nov 14, 2026", @a.events.where(category: "flight").first.event_name
+ assert_match "Tach in", @a.events.where(category: "flight").first.notes
+ end
+
+ test "an earlier flight's readings are locked; everything else can be corrected" do
+ first = log(@owner, tach_out: 1000.0, tach_in: 1001.4)
+ log(@owner, tach_out: 1001.4, tach_in: 1003.0)
+
+ get edit_aircraft_flight_log_path(@a, first)
+ assert_select "fieldset[disabled]", 2
+ assert_select ".hint a[href=?]", aircraft_path(@a), text: "Update Hours"
+
+ patch aircraft_flight_log_path(@a, first), params: { flight_log: { tach_in: 1009, tach_time: 9, destination_location: "kbos" } }
+ first.reload
+ assert_equal 1001.4, first.tach_in
+ assert_equal "KBOS", first.destination_location
+ assert_equal 1003.0, @a.reload.tach_time
+ assert_equal 503.0, @engine.reload.hours_in_service
+ end
+
+ test "after an hours update the latest flight's readings lock too" do
+ flight = log(@owner, tach_out: 1000.0, tach_in: 1001.4)
+ patch hours_aircraft_path(@a), params: { tach_time: 1002.0 }
+ refute flight.reload.meters_editable?
+
+ patch aircraft_flight_log_path(@a, flight), params: { flight_log: { tach_in: 1001.6 } }
+ assert_equal 1001.4, flight.reload.tach_in
+ assert_equal 1002.0, @a.reload.tach_time
+ end
+
+ test "a pilot can correct the flights they logged, not someone else's" do
+ flight = log(@pilot, tach_out: 1000.0, tach_in: 1001.4)
+ get aircraft_flight_log_path(@a, flight)
+ assert_select "a[href=?]", edit_aircraft_flight_log_path(@a, flight)
+ patch aircraft_flight_log_path(@a, flight), params: { flight_log: { notes: "Mine" } }
+ assert_equal "Mine", flight.reload.notes
+
+ delete session_path
+ sign_in @other
+ get aircraft_flight_log_path(@a, flight)
+ assert_select "a[href=?]", edit_aircraft_flight_log_path(@a, flight), 0
+ get edit_aircraft_flight_log_path(@a, flight)
+ assert_redirected_to aircraft_flight_log_path(@a, flight)
+ patch aircraft_flight_log_path(@a, flight), params: { flight_log: { notes: "Not mine" } }
+ assert_equal "Mine", flight.reload.notes
+
+ delete session_path
+ sign_in @owner
+ patch aircraft_flight_log_path(@a, flight), params: { flight_log: { notes: "Owner fixed" } }
+ assert_equal "Owner fixed", flight.reload.notes
+ end
+
+ test "oil and fuel records follow the correction" do
+ flight = log(@owner, tach_out: 1000.0, tach_in: 1001.4, fuel_added: 10)
+ assert_equal [ 10 ], flight.consumable_records.where(record_type: "fuel").pluck(:quantity_added)
+
+ patch aircraft_flight_log_path(@a, flight), params: { flight_log: { fuel_added: 12, oil_added: 1, oil_added_type: "W100" } }
+ assert_equal [ 12 ], flight.consumable_records.where(record_type: "fuel").pluck(:quantity_added)
+ assert_equal [ [ 1, "W100" ] ], flight.consumable_records.where(record_type: "oil").pluck(:quantity_added, :consumable_type)
+
+ patch aircraft_flight_log_path(@a, flight), params: { flight_log: { fuel_added: "" } }
+ assert_empty flight.consumable_records.where(record_type: "fuel")
+ assert_equal 1, flight.consumable_records.where(record_type: "oil").count
+ end
+
+ test "an invalid correction shows the form again and changes nothing" do
+ flight = log(@owner, tach_out: 1000.0, tach_in: 1001.4)
+ patch aircraft_flight_log_path(@a, flight), params: { flight_log: { date: "" } }
+ assert_response :unprocessable_entity
+ assert_select "fieldset[disabled]", 0 # still the latest flight
+ assert_equal Date.new(2026, 11, 14), flight.reload.date
+ assert_equal 1001.4, @a.reload.tach_time
+ end
+end