# Ledger

#### Create Ledger

## Create Ledger

<mark style="color:green;">`POST`</mark> `{base url}/v1/accounting/ledgers`

Create a new ledger

**Headers**

| Name                                                   | Type   | Description           |
| ------------------------------------------------------ | ------ | --------------------- |
| Authorization header<mark style="color:red;">\*</mark> | string | `API user secret key` |

**Body**

<table><thead><tr><th width="246">Name</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><code>ledgerName</code><mark style="color:red;">*</mark></td><td>string</td><td>Ledger account name</td></tr><tr><td><code>currency</code><mark style="color:red;">*</mark></td><td>string</td><td>Ledger currency</td></tr><tr><td><code>ledgerType</code><mark style="color:red;">*</mark></td><td>number</td><td>Ledger type</td></tr><tr><td><code>description</code></td><td>string</td><td>Ledger description</td></tr><tr><td><code>isActive</code></td><td>boolean</td><td>Ledger status</td></tr><tr><td><code>allowedManualEntry</code><mark style="color:red;">*</mark></td><td>boolean</td><td>Ledger manual entry status</td></tr><tr><td><code>isHeadAccount</code></td><td>boolean</td><td>Ledger account type</td></tr><tr><td><code>headAccount</code></td><td>string</td><td>If ledger head account is false, provide head acount here</td></tr></tbody></table>

**Response**

{% tabs %}
{% tab title="200: OK ledger created successfully " %}

```json
{
    "responseCode": "00",
    "message": "Ledger successfully created",
    "data": {
        "organizationId": "153c58d7-c15b-41fa-a717-67b5ae8e3f98",
        "name": "Ledger1",
        "type": 101,
        "currency": "NGN",
        "description": "Expense account",
        "allowedManualEntry": false,
        "isHeadAccount": true,
        "isActive": true,
        "accountNumber": "1012130087",
        "id": "5b1f7422-bed6-473f-81a0-1712359a1023",
        "balance": 0,
        "created_at": "2024-03-28T07:09:19.554Z",
        "updated_at": "2024-03-28T07:09:19.554Z"
    }
}
```

{% endtab %}

{% tab title="400: Forbidden unauthorised " %}

```json
{
    "message": "No authorization token found",
    "code": 90
}
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Sample request" %}

```
{
    "ledgerName" : "Ledger1",
    "currency" : "NGN",
    "ledgerType" : 101,
    "description": "Expense account",
    "isActive": true,
    "allowedManualEntry": false,
    "isHeadAccount":true,
}
```

{% endtab %}

{% tab title="Sample response" %}

```
{
    "responseCode": "00",
    "message": "Ledger successfully created",
    "data": {
        "organizationId": "153c58d7-c15b-41fa-a717-67b5ae8e3f98",
        "name": "Ledger1",
        "type": 101,
        "currency": "NGN",
        "description": "Expense account",
        "allowedManualEntry": false,
        "isHeadAccount": true,
        "isActive": true,
        "accountNumber": "1012130087",
        "id": "5b1f7422-bed6-473f-81a0-1712359a1023",
        "balance": 0,
        "created_at": "2024-03-28T07:09:19.554Z",
        "updated_at": "2024-03-28T07:09:19.554Z"
    }
}
```

{% endtab %}
{% endtabs %}

#### Update Ledger balance

## Update Ledger Balance

<mark style="color:green;">`PATCH`</mark> `{Base url}/v1/accounting/update_balance/{ledgerId}`

Update ledger balance

**Headers**

| Name                                                   | Type   | Description           |
| ------------------------------------------------------ | ------ | --------------------- |
| Authorization header<mark style="color:red;">\*</mark> | string | `API user secret key` |

**Body**

<table><thead><tr><th width="246">Name</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><code>amount</code><mark style="color:red;">*</mark></td><td>number</td><td>amount</td></tr><tr><td><code>type</code><mark style="color:red;">*</mark></td><td>string</td><td>Ledger type (credit or debit)</td></tr></tbody></table>

**Response**

{% tabs %}
{% tab title="200: Ok ledger balance credited successfully" %}

```json
{
    "message": "ledger balance credited successfully",
    "data": {
        "balance": 2000
    }
}
```

{% endtab %}

{% tab title="400: Forbidden unauthorised " %}

```json
{
    "message": "No authorization token found",
    "code": 90
}
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Sample request" %}

```
{
    "amount": 2000,
    "type": "credit"
}

```

{% endtab %}

{% tab title="Sample response" %}

```
{
    "message": "ledger balance credited successfully",
    "data": {
        "balance": 2000
    }
}
```

{% endtab %}
{% endtabs %}

#### Fetch Ledgers

## Fetch Ledgers

<mark style="color:green;">`GET`</mark> `{Base url}/v1/accounting/ledgers`

Fetch all available ledgers

**Headers**

