Início › Documentação › Exports · origen_billing
Todos os exports são registados com o nome de recurso origen_billing.
CreateInvoice(target, amount, description, jobName, author, notes?, company?) → boolean, string|numberCria uma fatura individual a partir de outro recurso.
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)| Parâmetro | Tipo | Descrição |
|---|---|---|
target |
string|number |
Citizenid ou source do servidor do destinatário |
amount |
number |
Valor da fatura (tem de ser > 0) |
description |
string |
Descrição curta apresentada na fatura |
jobName |
string |
Tem de corresponder a um job autorizado com canInvoice = true |
author |
string |
Citizenid do jogador que emite a fatura |
notes |
string|nil |
Notas internas opcionais |
company |
string|nil |
Substituição opcional da etiqueta de empresa apresentada |
CreateInvoiceWithItems(target, jobName, author, items, notes?, company?) → boolean, string|numberCria uma fatura com um carrinho de linhas individuais. O total é calculado automaticamente.
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
)| Parâmetro | Tipo | Descrição |
|---|---|---|
target |
string|number |
Citizenid ou source do servidor do destinatário |
jobName |
string |
Tem de corresponder a um job autorizado com canInvoice = true |
author |
string |
Citizenid do jogador que emite a fatura |
items |
table |
Array de { name, price, quantity, product_id? } |
notes |
string|nil |
Notas internas opcionais |
company |
string|nil |
Substituição opcional da etiqueta de empresa |
CreateBulkInvoice(targets, amount, description, jobName, author, notes?, company?) → tableCria a mesma fatura para vários destinatários de uma só vez.
local result = exports['origen_billing']:CreateBulkInvoice(
{ 'ABC12345', 'DEF67890' },
200,
'Event fee',
'police',
'XYZ99999'
)
-- result = { total, successful, failed, details = { { target, success, result }, ... } }| Campo devolvido | Tipo | Descrição |
|---|---|---|
total |
number |
Total de destinatários tentados |
successful |
number |
Número de faturas criadas com sucesso |
failed |
number |
Número de falhas |
details |
table |
Resultado por destinatário: { target, success, result } |
GetJobStatistics(jobName) → tableDevolve as estatísticas de faturação de um job.
local res = exports['origen_billing']:GetJobStatistics('police')
-- res = { success = true, data = { total, pending, paid, cancelled, totalRevenue, totalCommissions, averageAmount } }GetPlayerTotalDebt(target) → numberDevolve o valor total das faturas pendentes de um jogador. Devolve 0 se o jogador não tiver faturas pendentes ou não puder ser resolvido.
local debt = exports['origen_billing']:GetPlayerTotalDebt('ABC12345')
-- or by server source:
local debt = exports['origen_billing']:GetPlayerTotalDebt(source)GetPlayerPendingInvoices(target) → tableDevolve a lista de faturas pendentes de um jogador.
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) → booleanDevolve true se o jogador indicado estiver atualmente a trabalhar no job especificado e esse job estiver autorizado a emitir faturas.
local allowed = exports['origen_billing']:CanInvoice(source, 'ambulance')Estes exports destinam-se ao origen_police (ou a qualquer recurso de polícia) e seguem o modelo de faturação policial.
CreatePoliceInvoice(targetIdentifier, amount, description, jobName, author, contextData) → boolean, string|numberCria uma fatura policial. O campo contextData é uma string codificada em JSON com metadados específicos da polícia (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) → booleanAtualiza o valor e os metadados de uma fatura policial pendente.
exports['origen_billing']:UpdatePoliceInvoice(invoiceId, {
price = 2000,
description = 'Updated charges',
context_data = json.encode({ ... }),
})CancelPoliceInvoice(invoiceId) → booleanCancela uma fatura policial pendente. O recurso que a chama tem de verificar as permissões antes de invocar este export.
exports['origen_billing']:CancelPoliceInvoice(invoiceId)PayPoliceInvoice(source, invoiceId, paymentMethod) → boolean, stringPaga uma fatura policial. Delega em InvoiceManager, que trata de descontar o dinheiro e do depósito na sociedade.
local ok, reason = exports['origen_billing']:PayPoliceInvoice(source, invoiceId, 'bank')GetPoliceBillsByIdentifier(identifier, jobCategory?) → boolean, tableDevolve o histórico completo de faturas de um cidadão (todos os estados). Usado nos perfis de cidadão do tablet da polícia.
local ok, bills = exports['origen_billing']:GetPoliceBillsByIdentifier('ABC12345', 'police')GetPolicePendingByIdentifier(identifier) → boolean, tableDevolve apenas as faturas policiais pendentes de um cidadão. Usado pelos NPC de pagamento.
local ok, bills = exports['origen_billing']:GetPolicePendingByIdentifier('ABC12345')GetPoliceInvoicesByReportId(reportid) → boolean, tableDevolve todas as faturas policiais associadas a um ID de relatório específico.
local ok, bills = exports['origen_billing']:GetPoliceInvoicesByReportId(42)GetPoliceDebtorsByCategory(jobCategory) → boolean, tableDevolve uma lista de devedores com faturas policiais pendentes, agrupados por citizenid com a respetiva dívida total.
local ok, debtors = exports['origen_billing']:GetPoliceDebtorsByCategory('police')
-- debtors = { { citizenid, totalprice }, ... }