# Server: Advanced Billing exports

> Reference for Server: Advanced Billing exports in mechanicjob.

[All exports](/docs/jobs/mechanicjob/reference/exports)

This page documents supported public integration calls and usage examples. It does not expose or reproduce the resource's internal implementation.

## Server Exports

All Advanced Pricing and Billing exports return a result table:

```lua
{
    success = true,
    data = {}
}
```

Rejected requests return `success = false` and a stable `error` code. Player identity, mechanic job, grade, permissions, vehicle distance, configured limits, quote state, invoice ownership, and monetary values are always resolved or validated on the server.

### Advanced Billing exports

<table>
<thead>
  <tr>
    <th>
      Export
    </th>
    
    <th>
      Arguments
    </th>
    
    <th>
      Purpose
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        CreateInvoice
      </code>
    </td>
    
    <td>
      <code>
        source, payload
      </code>
    </td>
    
    <td>
      Creates a validated invoice for configured work, positions, or permitted manual lines
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        CreateEstimate
      </code>
    </td>
    
    <td>
      <code>
        source, payload
      </code>
    </td>
    
    <td>
      Creates a time-limited estimate using the same validation and price boundaries
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        GetInvoice
      </code>
    </td>
    
    <td>
      <code>
        source, invoiceId
      </code>
    </td>
    
    <td>
      Returns one invoice to its customer or an authorized workshop manager
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        GetPlayerInvoices
      </code>
    </td>
    
    <td>
      <code>
        source, limit?
      </code>
    </td>
    
    <td>
      Returns up to 100 invoices belonging to that player
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        PayInvoice
      </code>
    </td>
    
    <td>
      <code>
        source, payload
      </code>
    </td>
    
    <td>
      Pays the server-calculated balance or an allowed partial amount
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        RespondToEstimate
      </code>
    </td>
    
    <td>
      <code>
        source, payload
      </code>
    </td>
    
    <td>
      Accepts or declines an estimate owned by the player
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        SendInvoiceReminder
      </code>
    </td>
    
    <td>
      <code>
        source, payload
      </code>
    </td>
    
    <td>
      Sends a permission- and cooldown-checked overdue reminder
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        CancelInvoice
      </code>
    </td>
    
    <td>
      <code>
        source, payload
      </code>
    </td>
    
    <td>
      Cancels an unpaid document when the mechanic grade permits it
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        GetBillingAnalytics
      </code>
    </td>
    
    <td>
      <code>
        source, periodDays?
      </code>
    </td>
    
    <td>
      Returns the authorized workshop's accounting summary
    </td>
  </tr>
</tbody>
</table>

#### Creating an invoice or estimate

```lua [server.lua]
local invoice = exports["sky_mechanicjob"]:CreateInvoice(source, {
    targetId = customer_source,
    plate = "ABC123",
    historyIds = { 481, 482 },
    customPositionKeys = { "diagnostics" },
    discountPercent = 5
})

local estimate = exports["sky_mechanicjob"]:CreateEstimate(source, {
    targetId = customer_source,
    manualItems = {
        {
            label = "Custom fabrication",
            category = "bodywork",
            costType = "labor",
            quantity = 2,
            unitPrice = 750
        }
    }
})
```

Manual positions, custom prices, discounts, document totals, and estimates must be enabled for the mechanic's grade. The customer must be online and within eight meters when `targetId` is used.

#### Reading and paying invoices

```lua [server.lua]
local invoice = exports["sky_mechanicjob"]:GetInvoice(source, invoice_id)
local invoices = exports["sky_mechanicjob"]:GetPlayerInvoices(source, 25)

local payment = exports["sky_mechanicjob"]:PayInvoice(
    source,
    {
        invoiceId = invoice_id,
        paymentMethod = "card",
        amount = 500
    }
)
```

The server loads the invoice owner and outstanding balance, enforces the deposit and minimum partial payment, removes the money, deposits workshop funds, records the payment, and updates the status. Supplying a larger amount cannot overpay the invoice.

#### Estimate and management actions

```lua [server.lua]
exports["sky_mechanicjob"]:RespondToEstimate(customer_source, {
    invoiceId = estimate_id,
    accepted = true
})
exports["sky_mechanicjob"]:SendInvoiceReminder(mechanic_source, {
    invoiceId = invoice_id
})
exports["sky_mechanicjob"]:CancelInvoice(mechanic_source, {
    invoiceId = invoice_id,
    reason = "Created by mistake"
})

local analytics = exports["sky_mechanicjob"]:GetBillingAnalytics(mechanic_source, 30)
```

<callout color="success" icon="i-lucide-shield-check">

These are server exports. Do not proxy them through an unvalidated `RegisterNetEvent`. If a client UI needs an action, let the existing Mechanic callbacks perform the server-side validation.

</callout>
