# DeletePartnerAddress

## Permission Scope

partnerDetail

## Overview

deletePartnerAddress removes an address from a business partner. Addresses that are currently referenced on transactions (e.g., sales orders, purchase orders) cannot be deleted to preserve data integrity. If the deleted address was the default for its type, no other address is automatically promoted to default.

## Business Rules

- Address must exist in the system
- Address cannot be deleted if it is referenced on existing transactions
- Deleting the default address does not auto-promote another address to default
- Deletion is permanent and cannot be undone

## Process Flow

```mermaid
flowchart TD
    A[Receive delete request] --> B{Address exists?}
    B -->|No| C[Return error: address not found]
    B -->|Yes| D{Address referenced on transactions?}
    D -->|Yes| E[Return error: address in use]
    D -->|No| F[Delete address record]
    F --> G[Return success]
```

## External Dependencies

- None

## Error Scenarios

- **ADDRESS_NOT_FOUND**: Specified address ID does not exist
- **ADDRESS_IN_USE**: Address is referenced on existing transactions and cannot be deleted

## Test Cases

- deletes an address
- returns error when address not found
- returns error when address is referenced on transactions
- deleting default does not promote another
