"""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 BusinessUnitTypedDict(TypedDict):
    r"""Business Unit (invoice recipient) details"""

    name: NotRequired[str]
    r"""The name of the business unit (invoice recipient)"""
    tax_id: NotRequired[str]
    r"""The tax payer registration number"""
    address: NotRequired[str]
    r"""The address of the business unit (invoice recipient). Used when no BusinessUnits data catalog is used or business unit not found in catalog."""
    country: NotRequired[str]
    r"""The country of the business unit (invoice recipient)"""
    state: NotRequired[str]
    r"""The state of the business unit (invoice recipient)"""
    state_or_province: NotRequired[str]
    r"""The state or province of the business unit (invoice recipient)"""
    city: NotRequired[str]
    r"""The city of the business unit (invoice recipient)"""
    street: NotRequired[str]
    r"""The street address of the business unit (invoice recipient)"""
    postal_code: NotRequired[str]
    r"""The postal code of the business unit (invoice recipient)"""
    zip_code: NotRequired[str]
    r"""The ZIP code of the business unit (invoice recipient)"""
    id: NotRequired[str]
    r"""The unique identifier of the business unit in an external system"""


class BusinessUnit(BaseModel):
    r"""Business Unit (invoice recipient) details"""

    name: Optional[str] = None
    r"""The name of the business unit (invoice recipient)"""

    tax_id: Annotated[Optional[str], pydantic.Field(alias="taxId")] = None
    r"""The tax payer registration number"""

    address: Optional[str] = None
    r"""The address of the business unit (invoice recipient). Used when no BusinessUnits data catalog is used or business unit not found in catalog."""

    country: Optional[str] = None
    r"""The country of the business unit (invoice recipient)"""

    state: Optional[str] = None
    r"""The state of the business unit (invoice recipient)"""

    state_or_province: Annotated[
        Optional[str], pydantic.Field(alias="stateOrProvince")
    ] = None
    r"""The state or province of the business unit (invoice recipient)"""

    city: Optional[str] = None
    r"""The city of the business unit (invoice recipient)"""

    street: Optional[str] = None
    r"""The street address of the business unit (invoice recipient)"""

    postal_code: Annotated[Optional[str], pydantic.Field(alias="postalCode")] = None
    r"""The postal code of the business unit (invoice recipient)"""

    zip_code: Annotated[Optional[str], pydantic.Field(alias="zipCode")] = None
    r"""The ZIP code of the business unit (invoice recipient)"""

    id: Optional[str] = None
    r"""The unique identifier of the business unit in an external system"""


class VendorTypedDict(TypedDict):
    r"""Vendor details"""

    name: NotRequired[str]
    r"""The vendor's name"""
    tax_id: NotRequired[str]
    r"""International tax payer registration number"""
    national_tax_id: NotRequired[str]
    r"""The tax payer registration number inside the country of origin"""
    iban: NotRequired[str]
    r"""The vendor's international bank account number"""
    bank_account: NotRequired[str]
    r"""The vendor's bank account"""
    bank_code: NotRequired[str]
    r"""The vendor's bank code"""
    swift_code: NotRequired[str]
    r"""The SWIFT code of the vendor"""
    address: NotRequired[str]
    r"""The vendor's address. Used when no Vendors data catalog is used or vendor not found in catalog."""
    country: NotRequired[str]
    r"""The vendor's country"""
    state: NotRequired[str]
    r"""The state of the business unit (invoice recipient)"""
    state_or_province: NotRequired[str]
    r"""The state or province of the business unit (invoice recipient)"""
    city: NotRequired[str]
    r"""The vendor's city"""
    street: NotRequired[str]
    r"""The vendor's street address"""
    postal_code: NotRequired[str]
    r"""The vendor's postal code"""
    zip_code: NotRequired[str]
    r"""The ZIP code of the business unit (invoice recipient)"""
    id: NotRequired[str]
    r"""The vendor's unique identifier in an external system"""


