> ## Documentation Index
> Fetch the complete documentation index at: https://docs.laportenard.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Close session

> Session close wizard with cash denomination counting, open order warnings, and manager override.

The close session flow is a multi-step wizard that guides the user through closing out their POS session, counting cash, and generating a session report.

## Permissions

Closing a session requires the `close_session` permission. The close session option appears in the floor plan header's system menu.

## Wizard steps

The close session flow uses a reducer-based state machine with seven states:

<Steps>
  <Step title="Loading">
    Fetches session data from the backend: open order count, payment totals by method, and cash denomination configuration.
  </Step>

  <Step title="Warning (conditional)">
    If there are open (unpaid) orders, the wizard pauses and shows a warning. The user must acknowledge before continuing.
  </Step>

  <Step title="Cash counting">
    Displays the cash denomination counting interface. Users enter counts per denomination (bills and coins) using a numpad. The system calculates the expected vs. actual cash totals.
  </Step>

  <Step title="Manager override (conditional)">
    If required by POS configuration, a manager must approve the session close via PIN or card authentication.
  </Step>

  <Step title="Closing">
    Submits the close session request to the backend with cash counts and optional manager override credentials.
  </Step>

  <Step title="Print report (optional)">
    Prints the session report with payment breakdowns, expected vs. actual totals, and discrepancies.
  </Step>

  <Step title="Done">
    Session is closed. The user is redirected to the login screen.
  </Step>
</Steps>

## Cash counting

The denomination counting interface supports:

* **Pre-configured denominations** from `cashbox_lines` in the Odoo session
* **Expression input** with `+` and `−` operators for adjustments (e.g., `5+3` = 8 bills)
* **Manual cash entry** as an alternative to denomination counting
* **Real-time totals** comparing expected cash (from payment lines) vs. counted cash

## API endpoints

| Endpoint                                 | Purpose                                                     |
| ---------------------------------------- | ----------------------------------------------------------- |
| `POST /pos-api/v1/session/close/prepare` | Fetch session data, open order count, payment totals        |
| `POST /pos-api/v1/session/close`         | Submit close with cash counts and optional manager override |
| `POST /pos-api/v1/session/report`        | Fetch session report data for printing                      |
| `POST /pos-api/v1/session/comment`       | Post a comment to the session                               |

## Source files

```
src/features/management/screens/SessionCloseScreen.tsx  # Main UI
src/features/management/screens/closeSessionReducer.ts  # Wizard state machine
src/domain/sessions/closeSessionUtils.ts                # Cash denomination utilities
src/domain/sessions/models.ts                           # Type definitions
```
