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

# Tally one salesperson's day

> Rolls ONE salesperson's finalized sale tickets for ONE UTC calendar day up into their day figures: sales and returns counts, net gross TTC taken (chiffre d'affaires), items sold, basket average and VAT. Pass `?sellerId=` (a `GET /v1/team` member id — the same `user-*` id `SaleTicket.sellerId` carries), optionally `?day=YYYY-MM-DD` (defaults to today) and `?store=` to narrow to one store. Money is integer cents.

WHICH DAY. The window is the UTC calendar day of `recordedAt`, the instant the BACKEND booked each sale — the same bucket the daily Z closure, the FEC and the accounting export use. It is deliberately NOT the instant the till rang the sale up: the two diverge by days for a sale captured offline and replayed later, and a figure bucketed the other way would contradict the store's own close.

WHOSE FIGURES. This is the read about SOMEBODY ELSE, so it rides `pos.finance.view` — the same grant that already serves every ticket and its `sellerId` through `GET /v1/sales`, so it exposes nothing new, only conveniently. To read your OWN day, call `GET /v1/me/day-summary`, which needs no scope and takes no id.

READING ZEROS. A seller with no ticket that day is a successful read returning zeros. That is a real, quiet day — it is NOT what a failed read looks like, and a client must never render a transport failure as `0`.



## OpenAPI

````yaml /openapi.json get /v1/sales/seller-day
openapi: 3.0.3
info:
  title: Solya POS API
  version: 1.0.0
  description: >-
    The Solya POS backend HTTP surface. Every documented operation is
    agent-ready: it carries an `operationId`, an agent-facing `description`, the
    `pos.*` scopes it enforces (`x-required-permissions`) and an `x-agent-tier`.
    Success responses return the payload as raw JSON; failures return the
    `ErrorResponse` envelope (`{ error: { code, message, statusCode } }`).
servers:
  - url: /
    description: The backend, relative to its deployed origin.
