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

@dataclass
class ExpensesPostResponse(Parsable):
    # Not relevant
    aggregate_by: Optional[str] = None
    # The total value of the subitems of the expense.
    amount: Optional[float] = None
    # The date and time when the expense was approved.
    approved_at: Optional[str] = None
    # The ID of the Budget Pay App the expense amount will be aggregated to.
    budget_payment_id: Optional[str] = None
    # The user who made the last change to the expense. This is the ID of a user managed by BIM 360 Admin.
    changed_by: Optional[str] = None
    # The date and time that the item was created, in ISO 8601 format.
    created_at: Optional[datetime.datetime] = None
    # The user who created the expense. This is the ID of a user managed by BIM 360 Admin.
    creator_id: Optional[str] = None
    # The detailed description of the expense.Max length: 2048
    description: Optional[str] = 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 date and time determine which distribution period this expense belongs to, after the status of ``status`` is set to ``approved`` or ``paid``.
    forecast_distribution_at: Optional[str] = None
    # The unique identifier of the expense.
    id: 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 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
    # The date and time when the expense was issued.
    issued_at: 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 ID of the Main Contract to which the expense belongs.
    main_contract_id: Optional[str] = None
    # The name of the expense.Max length: 1024
    name: Optional[str] = None
    # The note attached to the expense, if returned. The note consists of Tiptap formatted rich text. For more information, see `https://tiptap.dev <https://tiptap.dev/introduction/>`_.
    note: Optional[str] = None
    # The auto-generated sequence number for the expense.Max length: 255
    number: Optional[str] = None
    # The date and time when the expense was paid.
    paid_at: Optional[str] = None
    # The payment due date and time of the expense.
    payment_due: Optional[str] = None
    # The user who purchased the expense. This is the ID of a user managed by BIM 360 Admin.
    purchased_by: Optional[str] = None
    # The date and time when the expense was received.
    received_at: Optional[str] = None
    # The user-provided reference number of the expense.
    reference_number: Optional[str] = None
    # The applicable scope of the expense. Possible values: ``full``, ``partial``.
    scope: Optional[str] = None
    # The status of the expense. Possible values: ``draft``, ``pending``, ``revise``, ``rejected``, ``approved``, ``paid``.
    status: 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.
    supplier_company_uid: Optional[str] = None
    # The ID of a company managed by a BIM 360 Admin. Detailed company information can be retrieved by calling `GET projects/:project_id/companies <en/docs/bim360/v1/reference/http/projects-:project_id-companies-GET/>`_ and locating the `member_group_id` in the response.
    supplier_id: Optional[str] = None
    # The supplier company name for the expense. Any company can be used regardless the ones added in Account Administration.Max length: 255
    supplier_name: Optional[str] = None
    # The term of the expense. This is customizable by the project administrator.
    term: Optional[str] = None
    # The type of the expense. This is customizable by the project administrator.Max length: 128
    type: 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) -> ExpensesPostResponse:
        """
        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: ExpensesPostResponse
        """
        if parse_node is None:
            raise TypeError("parse_node cannot be null.")
        return ExpensesPostResponse()
    
    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]] = {
            "aggregateBy": lambda n : setattr(self, 'aggregate_by', n.get_str_value()),
            "amount": lambda n : setattr(self, 'amount', n.get_float_value()),
            "approvedAt": lambda n : setattr(self, 'approved_at', n.get_str_value()),
            "budgetPaymentId": lambda n : setattr(self, 'budget_payment_id', n.get_str_value()),
            "changedBy": lambda n : setattr(self, 'changed_by', n.get_str_value()),
            "createdAt": lambda n : setattr(self, 'created_at', n.get_datetime_value()),
            "creatorId": lambda n : setattr(self, 'creator_id', n.get_str_value()),
            "description": lambda n : setattr(self, 'description', n.get_str_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()),
            "forecastDistributionAt": lambda n : setattr(self, 'forecast_distribution_at', n.get_str_value()),
            "id": lambda n : setattr(self, 'id', n.get_str_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()),
            "issuedAt": lambda n : setattr(self, 'issued_at', n.get_str_value()),
            "lastSyncTime": lambda n : setattr(self, 'last_sync_time', n.get_datetime_value()),
            "mainContractId": lambda n : setattr(self, 'main_contract_id', n.get_str_value()),
            "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()),
            "paidAt": lambda n : setattr(self, 'paid_at', n.get_str_value()),
            "paymentDue": lambda n : setattr(self, 'payment_due', n.get_str_value()),
            "purchasedBy": lambda n : setattr(self, 'purchased_by', n.get_str_value()),
            "receivedAt": lambda n : setattr(self, 'received_at', n.get_str_value()),
            "referenceNumber": lambda n : setattr(self, 'reference_number', n.get_str_value()),
            "scope": lambda n : setattr(self, 'scope', n.get_str_value()),
            "status": lambda n : setattr(self, 'status', n.get_str_value()),
            "supplierCompanyUid": lambda n : setattr(self, 'supplier_company_uid', n.get_str_value()),
            "supplierId": lambda n : setattr(self, 'supplier_id', n.get_str_value()),
            "supplierName": lambda n : setattr(self, 'supplier_name', n.get_str_value()),
            "term": lambda n : setattr(self, 'term', n.get_str_value()),
            "type": lambda n : setattr(self, 'type', 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_str_value("aggregateBy", self.aggregate_by)
        writer.write_float_value("amount", self.amount)
        writer.write_str_value("approvedAt", self.approved_at)
        writer.write_str_value("budgetPaymentId", self.budget_payment_id)
        writer.write_str_value("changedBy", self.changed_by)
        writer.write_datetime_value("createdAt", self.created_at)
        writer.write_str_value("creatorId", self.creator_id)
        writer.write_str_value("description", self.description)
        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("forecastDistributionAt", self.forecast_distribution_at)
        writer.write_str_value("id", self.id)
        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_str_value("issuedAt", self.issued_at)
        writer.write_datetime_value("lastSyncTime", self.last_sync_time)
        writer.write_str_value("mainContractId", self.main_contract_id)
        writer.write_str_value("name", self.name)
        writer.write_str_value("note", self.note)
        writer.write_str_value("number", self.number)
        writer.write_str_value("paidAt", self.paid_at)
        writer.write_str_value("paymentDue", self.payment_due)
        writer.write_str_value("purchasedBy", self.purchased_by)
        writer.write_str_value("receivedAt", self.received_at)
        writer.write_str_value("referenceNumber", self.reference_number)
        writer.write_str_value("scope", self.scope)
        writer.write_str_value("status", self.status)
        writer.write_str_value("supplierCompanyUid", self.supplier_company_uid)
        writer.write_str_value("supplierId", self.supplier_id)
        writer.write_str_value("supplierName", self.supplier_name)
        writer.write_str_value("term", self.term)
        writer.write_str_value("type", self.type)
        writer.write_datetime_value("updatedAt", self.updated_at)
    

