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

if TYPE_CHECKING:
    from .cost_items_get_response_results_scope import CostItemsGetResponse_results_scope
    from .cost_items_get_response_results_split_number import CostItemsGetResponse_results_splitNumber

@dataclass
class CostItemsGetResponse_results(Parsable):
    # The amount approved by the owner.
    approved: Optional[float] = None
    # The ID of the budget to which the cost item is linked.
    budget_id: Optional[str] = None
    # The current budget status of the cost item, indicating its lifecycle stage.Possible values: ``draft``, ``open``, ``submitted``, ``accepted``, ``approved``, ``executed``, ``revising``, ``rejected``, ``void``.Note that you can only change the status by updating the associated change order.
    budget_status: Optional[str] = None
    # Not relevant
    budget_transfer_id: Optional[str] = None
    # Not relevant
    budget_transfer_item_id: Optional[str] = None
    # The amount committed to the supplier.
    committed: Optional[float] = None
    # The exchange rate used for the ``committed`` cost. If multi-currency was not enabled, the value is set to ``1`` regardless of the specified rate. Default value: ``1``.
    committed_exchange_rate: Optional[float] = None
    # The ID of the contract to which the cost item is linked.
    contract_id: Optional[str] = None
    # The current financial approval status of the cost item.Possible values: ``draft``, ``open``, ``revising``, ``pricing``, ``proposed``, ``approved``, ``executed``, ``rejected``, ``contracted``, ``accepted``, ``void``.Note that the cost status can only be changed by updating the associated change order.
    cost_status: Optional[str] = None
    # The date and time that the item was created, in ISO 8601 format.
    created_at: Optional[datetime.datetime] = None
    # A detailed description of the cost item.
    description: Optional[str] = None
    # The rough estimate of the cost item without a formal quote.
    estimated: 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 identifier of the cost item.
    id: Optional[UUID] = None
    # The initial quantity of the proposed cost item as specified in the budget or contract.
    input_quantity: Optional[float] = None
    # The state of the item during the integration with the external ERP system (such as SignNow). An item can be a ``budget``, ``contract``, ``main contract``, ``main contract item``, ``cost item``, ``expense``, ``expense item``, ``change order``, or ``schedule of value``. For more details, see `Integrate with External System </en/docs/acc/v1/tutorials/cost/integrate-with-external-system/>`_ tutorial.Possible values:``locked``: the item is currently locked within the ERP system, preventing modifications until unlocked. To unlock and modify the item, use the relevant PATCH endpoint to set ``integrationState`` to ``null``. For example, for a budget, call `PATCH budgets <en/docs/bim360/v1/reference/http/cost-budgets-budgetId-PATCH/>`_. For a contract, call `PATCH contracts <en/docs/bim360/v1/reference/http/cost-contracts-contractId-PATCH/>`_. For more details, see the `Help documentation <https://help.autodesk.com/view/BUILD/ENU/?guid=Integrated_and_Locked>`_.``integrated``: the item has been successfully added to the ERP system.``failed``: the item encountered an error during the integration process and was not successfully added to the ERP system. For example, if a user tries to integrate ``contracts`` from an ERP system and the updates fail, the ``integrationState`` can be set to ``failed``. Retry the sync process or analyze the issue if it continues to fail.``null``: The item has not been integrated with the ERP system. This is default value.For more information regarding integrations within the Cost Management system, see `Integrations in Cost Management <https://help.autodesk.com/view/BUILD/ENU/?guid=Cost_Integrations>`_.
    integration_state: Optional[str] = None
    # The date and time that the item's integration status was last changed.
    integration_state_changed_at: Optional[str] = None
    # The user who last changed the integration status. This is the ID of a user managed by the BIM 360/ACC Admin.
    integration_state_changed_by: Optional[str] = None
    # Indicates if the cost item includes a markup.``true``: the item is a markup cost item.``false``: (default) the item is not a markup cost item.
    is_markup: Optional[bool] = 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
    # A list of the IDs of the project locations where this item applies, along with the node paths of these locations in the project's locations tree.For more information, see the Locations `Help documentation <https://aps.autodesk.com/en/docs/bim360/v1/reference/http/locations-nodes-GET/>`_ help.
    location_paths: Optional[list[str]] = None
    # A list of the IDs of the project locations where this item applies.For more information, see the Locations `Help documentation <https://aps.autodesk.com/en/docs/bim360/v1/reference/http/locations-nodes-GET/>`_ help.
    locations: Optional[list[str]] = None
    # The name of the cost item.Max length: 255
    name: Optional[str] = None
    # A note associated with the cost item, formatted as Tiptap rich text (https://tiptap.dev/introduction/).
    note: Optional[str] = None
    # The system generated sequential number.
    number: Optional[str] = None
    # The quoted cost of the cost item provided by the supplier.
    proposed: Optional[float] = None
    # The exchange rate used for the ``proposed`` cost. If multi-currency was not enabled, the value is set to ``1`` regardless of the specified rate. Default value: ``1``.
    proposed_exchange_rate: Optional[float] = None
    # The total quantity of the cost item.
    quantity: Optional[float] = None
    # Defines the project's scope status of the cost item. Possible values: ``out``, ``in``, ``tbd``, ``budgetOnly``, ``contingency``.
    scope: Optional[CostItemsGetResponse_results_scope] = None
    # The scope of work of the cost items, formatted as Tiptap rich text (https://tiptap.dev/introduction/).
    scope_of_work: Optional[str] = None
    # Not relevant
    split_number: Optional[CostItemsGetResponse_results_splitNumber] = None
    # The amount submitted to the owner for approval.
    submitted: Optional[float] = None
    # The category or classification of the cost item, which the Project Admin can customize.
    type: Optional[str] = None
    # The unit of measurement for the cost item.
    unit: Optional[str] = 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) -> CostItemsGetResponse_results:
        """
        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: CostItemsGetResponse_results
        """
        if parse_node is None:
            raise TypeError("parse_node cannot be null.")
        return CostItemsGetResponse_results()
    
    def get_field_deserializers(self,) -> dict[str, Callable[[ParseNode], None]]:
        """
        The deserialization information for the current model
        Returns: dict[str, Callable[[ParseNode], None]]
        """
        from .cost_items_get_response_results_scope import CostItemsGetResponse_results_scope
        from .cost_items_get_response_results_split_number import CostItemsGetResponse_results_splitNumber

        from .cost_items_get_response_results_scope import CostItemsGetResponse_results_scope
        from .cost_items_get_response_results_split_number import CostItemsGetResponse_results_splitNumber

        fields: dict[str, Callable[[Any], None]] = {
            "approved": lambda n : setattr(self, 'approved', n.get_float_value()),
            "budgetId": lambda n : setattr(self, 'budget_id', n.get_str_value()),
            "budgetStatus": lambda n : setattr(self, 'budget_status', n.get_str_value()),
            "budgetTransferId": lambda n : setattr(self, 'budget_transfer_id', n.get_str_value()),
            "budgetTransferItemId": lambda n : setattr(self, 'budget_transfer_item_id', n.get_str_value()),
            "committed": lambda n : setattr(self, 'committed', n.get_float_value()),
            "committedExchangeRate": lambda n : setattr(self, 'committed_exchange_rate', n.get_float_value()),
            "contractId": lambda n : setattr(self, 'contract_id', n.get_str_value()),
            "costStatus": lambda n : setattr(self, 'cost_status', n.get_str_value()),
            "createdAt": lambda n : setattr(self, 'created_at', n.get_datetime_value()),
            "description": lambda n : setattr(self, 'description', n.get_str_value()),
            "estimated": lambda n : setattr(self, 'estimated', 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()),
            "inputQuantity": lambda n : setattr(self, 'input_quantity', n.get_float_value()),
            "integrationState": lambda n : setattr(self, 'integration_state', n.get_str_value()),
            "integrationStateChangedAt": lambda n : setattr(self, 'integration_state_changed_at', n.get_str_value()),
            "integrationStateChangedBy": lambda n : setattr(self, 'integration_state_changed_by', n.get_str_value()),
            "isMarkup": lambda n : setattr(self, 'is_markup', n.get_bool_value()),
            "lastSyncTime": lambda n : setattr(self, 'last_sync_time', n.get_datetime_value()),
            "locationPaths": lambda n : setattr(self, 'location_paths', n.get_collection_of_primitive_values(str)),
            "locations": lambda n : setattr(self, 'locations', n.get_collection_of_primitive_values(str)),
            "name": lambda n : setattr(self, 'name', n.get_str_value()),
            "note": lambda n : setattr(self, 'note', n.get_str_value()),
            "number": lambda n : setattr(self, 'number', n.get_str_value()),
            "proposed": lambda n : setattr(self, 'proposed', n.get_float_value()),
            "proposedExchangeRate": lambda n : setattr(self, 'proposed_exchange_rate', n.get_float_value()),
            "quantity": lambda n : setattr(self, 'quantity', n.get_float_value()),
            "scope": lambda n : setattr(self, 'scope', n.get_enum_value(CostItemsGetResponse_results_scope)),
            "scopeOfWork": lambda n : setattr(self, 'scope_of_work', n.get_str_value()),
            "splitNumber": lambda n : setattr(self, 'split_number', n.get_object_value(CostItemsGetResponse_results_splitNumber)),
            "submitted": lambda n : setattr(self, 'submitted', n.get_float_value()),
            "type": lambda n : setattr(self, 'type', n.get_str_value()),
            "unit": lambda n : setattr(self, 'unit', n.get_str_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("approved", self.approved)
        writer.write_str_value("budgetId", self.budget_id)
        writer.write_str_value("budgetStatus", self.budget_status)
        writer.write_str_value("budgetTransferId", self.budget_transfer_id)
        writer.write_str_value("budgetTransferItemId", self.budget_transfer_item_id)
        writer.write_float_value("committed", self.committed)
        writer.write_float_value("committedExchangeRate", self.committed_exchange_rate)
        writer.write_str_value("contractId", self.contract_id)
        writer.write_str_value("costStatus", self.cost_status)
        writer.write_datetime_value("createdAt", self.created_at)
        writer.write_str_value("description", self.description)
        writer.write_float_value("estimated", self.estimated)
        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_float_value("inputQuantity", self.input_quantity)
        writer.write_str_value("integrationState", self.integration_state)
        writer.write_str_value("integrationStateChangedAt", self.integration_state_changed_at)
        writer.write_str_value("integrationStateChangedBy", self.integration_state_changed_by)
        writer.write_bool_value("isMarkup", self.is_markup)
        writer.write_datetime_value("lastSyncTime", self.last_sync_time)
        writer.write_collection_of_primitive_values("locationPaths", self.location_paths)
        writer.write_collection_of_primitive_values("locations", self.locations)
        writer.write_str_value("name", self.name)
        writer.write_str_value("note", self.note)
        writer.write_str_value("number", self.number)
        writer.write_float_value("proposed", self.proposed)
        writer.write_float_value("proposedExchangeRate", self.proposed_exchange_rate)
        writer.write_float_value("quantity", self.quantity)
        writer.write_enum_value("scope", self.scope)
        writer.write_str_value("scopeOfWork", self.scope_of_work)
        writer.write_object_value("splitNumber", self.split_number)
        writer.write_float_value("submitted", self.submitted)
        writer.write_str_value("type", self.type)
        writer.write_str_value("unit", self.unit)
        writer.write_datetime_value("updatedAt", self.updated_at)
    

