> For the complete documentation index, see [llms.txt](https://corem.gitbook.io/corem/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://corem.gitbook.io/corem/crm-banking/exports.md).

# Exports

{% hint style="danger" %}
Prior experience as a developer or basic programming skills are recommended to effectively navigate this section of the documentation.
{% endhint %}

### Banking Exports

*<mark style="color:$info;">This module provides a set of exports to interact with the banking system. (server side only)</mark>*

You can use these exports from other resources with:

```lua
exports["crm-banking"]:functionName(args)
```

***

### 🔸getSocietyMoney

<mark style="color:$info;">Returns the current balance of a society account.</mark>

```lua
local crm_balance = exports["crm-banking"]:getSocietyMoney(crm_owner)
```

#### Parameters

* `crm_owner` *(string)* – The society/job name (e.g. `"police"`).

#### Returns

* *(number| nil)* – The current balance, or `nil` if the account doesn’t exist.

#### Example

```lua
local crm_balance = exports["crm-banking"]:getSocietyMoney("police")
print("Police Department - Bank Balance: "..tostring(crm_balance))
```

### 🔸setSocietyMoney

<mark style="color:$info;">Sets the exact balance of a society account.</mark>

```lua
exports["crm-banking"]:setSocietyMoney(crm_owner, crm_amount)
```

#### Parameters

* `crm_owner` *(string)* – The society/job name.
* `crm_amount` *(number)* – The new balance to set.

#### Returns

* *(*&#x62;oolea&#x6E;*)* –  `true` if updated successfully, `false` otherwise.

#### Example

```lua
if exports["crm-banking"]:setSocietyMoney("police", 20000) then
    print("Police Department - Balance set to $20000")
end
```

***

### 🔸addSocietyMoney

Adds a specific amount to a society’s balance.

```lua
exports["crm-banking"]:addSocietyMoney(crm_owner, crm_amount)
```

**Parameters**

* `crm_owner` *(string)* – The society/job name.
* `crm_amount` *(number)* – The amount to add.

**Returns**

* *(boolean)* – `true` if successful, `false` otherwise.

**Example**

```lua
exports["crm-banking"]:addSocietyMoney("mechanic", 1500)
```

***

### 🔸removeSocietyMoney

Removes a specific amount from a society’s balance.

```lua
exports["crm-banking"]:removeSocietyMoney(crm_owner, crm_amount)
```

**Parameters**

* `crm_owner` *(string)* – The society/job name.
* `crm_amount` *(number)* – The amount to remove (must be greater than 0).

**Returns**

* *(boolean)* – `true` if successful, `false` otherwise.

**Example**

```lua
exports["crm-banking"]:removeSocietyMoney("ambulance", 1000)
```

***

### 🔸createSocietyAccount

Creates a new society account.

```lua
exports["crm-banking"]:createSocietyAccount(crm_owner, crm_label, crm_budget)
```

**Parameters**

* `crm_owner` *(string)* – The society/job name.
* `crm_label` *(string, optional)* – The display label of the account.
* `crm_budget` *(number, optional)* – The starting balance (default = 0).

**Example**

```lua
exports["crm-banking"]:createSocietyAccount("police", "LSPD Treasury", 10000)
```

***

### 🔸getSocietyAccount

Returns the full account data of a society account.

```lua
local crm_account = exports["crm-banking"]:getSocietyAccount(crm_owner)
```

**Parameters**

* `crm_owner` *(string)* – The society/job name.

**Returns**

* *(table | nil)* – Account data table or `nil` if not found.

**Example**

```lua
local crm_account = exports["crm-banking"]:getSocietyAccount("mechanic")
if crm_account then
    print("Balance:", crm_account.crm_balance)
end
```

***

### 🔸getSocietyIban

Returns the IBAN of a society account.

```lua
local crm_iban = exports["crm-banking"]:getSocietyIban(crm_owner)
```

**Parameters**

* `crm_owner` *(string)* – The society/job name.

**Returns**

* *(string | nil)* – The IBAN, or `nil` if the account doesn’t exist.

**Example**

```lua
local crm_iban = exports["crm-banking"]:getSocietyIban("police")
print("Police IBAN:", crm_iban)
```

***

### 🔸addSocietyTransaction

Creates a transaction entry for a society account.

```lua
exports["crm-banking"]:addSocietyTransaction(crm_owner, crm_amount, crm_type, crm_description, crm_by)
```

**Parameters**

* `crm_owner` *(string)* – The society/job name.
* `crm_amount` *(number)* – The transaction amount.
* `crm_type` *(string)* – The transaction type (e.g. `"crm-deposit"`, `"crm-withdraw"`).
* `crm_description` *(string)* – A short reason for the transaction.
* `crm_by` *(number, optional)* – Player server ID (source) who made the transaction. Optional, can be left `nil`

**Returns**

* *(boolean)* – `true` if logged successfully, `false` otherwise.

**Example**

```lua
exports["crm-banking"]:addSocietyTransaction("police", 1000, "deposit", "Fine collected", source)
```

***

### 🔸getAccountByIban

Returns the full account table for a given IBAN.

```lua
exports["crm-banking"]:getAccountByIban(crm_iban)
```

**Parameters**

* `crm_iban`*(string)* – The IBAN of the account you want to retrieve.

**Returns**

* *(*&#x74;able | ni&#x6C;*)* – The account table if found, otherwise `nil`.

**Example**

```lua
local crm_account = exports["crm-banking"]:getAccountByIban("USA18SO410707070500")
if crm_account then
    print(crm_account.crm_owner)
    print(crm_account.crm_type)
end
```

***

### 🔸getPlayerAccounts

Returns all banking accounts owned by a specific player.

```lua
exports["crm-banking"]:getPlayerAccounts(crm_owner)
```

**Parameters**

* `crm_owner` *(string)* – The owner identifier (character identifier).

**Returns**

* (table) – A table (array) of all matching account rows. Will return an **empty table** if the owner has no accounts.

**Example**

```lua
local crm_accounts = exports["crm-banking"]:getPlayerAccounts("Z4VNKWZ5")
for _, crm_account in ipairs(crm_accounts ) do
    if crm_account.crm_type == "crm-saving" then
        print(crm_account.crm_balance)
    end
end
```

***

### 🔸deletePlayerAccounts

Deletes all accounts belonging to a specific owner.

```lua
exports["crm-banking"]:deletePlayerAccounts(crm_owner, crm_source)
```

**Parameters**

* `crm_owner` *(string)* – The owner whose accounts should be deleted.
* `crm_source`*(number* | ni&#x6C;**)** – *(Optional)* The source/player who triggered the deletion.\
  Used for logging purposes.

**Returns**

* *(boolean)* – `true` if the process executed, `false` if `crm_owner` was invalid.

**Example**

```lua
local crm_deleted = exports["crm-banking"]:deletePlayerAccounts("Z4VNKWZ5")
if crm_deleted then
    print("Accounts deleted.")
end
```

***

### 🔸addTransaction

Creates a transaction entry for any account.

```lua
exports["crm-banking"]:addTransaction(crm_data)
```

**Parameters**

* `crm_data` *(table)* – The transaction details.

**Example**

```lua
exports["crm-banking"]:addTransaction({
    crm_sender = "USA18SO410707070500",
    crm_receiver = "USA18SO420709993466",
    crm_amount = 1000,
    crm_type = 'crm-transfer',
    crm_description = 'Money transfer', -- optional
    crm_by = source, -- optional
})
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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://corem.gitbook.io/corem/crm-banking/exports.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.
