# ActivateSalesPaymentTerm

## Permission Scope

salesPricing

## Overview

ActivateSalesPaymentTerm moves a draft SalesPaymentTerm into ACTIVE status so it can participate in downstream commercial processing.

## Business Rules

- Only DRAFT SalesPaymentTerm records may be activated.
- At least one schedule line is required.
- Percentage-based schedules must total 100 percent.
- Discount cutoff must not fall after the final due date.

## Process Flow

```mermaid
flowchart TD
    A[Receive activate request] --> B[Load SalesPaymentTerm]
    B --> C{Status is DRAFT?}
    C -->|No| D[Return INVALID_SALESPAYMENTTERM_STATUS]
    C -->|Yes| E[Validate activation prerequisites]
    E --> F[Set status to ACTIVE]
    F --> G[Return activated SalesPaymentTerm]
```

## External Dependencies

- [organization::GetCompany](../../../organization/docs/queries/GetCompany.md) - Validate company scope for the term.

## Error Scenarios

- **SALESPAYMENTTERM_NOT_FOUND**: Referenced SalesPaymentTerm does not exist
- **INVALID_SALESPAYMENTTERM_STATUS**: SalesPaymentTerm status does not allow this operation
- **INVALID_PAYMENT_SCHEDULE**: Schedule lines do not satisfy payment-term rules.

## Test Cases

- activates a draft SalesPaymentTerm
- throws when SalesPaymentTerm is not in DRAFT status
- throws when SalesPaymentTerm does not exist
- throws on invalid payment schedule