class Vendor(BaseModel):
    r"""Vendor details"""

    name: Optional[str] = None
    r"""The vendor's name"""

    tax_id: Annotated[Optional[str], pydantic.Field(alias="taxId")] = None
    r"""International tax payer registration number"""

    national_tax_id: Annotated[Optional[str], pydantic.Field(alias="nationalTaxId")] = (
        None
    )
    r"""The tax payer registration number inside the country of origin"""

    iban: Optional[str] = None
    r"""The vendor's international bank account number"""

    bank_account: Annotated[Optional[str], pydantic.Field(alias="bankAccount")] = None
    r"""The vendor's bank account"""

    bank_code: Annotated[Optional[str], pydantic.Field(alias="bankCode")] = None
    r"""The vendor's bank code"""

    swift_code: Annotated[Optional[str], pydantic.Field(alias="swiftCode")] = None
    r"""The SWIFT code of the vendor"""

    address: Optional[str] = None
    r"""The vendor's address. Used when no Vendors data catalog is used or vendor not found in catalog."""

    country: Optional[str] = None
    r"""The vendor's country"""

    state: Optional[str] = None
    r"""The state of the business unit (invoice recipient)"""

    state_or_province: Annotated[
        Optional[str], pydantic.Field(alias="stateOrProvince")
    ] = None
    r"""The state or province of the business unit (invoice recipient)"""

    city: Optional[str] = None
    r"""The vendor's city"""

    street: Optional[str] = None
    r"""The vendor's street address"""

    postal_code: Annotated[Optional[str], pydantic.Field(alias="postalCode")] = None
    r"""The vendor's postal code"""

    zip_code: Annotated[Optional[str], pydantic.Field(alias="zipCode")] = None
    r"""The ZIP code of the business unit (invoice recipient)"""

    id: Optional[str] = None
    r"""The vendor's unique identifier in an external system"""


class InvoiceDataTypedDict(TypedDict):
    due_date: NotRequired[date]
    r"""The date by which the invoice should be paid."""


class InvoiceData(BaseModel):
    due_date: Annotated[Optional[date], pydantic.Field(alias="dueDate")] = None
    r"""The date by which the invoice should be paid."""


class TaxRatesTypedDict(TypedDict):
    r"""Tax rate details for a specific rate"""

    net_amount: NotRequired[float]
    r"""Cost of goods or services without tax"""
    tax_amount: NotRequired[float]
    r"""Tax charged"""
    tax_rate: NotRequired[float]
    r"""Tax rate percentage"""


class TaxRates(BaseModel):
    r"""Tax rate details for a specific rate"""

    net_amount: Annotated[Optional[float], pydantic.Field(alias="netAmount")] = None
    r"""Cost of goods or services without tax"""

    tax_amount: Annotated[Optional[float], pydantic.Field(alias="taxAmount")] = None
    r"""Tax charged"""

    tax_rate: Annotated[Optional[float], pydantic.Field(alias="taxRate")] = None
    r"""Tax rate percentage"""


class InvoiceFieldsTaxesTypedDict(TypedDict):
    r"""Tax information"""

    total_net_amount: NotRequired[float]
    r"""The total cost of goods and services without tax"""
    total_taxes: NotRequired[float]
    r"""The total tax amount"""
    non_taxable_amount: NotRequired[float]
    r"""The amount on which no tax is payable"""
    tax_rates: NotRequired[List[TaxRatesTypedDict]]
    r"""Tax rates and amounts for different rates"""


class InvoiceFieldsTaxes(BaseModel):
    r"""Tax information"""

    total_net_amount: Annotated[
        Optional[float], pydantic.Field(alias="totalNetAmount")
    ] = None
    r"""The total cost of goods and services without tax"""

    total_taxes: Annotated[Optional[float], pydantic.Field(alias="totalTaxes")] = None
    r"""The total tax amount"""

    non_taxable_amount: Annotated[
        Optional[float], pydantic.Field(alias="nonTaxableAmount")
    ] = None
    r"""The amount on which no tax is payable"""

    tax_rates: Annotated[Optional[List[TaxRates]], pydantic.Field(alias="taxRates")] = (
        None
    )
    r"""Tax rates and amounts for different rates"""


class InvoiceTypeTypedDict(TypedDict):
    r"""The type of invoice document"""

    invoice: bool
    r"""Specifies the Invoice type of the invoice."""
    credit_note: bool
    r"""Specifies the Credit Note type of the invoice."""


