> For the complete documentation index, see [llms.txt](https://docs.snapfix.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.snapfix.com/engineering-reference/db/tables/xero_sales_invoices.md).

# xero\_sales\_invoices

{% hint style="info" %}
Generated from the staging database schema, with descriptions drafted by agents ([how to read these docs](https://docs.snapfix.com/how-to-read.md)). [Source on GitHub](https://github.com/snapfix/docs/blob/main/spec/db/tables/xero_sales_invoices.md).
{% endhint %}

## Description

One sales invoice copied from Xero, with number, contact, status and totals; the dates are datetimes and the rest is text. apipy's Xero routes list it (nothing calls them), no in-scope code writes it, and no row is newer than 2022-06.

<details>

<summary><strong>Table Definition</strong></summary>

```sql
CREATE TABLE `xero_sales_invoices` (
  `id` int NOT NULL AUTO_INCREMENT,
  `uuid` varchar(255) DEFAULT NULL,
  `xero_ref` varchar(255) DEFAULT NULL,
  `Contact` varchar(255) DEFAULT NULL,
  `Contactname` varchar(255) DEFAULT NULL,
  `Contactemail` varchar(255) DEFAULT NULL,
  `Contactfirstname` varchar(255) DEFAULT NULL,
  `Contactlastname` varchar(255) DEFAULT NULL,
  `Contactphonenumber` varchar(255) DEFAULT NULL,
  `Phones` varchar(255) DEFAULT NULL,
  `Balances` varchar(255) DEFAULT NULL,
  `Date` datetime DEFAULT NULL,
  `Duedate` datetime DEFAULT NULL,
  `Status` varchar(255) DEFAULT NULL,
  `Lineamounttypes` varchar(255) DEFAULT NULL,
  `Lineitems` varchar(255) DEFAULT NULL,
  `SubTotal` varchar(255) DEFAULT NULL,
  `TotalTax` varchar(255) DEFAULT NULL,
  `Total` varchar(255) DEFAULT NULL,
  `UpdatedDateUTC` datetime DEFAULT NULL,
  `Currencycode` varchar(255) DEFAULT NULL,
  `Type` varchar(255) DEFAULT NULL,
  `Invoiceid` varchar(255) DEFAULT NULL,
  `Invoicenumber` varchar(255) DEFAULT NULL,
  `Reference` varchar(255) DEFAULT NULL,
  `Amountdue` varchar(255) DEFAULT NULL,
  `Amountpaid` varchar(255) DEFAULT NULL,
  `Amountcredited` varchar(255) DEFAULT NULL,
  `Currencyrate` varchar(255) DEFAULT NULL,
  `RepeatingInvoiceID` varchar(255) DEFAULT NULL,
  `fDeleted` tinyint DEFAULT '0',
  `fCreatedTs` bigint DEFAULT NULL,
  `fModifiedTs` bigint DEFAULT NULL,
  `fServerTs` bigint DEFAULT NULL,
  `uuid_tUser_CreatedBy` varchar(255) DEFAULT NULL,
  `uuid_tUser_ModifiedBy` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE KEY `uuid` (`uuid`) USING BTREE,
  KEY `fk_xero_sales_invoices_createdbyuser` (`uuid_tUser_CreatedBy`),
  CONSTRAINT `fk_xero_sales_invoices_createdbyuser` FOREIGN KEY (`uuid_tUser_CreatedBy`) REFERENCES `tPri_User` (`uuid`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE=InnoDB DEFAULT CHARSET=latin1
```

</details>

## Columns

| Name                    | Type         | Default | Nullable | Extra Definition | Parents                                                                             |
| ----------------------- | ------------ | ------- | -------- | ---------------- | ----------------------------------------------------------------------------------- |
| id                      | int          |         | false    | auto\_increment  |                                                                                     |
| uuid                    | varchar(255) |         | true     |                  |                                                                                     |
| xero\_ref               | varchar(255) |         | true     |                  |                                                                                     |
| Contact                 | varchar(255) |         | true     |                  |                                                                                     |
| Contactname             | varchar(255) |         | true     |                  |                                                                                     |
| Contactemail            | varchar(255) |         | true     |                  |                                                                                     |
| Contactfirstname        | varchar(255) |         | true     |                  |                                                                                     |
| Contactlastname         | varchar(255) |         | true     |                  |                                                                                     |
| Contactphonenumber      | varchar(255) |         | true     |                  |                                                                                     |
| Phones                  | varchar(255) |         | true     |                  |                                                                                     |
| Balances                | varchar(255) |         | true     |                  |                                                                                     |
| Date                    | datetime     |         | true     |                  |                                                                                     |
| Duedate                 | datetime     |         | true     |                  |                                                                                     |
| Status                  | varchar(255) |         | true     |                  |                                                                                     |
| Lineamounttypes         | varchar(255) |         | true     |                  |                                                                                     |
| Lineitems               | varchar(255) |         | true     |                  |                                                                                     |
| SubTotal                | varchar(255) |         | true     |                  |                                                                                     |
| TotalTax                | varchar(255) |         | true     |                  |                                                                                     |
| Total                   | varchar(255) |         | true     |                  |                                                                                     |
| UpdatedDateUTC          | datetime     |         | true     |                  |                                                                                     |
| Currencycode            | varchar(255) |         | true     |                  |                                                                                     |
| Type                    | varchar(255) |         | true     |                  |                                                                                     |
| Invoiceid               | varchar(255) |         | true     |                  |                                                                                     |
| Invoicenumber           | varchar(255) |         | true     |                  |                                                                                     |
| Reference               | varchar(255) |         | true     |                  |                                                                                     |
| Amountdue               | varchar(255) |         | true     |                  |                                                                                     |
| Amountpaid              | varchar(255) |         | true     |                  |                                                                                     |
| Amountcredited          | varchar(255) |         | true     |                  |                                                                                     |
| Currencyrate            | varchar(255) |         | true     |                  |                                                                                     |
| RepeatingInvoiceID      | varchar(255) |         | true     |                  |                                                                                     |
| fDeleted                | tinyint      | 0       | true     |                  |                                                                                     |
| fCreatedTs              | bigint       |         | true     |                  |                                                                                     |
| fModifiedTs             | bigint       |         | true     |                  |                                                                                     |
| fServerTs               | bigint       |         | true     |                  |                                                                                     |
| uuid\_tUser\_CreatedBy  | varchar(255) |         | true     |                  | [tPri\_User](https://docs.snapfix.com/engineering-reference/db/tables/tpri_user.md) |
| uuid\_tUser\_ModifiedBy | varchar(255) |         | true     |                  |                                                                                     |

## Viewpoints

| Name                                                                                | Definition                                                                                                                                                                           |
| ----------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| [billing](https://docs.snapfix.com/engineering-reference/db/tables/viewpoint-13.md) | Plans and packages, the billing organisation (`tPri_Org`) with its Stripe, GoCardless, Xero and HubSpot deal records, in-app purchases, the paywall, support minutes and currencies. |

## Constraints

| Name                                     | Type        | Definition                                                        |
| ---------------------------------------- | ----------- | ----------------------------------------------------------------- |
| fk\_xero\_sales\_invoices\_createdbyuser | FOREIGN KEY | FOREIGN KEY (uuid\_tUser\_CreatedBy) REFERENCES tPri\_User (uuid) |
| PRIMARY                                  | PRIMARY KEY | PRIMARY KEY (id)                                                  |
| uuid                                     | UNIQUE      | UNIQUE KEY uuid (uuid)                                            |

## Indexes

| Name                                     | Definition                                                                        |
| ---------------------------------------- | --------------------------------------------------------------------------------- |
| fk\_xero\_sales\_invoices\_createdbyuser | KEY fk\_xero\_sales\_invoices\_createdbyuser (uuid\_tUser\_CreatedBy) USING BTREE |
| PRIMARY                                  | PRIMARY KEY (id) USING BTREE                                                      |
| uuid                                     | UNIQUE KEY uuid (uuid) USING BTREE                                                |

## Triggers

| Name                                  | Definition                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| ------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| BEFORE\_INSERT\_xero\_sales\_invoices | <p>CREATE TRIGGER BEFORE\_INSERT\_xero\_sales\_invoices BEFORE INSERT ON xero\_sales\_invoices<br>FOR EACH ROW<br>BEGIN<br>IF new\.uuid IS NULL THEN<br>SET new\.uuid = uuid();<br>END IF;<br><br>IF new\.fCreatedTs IS NULL THEN<br>SET new\.fCreatedTs = UNIX\_TIMESTAMP()\*1000;<br>END IF;<br>IF new\.fModifiedTs IS NULL THEN<br>SET new\.fModifiedTs = UNIX\_TIMESTAMP()\*1000;<br>END IF;<br>IF new\.fServerTs IS NULL THEN<br>SET new\.fServerTs = UNIX\_TIMESTAMP()\*1000;<br>END IF;<br>IF new\.uuid\_tUser\_CreatedBy IS NULL THEN<br>SET new\.uuid\_tUser\_CreatedBy = 'hubspot-integration-cathal';<br>END IF;<br>IF new\.uuid\_tUser\_ModifiedBy IS NULL THEN<br>SET new\.uuid\_tUser\_ModifiedBy = 'hubspot-integration-cathal';<br>END IF;<br>END</p> |

## Relations

```mermaid
erDiagram

"xero_sales_invoices" }o--o| "tPri_User" : "FOREIGN KEY (uuid_tUser_CreatedBy) REFERENCES tPri_User (uuid)"

"xero_sales_invoices" {
  int id PK
  varchar_255_ uuid_tUser_CreatedBy FK
}
"tPri_User" {
  int id PK
  varchar_255_ uuid
  varchar_255_ uuid_tUser_CreatedBy FK
}
```

***

> Generated by [tbls](https://github.com/k1LoW/tbls)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.snapfix.com/engineering-reference/db/tables/xero_sales_invoices.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
