> For the complete documentation index, see [llms.txt](https://docs.okokscripts.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.okokscripts.io/scripts/okokbillingv3/legacy-docs-v2.md).

# Legacy Docs (V2)

[**YouTube Video**](https://www.youtube.com/watch?v=9gXfTvyzzEI)

{% hint style="danger" %}
**Warning: Legacy Documentation (V2)**

This page is intended **exclusively for okokBillingV2** and should not be used when installing okokBillingV3.

**If you're using okokBillingV3, do NOT execute any SQL queries from this page.** V3 automatically creates the required database tables and migrates existing V2 invoices without any manual intervention.

For V3 installation instructions, please refer to the [**okokBillingV3 documentation**](https://docs.okokscripts.io/scripts/okokbillingv3.md).
{% endhint %}

## Installation Guide

In case you had the previous okokBilling version (both ESX & QBCore) execute the code below in your database, otherwise ignore it.

```sql
DROP TABLE okokbilling;
```

#### Execute the following SQL code in your database:

```sql
CREATE TABLE `okokbilling` (
    `id` int NOT NULL AUTO_INCREMENT,
    `ref_id` varchar(10) NOT NULL,
    `receiver_identifier` varchar(255) NOT NULL,
    `receiver_name` varchar(255) NOT NULL,
    `author_identifier` varchar(255) NOT NULL,
    `author_name` varchar(255) NOT NULL,
    `society` varchar(255) NOT NULL,
    `society_name` varchar(255) NOT NULL,
    `item` varchar(255) NOT NULL,
    `invoice_value` int NOT NULL,
    `fees_amount` int NOT NULL,
    `status` varchar(50) NOT NULL,
    `notes` LONGTEXT DEFAULT ' ',
    `sent_date` varchar(255) NOT NULL,
    `limit_pay_date` varchar(255) NOT NULL,
    `paid_date` varchar(255) DEFAULT NULL,
    PRIMARY KEY (`id`)
);
```

### Server artifacts

Make sure your server artifacts version is above the **5181**.

* Windows: <https://runtime.fivem.net/artifacts/fivem/build_server_windows/master/>
* Linux: <https://runtime.fivem.net/artifacts/fivem/build_proot_linux/master/>

## Snippets:

### Create custom invoices

```lua
TriggerServerEvent("okokBilling:CreateCustomInvoice", target, price, reason, invoiceSource, society, societyName, authorIdentifier)
```

#### Variables:

**target**: `xTarget.source`

**price**: `500`

**reason**: `Speeding`

**invoiceSource**: `Highway Radar`

**society**: `police` (you can remove this in case you want no society to receive money)

**societyName:** `LSPD` (you can remove this in case you want no society to receive money)

### Event to open the My Invoices menu (client side)

```lua
TriggerEvent("okokBilling:ToggleMyInvoices")
```

### Event to open the Create Invoice menu (client side)

```lua
TriggerEvent("okokBilling:ToggleCreateInvoice")
```
