Home › Documentation › Exports · origen_banking
All exports are registered under the resource name origen_banking and are server-side only.
Most account exports return a structured envelope instead of a raw boolean:
-- success
{ success = true, data = { ... }, meta = { message = { key = '...', args = { ... } } } }
-- failure
{ success = false, error = { key = 'errors.insufficient_balance', args = { ... } } }The key field is a locale key from locales/*.json, so the calling resource can translate the message itself.
The job account exports in the compatibility layer use a simpler envelope: { success = true, data = { balance = number } } or { success = false, error = 'insufficient_balance' } where error is a plain string.
getJobAccountBalance(jobName) → number, string|nilReturns the current balance of a job account. Read-only — it never creates the account.
local balance, err = exports['origen_banking']:getJobAccountBalance('mechanic')| Parameter | Type | Description |
|---|---|---|
jobName | string | Exact owner name stored in the database, e.g. 'ambulance' |
Returns 0 and an error reason ('invalid_job_name' or 'account_not_found') when the account does not exist.
depositJobAccount(jobName, amount, detail) → tableAdds money to a job account. Creates the account automatically when it does not exist yet.
local res = exports['origen_banking']:depositJobAccount('mechanic', 2500, 'Repair job')
if res.success then print(res.data.balance) end| Parameter | Type | Description |
|---|---|---|
jobName | string | Job / society name |
amount | number | Positive integer |
detail | string | Optional audit label shown in the transaction history |
Errors: invalid_amount, invalid_job_name.
withdrawJobAccount(jobName, amount, detail) → tableRemoves money from a job account. Never auto-creates the account.
local res = exports['origen_banking']:withdrawJobAccount('mechanic', 500, 'Parts purchase')Errors: invalid_amount, account_not_found, insufficient_balance.
getAccountMoney(accountName) → numberLegacy alias of getJobAccountBalance. Returns only the balance, or 0.
addAccountMoney(accountName, amount) → booleanLegacy deposit. Auto-creates the account. Registers the transaction as Society income.
removeAccountMoney(accountName, amount) → booleanLegacy withdrawal. Returns false when the account does not exist or the balance is insufficient.
newAccount(data) → AccountCreates an account object. When data.id is omitted a new IBAN is generated and the account is persisted immediately.
| Field | Type | Description |
|---|---|---|
owner | string | Citizen ID, job name or gang name |
name | string | Display name |
balance | number | Initial balance. Default 0 |
default | boolean | Marks it as the player's primary account |
shared | boolean | Marks it as a shared job / gang account |
bank | string | Optional bank ID the account belongs to |
GetAccountById(id) → Account | nilReturns the account from the in-memory cache, falling back to a database lookup.
local account = exports['origen_banking']:GetAccountById('1234567890123456')GetAccountAccessByCitizenid(citizenid) → tableReturns the raw access list for a citizen: an array of { accountId, permission }. Permission is 'owner', 'manager' or 'operator'.
GetAccountsInfoByCitizenId(citizenid) → tableReturns the full account list for a citizen, enriched for UI use: members, account type ('personal' / 'shared'), the framework primary flag and live balance. Job and gang accounts the player currently has access to are injected at runtime.
This export resolves job and gang access on every call and can create the shared account if it does not exist yet. Do not call it in a loop.
CreateInitialAccount(citizenid) → stringCreates the primary account for a citizen and returns the generated account ID.
LoadAccountsForPlayer(citizenid)Preloads every account owned by, or shared with, a citizen into memory. Accounts are lazy-loaded on player connect, so this is only needed for offline operations.
"Active account" is the account currently selected in the player's activeAccount metadata. "Default account" is the one flagged as default in the database.
GetActiveAccBalance(source) → number | nilReturns the balance of the player's active account. Cached for 500 ms.
PayWithAccId(accountId, amount, detail) → tableCharges a specific account by ID.
| Parameter | Type | Description |
|---|---|---|
accountId | string | Target account IBAN |
amount | number | Amount to charge |
detail | string | Reason shown in the transaction history |
Errors: errors.account_not_found, errors.insufficient_balance.
PayWithActiveAcc(source, amount, detail) → tableCharges the player's currently active account.
local res = exports['origen_banking']:PayWithActiveAcc(source, 150, 'Parking fee')
if not res.success then print(res.error.key) endPayFromDefaultAcc(source, amount, detail) → tableCharges the player's default account. When that account is the framework primary, the balance is debited from framework bank money instead of the database.
ReceiveToActiveAcc(source, amount, detail) → tableCredits the player's active account.
ReceiveToDefaultAcc(source, amount, detail) → tableCredits the player's default account. Framework primary accounts are credited directly to framework bank money.
SetActiveAccBalance(source, amount) → booleanOverwrites the balance of the player's active account. No transaction is registered.
SetDefaultAccBalance(source, amount) → booleanOverwrites the balance of the player's default account. When it is the framework primary, the difference is applied to framework bank money.
Both setters bypass transaction history and permission checks. Use them only for admin or migration tooling.
CreateLoan(accountId, typeKey, amount, term, collateral) → tableCreates a loan against an account, applying every server-side validation.
| Parameter | Type | Description |
|---|---|---|
accountId | string | Account that receives the disbursement |
typeKey | string | Loan type key from Config.Loans.Types, e.g. 'personal' |
amount | number | Principal |
term | number | Number of installments, must be in allowedTerms |
collateral | string | Asset reference. Required when the type sets requiresCollateral |
local res = exports['origen_banking']:CreateLoan(accountId, 'personal', 15000, 12)
if res.success then print(res.loanId) endErrors: disabled, account_not_found, invalid_type, invalid_term.
GetPlayerLoans(citizenId) → tableReturns every loan belonging to a citizen, shaped as the UI receives them.
HasOverdueLoan(citizenId) → booleanReturns true when the citizen has an overdue or defaulted loan. Useful to gate credit-based purchases in dealerships, rentals and similar resources.
if exports['origen_banking']:HasOverdueLoan(citizenid) then
-- deny the financed purchase
endnewBank(data) → BankCreates a bank entity.
GetBankById(id) → Bank | nilReturns a bank from cache or database.
newCard(data) → CardCreates a card bound to an account.
GetCardById(id) → Card | nilReturns a card from cache or database.