# coding: utf-8

"""
    (v2.0) Dynamics 365 Business Central

    (v2.0) Business Central Standard APIs

    The version of the OpenAPI document: 2.0.0
    Generated by OpenAPI Generator (https://openapi-generator.tech)

    Do not edit the class manually.
"""  # noqa: E501


from __future__ import annotations
import pprint
import re  # noqa: F401
import json

from pydantic import BaseModel, ConfigDict, Field, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from typing_extensions import Annotated
from pybusinesscentral.model.account import Account
from pybusinesscentral.model.aged_accounts_payable import AgedAccountsPayable
from pybusinesscentral.model.aged_accounts_receivable import AgedAccountsReceivable
from pybusinesscentral.model.attachments import Attachments
from pybusinesscentral.model.balance_sheet import BalanceSheet
from pybusinesscentral.model.bank_account import BankAccount
from pybusinesscentral.model.cash_flow_statement import CashFlowStatement
from pybusinesscentral.model.company_information import CompanyInformation
from pybusinesscentral.model.country_region import CountryRegion
from pybusinesscentral.model.currency import Currency
from pybusinesscentral.model.customer import Customer
from pybusinesscentral.model.customer_financial_detail import CustomerFinancialDetail
from pybusinesscentral.model.customer_payment import CustomerPayment
from pybusinesscentral.model.customer_payment_journal import CustomerPaymentJournal
from pybusinesscentral.model.customer_sale import CustomerSale
from pybusinesscentral.model.default_dimensions import DefaultDimensions
from pybusinesscentral.model.dimension import Dimension
from pybusinesscentral.model.dimension_line import DimensionLine
from pybusinesscentral.model.dimension_value import DimensionValue
from pybusinesscentral.model.employee import Employee
from pybusinesscentral.model.general_ledger_entry import GeneralLedgerEntry
from pybusinesscentral.model.general_ledger_entry_attachments import GeneralLedgerEntryAttachments
from pybusinesscentral.model.income_statement import IncomeStatement
from pybusinesscentral.model.item import Item
from pybusinesscentral.model.item_category import ItemCategory
from pybusinesscentral.model.journal import Journal
from pybusinesscentral.model.journal_line import JournalLine
from pybusinesscentral.model.payment_method import PaymentMethod
from pybusinesscentral.model.payment_term import PaymentTerm
from pybusinesscentral.model.pdf_document import PdfDocument
from pybusinesscentral.model.picture import Picture
from pybusinesscentral.model.project import Project
from pybusinesscentral.model.purchase_invoice import PurchaseInvoice
from pybusinesscentral.model.purchase_invoice_line import PurchaseInvoiceLine
from pybusinesscentral.model.retained_earnings_statement import RetainedEarningsStatement
from pybusinesscentral.model.sales_credit_memo import SalesCreditMemo
from pybusinesscentral.model.sales_credit_memo_line import SalesCreditMemoLine
from pybusinesscentral.model.sales_invoice import SalesInvoice
from pybusinesscentral.model.sales_invoice_line import SalesInvoiceLine
from pybusinesscentral.model.sales_order import SalesOrder
from pybusinesscentral.model.sales_order_line import SalesOrderLine
from pybusinesscentral.model.sales_quote import SalesQuote
from pybusinesscentral.model.sales_quote_line import SalesQuoteLine
from pybusinesscentral.model.shipment_method import ShipmentMethod
from pybusinesscentral.model.tax_area import TaxArea
from pybusinesscentral.model.tax_group import TaxGroup
from pybusinesscentral.model.time_registration_entry import TimeRegistrationEntry
from pybusinesscentral.model.trial_balance import TrialBalance
from pybusinesscentral.model.unit_of_measure import UnitOfMeasure
from pybusinesscentral.model.vendor import Vendor
from pybusinesscentral.model.vendor_purchase import VendorPurchase
from typing import Optional, Set
from typing_extensions import Self