| Name                                                   | Type   | Description           |
| ------------------------------------------------------ | ------ | --------------------- |
| Authorization header<mark style="color:red;">\*</mark> | string | `API user secret key` |

**Response**

{% tabs %}
{% tab title="200: Ok ledgers fetch successfully" %}

```json
{
    "message": "ledgers fetch successfully",
    "data": [
        {
            "id": "32430370-69bd-4347-ab2d-f92df7b64ab6",
            "organizationId": "153c58d7-c15b-41fa-a717-67b5ae8e3f98",
            "name": "transactions gl",
            "accountNumber": "3033699536",
            "balance": 0,
            "currency": "NGN",
            "type": 303,
            "description": "test",
            "isHeadAccount": true,
            "headAccount": "",
            "isActive": false,
            "allowedManualEntry": true,
            "created_at": "2024-02-05T19:47:18.486Z",
            "updated_at": "2024-03-13T14:33:19.355Z",
            "childAccount": [
                {
                    "id": "08f743a6-757f-4e06-a729-dc3989001e30",
                    "organizationId": "153c58d7-c15b-41fa-a717-67b5ae8e3f98",
                    "name": "transactions child",
                    "accountNumber": "3036126385",
                    "balance": 660000,
                    "currency": "NGN",
                    "type": 303,
                    "description": "test",
                    "isHeadAccount": false,
                    "headAccount": "3033699536",
                    "isActive": false,
                    "allowedManualEntry": true,
                    "created_at": "2024-02-05T19:47:36.279Z",
                    "updated_at": "2024-03-13T14:32:41.612Z"
                }
            ]
        },
}
```

{% endtab %}

{% tab title="400: Forbidden unauthorised " %}

```json
{
    "message": "No authorization token found",
    "code": 90
}
```

{% endtab %}
{% endtabs %}

#### Fetch Ledger Balance

## Fetch Ledger Balance

<mark style="color:green;">`GET`</mark> `{Base url}/v1/accounting/{ledgerId}/balance`

Fetch ledger balance

**Headers**

| Name                                                   | Type   | Description           |
| ------------------------------------------------------ | ------ | --------------------- |
| Authorization header<mark style="color:red;">\*</mark> | string | `API user secret key` |

**Response**

{% tabs %}
{% tab title="200: Ok ledger balance fetch successfully" %}

```json
{
    "message": "ledger balance fetch successfully",
    "data": {
        "accountNumber": "3033699536",
        "balance": 0
    }
}
```

{% endtab %}

{% tab title="400: Forbidden unauthorised " %}

```json
{
    "message": "No authorization token found",
    "code": 90
}
```

{% endtab %}
{% endtabs %}

#### Fetch Ledger Transactions

## Fetch Ledger Transactions

<mark style="color:green;">`GET`</mark> `{base url}/v1/accounting/ledgers/transactions`

Fetch all Ledger transactions

**Headers**

| Name                 | Value                 |
| -------------------- | --------------------- |
| Authorization header | `API user secret key` |

**Params**

<table><thead><tr><th width="221">Name</th><th>Type</th><th width="185">Description</th></tr></thead><tbody><tr><td><code>accountNumber</code><mark style="color:red;">*</mark></td><td>string</td><td>Account number</td></tr><tr><td><code>startDate</code></td><td>string</td><td>table sort start date</td></tr><tr><td><code>endDate</code></td><td>string</td><td>table sort end date</td></tr><tr><td><code>page</code></td><td>number</td><td>page to fetch</td></tr><tr><td>perPage</td><td>number</td><td>number of items to fetch perPage</td></tr></tbody></table>

**Response**

{% tabs %}
{% tab title="200: ledger transactions fetch successful" %}

```json
{
    "responseCode": "00",
    "message": "ledger transactions fetch successful",
    "data": [
        {
            "id": "dd3269f9-0488-4103-a1f5-b36674e6fcbd",
            "organizationId": "153c58d7-c15b-41fa-a717-67b5ae8e3f98",
            "productId": "33c5ed37-56db-4275-b362-473f6a17f7ff",
            "accountNumber": "3036126385",
            "accountName": "transactions child",
            "accountType": "general_ledger",
            "transactionGroup": "deposit",
            "amount": 200000,
            "narration": "deposit on 59607912061",
            "type": "deposits",
            "created_at": "2024-02-06T06:57:53.286Z",
            "updated_at": "2024-02-06T06:57:53.290Z",
            "userId": "a677cce1-efec-4fc1-bf82-a5c2af257673",
            "fullName": "Louis",
            "total_count": "4"
        },
        {
            "id": "8f480ee0-5835-4302-a63b-1647f284f90f",
            "organizationId": "153c58d7-c15b-41fa-a717-67b5ae8e3f98",
            "productId": "33c5ed37-56db-4275-b362-473f6a17f7ff",
            "accountNumber": "3036126385",
            "accountName": "transactions child",
            "accountType": "general_ledger",
            "transactionGroup": "deposit",
            "amount": 50000,
            "narration": "withdrawal on 59607912061",
            "type": "withdrawals",
            "created_at": "2024-02-06T06:58:08.641Z",
            "updated_at": "2024-02-06T06:58:08.644Z",
            "userId": "a677cce1-efec-4fc1-bf82-a5c2af257673",
            "fullName": "Louis",
            "total_count": "4"
        },
    ],
    "pagination": {
        "totalCount": 4,
        "totalPages": null,
        "previousPage": 1,
        "nextPage": 1
    }
}
```

