OrigenNetwork
Docs

Exports · origen_billing

All exports are registered under the resource name origen_billing.


Server-side exports

CreateInvoice(target, amount, description, jobName, author, notes?, company?)boolean, string|number

Creates a single invoice from another resource.

lua
local ok, result = exports['origen_billing']:CreateInvoice(
    'ABC12345',   -- target citizenid (or server source as number)
    500,          -- amount
    'Medical fee',
    'ambulance',
    'XYZ99999',   -- author citizenid
    'Notes here', -- optional
    nil           -- optional company label override
)
-- ok = true, result = invoiceId (number)
-- ok = false, result = reason (string)
ParameterTypeDescription
targetstring|numberTarget citizenid or server source
amountnumberInvoice amount (must be > 0)
descriptionstringShort description shown on the invoice
jobNamestringMust match an authorized job with canInvoice = true
authorstringCitizenid of the player issuing the invoice
notesstring|nilOptional internal notes
companystring|nilOptional override for the company display label

CreateInvoiceWithItems(target, jobName, author, items, notes?, company?)boolean, string|number

Creates an invoice with a cart of individual line items. The total is calculated automatically.

lua
local ok, result = exports['origen_billing']:CreateInvoiceWithItems(
    'ABC12345',
    'mechanic',
    'XYZ99999',
    {
        { name = 'Oil change', price = 150, quantity = 1 },
        { name = 'Tire rotation', price = 80, quantity = 4, product_id = 12 },
    },
    nil, -- notes
    nil  -- company override
)
ParameterTypeDescription
targetstring|numberTarget citizenid or server source
jobNamestringMust match an authorized job with canInvoice = true
authorstringCitizenid of the issuing player
itemstableArray of { name, price, quantity, product_id? }
notesstring|nilOptional internal notes
companystring|nilOptional company label override

CreateBulkInvoice(targets, amount, description, jobName, author, notes?, company?)table

Creates the same invoice for multiple targets at once.

lua
local result = exports['origen_billing']:CreateBulkInvoice(
    { 'ABC12345', 'DEF67890' },
    200,
    'Event fee',
    'police',
    'XYZ99999'
)
-- result = { total, successful, failed, details = { { target, success, result }, ... } }
Return fieldTypeDescription
totalnumberTotal targets attempted
successfulnumberNumber of invoices created successfully
failednumberNumber of failures
detailstablePer-target result: { target, success, result }

GetJobStatistics(jobName)table

Returns billing statistics for a job.

lua
local res = exports['origen_billing']:GetJobStatistics('police')
-- res = { success = true, data = { total, pending, paid, cancelled, totalRevenue, totalCommissions, averageAmount } }

GetPlayerTotalDebt(target)number

Returns the total pending invoice amount for a player. Returns 0 if the player has no pending invoices or cannot be resolved.

lua
local debt = exports['origen_billing']:GetPlayerTotalDebt('ABC12345')
-- or by server source:
local debt = exports['origen_billing']:GetPlayerTotalDebt(source)

GetPlayerPendingInvoices(target)table

Returns the list of pending invoices for a player.

lua
local invoices = exports['origen_billing']:GetPlayerPendingInvoices('ABC12345')
-- Array of { id, job_name, company_label, amount, description, notes, context_data, status, created_at }

CanInvoice(source, jobName)boolean

Returns true if the given player is currently working the specified job and that job is authorized to issue invoices.

lua
local allowed = exports['origen_billing']:CanInvoice(source, 'ambulance')

Police integration exports

These exports are intended for origen_police (or any police resource) and follow the police billing model.

CreatePoliceInvoice(targetIdentifier, amount, description, jobName, author, contextData)boolean, string|number

Creates a police invoice. The contextData field is a JSON-encoded string containing police-specific metadata (reportid, months, concepts, title, etc.).

lua
local ok, result = exports['origen_billing']:CreatePoliceInvoice(
    'ABC12345',
    1500,
    'Traffic violation | Speeding',
    'police',
    'Officer Smith',
    json.encode({
        title    = 'Traffic Fines',
        reportid = 42,
        months   = 0,
        concepts = {
            { name = 'Speeding', price = 1000 },
            { name = 'No license', price = 500 },
        },
    })
)

UpdatePoliceInvoice(invoiceId, data)boolean

Updates the amount and metadata of a pending police invoice.

lua
exports['origen_billing']:UpdatePoliceInvoice(invoiceId, {
    price        = 2000,
    description  = 'Updated charges',
    context_data = json.encode({ ... }),
})

CancelPoliceInvoice(invoiceId)boolean

Cancels a pending police invoice. Permission checks must be performed by the calling resource before invoking this export.

lua
exports['origen_billing']:CancelPoliceInvoice(invoiceId)

PayPoliceInvoice(source, invoiceId, paymentMethod)boolean, string

Pays a police invoice. Delegates to InvoiceManager — handles money deduction and society deposit.

lua
local ok, reason = exports['origen_billing']:PayPoliceInvoice(source, invoiceId, 'bank')

GetPoliceBillsByIdentifier(identifier, jobCategory?)boolean, table

Returns the full invoice history for a citizen (all statuses). Used in police tablet citizen profiles.

lua
local ok, bills = exports['origen_billing']:GetPoliceBillsByIdentifier('ABC12345', 'police')

GetPolicePendingByIdentifier(identifier)boolean, table

Returns only pending police invoices for a citizen. Used by payment NPCs.

lua
local ok, bills = exports['origen_billing']:GetPolicePendingByIdentifier('ABC12345')

GetPoliceInvoicesByReportId(reportid)boolean, table

Returns all police invoices linked to a specific report ID.

lua
local ok, bills = exports['origen_billing']:GetPoliceInvoicesByReportId(42)

GetPoliceDebtorsByCategory(jobCategory)boolean, table

Returns a list of debtors with pending police invoices, grouped by citizenid with their total debt.

lua
local ok, debtors = exports['origen_billing']:GetPoliceDebtorsByCategory('police')
-- debtors = { { citizenid, totalprice }, ... }