"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""

from __future__ import annotations
from abbyy_document_ai.types import BaseModel
from datetime import date
import pydantic
from typing import List, Optional
from typing_extensions import Annotated, NotRequired, TypedDict


class BillingPeriodTypedDict(TypedDict):
    start_date: NotRequired[date]
    r"""The billing period start date"""
    end_date: NotRequired[date]
    r"""The billing period end date"""


class BillingPeriod(BaseModel):
    start_date: Annotated[Optional[date], pydantic.Field(alias="startDate")] = None
    r"""The billing period start date"""

    end_date: Annotated[Optional[date], pydantic.Field(alias="endDate")] = None
    r"""The billing period end date"""


class IssuerTypedDict(TypedDict):
    name: NotRequired[str]
    r"""Name of the company providing the services"""
    address: NotRequired[str]
    r"""Address of the company providing the services"""
    tax_id: NotRequired[str]
    r"""Tax ID of the company providing the services"""


class Issuer(BaseModel):
    name: Optional[str] = None
    r"""Name of the company providing the services"""

    address: Optional[str] = None
    r"""Address of the company providing the services"""

    tax_id: Annotated[Optional[str], pydantic.Field(alias="taxId")] = None
    r"""Tax ID of the company providing the services"""


class UtilityBillFieldsCustomerTypedDict(TypedDict):
    account_number: NotRequired[str]
    r"""Customer account number"""
    name: NotRequired[str]
    r"""Customer name"""
    customer_address: NotRequired[str]
    r"""Customer billing address"""
    service_address: NotRequired[str]
    r"""Address where the service was performed"""
    tax_id: NotRequired[str]
    r"""Customer tax ID"""


class UtilityBillFieldsCustomer(BaseModel):
    account_number: Annotated[Optional[str], pydantic.Field(alias="accountNumber")] = (
        None
    )
    r"""Customer account number"""

    name: Optional[str] = None
    r"""Customer name"""

    customer_address: Annotated[
        Optional[str], pydantic.Field(alias="customerAddress")
    ] = None
    r"""Customer billing address"""

    service_address: Annotated[
        Optional[str], pydantic.Field(alias="serviceAddress")
    ] = None
    r"""Address where the service was performed"""

    tax_id: Annotated[Optional[str], pydantic.Field(alias="taxId")] = None
    r"""Customer tax ID"""


class RemitToTypedDict(TypedDict):
    name: NotRequired[str]
    r"""Name of the business unit or payment recipient"""
    address: NotRequired[str]
    r"""Address of the business unit or payment recipient"""


class RemitTo(BaseModel):
    name: Optional[str] = None
    r"""Name of the business unit or payment recipient"""

    address: Optional[str] = None
    r"""Address of the business unit or payment recipient"""


class UtilityBillFieldsLineItemsTypedDict(TypedDict):
    billing_number: NotRequired[str]
    r"""The customer account number used to identify the account"""
    description: NotRequired[str]
    r"""A description of the line item"""
    quantity: NotRequired[float]
    r"""The number of units purchased"""
    unit_price: NotRequired[float]
    r"""The price of one item"""
    uom: NotRequired[str]
    r"""The unit of measurement for the line items"""
    amount: NotRequired[float]
    r"""The payment amount"""


class UtilityBillFieldsLineItems(BaseModel):
    billing_number: Annotated[Optional[str], pydantic.Field(alias="billingNumber")] = (
        None
    )
    r"""The customer account number used to identify the account"""

    description: Optional[str] = None
    r"""A description of the line item"""

    quantity: Optional[float] = None
    r"""The number of units purchased"""

    unit_price: Annotated[Optional[float], pydantic.Field(alias="unitPrice")] = None
    r"""The price of one item"""

    uom: Optional[str] = None
    r"""The unit of measurement for the line items"""

    amount: Optional[float] = None
    r"""The payment amount"""


class AdjustmentsTypedDict(TypedDict):
    adjustments: NotRequired[float]
    r"""Amount of the adjustment"""


