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.
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)| Parameter | Type | Description |
|---|---|---|
target | string|number | Target citizenid or server source |
amount | number | Invoice amount (must be > 0) |
description | string | Short description shown on the invoice |
jobName | string | Must match an authorized job with canInvoice = true |
author | string | Citizenid of the player issuing the invoice |
notes | string|nil | Optional internal notes |
company | string|nil | Optional 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.
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
)| Parameter | Type | Description |
|---|---|---|
target | string|number | Target citizenid or server source |
jobName | string | Must match an authorized job with canInvoice = true |
author | string | Citizenid of the issuing player |
items | table | Array of { name, price, quantity, product_id? } |
notes | string|nil | Optional internal notes |
company | string|nil | Optional company label override |
CreateBulkInvoice(targets, amount, description, jobName, author, notes?, company?) → table
Creates the same invoice for multiple targets at once.
local result = exports['origen_billing']:CreateBulkInvoice(
{ 'ABC12345', 'DEF67890' },
200,
'Event fee',
'police',
'XYZ99999'
)
-- result = { total, successful, failed, details = { { target, success, result }, ... } }| Return field | Type | Description |
|---|---|---|
total | number | Total targets attempted |
successful | number | Number of invoices created successfully |
failed | number | Number of failures |
details | table | Per-target result: { target, success, result } |
GetJobStatistics(jobName) → table
Returns billing statistics for a job.
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.
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.
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.
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.).
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.
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.
exports['origen_billing']:CancelPoliceInvoice(invoiceId)PayPoliceInvoice(source, invoiceId, paymentMethod) → boolean, string
Pays a police invoice. Delegates to InvoiceManager — handles money deduction and society deposit.
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.
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.
local ok, bills = exports['origen_billing']:GetPolicePendingByIdentifier('ABC12345')GetPoliceInvoicesByReportId(reportid) → boolean, table
Returns all police invoices linked to a specific report ID.
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.
local ok, debtors = exports['origen_billing']:GetPoliceDebtorsByCategory('police')
-- debtors = { { citizenid, totalprice }, ... }