# accounting_period

## Description

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

```sql
CREATE TABLE `accounting_period` (
  `accounting_period_id` smallint unsigned NOT NULL AUTO_INCREMENT,
  `statement_period_id` mediumint unsigned NOT NULL,
  `accounting_period_name` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `accounting_period_status` enum('open','locked','closed') COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'open',
  `contract_type` enum('distribution','legacy_distribution','neighbouring_rights') COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'distribution',
  `closed_date` datetime DEFAULT NULL,
  `is_visible` tinyint(1) NOT NULL DEFAULT '1',
  `visible_reason` varchar(50) 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 (`accounting_period_id`),
  KEY `fk_statement_period_acct_period` (`statement_period_id`),
  CONSTRAINT `fk_statement_period_acct_period` FOREIGN KEY (`statement_period_id`) REFERENCES `statement_period` (`statement_period_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `chk_is_visible_value` CHECK ((`is_visible` in (false,true)))
) 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 |
| ------------------------ | ---------------------------------------------------------------- | ------------ | -------- | ---------------- | ----------------------------------------------------------------------------------------------------------------------- | --------------------------------------- | ------- |
| accounting_period_id     | smallint unsigned                                                |              | false    | auto_increment   | [accounting_period_report](accounting_period_report.md) [accounting_run](accounting_run.md) [sales_file](sales_file.md) |                                         |         |
| accounting_period_name   | varchar(255)                                                     |              | true     |                  |                                                                                                                         |                                         |         |
| accounting_period_status | enum('open','locked','closed')                                   | open         | false    |                  |                                                                                                                         |                                         |         |
| closed_date              | datetime                                                         |              | true     |                  |                                                                                                                         |                                         |         |
| contract_type            | enum('distribution','legacy_distribution','neighbouring_rights') | distribution | false    |                  |                                                                                                                         |                                         |         |
| created_at               | datetime                                                         |              | false    |                  |                                                                                                                         |                                         |         |
| created_by               | varchar(255)                                                     |              | false    |                  |                                                                                                                         |                                         |         |
| is_visible               | tinyint(1)                                                       | 1            | false    |                  |                                                                                                                         |                                         |         |
| last_modified            | datetime                                                         |              | false    |                  |                                                                                                                         |                                         |         |
| last_modified_by         | varchar(255)                                                     |              | false    |                  |                                                                                                                         |                                         |         |
| statement_period_id      | mediumint unsigned                                               |              | false    |                  |                                                                                                                         | [statement_period](statement_period.md) |         |
| visible_reason           | varchar(50)                                                      |              | true     |                  |                                                                                                                         |                                         |         |

## Constraints

| Name                            | Type        | Definition                                                                          |
| ------------------------------- | ----------- | ----------------------------------------------------------------------------------- |
| PRIMARY                         | PRIMARY KEY | PRIMARY KEY (accounting_period_id)                                                  |
| chk_is_visible_value            | CHECK       | CHECK ((`is_visible` in (false,true)))                                              |
| fk_statement_period_acct_period | FOREIGN KEY | FOREIGN KEY (statement_period_id) REFERENCES statement_period (statement_period_id) |

## Indexes

| Name                            | Definition                                                            |
| ------------------------------- | --------------------------------------------------------------------- |
| PRIMARY                         | PRIMARY KEY (accounting_period_id) USING BTREE                        |
| fk_statement_period_acct_period | KEY fk_statement_period_acct_period (statement_period_id) USING BTREE |

## Relations

![er](accounting_period.svg)

---

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