security: []
paths:
  /v1/sales/seller-day:
    get:
      tags:
        - Finance
      summary: Tally one salesperson's day
      description: >-
        Rolls ONE salesperson's finalized sale tickets for ONE UTC calendar day
        up into their day figures: sales and returns counts, net gross TTC taken
        (chiffre d'affaires), items sold, basket average and VAT. Pass
        `?sellerId=` (a `GET /v1/team` member id — the same `user-*` id
        `SaleTicket.sellerId` carries), optionally `?day=YYYY-MM-DD` (defaults
        to today) and `?store=` to narrow to one store. Money is integer cents.


        WHICH DAY. The window is the UTC calendar day of `recordedAt`, the
        instant the BACKEND booked each sale — the same bucket the daily Z
        closure, the FEC and the accounting export use. It is deliberately NOT
        the instant the till rang the sale up: the two diverge by days for a
        sale captured offline and replayed later, and a figure bucketed the
        other way would contradict the store's own close.


        WHOSE FIGURES. This is the read about SOMEBODY ELSE, so it rides
        `pos.finance.view` — the same grant that already serves every ticket and
        its `sellerId` through `GET /v1/sales`, so it exposes nothing new, only
        conveniently. To read your OWN day, call `GET /v1/me/day-summary`, which
        needs no scope and takes no id.


        READING ZEROS. A seller with no ticket that day is a successful read
        returning zeros. That is a real, quiet day — it is NOT what a failed
        read looks like, and a client must never render a transport failure as
        `0`.
      operationId: sellerDaySummary
      parameters:
        - schema:
            type: string
          in: query
          name: sellerId
          required: false
          description: >-
            The salesperson whose day to tally — a `GET /v1/team` member id
            (`user-*`), the same id `SaleTicket.sellerId` carries. Required;
            omitting it 400s.
        - schema:
            type: string
          in: query
          name: day
          required: false
          description: >-
            The UTC calendar day (`YYYY-MM-DD`) to tally; defaults to today. A
            malformed day 400s.
        - schema:
            type: string
          in: query
          name: store
          required: false
          description: >-
            Narrow the tally to one store by its canonical store id; omit to
            span every store.
      responses:
        '200':
          description: The salesperson's tallies for the requested UTC calendar day.
          content:
            application/json:
              schema:
                type: object
                properties:
                  sellerId:
                    type: string
                  day:
                    type: string
                    description: The UTC calendar day tallied (`YYYY-MM-DD`).
                  storeId:
                    nullable: true
                    description: The store the window was narrowed to, or `null`.
                    type: string
                  salesCount:
                    type: integer
                    minimum: -9007199254740991
                    maximum: 9007199254740991
                  returnsCount:
                    type: integer
                    minimum: -9007199254740991
                    maximum: 9007199254740991
                  revenueCents:
                    type: integer
                    minimum: -9007199254740991
                    maximum: 9007199254740991
                    description: Net gross TTC taken, integer cents (refunds negative).
                  itemsSold:
                    type: integer
                    minimum: -9007199254740991
                    maximum: 9007199254740991
                  basketAverageCents:
                    type: integer
                    minimum: -9007199254740991
                    maximum: 9007199254740991
                  vatTotalCents:
                    type: integer
                    minimum: -9007199254740991
                    maximum: 9007199254740991
                required:
                  - sellerId
                  - day
                  - storeId
                  - salesCount
                  - returnsCount
                  - revenueCents
                  - itemsSold
                  - basketAverageCents
                  - vatTotalCents
                additionalProperties: false
                description: The salesperson's tallies for the requested UTC calendar day.
                example:
                  sellerId: user-camille
                  day: '2026-07-16'
                  storeId: store-rivoli
                  salesCount: 1
                  returnsCount: 0
                  revenueCents: 3600
                  itemsSold: 2
                  basketAverageCents: 3600
                  vatTotalCents: 600
        '400':
          description: >-
            The request failed schema validation; `error.fieldErrors` lists the
            fields.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidationErrorResponse'
        '401':
          description: No valid credential was presented — send a bearer token.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: The actor is authenticated but lacks the required `pos.*` scope.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: An unexpected server error — safe to retry idempotent requests.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - bearerAuth: []
components:
  schemas:
    ValidationErrorResponse:
      type: object
      required:
        - error
      additionalProperties: false
      description: >-
        A `VALIDATION_FAILED` envelope carrying the offending fields in
        `fieldErrors`.
      properties:
        error:
          type: object
          required:
            - code
            - message
            - statusCode
          additionalProperties: false
          properties:
            code:
              type: string
              enum:
                - VALIDATION_FAILED
            message:
              type: string
            statusCode:
              type: integer
            fieldErrors:
              type: array
              description: >-
                One entry per rejected field: the field path and why it was
                rejected.
              items:
                type: object
                required:
                  - field
                  - message
                additionalProperties: false
                properties:
                  field:
                    type: string
                    description: Dot-path of the offending field.
                  message:
                    type: string
                    description: Why the field was rejected.
    ErrorResponse:
      type: object
      required:
        - error
      additionalProperties: false
      description: The uniform failure envelope every non-2xx response returns.
      properties:
        error:
          type: object
          required:
            - code
            - message
            - statusCode
          additionalProperties: false
          properties:
            code:
              type: string
              enum:
                - VALIDATION_FAILED
                - UNAUTHORIZED
                - FORBIDDEN
                - NOT_FOUND
                - CONFLICT
                - BUSINESS_RULE_VIOLATION
                - INTERNAL_ERROR
              description: >-
                Machine-readable kernel `ResultCode` — branch on this, not on
                `message`.
            message:
              type: string
              description: >-
                Human-readable explanation. Safe to surface; never leaks server
                internals.
            statusCode:
              type: integer
              description: >-
                The HTTP status, mirrored into the body so a client need not
                read headers.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        `Authorization: Bearer <token>`. Accepts EITHER a Keycloak access token
        (scopes-in-token) OR an opaque POS session token; both resolve to the
        same `pos.*` scope vocabulary the route guards enforce.

````