# UK Banking

***

### Important

All exports must be used **server-side only.**

Using these exports client-side will not work.

***

## AddMoney 💰

Adds funds to a personal or business account.

#### Export

```lua
exports["LGMods_Banking"]:AddMoney(playerId, amount, accountType, businessName)
```

#### Parameters

| Parameter    | Type   | Required      | Description                            |
| ------------ | ------ | ------------- | -------------------------------------- |
| playerId     | number | Yes           | Player server ID                       |
| amount       | number | Yes           | Amount to add (must be greater than 0) |
| accountType  | string | Yes           | "personal" or "business"               |
| businessName | string | Business only | Business/job name (e.g. "lscustoms")   |

#### Returns

boolean\
Returns true if accepted, otherwise false.

#### Example

```lua
-- Add to personal account
exports["LGMods_Banking"]:AddMoney(source, 2500, "personal")

-- Add to business account
exports["LGMods_Banking"]:AddMoney(source, 5000, "business", "lscustoms")
```

#### Behaviour

• Sends an in-game notification\
• Inserts a transaction into lgmods\_banking\_transactions\
• Refreshes relevant UI data

***

## RemoveMoney 💸

Removes funds from a personal or business account.

#### Export

```lua
exports["LGMods_Banking"]:RemoveMoney(playerId, amount, accountType, businessName)
```

#### Parameters

| Parameter    | Type   | Required      | Description                               |
| ------------ | ------ | ------------- | ----------------------------------------- |
| playerId     | number | Yes           | Player server ID                          |
| amount       | number | Yes           | Amount to remove (must be greater than 0) |
| accountType  | string | Yes           | "personal" or "business"                  |
| businessName | string | Business only | Business/job name                         |

#### Returns

boolean\
Returns true on success, false on failure.

#### Business Withdrawal Permissions

When removing money from a business account:

• Player must have the matching job name\
• Player must meet Config.BusinessAccounts\[businessName].minGrade

If either condition fails, the withdrawal is denied.

#### Example

```lua
exports["LGMods_Banking"]:RemoveMoney(source, 1000, "personal")

exports["LGMods_Banking"]:RemoveMoney(source, 2500, "business", "lscustoms")
```

***

## AddTransaction 🧾

Manually inserts a transaction entry into the banking history.

#### Export

```lua
exports["LGMods_Banking"]:AddTransaction(playerId, transactionType, amount, accountType, note, businessName)
```

#### Parameters

| Parameter       | Type   | Required      | Description                    |
| --------------- | ------ | ------------- | ------------------------------ |
| playerId        | number | Yes           | Player server ID               |
| transactionType | string | Yes           | Example: "Purchase", "Payroll" |
| amount          | number | Yes           | Must be greater than 0         |
| accountType     | string | Yes           | "personal" or "business"       |
| note            | string | Optional      | Custom description             |
| businessName    | string | Business only | Business/job name              |

#### Returns

boolean

#### Example

```lua
-- Personal transaction
exports["LGMods_Banking"]:AddTransaction(
    source,
    "Vehicle Purchase",
    25000,
    "personal",
    "Bought Sultan RS"
)

-- Business transaction
exports["LGMods_Banking"]:AddTransaction(
    source,
    "Payroll",
    10000,
    "business",
    "Weekly wages",
    "lscustoms"
)
```

***

## GetAccountDetails 🏦

Retrieves account information for personal or business accounts.

This export is callback-based due to asynchronous database queries.

#### Export

```lua
exports["LGMods_Banking"]:GetAccountDetails(playerId, accountType, businessName, callback)
```

#### Parameters

| Parameter    | Type     | Required      | Description              |
| ------------ | -------- | ------------- | ------------------------ |
| playerId     | number   | Yes           | Player server ID         |
| accountType  | string   | Yes           | "personal" or "business" |
| businessName | string   | Business only | Business/job name        |
| callback     | function | Yes           | Receives result object   |

#### Callback Response

On success (Personal):

success = true\
account.identifier\
account.balance\
account.sortcode\
account.accountnumber

On success (Business):

success = true\
account = row from lgmods\_business\_accounts

On failure:

success = false\
error = reason string

#### Example

```lua
exports["LGMods_Banking"]:GetAccountDetails(source, "personal", nil, function(data)
    if data.success then
        print("Balance:", data.account.balance)
    end
end)
```

***

## TransferMoney 🔁

Initiates a transfer from a personal or business account.

#### Export

```lua
exports["LGMods_Banking"]:TransferMoney(playerId, amount, fromType, toSortcode, toAccountnumber, businessName)
```

#### Parameters

| Parameter       | Type   | Required      | Description                      |
| --------------- | ------ | ------------- | -------------------------------- |
| playerId        | number | Yes           | Player initiating transfer       |
| amount          | number | Yes           | Must be greater than 0           |
| fromType        | string | Yes           | "personal" or "business"         |
| toSortcode      | string | Yes           | Destination sort code            |
| toAccountnumber | string | Yes           | Destination account number       |
| businessName    | string | Business only | Required if fromType is business |

#### Returns

boolean

#### Example

```lua
exports["LGMods_Banking"]:TransferMoney(
    source,
    2500,
    "personal",
    "12-34-56",
    "12345678"
)

exports["LGMods_Banking"]:TransferMoney(
    source,
    5000,
    "business",
    "12-34-56",
    "12345678",
    "lscustoms"
)
```

***

## Database Requirements 🗄

#### Required Tables

• lgmods\_banking\_transactions\
• lgmods\_business\_accounts

#### Framework Integration

ESX

• users.identifier\
• users.sortcode\
• users.accountnumber

QBCore

• players.citizenid\
• players.sortcode\
• players.accountnumber

***

## Dependencies 🔧

• oxmysql\
• ESX or QBCore\
• Correct Config.Framework configuration


---

# 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://docs.lgmods.co.uk/scripts/uk-banking.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.
