# VAT Exemption Reasons (VATEX) for JavaScript / TypeScript

[![npm version](https://badge.fury.io/js/vat-exemption-reasons.svg)](https://badge.fury.io/js/vat-exemption-reasons)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

JavaScript package for the VAT Exemption Reasons (VATEX) code lists used in European e-invoicing.

## About VAT Exemption Reasons (VATEX)

The **VAT Exemption Reasons (VATEX)** is a code list used within the European e-invoicing standard **EN 16931** to specify the reason for VAT exemption on an invoice. When an invoice includes items that are exempt from VAT, the VATEX code clarifies the legal basis for this exemption, such as reverse charge mechanisms, intra-community supply, or specific exemptions based on EU Council Directive 2006/112/EC.

This ensures that different systems can correctly interpret and process VAT-exempt transactions. The code list is maintained by KoSIT (Coordination Office for IT Standards) and is based on VATEX from the Connecting Europe Facility (CEF). It is essential for standards like **XRechnung**, **ZUGFeRD**, and networks like **Peppol**.

This package provides the official VATEX code lists in a simple, accessible format for use in JavaScript and TypeScript applications.

## RechnungsAPI

If you are looking for an API solution to generate German e-invoice documents, consider checking out [RechnungsAPI](https://www.rechnungs-api.de), without which this package would not exist.

## Installation

Install the package using your favorite package manager:

```bash
npm install vat-exemption-reasons
```

or

```bash
yarn add vat-exemption-reasons
```

## Usage

You can import the latest version of the code list or a specific historical version to match your compliance needs.

### Importing the Latest Code List

The main export of the package provides all versions of the VATEX code list.

```javascript
import { VATEX } from 'vat-exemption-reasons';
// Or to just get the latest version:
import { VATEX } from 'vat-exemption-reasons/latest';

console.log('Latest VATEX Codes:', VATEX);
// [
//   {
//   	code: "VATEX-EU-79-C",
//   	name: "Exempt based on article 79, point c of Council Directive 2006/112/EC",
//   	description: "Repayment handling context"
//   },
//   { code: "VATEX-EU-AE", name: "Reverse charge", description: "Only use with VAT category code AE" },
//   { code: "VATEX-EU-IC", name: "Intra-community supply", description: "Only use with VAT category code K" },
//   ...
// ]
```

### Importing a Specific Version

For specific use cases or to align with older specifications, you can deep-import a particular version of the code list. The package is configured to allow this to help optimize your application's bundle size.

```javascript
// For example, to get version 2 of the list
import { VATEX_2 } from 'vat-exemption-reasons/2';

console.log('VATEX Version 2:', VATEX_2);
```

### Data Structure

Each code list is an array of objects, where each object conforms to the `CodeListEntry` type.

```typescript
export interface CodeListEntry {
	code: string;
	name?: string;
	description?: string;
}

export type CodeList = CodeListEntry[];
```

## Available Code Lists

This package contains multiple versions of the VAT Exemption Reasons (VATEX) code list. You can import them as needed:

*   **Version 1**
*   **Version 2** (Latest)

