# PartnerRole

## Description

PartnerRole is a child entity that assigns a role classification (CUSTOMER or SUPPLIER) to a business partner. A single partner can hold multiple roles simultaneously — for example, both CUSTOMER and SUPPLIER — without record duplication. Role assignment is additive and follows the SAP unified Business Partner model.

Roles can only be assigned to or removed from ACTIVE partners. A partner with no roles is a valid state.

## Domain Model Definitions

### Model type

Standard

### Command Definitions

- [assignRoleToPartner](../commands/AssignRoleToPartner.md) - Assign a CUSTOMER or SUPPLIER role to an ACTIVE partner
- [removeRoleFromPartner](../commands/RemoveRoleFromPartner.md) - Remove a role from an ACTIVE partner

### Query Definitions

- [GetPartnerRole](../queries/GetPartnerRole.md) - Retrieve a role assignment by partnerId and role
- [ListPartnersByRole](../queries/ListPartnersByRole.md) - List all partners holding a specified role

### Models

- PartnerRole

### Invariants

- Role must be one of CUSTOMER or SUPPLIER
- The combination of (partnerId, role) must be unique — no duplicate role assignments
- Roles can only be assigned to or removed from ACTIVE partners; assigning or removing a role on a DRAFT or INACTIVE partner is rejected
- Assigning a role that is already held is idempotent — no error, no duplicate
- Removing a role that is not held is idempotent — no error
- A partner with no roles assigned is a valid state
- Role assignment does not modify any other partner fields (name, status, identifiers)
- Partners can be filtered by role; a partner holding both roles appears in results for both CUSTOMER and SUPPLIER queries

### Relationships

- **References BusinessPartner**: Each role assignment belongs to exactly one BusinessPartner
