use super::inputs::SelectedCompanyInputs;
use super::model::SelectedCompanySummaryFields;

pub(super) fn fill_selected_company_distress_fields(
    fields: &mut SelectedCompanySummaryFields,
    inputs: &SelectedCompanyInputs<'_>,
) {
    fields.selected_company_creditor_pressure_recent_bad_net_profit_year_count = inputs
        .creditor_pressure_state
        .as_ref()
        .map(|pressure_state| pressure_state.recent_bad_net_profit_year_count);
    fields.selected_company_creditor_pressure_recent_peak_revenue = inputs
        .creditor_pressure_state
        .as_ref()
        .and_then(|pressure_state| pressure_state.recent_peak_revenue);
    fields.selected_company_creditor_pressure_recent_three_year_net_profit_total = inputs
        .creditor_pressure_state
        .as_ref()
        .and_then(|pressure_state| pressure_state.recent_three_year_net_profit_total);
    fields.selected_company_creditor_pressure_cash_floor = inputs
        .creditor_pressure_state
        .as_ref()
        .and_then(|pressure_state| pressure_state.pressure_ladder_cash_floor);
    fields.selected_company_creditor_pressure_cash_plus_slot_12_total = inputs
        .creditor_pressure_state
        .as_ref()
        .and_then(|pressure_state| pressure_state.current_cash_plus_slot_12_total);
    fields.selected_company_creditor_pressure_share_price_floor = inputs
        .creditor_pressure_state
        .as_ref()
        .and_then(|pressure_state| pressure_state.support_adjusted_share_price_floor);
    fields.selected_company_creditor_pressure_share_price_scalar = inputs
        .creditor_pressure_state
        .as_ref()
        .and_then(|pressure_state| pressure_state.support_adjusted_share_price_scalar);
    fields.selected_company_creditor_pressure_current_fuel_cost = inputs
        .creditor_pressure_state
        .as_ref()
        .and_then(|pressure_state| pressure_state.current_fuel_cost);
    fields.selected_company_creditor_pressure_current_fuel_cost_floor = inputs
        .creditor_pressure_state
        .as_ref()
        .and_then(|pressure_state| pressure_state.current_fuel_cost_floor);
    fields.selected_company_creditor_pressure_eligible_for_bankruptcy_branch = inputs
        .creditor_pressure_state
        .as_ref()
        .map(|pressure_state| pressure_state.eligible_for_bankruptcy_branch);
    fields.selected_company_deep_distress_current_cash = inputs
        .deep_distress_state
        .as_ref()
        .and_then(|pressure_state| pressure_state.current_cash);
    fields.selected_company_deep_distress_recent_first_three_net_profit_years = inputs
        .deep_distress_state
        .as_ref()
        .map(|pressure_state| pressure_state.recent_first_three_net_profit_years.clone())
        .unwrap_or_default();
    fields.selected_company_deep_distress_cash_floor = inputs
        .deep_distress_state
        .as_ref()
        .and_then(|pressure_state| pressure_state.deep_distress_cash_floor);
    fields.selected_company_deep_distress_net_profit_floor = inputs
        .deep_distress_state
        .as_ref()
        .and_then(|pressure_state| pressure_state.deep_distress_net_profit_floor);
    fields.selected_company_deep_distress_eligible_for_bankruptcy_fallback = inputs
        .deep_distress_state
        .as_ref()
        .map(|pressure_state| pressure_state.eligible_for_bankruptcy_fallback);
}
