# Troubleshooting

This guide provides solutions to common issues you might encounter while installing or using the Billing System.

## General Issues

### The Tablet Won't Open (F7 Key)

**Possibilities:**

1. **Wrong Job:** Check if your job is listed in `Config.AllowedJobs` in `config.lua`.
2. **Keybind Conflict:** Another resource might be using the same key. Try changing `Config.Keybind`.
3. **Resource Not Started:** Ensure `src-billing` is started in your `server.cfg`.
4. **Console Errors:** Open the F8 console to check for any client-side JavaScript or Lua errors.

**Solution:**

* Type `/ensure src-billing` in the console to restart the resource.
* Check the F8 console for error messages.
* Ensure you have a job that is allowed to open the tablet.

***

## Technical Issues

### Framework Not Detected

By default, the bridge uses `Config.Framework = 'auto'`. Occasionally, detection might fail if your framework resource is named differently.

**Check:**

* Is your framework (QBox, QBCore, or ESX) started before `src-billing`?
* Are you using a highly modified or renamed version of a framework?

**Solution:**

* Manually set the framework in `config.lua`:

  ```lua
  Config.Framework = 'qbox' -- or 'qb', 'esx'
  ```

### Database Errors

If you see errors related to `MySQL` or missing tables in your server console.

**Check:**

* Did you import `sql/billing.sql`?
* Are the table names exactly as expected?

**Solution:**

* Re-import the SQL file.
* Ensure your database connection string in `server.cfg` is correct.

***

## Payment Issues

### Money Not Being Removed

If a player pays an invoice but no money is taken from their account.

**Check:**

* Check the server console for errors when the payment is made.
* If using a **Custom Framework**, verify your `Bridge.RemoveMoney` implementation in `bridge/server.lua`.

**Solution:**

* Ensure the `Bridge.RemoveMoney` function returns `true` on success and `false` on failure.

### Physical Receipt Not Given

**Check:**

* Is `ox_inventory` started?
* Is `Config.ReceiptSettings.Enabled = true`?
* Do you have the `receipt` item added to your inventory's items list?

***

## UI Issues

### Black Screen or Layout Glitches

If the tablet UI appears broken or shows a black screen.

**Possibilities:**

1. **NUI Focus:** Something might be blocking the NUI focus.
2. **Build Error:** If you modified the web code, the build might have failed.

**Solution:**

* Restart the resource: `ensure src-billing`.
* If you made changes to the `web` folder, run `npm run build` again.
* Clear your local browser cache (FiveM cache folder).

***

## Getting More Help

If you're still having issues:

1. **Check the Logs:** Both server console and F8 client console contain vital clues.
2. **Verify Dependencies:** Ensure `ox_lib` and/or `ox_inventory` are up to date if you're using them.
3. **Open an Issue:** If you believe you've found a bug, please report it on the GitHub repository with detailed logs.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.sourcedev.pro/advanced-billing-system/troubleshooting.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
