> For the complete documentation index, see [llms.txt](https://tgiann.gitbook.io/tgiann/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://tgiann.gitbook.io/tgiann/scripts/tgiann-phone/billing.md). Agents can also search and read this documentation through its [MCP server](https://tgiann.gitbook.io/tgiann/~gitbook/mcp).

# Billing

The Billing app lets players send and pay invoices. It has three main tabs (Summary, Invoices, New) and a Business tab for players who run a job or a business. Every change reaches the phones involved right away and comes with a phone notification. Players who are offline get the notification on the number the invoice was sent to.

Most Billing settings are managed in game: admins open the panel with `/phoneadmin` and pick the Billing module. Changes save to `data/billing.json` and apply right away, no restart needed. The few settings that stay in files are in [configBilling.lua](https://tgiann.gitbook.io/tgiann/scripts/tgiann-phone/configs/apps/configbilling.lua.md).

## Who can bill

A player can send an invoice in several names. The "Send as" picker only shows the ones they are allowed to use.

* **Personal**: the player bills in their own name. This works while personal invoices are on in the admin panel. The admin can also make the receiver accept a personal invoice before it can be paid.
* **Trusted citizens**: characters added to this list can always bill in their own name, even when personal invoices are off. Each one can skip receiver approval and have its own VAT rate.
* **Jobs**: every employee of a listed job can bill in the job name and the money goes to the job account. Each job can have a name shown on invoices, its own VAT rate, its own overdue rule and a "Receiver accepts first" option. With "Job bosses can always bill" on, the boss of any job can bill in its name even when the job is not on the list.
* **Businesses**: player owned businesses from tgiann-core. A rule can be an exact key name, a prefix such as `food_job_*`, or `@resource` for every business of one script. Owners always can bill. Employees can bill once the owner allows it in the Business tab. The money goes to the business account.

The admin panel (`/phoneadmin` > Billing) has these sections:

* Personal invoices
* Trusted citizens
* Jobs
* Businesses
* Tax and commission
* Due dates and collection
* Disputes
* City and taxes (with the treasury card)
* Logo requests

## Creating an invoice

New invoices are made in a 4-step wizard: **Recipient**, **Items**, **Details**, **Review**.

1. **Recipient**: pick a nearby player (within `nearbyDistance` meters), a contact, or type a phone number.
2. **Items**: add up to `maxItems` line items with a label, price and quantity (up to `maxQuantity`). Items can be typed by hand, picked from the business price list, or picked from the player's own inventory under "My items". Packets from tgiann-food-jobs show their contents with the menu prices.
3. **Details**: due date, installments, a note, photos (up to `maxPhotos`, from the gallery or camera) and "Require a signature".
4. **Review**: the subtotal, VAT and the issuer's commission are shown before sending.

A few limits apply:

* The total with VAT can't be more than `maxAmount`.
* A player can't bill themselves.
* A player waits `createCooldown` seconds between two invoices.
* When a business uses "Only from the list", its staff can only bill items from the price list.

When a signature is required, the receiver draws it on the phone before accepting or paying. Signatures can be turned off for everyone in the admin panel.

## Payment terms

Admins set these under **Due dates and collection**:

* **Default due** and **Longest due** in days. 0 means no due date.
* **Allow installments**, then **Most installments** (2 or more) and **Shortest gap between installments** in days.
* **When overdue**: the general overdue rule. Jobs and businesses can override it.
* **Penalty multiplier**: what is left is multiplied by this once, 1 means no penalty.
* **Allow signatures**.

The overdue rule and the multiplier are saved on the invoice when it is created, so later changes don't affect older invoices. The rule runs once, the moment the due time passes:

* **partial** (Collect, then penalty): takes what the receiver's bank account has, then multiplies the rest by the penalty multiplier. With tgiann-bank the main account is used. Without it only online players can be charged, from their framework bank money.
* **debt** (Penalty only): only multiplies the amount left.
* **none** (Mark only): only marks the invoice overdue.

Installments split the total evenly, and the remainder goes on the last part. The first part is due after the due date (or after one gap when there is no due date), and each next part one gap later. The receiver pays one part at a time. The overdue rule runs on each part separately.

An invoice that waits for the receiver to accept it doesn't lose time: its due dates move forward by the time it waited.

## Business tab

Job bosses and business owners see a Business tab for each business they run.

* **Price list**: up to `maxPriceItems` ready items for quick invoices. With **Only from the list** on, staff can't type their own items or prices.
* **tgiann-food-jobs menu**: a food business (a job with the same name as a food-jobs location, or a `food_job_<key>` business) always bills from its food menu. Prices changed here stay inside the menu min and max, and items can be shown or hidden. Changes are written to the food menu too.
* **Staff**: permissions per job grade or per business employee: "Can send invoices", "Sees every invoice", "Can cancel any invoice" and an optional custom commission. Job grades without saved settings can send invoices. Business employees can't until the owner allows it.
* **Commission**: the share of the subtotal each staff member earns from the invoices they issue. For a tgiann-food-jobs business this is the same value as the worker cut in the food-jobs boss panel, and changing one changes the other.
* **Brand**: a color and a logo printed on new invoices. The logo can come from the gallery, the camera or a link. With `brandApproval` on, a new logo waits under Logo requests in the admin panel. The managers get a notification when it is approved or rejected.
* **Numbers**: stats for the last day, week, month or all time: collected money, paid and open invoices, VAT, commission and the top 10 staff.
* **Invoices**: everything sent in the business name, by anyone, with All / Open / Paid / Closed filters and a search by name or invoice no. Staff with "Sees every invoice" can also open any invoice sent in the business name.

## Refunds

The issuer, or someone who can cancel any invoice of the business, can refund a paid invoice. A refund can be full or partial (up to what is left) and can have a short reason (`refunds.reasonMax`). The money moves back the same way it came in: the sender returns its share, the issuer returns their commission (the sender covers it when the issuer can't), and the treasury returns the VAT. The receiver gets the full amount. When everything is refunded, the invoice becomes Refunded. The refund fails when the sender's account can't cover it.

Cancelling an unpaid invoice that already has money on it (paid installments or collected money) sends that money back first.

## Disputes

The receiver can dispute an unpaid invoice with a reason (`disputes.reasonMax`). While it is disputed, payment and the overdue rule are paused.

A dispute can be settled by the issuer, by someone who can cancel any invoice of the business, or by a resolver job set in the admin panel under **Disputes** (with a minimum grade). The receiver can't settle their own dispute. There are three outcomes:

* **Reject**: the invoice stays as it is and becomes unpaid again.
* **Reduce**: set a lower total. It can't go below what was already paid. VAT and commission scale down with it.
* **Cancel invoice**: money already paid goes back to the receiver and the invoice is cancelled.

After Reject or Reduce, the due dates move forward by the time the dispute was open. The settler can add a short note, and the receiver gets a notification with the result.

## City and taxes

The **City and taxes** section of the admin panel holds:

* **City name on invoices**: tax invoices are sent in this name, with no VAT and no commission.
* **Taxes**: each tax has a key, a name on invoices, an amount, a period ("Every (days)"), a due time in days and an Active switch. What it charges per:
  * **vehicle** (Owned vehicle): amount × vehicles the citizen owns (`editable.countVehicles`).
  * **house** (Owned house): amount × houses the citizen owns (`editable.countHouses`).
  * **business** (Owned business): amount × bought tgiann-core businesses the citizen owns.
  * **custom** (Every citizen): a flat amount.
* **Jobs that can look up citizens**: officials (with a minimum grade) can search a citizen in the app and see their open invoices, unpaid total, overdue and disputed counts.
* **Treasury**: VAT collected, taxes collected and commissions paid out.

Taxes are checked every 10 minutes. Every character with a phone (a saved device or a SIM number) is billed once per period. A new character starts their period without being billed right away. "Charge taxes now" runs a pass at once.

Tax money and VAT go to the treasury job when "Send VAT to a job account" is on. Otherwise they stay in the billing treasury, which is only a ledger shown on the treasury card.

## Items

Billing uses two inventory items:

* `invoice`: a printed invoice. Anyone who may bill for the sender (the issuer or the business staff) can print an open invoice from the app. Whoever uses the paper can open that invoice on the phone for `paperItem.viewMinutes` minutes.
* `pos_terminal`: business staff use it to charge the nearest player. They pick the business, enter an amount and an optional description. The customer gets a payment request banner on the phone and has `pos.timeout` seconds to answer. The invoice is created unpaid first, so a declined or ignored request still leaves it on the customer's phone. Accepting pays from the main bank account when it covers the total, otherwise from the first account that does.

Add them to your inventory item list. The definitions from tgiann-inventory `items/items.lua`:

```lua
invoice                       = { label = "Invoice", weight = 0, type = "item", image = "invoice.png", unique = true, useable = true, shouldClose = true, description = "A printed invoice" },
pos_terminal                  = { label = "POS Terminal", weight = 500, type = "item", image = "pos_terminal.png", useable = true, shouldClose = true, description = "Charges a nearby customer in the business name" },
```

Item names can be changed with `paperItem.itemName` and `pos.itemName`.

## Compatibility

### esx\_billing

With `config.billing.bridge.esxBilling = true`, tgiann-phone takes over the esx\_billing events, so scripts that send bills through esx\_billing create phone invoices instead:

* `esx_billing:sendBill` and `esx_billing:sendBillToIdentifier` create an invoice. A `society_<job>` account sends it in the job name (with VAT) when the issuer has that job. Anything else is a personal invoice.
* The `BillPlayer` and `BillPlayerByIdentifier` exports are available on tgiann-phone with the same arguments.
* `esx_billing:paidBill` fires when a bridged invoice is paid and the receiver is online.

{% hint style="warning" %}
The bridge only starts when esx\_billing is not installed at all. Stopping it is not enough: remove the esx\_billing folder from your resources. Otherwise the console prints `[tgiann-phone] esx_billing is installed, the billing bridge stays off`.
{% endhint %}

`esx_mechanicjob` lists `esx_billing` under `dependencies` in its `fxmanifest.lua`. After removing esx\_billing, delete that line, or esx\_mechanicjob won't start. Its bills keep working through the bridge.

Scripts that call `exports.esx_billing:BillPlayer(...)` directly need to call `exports["tgiann-phone"]:BillPlayer(...)` instead.

### tgiann-policejob

When tgiann-phone is running, money fines are sent as police job invoices without VAT.

### tgiann-food-jobs

When tgiann-phone is running, the cash register bills the customer by itself: the customer receives the order packet right away and an invoice for the order total (with VAT) lands on their phone, sent in the `food_job_<key>` business name by the employee who prepared the order. The manual "bill" entry of the F4 menu is hidden. If the invoice can't be created, the register falls back to charging the customer's bank at the counter.

## Money flow

When tgiann-bank is running, all money moves through its accounts. The payer picks any account they can withdraw or transfer from, as long as it isn't frozen. Without tgiann-bank the framework money is used, and the payer picks from `frameworkPayment` (bank and cash by default).

Each payment is split when it comes in:

* **VAT**: goes to the treasury job account when one is set, otherwise to the billing treasury.
* **Commission**: goes to the staff member who issued the invoice. Personal and city invoices have no commission.
* **The rest**, penalties included, goes to the sender:
  * Job: the job account (tgiann-bank job account, or the framework society money).
  * Business: the business account (tgiann-bank business account, or the tgiann-core business money).
  * Player: their main bank account, or framework bank money. A player who is offline gets it the next time they open the Billing app.
  * City: the treasury job, or the billing treasury.

Money collected by the **partial** overdue rule is split the same way.

{% hint style="info" %}
VAT is added on top of the subtotal. Commission is taken from the subtotal, so it doesn't change what the receiver pays.
{% endhint %}
