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

# Render the payment basis of expense reports

> The payment basis sums up what is to be paid out to each employee for the listed reports: the tax free amount, the taxable amount and their total, one row per employee sorted by email, followed by the grand total. It is returned as HTML, or as a PDF with `format=pdf`.

Which amounts are summed depends on the organization's accounting structure. On the new accounting structure only the per diem, mileage and food benefit amounts of each report are summed, receipts are not included. On the old accounting structure the per diem, mileage and food benefit amounts are summed as well, and the receipt amounts in the base currency are added to the tax free amount.

The endpoint also accepts a pre-signed URL (the `X-Findity-*` query parameters added by `POST /api/auth/urlsignature`), so the document can be opened in a new browser tab without an `Authorization` header. The signed URL acts as the user who signed it, limited to the same organization when the signing token was. Like without a signature, a signed URL without `format` renders HTML; a signed URL with any other `format` than `html` or `pdf` is answered with 401.




## OpenAPI

````yaml /openapi/findity-admin-api.json get /organizations/{organizationId}/reports/paymentbasis
openapi: 3.1.0
info:
  title: Findity Admin API
  description: Findity Admin API
  version: 1.0.0
servers:
  - url: https://stage-api.findity.com/api/v1/admin
  - url: https://api.findity.com/api/v1/admin
security:
  - bearerAuth: []
paths:
  /organizations/{organizationId}/reports/paymentbasis:
    get:
      tags:
        - Expense Reports
      summary: Render the payment basis of expense reports
      description: >
        The payment basis sums up what is to be paid out to each employee for
        the listed reports: the tax free amount, the taxable amount and their
        total, one row per employee sorted by email, followed by the grand
        total. It is returned as HTML, or as a PDF with `format=pdf`.


        Which amounts are summed depends on the organization's accounting
        structure. On the new accounting structure only the per diem, mileage
        and food benefit amounts of each report are summed, receipts are not
        included. On the old accounting structure the per diem, mileage and food
        benefit amounts are summed as well, and the receipt amounts in the base
        currency are added to the tax free amount.


        The endpoint also accepts a pre-signed URL (the `X-Findity-*` query
        parameters added by `POST /api/auth/urlsignature`), so the document can
        be opened in a new browser tab without an `Authorization` header. The
        signed URL acts as the user who signed it, limited to the same
        organization when the signing token was. Like without a signature, a
        signed URL without `format` renders HTML; a signed URL with any other
        `format` than `html` or `pdf` is answered with 401.
      operationId: getOrganizationExpenseReportsPaymentBasis
      parameters:
        - $ref: '#/components/parameters/organizationIdOrExternalIdInPath'
        - $ref: '#/components/parameters/paymentBasisExpenseReportIds'
        - $ref: '#/components/parameters/paymentBasisRecipientId'
        - $ref: '#/components/parameters/paymentBasisFormat'
        - $ref: '#/components/parameters/renderLang'
        - $ref: '#/components/parameters/renderFormattingRegion'
      responses:
        '200':
          description: The rendered payment basis
          headers:
            Content-Disposition:
              description: Only for `format=pdf`, the PDF is shown inline in the browser
              schema:
                type: string
              example: inline;filename="paymentbasis.pdf"
            Cache-Control:
              description: The document is rendered per request and never cacheable
              schema:
                type: string
              example: no-store
          content:
            text/html:
              schema:
                type: string
              example: |
                <!DOCTYPE html>
                <html>
                  <head><title>Payment basis</title></head>
                  <body>...</body>
                </html>
            application/pdf:
              schema:
                type: string
                format: binary
        '400':
          description: >
            An invalid query parameter, or the PDF could not be created. The
            renderer failure is answered as 400 `FAILED_TO_CREATE_PDF`, the same
            status the API uses for its other coded errors on this GET, as on
            `GET /organizations/{organizationId}/reports/output`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/400Error'
              examples:
                missingExpenseReportIds:
                  summary: expenseReportIds was left out
                  value:
                    result: error
                    code: MISSING_PARAMETER
                    description: expenseReportIds is required for action 'paymentBasis'
                tooManyReports:
                  summary: More reports than the batch limit
                  value:
                    result: error
                    code: INVALID_PARAMETER
                    description: A maximum of 100 reports can be handled at once, got 101
                recipientNotInOrganization:
                  summary: The recipient belongs to another organization
                  value:
                    result: error
                    code: INVALID_PARAMETER
                    description: 'Invalid recipientId: ''3f2b1a0c9d8e7f6a5b4c3d2e1f0a9b8c'''
                invalidFormat:
                  summary: format is not html or pdf
                  value:
                    result: error
                    code: INVALID_PARAMETER
                    description: 'Invalid format: ''json'', use one of html, pdf'
                pdfFailed:
                  summary: The pdf renderer could not create the document
                  value:
                    result: error
                    code: FAILED_TO_CREATE_PDF
                    description: Could not create the pdf
        '401':
          description: >
            The token is missing, invalid or expired, the caller lacks the
            `adminApiExpenseReports:getPaymentBasis` permission, or a signed URL
            has a `format` other than `html` or `pdf`. A caller who has the
            permission but no access to the organization gets 404
            `ORGANIZATION_NOT_FOUND` instead.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/401Error'
              examples:
                unauthorized:
                  summary: The caller lacks the permission the endpoint requires
                  value:
                    result: unauthorized
        '404':
          description: Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/404Error'
              examples:
                organizationNotFound:
                  summary: Organization not found or the caller has no access to it
                  value:
                    result: error
                    code: ORGANIZATION_NOT_FOUND
                    description: Organization not found
                expenseReportNotFound:
                  summary: >-
                    One or more of the reports are not on the organization or
                    are deleted
                  value:
                    result: error
                    code: EXPENSE_REPORT_NOT_FOUND
                    description: Expense report not found