class InvoiceType(BaseModel):
    r"""The type of invoice document"""

    invoice: bool
    r"""Specifies the Invoice type of the invoice."""

    credit_note: Annotated[bool, pydantic.Field(alias="creditNote")]
    r"""Specifies the Credit Note type of the invoice."""


class InvoiceFieldsPurchaseOrderTypedDict(TypedDict):
    r"""Purchase order details"""

    order_number: NotRequired[str]
    r"""The number of the purchase order"""
    total: NotRequired[float]
    r"""The cost of the goods or services listed in the purchase order"""
    order_checked: NotRequired[bool]
    r"""Indicates whether the order number is verified"""


class InvoiceFieldsPurchaseOrder(BaseModel):
    r"""Purchase order details"""

    order_number: Annotated[Optional[str], pydantic.Field(alias="orderNumber")] = None
    r"""The number of the purchase order"""

    total: Optional[float] = None
    r"""The cost of the goods or services listed in the purchase order"""

    order_checked: Annotated[Optional[bool], pydantic.Field(alias="orderChecked")] = (
        None
    )
    r"""Indicates whether the order number is verified"""


class LineItemsTypedDict(TypedDict):
    r"""Line item details"""

    order_number: NotRequired[str]
    r"""The number of the purchase order"""
    is_valid: NotRequired[bool]
    r"""Indicates whether the order number matches any checked order number in the Purchase Order group"""
    order_date: NotRequired[date]
    r"""The date when the purchase order was created"""
    position: NotRequired[float]
    r"""The number of the line item in the list"""
    article_number_vendor: NotRequired[str]
    r"""The article number or code in the vendor's database"""
    article_number_bu: NotRequired[str]
    r"""The article number or code in the business unit's database"""
    description: NotRequired[str]
    r"""A description of the line item"""
    quantity: NotRequired[float]
    r"""The number of units purchased"""
    unit_of_measurement: NotRequired[str]
    r"""The unit of measurement used for the goods"""
    unit_price: NotRequired[float]
    r"""The price of one item of goods"""
    discount_percentage: NotRequired[float]
    r"""The discount percentage on the initial line item price"""
    discount: NotRequired[float]
    r"""Discount applicable to the line item"""
    net_price: NotRequired[float]
    r"""The price of the line item without tax"""
    tax_rate: NotRequired[float]
    r"""The tax rate for the line item"""
    tax_amount: NotRequired[float]
    r"""The amount of tax payable on the line item"""
    tax_code: NotRequired[str]
    r"""The code of the tax"""
    total_price: NotRequired[float]
    r"""The price of the line item including tax"""
    currency: NotRequired[str]
    r"""The currency of the line item"""
    order_item_id: NotRequired[str]
    r"""The unique line item identifier"""


class LineItems(BaseModel):
    r"""Line item details"""

    order_number: Annotated[Optional[str], pydantic.Field(alias="orderNumber")] = None
    r"""The number of the purchase order"""

    is_valid: Annotated[Optional[bool], pydantic.Field(alias="isValid")] = None
    r"""Indicates whether the order number matches any checked order number in the Purchase Order group"""

    order_date: Annotated[Optional[date], pydantic.Field(alias="orderDate")] = None
    r"""The date when the purchase order was created"""

    position: Optional[float] = None
    r"""The number of the line item in the list"""

    article_number_vendor: Annotated[
        Optional[str], pydantic.Field(alias="articleNumberVendor")
    ] = None
    r"""The article number or code in the vendor's database"""

    article_number_bu: Annotated[
        Optional[str], pydantic.Field(alias="articleNumberBu")
    ] = None
    r"""The article number or code in the business unit's database"""

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

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

    unit_of_measurement: Annotated[
        Optional[str], pydantic.Field(alias="unitOfMeasurement")
    ] = None
    r"""The unit of measurement used for the goods"""

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

    discount_percentage: Annotated[
        Optional[float], pydantic.Field(alias="discountPercentage")
    ] = None
    r"""The discount percentage on the initial line item price"""

    discount: Optional[float] = None
    r"""Discount applicable to the line item"""

    net_price: Annotated[Optional[float], pydantic.Field(alias="netPrice")] = None
    r"""The price of the line item without tax"""

    tax_rate: Annotated[Optional[float], pydantic.Field(alias="taxRate")] = None
    r"""The tax rate for the line item"""

    tax_amount: Annotated[Optional[float], pydantic.Field(alias="taxAmount")] = None
    r"""The amount of tax payable on the line item"""

    tax_code: Annotated[Optional[str], pydantic.Field(alias="taxCode")] = None
    r"""The code of the tax"""

    total_price: Annotated[Optional[float], pydantic.Field(alias="totalPrice")] = None
    r"""The price of the line item including tax"""

    currency: Optional[str] = None
    r"""The currency of the line item"""

    order_item_id: Annotated[Optional[str], pydantic.Field(alias="orderItemId")] = None
    r"""The unique line item identifier"""


