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

if TYPE_CHECKING:
    from .change_order_patch_request_body_additional_collaborators import ChangeOrderPatchRequestBody_additionalCollaborators
    from .change_order_patch_request_body_scope import ChangeOrderPatchRequestBody_scope

@dataclass
class ChangeOrderPatchRequestBody(Parsable):
    # The additional collaborator company and contacts.
    additional_collaborators: Optional[list[ChangeOrderPatchRequestBody_additionalCollaborators]] = None
    # Not relevant
    approved: Optional[float] = None
    # The BIM360/ACC ID of the architecture firm.
    architect_company_id: Optional[str] = None
    # The unique ID (UUID) of the company in this account. Detailed company information can be retrieved using this UUID by calling `GET companies/:company_id <en/docs/bim360/v1/reference/http/companies-:company_id-GET/>`_ in the response.
    architect_company_uid: Optional[str] = None
    # The BIM360/ACC ID of the primary contact at the architecture firm.
    architect_contact_id: Optional[str] = None
    # Not relevant
    committed: Optional[float] = None
    # The BIM360/ACC ID of the company. For RFQ & SCO it's the supplier company. For OCO and OCO it's the owner company. For PCO, when PCO acts as RFQ it's the supplier company, when PCO asts as RCO it's the owner company, otherwise it's empty.
    company_id: Optional[str] = None
    # The unique ID (UUID) of the company in this account. Detailed company information can be retrieved using this UUID by calling `GET companies/:company_id <en/docs/bim360/v1/reference/http/companies-:company_id-GET/>`_ in the response.
    company_uid: Optional[str] = None
    # The description of the change order.Max length: 2048
    description: Optional[str] = None
    # Not relevant
    estimated: Optional[float] = None
    # A new currency exchange rate for the change order.Note that:- If the ``changeOrder`` parameter value is ``rfq``, this value updates the proposed exchange rate for all cost items under this RFQ.- If the ``changeOrder`` parameter value is ``sco``, this value updates the committed exchange rate for all cost items under this SCO.
    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 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 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 change order.Max length: 1024
    name: Optional[str] = None
    # Additional notes to the change order. This is a Tiptap formatted rich text (https://tiptap.dev/introduction/).
    note: Optional[str] = None
    # The ID of the change order’s owner/purchaser, a project user managed by BIM 360 Admin.
    owner_id: Optional[str] = None
    # Not relevant
    proposed: Optional[float] = None
    # The proposed revised completion date of the change order.
    proposed_revised_completion_date: Optional[str] = None
    # Not relevant
    quantity: Optional[float] = None
    # The schedule change of the change order.
    schedule_change: Optional[float] = None
    # The scope of the change order. Possible values: ``out``, ``in``, ``tbd`` , ``budgetOnly``, ``contingency``.
    scope: Optional[ChangeOrderPatchRequestBody_scope] = None
    # The scope of work of the change order. This is a Tiptap formatted rich text (https://tiptap.dev/introduction/).
    scope_of_work: Optional[str] = None
    # The type of entity from which the change order is created (e.g., RFI, Issue).
    source_type: Optional[str] = None
    # Not relevant
    submitted: Optional[float] = None
    # The type of the change order. It is customizable by the project admin.
    type: Optional[str] = None
    # Not relevant
    unit: Optional[str] = None
    
    @staticmethod
    def create_from_discriminator_value(parse_node: ParseNode) -> ChangeOrderPatchRequestBody:
        """
        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: ChangeOrderPatchRequestBody
        """
        if parse_node is None:
            raise TypeError("parse_node cannot be null.")
        return ChangeOrderPatchRequestBody()
    
    def get_field_deserializers(self,) -> dict[str, Callable[[ParseNode], None]]:
        """
        The deserialization information for the current model
        Returns: dict[str, Callable[[ParseNode], None]]
        """
        from .change_order_patch_request_body_additional_collaborators import ChangeOrderPatchRequestBody_additionalCollaborators
        from .change_order_patch_request_body_scope import ChangeOrderPatchRequestBody_scope

        from .change_order_patch_request_body_additional_collaborators import ChangeOrderPatchRequestBody_additionalCollaborators
        from .change_order_patch_request_body_scope import ChangeOrderPatchRequestBody_scope

        fields: dict[str, Callable[[Any], None]] = {
            "additionalCollaborators": lambda n : setattr(self, 'additional_collaborators', n.get_collection_of_object_values(ChangeOrderPatchRequestBody_additionalCollaborators)),
            "approved": lambda n : setattr(self, 'approved', n.get_float_value()),
            "architectCompanyId": lambda n : setattr(self, 'architect_company_id', n.get_str_value()),
            "architectCompanyUid": lambda n : setattr(self, 'architect_company_uid', n.get_str_value()),
            "architectContactId": lambda n : setattr(self, 'architect_contact_id', n.get_str_value()),
            "committed": lambda n : setattr(self, 'committed', n.get_float_value()),
            "companyId": lambda n : setattr(self, 'company_id', n.get_str_value()),
            "companyUid": lambda n : setattr(self, 'company_uid', n.get_str_value()),
            "description": lambda n : setattr(self, 'description', n.get_str_value()),
            "estimated": lambda n : setattr(self, 'estimated', n.get_float_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()),
            "integrationState": lambda n : setattr(self, 'integration_state', n.get_str_value()),
            "lastSyncTime": lambda n : setattr(self, 'last_sync_time', n.get_datetime_value()),
            "name": lambda n : setattr(self, 'name', n.get_str_value()),
            "note": lambda n : setattr(self, 'note', n.get_str_value()),
            "ownerId": lambda n : setattr(self, 'owner_id', n.get_str_value()),
            "proposed": lambda n : setattr(self, 'proposed', n.get_float_value()),
            "proposedRevisedCompletionDate": lambda n : setattr(self, 'proposed_revised_completion_date', n.get_str_value()),
            "quantity": lambda n : setattr(self, 'quantity', n.get_float_value()),
            "scheduleChange": lambda n : setattr(self, 'schedule_change', n.get_float_value()),
            "scope": lambda n : setattr(self, 'scope', n.get_enum_value(ChangeOrderPatchRequestBody_scope)),
            "scopeOfWork": lambda n : setattr(self, 'scope_of_work', n.get_str_value()),
            "sourceType": lambda n : setattr(self, 'source_type', n.get_str_value()),
            "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()),
        }
        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_collection_of_object_values("additionalCollaborators", self.additional_collaborators)
        writer.write_float_value("approved", self.approved)
        writer.write_str_value("architectCompanyId", self.architect_company_id)
        writer.write_str_value("architectCompanyUid", self.architect_company_uid)
        writer.write_str_value("architectContactId", self.architect_contact_id)
        writer.write_float_value("committed", self.committed)
        writer.write_str_value("companyId", self.company_id)
        writer.write_str_value("companyUid", self.company_uid)
        writer.write_str_value("description", self.description)
        writer.write_float_value("estimated", self.estimated)
        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_str_value("integrationState", self.integration_state)
        writer.write_datetime_value("lastSyncTime", self.last_sync_time)
        writer.write_str_value("name", self.name)
        writer.write_str_value("note", self.note)
        writer.write_str_value("ownerId", self.owner_id)
        writer.write_float_value("proposed", self.proposed)
        writer.write_str_value("proposedRevisedCompletionDate", self.proposed_revised_completion_date)
        writer.write_float_value("quantity", self.quantity)
        writer.write_float_value("scheduleChange", self.schedule_change)
        writer.write_enum_value("scope", self.scope)
        writer.write_str_value("scopeOfWork", self.scope_of_work)
        writer.write_str_value("sourceType", self.source_type)
        writer.write_float_value("submitted", self.submitted)
        writer.write_str_value("type", self.type)
        writer.write_str_value("unit", self.unit)
    

