# GetDefaultPartnerAddress

## Overview

GetDefaultPartnerAddress retrieves the default address for a partner and address type. This is used by downstream modules (AP, order management, shipping) to resolve the relevant default address for a given business partner.

## Business Rules

- Accepts `{ partnerId, addressType }` as input — retrieves the address with isDefault=true for the given partner and type
- Returns the PartnerAddress record where isDefault is true for the specified address type
- At most one address per partner per address type can be marked as default
- When no default address exists for the requested type, returns an error — the caller must either set a default or select an address explicitly
- When the partner has no addresses of the given type, returns an error indicating no address of that type exists

## Process Flow

```mermaid
flowchart TD
    A[Receive input] --> B[SELECT from PartnerAddress where partnerId = input.partnerId AND addressType = input.addressType AND isDefault = true]
    B --> C{Default address found?}
    C -->|Yes| D[Return address record]
    C -->|No| E{Any address of this type exists?}
    E -->|Yes| F[Return error: no default set — caller must select explicitly]
    E -->|No| G[Return error: no address of this type exists]
```

## External Dependencies

- None

## Error Scenarios

- **NO_DEFAULT_ADDRESS**: Addresses of the requested type exist for the partner, but none is marked as default — the caller must set a default or select an address explicitly
- **NO_ADDRESS_OF_TYPE**: The partner has no addresses of the requested address type

## Test Cases

- returns default address when one exists
- returns error when addresses of the type exist but no default is set
- returns error when partner has no addresses of the given type
