@php $d = $breakdown['irs_data']; $components = $breakdown['components']; $method = $breakdown['method']; $suggested = $breakdown['suggested']; $confidence = $breakdown['confidence'] ?? null; $needScore = $breakdown['need_score'] ?? null; $countryPts = $breakdown['country_pts'] ?? null; $directPts = $breakdown['direct_pts'] ?? null; $modifier = $d['activity_modifier'] ?? 0; $fmt = fn($v) => $v !== null ? '$' . number_format($v) : '—'; $pct = fn($v) => $v !== null ? $v . '%' : '—'; $source = strtoupper((string) ($charity->data_source ?? 'IRS')); $schedule = $source === 'CRA' ? 'Schedule 2' : 'Schedule F'; $methodCopy = match ($method) { 'regions_recipient_count' => 'Need score weighted by the number of recipients in each region (' . $schedule . ' Part III). Regions with more recipients pull the score toward their own median-income–based need.', 'regions_amount' => 'Need score weighted by the dollar amount sent to each region (' . $schedule . ' Parts II + III). Regions receiving more money have more influence.', 'country_codes' => 'Each country listed on ' . $schedule . ' weighted equally. Need per country = min(100, 50,000 ÷ median income).', 'ccew_equal_weight_country' => 'CCEW publishes no spend split by country, so each declared area of operation is weighted equally. Need per country = min(100, 50,000 ÷ median income).', 'foreign_no_geography' => 'Foreign activity flagged but no per-region or per-country data is reported — cannot assess recipient poverty. R3 is omitted from the composite.', 'domestic_only' => 'Domestic-only charity — out of AAA international-poverty scope. R3 is omitted from the composite.', 'not_applicable' => 'R3 not applicable.', default => 'Need score = min(100, 50,000 ÷ median income), then weighted by available data.', }; $regionRows = $d['region_details'] ?? []; $countryRows = $d['country_details'] ?? []; usort($regionRows, fn($a, $b) => $b['need_score'] <=> $a['need_score']); usort($countryRows, fn($a, $b) => $b['need_score'] <=> $a['need_score']); $hasRegions = !empty($regionRows); $hasCountries = !empty($countryRows); $omitted = in_array($method, ['foreign_no_geography', 'domestic_only', 'not_applicable'], true); $needBar = fn($v) => max(2, min(100, (float) $v)); // Re-derive direct-bonus sub-points for the breakdown display. $ratioPts = ($d['total_expenses'] ?? 0) > 0 ? round(min(15, ($d['grants_paid'] / $d['total_expenses']) * 15), 1) : 0; $indivPts = $d['grants_to_individuals'] ? 15 : 0; @endphp
Methodology @if($confidence) {{ strtoupper($confidence) }} confidence @endif

{{ $methodCopy }}

@unless($omitted)

Score = need × 70% + direct beneficiary bonus (up to 30) + activity-keyword modifier (−5 to +8). Lower median income → higher need → higher score.

@endunless
{{-- ── Component split ─────────────────────────────────────────────── --}}
Component Breakdown
@foreach($components as $c) @endforeach
Component Max Earned Calculation
{{ $c['label'] }} {{ $c['max'] }} {{ $c['earned'] === null ? 'N/A' : $c['earned'] }} {{ $c['explanation'] }}
{{-- ── Recipient table: regions or countries ───────────────────────── --}} @if($hasRegions)
Recipient Regions {{ count($regionRows) }} region{{ count($regionRows) === 1 ? '' : 's' }} · need {{ $needScore }}/100
@foreach($regionRows as $r) @endforeach
Region Median Income Amount Recipients Need Score
{{ $r['region'] }} ${{ number_format($r['median_income']) }} {{ ($r['amount'] ?? 0) > 0 ? $fmt((int) $r['amount']) : '—' }} {{ ($r['recipients'] ?? 0) > 0 ? number_format($r['recipients']) : '—' }}
{{ $r['need_score'] }}
@elseif($hasCountries)
Recipient Countries {{ count($countryRows) }} countr{{ count($countryRows) === 1 ? 'y' : 'ies' }} · need {{ $needScore }}/100
@foreach($countryRows as $r) @endforeach
Country Code Median Income Need Score
{{ $r['code'] }} ${{ number_format($r['median_income']) }}
{{ $r['need_score'] }}

Country codes follow each regulator's convention (IRS Schedule F = FIPS; CCEW / CRA = ISO or full names). FIPS codes differ from ISO (e.g. UK = United Kingdom, IZ = Iraq, JA = Japan).

@else

@if($method === 'foreign_no_geography') Foreign activities are flagged, but no per-region or per-country data was filed. R3 is omitted from the composite. @elseif($method === 'domestic_only') This organization does not report foreign activities — domestic-only, out of AAA scope. R3 is omitted from the composite. @else No recipient geography data available. @endif

@endif {{-- ── Direct beneficiary bonus details ────────────────────────────── --}} @unless($omitted)
Direct Beneficiary Bonus {{ $directPts ?? 0 }} / 30
{{ $d['grants_to_individuals'] ? '+15' : '0' }}
Grants to individuals
{{ $d['grants_to_individuals'] ? 'Org reports direct grants to individuals (flat +15)' : 'No direct grants to individuals reported' }}
+{{ $ratioPts }}
Grant ratio (grants ÷ total expenses)
{{ $fmt($d['grants_paid']) }} / {{ $fmt($d['total_expenses']) }} = {{ $pct($d['grant_ratio_pct']) }} · max +15
{{-- ── Activity-keyword modifier ────────────────────────────────── --}} @if($modifier !== 0)
Activity-Keyword Modifier {{ $modifier > 0 ? '+' : '' }}{{ $modifier }}
Keywords in the org's mission and program descriptions adjust the score: +5 for poverty/humanitarian language, +3 for vulnerable populations, −5 for indirect-aid language (advocacy, awareness, research, policy).
@endif @endunless {{-- ── Source IRS Data ─────────────────────────────────────────────── --}}
Source IRS Data @if(!empty($d['foreign_countries'])) @endif
{{ $schedule }} Filed {{ $d['schedule_f_filed'] ? 'Yes' : 'No' }}
Foreign Activities Flag {{ $d['foreign_activities'] ? 'Yes' : 'No' }}
Foreign Expenditures {{ $fmt($d['foreign_expenditures']) }}
Grants Paid {{ $fmt($d['grants_paid']) }} {{ $pct($d['grant_ratio_pct']) }} of expenses
Grants to Individuals {{ $d['grants_to_individuals'] ? 'Yes' : 'No' }}
Total Expenses {{ $fmt($d['total_expenses']) }}
Country Codes
@foreach($d['foreign_countries'] as $cc) {{ $cc }} @endforeach
Algorithm-suggested score {{ $suggested === null ? 'N/A — R3 omitted' : $suggested }}