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

# Testing Guide

> Complete testing scenarios and requirements before moving to production.

## Overview

This guide outlines the mandatory test scenarios for integrating with the MMR-SASK API. You must complete all test scenarios in the test environment before moving to production.

<Note>
  Once you complete all test cases, contact us to proceed with production deployment.
</Note>

## Test Environment

Use the development server for all testing:

```
https://api.rrc.dev.finventi.com
```

## Test Scenarios

<Tabs>
  <Tab title="Report Natural Person Account">
    Natural person accounts are reported with owner type `F`. This flow covers account creation, updates, and representative management.

    **What you report for a natural person account:**

    * **Account details** - IBAN, currency, account type, open/close dates
    * **Owner information** - Name, surname, birth date, address, nationality
    * **Identification** - Personal code or foreign identification code, document type and number
    * **Representatives** - Individuals authorized to manage the account on behalf of the owner

    <Note>
      - Beneficial owners (UBO) are not reported for natural person accounts.
      - Representatives can only be natural persons.
    </Note>

    <AccordionGroup>
      <Accordion title="Test Case 1: Create Account" icon="plus">
        **Objective**: Report a newly opened account with owner and representatives to the tax authority.

        Use `POST` only for newly opened accounts. If the account was opened and closed on the same day, include `closedDate` in the request - no separate update is required.

        **Request**: `POST /reports/sask/v1/accounts`

        **Request Body**:

        ```json theme={null}
        [
          {
            "accountType": "CURRENT_ACCOUNT",
            "iban": "LT601010012345678901",
            "currency": "EUR",
            "openedDate": "2024-12-20",
            "owner": {
              "type": "F",
              "name": "Jonas",
              "surname": "Jonaitis",
              "birthDate": "1990-05-15",
              "addressCountry": "LT",
              "address": "Vilnius, Gedimino pr. 1",
              "codeCountry": "LT",
              "codeInForeignCountry": "39005150001",
              "documentType": "LT_PASSPORT",
              "documentNumber": "AB123456",
              "nationalities": ["LT"]
            },
            "representatives": [
              {
                "dateFrom": "2024-12-20",
                "representative": {
                  "type": "F",
                  "name": "Petras",
                  "surname": "Petraitis",
                  "birthDate": "1985-03-20",
                  "addressCountry": "LT",
                  "address": "Kaunas, Laisves al. 10",
                  "codeCountry": "LT",
                  "codeInForeignCountry": "38503200001",
                  "documentType": "LT_PASSPORT",
                  "documentNumber": "CD789012",
                  "nationalities": ["LT"]
                }
              }
            ]
          }
        ]
        ```

        <Info>
          The `representatives` array is optional. Include it when the account has authorized representatives.
        </Info>

        **Expected Response**:

        ```json theme={null}
        [
          {
            "status": "SUCCESS",
            "data": {
              "refId": "305697289_20250303_E5D11991C7B74CB0",
              ...
            }
          }
        ]
        ```

        <Info>
          Store the returned `refId` for use in Test Cases 2, 3, and 4.
        </Info>
      </Accordion>

      <Accordion title="Test Case 2: Update Account" icon="pen-to-square">
        **Objective**: Update a previously reported account when account details or owner information changes.

        The `refId` from the original account submission is required to identify the record to update.

        **Request**: `PUT /reports/sask/v1/accounts`

        **Request Body**:

        ```json theme={null}
        [
          {
            "refId": "<refId from Test Case 1>",
            "accountType": "CURRENT_ACCOUNT",
            "iban": "LT601010012345678901",
            "currency": "EUR",
            "openedDate": "2024-12-20",
            "closedDate": "2025-06-30",
            "owner": {
              "type": "F",
              "name": "Jonas",
              "surname": "Jonaitis",
              "birthDate": "1990-05-15",
              "addressCountry": "LT",
              "address": "Vilnius, Gedimino pr. 1",
              "codeCountry": "LT",
              "codeInForeignCountry": "39005150001",
              "documentType": "LT_PASSPORT",
              "documentNumber": "AB123456",
              "nationalities": ["LT"]
            }
          }
        ]
        ```

        **Expected Response**:

        ```json theme={null}
        [
          {
            "status": "SUCCESS",
            "data": {
              "refId": "305697289_20250303_E5D11991C7B74CB0",
              ...
            }
          }
        ]
        ```
      </Accordion>

      <Accordion title="Test Case 3: Create Representative" icon="user-tie">
        **Objective**: Add a new representative for an already reported account.

        The `accountRefId` in the URL must be the `refId` returned when the account was reported.

        **Request**: `POST /reports/sask/v1/accounts/{accountRefId}/representatives`

        **Request Body**:

        ```json theme={null}
        [
          {
            "dateFrom": "2024-12-18",
            "representative": {
              "type": "F",
              "name": "Petras",
              "surname": "Petraitis",
              "birthDate": "1985-03-20",
              "addressCountry": "LT",
              "address": "Kaunas, Laisves al. 10",
              "codeCountry": "LT",
              "codeInForeignCountry": "38503200001",
              "documentType": "LT_PASSPORT",
              "documentNumber": "CD789012",
              "nationalities": ["LT"]
            }
          }
        ]
        ```

        **Expected Response**:

        ```json theme={null}
        [
          {
            "status": "SUCCESS",
            "data": {
              "refId": "a8306155-8731-4aea-9b36-d30e958fbe33",
              ...
            }
          }
        ]
        ```

        <Info>
          Store the returned representative `refId` for Test Case 4.
        </Info>
      </Accordion>

      <Accordion title="Test Case 4: Update Representative" icon="calendar-xmark">
        **Objective**: Update a representative when their information changes, or end the representative relationship by adding `dateTo`.

        **Request**: `PUT /reports/sask/v1/accounts/{accountRefId}/representatives`

        **Request Body**:

        ```json theme={null}
        [
          {
            "refId": "<representative refId from Test Case 3>",
            "dateFrom": "2024-12-18",
            "dateTo": "2025-12-31",
            "representative": {
              "type": "F",
              "name": "Petras",
              "surname": "Petraitis",
              "birthDate": "1985-03-20",
              "addressCountry": "LT",
              "address": "Kaunas, Laisves al. 10",
              "codeCountry": "LT",
              "codeInForeignCountry": "38503200001",
              "documentType": "LT_PASSPORT",
              "documentNumber": "CD789012",
              "nationalities": ["LT"]
            }
          }
        ]
        ```

        **Expected Response**:

        ```json theme={null}
        [
          {
            "status": "SUCCESS",
            "data": {
              "refId": "a8306155-8731-4aea-9b36-d30e958fbe33",
              ...
            }
          }
        ]
        ```
      </Accordion>
    </AccordionGroup>
  </Tab>

  <Tab title="Report Legal Entity Account">
    Legal entity (juridical person) accounts are reported with owner type `J`. This flow covers account creation, updates, and beneficial owner reporting.

    **What you report for a legal entity account:**

    * **Account details** - IBAN, currency, account type, open/close dates
    * **Owner information** - Company name, registration code, address
    * **Representatives** - Individuals authorized to manage the account on behalf of the legal entity
    * **Beneficiaries** - Ultimate beneficial owners of the legal entity (natural persons)

    <Note>
      - Beneficial owners (UBO) are not required for Lithuanian companies.
      - Beneficial owners and representatives can only be natural persons.
    </Note>

    <AccordionGroup>
      <Accordion title="Test Case 1: Create Account" icon="plus">
        **Objective**: Report a newly opened account for a legal entity to the tax authority.

        Use `POST` only for newly opened accounts. If the account was opened and closed on the same day, include `closedDate` in the request - no separate update is required.

        **Request**: `POST /reports/sask/v1/accounts`

        **Request Body**:

        ```json theme={null}
        [
          {
            "accountType": "CURRENT_ACCOUNT",
            "iban": "LT701010098765432100",
            "currency": "EUR",
            "openedDate": "2024-12-20",
            "owner": {
              "type": "J",
              "surname": "UAB Example Company",
              "codeCountry": "LT",
              "codeInForeignCountry": "305697289",
              "addressCountry": "LT",
              "address": "Vilnius, Lvovo g. 25"
            }
          }
        ]
        ```

        **Expected Response**:

        ```json theme={null}
        [
          {
            "status": "SUCCESS",
            "data": {
              "refId": "305697289_20250303_J1K2L3M4N5O6",
              ...
            }
          }
        ]
        ```

        <Info>
          Store the returned `refId` for use in Test Case 2.
        </Info>
      </Accordion>

      <Accordion title="Test Case 2: Update Account" icon="pen-to-square">
        **Objective**: Update a previously reported account when account details or owner information changes.

        The `refId` from the original account submission is required to identify the record to update.

        **Request**: `PUT /reports/sask/v1/accounts`

        **Request Body**:

        ```json theme={null}
        [
          {
            "refId": "<refId from Test Case 1>",
            "accountType": "CURRENT_ACCOUNT",
            "iban": "LT701010098765432100",
            "currency": "EUR",
            "openedDate": "2024-12-20",
            "closedDate": "2025-06-30",
            "owner": {
              "type": "J",
              "name": "UAB Example Company",
              "codeCountry": "LT",
              "codeInForeignCountry": "305697289",
              "addressCountry": "LT",
              "address": "Vilnius, Lvovo g. 25"
            }
          }
        ]
        ```

        **Expected Response**:

        ```json theme={null}
        [
          {
            "status": "SUCCESS",
            "data": {
              "refId": "305697289_20250303_J1K2L3M4N5O6",
              ...
            }
          }
        ]
        ```
      </Accordion>

      <Accordion title="Test Case 3: Create Beneficiary" icon="users">
        **Objective**: Report a beneficial owner (natural person) for a legal entity.

        Beneficiaries are reported separately from accounts using the legal entity's identification code.

        **Request**: `POST /reports/sask/v1/beneficiaries`

        **Request Body**:

        ```json theme={null}
        [
          {
            "codeInForeignCountry": "305697289",
            "name": "UAB Example Company",
            "dateFrom": "2024-12-18",
            "country": "LT",
            "address": "Vilnius, Lvovo g. 25",
            "beneficiary": {
              "type": "F",
              "name": "Jonas",
              "surname": "Jonaitis",
              "birthDate": "1990-05-15",
              "addressCountry": "LT",
              "address": "Vilnius, Gedimino pr. 1",
              "codeCountry": "LT",
              "codeInForeignCountry": "39005150001",
              "documentType": "LT_PASSPORT",
              "documentNumber": "AB123456",
              "nationalities": ["LT"]
            }
          }
        ]
        ```

        **Expected Response**:

        ```json theme={null}
        [
          {
            "status": "SUCCESS",
            "data": {
              "refId": "305697289_20250303_F1A2B3C4D5E6",
              ...
            }
          }
        ]
        ```

        <Info>
          Store the returned `refId` for Test Case 4.
        </Info>
      </Accordion>

      <Accordion title="Test Case 4: Update Beneficiary" icon="user-pen">
        **Objective**: Update a beneficiary when their information changes, or end the beneficial ownership by adding `dateTo`.

        The `refId` from the original beneficiary submission is required to identify the record to update.

        **Request**: `PUT /reports/sask/v1/beneficiaries`

        **Request Body**:

        ```json theme={null}
        [
          {
            "refId": "<refId from Test Case 3>",
            "codeInForeignCountry": "305697289",
            "name": "UAB Example Company",
            "dateFrom": "2024-12-18",
            "dateTo": "2025-12-31",
            "country": "LT",
            "address": "Vilnius, Lvovo g. 25",
            "beneficiary": {
              "type": "F",
              "name": "Jonas",
              "surname": "Jonaitis",
              "birthDate": "1990-05-15",
              "addressCountry": "LT",
              "address": "Vilnius, Gedimino pr. 1",
              "codeCountry": "LT",
              "codeInForeignCountry": "39005150001",
              "documentType": "LT_PASSPORT",
              "documentNumber": "AB123456",
              "nationalities": ["LT"]
            }
          }
        ]
        ```

        **Expected Response**:

        ```json theme={null}
        [
          {
            "status": "SUCCESS",
            "data": {
              "refId": "305697289_20250303_F1A2B3C4D5E6",
              ...
            }
          }
        ]
        ```
      </Accordion>

      <Accordion title="Test Case 5: Create Representative" icon="user-tie">
        **Objective**: Add a new representative for an already reported legal entity account.

        The `accountRefId` in the URL must be the `refId` returned when the account was reported.

        **Request**: `POST /reports/sask/v1/accounts/{accountRefId}/representatives`

        **Request Body**:

        ```json theme={null}
        [
          {
            "dateFrom": "2024-12-20",
            "representative": {
              "type": "F",
              "name": "Petras",
              "surname": "Petraitis",
              "birthDate": "1985-03-20",
              "addressCountry": "LT",
              "address": "Kaunas, Laisves al. 10",
              "codeCountry": "LT",
              "codeInForeignCountry": "38503200001",
              "documentType": "LT_PASSPORT",
              "documentNumber": "CD789012",
              "nationalities": ["LT"]
            }
          }
        ]
        ```

        **Expected Response**:

        ```json theme={null}
        [
          {
            "status": "SUCCESS",
            "data": {
              "refId": "b9417266-9842-5bfb-0c47-e41f069gcf44",
              ...
            }
          }
        ]
        ```

        <Info>
          Store the returned representative `refId` for Test Case 6.
        </Info>
      </Accordion>

      <Accordion title="Test Case 6: Update Representative" icon="calendar-xmark">
        **Objective**: Update a representative when their information changes, or end the representative relationship by adding `dateTo`.

        **Request**: `PUT /reports/sask/v1/accounts/{accountRefId}/representatives`

        **Request Body**:

        ```json theme={null}
        [
          {
            "refId": "<representative refId from Test Case 5>",
            "dateFrom": "2024-12-20",
            "dateTo": "2025-12-31",
            "representative": {
              "type": "F",
              "name": "Petras",
              "surname": "Petraitis",
              "birthDate": "1985-03-20",
              "addressCountry": "LT",
              "address": "Kaunas, Laisves al. 10",
              "codeCountry": "LT",
              "codeInForeignCountry": "38503200001",
              "documentType": "LT_PASSPORT",
              "documentNumber": "CD789012",
              "nationalities": ["LT"]
            }
          }
        ]
        ```

        **Expected Response**:

        ```json theme={null}
        [
          {
            "status": "SUCCESS",
            "data": {
              "refId": "b9417266-9842-5bfb-0c47-e41f069gcf44",
              ...
            }
          }
        ]
        ```
      </Accordion>
    </AccordionGroup>
  </Tab>
