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

# EXPORTS

Resource name: **`shr-banksystem`**

## Client exports

### OpenBank

Opens the bank UI at a branch (full features) or ATM (limited features).

```lua
exports['shr-banksystem']:OpenBank('bank')  -- branch
exports['shr-banksystem']:OpenBank('atm')   -- ATM
```

### CloseBank

Closes the UI and clears NUI focus.

```lua
exports['shr-banksystem']:CloseBank()
```

## Server export

### addTransaction

Log a custom transaction and update spending analytics for the player.

```lua
exports['shr-banksystem']:addTransaction(
    source,           -- player server id
    txType,           -- e.g. 'deposit', 'withdraw', 'fee'
    category,         -- e.g. 'deposit', 'withdraw', 'bill', 'loan', 'saving', 'society'
    amount,           -- number
    counterparty,     -- string or nil (shown as sub-label in history)
    description       -- string or locale key (e.g. 'tx_desc_deposit')
)
```

**Example — charge a custom bank fee:**

```lua
exports['shr-banksystem']:addTransaction(source, 'fee', 'fee', 250, nil, 'tx_desc_pin_restore')
```

Use keys from `locales/en.lua` / `locales/cs.lua` for `description` so history respects `Config.Locale`.

## Client events

```lua
TriggerEvent('shr-banksystem:openBank')
TriggerEvent('shr-banksystem:openATM')
```

## Server callbacks (internal)

Used by the NUI layer. You normally do not call these directly, but they are useful for custom integrations:

| Callback                                           | Purpose                                                   |
| -------------------------------------------------- | --------------------------------------------------------- |
| `shr-banksystem:canOpen`                           | Open bank/ATM                                             |
| `shr-banksystem:deposit` / `withdraw` / `transfer` | Money operations                                          |
| `shr-banksystem:takeLoan`                          | Take loan by product id                                   |
| `shr-banksystem:payLoan`                           | Pay loan (`amount`: number, `'installment'`, or `'full'`) |
| `shr-banksystem:createSaving`                      | Open savings                                              |
| `shr-banksystem:withdrawSaving`                    | Withdraw matured savings                                  |
| `shr-banksystem:getTransactions`                   | Transaction history                                       |
| `shr-banksystem:getSpending`                       | Spending analytics                                        |
| `shr-banksystem:getSocietyData`                    | Society dashboard                                         |

## Hooks (open files)

### Client — `open/client.lua`

| Function                            | Description                                                      |
| ----------------------------------- | ---------------------------------------------------------------- |
| `Open.Client.BeforeOpen(mode)`      | Return `false` to cancel opening (`mode` is `'bank'` or `'atm'`) |
| `Open.Client.AfterClose()`          | Called after UI closes                                           |
| `Open.Client.Notify(message, type)` | Return `true` if you handle notifications                        |

### Server — `open/server.lua`

| Function                                                | Description                               |
| ------------------------------------------------------- | ----------------------------------------- |
| `Open.Server.BeforeTransaction(source, action, amount)` | Return `false` to block an operation      |
| `Open.Server.GetAvatarUrl(source)`                      | Return a custom avatar URL string         |
| `Open.Server.Notify(source, message, type)`             | Return `true` if you handle notifications |

**`action` values:** `deposit`, `withdraw`, `transfer`, `paybill`, `loan`, `saving`, `society`

**Example — block withdrawals for a job:**

```lua
function Open.Server.BeforeTransaction(source, action, amount)
    local xPlayer = ESX.GetPlayerFromId(source)
    if action == 'withdraw' and xPlayer.job.name == 'police' then
        return false
    end
    return true
end
```

## NUI callbacks (reference)

Registered in `client/nui.lua` for the built-in UI. Custom frontends can use the same names via `RegisterNUICallback` pattern:

`deposit`, `withdraw`, `transfer`, `payLoan`, `takeLoan`, `createSaving`, `withdrawSaving`, `getTransactions`, `getSpending`, `getBills`, `payBill`, `getSocietyData`, `setPin`, `deleteCard`, `restorePin`, `close`

`payLoan` accepts `{ amount: number | 'installment' | 'full' }`.
