# ledger_adjustment_detail

## Description

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

```sql
CREATE TABLE `ledger_adjustment_detail` (
  `ledger_adjustment_detail_id` mediumint unsigned NOT NULL AUTO_INCREMENT,
  `account_id` mediumint unsigned NOT NULL,
  `contract_id` mediumint unsigned DEFAULT NULL,
  `activity_statement_period_id` mediumint unsigned NOT NULL,
  `apply_to_statement_period_id` mediumint unsigned NOT NULL,
  `reference_adjustment_type_id` tinyint unsigned NOT NULL,
  `currency_code` char(3) COLLATE utf8mb4_general_ci NOT NULL,
  `amount` decimal(20,2) NOT NULL,
  `upc` varchar(20) COLLATE utf8mb4_general_ci NOT NULL,
  `distribution_type` enum('digital','physical') COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'digital',
  `note` varchar(180) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `created_by` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,
  `created_at` datetime NOT NULL,
  `last_modified_by` varchar(180) COLLATE utf8mb4_general_ci NOT NULL,
  `last_modified` datetime NOT NULL,
  PRIMARY KEY (`ledger_adjustment_detail_id`),
  KEY `fk_ledger_adjustment_detail_account` (`account_id`),
  KEY `fk_ledger_adjustment_detail_contract` (`contract_id`),
  KEY `fk_ledger_adjustment_detail_activity_statement_period` (`activity_statement_period_id`),
  KEY `fk_ledger_adjustment_detail_apply_to_statement_period` (`apply_to_statement_period_id`),
  KEY `fk_ledger_adjustment_type` (`reference_adjustment_type_id`),
  CONSTRAINT `fk_ledger_adjustment_detail_account` FOREIGN KEY (`account_id`) REFERENCES `account` (`account_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `fk_ledger_adjustment_detail_activity_statement_period` FOREIGN KEY (`activity_statement_period_id`) REFERENCES `statement_period` (`statement_period_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `fk_ledger_adjustment_detail_apply_to_statement_period` FOREIGN KEY (`apply_to_statement_period_id`) REFERENCES `statement_period` (`statement_period_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `fk_ledger_adjustment_detail_contract` FOREIGN KEY (`contract_id`) REFERENCES `contract` (`contract_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `fk_ledger_adjustment_type` FOREIGN KEY (`reference_adjustment_type_id`) REFERENCES `reference_adjustment_type` (`reference_adjustment_type_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 |
| ---------------------------- | -------------------------- | ------- | -------- | ---------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------- | ------- |
| account_id                   | mediumint unsigned         |         | false    |                  |                                                                                                                                                       | [account](account.md)                                     |         |
| activity_statement_period_id | mediumint unsigned         |         | false    |                  |                                                                                                                                                       | [statement_period](statement_period.md)                   |         |
| amount                       | decimal(20,2)              |         | false    |                  |                                                                                                                                                       |                                                           |         |
| apply_to_statement_period_id | mediumint unsigned         |         | false    |                  |                                                                                                                                                       | [statement_period](statement_period.md)                   |         |
| contract_id                  | mediumint unsigned         |         | true     |                  |                                                                                                                                                       | [contract](contract.md)                                   |         |
| created_at                   | datetime                   |         | false    |                  |                                                                                                                                                       |                                                           |         |
| created_by                   | varchar(180)               |         | false    |                  |                                                                                                                                                       |                                                           |         |
| currency_code                | char(3)                    |         | false    |                  |                                                                                                                                                       |                                                           |         |
| distribution_type            | enum('digital','physical') | digital | false    |                  |                                                                                                                                                       |                                                           |         |
| last_modified                | datetime                   |         | false    |                  |                                                                                                                                                       |                                                           |         |
| last_modified_by             | varchar(180)               |         | false    |                  |                                                                                                                                                       |                                                           |         |
| ledger_adjustment_detail_id  | mediumint unsigned         |         | false    | auto_increment   | [ledger_adjustment_adjustment_detail](ledger_adjustment_adjustment_detail.md) [ledger_adjustment_detail_applied](ledger_adjustment_detail_applied.md) |                                                           |         |
| note                         | varchar(180)               |         | true     |                  |                                                                                                                                                       |                                                           |         |
| reference_adjustment_type_id | tinyint unsigned           |         | false    |                  |                                                                                                                                                       | [reference_adjustment_type](reference_adjustment_type.md) |         |
| upc                          | varchar(20)                |         | false    |                  |                                                                                                                                                       |                                                           |         |

## Constraints

| Name                                                  | Type        | Definition                                                                                                     |
| ----------------------------------------------------- | ----------- | -------------------------------------------------------------------------------------------------------------- |
| PRIMARY                                               | PRIMARY KEY | PRIMARY KEY (ledger_adjustment_detail_id)                                                                      |
| fk_ledger_adjustment_detail_account                   | FOREIGN KEY | FOREIGN KEY (account_id) REFERENCES account (account_id)                                                       |
| fk_ledger_adjustment_detail_activity_statement_period | FOREIGN KEY | FOREIGN KEY (activity_statement_period_id) REFERENCES statement_period (statement_period_id)                   |
| fk_ledger_adjustment_detail_apply_to_statement_period | FOREIGN KEY | FOREIGN KEY (apply_to_statement_period_id) REFERENCES statement_period (statement_period_id)                   |
| fk_ledger_adjustment_detail_contract                  | FOREIGN KEY | FOREIGN KEY (contract_id) REFERENCES contract (contract_id)                                                    |
| fk_ledger_adjustment_type                             | FOREIGN KEY | FOREIGN KEY (reference_adjustment_type_id) REFERENCES reference_adjustment_type (reference_adjustment_type_id) |

## Indexes

| Name                                                  | Definition                                                                                           |
| ----------------------------------------------------- | ---------------------------------------------------------------------------------------------------- |
| PRIMARY                                               | PRIMARY KEY (ledger_adjustment_detail_id) USING BTREE                                                |
| fk_ledger_adjustment_detail_account                   | KEY fk_ledger_adjustment_detail_account (account_id) USING BTREE                                     |
| fk_ledger_adjustment_detail_activity_statement_period | KEY fk_ledger_adjustment_detail_activity_statement_period (activity_statement_period_id) USING BTREE |
| fk_ledger_adjustment_detail_apply_to_statement_period | KEY fk_ledger_adjustment_detail_apply_to_statement_period (apply_to_statement_period_id) USING BTREE |
| fk_ledger_adjustment_detail_contract                  | KEY fk_ledger_adjustment_detail_contract (contract_id) USING BTREE                                   |
| fk_ledger_adjustment_type                             | KEY fk_ledger_adjustment_type (reference_adjustment_type_id) USING BTREE                             |

## Relations

![er](ledger_adjustment_detail.svg)

---

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