@php $d = $breakdown['irs_data']; $components = $breakdown['components']; $suggested = $breakdown['suggested']; $method = $breakdown['method']; $needScore = $breakdown['need_score']; $countryPts = $breakdown['country_pts']; $directPts = $breakdown['direct_pts']; $fmt = fn($v) => $v !== null ? '$' . number_format($v) : '—'; $pct = fn($v) => $v !== null ? $v . '%' : '—'; $badge = fn($bool, $yes='Yes', $no='No') => '' .($bool ? $yes : $no).''; $source = strtoupper((string) ($record->data_source ?? 'IRS')); $schedule = $source === 'CRA' ? 'Schedule 2' : 'Schedule F'; $confidence = $breakdown['confidence'] ?? null; $methodLabels = [ 'regions_recipient_count' => $schedule . ' Regions (RecipientCnt weighted)', 'regions_amount' => $schedule . ' Regions (amount weighted)', 'country_codes' => 'Country Codes (equal weight)', 'ccew_equal_weight_country' => 'CCEW Areas of Operation (equal weight)', 'foreign_no_geography' => 'Foreign Activity, No Geography', 'domestic_only' => 'Domestic Only (out of AAA scope)', 'not_applicable' => 'Not Applicable', ]; $methodColors = [ 'regions_recipient_count' => '#065f46', 'regions_amount' => '#0369a1', 'country_codes' => '#059669', 'ccew_equal_weight_country' => '#7c3aed', 'foreign_no_geography' => '#d97706', 'domestic_only' => '#9ca3af', 'not_applicable' => '#9ca3af', ]; $methodLabel = $methodLabels[$method] ?? $method; $methodColor = $methodColors[$method] ?? '#6b7280'; $confColors = ['high' => '#15803d', 'medium' => '#d97706', 'low' => '#b91c1c']; $hasScheduleF = $d['schedule_f_filed']; $countries = $d['foreign_countries'] ?? []; $countryDetails = $d['country_details'] ?? []; $regionDetails = $d['region_details'] ?? []; $grantRegions = $d['grant_regions'] ?? []; $indivRegions = $d['indiv_regions'] ?? []; @endphp
{{-- Status Badges --}}
Foreign Activities: {!! $badge($d['foreign_activities']) !!}
{{ $schedule }} Filed: {!! $badge($hasScheduleF) !!}
Grants to Individuals: {!! $badge($d['grants_to_individuals']) !!}
{{-- No Schedule F notice --}} @if(!$hasScheduleF && empty($countries))
No {{ $schedule }} data available. @if($d['foreign_activities']) Foreign activities are indicated, but no country/region detail is filed. Scoring falls back to a flat 50/70 country need score. @else No foreign activities reported. Scoring falls back to a flat 20/70 (domestic only). @endif Re-load the XML data after the {{ $schedule }} migration to see detailed country scoring.
@endif {{-- Financial data table --}} @if($d['foreign_expenditures']) @endif
Field Value
Grants Paid
{{ $fmt($d['grants_paid']) }}
Total Expenses
{{ $fmt($d['total_expenses']) }}
Grant Ratio
{{ $pct($d['grant_ratio_pct']) }}
Foreign Expenditures ({{ $schedule }})
{{ $fmt($d['foreign_expenditures']) }}
{{-- Countries served --}} @if(count($countryDetails) > 0)
Countries Served ({{ count($countryDetails) }})
@foreach($countryDetails as $ctry) @endforeach
FIPS Median Income Need Score
{{ $ctry['code'] }} {{ $fmt($ctry['median_income']) }} {{ $ctry['need_score'] }}
@endif {{-- Region data --}} @if(count($regionDetails) > 0)
{{ $schedule }} Regions
@foreach($regionDetails as $reg) @endforeach
Region Recipients Amount Median Income Need Score
{{ $reg['region'] }} {{ !empty($reg['recipients']) ? number_format($reg['recipients']) : '—' }} {{ $reg['amount'] > 0 ? $fmt($reg['amount']) : '—' }} {{ $fmt($reg['median_income']) }} {{ $reg['need_score'] }}
@endif {{-- Methodology callout --}}
Methodology
{{ $methodLabel }}

@if($method === 'domestic_only') Domestic-only charity — out of AAA international-poverty scope. Neutral 25/100 fallback (low confidence). @elseif($method === 'foreign_no_geography') Foreign activity flagged but no countries listed. Neutral 25/100 fallback (low confidence). @else Country need score formula: min(100, 50000 ÷ median_income) → Weighted average = {{ $needScore }} → × 0.70 = {{ $countryPts }} pts @if(($d['activity_modifier'] ?? 0) !== 0) + activity modifier {{ $d['activity_modifier'] > 0 ? '+' : '' }}{{ $d['activity_modifier'] }} @endif @endif

@foreach($components as $comp) @endforeach
Component Max Earned Calculation
{{ $comp['label'] }} {{ $comp['max'] }} {{ $comp['earned'] === null ? 'N/A' : $comp['earned'] }} {{ $comp['explanation'] }}
Suggested score: {{ $suggested === null ? 'N/A' : $suggested }} @if($confidence) {{ strtoupper($confidence) }} confidence @endif