# payment_group_payment_account

## Description

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

```sql
CREATE TABLE `payment_group_payment_account` (
  `payment_group_payment_account_id` mediumint unsigned NOT NULL AUTO_INCREMENT,
  `payment_group_payment_id` mediumint unsigned NOT NULL,
  `prior_payment_group_payment_id` mediumint unsigned DEFAULT NULL,
  `account_id` mediumint unsigned NOT NULL,
  `payoneer_program_id` int unsigned NOT NULL,
  `last_statement_period_id` mediumint unsigned DEFAULT NULL,
  `current_statement_period_id` mediumint unsigned NOT NULL,
  `currency_code` char(3) COLLATE utf8mb4_general_ci NOT NULL,
  `last_payment` decimal(20,2) NOT NULL,
  `contracts_payable` json DEFAULT NULL,
  `current_balance` decimal(20,2) NOT NULL,
  `tax_withholding` decimal(20,2) DEFAULT NULL,
  `vat_amount` decimal(20,2) DEFAULT NULL,
  `balance_after_tax` decimal(20,2) NOT NULL,
  `note` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `created_at` datetime NOT NULL,
  `created_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,
  `last_modified` datetime NOT NULL,
  `last_modified_by` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,
  `deleted_at` datetime DEFAULT NULL,
  `deleted_by` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
  PRIMARY KEY (`payment_group_payment_account_id`),
  UNIQUE KEY `uidx_group_payment_account` (`payment_group_payment_id`,`account_id`),
  KEY `idx_group_payment_id` (`payment_group_payment_id`),
  KEY `idx_account_id` (`account_id`),
  KEY `fk_payment_account_reference_payoneer_program` (`payoneer_program_id`),
  KEY `fk_payment_account_last_statement_period` (`last_statement_period_id`),
  KEY `fk_payment_account_current_statement_period` (`current_statement_period_id`),
  CONSTRAINT `fk_group_account_account` FOREIGN KEY (`account_id`) REFERENCES `account` (`account_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `fk_group_account_group_payment` FOREIGN KEY (`payment_group_payment_id`) REFERENCES `payment_group_payment` (`payment_group_payment_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `fk_payment_account_current_statement_period` FOREIGN KEY (`current_statement_period_id`) REFERENCES `statement_period` (`statement_period_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `fk_payment_account_last_statement_period` FOREIGN KEY (`last_statement_period_id`) REFERENCES `statement_period` (`statement_period_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `fk_payment_account_reference_payoneer_program` FOREIGN KEY (`payoneer_program_id`) REFERENCES `reference_payoneer_program` (`payoneer_program_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)                                       |         |
| balance_after_tax                | decimal(20,2)      |         | false    |                  |                                                                                                                                                               |                                                             |         |
| contracts_payable                | json               |         | true     |                  |                                                                                                                                                               |                                                             |         |
| created_at                       | datetime           |         | false    |                  |                                                                                                                                                               |                                                             |         |
| created_by                       | varchar(255)       |         | false    |                  |                                                                                                                                                               |                                                             |         |
| currency_code                    | char(3)            |         | false    |                  |                                                                                                                                                               |                                                             |         |
| current_balance                  | decimal(20,2)      |         | false    |                  |                                                                                                                                                               |                                                             |         |
| current_statement_period_id      | mediumint unsigned |         | false    |                  |                                                                                                                                                               | [statement_period](statement_period.md)                     |         |
| deleted_at                       | datetime           |         | true     |                  |                                                                                                                                                               |                                                             |         |
| deleted_by                       | varchar(255)       |         | true     |                  |                                                                                                                                                               |                                                             |         |
| last_modified                    | datetime           |         | false    |                  |                                                                                                                                                               |                                                             |         |
| last_modified_by                 | varchar(255)       |         | false    |                  |                                                                                                                                                               |                                                             |         |
| last_payment                     | decimal(20,2)      |         | false    |                  |                                                                                                                                                               |                                                             |         |
| last_statement_period_id         | mediumint unsigned |         | true     |                  |                                                                                                                                                               | [statement_period](statement_period.md)                     |         |
| note                             | varchar(255)       |         | true     |                  |                                                                                                                                                               |                                                             |         |
| payment_group_payment_account_id | mediumint unsigned |         | false    | auto_increment   | [payment_group_payment_account_detail](payment_group_payment_account_detail.md) [payment_group_payment_batch_account](payment_group_payment_batch_account.md) |                                                             |         |
| payment_group_payment_id         | mediumint unsigned |         | false    |                  |                                                                                                                                                               | [payment_group_payment](payment_group_payment.md)           |         |
| payoneer_program_id              | int unsigned       |         | false    |                  |                                                                                                                                                               | [reference_payoneer_program](reference_payoneer_program.md) |         |
| prior_payment_group_payment_id   | mediumint unsigned |         | true     |                  |                                                                                                                                                               |                                                             |         |
| tax_withholding                  | decimal(20,2)      |         | true     |                  |                                                                                                                                                               |                                                             |         |
| vat_amount                       | decimal(20,2)      |         | true     |                  |                                                                                                                                                               |                                                             |         |

## Constraints

| Name                                          | Type        | Definition                                                                                         |
| --------------------------------------------- | ----------- | -------------------------------------------------------------------------------------------------- |
| PRIMARY                                       | PRIMARY KEY | PRIMARY KEY (payment_group_payment_account_id)                                                     |
| fk_group_account_account                      | FOREIGN KEY | FOREIGN KEY (account_id) REFERENCES account (account_id)                                           |
| fk_group_account_group_payment                | FOREIGN KEY | FOREIGN KEY (payment_group_payment_id) REFERENCES payment_group_payment (payment_group_payment_id) |
| fk_payment_account_current_statement_period   | FOREIGN KEY | FOREIGN KEY (current_statement_period_id) REFERENCES statement_period (statement_period_id)        |
| fk_payment_account_last_statement_period      | FOREIGN KEY | FOREIGN KEY (last_statement_period_id) REFERENCES statement_period (statement_period_id)           |
| fk_payment_account_reference_payoneer_program | FOREIGN KEY | FOREIGN KEY (payoneer_program_id) REFERENCES reference_payoneer_program (payoneer_program_id)      |
| uidx_group_payment_account                    | UNIQUE      | UNIQUE KEY uidx_group_payment_account (payment_group_payment_id, account_id)                       |

## Indexes

| Name                                          | Definition                                                                                |
| --------------------------------------------- | ----------------------------------------------------------------------------------------- |
| PRIMARY                                       | PRIMARY KEY (payment_group_payment_account_id) USING BTREE                                |
| fk_payment_account_current_statement_period   | KEY fk_payment_account_current_statement_period (current_statement_period_id) USING BTREE |
| fk_payment_account_last_statement_period      | KEY fk_payment_account_last_statement_period (last_statement_period_id) USING BTREE       |
| fk_payment_account_reference_payoneer_program | KEY fk_payment_account_reference_payoneer_program (payoneer_program_id) USING BTREE       |
| idx_account_id                                | KEY idx_account_id (account_id) USING BTREE                                               |
| idx_group_payment_id                          | KEY idx_group_payment_id (payment_group_payment_id) USING BTREE                           |
| uidx_group_payment_account                    | UNIQUE KEY uidx_group_payment_account (payment_group_payment_id, account_id) USING BTREE  |

## Relations

![er](payment_group_payment_account.svg)

---

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