<% content_for :title, "#{@aircraft.tail_number} Weight & Balance" %> <%= render "shared/aircraft_header", aircraft: @aircraft %> <% setup = @aircraft.loading_setup %>

Current weight & balance

<% if owner? %><%= link_to "+ New W&B", new_aircraft_weight_balance_record_path(@aircraft), class: "btn-primary btn-sm" %><% end %>
<% if @current %>
As of
<%= fmt_date(@current.date) %><%= " ยท #{@current.reason}" if @current.reason.present? %>
Empty weight
<%= number_with_precision(@current.empty_weight, precision: 1, delimiter: ",") %> lb
Empty CG (arm)
<%= number_with_precision(@current.empty_arm, precision: 2) %> in
Moment
<%= number_with_precision(@current.empty_moment, precision: 0, delimiter: ",") %> lb-in
Max gross weight
<%= @current.max_gross_weight ? "#{number_with_precision(@current.max_gross_weight, precision: 0, delimiter: ',')} lb" : "โ€”" %>
Useful load
<%= @current.useful_load ? "#{number_with_precision(@current.useful_load, precision: 1, delimiter: ',')} lb" : "โ€”" %>
<% else %> <%= empty_state "No weight & balance recorded yet. Add the figures from the current W&B report." %> <% end %>

Loading calculator

<% if owner? %><%= link_to "Loading setup", edit_aircraft_loading_setup_path(@aircraft), class: "btn-secondary btn-sm" %><% end %>
<% if @current && setup.configured? %> <%= render "weight_balance_records/calculator", record: @current, setup: setup %> <% elsif !@current %> <%= empty_state "Record the current weight & balance first." %> <% else %> <%= empty_state(owner? ? "Set up the loading stations and CG envelope from the POH to use the calculator." : "An owner needs to set up the loading stations first.") %> <% end %>

History

<% if @records.any? %>
<% @records.each do |r| %> <% end %>
DateEmpty weightCGUseful loadReason
<%= fmt_date(r.date) %> <%= number_with_precision(r.empty_weight, precision: 1, delimiter: ",") %> lb <%= number_with_precision(r.empty_arm, precision: 2) %> in <%= r.useful_load ? "#{number_with_precision(r.useful_load, precision: 1, delimiter: ',')} lb" : "โ€”" %> <%= r.reason %> <% if r.major_record %>
<%= link_to r.major_record.title, aircraft_major_record_path(@aircraft, r.major_record), class: "link" %>
<% end %> <% if r.document %>
<%= link_to "๐Ÿ“„ #{r.document.name}", aircraft_document_path(@aircraft, r.document), class: "link" %>
<% end %>
<% if owner? %><%= link_to "Edit", edit_aircraft_weight_balance_record_path(@aircraft, r), class: "btn-secondary btn-sm" %><% end %>
<% else %><%= empty_state "No records yet." %><% end %>