# Invoicing

There are three different types of invoices: a **proforma** invoice, an **Account Receivable (AR)** invoice, and an **Accounts Payable (AP)** invoice.

* **PROFORMA** — a **proforma** describes the total earned/billed for a specific service that a provider rendered. A **proforma** is attached to an **AP** and/or **AR** invoice for payment and contains one or more **slips** (line items) for services.
* **AR** — an **AR** invoice is what customers are billed for services they have been provided. An **AR** invoice will contain one or more **proformas** as well as inidividual **slips**.
* **AP** — an **AP** invoice is what providers submit to the *partner* for payment for services they have provided. An **AP** invoice will contain one or more **proformas** as well as individual **slips**.
* **Slip** — a **slip** is a line item that goes on an invoice.

{% hint style="info" %}
In our legacy application a **proforma** was called a *service invoice*.
{% endhint %}

### Proforma invoice

The *proforma* invoice is what is generated for some kind of billable service. It can be attached to a `Bid` or a `Schedule` or a `Assignment` or a `Reservation`. It contains the *slips* that indicate who is earning or paying for what when it is finally attached to either an AP or AR invoice (or both).

A *proforma* invoice is generated automatically by the API either:

1. When a job's outcome is finally published.
2. When a reservation shift is finished and all other *proforma* invoices related to the shift are submitted (this happens via a worker).
3. When a schedule/request is in the past (also via a worker).

### AR invoices

Customers are sent **AR** invoices (bills). These bills contain one or more **proforma** invoices for services rendered as well as additional slips (if needed). **AR** invoices can be generated based on the customer's preferred schedule (after each service, every day, weekly, monthly, etc).

Customers can also leverage **expense codes** (e.g., "purchase orders" or "authorization codes") that are entered during the new request process and brought over to the invoice.

We also support uploading required financial documents during the new request process which will also be attached to invoices.

#### Child AR Invoices

Generally, AR/AP invoices only have *proforma* child invoices. However, there is one other special use case that allows for an AR invoice to *also* have a child AR invoice.

A child AR invoice is created to "share" payments for the same proforma invoices with another customer.

For example, let's say there is an AR invoice (#1) for Customer A that is for $2,000 total but there is an agreement that Customer B will split the payment.

1. API will generate the original AR Invoice (#1) that belongs to Customer A. All the *proforma* invoices on this AR alos belong to Customer A. Total due is $2,000.
2. An admin manually creates a new AR Invoice (#2) with no PFs attached and applies a `general` slip for the amount the second customer has agreed to share ($1,000). Invoice #2 would have different billing information than Invoice #1 (and could even have a difference customer). It only has one slip and no *proforma* invoices.
3. Admin then *manually attaches* Invoice #2 (child) to Invoice #1 (parent/original).
4. This act decreases the Invoice #1's `#outstanding_balance_units` by the amount that Invoice #2 is contributing (in this case $1,000).

### AP invoices

After a provider has completed their services and confirmed them an AP invoice can be generated and will be paid by the partner in the agreed timeframe.

### Slips

Most slips you see will be on **proforma** invoices (although they can go directly on AR/AP invoices as well and do sometimes). Each slip represents a line item charge for certain items: services rendered, mileage, tolls, prep time, booking fees, etc.

Each **slip** is defined by its **slip type** (e.g., `service` or `mileage` or `reimbursement`). Some slips *require* a [pay schedule rate](/general/agreements.md#payschedule) (e.g., "weekday", "weeknight", etc) while others do not. A **pay schedule** informs the user about where the rate information is coming from. For example, a `service` slip with a **pay schedule** rate of "weekday" would inform the user they are being charged their weekday rate for that service.

A slip has a `quantity` as well as a `rate` that tracks what is charged to a customer and billed by a provider. More information about billing is in the [agreements](/general/agreements.md) section.

### Time-based policies

A proforma invoice is impacted by time-based policies that are applied to the service (provider and customer). See the agreement's [time-based policy](/general/agreements.md#time-based-policy) section for more information on how these are applied.

###


---

# 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.octoo.com/general/invoicing.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.
