# Financial Transactions Report

<mark style="color:blue;">`GET`</mark> `/v2/finplus/debtmanagement/financialtransactions`

This report provides **a comprehensive view of transactions**, offering the ability to **group** data by family/parent while also allowing for further **breakdowns** per learner using the `per_learner` parameter. When `per_learner` is specified, the family/parent object is extended to include **learner-specific transaction details**. The API supports flexible filtering options, such as date ranges, category IDs, debtor codes, learners, and accountable persons.

The possible **transaction types** and **transaction categories** can be looked up using the [Get Transaction Type(s)](/v2/reference/finance+/debt-management/get-transaction-type-s.md) and [Get Transaction Category(s)](broken://pages/VqXRquSvVzmxaz0SXOwk) API calls.

### Pagination <a href="#pagination" id="pagination"></a>

The response data includes a `meta` object that contains **pagination-specific metadata**. You can use the following query parameters to **control pagination**:

* **limit**: This parameter allows you to override the default limit of records returned, up to the `max_allowed_limit` specified in the response's `meta` object.
* **cursor**: If the `meta` object contains a `next_cursor` field, it indicates that more records are available. To fetch the next set of records, include the `cursor` parameter in your request with the value of `next_cursor`. If the `next_cursor` field is not present, it means there are no more records to retrieve.
* **reverse\_order**: This parameter can be used to reverse the order in which the data is returned, useful for fetching the latest records first.

### Request Headers

<table><thead><tr><th width="196.571533203125">Name</th><th width="106.85711669921875">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>HTTP-X-USERNAME</code><mark style="color:red;">*</mark></td><td>String</td><td>As provided by d6</td></tr><tr><td><code>HTTP-X-PASSWORD</code><mark style="color:red;">*</mark></td><td>String</td><td>As provided by d6</td></tr><tr><td><code>HTTP-X-SCHOOLID</code><mark style="color:red;">*</mark></td><td>Integer</td><td>The unique identifier of the school for which the data is being queried.</td></tr></tbody></table>

### Query Parameters

<table><thead><tr><th width="220.3427734375">Name</th><th width="111.71429443359375">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>all_accounts</code></td><td>Boolean</td><td>Whether to include <strong>all</strong> accounts</td></tr><tr><td><code>per_learner</code></td><td>Boolean</td><td>Whether to include a break-down of transactions <strong>per learner</strong></td></tr><tr><td><code>debtor_code</code></td><td>Integer</td><td>To filter on a specific <strong>Debtor Code</strong></td></tr><tr><td><code>learner_id</code></td><td>Integer</td><td>To filter on a specific <strong>Learner ID</strong></td></tr><tr><td><code>accountable_person_id</code></td><td>Integer</td><td>To filter on a specific <strong>Accountable Person ID</strong></td></tr><tr><td><code>category_id</code></td><td>Integer</td><td>To filter on a specific <strong>Category ID</strong></td></tr><tr><td><code>start_date</code></td><td>String</td><td>The <strong>start date</strong> for filtering transactions (format: YYYY-MM-DD)</td></tr><tr><td><code>end_date</code></td><td>String</td><td>The <strong>end date</strong> for filtering transactions (format: <code>YYYY-MM-DD</code>). The <code>start_date</code> is required when specifying an end date.</td></tr><tr><td><code>cursor</code></td><td>String</td><td>To <strong>retrieve</strong> the <strong>next group</strong> of items (if any)</td></tr><tr><td><code>limit</code></td><td>Integer</td><td>To <strong>override</strong> the <strong>default limit</strong> of records returned (up to the <code>max_allowed_limit</code> provided in the response metadata).</td></tr><tr><td><code>reverse_order</code></td><td>Boolean</td><td>To <strong>reverse</strong> the <strong>order</strong> the data is returned in</td></tr></tbody></table>

### Response Examples

{% tabs %}
{% tab title="Success: Per family and parent (200 OK)" %}
**Status:** <mark style="color:green;">`200 OK`</mark>

<pre class="language-json"><code class="lang-json"><strong>{
</strong>    "data": [
        {
            "debtor_code": "1001",
            "accountable_person_id": "40",
            "transactions": [
                {
                    "category_id": null,
                    "category_name": null,
                    "transaction_date": "2024-04-01",
                    "transaction_type_id": null,
                    "transaction_type_name": null,
                    "transaction_reference": null,
                    "transaction_description": "Opening balance",
                    "part_of_base_fee": null,
                    "debit_amount": "17200.00",
                    "credit_amount": "0.00",
                    "accumulated_balance": "17200.00"
                },
                {
                    "category_id": "1",
                    "category_name": "School Fees",
                    "transaction_date": "2024-04-01",
                    "transaction_type_id": "14",
                    "transaction_type_name": "Debtor Invoice",
                    "transaction_reference": "663",
                    "transaction_description": "Invoice - School Fees Jordan Smith - 00002 Apr2024",
                    "part_of_base_fee": "1",
                    "debit_amount": "2000.00",
                    "credit_amount": "0.00",
                    "accumulated_balance": "19200.00"
                },
                {
                    "category_id": "6",
                    "category_name": "Hostel Fees",
                    "transaction_date": "2024-04-01",
                    "transaction_type_id": "14",
                    "transaction_type_name": "Debtor Invoice",
                    "transaction_reference": "872",
                    "transaction_description": "Invoice - Hostel Fees Jordan Smith - 00002 Apr2024",
                    "part_of_base_fee": "0",
                    "debit_amount": "1000.00",
                    "credit_amount": "0.00",
                    "accumulated_balance": "20200.00"
                },
                {
                    "category_id": "1",
                    "category_name": "School Fees",
                    "transaction_date": "2024-05-01",
                    "transaction_type_id": "14",
                    "transaction_type_name": "Debtor Invoice",
                    "transaction_reference": "682",
                    "transaction_description": "Invoice - School Fees Jordan Smith - 00002 May2024",
                    "part_of_base_fee": "1",
                    "debit_amount": "2000.00",
                    "credit_amount": "0.00",
                    "accumulated_balance": "22700.00"
                },
                {
                    "category_id": "6",
                    "category_name": "Hostel Fees",
                    "transaction_date": "2024-05-01",
                    "transaction_type_id": "14",
                    "transaction_type_name": "Debtor Invoice",
                    "transaction_reference": "891",
                    "transaction_description": "Invoice - Hostel Fees Jordan Smith - 00002 May2024",
                    "part_of_base_fee": "0",
                    "debit_amount": "1000.00",
                    "credit_amount": "0.00",
                    "accumulated_balance": "23700.00"
                }
            ]
        },
        {
            "debtor_code": "1002",
            "accountable_person_id": "3",
            "transactions": [
                {
                    "category_id": null,
                    "category_name": null,
                    "transaction_date": "2024-04-01",
                    "transaction_type_id": null,
                    "transaction_type_name": null,
                    "transaction_reference": null,
                    "transaction_description": "Opening balance",
                    "part_of_base_fee": null,
                    "debit_amount": "21700.00",
                    "credit_amount": "0.00",
                    "accumulated_balance": "21700.00"
                },
                {
                    "category_id": "1",
                    "category_name": "School Fees",
                    "transaction_date": "2024-04-01",
                    "transaction_type_id": "14",
                    "transaction_type_name": "Debtor Invoice",
                    "transaction_reference": "662",
                    "transaction_description": "Invoice - School Fees Nic Webster - 00001 Apr2024",
                    "part_of_base_fee": "1",
                    "debit_amount": "2000.00",
                    "credit_amount": "0.00",
                    "accumulated_balance": "23700.00"
                }
            ]
        }
    ],
    "meta": {
        "limit": 10,
        "max_allowed_limit": 50,
        "cursor": "eyJpZCI6MjU0NiwiX2JhY2t3YXJkIjpmYWxzZX0"
    }
}
</code></pre>

{% endtab %}

{% tab title="Success: Per learner (200 OK)" %}
**Status:** <mark style="color:green;">`200 OK`</mark>

```json
{
    "data": [
        {
            "debtor_code": "1001",
            "accountable_person_id": "40",
            "learners": [
                {
                    "learner_id": "1",
                    "learner_first_name": "Jordan",
                    "learner_last_name": "Smith",
                    "transactions": [
                        {
                            "category_id": null,
                            "category_name": null,
                            "transaction_date": "2024-04-01",
                            "transaction_type_id": null,
                            "transaction_type_name": null,
                            "transaction_reference": null,
                            "transaction_description": "Opening balance",
                            "part_of_base_fee": null,
                            "debit_amount": "21700.00",
                            "credit_amount": "0.00",
                            "accumulated_balance": "21700.00"
                        },
                        {
                            "category_id": "1",
                            "category_name": "School Fees",
                            "transaction_date": "2024-04-01",
                            "transaction_type_id": "14",
                            "transaction_type_name": "Debtor Invoice",
                            "transaction_reference": "662",
                            "transaction_description": "Invoice - School Fees Jordan Smith - 00001 Apr2024",
                            "part_of_base_fee": "1",
                            "debit_amount": "2000.00",
                            "credit_amount": "0.00",
                            "accumulated_balance": "23700.00"
                        },
                        {
                            "category_id": "6",
                            "category_name": "Hostel Fees",
                            "transaction_date": "2024-04-01",
                            "transaction_type_id": "14",
                            "transaction_type_name": "Debtor Invoice",
                            "transaction_reference": "871",
                            "transaction_description": "Invoice - Hostel Fees Jordan Smith - 00001 Apr2024",
                            "part_of_base_fee": "0",
                            "debit_amount": "1000.00",
                            "credit_amount": "0.00",
                            "accumulated_balance": "24700.00"
                        },
                        {
                            "category_id": "1",
                            "category_name": "School Fees",
                            "transaction_date": "2024-05-01",
                            "transaction_type_id": "14",
                            "transaction_type_name": "Debtor Invoice",
                            "transaction_reference": "681",
                            "transaction_description": "Invoice - School Fees Jordan Smith - 00001 May2024",
                            "part_of_base_fee": "1",
                            "debit_amount": "2000.00",
                            "credit_amount": "0.00",
                            "accumulated_balance": "27200.00"
                        },
                        {
                            "category_id": "6",
                            "category_name": "Hostel Fees",
                            "transaction_date": "2024-05-01",
                            "transaction_type_id": "14",
                            "transaction_type_name": "Debtor Invoice",
                            "transaction_reference": "890",
                            "transaction_description": "Invoice - Hostel Fees Jordan Smith - 00001 May2024",
                            "part_of_base_fee": "0",
                            "debit_amount": "1000.00",
                            "credit_amount": "0.00",
                            "accumulated_balance": "28200.00"
                        }
                    ]
                }
            ]
        },
        {
            "debtor_code": "1002",
            "accountable_person_id": "3",
            "learners": [
                {
                    "learner_id": "3",
                    "learner_first_name": "Nick",
                    "learner_last_name": "Webster",
                    "transactions": [
                        {
                            "category_id": null,
                            "category_name": null,
                            "transaction_date": "2024-04-01",
                            "transaction_type_id": null,
                            "transaction_type_name": null,
                            "transaction_reference": null,
                            "transaction_description": "Opening balance",
                            "part_of_base_fee": null,
                            "debit_amount": "17200.00",
                            "credit_amount": "0.00",
                            "accumulated_balance": "17200.00"
                        },
                        {
                            "category_id": "1",
                            "category_name": "School Fees",
                            "transaction_date": "2024-04-01",
                            "transaction_type_id": "14",
                            "transaction_type_name": "Debtor Invoice",
                            "transaction_reference": "663",
                            "transaction_description": "Invoice - School Fees Nick Webster - 00002 Apr2024",
                            "part_of_base_fee": "1",
                            "debit_amount": "2000.00",
                            "credit_amount": "0.00",
                            "accumulated_balance": "19200.00"
                        },
                        {
                            "category_id": "1",
                            "category_name": "School Fees",
                            "transaction_date": "2024-05-01",
                            "transaction_type_id": "14",
                            "transaction_type_name": "Debtor Invoice",
                            "transaction_reference": "682",
                            "transaction_description": "Invoice - School Fees Nick Webster - 00002 May2024",
                            "part_of_base_fee": "1",
                            "debit_amount": "2000.00",
                            "credit_amount": "0.00",
                            "accumulated_balance": "22700.00"
                        }
                    ]
                }
            ]
        }
    ],
    "meta": {
        "limit": 10,
        "max_allowed_limit": 50,
        "cursor": "eyJpZCI6MjU0NiwiX2JhY2t3YXJkIjpmYWxzZX0"
    }

}
```

{% endtab %}

{% tab title="Validation Error (400 Bad Request)" %}
**Description:** When validation failed for one or more fields

**Status:** <mark style="color:red;">`400 Bad Request`</mark>

```json
{
    "success": false,
    "message": "Validation Failed",
    "validation_errors": {
        "accountable_person_id": "The Accountable person id must be integer",
        "start_date": "The Start date is not valid date format. Expected format is 'Y-m-d'."
    }
}
```

{% endtab %}
{% endtabs %}

### Code Samples

{% tabs %}
{% tab title="PHP" %}

```php
<?php

// API Credentials
$api_username = 'your_username';
$api_password = 'your_password';
$school_id = 'your_school_id';

// Base API endpoint
$base_url = 'https://integrate.d6plus.co.za/api/v2/finplus/debtmanagement/financialtransactions';

// Query parameters (customize as needed)
$query_params = [
    'all_accounts'          => 1, // To include all accounts (including left learners and zero-balance accounts)
    'per_learner'           => 1, // To group by learner
    'category_id'           => '',
    'debtor_code'           => '1001',
    'learner_id'            => '',
    'accountable_person_id' => '',
    'start_date'            => '',
    'end_date'              => '',
    // Pagination controls
    'limit'                 => 50,
    'reverse_order'         => 1,
    'cursor'                => 'eyJ2YWx1ZSI6IjcxIiwiX2JhY2t3YXJkIjp0cnVlfQ'
];

// Build the full request URL
$url = $base_url . '?' . http_build_query(array_filter($query_params));

// Initialize cURL
$curl = curl_init();

// Set cURL options
curl_setopt_array($curl, [
    CURLOPT_URL            => $url,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_TIMEOUT        => 30,  // Prevents hanging requests
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_HTTP_VERSION   => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST  => 'GET',
    CURLOPT_HTTPHEADER     => [
        "HTTP-X-USERNAME: $api_username",
        "HTTP-X-PASSWORD: $api_password",
        "HTTP-X-SCHOOLID: $school_id",
        "Accept: application/json"
    ],
]);

// Execute request
$response = curl_exec($curl);

// Check for errors
if (curl_errno($curl)) {
    throw new Exception('cURL Error: ' . curl_error($curl));
}

// Close cURL
curl_close($curl);

// Output the response
header('Content-Type: application/json');
echo $response;

```

{% endtab %}

{% tab title="cURL" %}

```bash
curl --request GET 'https://integrate.d6plus.co.za/api/v2/finplus/debtmanagement/financialtransactions?per_learner=1&all_accounts=1' \
     --header 'HTTP-X-USERNAME: your_username' \
     --header 'HTTP-X-PASSWORD: your_password' \
     --header 'HTTP-X-SCHOOLID: the_school_id'
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://apidocs.d6plus.co.za/v2/reference/finance+/debt-management/financial-transactions-report.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
