# PartnerBankAccount

## Description

PartnerBankAccount is a child entity of BusinessPartner that stores the banking details required to execute financial transactions with that partner. Each record captures bank name, account holder name, account number, routing number, IBAN, SWIFT/BIC, and transaction currency. A partner may hold multiple bank accounts, and one account per partner may be designated as the default.

Bank account records can be created and maintained regardless of the partner's current lifecycle state (DRAFT, ACTIVE, or INACTIVE).

## Domain Model Definitions

### Model type

Standard

### Command Definitions

- [createPartnerBankAccount](../commands/CreatePartnerBankAccount.md) - Add a bank account to a partner
- [updatePartnerBankAccount](../commands/UpdatePartnerBankAccount.md) - Update bank account details
- [deletePartnerBankAccount](../commands/DeletePartnerBankAccount.md) - Remove a bank account from a partner
- [setDefaultPartnerBankAccount](../commands/SetDefaultPartnerBankAccount.md) - Designate a bank account as the default for a partner

### Query Definitions

- [GetPartnerBankAccount](../queries/GetPartnerBankAccount.md) - Retrieve a bank account by id
- [GetDefaultPartnerBankAccount](../queries/GetDefaultPartnerBankAccount.md) - Retrieve the default bank account for a partner
- [ListPartnerBankAccountsByPartner](../queries/ListPartnerBankAccountsByPartner.md) - List all bank accounts for a partner

### Models

- PartnerBankAccount

### Invariants

- `bankName` is required and must be non-empty
- `accountHolderName` is required and must be non-empty
- At least one of `accountNumber` or `iban` must be provided; both may be provided simultaneously
- `routingNumber` is optional (domestic routing conventions)
- `swiftBic` is optional (international transfers)
- `currencyId` must reference a valid, existing Currency from the primitives module
- Bank accounts can be added to a partner in any lifecycle state (DRAFT, ACTIVE, or INACTIVE)
- At most one bank account per partner can be designated as default at any time
- Marking a bank account as default automatically unsets the default flag on all other accounts for that partner
- The first bank account added to a partner is automatically designated as the default
- Removing the default bank account does not automatically promote another account; the partner has no default until one is explicitly designated
- Bank accounts are isolated per partner; accounts belonging to one partner are not visible on another

### Relationships

- **References BusinessPartner**: Each bank account belongs to exactly one BusinessPartner
- **References Currency**: Each bank account references a Currency from the primitives module
