# Financial Transactions Report

## Retrieve debtor financial transactions

<mark style="color:blue;">`GET`</mark> `https://integrate.d6plus.co.za/api/v1/finplus/debtmanagement/financialtransactions/{school_login_id}`

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, enabling precise and targeted reporting. Additionally, the `all_accounts` parameter provides control over whether to include only active accounts or a complete financial history.

#### Path Parameters

| Name                                                | Type    | Description                                      |
| --------------------------------------------------- | ------- | ------------------------------------------------ |
| school\_login\_id<mark style="color:red;">\*</mark> | Integer | The login ID of the school to retrieve data from |

#### Headers

| Name                                              | Type   | Description       |
| ------------------------------------------------- | ------ | ----------------- |
| HTTP-X-USERNAME<mark style="color:red;">\*</mark> | String | As provided by d6 |
| HTTP-X-PASSWORD<mark style="color:red;">\*</mark> | String | As provided by d6 |

#### Query Parameters

| Name                    | Type    | Description                                                                                                               |
| ----------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------- |
| all\_accounts           | Boolean | Whether to include all accounts                                                                                           |
| per\_learner            | Boolean | Whether to include a break-down of transactions per learner                                                               |
| debtor\_code            | Integer | To filter on a specific Debtor Code                                                                                       |
| learner\_id             | Integer | To filter on a specific Learner ID                                                                                        |
| accountable\_person\_id | Integer | To filter on a specific Accountable Person ID                                                                             |
| category\_id            | Integer | To filter on a specific Category ID                                                                                       |
| start\_date             | String  | The start date for filtering transactions (format: YYYY-MM-DD)                                                            |
| end\_date               | String  | The end date for filtering transactions (format: `YYYY-MM-DD`). The `start_date` is required when specifying an end date. |

#### Response Examples

{% tabs %}
{% tab title="200: Per family and parent" %}

```json
[
    {
        "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"
            }
        ]
    }
]
```

{% endtab %}

{% tab title="200: Per learner" %}

```json
[
    {
        "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"
                    }
                ]
            }
        ]
    }
]
```

{% endtab %}

{% tab title="204: No Content" %}

```json
```

{% endtab %}

{% tab title="401: Unauthorized The server understood the request, but is refusing it or access is not allowed." %}

```json
{
    "error": "Unauthorized",
    "error_description": "Client access not authorised"
}
```

{% endtab %}

{% tab title="403: Forbidden The server understood the request, but the requested action is not allowed." %}

```json
{
    "error": "Integration not activated",
    "error_description": "Please activate the Finance+ API for this client before making this request"
}
```

{% endtab %}
{% endtabs %}

## Code Samples

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

```php
<?php

const BASE_URL = 'https://integrate.d6plus.co.za/api/v1/finplus/debtmanagement/financialtransactions';
const SCHOOL_LOGIN_ID = '1000';
const PARAMS = [
    'per_learner' => 1, 
    'all_accounts' => 1
    ];
const API_USERNAME = getenv('API_USERNAME'); // Assuming you have these environment variables set
const API_PASSWORD = getenv('API_PASSWORD');

$curl = curl_init();

$query = http_build_query(PARAMS);

$options = [
    CURLOPT_URL => BASE_URL . '/' . SCHOOL_LOGIN_ID . '?' . $query,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_SSL_VERIFYPEER => true,
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_HTTPHEADER => [
        "HTTP-X-USERNAME: " . API_USERNAME,
        "HTTP-X-PASSWORD: " . API_PASSWORD
    ],
];

curl_setopt_array($curl, $options);

$response = curl_exec($curl);

if (curl_errno($curl)) {
    throw new Exception('Curl error: ' . curl_error($curl));
}

curl_close($curl);

echo $response;
```

{% endtab %}

{% tab title="cURL" %}

```bash
curl --location 'https://integrate.d6plus.co.za/api/v1/finplus/debtmanagement/financialtransactions/1000?per_learner=1&all_accounts=1' \
--header 'HTTP-X-USERNAME: your_username' \
--header 'HTTP-X-PASSWORD: your_password'
```

{% 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/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.
