Skip to content

SpendPolicy

Configuration dataclass for spend governance rules.

paygraph.policy.SpendPolicy dataclass

Configuration for spend governance rules.

Attributes:

Name Type Description
max_transaction float

Maximum dollar amount allowed per transaction.

daily_budget float

Maximum total dollar amount allowed per calendar day.

allowed_vendors list[str] | None

If set, only vendors matching these names are permitted (case-insensitive substring match).

blocked_vendors list[str] | None

If set, vendors matching these names are always blocked (case-insensitive substring match).

allowed_mccs list[int] | None

Merchant Category Code allowlist (reserved for future use).

require_justification bool

Whether a justification string is required for every spend request.

Source code in src/paygraph/policy.py
@dataclass
class SpendPolicy:
    """Configuration for spend governance rules.

    Attributes:
        max_transaction: Maximum dollar amount allowed per transaction.
        daily_budget: Maximum total dollar amount allowed per calendar day.
        allowed_vendors: If set, only vendors matching these names are
            permitted (case-insensitive substring match).
        blocked_vendors: If set, vendors matching these names are always
            blocked (case-insensitive substring match).
        allowed_mccs: Merchant Category Code allowlist (reserved for future use).
        require_justification: Whether a justification string is required
            for every spend request.
    """

    max_transaction: float = 50.0
    daily_budget: float = 200.0
    allowed_vendors: list[str] | None = None
    blocked_vendors: list[str] | None = None
    allowed_mccs: list[int] | None = None
    require_justification: bool = True

paygraph.policy.PolicyResult dataclass

Result of a policy evaluation.

Attributes:

Name Type Description
approved bool

Whether the spend request passed all policy checks.

denial_reason str | None

Human-readable reason if the request was denied.

checks_passed list[str]

Names of policy checks that passed before denial (or all checks if approved).

Source code in src/paygraph/policy.py
@dataclass
class PolicyResult:
    """Result of a policy evaluation.

    Attributes:
        approved: Whether the spend request passed all policy checks.
        denial_reason: Human-readable reason if the request was denied.
        checks_passed: Names of policy checks that passed before denial
            (or all checks if approved).
    """

    approved: bool
    denial_reason: str | None = None
    checks_passed: list[str] = field(default_factory=list)