class InvoiceFieldsTypedDict(TypedDict):
    r"""Fields extracted from an invoice"""

    invoice_number: NotRequired[str]
    r"""The number of the invoice"""
    invoice_date: NotRequired[date]
    r"""The date when the invoice was issued"""
    total: NotRequired[float]
    r"""The total cost of goods or services"""
    currency: NotRequired[str]
    r"""The currency of the invoice"""
    business_unit: NotRequired[BusinessUnitTypedDict]
    r"""Business Unit (invoice recipient) details"""
    vendor: NotRequired[VendorTypedDict]
    r"""Vendor details"""
    delivery_date: NotRequired[date]
    r"""The date the goods were delivered or services performed"""
    invoice_data: NotRequired[InvoiceDataTypedDict]
    due_date: NotRequired[date]
    r"""The date by which the invoice should be paid"""
    reversed_charge: NotRequired[bool]
    r"""Indicates that a reverse charge is applied"""
    taxes: NotRequired[InvoiceFieldsTaxesTypedDict]
    r"""Tax information"""
    invoice_type: NotRequired[InvoiceTypeTypedDict]
    r"""The type of invoice document"""
    purchase_order: NotRequired[List[InvoiceFieldsPurchaseOrderTypedDict]]
    r"""Purchase order details"""
    line_items: NotRequired[List[LineItemsTypedDict]]
    r"""List of line items in the invoice"""


class InvoiceFields(BaseModel):
    r"""Fields extracted from an invoice"""

    invoice_number: Annotated[Optional[str], pydantic.Field(alias="invoiceNumber")] = (
        None
    )
    r"""The number of the invoice"""

    invoice_date: Annotated[Optional[date], pydantic.Field(alias="invoiceDate")] = None
    r"""The date when the invoice was issued"""

    total: Optional[float] = None
    r"""The total cost of goods or services"""

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

    business_unit: Annotated[
        Optional[BusinessUnit], pydantic.Field(alias="businessUnit")
    ] = None
    r"""Business Unit (invoice recipient) details"""

    vendor: Optional[Vendor] = None
    r"""Vendor details"""

    delivery_date: Annotated[Optional[date], pydantic.Field(alias="deliveryDate")] = (
        None
    )
    r"""The date the goods were delivered or services performed"""

    invoice_data: Annotated[
        Optional[InvoiceData], pydantic.Field(alias="invoiceData")
    ] = None

    due_date: Annotated[Optional[date], pydantic.Field(alias="dueDate")] = None
    r"""The date by which the invoice should be paid"""

    reversed_charge: Annotated[
        Optional[bool], pydantic.Field(alias="reversedCharge")
    ] = None
    r"""Indicates that a reverse charge is applied"""

    taxes: Optional[InvoiceFieldsTaxes] = None
    r"""Tax information"""

    invoice_type: Annotated[
        Optional[InvoiceType], pydantic.Field(alias="invoiceType")
    ] = None
    r"""The type of invoice document"""

    purchase_order: Annotated[
        Optional[List[InvoiceFieldsPurchaseOrder]],
        pydantic.Field(alias="purchaseOrder"),
    ] = None
    r"""Purchase order details"""

    line_items: Annotated[
        Optional[List[LineItems]], pydantic.Field(alias="lineItems")
    ] = None
    r"""List of line items in the invoice"""
