# 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.</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)
```
