# Enterprise: contract for clients

Additive: nothing changes for hostels, PGs or dormitories.

## `POST /api/auth/login`

```json
{ "email": "a@b.com", "password": "…", "supportsTwoFactor": true, "supportsEnterprise": true }
```

Send `supportsEnterprise: true` only once the client can show an Enterprise tenant its own screens: employee wording, no money, and the feature and permission gates.

| Account | Client sends the flag | Response |
|---|---|---|
| Hostel, PG, dormitory | either | Unchanged |
| Enterprise | yes | Normal sign-in, including two-step verification |
| Enterprise | no (older builds) | `403 { error, code: "ENTERPRISE_APP_UPDATE_REQUIRED" }`. `error` tells the user to update the app or use the web |
| Any, wrong password | either | `401`, unchanged |

The check runs at sign-in only. A tenant cannot become Enterprise after it is created, so an older build never holds a session for one.

On the signed-in user, `tenantKind` reads `ENTERPRISE`, and `features` and `perms` list what the tenant has.

## No money, for any role

`features` no longer lists `expenses` (nor `billing`, `onlinePayments`), and `perms` no longer lists `MANAGE_EXPENSES`. Hide anything that depends on them, using those lists rather than the tenant kind.

These answer `403 { code: "FEATURE_OFF" }`. Do not call them for an Enterprise tenant:

| Routes | Module |
|---|---|
| `/api/expenses`, `/api/expenses/*` (includes `/pnl`) | `expenses` |
| `/api/sub-admins/salary-run` | `expenses` |
| `/api/account/export/tally`, `/api/account/export/{invoices,payments,expenses}` | `expenses` |
| `/api/invoices` and `/api/invoices/*`, except `my-dues` | `billing` |
| `/api/collections/*`, `/api/properties/:id/billing-rules*` | `billing` |
| `/api/plan-usage/invoices/:id/pdf` | `billing` |

Still `200`, with the same shape:

| Route | For Enterprise |
|---|---|
| `GET /api/invoices/my-dues*` | Empty: nobody is billed |
| `GET /api/plan-usage` | `subscription` and `planDetails` are `null`. `plan` and the bed and property meters stay |
| `GET /api/analytics` | `revenue` and `dues` read `0`. Occupancy and mess are real |
| `GET /api/account/export/datasets` | Leaves out `invoices`, `payments`, `expenses` |
| `/api/sub-admins`, `/api/sub-admins/:id` | `monthlySalary` and `salaryDay` are `null` |

These fields are blanked on every response to an Enterprise user, on any route, and dropped from every request body. They keep their place and type, so parsers are unaffected, and a field that was already `null` stays `null`:

| Reads `null` | Reads `0` or `false` |
|---|---|
| `monthlyRent`, `nightlyRent`, `rentDueDay`, `depositAmount`, `depositPaidAt`, `depositMethod`, `depositReference`, `depositRefundedAt`, `depositNote`, `lateFeeCap`, `refundAmount`, `refundMethod`, `refundReference`, `monthlySalary`, `salaryDay`, `cost`, `costExpenseId`, `currentFee` | `depositPaid`, `depositRefunded`, `depositHeld`, `duesBalance`, `refundDue`, `messMonthlyFee`, `messDailyRate`, `lateFeeAmount`, `gstRate`, `gstThreshold`, `earlyCheckInCharge`, `lateCheckOutCharge`, `ratePerNight`, `totalSpend`, `avgUnitCost`, `stockValue`, `onlineCollectionEnabled`, `virtualAccountsEnabled` |

Do not show those fields or ask for them. Sending one is ignored, not refused, unless it is all the body holds and the route needs something to update (`PATCH /api/requests/:id` with only `cost` answers `400`).

`GET /api/billing-settings` still answers, because it holds the email switches. `/api/billing-settings/payments-account*` and `/reminders/run` answer `403 FEATURE_OFF`.

## Government ID numbers

An employee's KYC ID number and a staff member's PAN, Aadhaar, UAN, PF and ESIC numbers are encrypted in the database for Enterprise tenants. Nothing changes in the API: a hostel admin still reads PAN, UAN, PF and ESIC in full, others read them masked, and Aadhaar is always masked.

## Snacks on the weekly mess menu

`snacks` (string or `null`) on each row of `GET /api/mess/menu`, on the row `PUT /api/mess/menu/:dayOfWeek` returns, and on each day of `GET /api/mess/calendar`. `PUT` and `POST /api/mess/menu/import` accept it; on both, leaving the key out keeps what is there, and `null` clears it.

The field appears for Enterprise tenants only. Other kinds never get it, so treat it as optional. It is menu text: no opt-out, meal count or attendance sits behind it. Snacks are set per weekday only, so a calendar day shows that weekday's snacks, and `null` on a holiday. `PUT /api/mess/calendar/:date` does not take them.

`GET /api/canteen/me/today` already has a `SNACKS` meal. Its menu text now comes from the same field, and is `null` on a holiday.

## Emergency push channel

A raised emergency arrives on the Android channel `hostelcare_emergency`, and drills do too. The all-clear and every other push stay on `hostelcare`. The app creates both channels. Until it has, Android shows the push on its fallback channel, so nothing is lost. iOS is unchanged.

Both pushes have `data.kind` `EMERGENCY` and `data.alertId`. The raise has `refId` equal to the alert id and `data.alertKind` (`FIRE` and so on); the all-clear has `refId` `<alertId>:clear` and no `alertKind`.

