# Upgrading PinnexBridge from v0.3.0 / v0.3.1 to v0.3.2

Three steps. Your settings are preserved.

## 1. Copy this ZIP to the Windows PC

Email or USB the file `PinnexBridge-0.3.2.zip` to the Windows machine
where Tally Prime runs.

## 2. Extract and run install.ps1

Right-click `install.ps1` -> **Run with PowerShell** (as Administrator).

You will NOT be prompted for the license key, firm code, or company name —
the installer detects your existing `C:\Program Files\Pinnex Bridge\.env`
and leaves it untouched.

What you should see at the end:

```
[*] Existing .env detected at C:\Program Files\Pinnex Bridge\.env - PRESERVING (upgrade mode)
[*] Stopping existing PinnexBridge service
[*] Copying pinnex-bridge.exe and nssm.exe to C:\Program Files\Pinnex Bridge
[+] .env preserved
[*] Starting PinnexBridge
[*] Testing http://127.0.0.1:9888/health
[+] PinnexBridge updated to v0.3.2

  firm_code:        PINNEX
  tally_reachable:  True
  company_loaded:   True
  matched_company:  Being Zero Consulting Private Limited (From Apr 25)
  loaded_companies: Being Zero Consulting Private Limited (From Apr 25), Testing Company
  bridge URL:       http://127.0.0.1:9888
```

The line that matters is **`company_loaded: True`**. That's the bug fix
landing.

## 3. Verify end-to-end from your Mac

On your Mac:

```bash
bash ~/Downloads/tally-bridge-v0.3/diag.sh
```

This walks the full chain (firm-config -> Tailscale -> /health ->
company_loaded -> auth) and prints green / red per check with a fix for
every red.

After diag.sh shows all-green, your bookkeeping posts will land.

## What if company_loaded still shows false?

v0.3.2 changes the failure mode from silent-empty to loud-honest:

```
"company_loaded": false,
"loaded_companies": ["Being Zero Consulting Private Limited (From Apr 25)", "Testing Company"],
"error_detail": "configured company 'Being Zero (Apr 25)' not found in loaded list: [Being Zero Consulting Private Limited (From Apr 25), Testing Company]"
```

So you can see *exactly* what Tally has open, and exactly what name to
paste into TALLY_COMPANY.

To fix: open `C:\Program Files\Pinnex Bridge\.env` in Notepad, set
`TALLY_COMPANY=` to one of the names listed in `loaded_companies` (copy-
paste verbatim, suffix and all), save, then in PowerShell run
`Restart-Service PinnexBridge`.

## Rollback (if anything breaks)

```powershell
# Stop v0.3.2
Stop-Service PinnexBridge

# Restore the old binary
Copy-Item "<wherever you backed up v0.3.0 exe>" `
          "C:\Program Files\Pinnex Bridge\pinnex-bridge.exe" -Force

# Restart
Start-Service PinnexBridge
```

Your `.env` is untouched in both directions, so rolling back is purely
a binary swap.

## Notes

- The stale v0.2.0 install at `C:\PinnexBridge\` is NOT touched by this
  installer. Leave it alone or remove manually later — it doesn't affect
  the v0.3.x service.
- Default bridge port is 9888 (unchanged from v0.3.1).
- License verify now fails open when `api.pinnex.in` is unreachable, so
  Tailscale-only / offline boots stop blocking on the license check.
