from __future__ import annotations
import datetime
from collections.abc import Callable
from dataclasses import dataclass, field
from kiota_abstractions.serialization import Parsable, ParseNode, SerializationWriter
from typing import Any, Optional, TYPE_CHECKING, Union
from uuid import UUID

@dataclass
class ScheduleOfValuesPostResponse(Parsable):
    # The total price of the SOV item.
    amount: Optional[float] = None
    # The ID of a change order or cost item that this SOV item was originally created from.
    association_id: Optional[str] = None
    # The type of object from which the SOV item was created:a change order or a cost item.
    association_type: Optional[str] = None
    # The ID of the budget to which the SOV item belongs.
    budget_id: Optional[str] = None
    # The converted quantity of the SOV item.
    bulk: Optional[float] = None
    # The unit price of the converted SOV item quantity.
    bulk_unit_price: Optional[float] = None
    # The code of the SOV item.Max length: 255
    code: Optional[str] = None
    # The ID of the contract to which the SOV item belongs.
    contract_id: Optional[str] = None
    # The date and time that the item was created, in ISO 8601 format.
    created_at: Optional[datetime.datetime] = None
    # The exchange rate that applies to the SOV item's base currency price. For example, provide the value ``0.7455`` for a foreign currency that's worth ``0.7455`` of your base currency.
    exchange_rate: Optional[float] = None
    # The identifier assigned to an item in its original external ERP system. Use this ID to track and look up data within the integrated system. Note that this value comes from the item's ID in the external system.Max length: 255
    external_id: Optional[str] = None
    # A message generated by the external ERP system that explains the sync status of the integration. For example, common values include ``success`` or ``fail`` to indicate the result of the integration operation.Max length: 255
    external_message: Optional[str] = None
    # The name of the external ERP system integrated with Cost Management. Use this name to identify and search for data within the integrated system.Max length: 255
    external_system: Optional[str] = None
    # The unique ID of this SOV item.
    id: Optional[UUID] = None
    # The date and time when the item was last synchronized with the external ERP system. This value is updated by the external system and is in ISO 8601 format.
    last_sync_time: Optional[datetime.datetime] = None
    # The name of the SOV item.Max length: 1024
    name: Optional[str] = None
    # The ID of the SOV item's parent item. For root SOV items, this value is **null**.Root items can only be created when allocating a budget to a contract.
    parent_id: Optional[str] = None
    # The position of the SOV item in the list of SOV items.
    position: Optional[float] = None
    # The quantity of the SOV item.
    quantity: Optional[float] = None
    # The quantity conversion ratio of the SOV item.
    quantity_per_bulk: Optional[float] = None
    # The unit of measure of the SOV item.Max length: 1024
    unit: Optional[str] = None
    # The unit price of the SOV item.
    unit_price: Optional[float] = None
    # The date and time that the item was last updated, in ISO 8601 format.
    updated_at: Optional[datetime.datetime] = None
    
    @staticmethod
    def create_from_discriminator_value(parse_node: ParseNode) -> ScheduleOfValuesPostResponse:
        """
        Creates a new instance of the appropriate class based on discriminator value
        param parse_node: The parse node to use to read the discriminator value and create the object
        Returns: ScheduleOfValuesPostResponse
        """
        if parse_node is None:
            raise TypeError("parse_node cannot be null.")
        return ScheduleOfValuesPostResponse()
    
    def get_field_deserializers(self,) -> dict[str, Callable[[ParseNode], None]]:
        """
        The deserialization information for the current model
        Returns: dict[str, Callable[[ParseNode], None]]
        """
        fields: dict[str, Callable[[Any], None]] = {
            "amount": lambda n : setattr(self, 'amount', n.get_float_value()),
            "associationId": lambda n : setattr(self, 'association_id', n.get_str_value()),
            "associationType": lambda n : setattr(self, 'association_type', n.get_str_value()),
            "budgetId": lambda n : setattr(self, 'budget_id', n.get_str_value()),
            "bulk": lambda n : setattr(self, 'bulk', n.get_float_value()),
            "bulkUnitPrice": lambda n : setattr(self, 'bulk_unit_price', n.get_float_value()),
            "code": lambda n : setattr(self, 'code', n.get_str_value()),
            "contractId": lambda n : setattr(self, 'contract_id', n.get_str_value()),
            "createdAt": lambda n : setattr(self, 'created_at', n.get_datetime_value()),
            "exchangeRate": lambda n : setattr(self, 'exchange_rate', n.get_float_value()),
            "externalId": lambda n : setattr(self, 'external_id', n.get_str_value()),
            "externalMessage": lambda n : setattr(self, 'external_message', n.get_str_value()),
            "externalSystem": lambda n : setattr(self, 'external_system', n.get_str_value()),
            "id": lambda n : setattr(self, 'id', n.get_uuid_value()),
            "lastSyncTime": lambda n : setattr(self, 'last_sync_time', n.get_datetime_value()),
            "name": lambda n : setattr(self, 'name', n.get_str_value()),
            "parentId": lambda n : setattr(self, 'parent_id', n.get_str_value()),
            "position": lambda n : setattr(self, 'position', n.get_float_value()),
            "quantity": lambda n : setattr(self, 'quantity', n.get_float_value()),
            "quantityPerBulk": lambda n : setattr(self, 'quantity_per_bulk', n.get_float_value()),
            "unit": lambda n : setattr(self, 'unit', n.get_str_value()),
            "unitPrice": lambda n : setattr(self, 'unit_price', n.get_float_value()),
            "updatedAt": lambda n : setattr(self, 'updated_at', n.get_datetime_value()),
        }
        return fields
    
    def serialize(self,writer: SerializationWriter) -> None:
        """
        Serializes information the current object
        param writer: Serialization writer to use to serialize this model
        Returns: None
        """
        if writer is None:
            raise TypeError("writer cannot be null.")
        writer.write_float_value("amount", self.amount)
        writer.write_str_value("associationId", self.association_id)
        writer.write_str_value("associationType", self.association_type)
        writer.write_str_value("budgetId", self.budget_id)
        writer.write_float_value("bulk", self.bulk)
        writer.write_float_value("bulkUnitPrice", self.bulk_unit_price)
        writer.write_str_value("code", self.code)
        writer.write_str_value("contractId", self.contract_id)
        writer.write_datetime_value("createdAt", self.created_at)
        writer.write_float_value("exchangeRate", self.exchange_rate)
        writer.write_str_value("externalId", self.external_id)
        writer.write_str_value("externalMessage", self.external_message)
        writer.write_str_value("externalSystem", self.external_system)
        writer.write_uuid_value("id", self.id)
        writer.write_datetime_value("lastSyncTime", self.last_sync_time)
        writer.write_str_value("name", self.name)
        writer.write_str_value("parentId", self.parent_id)
        writer.write_float_value("position", self.position)
        writer.write_float_value("quantity", self.quantity)
        writer.write_float_value("quantityPerBulk", self.quantity_per_bulk)
        writer.write_str_value("unit", self.unit)
        writer.write_float_value("unitPrice", self.unit_price)
        writer.write_datetime_value("updatedAt", self.updated_at)
    

