# Issue e-invoices

Issue an e-invoice automatically when a payment is paid, or by hand for any payment or transfer, follow it until the tax office accepts it, and fix the ones that fail.

Once your [e-invoice provider is connected](https://hatang.dev/help/payments/einvoice-providers), Ha Tang can issue the e-invoice for a sale: automatically when the customer pays, or by hand for any payment or bank transfer. Every invoice is created under your tax code at your provider, signed there, and sent to the tax office; Ha Tang follows it and shows where it stands.

Creating, sending and retrying invoices needs the **Work** level on the Payments module.

## Automatically when a payment is paid

When you create a payment under **Payments → Payments**, open **Issue an e-invoice once paid**:

- **Item (defaults to the description)**: the line on the invoice.
- **VAT**: the rate, including **KCT (not subject)**. One line covers the whole amount; the price before VAT is worked out from the amount.
- **Template** and **When paid**: keep the provider's defaults, or choose **create the draft only** for this payment.

Nothing is sent to the provider until the payment is **Paid** or **Overpaid**. Then the invoice is created and, depending on the mode, sent for approval. Your website can also ask for an invoice when it creates payments, with the buyer's details and several lines; your developer finds how in [E-invoices in the developer hub](https://hatang.dev/docs/guides/payments/einvoices).

The customer's checkout page says an invoice is coming and, once issued, shows its number and lookup code.

## By hand

Open **Payments → E-invoices** and use **New invoice**:

1. Enter the **Buyer name**, and for a company the **Company (optional)**, **Tax code (optional)** and **Address**.
2. Optionally **Link to payment id (optional)**, so the payment shows its invoice. A payment can have only one invoice.
3. Fill in the item: **Item**, **Qty**, **Unit price** (before VAT) and **VAT %**.
4. Choose what happens **Then**: **stop at the draft** or **send for approval**, and the **Provider and template**.
5. Click **Create invoice**.

Shortcuts open the same form already linked: **Create one** on a payment without an invoice, and **Create invoice** next to a transfer under [Reconciliation](https://hatang.dev/help/payments/reconciliation).

> [!WARNING]
> Make the invoice total (after VAT) equal what the customer paid. Each line is rounded to whole đồng, and the total is the sum of the rounded lines. Ha Tang does not compare the invoice with the payment for you.

## Follow an invoice

| Status | Meaning |
|---|---|
| **waiting for payment** | The payment is not paid yet; nothing has been sent |
| **creating draft** | The draft is being created at the provider |
| **draft** | The draft exists. In draft mode it stops here until someone clicks **Send for approval** |
| **sending for approval** | Sent for signing |
| **issued** | Signed: it has a number and a lookup code, and waits for the tax office |
| **code issued** | The tax office accepted it and gave its code |
| **tax office rejected** | The tax office refused it |
| **failed** | The provider refused a step; the invoice page says why |
| **canceled**, **replaced**, **adjusted** | Changed afterwards, at the provider or by another invoice |
| **deleted** | A draft that was deleted |

The invoice page shows the buyer, the lines with VAT, the totals, the related payment, **Download PDF** once issued, and a **Timeline** of every step with who made it (Ha Tang, a provider callback, or a change seen at the provider).

## Review drafts

With **stop at the draft**, someone checks each invoice before it is signed:

1. Open **Payments → E-invoices** and pick a **draft**.
2. Check the buyer, the lines and the totals.
3. Click **Send for approval**, or **Delete draft** if it should not be issued.

## When something fails

Timeouts and provider outages are retried automatically. A refusal, for example an invalid buyer tax code, stops the invoice at **failed** with the provider's message:

1. Read the message on the invoice page.
2. Fix the cause, for example the buyer's tax code at your provider or in your records.
3. Click **Retry** (or **Retry the failed step** on the payment). The same step runs again.

If a draft was edited both in Ha Tang and in the provider's portal, the invoice page says so and offers **Keep my version** or **Take Mắt Bão's version**. Nothing else can happen to that draft until you choose.

## After the tax office has it

Once sent to the tax office, an invoice can no longer be deleted or canceled from Ha Tang. To correct it, cancel or replace it in the Mắt Bão portal (the change comes back to Ha Tang), or have your developer issue a replacement invoice through the API. Owners and admins receive an email when an invoice fails, is rejected by the tax office, or has not reached the tax office 5 hours after it was created.

## Check that nothing is missing

**Payments → Reconciliation** lists the money in that still has no invoice. See [Reconcile money in against invoices](https://hatang.dev/help/payments/reconciliation).
