# historical_contract_advance

## Description

Holds historical advanced payment information.

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

```sql
CREATE TABLE `historical_contract_advance` (
  `id` int NOT NULL AUTO_INCREMENT COMMENT 'Primary key.',
  `oa_advance_id` int NOT NULL COMMENT 'Historical Orchard Admin advance payment ID.',
  `oa_contract_id` int NOT NULL COMMENT 'Orchard Admin contract id this advance is associated with.',
  `account_id` int NOT NULL COMMENT 'Abacus and Orchard Admin account id this advance is associated with.',
  `amount` double NOT NULL COMMENT 'Amount of advance.',
  `currency_id` smallint unsigned NOT NULL COMMENT 'Foreign key to currencies table.',
  `currency` varchar(3) NOT NULL COMMENT 'Currency code for the advance amount.',
  `due_type` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'Indicates how the advance is due.',
  `date_paid` date DEFAULT NULL COMMENT 'Date the advance is paid.',
  `exchange_rate` float DEFAULT NULL COMMENT 'Exchange Rate in decimal between 0 and 1',
  `description` text COMMENT 'Description of the advance payment.',
  `apply_to_period_id` smallint unsigned DEFAULT NULL COMMENT 'The period the advance is applied to.',
  PRIMARY KEY (`id`),
  KEY `account_id` (`account_id`)
) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb3 COMMENT='Holds historical advanced payment information.'
```

</details>

## Columns

| Name               | Type              | Default | Nullable | Extra Definition | Children | Parents               | Comment                                                              |
| ------------------ | ----------------- | ------- | -------- | ---------------- | -------- | --------------------- | -------------------------------------------------------------------- |
| account_id         | int               |         | false    |                  |          | [account](account.md) | Abacus and Orchard Admin account id this advance is associated with. |
| amount             | double            |         | false    |                  |          |                       | Amount of advance.                                                   |
| apply_to_period_id | smallint unsigned |         | true     |                  |          |                       | The period the advance is applied to.                                |
| currency           | varchar(3)        |         | false    |                  |          |                       | Currency code for the advance amount.                                |
| currency_id        | smallint unsigned |         | false    |                  |          |                       | Foreign key to currencies table.                                     |
| date_paid          | date              |         | true     |                  |          |                       | Date the advance is paid.                                            |
| description        | text              |         | true     |                  |          |                       | Description of the advance payment.                                  |
| due_type           | varchar(100)      |         | false    |                  |          |                       | Indicates how the advance is due.                                    |
| exchange_rate      | float             |         | true     |                  |          |                       | Exchange Rate in decimal between 0 and 1                             |
| id                 | int               |         | false    | auto_increment   |          |                       | Primary key.                                                         |
| oa_advance_id      | int               |         | false    |                  |          |                       | Historical Orchard Admin advance payment ID.                         |
| oa_contract_id     | int               |         | false    |                  |          |                       | Orchard Admin contract id this advance is associated with.           |

## Constraints

| Name    | Type        | Definition       |
| ------- | ----------- | ---------------- |
| PRIMARY | PRIMARY KEY | PRIMARY KEY (id) |

## Indexes

| Name       | Definition                              |
| ---------- | --------------------------------------- |
| PRIMARY    | PRIMARY KEY (id) USING BTREE            |
| account_id | KEY account_id (account_id) USING BTREE |

## Relations

![er](historical_contract_advance.svg)

---

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