class Adjustments(BaseModel):
    adjustments: Optional[float] = None
    r"""Amount of the adjustment"""


class UtilityBillFieldsTypedDict(TypedDict):
    r"""Fields extracted from a utility bill"""

    billing_period: NotRequired[BillingPeriodTypedDict]
    bill_date: NotRequired[date]
    r"""The date on which the bill was issued"""
    bill_number: NotRequired[str]
    r"""The bill number (also sometimes named Invoice Number)"""
    issuer: NotRequired[IssuerTypedDict]
    customer: NotRequired[UtilityBillFieldsCustomerTypedDict]
    remit_to: NotRequired[RemitToTypedDict]
    amount_due: NotRequired[float]
    r"""The total amount due for the billing period"""
    current_charges: NotRequired[float]
    r"""Charges for the current period"""
    currency: NotRequired[str]
    r"""The currency of the amount due"""
    line_items: NotRequired[List[UtilityBillFieldsLineItemsTypedDict]]
    previous_balance: NotRequired[float]
    r"""The balance for the previous billing period"""
    last_payment: NotRequired[float]
    r"""The payment made for the previous billing period"""
    balance_forward: NotRequired[float]
    r"""The balance brought forward from the previous billing period"""
    due_date: NotRequired[date]
    r"""The bill due date"""
    amount_after_due_date: NotRequired[float]
    r"""The amount charged if the payment is made after the due date"""
    late_charge: NotRequired[float]
    r"""Additional charges levied if payment is made after the due date"""
    penalties: NotRequired[float]
    r"""Charges levied on unpaid amounts for the billing period"""
    adjustments: NotRequired[List[AdjustmentsTypedDict]]
    r"""Payment adjustments"""


class UtilityBillFields(BaseModel):
    r"""Fields extracted from a utility bill"""

    billing_period: Annotated[
        Optional[BillingPeriod], pydantic.Field(alias="billingPeriod")
    ] = None

    bill_date: Annotated[Optional[date], pydantic.Field(alias="billDate")] = None
    r"""The date on which the bill was issued"""

    bill_number: Annotated[Optional[str], pydantic.Field(alias="billNumber")] = None
    r"""The bill number (also sometimes named Invoice Number)"""

    issuer: Optional[Issuer] = None

    customer: Optional[UtilityBillFieldsCustomer] = None

    remit_to: Annotated[Optional[RemitTo], pydantic.Field(alias="remitTo")] = None

    amount_due: Annotated[Optional[float], pydantic.Field(alias="amountDue")] = None
    r"""The total amount due for the billing period"""

    current_charges: Annotated[
        Optional[float], pydantic.Field(alias="currentCharges")
    ] = None
    r"""Charges for the current period"""

    currency: Optional[str] = None
    r"""The currency of the amount due"""

    line_items: Annotated[
        Optional[List[UtilityBillFieldsLineItems]], pydantic.Field(alias="lineItems")
    ] = None

    previous_balance: Annotated[
        Optional[float], pydantic.Field(alias="previousBalance")
    ] = None
    r"""The balance for the previous billing period"""

    last_payment: Annotated[Optional[float], pydantic.Field(alias="lastPayment")] = None
    r"""The payment made for the previous billing period"""

    balance_forward: Annotated[
        Optional[float], pydantic.Field(alias="balanceForward")
    ] = None
    r"""The balance brought forward from the previous billing period"""

    due_date: Annotated[Optional[date], pydantic.Field(alias="dueDate")] = None
    r"""The bill due date"""

    amount_after_due_date: Annotated[
        Optional[float], pydantic.Field(alias="amountAfterDueDate")
    ] = None
    r"""The amount charged if the payment is made after the due date"""

    late_charge: Annotated[Optional[float], pydantic.Field(alias="lateCharge")] = None
    r"""Additional charges levied if payment is made after the due date"""

    penalties: Optional[float] = None
    r"""Charges levied on unpaid amounts for the billing period"""

    adjustments: Optional[List[Adjustments]] = None
    r"""Payment adjustments"""
