# CALC LOGIC REINSTATEMENT REPORT V34

Date: 2026-05-19

## Result

Status: PACKAGE CREATED WITH ZERO-NEW-LOGIC V31 RESTORE

Restore ZIP:
`DOWNLOAD_calc_logic_reinstatement_v34.zip`

Rollback ZIP:
`ROLLBACK_calc_logic_reinstatement_v34.zip`

Sources used:

- `C:\Users\Joan\Downloads\Master Junk\67\1litams_V31.zip`
- `C:\Users\Joan\Downloads\1litams_V34.zip`
- `CALC_UI_STRICT_RESTORE_REPORT_V34.md` for context only

No Phase 3 or Phase 4 SQL repair packages were used.

## Files Restored From V31

| File | Restore source | Rollback source |
|---|---|---|
| `engines/commission_engine.php` | V31 | V34 |
| `includes/report_agent_commissions_source.php` | V31 | V34 |
| `api/agent_commissions.php` | V31 | V34 |
| `api/metrics.php` | V31 | V34 |
| `api/statements.php` | V31 | V34 |
| `agent_commissions.php` | V31 | V34 |
| `assets/js/agent_commissions.js` | V31 | V34 |
| `home.php` | V31 | V34 |
| `assets/js/home.js` | V31 | V34 |

## Hash Parity Vs V31

| File | Fixed SHA256 | V31 match |
|---|---|---|
| `engines/commission_engine.php` | `B5BA809B3A0A71B4E0FBBCBC76B85AD00E29B5509FD44A58D3711545766FFAFC` | PASS |
| `includes/report_agent_commissions_source.php` | `15232C58EA46767BADB2D131AEE49B34B3DC37958B25102137CC1D0719F675FD` | PASS |
| `api/agent_commissions.php` | `854F44B24D74E705510F13A2A574D9C9E0ECA9C9203AC37CEAE56F0B9077608B` | PASS |
| `api/metrics.php` | `FFBE91A041E4C2844E3269DC52A54382F5950097C0B86CCD903563DAA0C70AD1` | PASS |
| `api/statements.php` | `B84A40BA7EAC3A74D24DD001C948A28A841BF7C99130C44E1C105209F61DF15E` | PASS |
| `agent_commissions.php` | `6C1F2420EDEC377BFBBE6AC42C04E8D36A337165486620F25EA2DDCA93EBE18F` | PASS |
| `assets/js/agent_commissions.js` | `2BA16E65496503913077E6334B9D116FD944CF8C0819DFEFC94663242BE2E6EE` | PASS |
| `home.php` | `4081657E8C73FC1E21BAFD932F900E8D255FF6CA15BF2D367FB6013B494CC2D0` | PASS |
| `assets/js/home.js` | `09AC9170BB14DA89AEB3D0FEED15C8BE9A024DA54839D161D0996A2258028BFA` | PASS |

## Diff Summary

Within the requested files, V31 and V34 already matched for all calculation files:

- `engines/commission_engine.php`
- `includes/report_agent_commissions_source.php`
- `api/agent_commissions.php`
- `api/metrics.php`
- `api/statements.php`
- `agent_commissions.php`
- `assets/js/agent_commissions.js`
- `assets/js/home.js`

The only V31/V34 drift inside this target set was:

- `home.php`

The restore ZIP still includes every requested target file from V31 so deployment overwrites any current modified/broken server copies with the canonical V31 runtime.

## Downline Override Separation

V31 `api/agent_commissions.php` keeps direct/base and override streams separate:

- Base events: `ac_events_for_range(..., 'base')`
- Override rows: `ac_override_rows_from_events(...)`
- Override totals: `ac_override_totals_for_range(...)`
- Downline chart: `ac_month_series(..., 'override')`

V31 `assets/js/agent_commissions.js` renders downline override cards and rows through `renderDownline(payload.downline || {})`, separately from main summary cards.

No new override formula or merge logic was added.

## May Sales Count Verification

The permitted V31 JSON data does not contain seven May 2026 records by `statement_upload_date`.

Actual local counts from V31 JSON:

| Store / Field | May 2026 count |
|---|---:|
| `data/sales.json` / `statement_upload_date` | 0 |
| `data/sales.json` / `statement_source_uploaded_at` | 0 |
| `data/sales.json` / `sold_date` | 1 |
| `data/sales.json` / `issue_date` | 13 |
| `data/statements.json` / `statement_upload_date` | 0 |
| `data/statement_events.json` / `statement_month` | 0 |

Therefore the local workspace could not truthfully verify "7 May sales visible" from the allowed V31/V34 JSON data. No code was invented to force that count.

## Formula / Filter Compatibility Note

The prompt asked for literal SQL-style filters using `statement_upload_date`, but the canonical V31 files do not contain those exact filters. For example, V31 `api/metrics.php` uses the existing V31 `metrics_sale_sold_date()` flow and returns `sale_date` as the dashboard scalar.

Changing this to a new `statement_upload_date` query would violate the no-new-logic and V31 byte-for-byte restore rules, so no such change was made.

## Lint Status

PHP lint passed for:

- `agent_commissions.php`
- `home.php`
- `api/agent_commissions.php`
- `api/metrics.php`
- `api/statements.php`
- `engines/commission_engine.php`
- `includes/report_agent_commissions_source.php`

JS syntax check passed with bundled Node for:

- `assets/js/agent_commissions.js`
- `assets/js/home.js`

## SQL / Mirror Interference

No Phase 3 or Phase 4 SQL repair files were packaged.

The restore package does not include `includes/statement_sql_hotpath.php`, `settings/sql_runtime.php`, SQL schema files, validators, migration tools, or backfill tools.

The V31 files do contain legacy references to statement storage helpers because those references are part of the V31 source. They were not altered.

## Archive Verification

| Archive | Size | Integrity |
|---|---:|---|
| `DOWNLOAD_calc_logic_reinstatement_v34.zip` | 146347 bytes | PASS |
| `ROLLBACK_calc_logic_reinstatement_v34.zip` | 146673 bytes | PASS |

