dodil/erp-brick-ar

DODIL ERP brick: accounts receivable

src/brick_ar/domain/tax.py

"""The tax module's answer, as this brick holds it: a copy frozen on the document at issue. Invoicing never applies a rate."""
from dataclasses import dataclass, field
from decimal import Decimal
from typing import Optional


@dataclass(frozen=True)
class TaxedLine:
    line_no: int
    tax_code: str
    rate_pct: Decimal
    tax_amount: Decimal


@dataclass(frozen=True)
class TaxRowIn:
    tax_code: str
    rate_pct: Decimal
    net_amount: Decimal
    tax_amount: Decimal


@dataclass(frozen=True)
class TaxQuote:
    """compute(lines, bp_id, tax_point, currency): a code, rate and tax per line, the per-rate summary and the method
    that rounded them."""
    lines: tuple = ()
    summary: tuple = ()
    rounding_method: str = ""
    tax_point: Optional[object] = None


@dataclass
class TaxOutcome:
    """What asking tax came to: a quote, or the reason there is none (not installed, refused, down)."""
    quote: Optional[TaxQuote] = None
    reason: str = ""
    gates: list = field(default_factory=list)       # tax's own content gates [{gate, met, reason, fix}]