# ledger_accounting_run_vat

## Description

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

```sql
CREATE TABLE `ledger_accounting_run_vat` (
  `ledger_accounting_run_vat_id` mediumint unsigned NOT NULL AUTO_INCREMENT,
  `accounting_run_id` mediumint unsigned NOT NULL,
  `abacus_event_id` mediumint unsigned NOT NULL,
  `contract_id` mediumint unsigned NOT NULL,
  `currency_code` char(3) COLLATE utf8mb4_general_ci NOT NULL,
  `country_of_tax_residence` char(3) COLLATE utf8mb4_general_ci NOT NULL,
  `gross_revenue` decimal(20,2) DEFAULT NULL,
  `net_revenue` decimal(20,2) DEFAULT NULL,
  `distribution_fee` decimal(20,2) DEFAULT NULL,
  `gross_vat_rate` decimal(5,2) DEFAULT NULL,
  `distribution_vat_rate` decimal(5,2) DEFAULT NULL,
  `gross_vat` decimal(20,2) DEFAULT NULL,
  `distribution_vat` decimal(20,2) DEFAULT NULL,
  `adjusted_net_revenue` decimal(20,2) DEFAULT NULL,
  `exempt_reason` varchar(180) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `created_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,
  `created_at` datetime NOT NULL,
  `last_modified_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,
  `last_modified` datetime NOT NULL,
  PRIMARY KEY (`ledger_accounting_run_vat_id`),
  KEY `fk_ledger_accounting_run_vat_acc_run` (`accounting_run_id`),
  KEY `fk_ledger_accounting_run_vat_event` (`abacus_event_id`),
  KEY `fk_ledger_accounting_run_vat_contract` (`contract_id`),
  CONSTRAINT `fk_ledger_accounting_run_vat_acc_run` FOREIGN KEY (`accounting_run_id`) REFERENCES `accounting_run` (`accounting_run_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `fk_ledger_accounting_run_vat_contract` FOREIGN KEY (`contract_id`) REFERENCES `contract` (`contract_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `fk_ledger_accounting_run_vat_event` FOREIGN KEY (`abacus_event_id`) REFERENCES `abacus_event` (`abacus_event_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci
```

</details>

## Columns

| Name                         | Type               | Default | Nullable | Extra Definition | Children | Parents                             | Comment |
| ---------------------------- | ------------------ | ------- | -------- | ---------------- | -------- | ----------------------------------- | ------- |
| abacus_event_id              | mediumint unsigned |         | false    |                  |          | [abacus_event](abacus_event.md)     |         |
| accounting_run_id            | mediumint unsigned |         | false    |                  |          | [accounting_run](accounting_run.md) |         |
| adjusted_net_revenue         | decimal(20,2)      |         | true     |                  |          |                                     |         |
| contract_id                  | mediumint unsigned |         | false    |                  |          | [contract](contract.md)             |         |
| country_of_tax_residence     | char(3)            |         | false    |                  |          |                                     |         |
| created_at                   | datetime           |         | false    |                  |          |                                     |         |
| created_by                   | varchar(255)       |         | false    |                  |          |                                     |         |
| currency_code                | char(3)            |         | false    |                  |          |                                     |         |
| distribution_fee             | decimal(20,2)      |         | true     |                  |          |                                     |         |
| distribution_vat             | decimal(20,2)      |         | true     |                  |          |                                     |         |
| distribution_vat_rate        | decimal(5,2)       |         | true     |                  |          |                                     |         |
| exempt_reason                | varchar(180)       |         | true     |                  |          |                                     |         |
| gross_revenue                | decimal(20,2)      |         | true     |                  |          |                                     |         |
| gross_vat                    | decimal(20,2)      |         | true     |                  |          |                                     |         |
| gross_vat_rate               | decimal(5,2)       |         | true     |                  |          |                                     |         |
| last_modified                | datetime           |         | false    |                  |          |                                     |         |
| last_modified_by             | varchar(255)       |         | false    |                  |          |                                     |         |
| ledger_accounting_run_vat_id | mediumint unsigned |         | false    | auto_increment   |          |                                     |         |
| net_revenue                  | decimal(20,2)      |         | true     |                  |          |                                     |         |

## Constraints

| Name                                  | Type        | Definition                                                                    |
| ------------------------------------- | ----------- | ----------------------------------------------------------------------------- |
| PRIMARY                               | PRIMARY KEY | PRIMARY KEY (ledger_accounting_run_vat_id)                                    |
| fk_ledger_accounting_run_vat_acc_run  | FOREIGN KEY | FOREIGN KEY (accounting_run_id) REFERENCES accounting_run (accounting_run_id) |
| fk_ledger_accounting_run_vat_contract | FOREIGN KEY | FOREIGN KEY (contract_id) REFERENCES contract (contract_id)                   |
| fk_ledger_accounting_run_vat_event    | FOREIGN KEY | FOREIGN KEY (abacus_event_id) REFERENCES abacus_event (abacus_event_id)       |

## Indexes

| Name                                  | Definition                                                               |
| ------------------------------------- | ------------------------------------------------------------------------ |
| PRIMARY                               | PRIMARY KEY (ledger_accounting_run_vat_id) USING BTREE                   |
| fk_ledger_accounting_run_vat_acc_run  | KEY fk_ledger_accounting_run_vat_acc_run (accounting_run_id) USING BTREE |
| fk_ledger_accounting_run_vat_contract | KEY fk_ledger_accounting_run_vat_contract (contract_id) USING BTREE      |
| fk_ledger_accounting_run_vat_event    | KEY fk_ledger_accounting_run_vat_event (abacus_event_id) USING BTREE     |

## Relations

![er](ledger_accounting_run_vat.svg)

---

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