# CRA T3010 Dataset Reference

How the Canada Revenue Agency's annual *List of Charities* dataset is structured, what each CSV contains, and exactly how every field flows into the `charities` table. Source: [load_cra.py](load_cra.py), with column maps verified against the 2024 dataset (`80c00cdb-1358-415c-bb8b-0de7f12675b8`).

---

## 1. How the data is published

The CRA publishes one **CKAN dataset per fiscal year** on `open.canada.ca`. A dataset bundles ~20 bilingual CSVs — one CSV per T3010 section/schedule. Discovery uses the CKAN API:

```
https://open.canada.ca/data/en/api/3/action/package_show?id={dataset_id}
```

**Important:** the API and CSV downloads sit behind a WAF that rejects the literal `Mozilla/5.0` User-Agent with an HTML "Request Rejected" page. The loader sends a full Chrome UA string ([load_cra.py:48-51](load_cra.py#L48-L51)).

Every CSV is keyed by `(BN, FPE)` — Business Number + Fiscal Period End. BN format: `123456789RR0001` (9-digit corporation number + 4-char program account). FPE is `YYYY-MM-DD`. The loader collapses FPE to a 4-digit year and joins everything on `(registration_number, tax_year)`.

---

## 2. CSV inventory (2024 dataset)

| Slug (`RESOURCE_PATTERNS`) | Filename | Loaded? | What it holds |
|---|---|---|---|
| `ident` | `ident_2024.csv` | ✅ | Charity identity: BN, name, address, designation |
| `section_abc` | `financial_section_a_b_and_c_2024_updated.csv` | ✅ (partial) | T3010 Sections A/B/C — program codes + some operational lines |
| `schedule_6` | `financial_d_and_schedule_6_2024_updated.csv` | ✅ | The bulk of revenue/expense/asset line items |
| `sch2_countries` | `schedule_2_countries_2024.csv` | ✅ | One row per country of foreign activity |
| `sch2_resources` | `schedule_2_resources_2024_updated.csv` | ✅ | Per-recipient cash sent outside Canada |
| `sch2_goods` | `schedule_2_goods_2024.csv` | ✅ | Per-item in-kind goods sent outside Canada |
| `sch2_details` | `schedule_2_details_2024.csv` | ❌ | Y/N flags for *types* of foreign activity (lines 200-260) |
| `sch3_compensation` | `schedule_3_compensation_2024.csv` | ✅ | Compensation: position counts per $40k band + total $ |
| `programs` | `new_ongoing_programs_2024_updated.csv` | ✅ | Free-text descriptions of ongoing programs |
| `directors` | `directors_2024_updated.csv` | ✅ | Board members & officers (name + position) |
| — | `qualified_donees_2024_updated.csv` | ❌ | Cash grants to other Canadian charities |
| — | `non_qualified_donees_2024_updated.csv` | ❌ | Grants to non-charity beneficiaries |
| — | `schedule_1_foundations_2024.csv` | ❌ | Foundation-specific (disbursement quota etc.) |
| — | `schedule_5_gifts_in_kind_2024_updated.csv` | ❌ | Gifts in kind received |
| — | `schedule_7_pa_description_2024.csv` | ❌ | Political-activity narrative |
| — | `schedule_7_pa_funding_from_outside_ca_2024.csv` | ❌ | Foreign funding for political activity |
| — | `schedule_7_pa_resources_2024.csv` | ❌ | Resources spent on political activity |
| — | `schedule_8_dq_2024.csv` | ❌ | Disbursement quota calculations |
| — | `weburl_2024_updated.csv` | ❌ | Charity website URLs |

The dataset also publishes French (`_fr.csv` / `_fra.csv`) duplicates of most resources; `is_english_csv()` filters them out at discovery time.

---

## 3. CSV column reference

Every CSV has been verified by hitting the URL and reading the header row.

### `ident_2024.csv`
```
BN, Category, Sub Category, Designation, Legal Name, Account Name,
Address Line 1, Address Line 2, City, Province, Postal Code, Country
```
- **Category / Sub Category**: CRA's activity taxonomy (e.g. *Welfare → Disaster relief*).
- **Designation**: "Charitable Organization", "Public Foundation", "Private Foundation".
- **Legal Name** vs **Account Name**: the legal corporate name vs the operating/public name.

### `directors_2024_updated.csv`
```
BN, FPE, Form ID, #, Last Name, First Name, Initials, Position,
At Arm's Length, Start Date, End Date
```
- **Position**: free-text, common values include `Director`, `President`, `Chairperson`, `Treasurer/Director`, `Executive Director`, `CEO`.
- **At Arm's Length**: `Y`/`N` — does the director have an outside business relationship with the charity.

### `financial_d_and_schedule_6_*.csv`
```
BN, FPE, Form ID, Section Used,
4020, 4050, 4100, 4110, 4120, 4130, 4140, 4150, 4155, 4160, 4165, 4166,
4170, 4180, 4200, 4250, 4300, 4310, 4320, 4330, 4350, 4400, 4490, 4500,
5610, 4505, 4510, 4530, 4540, 4550, 4560, 4565, 4570, 4571, 4575, 4580,
4590, 4600, 4610, 4620, 4630, 4640, 4650, 4655, 4700, 4800, 4810, 4820,
4830, 4840, 4850, 4860, 4870, 4880, 4890, 4891, 4900, 4910, 4920, 4930,
4950, 5000, 5010, 5020, 5030, 5040, 5050, 5100, 5500, 5510, 5750, 5900,
5910, 5045, 4101, 4102, 4157, 4158, 4190, 4576, 4577
```
Most useful lines (per T3010 form guide):
| Line | Meaning |
|---|---|
| 4020-4180 | Asset categories (cash, receivables, investments, inventory, capital assets) |
| 4200 | Total assets (book value, at fair market value on some forms) |
| 4250-4350 | Liabilities |
| 4400 | Total liabilities |
| 4500 | Total tax-receipted gifts |
| 4510-4655 | Revenue breakdowns (gifts not receipted, government, investment, fundraising, sales) |
| 4700 | **Total revenue** |
| 4800-4930 | Expense categories (advertising, office, travel, occupancy, prof. fees, etc.) |
| 5000 | **Expenditures on charitable activities** |
| 5010 | **Management and administration expenditures** |
| 5020 | **Fundraising expenditures** |
| 5030-5045 | Political activity / other expenditure subtotals |
| 5050 | **Total gifts to qualified donees** |
| 5100 | **Total expenditures** |
| 5500-5910 | Schedule 6 fair-market-value disclosures, accumulated DQ |

### `financial_section_a_b_and_c_*.csv`
```
BN, FPE, Form ID,
Program #1 Code, Program #1 %, Program #1 Desc,
Program #2 Code, Program #2 %, Program #2 Desc,
Program #3 Code, Program #3 %, Program #3 Desc,
1510, 1510-BN, 1510-Name, 1570, 1600, 1800, 2000, 2100, 2400,
5030  , 5031, 5032, 2500, 2510, 2530, 2540, 2550, 2560, 2570,
2575, 2580, 2590, 2600, 2610, 2620, 2630, 2640, 2650, 2660,
2700, 5450, 5460, 2730, 2740, 2750, 2760, 2770, 2780, 2790,
2800, 3200, 3400, 3900, 4000, 5800-5864
```
- **Program #N Code / % / Desc**: top-3 program activity codes (CRA standard categorization) and what share of the charity's resources each consumes.
- **1510 / 1510-BN / 1510-Name**: associated charity (cross-references another BN).
- **2000-2800**: Section B "general information" — checkboxes about activities (e.g. fundraising methods, gaming, related businesses).
- **5800-5864**: fundraising-method flags (door-to-door, mail, telemarketing, etc.).
- **Note**: in earlier T3010 forms, lines 4700/5000/5100 lived here. They moved to Schedule 6. The loader uses `_apply_financials` on both files so whichever has the data wins.

### `schedule_2_countries_2024.csv`
```
BN, FPE, Form ID, #, Country
```
One row per country the charity operated in. **Country** is sometimes a 2-letter ISO code, sometimes a full name — depends on the year. The 2024 file uses codes.

### `schedule_2_resources_2024_updated.csv`
```
BN, FPE, Form ID, #, Indiv/Org Name, Amount, Country
```
One row per *recipient* of cash sent abroad. **Amount** is CAD dollars.

### `schedule_2_goods_2024.csv`
```
BN, FPE, Form ID, #, Item Name, Item Value, Destination, Country
```
One row per in-kind item shipped abroad. **Item Value** is the declared fair-market value (CAD).

### `schedule_2_details_2024.csv`
```
BN, FPE, Form ID, 200, 210, 220, 230, 240, 250, 260
```
Y/N flags answering "did the charity carry on activities outside Canada through…":
- 200 = activities at all outside Canada
- 210-260 = via employees / volunteers / agents / joint ventures / intermediaries / contractors

### `schedule_3_compensation_2024.csv`
```
BN, FPE, Form ID,
300, 305, 310, 315, 320, 325, 330, 335, 340, 345,
370, 380, 390
```
- **300-345**: count of permanent positions in each compensation band.
- **370**: average number of part-time / part-year positions.
- **380**: total expenditure on FT compensation (CAD).
- **390**: total compensation expenditure including all positions (CAD).

Compensation bands (each col → annual $ range):

| Col | Range |
|---|---|
| 300 | $1 – 39,999 |
| 305 | $40,000 – 79,999 |
| 310 | $80,000 – 119,999 |
| 315 | $120,000 – 159,999 |
| 320 | $160,000 – 199,999 |
| 325 | $200,000 – 249,999 |
| 330 | $250,000 – 299,999 |
| 335 | $300,000 – 349,999 |
| 340 | $350,000 + |
| 345 | $400,000 + *(some years)* |

**Critically**: CRA does *not* publish individual salaries, only counts per band. So `ceo_comp` can only be approximated by the lower bound of the highest non-empty band.

### `new_ongoing_programs_2024_updated.csv`
```
BN, FPE, Form ID, Program Type, Description
```
Many rows per charity — one per ongoing program. **Description** is free text up to ~65k chars.

---

## 4. `charities` column → CRA source map

`SHARED_COLUMNS` is defined in [loader_common.py:25-43](loader_common.py#L25-L43). Below: each column, where the CRA value comes from, and the function that writes it.

### Identity & metadata

| Column | CRA source | Writer |
|---|---|---|
| `country_code` | constant `"CA"` | [parse_ident()](load_cra.py#L170) |
| `data_source` | constant `"CRA"` | [parse_ident()](load_cra.py#L170) |
| `form_type` | constant `"T3010"` | [parse_ident()](load_cra.py#L170) |
| `registration_number` | `ident.BN` | [parse_ident()](load_cra.py#L170) |
| `name` | `ident.Legal Name` → fallback `Account Name` | [parse_ident()](load_cra.py#L170) |
| `tax_year` | filename year, fallback `FPE` year | `reg_year_key()` + `year_from_filename()` |
| `city` | `ident.City` | [parse_ident()](load_cra.py#L170) |
| `state` | `ident.Province` | [parse_ident()](load_cra.py#L170) |
| `ein` | always NULL (US-only concept) | — |
| `sub_jurisdiction` | always NULL (could hold province in future) | — |

### Officer / compensation

| Column | CRA source | Writer |
|---|---|---|
| `ceo_name` | `directors.First Name` + `Last Name` of highest-tier officer | [merge_directors()](load_cra.py#L394) |
| `ceo_title` | `directors.Position` of that officer | [merge_directors()](load_cra.py#L394) |
| `ceo_comp` | Schedule 3 highest non-empty band's lower bound | [merge_sch3_compensation()](load_cra.py#L362) |
| `salaries` | Schedule 3 line **390** (fallback 380) | [merge_sch3_compensation()](load_cra.py#L362) |
| `employees` | sum of Schedule 3 lines 300-345 | [merge_sch3_compensation()](load_cra.py#L362) |

Title priority (best → worst): `CEO` → `Executive Director` → `President` → `Chair/Chairperson` ([_CEO_TITLE_TIERS](load_cra.py#L380)).

### Financials

| Column | CRA source | Writer |
|---|---|---|
| `total_revenue` | Schedule 6 line **4700** | [_apply_financials()](load_cra.py#L207) |
| `total_expenses` | Schedule 6 line **5100** | _apply_financials |
| `program_expenses` | Schedule 6 line **5000** | _apply_financials |
| `mgmt_expenses` | Schedule 6 line **5010** | _apply_financials |
| `fundraising_expenses` | Schedule 6 line **5020** | _apply_financials |
| `grants_paid` | Schedule 6 line **5050** (gifts to qualified donees) | _apply_financials |
| `gross_receipts` | Schedule 6 line **4500** (total tax-receipted gifts) | _apply_financials |
| `total_assets` | Schedule 6 line **4200** *(see caveat below)* | _apply_financials |

> **Caveat on `total_assets` ⇄ line 4200**: in modern T3010s, line 4200 is total compensation (Schedule 6 cross-foot). The historical lookup was kept for backward compatibility with older datasets where 4200 *was* total assets. For 2024 data this field will frequently be wrong — likely needs to remap to line 4400 (total assets at FMV) in a follow-up.

### Programs & mission

| Column | CRA source | Writer |
|---|---|---|
| `mission` | first program description per charity | [merge_programs()](load_cra.py#L347) |
| `program_desc1/2/3` | up to 3 program descriptions | merge_programs |
| `program_count` | count of program rows per charity | merge_programs |

### Foreign activity

| Column | CRA source | Writer |
|---|---|---|
| `foreign_countries` | JSON list from `sch2_countries.Country` | [merge_sch2_countries()](load_cra.py#L262) |
| `foreign_grant_regions` | JSON `{country: $}` aggregated from `sch2_resources.Amount` + `sch2_goods.Item Value` | [_finalize_foreign_grants()](load_cra.py#L483) |
| `foreign_expenditures` | sum of values in `foreign_grant_regions` | _finalize_foreign_grants |
| `foreign_activities` | 1 if any foreign country / amount reported | merge_sch2_countries + _finalize_foreign_grants |
| `schedule_f_filed` | 1 if any Schedule 2 data reported | merge_sch2_countries + _finalize_foreign_grants |

---

## 5. Columns with **no** CRA mapping (always NULL on CRA rows)

These columns are either US-form-specific (IRS Form 990 fields) or simply not asked about on T3010. They will be NULL for every CRA-sourced row unless future enrichment is added.

### Genuinely not in T3010
| Column | Why no source |
|---|---|
| `volunteers` | Modern T3010 dropped the volunteer-count question (historical line 5640 not in 2024 file) |
| `voting_members` | T3010 doesn't ask about board voting structure |
| `independent_members` | T3010 doesn't ask about director independence |
| `conflict_policy` | T3010 has no governance-policy questions |
| `whistleblower_policy` | same |
| `doc_retention_policy` | same |
| `form990_to_board` | US-specific (Form 990 disclosure-to-board question) |
| `audited` | Modern T3010 dropped the explicit "audited financial statements" Y/N |
| `comp_process_ceo` | T3010 doesn't probe CEO comp-setting process |
| `grants_to_individuals` | T3010 reports gifts to *qualified donees* only (CRA prohibits granting to individuals for most charity classes) |
| `operates_hospital` | Not asked explicitly; **could be inferred** from `ident.Sub Category` |
| `operates_school` | same — inferable from Sub Category |
| `is_501c3` | US tax-code concept |
| `described_501c3` | US tax-code concept |
| `schedule_a_filed` | US Form 990 Schedule A |
| `foreign_individual_regions` | T3010 doesn't break grants out by individual vs organization geography |
| `foreign_offices` | T3010 doesn't ask about overseas office count |
| `foreign_employees` | T3010 doesn't ask about overseas headcount |
| `total_revenue_py` | CRA dataset is one year at a time; prior-year requires joining with the previous year's dataset |
| `net_assets` | Not a direct line item; could be derived as `(4200 total assets) − (4400 total liabilities)` |

### Calculated downstream (not loader's job)
- `score_composite`, `score_revenue`, `score_religious`, `score_recipient`, `score_results` — populated by [CharityScoreCalculator](app/Services/CharityScoreCalculator.php).

### CSVs published by CRA but currently ignored
Potential enrichments waiting to be wired:
| Source | Could populate |
|---|---|
| `weburl_*.csv` | (new column) charity website |
| `qualified_donees_*.csv` | per-donee grant detail (currently rolled into `grants_paid` total only) |
| `schedule_5_gifts_in_kind_*.csv` | breakdown of in-kind gifts received |
| `schedule_8_dq_*.csv` | disbursement quota compliance |
| `ident.Sub Category` | `operates_hospital` / `operates_school` heuristics |
| `ident.Designation` | distinguish public vs private foundations |
| Schedule 6 line 4400 | `total_assets` (more accurate than line 4200 on modern forms) |
| Schedule 3 line 370 | (new column) part-time-position count |
| Schedule 2 details lines 200-260 | finer-grained foreign-activity flags |

---

## 6. Caveats and known issues

1. **Compensation bands are approximations.** CRA does not disclose individual salaries. `ceo_comp` is the lower bound of the highest non-empty band — a charity with one position in the $350k+ band reports `ceo_comp = 350000`, regardless of whether the actual salary is $360k or $1.2M.

2. **`total_assets` uses line 4200**, which is correct on older T3010 forms but is *total compensation* on modern (post-2020) forms. Most 2024 rows will have this field populated with the wrong concept. Fix: switch to line 4400 (or compute from 4020-4180 sum).

3. **`audited` was being looked up under field names that don't exist** in modern CRA CSVs (`audited_financial_statements`, `financial_statements_audited`). The lookup is harmless (always returns None) but the column will always be NULL.

4. **The "primary officer" heuristic is imperfect.** Many small Canadian charities are entirely volunteer-run boards where every director's title is just "Director". The loader returns NULL `ceo_name` for those, which is honest but means about 40% of charities have no officer attributed. Future work could fall back to the first-listed director when no priority title exists.

5. **Foreign country codes vs names.** `sch2_resources.Country` uses ISO 2-letter codes (e.g. `KE`, `LB`) in 2024, but `sch2_countries.Country` mixes codes and full names depending on year. The two collections are not normalized to a single representation before being stored.

6. **Backward compatibility.** Loader supports both modern dataset structure (financials in Schedule 6) and older layouts (financials in Section ABC). `_apply_financials` runs against both files and writes only when the field is still NULL, so whichever file actually contains the data populates it.