class Company(BaseModel):
    """
    Company
    """ # noqa: E501
    id: Optional[StrictStr] = Field(default=None, description="(v1.0) The id property for the Dynamics 365 Business Central company entity")
    system_version: Optional[StrictStr] = Field(default=None, description="(v1.0) The systemVersion property for the Dynamics 365 Business Central company entity", alias="systemVersion")
    name: Optional[Annotated[str, Field(strict=True, max_length=30)]] = Field(default=None, description="(v1.0) The name property for the Dynamics 365 Business Central company entity")
    display_name: Optional[Annotated[str, Field(strict=True, max_length=250)]] = Field(default=None, description="(v1.0) The displayName property for the Dynamics 365 Business Central company entity", alias="displayName")
    business_profile_id: Optional[Annotated[str, Field(strict=True, max_length=250)]] = Field(default=None, description="(v1.0) The businessProfileId property for the Dynamics 365 Business Central company entity", alias="businessProfileId")
    items: Optional[List[Item]] = None
    picture: Optional[List[Picture]] = None
    default_dimensions: Optional[List[DefaultDimensions]] = Field(default=None, alias="defaultDimensions")
    customers: Optional[List[Customer]] = None
    customer_financial_details: Optional[List[CustomerFinancialDetail]] = Field(default=None, alias="customerFinancialDetails")
    vendors: Optional[List[Vendor]] = None
    company_information: Optional[List[CompanyInformation]] = Field(default=None, alias="companyInformation")
    sales_invoices: Optional[List[SalesInvoice]] = Field(default=None, alias="salesInvoices")
    sales_invoice_lines: Optional[List[SalesInvoiceLine]] = Field(default=None, alias="salesInvoiceLines")
    pdf_document: Optional[List[PdfDocument]] = Field(default=None, alias="pdfDocument")
    customer_payment_journals: Optional[List[CustomerPaymentJournal]] = Field(default=None, alias="customerPaymentJournals")
    customer_payments: Optional[List[CustomerPayment]] = Field(default=None, alias="customerPayments")
    accounts: Optional[List[Account]] = None
    tax_groups: Optional[List[TaxGroup]] = Field(default=None, alias="taxGroups")
    journals: Optional[List[Journal]] = None
    journal_lines: Optional[List[JournalLine]] = Field(default=None, alias="journalLines")
    attachments: Optional[List[Attachments]] = None
    employees: Optional[List[Employee]] = None
    time_registration_entries: Optional[List[TimeRegistrationEntry]] = Field(default=None, alias="timeRegistrationEntries")
    general_ledger_entries: Optional[List[GeneralLedgerEntry]] = Field(default=None, alias="generalLedgerEntries")
    currencies: Optional[List[Currency]] = None
    payment_methods: Optional[List[PaymentMethod]] = Field(default=None, alias="paymentMethods")
    dimensions: Optional[List[Dimension]] = None
    dimension_values: Optional[List[DimensionValue]] = Field(default=None, alias="dimensionValues")
    dimension_lines: Optional[List[DimensionLine]] = Field(default=None, alias="dimensionLines")
    payment_terms: Optional[List[PaymentTerm]] = Field(default=None, alias="paymentTerms")
    shipment_methods: Optional[List[ShipmentMethod]] = Field(default=None, alias="shipmentMethods")
    item_categories: Optional[List[ItemCategory]] = Field(default=None, alias="itemCategories")
    cash_flow_statement: Optional[List[CashFlowStatement]] = Field(default=None, alias="cashFlowStatement")
    countries_regions: Optional[List[CountryRegion]] = Field(default=None, alias="countriesRegions")
    sales_orders: Optional[List[SalesOrder]] = Field(default=None, alias="salesOrders")
    sales_order_lines: Optional[List[SalesOrderLine]] = Field(default=None, alias="salesOrderLines")
    retained_earnings_statement: Optional[List[RetainedEarningsStatement]] = Field(default=None, alias="retainedEarningsStatement")
    units_of_measure: Optional[List[UnitOfMeasure]] = Field(default=None, alias="unitsOfMeasure")
    aged_accounts_receivable: Optional[List[AgedAccountsReceivable]] = Field(default=None, alias="agedAccountsReceivable")
    aged_accounts_payable: Optional[List[AgedAccountsPayable]] = Field(default=None, alias="agedAccountsPayable")
    balance_sheet: Optional[List[BalanceSheet]] = Field(default=None, alias="balanceSheet")
    trial_balance: Optional[List[TrialBalance]] = Field(default=None, alias="trialBalance")
    income_statement: Optional[List[IncomeStatement]] = Field(default=None, alias="incomeStatement")
    tax_areas: Optional[List[TaxArea]] = Field(default=None, alias="taxAreas")
    sales_quotes: Optional[List[SalesQuote]] = Field(default=None, alias="salesQuotes")
    sales_quote_lines: Optional[List[SalesQuoteLine]] = Field(default=None, alias="salesQuoteLines")
    sales_credit_memos: Optional[List[SalesCreditMemo]] = Field(default=None, alias="salesCreditMemos")
    sales_credit_memo_lines: Optional[List[SalesCreditMemoLine]] = Field(default=None, alias="salesCreditMemoLines")
    general_ledger_entry_attachments: Optional[List[GeneralLedgerEntryAttachments]] = Field(default=None, alias="generalLedgerEntryAttachments")
    purchase_invoices: Optional[List[PurchaseInvoice]] = Field(default=None, alias="purchaseInvoices")
    purchase_invoice_lines: Optional[List[PurchaseInvoiceLine]] = Field(default=None, alias="purchaseInvoiceLines")
    projects: Optional[List[Project]] = None
    bank_accounts: Optional[List[BankAccount]] = Field(default=None, alias="bankAccounts")
    customer_sales: Optional[List[CustomerSale]] = Field(default=None, alias="customerSales")
    vendor_purchases: Optional[List[VendorPurchase]] = Field(default=None, alias="vendorPurchases")
    __properties: ClassVar[List[str]] = ["id", "systemVersion", "name", "displayName", "businessProfileId", "items", "picture", "defaultDimensions", "customers", "customerFinancialDetails", "vendors", "companyInformation", "salesInvoices", "salesInvoiceLines", "pdfDocument", "customerPaymentJournals", "customerPayments", "accounts", "taxGroups", "journals", "journalLines", "attachments", "employees", "timeRegistrationEntries", "generalLedgerEntries", "currencies", "paymentMethods", "dimensions", "dimensionValues", "dimensionLines", "paymentTerms", "shipmentMethods", "itemCategories", "cashFlowStatement", "countriesRegions", "salesOrders", "salesOrderLines", "retainedEarningsStatement", "unitsOfMeasure", "agedAccountsReceivable", "agedAccountsPayable", "balanceSheet", "trialBalance", "incomeStatement", "taxAreas", "salesQuotes", "salesQuoteLines", "salesCreditMemos", "salesCreditMemoLines", "generalLedgerEntryAttachments", "purchaseInvoices", "purchaseInvoiceLines", "projects", "bankAccounts", "customerSales", "vendorPurchases"]

    model_config = ConfigDict(
        populate_by_name=True,
        validate_assignment=True,
        protected_namespaces=(),
    )


    def to_str(self) -> str:
        """Returns the string representation of the model using alias"""
        return pprint.pformat(self.model_dump(by_alias=True))

    def to_json(self) -> str:
        """Returns the JSON representation of the model using alias"""
        # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
        return json.dumps(self.to_dict())

    @classmethod
    def from_json(cls, json_str: str) -> Optional[Self]:
        """Create an instance of Company from a JSON string"""
        return cls.from_dict(json.loads(json_str))

    def to_dict(self) -> Dict[str, Any]:
        """Return the dictionary representation of the model using alias.

        This has the following differences from calling pydantic's
        `self.model_dump(by_alias=True)`:

        * `None` is only added to the output dict for nullable fields that
          were set at model initialization. Other fields with value `None`
          are ignored.
        """
        excluded_fields: Set[str] = set([
        ])

        _dict = self.model_dump(
            by_alias=True,
            exclude=excluded_fields,
            exclude_none=True,
        )
        # override the default output from pydantic by calling `to_dict()` of each item in items (list)
        _items = []
        if self.items:
            for _item_items in self.items:
                if _item_items:
                    _items.append(_item_items.to_dict())
            _dict['items'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in picture (list)
        _items = []
        if self.picture:
            for _item_picture in self.picture:
                if _item_picture:
                    _items.append(_item_picture.to_dict())
            _dict['picture'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in default_dimensions (list)
        _items = []
        if self.default_dimensions:
            for _item_default_dimensions in self.default_dimensions:
                if _item_default_dimensions:
                    _items.append(_item_default_dimensions.to_dict())
            _dict['defaultDimensions'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in customers (list)
        _items = []
        if self.customers:
            for _item_customers in self.customers:
                if _item_customers:
                    _items.append(_item_customers.to_dict())
            _dict['customers'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in customer_financial_details (list)
        _items = []
        if self.customer_financial_details:
            for _item_customer_financial_details in self.customer_financial_details:
                if _item_customer_financial_details:
                    _items.append(_item_customer_financial_details.to_dict())
            _dict['customerFinancialDetails'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in vendors (list)
        _items = []
        if self.vendors:
            for _item_vendors in self.vendors:
                if _item_vendors:
                    _items.append(_item_vendors.to_dict())
            _dict['vendors'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in company_information (list)
        _items = []
        if self.company_information:
            for _item_company_information in self.company_information:
                if _item_company_information:
                    _items.append(_item_company_information.to_dict())
            _dict['companyInformation'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in sales_invoices (list)
        _items = []
        if self.sales_invoices:
            for _item_sales_invoices in self.sales_invoices:
                if _item_sales_invoices:
                    _items.append(_item_sales_invoices.to_dict())
            _dict['salesInvoices'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in sales_invoice_lines (list)
        _items = []
        if self.sales_invoice_lines:
            for _item_sales_invoice_lines in self.sales_invoice_lines:
                if _item_sales_invoice_lines:
                    _items.append(_item_sales_invoice_lines.to_dict())
            _dict['salesInvoiceLines'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in pdf_document (list)
        _items = []
        if self.pdf_document:
            for _item_pdf_document in self.pdf_document:
                if _item_pdf_document:
                    _items.append(_item_pdf_document.to_dict())
            _dict['pdfDocument'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in customer_payment_journals (list)
        _items = []
        if self.customer_payment_journals:
            for _item_customer_payment_journals in self.customer_payment_journals:
                if _item_customer_payment_journals:
                    _items.append(_item_customer_payment_journals.to_dict())
            _dict['customerPaymentJournals'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in customer_payments (list)
        _items = []
        if self.customer_payments:
            for _item_customer_payments in self.customer_payments:
                if _item_customer_payments:
                    _items.append(_item_customer_payments.to_dict())
            _dict['customerPayments'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in accounts (list)
        _items = []
        if self.accounts:
            for _item_accounts in self.accounts:
                if _item_accounts:
                    _items.append(_item_accounts.to_dict())
            _dict['accounts'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in tax_groups (list)
        _items = []
        if self.tax_groups:
            for _item_tax_groups in self.tax_groups:
                if _item_tax_groups:
                    _items.append(_item_tax_groups.to_dict())
            _dict['taxGroups'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in journals (list)
        _items = []
        if self.journals:
            for _item_journals in self.journals:
                if _item_journals:
                    _items.append(_item_journals.to_dict())
            _dict['journals'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in journal_lines (list)
        _items = []
        if self.journal_lines:
            for _item_journal_lines in self.journal_lines:
                if _item_journal_lines:
                    _items.append(_item_journal_lines.to_dict())
            _dict['journalLines'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in attachments (list)
        _items = []
        if self.attachments:
            for _item_attachments in self.attachments:
                if _item_attachments:
                    _items.append(_item_attachments.to_dict())
            _dict['attachments'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in employees (list)
        _items = []
        if self.employees:
            for _item_employees in self.employees:
                if _item_employees:
                    _items.append(_item_employees.to_dict())
            _dict['employees'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in time_registration_entries (list)
        _items = []
        if self.time_registration_entries:
            for _item_time_registration_entries in self.time_registration_entries:
                if _item_time_registration_entries:
                    _items.append(_item_time_registration_entries.to_dict())
            _dict['timeRegistrationEntries'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in general_ledger_entries (list)
        _items = []
        if self.general_ledger_entries:
            for _item_general_ledger_entries in self.general_ledger_entries:
                if _item_general_ledger_entries:
                    _items.append(_item_general_ledger_entries.to_dict())
            _dict['generalLedgerEntries'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in currencies (list)
        _items = []
        if self.currencies:
            for _item_currencies in self.currencies:
                if _item_currencies:
                    _items.append(_item_currencies.to_dict())
            _dict['currencies'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in payment_methods (list)
        _items = []
        if self.payment_methods:
            for _item_payment_methods in self.payment_methods:
                if _item_payment_methods:
                    _items.append(_item_payment_methods.to_dict())
            _dict['paymentMethods'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in dimensions (list)
        _items = []
        if self.dimensions:
            for _item_dimensions in self.dimensions:
                if _item_dimensions:
                    _items.append(_item_dimensions.to_dict())
            _dict['dimensions'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in dimension_values (list)
        _items = []
        if self.dimension_values:
            for _item_dimension_values in self.dimension_values:
                if _item_dimension_values:
                    _items.append(_item_dimension_values.to_dict())
            _dict['dimensionValues'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in dimension_lines (list)
        _items = []
        if self.dimension_lines:
            for _item_dimension_lines in self.dimension_lines:
                if _item_dimension_lines:
                    _items.append(_item_dimension_lines.to_dict())
            _dict['dimensionLines'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in payment_terms (list)
        _items = []
        if self.payment_terms:
            for _item_payment_terms in self.payment_terms:
                if _item_payment_terms:
                    _items.append(_item_payment_terms.to_dict())
            _dict['paymentTerms'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in shipment_methods (list)
        _items = []
        if self.shipment_methods:
            for _item_shipment_methods in self.shipment_methods:
                if _item_shipment_methods:
                    _items.append(_item_shipment_methods.to_dict())
            _dict['shipmentMethods'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in item_categories (list)
        _items = []
        if self.item_categories:
            for _item_item_categories in self.item_categories:
                if _item_item_categories:
                    _items.append(_item_item_categories.to_dict())
            _dict['itemCategories'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in cash_flow_statement (list)
        _items = []
        if self.cash_flow_statement:
            for _item_cash_flow_statement in self.cash_flow_statement:
                if _item_cash_flow_statement:
                    _items.append(_item_cash_flow_statement.to_dict())
            _dict['cashFlowStatement'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in countries_regions (list)
        _items = []
        if self.countries_regions:
            for _item_countries_regions in self.countries_regions:
                if _item_countries_regions:
                    _items.append(_item_countries_regions.to_dict())
            _dict['countriesRegions'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in sales_orders (list)
        _items = []
        if self.sales_orders:
            for _item_sales_orders in self.sales_orders:
                if _item_sales_orders:
                    _items.append(_item_sales_orders.to_dict())
            _dict['salesOrders'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in sales_order_lines (list)
        _items = []
        if self.sales_order_lines:
            for _item_sales_order_lines in self.sales_order_lines:
                if _item_sales_order_lines:
                    _items.append(_item_sales_order_lines.to_dict())
            _dict['salesOrderLines'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in retained_earnings_statement (list)
        _items = []
        if self.retained_earnings_statement:
            for _item_retained_earnings_statement in self.retained_earnings_statement:
                if _item_retained_earnings_statement:
                    _items.append(_item_retained_earnings_statement.to_dict())
            _dict['retainedEarningsStatement'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in units_of_measure (list)
        _items = []
        if self.units_of_measure:
            for _item_units_of_measure in self.units_of_measure:
                if _item_units_of_measure:
                    _items.append(_item_units_of_measure.to_dict())
            _dict['unitsOfMeasure'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in aged_accounts_receivable (list)
        _items = []
        if self.aged_accounts_receivable:
            for _item_aged_accounts_receivable in self.aged_accounts_receivable:
                if _item_aged_accounts_receivable:
                    _items.append(_item_aged_accounts_receivable.to_dict())
            _dict['agedAccountsReceivable'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in aged_accounts_payable (list)
        _items = []
        if self.aged_accounts_payable:
            for _item_aged_accounts_payable in self.aged_accounts_payable:
                if _item_aged_accounts_payable:
                    _items.append(_item_aged_accounts_payable.to_dict())
            _dict['agedAccountsPayable'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in balance_sheet (list)
        _items = []
        if self.balance_sheet:
            for _item_balance_sheet in self.balance_sheet:
                if _item_balance_sheet:
                    _items.append(_item_balance_sheet.to_dict())
            _dict['balanceSheet'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in trial_balance (list)
        _items = []
        if self.trial_balance:
            for _item_trial_balance in self.trial_balance:
                if _item_trial_balance:
                    _items.append(_item_trial_balance.to_dict())
            _dict['trialBalance'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in income_statement (list)
        _items = []
        if self.income_statement:
            for _item_income_statement in self.income_statement:
                if _item_income_statement:
                    _items.append(_item_income_statement.to_dict())
            _dict['incomeStatement'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in tax_areas (list)
        _items = []
        if self.tax_areas:
            for _item_tax_areas in self.tax_areas:
                if _item_tax_areas:
                    _items.append(_item_tax_areas.to_dict())
            _dict['taxAreas'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in sales_quotes (list)
        _items = []
        if self.sales_quotes:
            for _item_sales_quotes in self.sales_quotes:
                if _item_sales_quotes:
                    _items.append(_item_sales_quotes.to_dict())
            _dict['salesQuotes'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in sales_quote_lines (list)
        _items = []
        if self.sales_quote_lines:
            for _item_sales_quote_lines in self.sales_quote_lines:
                if _item_sales_quote_lines:
                    _items.append(_item_sales_quote_lines.to_dict())
            _dict['salesQuoteLines'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in sales_credit_memos (list)
        _items = []
        if self.sales_credit_memos:
            for _item_sales_credit_memos in self.sales_credit_memos:
                if _item_sales_credit_memos:
                    _items.append(_item_sales_credit_memos.to_dict())
            _dict['salesCreditMemos'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in sales_credit_memo_lines (list)
        _items = []
        if self.sales_credit_memo_lines:
            for _item_sales_credit_memo_lines in self.sales_credit_memo_lines:
                if _item_sales_credit_memo_lines:
                    _items.append(_item_sales_credit_memo_lines.to_dict())
            _dict['salesCreditMemoLines'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in general_ledger_entry_attachments (list)
        _items = []
        if self.general_ledger_entry_attachments:
            for _item_general_ledger_entry_attachments in self.general_ledger_entry_attachments:
                if _item_general_ledger_entry_attachments:
                    _items.append(_item_general_ledger_entry_attachments.to_dict())
            _dict['generalLedgerEntryAttachments'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in purchase_invoices (list)
        _items = []
        if self.purchase_invoices:
            for _item_purchase_invoices in self.purchase_invoices:
                if _item_purchase_invoices:
                    _items.append(_item_purchase_invoices.to_dict())
            _dict['purchaseInvoices'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in purchase_invoice_lines (list)
        _items = []
        if self.purchase_invoice_lines:
            for _item_purchase_invoice_lines in self.purchase_invoice_lines:
                if _item_purchase_invoice_lines:
                    _items.append(_item_purchase_invoice_lines.to_dict())
            _dict['purchaseInvoiceLines'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in projects (list)
        _items = []
        if self.projects:
            for _item_projects in self.projects:
                if _item_projects:
                    _items.append(_item_projects.to_dict())
            _dict['projects'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in bank_accounts (list)
        _items = []
        if self.bank_accounts:
            for _item_bank_accounts in self.bank_accounts:
                if _item_bank_accounts:
                    _items.append(_item_bank_accounts.to_dict())
            _dict['bankAccounts'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in customer_sales (list)
        _items = []
        if self.customer_sales:
            for _item_customer_sales in self.customer_sales:
                if _item_customer_sales:
                    _items.append(_item_customer_sales.to_dict())
            _dict['customerSales'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in vendor_purchases (list)
        _items = []
        if self.vendor_purchases:
            for _item_vendor_purchases in self.vendor_purchases:
                if _item_vendor_purchases:
                    _items.append(_item_vendor_purchases.to_dict())
            _dict['vendorPurchases'] = _items
        # set to None if system_version (nullable) is None
        # and model_fields_set contains the field
        if self.system_version is None and "system_version" in self.model_fields_set:
            _dict['systemVersion'] = None

        # set to None if name (nullable) is None
        # and model_fields_set contains the field
        if self.name is None and "name" in self.model_fields_set:
            _dict['name'] = None

        # set to None if display_name (nullable) is None
        # and model_fields_set contains the field
        if self.display_name is None and "display_name" in self.model_fields_set:
            _dict['displayName'] = None

        # set to None if business_profile_id (nullable) is None
        # and model_fields_set contains the field
        if self.business_profile_id is None and "business_profile_id" in self.model_fields_set:
            _dict['businessProfileId'] = None

        # set to None if items (nullable) is None
        # and model_fields_set contains the field
        if self.items is None and "items" in self.model_fields_set:
            _dict['items'] = None

        # set to None if picture (nullable) is None
        # and model_fields_set contains the field
        if self.picture is None and "picture" in self.model_fields_set:
            _dict['picture'] = None

        # set to None if default_dimensions (nullable) is None
        # and model_fields_set contains the field
        if self.default_dimensions is None and "default_dimensions" in self.model_fields_set:
            _dict['defaultDimensions'] = None

        # set to None if customers (nullable) is None
        # and model_fields_set contains the field
        if self.customers is None and "customers" in self.model_fields_set:
            _dict['customers'] = None

        # set to None if customer_financial_details (nullable) is None
        # and model_fields_set contains the field
        if self.customer_financial_details is None and "customer_financial_details" in self.model_fields_set:
            _dict['customerFinancialDetails'] = None

        # set to None if vendors (nullable) is None
        # and model_fields_set contains the field
        if self.vendors is None and "vendors" in self.model_fields_set:
            _dict['vendors'] = None

        # set to None if company_information (nullable) is None
        # and model_fields_set contains the field
        if self.company_information is None and "company_information" in self.model_fields_set:
            _dict['companyInformation'] = None

        # set to None if sales_invoices (nullable) is None
        # and model_fields_set contains the field
        if self.sales_invoices is None and "sales_invoices" in self.model_fields_set:
            _dict['salesInvoices'] = None

        # set to None if sales_invoice_lines (nullable) is None
        # and model_fields_set contains the field
        if self.sales_invoice_lines is None and "sales_invoice_lines" in self.model_fields_set:
            _dict['salesInvoiceLines'] = None

        # set to None if pdf_document (nullable) is None
        # and model_fields_set contains the field
        if self.pdf_document is None and "pdf_document" in self.model_fields_set:
            _dict['pdfDocument'] = None

        # set to None if customer_payment_journals (nullable) is None
        # and model_fields_set contains the field
        if self.customer_payment_journals is None and "customer_payment_journals" in self.model_fields_set:
            _dict['customerPaymentJournals'] = None

        # set to None if customer_payments (nullable) is None
        # and model_fields_set contains the field
        if self.customer_payments is None and "customer_payments" in self.model_fields_set:
            _dict['customerPayments'] = None

        # set to None if accounts (nullable) is None
        # and model_fields_set contains the field
        if self.accounts is None and "accounts" in self.model_fields_set:
            _dict['accounts'] = None

        # set to None if tax_groups (nullable) is None
        # and model_fields_set contains the field
        if self.tax_groups is None and "tax_groups" in self.model_fields_set:
            _dict['taxGroups'] = None

        # set to None if journals (nullable) is None
        # and model_fields_set contains the field
        if self.journals is None and "journals" in self.model_fields_set:
            _dict['journals'] = None

        # set to None if journal_lines (nullable) is None
        # and model_fields_set contains the field
        if self.journal_lines is None and "journal_lines" in self.model_fields_set:
            _dict['journalLines'] = None

        # set to None if attachments (nullable) is None
        # and model_fields_set contains the field
        if self.attachments is None and "attachments" in self.model_fields_set:
            _dict['attachments'] = None

        # set to None if employees (nullable) is None
        # and model_fields_set contains the field
        if self.employees is None and "employees" in self.model_fields_set:
            _dict['employees'] = None

        # set to None if time_registration_entries (nullable) is None
        # and model_fields_set contains the field
        if self.time_registration_entries is None and "time_registration_entries" in self.model_fields_set:
            _dict['timeRegistrationEntries'] = None

        # set to None if general_ledger_entries (nullable) is None
        # and model_fields_set contains the field
        if self.general_ledger_entries is None and "general_ledger_entries" in self.model_fields_set:
            _dict['generalLedgerEntries'] = None

        # set to None if currencies (nullable) is None
        # and model_fields_set contains the field
        if self.currencies is None and "currencies" in self.model_fields_set:
            _dict['currencies'] = None

        # set to None if payment_methods (nullable) is None
        # and model_fields_set contains the field
        if self.payment_methods is None and "payment_methods" in self.model_fields_set:
            _dict['paymentMethods'] = None

        # set to None if dimensions (nullable) is None
        # and model_fields_set contains the field
        if self.dimensions is None and "dimensions" in self.model_fields_set:
            _dict['dimensions'] = None

        # set to None if dimension_values (nullable) is None
        # and model_fields_set contains the field
        if self.dimension_values is None and "dimension_values" in self.model_fields_set:
            _dict['dimensionValues'] = None

        # set to None if dimension_lines (nullable) is None
        # and model_fields_set contains the field
        if self.dimension_lines is None and "dimension_lines" in self.model_fields_set:
            _dict['dimensionLines'] = None

        # set to None if payment_terms (nullable) is None
        # and model_fields_set contains the field
        if self.payment_terms is None and "payment_terms" in self.model_fields_set:
            _dict['paymentTerms'] = None

        # set to None if shipment_methods (nullable) is None
        # and model_fields_set contains the field
        if self.shipment_methods is None and "shipment_methods" in self.model_fields_set:
            _dict['shipmentMethods'] = None

        # set to None if item_categories (nullable) is None
        # and model_fields_set contains the field
        if self.item_categories is None and "item_categories" in self.model_fields_set:
            _dict['itemCategories'] = None

        # set to None if cash_flow_statement (nullable) is None
        # and model_fields_set contains the field
        if self.cash_flow_statement is None and "cash_flow_statement" in self.model_fields_set:
            _dict['cashFlowStatement'] = None

        # set to None if countries_regions (nullable) is None
        # and model_fields_set contains the field
        if self.countries_regions is None and "countries_regions" in self.model_fields_set:
            _dict['countriesRegions'] = None

        # set to None if sales_orders (nullable) is None
        # and model_fields_set contains the field
        if self.sales_orders is None and "sales_orders" in self.model_fields_set:
            _dict['salesOrders'] = None

        # set to None if sales_order_lines (nullable) is None
        # and model_fields_set contains the field
        if self.sales_order_lines is None and "sales_order_lines" in self.model_fields_set:
            _dict['salesOrderLines'] = None

        # set to None if retained_earnings_statement (nullable) is None
        # and model_fields_set contains the field
        if self.retained_earnings_statement is None and "retained_earnings_statement" in self.model_fields_set:
            _dict['retainedEarningsStatement'] = None

        # set to None if units_of_measure (nullable) is None
        # and model_fields_set contains the field
        if self.units_of_measure is None and "units_of_measure" in self.model_fields_set:
            _dict['unitsOfMeasure'] = None

        # set to None if aged_accounts_receivable (nullable) is None
        # and model_fields_set contains the field
        if self.aged_accounts_receivable is None and "aged_accounts_receivable" in self.model_fields_set:
            _dict['agedAccountsReceivable'] = None

        # set to None if aged_accounts_payable (nullable) is None
        # and model_fields_set contains the field
        if self.aged_accounts_payable is None and "aged_accounts_payable" in self.model_fields_set:
            _dict['agedAccountsPayable'] = None

        # set to None if balance_sheet (nullable) is None
        # and model_fields_set contains the field
        if self.balance_sheet is None and "balance_sheet" in self.model_fields_set:
            _dict['balanceSheet'] = None

        # set to None if trial_balance (nullable) is None
        # and model_fields_set contains the field
        if self.trial_balance is None and "trial_balance" in self.model_fields_set:
            _dict['trialBalance'] = None

        # set to None if income_statement (nullable) is None
        # and model_fields_set contains the field
        if self.income_statement is None and "income_statement" in self.model_fields_set:
            _dict['incomeStatement'] = None

        # set to None if tax_areas (nullable) is None
        # and model_fields_set contains the field
        if self.tax_areas is None and "tax_areas" in self.model_fields_set:
            _dict['taxAreas'] = None

        # set to None if sales_quotes (nullable) is None
        # and model_fields_set contains the field
        if self.sales_quotes is None and "sales_quotes" in self.model_fields_set:
            _dict['salesQuotes'] = None

        # set to None if sales_quote_lines (nullable) is None
        # and model_fields_set contains the field
        if self.sales_quote_lines is None and "sales_quote_lines" in self.model_fields_set:
            _dict['salesQuoteLines'] = None

        # set to None if sales_credit_memos (nullable) is None
        # and model_fields_set contains the field
        if self.sales_credit_memos is None and "sales_credit_memos" in self.model_fields_set:
            _dict['salesCreditMemos'] = None

        # set to None if sales_credit_memo_lines (nullable) is None
        # and model_fields_set contains the field
        if self.sales_credit_memo_lines is None and "sales_credit_memo_lines" in self.model_fields_set:
            _dict['salesCreditMemoLines'] = None

        # set to None if general_ledger_entry_attachments (nullable) is None
        # and model_fields_set contains the field
        if self.general_ledger_entry_attachments is None and "general_ledger_entry_attachments" in self.model_fields_set:
            _dict['generalLedgerEntryAttachments'] = None

        # set to None if purchase_invoices (nullable) is None
        # and model_fields_set contains the field
        if self.purchase_invoices is None and "purchase_invoices" in self.model_fields_set:
            _dict['purchaseInvoices'] = None

        # set to None if purchase_invoice_lines (nullable) is None
        # and model_fields_set contains the field
        if self.purchase_invoice_lines is None and "purchase_invoice_lines" in self.model_fields_set:
            _dict['purchaseInvoiceLines'] = None

        # set to None if projects (nullable) is None
        # and model_fields_set contains the field
        if self.projects is None and "projects" in self.model_fields_set:
            _dict['projects'] = None

        # set to None if bank_accounts (nullable) is None
        # and model_fields_set contains the field
        if self.bank_accounts is None and "bank_accounts" in self.model_fields_set:
            _dict['bankAccounts'] = None

        # set to None if customer_sales (nullable) is None
        # and model_fields_set contains the field
        if self.customer_sales is None and "customer_sales" in self.model_fields_set:
            _dict['customerSales'] = None

        # set to None if vendor_purchases (nullable) is None
        # and model_fields_set contains the field
        if self.vendor_purchases is None and "vendor_purchases" in self.model_fields_set:
            _dict['vendorPurchases'] = None

        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of Company from a dict"""
        if obj is None:
            return None

        if not isinstance(obj, dict):
            return cls.model_validate(obj)

        _obj = cls.model_validate({
            "id": obj.get("id"),
            "systemVersion": obj.get("systemVersion"),
            "name": obj.get("name"),
            "displayName": obj.get("displayName"),
            "businessProfileId": obj.get("businessProfileId"),
            "items": [Item.from_dict(_item) for _item in obj["items"]] if obj.get("items") is not None else None,
            "picture": [Picture.from_dict(_item) for _item in obj["picture"]] if obj.get("picture") is not None else None,
            "defaultDimensions": [DefaultDimensions.from_dict(_item) for _item in obj["defaultDimensions"]] if obj.get("defaultDimensions") is not None else None,
            "customers": [Customer.from_dict(_item) for _item in obj["customers"]] if obj.get("customers") is not None else None,
            "customerFinancialDetails": [CustomerFinancialDetail.from_dict(_item) for _item in obj["customerFinancialDetails"]] if obj.get("customerFinancialDetails") is not None else None,
            "vendors": [Vendor.from_dict(_item) for _item in obj["vendors"]] if obj.get("vendors") is not None else None,
            "companyInformation": [CompanyInformation.from_dict(_item) for _item in obj["companyInformation"]] if obj.get("companyInformation") is not None else None,
            "salesInvoices": [SalesInvoice.from_dict(_item) for _item in obj["salesInvoices"]] if obj.get("salesInvoices") is not None else None,
            "salesInvoiceLines": [SalesInvoiceLine.from_dict(_item) for _item in obj["salesInvoiceLines"]] if obj.get("salesInvoiceLines") is not None else None,
            "pdfDocument": [PdfDocument.from_dict(_item) for _item in obj["pdfDocument"]] if obj.get("pdfDocument") is not None else None,
            "customerPaymentJournals": [CustomerPaymentJournal.from_dict(_item) for _item in obj["customerPaymentJournals"]] if obj.get("customerPaymentJournals") is not None else None,
            "customerPayments": [CustomerPayment.from_dict(_item) for _item in obj["customerPayments"]] if obj.get("customerPayments") is not None else None,
            "accounts": [Account.from_dict(_item) for _item in obj["accounts"]] if obj.get("accounts") is not None else None,
            "taxGroups": [TaxGroup.from_dict(_item) for _item in obj["taxGroups"]] if obj.get("taxGroups") is not None else None,
            "journals": [Journal.from_dict(_item) for _item in obj["journals"]] if obj.get("journals") is not None else None,
            "journalLines": [JournalLine.from_dict(_item) for _item in obj["journalLines"]] if obj.get("journalLines") is not None else None,
            "attachments": [Attachments.from_dict(_item) for _item in obj["attachments"]] if obj.get("attachments") is not None else None,
            "employees": [Employee.from_dict(_item) for _item in obj["employees"]] if obj.get("employees") is not None else None,
            "timeRegistrationEntries": [TimeRegistrationEntry.from_dict(_item) for _item in obj["timeRegistrationEntries"]] if obj.get("timeRegistrationEntries") is not None else None,
            "generalLedgerEntries": [GeneralLedgerEntry.from_dict(_item) for _item in obj["generalLedgerEntries"]] if obj.get("generalLedgerEntries") is not None else None,
            "currencies": [Currency.from_dict(_item) for _item in obj["currencies"]] if obj.get("currencies") is not None else None,
            "paymentMethods": [PaymentMethod.from_dict(_item) for _item in obj["paymentMethods"]] if obj.get("paymentMethods") is not None else None,
            "dimensions": [Dimension.from_dict(_item) for _item in obj["dimensions"]] if obj.get("dimensions") is not None else None,
            "dimensionValues": [DimensionValue.from_dict(_item) for _item in obj["dimensionValues"]] if obj.get("dimensionValues") is not None else None,
            "dimensionLines": [DimensionLine.from_dict(_item) for _item in obj["dimensionLines"]] if obj.get("dimensionLines") is not None else None,
            "paymentTerms": [PaymentTerm.from_dict(_item) for _item in obj["paymentTerms"]] if obj.get("paymentTerms") is not None else None,
            "shipmentMethods": [ShipmentMethod.from_dict(_item) for _item in obj["shipmentMethods"]] if obj.get("shipmentMethods") is not None else None,
            "itemCategories": [ItemCategory.from_dict(_item) for _item in obj["itemCategories"]] if obj.get("itemCategories") is not None else None,
            "cashFlowStatement": [CashFlowStatement.from_dict(_item) for _item in obj["cashFlowStatement"]] if obj.get("cashFlowStatement") is not None else None,
            "countriesRegions": [CountryRegion.from_dict(_item) for _item in obj["countriesRegions"]] if obj.get("countriesRegions") is not None else None,
            "salesOrders": [SalesOrder.from_dict(_item) for _item in obj["salesOrders"]] if obj.get("salesOrders") is not None else None,
            "salesOrderLines": [SalesOrderLine.from_dict(_item) for _item in obj["salesOrderLines"]] if obj.get("salesOrderLines") is not None else None,
            "retainedEarningsStatement": [RetainedEarningsStatement.from_dict(_item) for _item in obj["retainedEarningsStatement"]] if obj.get("retainedEarningsStatement") is not None else None,
            "unitsOfMeasure": [UnitOfMeasure.from_dict(_item) for _item in obj["unitsOfMeasure"]] if obj.get("unitsOfMeasure") is not None else None,
            "agedAccountsReceivable": [AgedAccountsReceivable.from_dict(_item) for _item in obj["agedAccountsReceivable"]] if obj.get("agedAccountsReceivable") is not None else None,
            "agedAccountsPayable": [AgedAccountsPayable.from_dict(_item) for _item in obj["agedAccountsPayable"]] if obj.get("agedAccountsPayable") is not None else None,
            "balanceSheet": [BalanceSheet.from_dict(_item) for _item in obj["balanceSheet"]] if obj.get("balanceSheet") is not None else None,
            "trialBalance": [TrialBalance.from_dict(_item) for _item in obj["trialBalance"]] if obj.get("trialBalance") is not None else None,
            "incomeStatement": [IncomeStatement.from_dict(_item) for _item in obj["incomeStatement"]] if obj.get("incomeStatement") is not None else None,
            "taxAreas": [TaxArea.from_dict(_item) for _item in obj["taxAreas"]] if obj.get("taxAreas") is not None else None,
            "salesQuotes": [SalesQuote.from_dict(_item) for _item in obj["salesQuotes"]] if obj.get("salesQuotes") is not None else None,
            "salesQuoteLines": [SalesQuoteLine.from_dict(_item) for _item in obj["salesQuoteLines"]] if obj.get("salesQuoteLines") is not None else None,
            "salesCreditMemos": [SalesCreditMemo.from_dict(_item) for _item in obj["salesCreditMemos"]] if obj.get("salesCreditMemos") is not None else None,
            "salesCreditMemoLines": [SalesCreditMemoLine.from_dict(_item) for _item in obj["salesCreditMemoLines"]] if obj.get("salesCreditMemoLines") is not None else None,
            "generalLedgerEntryAttachments": [GeneralLedgerEntryAttachments.from_dict(_item) for _item in obj["generalLedgerEntryAttachments"]] if obj.get("generalLedgerEntryAttachments") is not None else None,
            "purchaseInvoices": [PurchaseInvoice.from_dict(_item) for _item in obj["purchaseInvoices"]] if obj.get("purchaseInvoices") is not None else None,
            "purchaseInvoiceLines": [PurchaseInvoiceLine.from_dict(_item) for _item in obj["purchaseInvoiceLines"]] if obj.get("purchaseInvoiceLines") is not None else None,
            "projects": [Project.from_dict(_item) for _item in obj["projects"]] if obj.get("projects") is not None else None,
            "bankAccounts": [BankAccount.from_dict(_item) for _item in obj["bankAccounts"]] if obj.get("bankAccounts") is not None else None,
            "customerSales": [CustomerSale.from_dict(_item) for _item in obj["customerSales"]] if obj.get("customerSales") is not None else None,
            "vendorPurchases": [VendorPurchase.from_dict(_item) for _item in obj["vendorPurchases"]] if obj.get("vendorPurchases") is not None else None
        })
        return _obj


