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

from __future__ import annotations
import dataclasses
import dateutil.parser
from ..shared import creditnoteminified as shared_creditnoteminified
from ..shared import invoiceminified as shared_invoiceminified
from dataclasses_json import Undefined, dataclass_json
from datetime import datetime
from enum import Enum
from orb import utils
from typing import Optional

class CustomerBalanceTransactionAction(str, Enum):
    APPLIED_TO_INVOICE = 'applied_to_invoice'
    PRORATED_REFUND = 'prorated_refund'
    MANUAL_ADJUSTMENT = 'manual_adjustment'

class CustomerBalanceTransactionType(str, Enum):
    INCREMENT = 'increment'
    DECREMENT = 'decrement'


@dataclass_json(undefined=Undefined.EXCLUDE)

@dataclasses.dataclass
class CustomerBalanceTransaction:
    action: CustomerBalanceTransactionAction = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('action') }})
    amount: str = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('amount') }})
    r"""The value of the amount changed in the transaction."""
    created_at: datetime = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('created_at'), 'encoder': utils.datetimeisoformat(False), 'decoder': dateutil.parser.isoparse }})
    r"""The creation time of this transaction."""
    credit_note: Optional[shared_creditnoteminified.CreditNoteMinified] = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('credit_note') }})
    description: Optional[str] = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('description') }})
    r"""An optional description provided for manual customer balance adjustments."""
    ending_balance: str = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('ending_balance') }})
    r"""The new value of the customer's balance prior to the transaction, in the customer's currency."""
    id: str = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('id') }})
    r"""A unique id for this transaction."""
    invoice: Optional[shared_invoiceminified.InvoiceMinified] = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('invoice') }})
    starting_balance: str = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('starting_balance') }})
    r"""The original value of the customer's balance prior to the transaction, in the customer's currency."""
    type: CustomerBalanceTransactionType = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('type') }})
    

