Double-Entry Accounting (ACID)
Every transaction credits one account and debits another with mathematical precision.
coe_economyACID Economic Engine & Ledger
Atomic Double-Entry Financial Transactions with Multi-Currency Support
coe_corecoe_databasecoe_audit
coe_economy
25 exports · 2 commands
Runs without a NUI: nothing is rendered on the client and the resource stays idle until events arrive.
The financial engine powering the entire COE Framework. Manages physical cash in pockets, checking accounts, savings, and interbank transfers. Every transaction strictly conforms to double-entry accounting principles, guaranteeing no currency is ever minted or lost without offsetting ledger entries.
Asynchronous mathematical execution in MariaDB utilizing atomic row-level locks on Node.js 24 LTS / Node 26 (libnode26), eliminating race conditions during simultaneous cash withdrawals.
Every transaction credits one account and debits another with mathematical precision.
Native support for Cash in Pockets, Bank Balances, and Escrowed Funds.
Atomic database row locks completely eliminate concurrent withdrawal exploits.
Built-in scheduler for municipal sales tax and savings interest disbursements.
Every COE Framework script strictly follows the principle of separation of concerns. Interact with the 3D stack below:
Operates strictly within layers L1–L3 (domain, HAL, and server-authoritative application logic). Visual interactions and management flows are delegated to centralized ecosystem apps (coe_ui / coe_tablet), guaranteeing 0.00 ms idle client overhead in FiveM DX12.
Manage your city without relying on developers. Runtime parameters, auditing, and ACE-protected commands:
IsPlayerAceAllowed(src, "coe.admin")
exports.coe_audit:Record(severity, category, event, context)
Clean Architecture & HAL
Typed contracts to call from other resources. Full types live in types.lua and in the docs reference.
exports['coe_economy']:IsReady()
→ boolean
Returns whether economy persistence is ready and caller is authorized.
No parameters.
local result = exports['coe_economy']:IsReady()exports['coe_economy']:Summary()
→ {
Returns total economy metrics (total accounts and aggregate balance). Requires `coe.economy.admin` ACE.
No parameters.
local result = exports['coe_economy']:Summary()exports['coe_economy']:GetBalance(characterId)
→ integer|nil, string|nil
Current balance of character (account is provisioned with `StartingBalance` on first access).
| Parameter | Type |
|---|---|
characterId | integer|string |
local ok, detail = exports['coe_economy']:GetBalance(characterId)exports['coe_economy']:GetFrozenBalance(characterId)
→ integer|nil, string|nil
Saldo bloqueado judicialmente na conta do personagem.
| Parameter | Type |
|---|---|
characterId | integer|string |
local ok, detail = exports['coe_economy']:GetFrozenBalance(characterId)exports['coe_economy']:FreezeFunds(characterId, amount, reason, reference)
→ true|nil, string|nil
Congela judicialmente parte do saldo da conta do personagem sem impedir o uso do saldo restante.
| Parameter | Type |
|---|---|
characterId | integer|string |
amount | integer |
reason | string |
reference | string|nil |
local ok, detail = exports['coe_economy']:FreezeFunds(characterId, amount, reason, reference)exports['coe_economy']:UnfreezeFunds(characterId, amount, reason, reference)
→ true|nil, string|nil
Desbloqueia saldo congelado judicialmente na conta do personagem.
| Parameter | Type |
|---|---|
characterId | integer|string |
amount | integer |
reason | string |
reference | string|nil |
local ok, detail = exports['coe_economy']:UnfreezeFunds(characterId, amount, reason, reference)exports['coe_economy']:Credit(characterId, amount, reason, reference)
→ true|nil, string|nil
Credits money to character account respecting `MaxBalance` ceiling. Audited (`money_credited`).
| Parameter | Type |
|---|---|
characterId | integer|string |
amount | integer |
reason | string |
reference | string|nil |
local ok, detail = exports['coe_economy']:Credit(characterId, amount, reason, reference)exports['coe_economy']:Debit(characterId, amount, reason, reference)
→ true|nil, string|nil
Debits money from character account; rejects if insufficient funds (strict atomic DB transaction). Audited (`money_debited`).
| Parameter | Type |
|---|---|
characterId | integer|string |
amount | integer |
reason | string |
reference | string|nil |
local ok, detail = exports['coe_economy']:Debit(characterId, amount, reason, reference)exports['coe_economy']:Transfer(fromId, toId, amount, reason, reference)
→ true|nil, string|nil
Transfers money between two characters in a single atomic transaction. Audited (`money_transferred`).
| Parameter | Type |
|---|---|
fromId | integer|string |
toId | integer|string |
amount | integer |
reason | string |
reference | string|nil |
local ok, detail = exports['coe_economy']:Transfer(fromId, toId, amount, reason, reference)exports['coe_economy']:Ledger(characterId, limit)
→ CoeEconomyLedgerRow[]|CoeEconomyError
Returns character transaction ledger, ordered newest first.
| Parameter | Type |
|---|---|
characterId | integer|string |
limit | integer|nil |
local result = exports['coe_economy']:Ledger(characterId, limit)exports['coe_economy']:LedgerStats(characterId, days, ignored)
→ {
Calculates ledger income and inflow metrics for the specified time window.
| Parameter | Type |
|---|---|
characterId | integer|string |
days | integer|nil |
ignored | string[]|nil |
local result = exports['coe_economy']:LedgerStats(characterId, days, ignored)exports['coe_economy']:SocietyBalance(businessId)
→ integer|CoeEconomyError
Returns the available balance of a society / business account.
| Parameter | Type |
|---|---|
businessId | string |
local result = exports['coe_economy']:SocietyBalance(businessId)exports['coe_economy']:SocietyLedger(businessId, limit)
→ table[]|CoeEconomyError
Returns transaction history for a society account.
| Parameter | Type |
|---|---|
businessId | string |
limit | integer|nil |
local result = exports['coe_economy']:SocietyLedger(businessId, limit)exports['coe_economy']:SocietyDeposit(businessId, characterId, amount)
→ true|CoeEconomyError
Deposits personal character funds into the society account. Restricted to business owner or staff (`not_staff`).
| Parameter | Type |
|---|---|
businessId | string |
characterId | integer|string |
amount | integer |
local result = exports['coe_economy']:SocietyDeposit(businessId, characterId, amount)exports['coe_economy']:SocietyWithdraw(businessId, characterId, amount)
→ true|CoeEconomyError
Withdraws society funds to character personal balance. Requires `business.funds` grade permission (owner has all).
| Parameter | Type |
|---|---|
businessId | string |
characterId | integer|string |
amount | integer |
local result = exports['coe_economy']:SocietyWithdraw(businessId, characterId, amount)exports['coe_economy']:SocietyCredit(businessId, amount, reason)
→ true|CoeEconomyError
Administrative deposit without character association. Requires `coe.economy.admin` ACE.
| Parameter | Type |
|---|---|
businessId | string |
amount | integer |
reason | string|nil |
local result = exports['coe_economy']:SocietyCredit(businessId, amount, reason)exports['coe_economy']:SocietyCollect(businessId, amount, reason)
→ true|CoeEconomyError
Revenue intake from customer payments (e.g. shop retail checkout). Requires `SocietyCollectors` or `coe.economy.society.collect` ACE.
| Parameter | Type |
|---|---|
businessId | string |
amount | integer |
reason | string |
local result = exports['coe_economy']:SocietyCollect(businessId, amount, reason)exports['coe_economy']:SocietyCharge(businessId, amount, reason, reference)
→ true|CoeEconomyError
Direct society business expense without character account (e.g. commercial rent). Requires `SocietyPayers` or `coe.economy.society.pay` ACE.
| Parameter | Type |
|---|---|
businessId | string |
amount | integer |
reason | string |
reference | string|nil |
local result = exports['coe_economy']:SocietyCharge(businessId, amount, reason, reference)exports['coe_economy']:BankSocietyPay(businessId, characterId, amount, reason, reference)
→ true|CoeEconomyError
Transfers money from society account to a character personal account.
| Parameter | Type |
|---|---|
businessId | string |
characterId | integer|string |
amount | integer |
reason | string |
reference | string|nil |
local result = exports['coe_economy']:BankSocietyPay(businessId, characterId, amount, reason, reference)exports['coe_economy']:BankSocietyDeposit(businessId, characterId, amount, reason, reference)
→ true|CoeEconomyError
Transfers money from a character personal account into the society account.
| Parameter | Type |
|---|---|
businessId | string |
characterId | integer|string |
amount | integer |
reason | string |
reference | string|nil |
local result = exports['coe_economy']:BankSocietyDeposit(businessId, characterId, amount, reason, reference)exports['coe_economy']:BankSocietyDebit(businessId, amount, reason, reference)
→ true|CoeEconomyError
Outflow from society account without destination character (cash withdrawal, corporate card expense).
| Parameter | Type |
|---|---|
businessId | string |
amount | integer |
reason | string |
reference | string|nil |
local result = exports['coe_economy']:BankSocietyDebit(businessId, amount, reason, reference)exports['coe_economy']:BankSocietyCredit(businessId, amount, reason, reference)
→ true|CoeEconomyError
Inflow into society account without origin character (cash deposit, reversal credit).
| Parameter | Type |
|---|---|
businessId | string |
amount | integer |
reason | string |
reference | string|nil |
local result = exports['coe_economy']:BankSocietyCredit(businessId, amount, reason, reference)exports['coe_economy']:BankSocietyTransfer(fromId, toId, amount, reason, reference)
→ true|CoeEconomyError
B2B corporate transfer between two business accounts.
| Parameter | Type |
|---|---|
fromId | string |
toId | string |
amount | integer |
reason | string |
reference | string|nil |
local result = exports['coe_economy']:BankSocietyTransfer(fromId, toId, amount, reason, reference)exports['coe_economy']:BankSocietyLedger(businessId, filter)
→ {
Filtered corporate transaction ledger with period aggregate totals.
| Parameter | Type |
|---|---|
businessId | string |
filter | { |
local result = exports['coe_economy']:BankSocietyLedger(businessId, filter)exports['coe_economy']:RunPayroll(businessId)
→ CoeEconomyPayrollSummary|CoeEconomyError
Pays grade salary to characters currently on duty from the society account; if funds are insufficient, skips without incurring debt. Requires `coe.economy.admin` ACE or banker role. Emits local event `coe_economy:payrollPaid`.
| Parameter | Type |
|---|---|
businessId | string |
local result = exports['coe_economy']:RunPayroll(businessId)/coe_economy_credit <stateId> <valor>
Administrative balance adjustment, recorded in the ledger. ACE command.coe_economy_credit.
/saldo
Shows the active character balance.