# worksheet_tax_correction_vat

## Description

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

```sql
CREATE TABLE `worksheet_tax_correction_vat` (
  `worksheet_tax_correction_vat_id` mediumint unsigned NOT NULL AUTO_INCREMENT,
  `payable_detail_type_id` tinyint unsigned NOT NULL,
  `contract_id` mediumint unsigned NOT NULL,
  `account_id` mediumint unsigned NOT NULL,
  `correction_statement_period_id` mediumint unsigned NOT NULL,
  `vat_category` enum('gross_revenue','distribution_fee','closing_balance','commission') DEFAULT NULL,
  `base_amount_payee_currency` decimal(20,2) NOT NULL,
  `payee_currency_code` char(3) NOT NULL,
  `vat_currency_code` char(3) NOT NULL,
  `vat_rate` decimal(20,2) NOT NULL,
  `vat_amount_payee_currency` decimal(20,2) NOT NULL,
  `vat_amount_vat_currency` decimal(20,2) NOT NULL,
  `net_amount_payee_currency` decimal(20,2) NOT NULL,
  `wht_rate` decimal(20,2) DEFAULT NULL,
  `wht_amount_payee_currency` decimal(20,2) DEFAULT NULL,
  `wht_amount_vat_currency` decimal(20,2) DEFAULT NULL,
  `note` varchar(255) DEFAULT NULL,
  `created_at` datetime NOT NULL,
  `created_by` varchar(255) NOT NULL,
  `last_modified` datetime NOT NULL,
  `last_modified_by` varchar(255) NOT NULL,
  `deleted_at` datetime DEFAULT NULL,
  `deleted_by` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`worksheet_tax_correction_vat_id`),
  KEY `fk_tcv_contract` (`contract_id`),
  KEY `fk_tcv_account` (`account_id`),
  KEY `fk_tcv_statement_period` (`correction_statement_period_id`),
  KEY `fk_tcv_ref_payable_detail` (`payable_detail_type_id`),
  CONSTRAINT `fk_tcv_account` FOREIGN KEY (`account_id`) REFERENCES `account` (`account_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `fk_tcv_contract` FOREIGN KEY (`contract_id`) REFERENCES `contract` (`contract_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `fk_tcv_ref_payable_detail` FOREIGN KEY (`payable_detail_type_id`) REFERENCES `reference_payable_detail_type` (`reference_payable_detail_type_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `fk_tcv_statement_period` FOREIGN KEY (`correction_statement_period_id`) REFERENCES `statement_period` (`statement_period_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb3
```

</details>

## Columns

| Name                            | Type                                                                    | Default | Nullable | Extra Definition | Children | Parents                                                           | Comment |
| ------------------------------- | ----------------------------------------------------------------------- | ------- | -------- | ---------------- | -------- | ----------------------------------------------------------------- | ------- |
| account_id                      | mediumint unsigned                                                      |         | false    |                  |          | [account](account.md)                                             |         |
| base_amount_payee_currency      | decimal(20,2)                                                           |         | false    |                  |          |                                                                   |         |
| contract_id                     | mediumint unsigned                                                      |         | false    |                  |          | [contract](contract.md)                                           |         |
| correction_statement_period_id  | mediumint unsigned                                                      |         | false    |                  |          | [statement_period](statement_period.md)                           |         |
| created_at                      | datetime                                                                |         | false    |                  |          |                                                                   |         |
| created_by                      | varchar(255)                                                            |         | false    |                  |          |                                                                   |         |
| deleted_at                      | datetime                                                                |         | true     |                  |          |                                                                   |         |
| deleted_by                      | varchar(255)                                                            |         | true     |                  |          |                                                                   |         |
| last_modified                   | datetime                                                                |         | false    |                  |          |                                                                   |         |
| last_modified_by                | varchar(255)                                                            |         | false    |                  |          |                                                                   |         |
| net_amount_payee_currency       | decimal(20,2)                                                           |         | false    |                  |          |                                                                   |         |
| note                            | varchar(255)                                                            |         | true     |                  |          |                                                                   |         |
| payable_detail_type_id          | tinyint unsigned                                                        |         | false    |                  |          | [reference_payable_detail_type](reference_payable_detail_type.md) |         |
| payee_currency_code             | char(3)                                                                 |         | false    |                  |          |                                                                   |         |
| vat_amount_payee_currency       | decimal(20,2)                                                           |         | false    |                  |          |                                                                   |         |
| vat_amount_vat_currency         | decimal(20,2)                                                           |         | false    |                  |          |                                                                   |         |
| vat_category                    | enum('gross_revenue','distribution_fee','closing_balance','commission') |         | true     |                  |          |                                                                   |         |
| vat_currency_code               | char(3)                                                                 |         | false    |                  |          |                                                                   |         |
| vat_rate                        | decimal(20,2)                                                           |         | false    |                  |          |                                                                   |         |
| wht_amount_payee_currency       | decimal(20,2)                                                           |         | true     |                  |          |                                                                   |         |
| wht_amount_vat_currency         | decimal(20,2)                                                           |         | true     |                  |          |                                                                   |         |
| wht_rate                        | decimal(20,2)                                                           |         | true     |                  |          |                                                                   |         |
| worksheet_tax_correction_vat_id | mediumint unsigned                                                      |         | false    | auto_increment   |          |                                                                   |         |

## Constraints

| Name                      | Type        | Definition                                                                                                       |
| ------------------------- | ----------- | ---------------------------------------------------------------------------------------------------------------- |
| PRIMARY                   | PRIMARY KEY | PRIMARY KEY (worksheet_tax_correction_vat_id)                                                                    |
| fk_tcv_account            | FOREIGN KEY | FOREIGN KEY (account_id) REFERENCES account (account_id)                                                         |
| fk_tcv_contract           | FOREIGN KEY | FOREIGN KEY (contract_id) REFERENCES contract (contract_id)                                                      |
| fk_tcv_ref_payable_detail | FOREIGN KEY | FOREIGN KEY (payable_detail_type_id) REFERENCES reference_payable_detail_type (reference_payable_detail_type_id) |
| fk_tcv_statement_period   | FOREIGN KEY | FOREIGN KEY (correction_statement_period_id) REFERENCES statement_period (statement_period_id)                   |

## Indexes

| Name                      | Definition                                                               |
| ------------------------- | ------------------------------------------------------------------------ |
| PRIMARY                   | PRIMARY KEY (worksheet_tax_correction_vat_id) USING BTREE                |
| fk_tcv_account            | KEY fk_tcv_account (account_id) USING BTREE                              |
| fk_tcv_contract           | KEY fk_tcv_contract (contract_id) USING BTREE                            |
| fk_tcv_ref_payable_detail | KEY fk_tcv_ref_payable_detail (payable_detail_type_id) USING BTREE       |
| fk_tcv_statement_period   | KEY fk_tcv_statement_period (correction_statement_period_id) USING BTREE |

## Relations

![er](worksheet_tax_correction_vat.svg)

---

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