# ledger_accounting_run_balance

## Description

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

```sql
CREATE TABLE `ledger_accounting_run_balance` (
  `ledger_accounting_run_balance_id` mediumint unsigned NOT NULL AUTO_INCREMENT,
  `accounting_run_id` mediumint unsigned NOT NULL,
  `abacus_event_id` mediumint unsigned NOT NULL,
  `contract_id` mediumint unsigned NOT NULL,
  `currency_code` char(3) NOT NULL,
  `total_gross_revenue_amount` decimal(20,2) DEFAULT NULL,
  `total_net_revenue_amount` decimal(20,2) DEFAULT NULL,
  `mechanical_deduction_total` decimal(20,2) DEFAULT NULL,
  `mechanical_deduction_admin_fee_total` decimal(20,2) DEFAULT NULL,
  `adjusted_net_revenue` decimal(20,2) NOT NULL,
  `distribution_fee` decimal(20,2) 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,
  PRIMARY KEY (`ledger_accounting_run_balance_id`),
  KEY `fk_accounting_run_ledger` (`accounting_run_id`),
  KEY `fk_abacus_event_ledger` (`abacus_event_id`),
  KEY `fk_contract_ledger` (`contract_id`),
  CONSTRAINT `fk_abacus_event_ledger` FOREIGN KEY (`abacus_event_id`) REFERENCES `abacus_event` (`abacus_event_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `fk_accounting_run_ledger` FOREIGN KEY (`accounting_run_id`) REFERENCES `accounting_run` (`accounting_run_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `fk_contract_ledger` FOREIGN KEY (`contract_id`) REFERENCES `contract` (`contract_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 |
| ------------------------------------ | ------------------ | ------- | -------- | ---------------- | -------- | ----------------------------------- | ------- |
| abacus_event_id                      | mediumint unsigned |         | false    |                  |          | [abacus_event](abacus_event.md)     |         |
| accounting_run_id                    | mediumint unsigned |         | false    |                  |          | [accounting_run](accounting_run.md) |         |
| adjusted_net_revenue                 | decimal(20,2)      |         | false    |                  |          |                                     |         |
| contract_id                          | mediumint unsigned |         | false    |                  |          | [contract](contract.md)             |         |
| created_at                           | datetime           |         | false    |                  |          |                                     |         |
| created_by                           | varchar(255)       |         | false    |                  |          |                                     |         |
| currency_code                        | char(3)            |         | false    |                  |          |                                     |         |
| distribution_fee                     | decimal(20,2)      |         | true     |                  |          |                                     |         |
| last_modified                        | datetime           |         | false    |                  |          |                                     |         |
| last_modified_by                     | varchar(255)       |         | false    |                  |          |                                     |         |
| ledger_accounting_run_balance_id     | mediumint unsigned |         | false    | auto_increment   |          |                                     |         |
| mechanical_deduction_admin_fee_total | decimal(20,2)      |         | true     |                  |          |                                     |         |
| mechanical_deduction_total           | decimal(20,2)      |         | true     |                  |          |                                     |         |
| total_gross_revenue_amount           | decimal(20,2)      |         | true     |                  |          |                                     |         |
| total_net_revenue_amount             | decimal(20,2)      |         | true     |                  |          |                                     |         |

## Constraints

| Name                     | Type        | Definition                                                                    |
| ------------------------ | ----------- | ----------------------------------------------------------------------------- |
| PRIMARY                  | PRIMARY KEY | PRIMARY KEY (ledger_accounting_run_balance_id)                                |
| fk_abacus_event_ledger   | FOREIGN KEY | FOREIGN KEY (abacus_event_id) REFERENCES abacus_event (abacus_event_id)       |
| fk_accounting_run_ledger | FOREIGN KEY | FOREIGN KEY (accounting_run_id) REFERENCES accounting_run (accounting_run_id) |
| fk_contract_ledger       | FOREIGN KEY | FOREIGN KEY (contract_id) REFERENCES contract (contract_id)                   |

## Indexes

| Name                     | Definition                                                   |
| ------------------------ | ------------------------------------------------------------ |
| PRIMARY                  | PRIMARY KEY (ledger_accounting_run_balance_id) USING BTREE   |
| fk_abacus_event_ledger   | KEY fk_abacus_event_ledger (abacus_event_id) USING BTREE     |
| fk_accounting_run_ledger | KEY fk_accounting_run_ledger (accounting_run_id) USING BTREE |
| fk_contract_ledger       | KEY fk_contract_ledger (contract_id) USING BTREE             |

## Relations

![er](ledger_accounting_run_balance.svg)

---

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