# Banking

## Bank Account Model

```lua
-- Output:
--{
--    number = "BNK123456789", -- The unique bank account number
--    type = "", -- The type of account. personal or business
--    name = "", -- The name of the account, user defined
--    owner = "", -- The CSN of the account owner
--    is_primary = false, -- If the account is a primary account for a person
--    balance = 0, -- The balance of the account
--    access = {}, -- A list of additional users CSN's and the access types they have
--    max_overdraft = 0, -- The maximum amount of overdraft available for an account
--    is_frozen = false, -- If the account is frozen or not
--}
```

## AccountExists

This can be used to check if the an account exists.

```lua
-- number: The account number to check

-- Returns true or false

exports.banking:AccountExists(number)
```

## GetAccount

Returns the full [bank account model](#bank-account-model) of the number.

```lua
-- number: The account number to get

-- Returns the bank account model

exports.banking:GetAccount(number)
```

## CreateAccount

Used to forcibly create a bank account.

```lua
-- bankType: The type of bank to create (`personal` or `business`)
-- name: The name of the account
-- owner: The CSN for the owner of the bank
-- primary: Is this a primary account (cannot be deleted) (default: false if not provided)
-- balance: The starting balance for the account (default: 0 if not provided)

-- Returns the generated bank account number

exports.banking:CreateAccount(bankType, name, owner, primary, balance)
```

## BankDeposit

Deposit money into a bank account and generate a transaction for it.

```lua
-- number: The bank account to deposit into.
-- amount: The amount to deposit
-- reason: The transaction reason

-- Returns a boolean indicating success and an error message

exports.banking:BankDeposit(number, amount, reason)
```

## BankWithdraw

Withdraw money from a bank account and generate a transaction for it.

```lua
-- number: The bank account to deposit into.
-- amount: The amount to withdraw
-- reason: The transaction reason
-- bypassOverdraft: Optional boolean if the max_overdraft can be bypassed - used in instances such as police fines

-- Returns a boolean indicating success and an error message

exports.banking:BankWithdraw(number, amount, reason, bypassOverdraft)
```

## BankSet

Set's the balance for an account and generates a transaction for it.

```lua
-- number: The bank account to deposit into.
-- amount: The amount to set
-- reason: The transaction reason

-- Returns a boolean indicating success

exports.banking:BankSet(number, amount, reason)
```

## DeleteAccount

Deletes a bank account. By default it doesn't allow deleting an account with a negative balance however this can be disabled.

```lua
-- number: The account number to get
-- forceDeleteWithNegativeBalance: Should we bypass the negative balance check (default: false if not provided)

-- Returns true or false if the deletion was successful

exports.banking:DeleteAccount(number, forceDeleteWithNegativeBalance)
```


---

# 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.tmc.bj/v2/other-resources/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.