{% endtab %}

{% tab title="400: Forbidden unauthorised " %}

```json
{
    "message": "No authorization token found",
    "code": 90
}
```

{% endtab %}
{% endtabs %}

#### get trial balance

## get trial balance

<mark style="color:green;">`POST`</mark> `{base url}/accounting/trial_balance`

get ledger trial balance

**Headers**

| Name                                                         | Value                 |
| ------------------------------------------------------------ | --------------------- |
| `Authorization header`` `<mark style="color:red;">`*`</mark> | `API user secret key` |

**Query parameters**&#x20;

| Name      | Type   | Description              |
| --------- | ------ | ------------------------ |
| `page`    | number | page to fetch            |
| `perPage` | number | number of items per page |

**Response**

{% tabs %}
{% tab title="200: OK ledgers fetch successful" %}

```json
{
    "responseCode": "00",
    "message": "ledgers fetch successful",
    "data": [
        {
            "id": "5b1f7422-bed6-473f-81a0-1712359a1023",
            "organizationId": "153c58d7-c15b-41fa-a717-67b5ae8e3f98",
            "name": "Ledger1",
            "accountNumber": "1012130087",
            "balance": 2000,
            "currency": "NGN",
            "type": "101",
            "description": "Expense account",
            "isHeadAccount": true,
            "headAccount": "if isHeadAccount is false, you will provide the headAccount here",
            "isActive": true,
            "allowedManualEntry": false,
            "created_at": "2024-03-28T07:09:19.554Z",
            "updated_at": "2024-03-28T07:21:49.056Z",
            "total_count": "11"
        },
        {
            "id": "08f743a6-757f-4e06-a729-dc3989001e30",
            "organizationId": "153c58d7-c15b-41fa-a717-67b5ae8e3f98",
            "name": "transactions child",
            "accountNumber": "3036126385",
            "balance": 660000,
            "currency": "NGN",
            "type": "303",
            "description": "test",
            "isHeadAccount": false,
            "headAccount": "3033699536",
            "isActive": false,
            "allowedManualEntry": true,
            "created_at": "2024-02-05T19:47:36.279Z",
            "updated_at": "2024-03-13T14:32:41.612Z",
            "total_count": "11"
        },
    ],
    "pagination": {
        "currentPage": 1,
        "perPage": 20,
        "totalCount": 11,
        "totalPages": 1,
        "previousPage": 0,
        "nextPage": 1
    }
}
```

{% endtab %}

{% tab title="400: Forbidden unauthorised " %}

```json
{
    "message": "No authorization token found",
    "code": 90
}
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Sample response" %}

```
{
    "responseCode": "00",
    "message": "ledgers fetch successful",
    "data": [
        {
            "id": "5b1f7422-bed6-473f-81a0-1712359a1023",
            "organizationId": "153c58d7-c15b-41fa-a717-67b5ae8e3f98",
            "name": "Ledger1",
            "accountNumber": "1012130087",
            "balance": 2000,
            "currency": "NGN",
            "type": "101",
            "description": "Expense account",
            "isHeadAccount": true,
            "headAccount": "if isHeadAccount is false, you will provide the headAccount here",
            "isActive": true,
            "allowedManualEntry": false,
            "created_at": "2024-03-28T07:09:19.554Z",
            "updated_at": "2024-03-28T07:21:49.056Z",
            "total_count": "11"
        },
        {
            "id": "08f743a6-757f-4e06-a729-dc3989001e30",
            "organizationId": "153c58d7-c15b-41fa-a717-67b5ae8e3f98",
            "name": "transactions child",
            "accountNumber": "3036126385",
            "balance": 660000,
            "currency": "NGN",
            "type": "303",
            "description": "test",
            "isHeadAccount": false,
            "headAccount": "3033699536",
            "isActive": false,
            "allowedManualEntry": true,
            "created_at": "2024-02-05T19:47:36.279Z",
            "updated_at": "2024-03-13T14:32:41.612Z",
            "total_count": "11"
        },
    ],
    "pagination": {
        "currentPage": 1,
        "perPage": 20,
        "totalCount": 11,
        "totalPages": 1,
        "previousPage": 0,
        "nextPage": 1
    }
}
```

{% 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://oobla.gitbook.io/tyche/reference/ledger.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.
