"""Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT."""

from __future__ import annotations
import dataclasses
import dateutil.parser
from ..shared import amountdiscount as shared_amountdiscount
from ..shared import bpsprice as shared_bpsprice
from ..shared import bulkbpsprice as shared_bulkbpsprice
from ..shared import bulkprice as shared_bulkprice
from ..shared import fivetranexampleprice as shared_fivetranexampleprice
from ..shared import matrixprice as shared_matrixprice
from ..shared import matrixsublineitem as shared_matrixsublineitem
from ..shared import maximum as shared_maximum
from ..shared import minimum as shared_minimum
from ..shared import othersublineitem as shared_othersublineitem
from ..shared import packageprice as shared_packageprice
from ..shared import packagewithallocationprice as shared_packagewithallocationprice
from ..shared import percentagediscount as shared_percentagediscount
from ..shared import taxamount as shared_taxamount
from ..shared import testratingfunctionprice as shared_testratingfunctionprice
from ..shared import thresholdtotalamountprice as shared_thresholdtotalamountprice
from ..shared import tieredbpsprice as shared_tieredbpsprice
from ..shared import tieredpackageprice as shared_tieredpackageprice
from ..shared import tieredprice as shared_tieredprice
from ..shared import tieredwithminimumprice as shared_tieredwithminimumprice
from ..shared import tiersublineitem as shared_tiersublineitem
from ..shared import trialdiscount as shared_trialdiscount
from ..shared import unitprice as shared_unitprice
from ..shared import usagediscount as shared_usagediscount
from dataclasses_json import Undefined, dataclass_json
from datetime import datetime
from orb import utils
from typing import Optional, Union



@dataclasses.dataclass
class InvoiceLineItemDiscount:
    pass



@dataclasses.dataclass
class InvoiceLineItemQuantity:
    pass


@dataclass_json(undefined=Undefined.EXCLUDE)

@dataclasses.dataclass
class InvoiceLineItem:
    amount: str = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('amount') }})
    r"""The final amount after any discounts or minimums."""
    discount: Optional[Union[shared_percentagediscount.PercentageDiscount, shared_trialdiscount.TrialDiscount, shared_usagediscount.UsageDiscount, shared_amountdiscount.AmountDiscount]] = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('discount') }})
    end_date: datetime = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('end_date'), 'encoder': utils.datetimeisoformat(False), 'decoder': dateutil.parser.isoparse }})
    r"""The end date of the range of time applied for this line item's price."""
    grouping: Optional[str] = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('grouping') }})
    r"""[DEPRECATED] For configured prices that are split by a grouping key, this will be populated with the key and a value. The `amount` and `subtotal` will be the values for this particular grouping."""
    id: str = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('id') }})
    r"""A unique ID for this line item."""
    maximum: Optional[shared_maximum.Maximum] = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('maximum') }})
    maximum_amount: Optional[str] = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('maximum_amount') }})
    minimum: Optional[shared_minimum.Minimum] = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('minimum') }})
    minimum_amount: Optional[str] = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('minimum_amount') }})
    name: str = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('name') }})
    r"""The name of the price associated with this line item."""
    price: Optional[Union[shared_unitprice.UnitPrice, shared_packageprice.PackagePrice, shared_matrixprice.MatrixPrice, shared_tieredprice.TieredPrice, shared_tieredbpsprice.TieredBpsPrice, shared_bpsprice.BpsPrice, shared_bulkbpsprice.BulkBpsPrice, shared_bulkprice.BulkPrice, shared_testratingfunctionprice.TestRatingFunctionPrice, shared_fivetranexampleprice.FivetranExamplePrice, shared_thresholdtotalamountprice.ThresholdTotalAmountPrice, shared_tieredpackageprice.TieredPackagePrice, shared_tieredwithminimumprice.TieredWithMinimumPrice, shared_packagewithallocationprice.PackageWithAllocationPrice]] = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('price'), 'decoder': utils.decoder_with_discriminator('model_type') }})
    quantity: Union[float, str] = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('quantity') }})
    start_date: datetime = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('start_date'), 'encoder': utils.datetimeisoformat(False), 'decoder': dateutil.parser.isoparse }})
    r"""The start date of the range of time applied for this line item's price."""
    sub_line_items: list[Union[shared_matrixsublineitem.MatrixSubLineItem, shared_tiersublineitem.TierSubLineItem, shared_othersublineitem.OtherSubLineItem]] = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('sub_line_items') }})
    r"""For complex pricing structures, the line item can be broken down further in `sub_line_items`."""
    subtotal: str = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('subtotal') }})
    r"""The line amount before any line item-specific discounts or minimums."""
    tax_amounts: list[shared_taxamount.TaxAmount] = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('tax_amounts') }})
    r"""An array of tax rates and their incurred tax amounts. Empty if no tax integration is configured."""
    

