# Tax engine connector

> Connect Avalara, Anrok or the local stub so a bill's lines take their tax type and location from the engine; the ledger keeps tracking purchase tax by type and location.

Source: /help/en/integrations/tax-engine

A tax engine answers one question for a purchase document: what tax type each line carries and where the purchase belongs. Alya Books tracks purchase tax by type and location itself (the purchase tax report under **VAT Return**); the connector is optional and only fills the lines of a draft bill. Three providers exist as data: **Avalara AvaTax**, **Anrok** and the **stub** of the local stack.

You find the card under **Connectors → Tax engine**. Owners and admins connect, test and remove it; accountants fill bills.

## Connect a provider

1. Pick the **Provider**. Each names its credential fields: Avalara an account id, a licence key and a company code; Anrok an API key; the stub nothing.
2. Enter the credentials and keep **Connection switched on**; click **Connect**. A secret is never shown again: the card prints its last two characters, and leaving the field empty on a later save keeps the stored value.
3. **Test connection** pings the provider with the saved credentials and records the outcome; the status badge reads *connected*, *error* (with the last message) or *disconnected*.

## Fill a bill

1. Open a draft bill (or one in review) under **Incoming → Bills** and select **More** → **Fill from tax engine**.
2. Every line takes the engine's tax type (standard, zero-rated, exempt, reverse charge or out of scope; the rate comes from your country pack when the engine names none), and the bill takes the **location** dimension that matches the engine's answer, when you keep one of that name. The bill's metadata records the provider and the time; the audit log holds *tax_engine.bill_filled*.
3. An accepted or booked bill is refused: void it and record it again to change its content.

The stub needs no network: a supplier in your country is a standard-rated purchase at the pack's rate, a supplier abroad a reverse-charge import, and the location is the supplier's emirate when a location of that name exists.

## API and assistants

`GET`, `PUT` and `DELETE /tax-engine`, `POST /tax-engine/test` and `POST /bills/{id}/tax-engine` (with `dryRun` to see the determination without writing); the assistant tools are `get_tax_engine`, `save_tax_engine`, `test_tax_engine` and `fill_bill_tax_from_engine`. Credentials are never answered back.

## Walkthrough

1. Connect the stub, test it (*The stub engine answers without a network*).
2. Record a bill from a German supplier with two zero-rated lines; **More** → **Fill from tax engine**: both lines read reverse charge and the bill names the provider.
3. Record a bill from a Sharjah supplier while a location *Sharjah* exists: both lines read standard at 5 % and the bill's location is Sharjah.
4. Accept the bill and try again: refused with *bill_posted*.

## Related

- [File the VAT return from the ledger](/help/en/vat/file-the-vat-return-from-the-ledger)
- [Dimensions and locations](/help/en/accounting/dimensions-and-locations)
