<%= f.field :recurring_hours, as: :number, step: 0.1, label: "Every (hours)" %>
- <%= f.field :recurring_months, as: :number, label: "Every (calendar months)", hint: "Due end of month." %>
- <%= f.field :recurring_days, as: :number, label: "Every (days)" %>
+ <%= f.interval :recurring, label: "Every", wrapper: { class: "sm:col-span-2" },
+ hint: "Months and years are calendar months: due at the end of the month (an annual done March 10 is due by the end of next March)." %>
diff --git a/app/views/weight_balance_records/_calculator.html.erb b/app/views/weight_balance_records/_calculator.html.erb
new file mode 100644
index 0000000..6048e26
--- /dev/null
+++ b/app/views/weight_balance_records/_calculator.html.erb
@@ -0,0 +1,34 @@
+<%# The loading calculator (W&B tab). %>
+
+
+ <% setup.stations.each do |st| %>
+
+ <% end %>
+ <% if setup.stations.any?(&:fuel) %>
+
+ <% end %>
+
+
+
+
Weight
CG
Moment
+
+
Takeoff
—
—
—
+
Landing
—
—
—
+
+
+
+
+
+
A planning aid from the figures entered here. Check against the POH and the aircraft's current W&B report.
+
diff --git a/app/views/weight_balance_records/index.html.erb b/app/views/weight_balance_records/index.html.erb
index 6c368b2..d1ef670 100644
--- a/app/views/weight_balance_records/index.html.erb
+++ b/app/views/weight_balance_records/index.html.erb
@@ -27,39 +27,7 @@
<% if owner? %><%= link_to "Loading setup", edit_aircraft_loading_setup_path(@aircraft), class: "btn-secondary btn-sm" %><% end %>
<% if @current && setup.configured? %>
-
-
- <% setup.stations.each do |st| %>
-
- <% end %>
- <% if setup.stations.any?(&:fuel) %>
-
- <% end %>
-
-
-
-
Weight
CG
Moment
-
-
Takeoff
—
—
—
-
Landing
—
—
—
-
-
-
-
-
-
A planning aid from the figures entered here. Check against the POH and the aircraft's current W&B report.
-
+ <%= render "weight_balance_records/calculator", record: @current, setup: setup %>
<% elsif !@current %>
<%= empty_state "Record the current weight & balance first." %>
<% else %>
diff --git a/db/migrate/20261112010000_add_month_intervals_to_components.rb b/db/migrate/20261112010000_add_month_intervals_to_components.rb
new file mode 100644
index 0000000..0a96b0c
--- /dev/null
+++ b/db/migrate/20261112010000_add_month_intervals_to_components.rb
@@ -0,0 +1,9 @@
+# Component limits can be set in months or years (stored as months), not
+# only days: "replace every 12 months" lands on the same date next year.
+class AddMonthIntervalsToComponents < ActiveRecord::Migration[8.1]
+ def change
+ add_column :components, :replacement_months, :integer
+ add_column :components, :tbo_months, :integer
+ add_column :components, :inspection_months, :integer
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 6363f10..c35d2b4 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -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_11_050000) do
+ActiveRecord::Schema[8.1].define(version: 2026_11_12_010000) do
create_table "active_storage_attachments", force: :cascade do |t|
t.string "name", null: false
t.string "record_type", null: false
@@ -353,6 +353,9 @@ ActiveRecord::Schema[8.1].define(version: 2026_11_11_050000) do
t.datetime "updated_at", null: false
t.date "expires_on"
t.string "overhaul_kind"
+ t.integer "replacement_months"
+ t.integer "tbo_months"
+ t.integer "inspection_months"
t.index ["aircraft_id"], name: "index_components_on_aircraft_id"
t.index ["component_type_id"], name: "index_components_on_component_type_id"
t.index ["parent_component_id"], name: "index_components_on_parent_component_id"
diff --git a/docs/guide/ads.md b/docs/guide/ads.md
index b15216c..a22baee 100644
--- a/docs/guide/ads.md
+++ b/docs/guide/ads.md
@@ -4,7 +4,7 @@ The **ADs** tab lists the ADs and bulletins that apply to the aircraft or its co
## Adding ADs
-- **+ New AD**: the number, type (AD, SAIB, SB, alert, other), standard or conditional, what it requires, whether it recurs (every so many hours and/or months; due at the end of the month) and a link to the AD. A conditional AD only applies when its trigger happens (“on prop strike”) and doesn't affect airworthiness. Non-mandatory bulletins can be tracked too.
+- **+ New AD**: the number, type (AD, SAIB, SB, alert, other), standard or conditional, what it requires, whether it recurs (every so many hours and/or days, months or years; months and years are due at the end of the month) and a link to the AD. A conditional AD only applies when its trigger happens (“on prop strike”) and doesn't affect airworthiness. Non-mandatory bulletins can be tracked too.
- **Link existing**: ADs are shared between aircraft; link one already entered for another aircraft.
- **Import from FAA DRS**: export the ADs for the aircraft, engine and propeller from the FAA's Dynamic Regulatory System, preferably as `.xlsx` so each AD keeps its DRS link, and upload it. The preview suggests **Track**, **Not applicable** or **Skip** for each AD and flags superseded ADs, model mismatches, appliance and STC-only ADs, and recurring actions. Nothing is duplicated.
diff --git a/docs/guide/aircraft.md b/docs/guide/aircraft.md
index 9bfe9f8..52b858b 100644
--- a/docs/guide/aircraft.md
+++ b/docs/guide/aircraft.md
@@ -10,6 +10,8 @@ The **Overview** tab shows:
- **Airworthiness**: the overall status and each reason for it.
- **Active squawks**, **Consumption** (oil and fuel rates), **Notes** and **Recent activity**.
+- **Coming due**: anything due in the next 30 days or 10 hours. Dates marked "~" are estimated from the last year's flying.
+- **Last flight**: the most recent day's legs as one route, the meters at the end, and the fuel and oil left.
- **Update Hours**: enter the current meter readings (see [Flights and hours](flights.md)).
- **Details** and the **Status report** link.
diff --git a/docs/guide/components.md b/docs/guide/components.md
index d5e5ba2..c24960e 100644
--- a/docs/guide/components.md
+++ b/docs/guide/components.md
@@ -9,10 +9,10 @@ The **Components** tab is a tree of the aircraft's parts: engine, propeller, mag
- **Type** (pick one, or type a new one), manufacturer, model, serial number, install location and status.
- **Time**: date in service, total time, last overhaul or service, hours since, and for engines and propellers the overhaul kind (printed in logbook entries as SMOH, SFOH or SNEW).
- **Limits**:
- - **Replace every** hours and/or days; **Replacement critical** makes overdue replacement ground the aircraft (oil, filters, ELT battery…).
+ - **Replace every** hours and/or a calendar interval in days, months or years (whichever comes first); **Replacement critical** makes overdue replacement ground the aircraft (oil, filters, ELT battery…).
- **Expires on**: a date marked on the part, such as an ELT battery's.
- - **TBO** hours and/or days. Under Part 91 TBO is usually a recommendation; tick **Treat TBO as a hard limit** only when an AD or the airworthiness limitations make it one, or **On condition** to show it without warnings.
- - **Inspect every** hours and/or days, optionally critical.
+ - **TBO** hours and/or a calendar interval. Under Part 91 TBO is usually a recommendation; tick **Treat TBO as a hard limit** only when an AD or the airworthiness limitations make it one, or **On condition** to show it without warnings.
+ - **Inspect every** hours and/or a calendar interval, counted from the component's last service. For an inspection with its own records (an oil change, a magneto inspection, the ELT check), set it up on the **Inspections** tab and apply it to the component instead: the inspection then governs and the component's own interval is ignored.
Logged hours are added to every component that's in service.
diff --git a/docs/guide/inspections.md b/docs/guide/inspections.md
index dcef636..2580d08 100644
--- a/docs/guide/inspections.md
+++ b/docs/guide/inspections.md
@@ -8,7 +8,7 @@ The **Inspections** tab shows each required inspection, when it was last done an
**+ Inspection Type** adds your own, for example a recurring inspection from an STC's instructions for continued airworthiness. Each type has:
-- **Recurring** every so many hours, calendar months (due at the end of the month) and/or days.
+- **Recurring** every so many hours and/or days, months or years (months and years are calendar months, due at the end of the month).
- What overdue means: **grounds the aircraft**, **no IFR flight** (91.411), **transponder can't be used** (91.413), or **advisory only**.
- **Overrun allowance**: for the 100-hour, 10 hours. Done late within it, the next one counts from when it was due (91.409(b)).
- **Also counts as**: an annual also counts as the 100-hour.
diff --git a/test/integration/overview_due_and_intervals_test.rb b/test/integration/overview_due_and_intervals_test.rb
new file mode 100644
index 0000000..0611520
--- /dev/null
+++ b/test/integration/overview_due_and_intervals_test.rb
@@ -0,0 +1,104 @@
+require "test_helper"
+
+# The Overview's Last flight and Coming due cards, and intervals entered as
+# days, months or years.
+class OverviewDueAndIntervalsTest < ActionDispatch::IntegrationTest
+ setup do
+ @owner = create_user("owner@example.com")
+ @pilot = create_user("pilot@example.com")
+ @a = create_aircraft(owner: @owner, pilot: @pilot, tail_number: "N12345", tach_time: 1000)
+ @a.flight_logs.create!(date: Date.current - 20, tach_time: 1.0, departure_location: "KAAA", destination_location: "KAAA")
+ @a.flight_logs.create!(date: Date.current - 3, tach_time: 1.2, departure_location: "KAAA", destination_location: "KBBB")
+ @a.flight_logs.create!(date: Date.current - 3, tach_time: 0.9, departure_location: "KBBB", destination_location: "KAAA",
+ tach_in: 1000, fuel_level_after: 18, oil_level_after: 5)
+ @oil = create_component(@a, component_type: component_type("Oil"), manufacturer: "Phillips", model: "20W50",
+ replacement_hours: 50, hours_since_overhaul: 46, overhaul_date: Date.current - 30)
+ create_component(@a, component_type: component_type("Magneto"), manufacturer: "Bendix", model: "S4LN-21",
+ replacement_hours: 500, hours_since_overhaul: 100, overhaul_date: Date.current - 30)
+ end
+
+ test "the overview shows the last day's flying and what's coming due" do
+ sign_in @pilot
+ get aircraft_path(@a)
+ assert_response :success
+ body = response.body
+ assert_includes body, "KAAA → KBBB → KAAA"
+ assert_includes body, "2 legs"
+ assert_includes body, "18 gal"
+ assert_includes body, "5 qt"
+ assert_includes body, "Replace Oil" # 4 hrs left
+ assert_not_includes body, "Replace Magneto" # 400 hrs left
+ end
+
+ test "the overview copes with nothing logged" do
+ bare = create_aircraft(owner: @owner, tail_number: "N54321")
+ sign_in @owner
+ get aircraft_path(bare)
+ assert_response :success
+ assert_includes response.body, "No flights logged yet."
+ assert_includes response.body, "Nothing coming due soon."
+ end
+
+ test "hours already run out count as overdue; an inspection covering a component replaces its own interval" do
+ filter = create_component(@a, component_type: component_type("Oil Filter"), manufacturer: "Champion", model: "CH48110",
+ inspection_hours: 50, hours_since_overhaul: 60, overhaul_date: Date.current - 300)
+ mag = create_component(@a, component_type: component_type("Magneto"), manufacturer: "Slick", model: "4371",
+ inspection_hours: 500, hours_since_overhaul: 120, overhaul_date: Date.current - 300)
+ items = DueList.new(@a).items.index_by(&:key)
+ assert items["inspect-#{filter.id}"].overdue?
+ assert_equal Date.current, items["inspect-#{filter.id}"].date
+ refute items["replace-#{@oil.id}"].overdue?
+
+ type = InspectionType.create!(name: "Oil change", effect: "advisory", recurring: true, recurring_hours: 50)
+ type.components << filter
+ assert_nil DueList.new(@a).items.find { _1.key == "inspect-#{filter.id}" }
+ assert DueList.new(@a).items.find { _1.key == "inspect-#{mag.id}" }
+ end
+
+ test "a component limit in years is stored as months and lands on the same date" do
+ sign_in @owner
+ get edit_aircraft_component_path(@a, @oil)
+ assert_select "select[name='component[replacement_unit]'] option", text: "years"
+
+ patch aircraft_component_path(@a, @oil), params: { component: { replacement_every: "2", replacement_unit: "years",
+ overhaul_date: "2026-03-10" } }
+ @oil.reload
+ assert_equal [ nil, 24 ], [ @oil.replacement_days, @oil.replacement_months ]
+ assert_equal Date.new(2028, 3, 10), @oil.next_replacement_date
+ assert_equal "2 years", @oil.replacement_interval_label
+
+ get edit_aircraft_component_path(@a, @oil)
+ assert_select "input[name='component[replacement_every]'][value='2']"
+ assert_select "select[name='component[replacement_unit]'] option[selected]", text: "years"
+
+ patch aircraft_component_path(@a, @oil), params: { component: { replacement_every: "90", replacement_unit: "days" } }
+ assert_equal [ 90, nil ], @oil.reload.then { [ _1.replacement_days, _1.replacement_months ] }
+
+ patch aircraft_component_path(@a, @oil), params: { component: { replacement_every: "", replacement_unit: "days" } }
+ assert_equal [ nil, nil ], @oil.reload.then { [ _1.replacement_days, _1.replacement_months ] }
+
+ patch aircraft_component_path(@a, @oil), params: { component: { replacement_every: "1.5", replacement_unit: "months" } }
+ assert_response :unprocessable_entity
+ assert_includes response.body, "must be a whole number more than 0"
+ end
+
+ test "inspection types and ADs take months or years, still due at the end of the month" do
+ sign_in @owner
+ post aircraft_inspection_types_path(@a), params: { inspection_type: { name: "ELT check", effect: "grounds", recurring: "1",
+ recurring_hours: "0", recurring_every: "1", recurring_unit: "years" },
+ applies_to_airframe: "1" }
+ type = InspectionType.find_by!(name: "ELT check")
+ assert_equal [ 12, 0 ], [ type.recurring_months, type.recurring_days ]
+ assert_equal "Every 1 year", type.interval_description
+
+ ad = AirworthinessDirective.new(name: "2020-01-01", short_description: "Seat rails", recurring: true, recurring_every: "100", recurring_unit: "days")
+ ad.valid?
+ assert_equal [ 100, 0 ], [ ad.recurring_days, ad.recurring_months ]
+ assert_equal({ hours: 0.0, months: 0, days: 100 }, ad.due_rule)
+ ad.recurring_every = "2"
+ ad.recurring_unit = "years"
+ ad.valid?
+ assert_equal [ 0, 24 ], [ ad.recurring_days, ad.recurring_months ]
+ assert_equal "2 years", ad.recurring_interval_label
+ end
+end