</Tabs>

## Batch Submission Tests

<AccordionGroup>
  <Accordion title="Test Case: Batch Submission - All Success (HTTP 200/201)" icon="layer-group">
    **Objective**: Verify batch submission where all records are valid.

    **Steps**:

    1. Submit multiple valid records in a single request
    2. Verify HTTP 200 or 201 response
    3. Confirm all items have `status: SUCCESS`

    **Expected Result**:

    ```json theme={null}
    HTTP 201 Created
    [
      { "status": "SUCCESS", "data": { "refId": "..." } },
      { "status": "SUCCESS", "data": { "refId": "..." } },
      { "status": "SUCCESS", "data": { "refId": "..." } }
    ]
    ```
  </Accordion>

  <Accordion title="Test Case: Batch Submission - Partial Success (HTTP 207)" icon="circle-half-stroke">
    **Objective**: Verify batch submission where some records fail validation.

    **Steps**:

    1. Submit multiple records where at least one has invalid data
    2. Verify HTTP 207 response
    3. Confirm successful items have `status: SUCCESS`
    4. Confirm failed items have `status: FAILED` with error details

    **Expected Result**:

    ```json theme={null}
    HTTP 207 Multi-Status
    [
      { "status": "SUCCESS", "data": { "refId": "..." } },
      { "status": "FAILED", "errors": [{ "field": "...", "message": "..." }] }
    ]
    ```
  </Accordion>

  <Accordion title="Test Case: Batch Submission - All Failed (HTTP 400)" icon="xmark">
    **Objective**: Verify batch submission where all records fail validation.

    **Steps**:

    1. Submit multiple records where all have invalid data
    2. Verify HTTP 400 response
    3. Confirm all items have `status: FAILED` with error details

    **Expected Result**:

    ```json theme={null}
    HTTP 400 Bad Request
    [
      { "status": "FAILED", "errors": [{ "field": "...", "message": "..." }] },
      { "status": "FAILED", "errors": [{ "field": "...", "message": "..." }] }
    ]
    ```
  </Accordion>
</AccordionGroup>

## Best Practices

<CardGroup cols={3}>
  <Card title="Store Reference IDs" icon="database">
    Always save the `refId` returned for each created record. You need this ID to update or delete records later.
  </Card>

  <Card title="Handle Partial Success" icon="circle-half-stroke">
    When you receive HTTP 207, check each item in the response array. Some items succeeded while others failed.
  </Card>

  <Card title="Validate Before Submission" icon="check">
    Validate your data locally before sending to reduce failed submissions and improve processing speed.
  </Card>
</CardGroup>
