A core script for managing personal and business bank accounts. These are all server-side exports to manage accounts.
Bank Account Model
-- 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.
-- number: The account number to check
-- Returns true or false
exports.banking:AccountExists(number)
-- number: The account number to get
-- Returns the bank account model
exports.banking:GetAccount(number)
CreateAccount
Used to forcibly create a bank account.
-- 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.
-- 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.
-- 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:BankDeposit(number, amount, reason, bypassOverdraft)
BankSet
Set's the balance for an account and generates a transaction for it.
-- 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.
-- 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)