Server exports
Invoices
Server exports that create, list and delete invoices in the Invoices app.
How invoices and job splits work is described in Bank, invoices and crypto. The cylex_phone forms addBill, addBilling, addSystemBill and deleteBill are also registered, with their own argument shapes: see cylex_phone compatibility.
#AddInvoice
Sends an invoice to a character. It appears in their Invoices app, where they can pay it.
lua---@class InvoiceData
---@field receiver string a character identifier or a phone number
---@field amount integer 1 or more
---@field description? string
---@field sender string|{ label?: string, job?: string, identifier?: string } a name such as 'City Hall', or a table
---@param data InvoiceData
---@return integer|nil id
exports['fx-phone']:AddInvoice(data)
lualocal id = exports['fx-phone']:AddInvoice({
receiver = citizenid, amount = 1500, description = 'Engine repair', sender = { job = 'mechanic', identifier = employeeCitizenid },
})
- With a
joblisted inConfig.Invoices.Jobs, the payment is split between the company and the employee as configured there, and the job's label is used whenlabelis left out. - Returns
nilwhendatais not a table, the receiver is unknown or the amount is below 1.
#GetInvoices
Returns the invoices a character received, newest first.
Also available as: getBills
lua---@param identifier string
---@param onlyUnpaid? boolean
---@return table[] invoices up to 100 rows
exports['fx-phone']:GetInvoices(identifier, onlyUnpaid)
lualocal unpaid = exports['fx-phone']:GetInvoices(citizenid, true)
- Each row:
{ id, sender = { label, job }, receiver = { name }, amount, description, status, createdAt, paidAt }.statusis'unpaid','paid'or'cancelled'.
#DeleteInvoice
Deletes an invoice.
lua---@param id integer
---@return boolean deleted
exports['fx-phone']:DeleteInvoice(id)
luaexports['fx-phone']:DeleteInvoice(id)