OrigenNetwork
Docs

LB Phone App · origen_billing

origen_billingapp is the companion LB Phone application for origen_billing. It provides a full billing experience directly inside the phone — no commands required.


Dependencies

ResourceNotes
lb-phoneRequired. The app registers itself via exports['lb-phone']:AddCustomApp
origen_billingRequired. All business logic is delegated to its phone exports
ox_libRequired. Locale utilities

Installation

1. server.cfg

Add origen_billingapp after origen_billing and lb-phone:

cfg
ensure lb-phone
ensure origen_billing
ensure origen_billingapp

2. Language

Open config.lua and set the language. It must match a file in locales/:

lua
Config.Language = 'en'  -- 'en' | 'es'

No SQL is required. origen_billingapp does not create any tables — all data is stored and managed by origen_billing.


How it works

The app registers itself in LB Phone on resource start and automatically re-registers if lb-phone restarts. The UI communicates exclusively through NUI callbacks → server events → origen_billing phone exports → client event response back to the phone UI.

text
UI (NUI)
  └─▶ NUI Callback (client.lua)
        └─▶ Server Event (origen_billingapp:server:*)
              └─▶ origen_billing Phone Export
                    └─▶ TriggerClientEvent → origen_billingapp:client:response
                          └─▶ exports['lb-phone']:SendCustomAppMessage

No business logic lives in origen_billingapp. It is a pure bridge.


Features by role

All players — My Invoices

  • View all pending invoices (bank + cash payment)
  • Pay an invoice directly from the phone
  • Receive a push notification when a new invoice arrives

Employees (authorized jobs)

  • Browse the product catalog for their job
  • Send a new invoice to a nearby player (manual amount or from catalog)

Bosses

  • Paginated company invoice list with search and filters (status, amount range, date range)
  • Cancel any company invoice
  • Company statistics (total, pending, paid, cancelled, revenue, commissions, average)
  • Dashboard with KPIs and a daily time series chart for a custom date range
  • Full product management: create, edit, toggle active/inactive, delete

Phone exports (origen_billing)

The app uses the following exports registered on origen_billing. These can also be called from other resources.

GetPhoneAppBootstrap(source)table

Loads all data needed to open the app in a single call. Returns permissions, pending invoices, catalog products, and — for bosses — company invoices, stats, and products.

lua
local data = exports['origen_billing']:GetPhoneAppBootstrap(source)
-- {
--   success         = true,
--   permissions     = { canInvoice, isBoss, jobName, jobLabel },
--   myInvoices      = { ... },
--   catalogProducts = { ... },
--   companyInvoices = { ... },  -- nil if not boss
--   companyMeta     = { page, pageSize, total, totalPages },
--   companyStats    = { ... },
--   companyProducts = { ... },
-- }

GetPhonePermissions(source)table

Returns the current permissions for the player. Called when the player's job changes.

lua
local res = exports['origen_billing']:GetPhonePermissions(source)
-- { success = true, permissions = { canInvoice, isBoss, jobName, jobLabel } }

GetPhoneMyInvoices(source)table

Returns the player's pending invoices.

lua
local res = exports['origen_billing']:GetPhoneMyInvoices(source)
-- { success = true, invoices = { ... } }

PayPhoneInvoice(source, invoiceId, paymentMethod)table

Pays an invoice. paymentMethod is 'bank' or 'cash'.

lua
local res = exports['origen_billing']:PayPhoneInvoice(source, 12, 'bank')
-- { success = true|false, reason = 'error_code' }

GetPhoneProducts(source)table

Returns the active product catalog for the player's job.

lua
local res = exports['origen_billing']:GetPhoneProducts(source)
-- { success = true, products = { { id, name, description, price }, ... } }

SendPhoneInvoice(source, payload)table

Creates an invoice from the phone. payload.items is optional — if omitted, a single-line invoice is created from payload.amount and payload.description.

lua
local res = exports['origen_billing']:SendPhoneInvoice(source, {
    targetId    = 'ABC12345',
    amount      = 500,
    description = 'Service fee',
    notes       = '',
    items       = {
        { name = 'Oil change', price = 150, quantity = 1, product_id = 5 },
    },
})
-- { success = true, invoiceId = 42 }

GetPhoneCompanyInvoicesPage(source, filters)table

Returns a paginated and filtered list of company invoices. Boss only.

lua
local res = exports['origen_billing']:GetPhoneCompanyInvoicesPage(source, {
    search    = 'John',
    status    = 'pending',  -- 'all' | 'pending' | 'paid' | 'cancelled'
    minAmount = 100,
    maxAmount = 1000,
    dateFrom  = '2025-01-01',
    dateTo    = '2025-12-31',
    page      = 1,
    pageSize  = 10,
})
-- { success, invoices, meta = { page, pageSize, total, totalPages }, stats = { ... } }

GetPhoneCompanyStats(source)table

Returns global statistics for the player's company. Boss only.

lua
local res = exports['origen_billing']:GetPhoneCompanyStats(source)
-- { success, stats = { total, pending, paid, cancelled, totalSociety, totalCommissions, avgAmount } }

GetPhoneCompanyDashboardLite(source, dateFrom, dateTo)table

Returns KPIs and a daily time series for a date range. Boss only.

lua
local res = exports['origen_billing']:GetPhoneCompanyDashboardLite(source, '2025-01-01', '2025-01-31')
-- {
--   success    = true,
--   kpis       = { total, pending, paid, cancelled, totalRevenue, totalSociety, totalCommissions, avgAmount },
--   timeSeries = { { day, totalAmount, paidAmount }, ... },
-- }

CancelPhoneCompanyInvoice(source, invoiceId)table

Cancels a company invoice. Caller must be a boss of the job that issued it.

lua
local res = exports['origen_billing']:CancelPhoneCompanyInvoice(source, 42)
-- { success = true|false, reason = 'error_code' }

GetPhoneCompanyProducts(source)table

Returns all products for the player's company (including inactive ones). Boss only.

lua
local res = exports['origen_billing']:GetPhoneCompanyProducts(source)
-- { success, products = { { id, name, description, price, active, created_at }, ... } }

CreatePhoneCompanyProduct(source, data)table

Creates a new product for the company. Boss only.

lua
local res = exports['origen_billing']:CreatePhoneCompanyProduct(source, {
    name        = 'Oil change',
    description = 'Full synthetic',
    price       = 150,
})
-- { success = true, productId = 7 }

UpdatePhoneCompanyProduct(source, data)table

Updates an existing product. Boss only.

lua
local res = exports['origen_billing']:UpdatePhoneCompanyProduct(source, {
    id          = 7,
    name        = 'Oil change (premium)',
    description = 'Full synthetic + filter',
    price       = 200,
})
-- { success = true|false }

TogglePhoneCompanyProduct(source, productId)table

Toggles a product between active and inactive. Boss only.

lua
local res = exports['origen_billing']:TogglePhoneCompanyProduct(source, 7)
-- { success = true, active = false }

DeletePhoneCompanyProduct(source, productId)table

Permanently deletes a product. Boss only.

lua
local res = exports['origen_billing']:DeletePhoneCompanyProduct(source, 7)
-- { success = true|false }