# statement_attachment

## Description

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

```sql
CREATE TABLE `statement_attachment` (
  `statement_attachment_id` mediumint unsigned NOT NULL AUTO_INCREMENT,
  `account_id` mediumint unsigned NOT NULL,
  `subaccount_id` mediumint DEFAULT NULL,
  `contract_id` mediumint DEFAULT NULL,
  `statement_period_id` mediumint unsigned NOT NULL,
  `statement_period_ids` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `statement_attachment_status` enum('in_progress','complete','error','retry') COLLATE utf8mb4_general_ci NOT NULL,
  `failure_reason` enum('missing_tax_information','missing_bank_information','system_error') COLLATE utf8mb4_general_ci DEFAULT NULL,
  `statement_attachment_type` enum('distribution_fee_invoice','self_billing_invoice','revenue_detail','nr_performer_revenue','nr_label_revenue','statement_awal','statement_knr_performer','statement_knr_label','collection_summary_label','collection_summary_performer','publishing_detail','internal_upload','legacy_revenue_detail_full','legacy_revenue_detail_physical') COLLATE utf8mb4_general_ci NOT NULL,
  `invoice_number` varchar(180) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `file_location` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `file_type` enum('csv','pdf','xls','xlsx','png','jpg','doc','docx','txt') COLLATE utf8mb4_general_ci NOT NULL,
  `created_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,
  `created_at` datetime NOT NULL,
  `number_format` enum('us','eu') COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'us',
  PRIMARY KEY (`statement_attachment_id`),
  UNIQUE KEY `uidx_statement_attachment_invoice_number` (`invoice_number`),
  KEY `fk_statement_attachment_account` (`account_id`),
  KEY `fk_statement_attachment_statement_period` (`statement_period_id`),
  KEY `fk_statement_attachment_contract` (`contract_id`),
  CONSTRAINT `fk_statement_attachment_account` FOREIGN KEY (`account_id`) REFERENCES `account` (`account_id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `fk_statement_attachment_statement_period` FOREIGN KEY (`statement_period_id`) REFERENCES `statement_period` (`statement_period_id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) 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)                   |         |
| contract_id                 | mediumint                                                                                                                                                                                                                                                                                                                                         |         | true     |                  |                                                                                   | [contract](contract.md)                 |         |
| created_at                  | datetime                                                                                                                                                                                                                                                                                                                                          |         | false    |                  |                                                                                   |                                         |         |
| created_by                  | varchar(255)                                                                                                                                                                                                                                                                                                                                      |         | false    |                  |                                                                                   |                                         |         |
| failure_reason              | enum('missing_tax_information','missing_bank_information','system_error')                                                                                                                                                                                                                                                                         |         | true     |                  |                                                                                   |                                         |         |
| file_location               | varchar(255)                                                                                                                                                                                                                                                                                                                                      |         | true     |                  |                                                                                   |                                         |         |
| file_type                   | enum('csv','pdf','xls','xlsx','png','jpg','doc','docx','txt')                                                                                                                                                                                                                                                                                     |         | false    |                  |                                                                                   |                                         |         |
| invoice_number              | varchar(180)                                                                                                                                                                                                                                                                                                                                      |         | true     |                  |                                                                                   |                                         |         |
| number_format               | enum('us','eu')                                                                                                                                                                                                                                                                                                                                   | us      | false    |                  |                                                                                   |                                         |         |
| statement_attachment_id     | mediumint unsigned                                                                                                                                                                                                                                                                                                                                |         | false    | auto_increment   | [statement_attachment_archive_WAR-1131](statement_attachment_archive_WAR-1131.md) |                                         |         |
| statement_attachment_status | enum('in_progress','complete','error','retry')                                                                                                                                                                                                                                                                                                    |         | false    |                  |                                                                                   |                                         |         |
| statement_attachment_type   | enum('distribution_fee_invoice','self_billing_invoice','revenue_detail','nr_performer_revenue','nr_label_revenue','statement_awal','statement_knr_performer','statement_knr_label','collection_summary_label','collection_summary_performer','publishing_detail','internal_upload','legacy_revenue_detail_full','legacy_revenue_detail_physical') |         | false    |                  |                                                                                   |                                         |         |
| statement_period_id         | mediumint unsigned                                                                                                                                                                                                                                                                                                                                |         | false    |                  |                                                                                   | [statement_period](statement_period.md) |         |
| statement_period_ids        | varchar(255)                                                                                                                                                                                                                                                                                                                                      |         | true     |                  |                                                                                   |                                         |         |
| subaccount_id               | mediumint                                                                                                                                                                                                                                                                                                                                         |         | true     |                  |                                                                                   |                                         |         |

## Constraints

| Name                                     | Type        | Definition                                                                          |
| ---------------------------------------- | ----------- | ----------------------------------------------------------------------------------- |
| PRIMARY                                  | PRIMARY KEY | PRIMARY KEY (statement_attachment_id)                                               |
| fk_statement_attachment_account          | FOREIGN KEY | FOREIGN KEY (account_id) REFERENCES account (account_id)                            |
| fk_statement_attachment_statement_period | FOREIGN KEY | FOREIGN KEY (statement_period_id) REFERENCES statement_period (statement_period_id) |
| uidx_statement_attachment_invoice_number | UNIQUE      | UNIQUE KEY uidx_statement_attachment_invoice_number (invoice_number)                |

## Indexes

| Name                                     | Definition                                                                       |
| ---------------------------------------- | -------------------------------------------------------------------------------- |
| PRIMARY                                  | PRIMARY KEY (statement_attachment_id) USING BTREE                                |
| fk_statement_attachment_account          | KEY fk_statement_attachment_account (account_id) USING BTREE                     |
| fk_statement_attachment_contract         | KEY fk_statement_attachment_contract (contract_id) USING BTREE                   |
| fk_statement_attachment_statement_period | KEY fk_statement_attachment_statement_period (statement_period_id) USING BTREE   |
| uidx_statement_attachment_invoice_number | UNIQUE KEY uidx_statement_attachment_invoice_number (invoice_number) USING BTREE |

## Relations

![er](statement_attachment.svg)

---

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