# account_tax_info

## Description

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

```sql
CREATE TABLE `account_tax_info` (
  `account_tax_info_id` mediumint unsigned NOT NULL AUTO_INCREMENT,
  `account_id` mediumint unsigned NOT NULL,
  `country_of_tax_residence` char(3) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `is_sba_signed` tinyint(1) DEFAULT '0',
  `is_vat_exempt` tinyint(1) NOT NULL DEFAULT '1',
  `is_tax_treaty_claimed` tinyint(1) NOT NULL DEFAULT '0',
  `tax_employment_type` enum('Business','Employed Individual','Self-Employed Individual (< 2 years)','Self-Employed Individual (>= 2 years)','Individual','Small Business that is not required to register for EU VAT') COLLATE utf8mb4_general_ci DEFAULT NULL,
  `certificate_of_residence_expiration_date` date DEFAULT NULL,
  `is_wht_applicable` tinyint(1) NOT NULL DEFAULT '1',
  `is_resident_of_spanish_islands` tinyint(1) DEFAULT NULL,
  `wht_rate_override` decimal(5,2) 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 (`account_tax_info_id`),
  UNIQUE KEY `uidx_account_id` (`account_id`),
  CONSTRAINT `fk_account_tax_info_account_id` FOREIGN KEY (`account_id`) REFERENCES `account` (`account_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `wht_rate_override_check` CHECK (((`wht_rate_override` is null) or ((`wht_rate_override` >= 0.00) and (`wht_rate_override` <= 100.00))))
) 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 |
| ---------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | -------- | ---------------- | ------------------------------------------------------- | --------------------- | ------- |
| account_id                               | mediumint unsigned                                                                                                                                                                              |         | false    |                  |                                                         | [account](account.md) |         |
| account_tax_info_id                      | mediumint unsigned                                                                                                                                                                              |         | false    | auto_increment   | [account_tax_info_history](account_tax_info_history.md) |                       |         |
| certificate_of_residence_expiration_date | date                                                                                                                                                                                            |         | true     |                  |                                                         |                       |         |
| country_of_tax_residence                 | char(3)                                                                                                                                                                                         |         | true     |                  |                                                         |                       |         |
| created_at                               | datetime                                                                                                                                                                                        |         | false    |                  |                                                         |                       |         |
| created_by                               | varchar(255)                                                                                                                                                                                    |         | false    |                  |                                                         |                       |         |
| is_resident_of_spanish_islands           | tinyint(1)                                                                                                                                                                                      |         | true     |                  |                                                         |                       |         |
| is_sba_signed                            | tinyint(1)                                                                                                                                                                                      | 0       | true     |                  |                                                         |                       |         |
| is_tax_treaty_claimed                    | tinyint(1)                                                                                                                                                                                      | 0       | false    |                  |                                                         |                       |         |
| is_vat_exempt                            | tinyint(1)                                                                                                                                                                                      | 1       | false    |                  |                                                         |                       |         |
| is_wht_applicable                        | tinyint(1)                                                                                                                                                                                      | 1       | false    |                  |                                                         |                       |         |
| last_modified                            | datetime                                                                                                                                                                                        |         | false    |                  |                                                         |                       |         |
| last_modified_by                         | varchar(255)                                                                                                                                                                                    |         | false    |                  |                                                         |                       |         |
| tax_employment_type                      | enum('Business','Employed Individual','Self-Employed Individual (< 2 years)','Self-Employed Individual (>= 2 years)','Individual','Small Business that is not required to register for EU VAT') |         | true     |                  |                                                         |                       |         |
| wht_rate_override                        | decimal(5,2)                                                                                                                                                                                    |         | true     |                  |                                                         |                       |         |

## Constraints

| Name                           | Type        | Definition                                                                                                     |
| ------------------------------ | ----------- | -------------------------------------------------------------------------------------------------------------- |
| PRIMARY                        | PRIMARY KEY | PRIMARY KEY (account_tax_info_id)                                                                              |
| fk_account_tax_info_account_id | FOREIGN KEY | FOREIGN KEY (account_id) REFERENCES account (account_id)                                                       |
| uidx_account_id                | UNIQUE      | UNIQUE KEY uidx_account_id (account_id)                                                                        |
| wht_rate_override_check        | CHECK       | CHECK (((`wht_rate_override` is null) or ((`wht_rate_override` >= 0.00) and (`wht_rate_override` <= 100.00)))) |

## Indexes

| Name            | Definition                                          |
| --------------- | --------------------------------------------------- |
| PRIMARY         | PRIMARY KEY (account_tax_info_id) USING BTREE       |
| uidx_account_id | UNIQUE KEY uidx_account_id (account_id) USING BTREE |

## Triggers

| Name                          | Definition                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| after_update_account_tax_info | CREATE TRIGGER after_update_account_tax_info AFTER UPDATE ON account_tax_info<br />FOR EACH ROW<br />BEGIN<br />    INSERT INTO `account_tax_info_history`(<br />        `account_tax_info_id`,<br />        `account_id`,<br />        `country_of_tax_residence`,<br />        `is_sba_signed`,<br />        `is_vat_exempt`,<br />        `is_tax_treaty_claimed`,<br />        `tax_employment_type`,<br />        `certificate_of_residence_expiration_date`,<br />        `is_wht_applicable`,<br />        `is_resident_of_spanish_islands`,<br />        `wht_rate_override`,<br />        `created_by`,<br />        `created_at`,<br />        `last_modified_by`,<br />        `last_modified`<br />    ) VALUES (<br />        old.account_tax_info_id,<br />        old.account_id,<br />        old.country_of_tax_residence,<br />        old.is_sba_signed,<br />        old.is_vat_exempt,<br />        old.is_tax_treaty_claimed,<br />        old.tax_employment_type,<br />        old.certificate_of_residence_expiration_date,<br />        old.is_wht_applicable,<br />        old.is_resident_of_spanish_islands,<br />        old.wht_rate_override,<br />        old.created_by,<br />        old.created_at,<br />        old.last_modified_by,<br />        old.last_modified<br />    );<br />END |

## Relations

![er](account_tax_info.svg)

---

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