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 .with_budget_patch_request_body_segment_code_map import WithBudgetPatchRequestBody_segmentCodeMap

@dataclass
class WithBudgetPatchRequestBody(Parsable):
    # The total amount of actual cost of the budget.
    actual_cost: Optional[float] = None
    # Not relevant
    actual_end_date: Optional[str] = None
    # Actual quantity of labor, material,... planned for a budget.
    actual_quantity: Optional[float] = None
    # Not relevant
    actual_start_date: Optional[str] = None
    # Actual unit price of a budget.
    actual_unit_price: Optional[float] = None
    # Unique code compliant with the budget code template defined by the project admin. Ignored if ``segmentCodeMap`` is defined.Max length: 255
    code: Optional[str] = None
    # Detailed description of the budget.
    description: Optional[str] = None
    # Not relevant
    duration_days: 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 input quantity planned for the budget.
    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
    # Not relevant
    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.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 locked budget item field. You can lock the budget item's amount (``originalAmount``), quantity (``quantity``), or unit cost (``unitPrice``) when calculating a budget.
    locked_field: Optional[str] = None
    # Not relevant
    main_contract_amount_source: Optional[str] = None
    # Name of the budget.Max length: 1024
    name: Optional[str] = None
    # Not relevant
    original_cost_unit_price: Optional[float] = None
    # Not relevant
    planned_end_date: Optional[str] = None
    # Not relevant
    planned_start_date: Optional[str] = None
    # The quantity of labor, material, and other items planned for the budget.
    quantity: Optional[float] = None
    # Map of budget code segments to be used in the budget code, required when updating root budget code with variable length segment. Key is the budget code segment ID, value is the code for the segment.
    segment_code_map: Optional[WithBudgetPatchRequestBody_segmentCodeMap] = None
    # Unit of measures used in the budget.
    unit: Optional[str] = None
    # Unit price of a budget.
    unit_price: Optional[float] = None
    
    @staticmethod
    def create_from_discriminator_value(parse_node: ParseNode) -> WithBudgetPatchRequestBody:
        """
        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: WithBudgetPatchRequestBody
        """
        if parse_node is None:
            raise TypeError("parse_node cannot be null.")
        return WithBudgetPatchRequestBody()
    
    def get_field_deserializers(self,) -> dict[str, Callable[[ParseNode], None]]:
        """
        The deserialization information for the current model
        Returns: dict[str, Callable[[ParseNode], None]]
        """
        from .with_budget_patch_request_body_segment_code_map import WithBudgetPatchRequestBody_segmentCodeMap

        from .with_budget_patch_request_body_segment_code_map import WithBudgetPatchRequestBody_segmentCodeMap

        fields: dict[str, Callable[[Any], None]] = {
            "actualCost": lambda n : setattr(self, 'actual_cost', n.get_float_value()),
            "actualEndDate": lambda n : setattr(self, 'actual_end_date', n.get_str_value()),
            "actualQuantity": lambda n : setattr(self, 'actual_quantity', n.get_float_value()),
            "actualStartDate": lambda n : setattr(self, 'actual_start_date', n.get_str_value()),
            "actualUnitPrice": lambda n : setattr(self, 'actual_unit_price', n.get_float_value()),
            "code": lambda n : setattr(self, 'code', n.get_str_value()),
            "description": lambda n : setattr(self, 'description', n.get_str_value()),
            "durationDays": lambda n : setattr(self, 'duration_days', 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()),
            "inputQuantity": lambda n : setattr(self, 'input_quantity', n.get_float_value()),
            "integrationState": lambda n : setattr(self, 'integration_state', 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()),
            "locations": lambda n : setattr(self, 'locations', n.get_collection_of_primitive_values(str)),
            "lockedField": lambda n : setattr(self, 'locked_field', n.get_str_value()),
            "mainContractAmountSource": lambda n : setattr(self, 'main_contract_amount_source', n.get_str_value()),
            "name": lambda n : setattr(self, 'name', n.get_str_value()),
            "originalCostUnitPrice": lambda n : setattr(self, 'original_cost_unit_price', n.get_float_value()),
            "plannedEndDate": lambda n : setattr(self, 'planned_end_date', n.get_str_value()),
            "plannedStartDate": lambda n : setattr(self, 'planned_start_date', n.get_str_value()),
            "quantity": lambda n : setattr(self, 'quantity', n.get_float_value()),
            "segmentCodeMap": lambda n : setattr(self, 'segment_code_map', n.get_object_value(WithBudgetPatchRequestBody_segmentCodeMap)),
            "unit": lambda n : setattr(self, 'unit', n.get_str_value()),
            "unitPrice": lambda n : setattr(self, 'unit_price', n.get_float_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("actualCost", self.actual_cost)
        writer.write_str_value("actualEndDate", self.actual_end_date)
        writer.write_float_value("actualQuantity", self.actual_quantity)
        writer.write_str_value("actualStartDate", self.actual_start_date)
        writer.write_float_value("actualUnitPrice", self.actual_unit_price)
        writer.write_str_value("code", self.code)
        writer.write_str_value("description", self.description)
        writer.write_float_value("durationDays", self.duration_days)
        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_float_value("inputQuantity", self.input_quantity)
        writer.write_str_value("integrationState", self.integration_state)
        writer.write_bool_value("isMarkup", self.is_markup)
        writer.write_datetime_value("lastSyncTime", self.last_sync_time)
        writer.write_collection_of_primitive_values("locations", self.locations)
        writer.write_str_value("lockedField", self.locked_field)
        writer.write_str_value("mainContractAmountSource", self.main_contract_amount_source)
        writer.write_str_value("name", self.name)
        writer.write_float_value("originalCostUnitPrice", self.original_cost_unit_price)
        writer.write_str_value("plannedEndDate", self.planned_end_date)
        writer.write_str_value("plannedStartDate", self.planned_start_date)
        writer.write_float_value("quantity", self.quantity)
        writer.write_object_value("segmentCodeMap", self.segment_code_map)
        writer.write_str_value("unit", self.unit)
        writer.write_float_value("unitPrice", self.unit_price)
    

