# ledger_adjustment

## Description

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

```sql
CREATE TABLE `ledger_adjustment` (
  `ledger_adjustment_id` mediumint unsigned NOT NULL AUTO_INCREMENT,
  `abacus_event_id` mediumint unsigned NOT NULL,
  `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,
  `adjustment_amount` decimal(20,2) NOT NULL,
  `adjustment_currency_code` char(3) COLLATE utf8mb4_general_ci NOT NULL,
  `note` mediumtext COLLATE utf8mb4_general_ci,
  `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_id`),
  KEY `fk_ledger_adjustment_abacus_event` (`abacus_event_id`),
  KEY `fk_ledger_adjustment_account` (`account_id`),
  KEY `fk_ledger_adjustment_contract` (`contract_id`),
  KEY `fk_ledger_adjustment_activity_statement_period` (`activity_statement_period_id`),
  KEY `fk_ledger_adjustment_applied_to_statement_period` (`apply_to_statement_period_id`),
  KEY `fk_ledger_adjustment_reference_adjustment_type` (`reference_adjustment_type_id`),
  CONSTRAINT `fk_ledger_adjustment_abacus_event` FOREIGN KEY (`abacus_event_id`) REFERENCES `abacus_event` (`abacus_event_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `fk_ledger_adjustment_account` FOREIGN KEY (`account_id`) REFERENCES `account` (`account_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `fk_ledger_adjustment_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_applied_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_contract` FOREIGN KEY (`contract_id`) REFERENCES `contract` (`contract_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `fk_ledger_adjustment_reference_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 |
| ---------------------------- | ------------------ | ------- | -------- | ---------------- | --------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------- | ------- |
| abacus_event_id              | mediumint unsigned |         | false    |                  |                                                                                                                                         | [abacus_event](abacus_event.md)                           |         |
| account_id                   | mediumint unsigned |         | false    |                  |                                                                                                                                         | [account](account.md)                                     |         |
| activity_statement_period_id | mediumint unsigned |         | false    |                  |                                                                                                                                         | [statement_period](statement_period.md)                   |         |
| adjustment_amount            | decimal(20,2)      |         | false    |                  |                                                                                                                                         |                                                           |         |
| adjustment_currency_code     | char(3)            |         | 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    |                  |                                                                                                                                         |                                                           |         |
| last_modified                | datetime           |         | false    |                  |                                                                                                                                         |                                                           |         |
| last_modified_by             | varchar(180)       |         | false    |                  |                                                                                                                                         |                                                           |         |
| ledger_adjustment_id         | mediumint unsigned |         | false    | auto_increment   | [ledger_adjustment_adjustment_detail](ledger_adjustment_adjustment_detail.md) [ledger_adjustment_applied](ledger_adjustment_applied.md) |                                                           |         |
| note                         | mediumtext         |         | true     |                  |                                                                                                                                         |                                                           |         |
| reference_adjustment_type_id | tinyint unsigned   |         | false    |                  |                                                                                                                                         | [reference_adjustment_type](reference_adjustment_type.md) |         |

## Constraints

| Name                                             | Type        | Definition                                                                                                     |
| ------------------------------------------------ | ----------- | -------------------------------------------------------------------------------------------------------------- |
| PRIMARY                                          | PRIMARY KEY | PRIMARY KEY (ledger_adjustment_id)                                                                             |
| fk_ledger_adjustment_abacus_event                | FOREIGN KEY | FOREIGN KEY (abacus_event_id) REFERENCES abacus_event (abacus_event_id)                                        |
| fk_ledger_adjustment_account                     | FOREIGN KEY | FOREIGN KEY (account_id) REFERENCES account (account_id)                                                       |
| fk_ledger_adjustment_activity_statement_period   | FOREIGN KEY | FOREIGN KEY (activity_statement_period_id) REFERENCES statement_period (statement_period_id)                   |
| fk_ledger_adjustment_applied_to_statement_period | FOREIGN KEY | FOREIGN KEY (apply_to_statement_period_id) REFERENCES statement_period (statement_period_id)                   |
| fk_ledger_adjustment_contract                    | FOREIGN KEY | FOREIGN KEY (contract_id) REFERENCES contract (contract_id)                                                    |
| fk_ledger_adjustment_reference_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_id) USING BTREE                                                  |
| fk_ledger_adjustment_abacus_event                | KEY fk_ledger_adjustment_abacus_event (abacus_event_id) USING BTREE                             |
| fk_ledger_adjustment_account                     | KEY fk_ledger_adjustment_account (account_id) USING BTREE                                       |
| fk_ledger_adjustment_activity_statement_period   | KEY fk_ledger_adjustment_activity_statement_period (activity_statement_period_id) USING BTREE   |
| fk_ledger_adjustment_applied_to_statement_period | KEY fk_ledger_adjustment_applied_to_statement_period (apply_to_statement_period_id) USING BTREE |
| fk_ledger_adjustment_contract                    | KEY fk_ledger_adjustment_contract (contract_id) USING BTREE                                     |
| fk_ledger_adjustment_reference_adjustment_type   | KEY fk_ledger_adjustment_reference_adjustment_type (reference_adjustment_type_id) USING BTREE   |

## Relations

![er](ledger_adjustment.svg)

---

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