components:
  parameters:
    organizationIdOrExternalIdInPath:
      in: path
      name: organizationId
      required: true
      description: >-
        Unique identifier of the organization. String in UUID without dashes
        (32-character hex string) if access is done via values from Findity
        system otherwise, id of external system can be used
      schema:
        type: string
      examples:
        Findity unique id:
          value: 05b8daba9ba14a49846fe77883248cf0
        External system unique id:
          value: a31a7372-3397-3924-ffcd-b7b4795e42eb
    paymentBasisExpenseReportIds:
      name: expenseReportIds
      in: query
      description: >
        The expense reports the payment basis covers, as a comma separated list

        (`expenseReportIds=05b8daba9ba14a49846fe77883248cf0,7c1f0a3b9d2e4f5a8b6c0d1e2f3a4b5c`).


        Every id must belong to the organization and not be deleted, if any of
        them does not the whole

        call is rejected with 404 and nothing is rendered. Array of strings,
        UUID format (32-character

        hexadecimal), 1-100 items. Required.
      required: true
      style: form
      explode: false
      schema:
        type: array
        minItems: 1
        maxItems: 100
        items:
          $ref: '#/components/schemas/Uuid'
      example:
        - 05b8daba9ba14a49846fe77883248cf0
        - 7c1f0a3b9d2e4f5a8b6c0d1e2f3a4b5c
    paymentBasisRecipientId:
      name: recipientId
      in: query
      description: >
        Recipient whose accounting the amounts are calculated with. Only
        organizations on the old accounting structure calculate the amounts per
        recipient, with the new accounting structure the amounts are the same
        for every recipient. A recipient that is disconnected from the
        organization is accepted, a recipient of another organization is
        rejected with 400 `INVALID_PARAMETER`. String, UUID format (32-character
        hexadecimal). Optional, the default accounting of each report is used
        when omitted.
      required: false
      schema:
        $ref: '#/components/schemas/Uuid'
      example: 3f2b1a0c9d8e7f6a5b4c3d2e1f0a9b8c
    paymentBasisFormat:
      name: format
      in: query
      required: false
      description: >
        What the payment basis is returned as. `html` renders it as a web page
        and `pdf` returns the same document as a PDF that opens in the browser.
        String, one of `html`, `pdf`. Optional, `html` when omitted, also for a
        pre-signed URL.
      schema:
        type: string
        enum:
          - html
          - pdf
        default: html
      example: pdf
    renderLang:
      name: lang
      in: query
      required: false
      description: >
        Language the document is rendered in. String, language variant such as
        sv_SE or en_GB. Optional, the language of the caller is used when
        omitted.
      schema:
        type: string
        pattern: ^[a-z]{2}(_[A-Z]{2})?$
      example: sv_SE
    renderFormattingRegion:
      name: formattingRegion
      in: query
      required: false
      description: >
        Region whose number and date formats the document uses. String, language
        variant such as sv_SE or en_GB. Optional, the formatting region of the
        caller is used when omitted or not recognised.
      schema:
        type: string
        pattern: ^[a-z]{2}(_[A-Z]{2})?$
      example: sv_SE
  schemas:
    400Error:
      type: object
      properties:
        result:
          type: string
        code:
          type: string
        description:
          type: string
    401Error:
      type: object
      properties:
        result:
          type: string
      example:
        result: unauthorized
    404Error:
      type: object
      properties:
        result:
          type: string
        code:
          type: string
        description:
          type: string
      example:
        result: error
        code: ORGANIZATION_NOT_FOUND
        description: 'Failed to get organization for id: {orgId}'
    Uuid:
      type: string
      pattern: ^[0-9a-fA-F]{32}$
      description: UUID without dashes (32-character hex string)
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````