internal static ApiListResultInvoiceLineApiModel DeserializeApiListResultInvoiceLineApiModel(JsonElement element)
        {
            Optional <long> count = default;
            Optional <IReadOnlyList <InvoiceLineApiModel> > data = default;
            Optional <long> totalCount = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("count"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    count = property.Value.GetInt64();
                    continue;
                }
                if (property.NameEquals("data"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <InvoiceLineApiModel> array = new List <InvoiceLineApiModel>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(InvoiceLineApiModel.DeserializeInvoiceLineApiModel(item));
                    }
                    data = array;
                    continue;
                }
                if (property.NameEquals("totalCount"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    totalCount = property.Value.GetInt64();
                    continue;
                }
            }
            return(new ApiListResultInvoiceLineApiModel(Optional.ToNullable(count), Optional.ToList(data), Optional.ToNullable(totalCount)));
        }
        internal static ApiListResultInvoiceLineApiModel DeserializeApiListResultInvoiceLineApiModel(XElement element)
        {
            long?count      = default;
            long?totalCount = default;
            IReadOnlyList <InvoiceLineApiModel> data = default;

            if (element.Element("count") is XElement countElement)
            {
                count = (long?)countElement;
            }
            if (element.Element("totalCount") is XElement totalCountElement)
            {
                totalCount = (long?)totalCountElement;
            }
            var array = new List <InvoiceLineApiModel>();

            foreach (var e in element.Elements("InvoiceLineApiModel"))
            {
                array.Add(InvoiceLineApiModel.DeserializeInvoiceLineApiModel(e));
            }
            data = array;
            return(new ApiListResultInvoiceLineApiModel(count, data, totalCount));
        }
        internal static InvoiceApiModel DeserializeInvoiceApiModel(XElement element)
        {
            long?                                   aeatAprovedFileId       = default;
            double?                                 computablePercentage    = default;
            double?                                 computablePercentageVAT = default;
            DateTimeOffset?                         creationDate            = default;
            string                                  entityString            = default;
            DateTimeOffset?                         expirationDate          = default;
            string                                  footer             = default;
            bool?                                   hasAeatAprovedFile = default;
            long?                                   id                          = default;
            int?                                    invoiceClass                = default;
            string                                  invoiceClassDescription     = default;
            DateTimeOffset?                         invoiceDate                 = default;
            bool?                                   isCashCriteria              = default;
            bool?                                   isRectificationInvoice      = default;
            DocumentEntityApiModel                  issuer                      = default;
            DateTimeOffset?                         lastUpdateDate              = default;
            string                                  notes                       = default;
            string                                  number                      = default;
            long?                                   numberingFormatId           = default;
            DateTimeOffset?                         operationDate               = default;
            InvoiceApiModelOperationType?           operationType               = default;
            string                                  operationTypeDescription    = default;
            long?                                   originalIssuerEntityID      = default;
            long?                                   originalTargetEntityID      = default;
            string                                  period                      = default;
            long?                                   rectifiesInvoiceId          = default;
            long?                                   relatedEstimateId           = default;
            double?                                 retentionAmount             = default;
            double?                                 retentionPercentage         = default;
            InvoiceApiModelStatus?                  status                      = default;
            DocumentEntityApiModel                  target                      = default;
            double?                                 totalAmount                 = default;
            double?                                 totalAmountPerPay           = default;
            double?                                 totalComputableAmount       = default;
            double?                                 totalComputableAmountForVAT = default;
            double?                                 totalPayedAmount            = default;
            double?                                 totalReAmount               = default;
            double?                                 totalTaxableAmount          = default;
            double?                                 totalVatAmount              = default;
            InvoiceApiModelType?                    type                        = default;
            IReadOnlyList <InvoiceLineApiModel>     lines                       = default;
            IReadOnlyList <DocumentPaymentApiModel> payments                    = default;

            if (element.Element("aeatAprovedFileId") is XElement aeatAprovedFileIdElement)
            {
                aeatAprovedFileId = (long?)aeatAprovedFileIdElement;
            }
            if (element.Element("computablePercentage") is XElement computablePercentageElement)
            {
                computablePercentage = (double?)computablePercentageElement;
            }
            if (element.Element("computablePercentageVAT") is XElement computablePercentageVATElement)
            {
                computablePercentageVAT = (double?)computablePercentageVATElement;
            }
            if (element.Element("creationDate") is XElement creationDateElement)
            {
                creationDate = creationDateElement.GetDateTimeOffsetValue("O");
            }
            if (element.Element("entityString") is XElement entityStringElement)
            {
                entityString = (string)entityStringElement;
            }
            if (element.Element("expirationDate") is XElement expirationDateElement)
            {
                expirationDate = expirationDateElement.GetDateTimeOffsetValue("O");
            }
            if (element.Element("footer") is XElement footerElement)
            {
                footer = (string)footerElement;
            }
            if (element.Element("hasAeatAprovedFile") is XElement hasAeatAprovedFileElement)
            {
                hasAeatAprovedFile = (bool?)hasAeatAprovedFileElement;
            }
            if (element.Element("id") is XElement idElement)
            {
                id = (long?)idElement;
            }
            if (element.Element("invoiceClass") is XElement invoiceClassElement)
            {
                invoiceClass = (int?)invoiceClassElement;
            }
            if (element.Element("invoiceClassDescription") is XElement invoiceClassDescriptionElement)
            {
                invoiceClassDescription = (string)invoiceClassDescriptionElement;
            }
            if (element.Element("invoiceDate") is XElement invoiceDateElement)
            {
                invoiceDate = invoiceDateElement.GetDateTimeOffsetValue("O");
            }
            if (element.Element("isCashCriteria") is XElement isCashCriteriaElement)
            {
                isCashCriteria = (bool?)isCashCriteriaElement;
            }
            if (element.Element("isRectificationInvoice") is XElement isRectificationInvoiceElement)
            {
                isRectificationInvoice = (bool?)isRectificationInvoiceElement;
            }
            if (element.Element("issuer") is XElement issuerElement)
            {
                issuer = DocumentEntityApiModel.DeserializeDocumentEntityApiModel(issuerElement);
            }
            if (element.Element("lastUpdateDate") is XElement lastUpdateDateElement)
            {
                lastUpdateDate = lastUpdateDateElement.GetDateTimeOffsetValue("O");
            }
            if (element.Element("notes") is XElement notesElement)
            {
                notes = (string)notesElement;
            }
            if (element.Element("number") is XElement numberElement)
            {
                number = (string)numberElement;
            }
            if (element.Element("numberingFormatId") is XElement numberingFormatIdElement)
            {
                numberingFormatId = (long?)numberingFormatIdElement;
            }
            if (element.Element("operationDate") is XElement operationDateElement)
            {
                operationDate = operationDateElement.GetDateTimeOffsetValue("O");
            }
            if (element.Element("operationType") is XElement operationTypeElement)
            {
                operationType = new InvoiceApiModelOperationType(operationTypeElement.Value);
            }
            if (element.Element("operationTypeDescription") is XElement operationTypeDescriptionElement)
            {
                operationTypeDescription = (string)operationTypeDescriptionElement;
            }
            if (element.Element("originalIssuerEntityID") is XElement originalIssuerEntityIDElement)
            {
                originalIssuerEntityID = (long?)originalIssuerEntityIDElement;
            }
            if (element.Element("originalTargetEntityID") is XElement originalTargetEntityIDElement)
            {
                originalTargetEntityID = (long?)originalTargetEntityIDElement;
            }
            if (element.Element("period") is XElement periodElement)
            {
                period = (string)periodElement;
            }
            if (element.Element("rectifiesInvoiceId") is XElement rectifiesInvoiceIdElement)
            {
                rectifiesInvoiceId = (long?)rectifiesInvoiceIdElement;
            }
            if (element.Element("relatedEstimateId") is XElement relatedEstimateIdElement)
            {
                relatedEstimateId = (long?)relatedEstimateIdElement;
            }
            if (element.Element("retentionAmount") is XElement retentionAmountElement)
            {
                retentionAmount = (double?)retentionAmountElement;
            }
            if (element.Element("retentionPercentage") is XElement retentionPercentageElement)
            {
                retentionPercentage = (double?)retentionPercentageElement;
            }
            if (element.Element("status") is XElement statusElement)
            {
                status = new InvoiceApiModelStatus(statusElement.Value);
            }
            if (element.Element("target") is XElement targetElement)
            {
                target = DocumentEntityApiModel.DeserializeDocumentEntityApiModel(targetElement);
            }
            if (element.Element("totalAmount") is XElement totalAmountElement)
            {
                totalAmount = (double?)totalAmountElement;
            }
            if (element.Element("totalAmountPerPay") is XElement totalAmountPerPayElement)
            {
                totalAmountPerPay = (double?)totalAmountPerPayElement;
            }
            if (element.Element("totalComputableAmount") is XElement totalComputableAmountElement)
            {
                totalComputableAmount = (double?)totalComputableAmountElement;
            }
            if (element.Element("totalComputableAmountForVAT") is XElement totalComputableAmountForVATElement)
            {
                totalComputableAmountForVAT = (double?)totalComputableAmountForVATElement;
            }
            if (element.Element("totalPayedAmount") is XElement totalPayedAmountElement)
            {
                totalPayedAmount = (double?)totalPayedAmountElement;
            }
            if (element.Element("totalReAmount") is XElement totalReAmountElement)
            {
                totalReAmount = (double?)totalReAmountElement;
            }
            if (element.Element("totalTaxableAmount") is XElement totalTaxableAmountElement)
            {
                totalTaxableAmount = (double?)totalTaxableAmountElement;
            }
            if (element.Element("totalVatAmount") is XElement totalVatAmountElement)
            {
                totalVatAmount = (double?)totalVatAmountElement;
            }
            if (element.Element("type") is XElement typeElement)
            {
                type = new InvoiceApiModelType(typeElement.Value);
            }
            var array = new List <InvoiceLineApiModel>();

            foreach (var e in element.Elements("InvoiceLineApiModel"))
            {
                array.Add(InvoiceLineApiModel.DeserializeInvoiceLineApiModel(e));
            }
            lines = array;
            var array0 = new List <DocumentPaymentApiModel>();

            foreach (var e in element.Elements("DocumentPaymentApiModel"))
            {
                array0.Add(DocumentPaymentApiModel.DeserializeDocumentPaymentApiModel(e));
            }
            payments = array0;
            return(new InvoiceApiModel(aeatAprovedFileId, computablePercentage, computablePercentageVAT, creationDate, entityString, expirationDate, footer, hasAeatAprovedFile, id, invoiceClass, invoiceClassDescription, invoiceDate, isCashCriteria, isRectificationInvoice, issuer, lastUpdateDate, lines, notes, number, numberingFormatId, operationDate, operationType, operationTypeDescription, originalIssuerEntityID, originalTargetEntityID, payments, period, rectifiesInvoiceId, relatedEstimateId, retentionAmount, retentionPercentage, status, target, totalAmount, totalAmountPerPay, totalComputableAmount, totalComputableAmountForVAT, totalPayedAmount, totalReAmount, totalTaxableAmount, totalVatAmount, type));
        }
        internal static InvoiceApiModel DeserializeInvoiceApiModel(JsonElement element)
        {
            Optional <long>                   aeatAprovedFileId       = default;
            Optional <double>                 computablePercentage    = default;
            Optional <double>                 computablePercentageVAT = default;
            Optional <DateTimeOffset>         creationDate            = default;
            Optional <string>                 entityString            = default;
            Optional <DateTimeOffset>         expirationDate          = default;
            Optional <string>                 footer             = default;
            Optional <bool>                   hasAeatAprovedFile = default;
            Optional <long>                   id                      = default;
            Optional <int>                    invoiceClass            = default;
            Optional <string>                 invoiceClassDescription = default;
            Optional <DateTimeOffset>         invoiceDate             = default;
            Optional <bool>                   isCashCriteria          = default;
            Optional <bool>                   isRectificationInvoice  = default;
            Optional <DocumentEntityApiModel> issuer                  = default;
            Optional <DateTimeOffset>         lastUpdateDate          = default;
            Optional <IReadOnlyList <InvoiceLineApiModel> > lines     = default;
            Optional <string>         notes                              = default;
            Optional <string>         number                             = default;
            Optional <long>           numberingFormatId                  = default;
            Optional <DateTimeOffset> operationDate                      = default;
            Optional <InvoiceApiModelOperationType> operationType        = default;
            Optional <string> operationTypeDescription                   = default;
            Optional <long>   originalIssuerEntityID                     = default;
            Optional <long>   originalTargetEntityID                     = default;
            Optional <IReadOnlyList <DocumentPaymentApiModel> > payments = default;
            Optional <string> period                      = default;
            Optional <long>   rectifiesInvoiceId          = default;
            Optional <long>   relatedEstimateId           = default;
            Optional <double> retentionAmount             = default;
            Optional <double> retentionPercentage         = default;
            Optional <InvoiceApiModelStatus>  status      = default;
            Optional <DocumentEntityApiModel> target      = default;
            Optional <double> totalAmount                 = default;
            Optional <double> totalAmountPerPay           = default;
            Optional <double> totalComputableAmount       = default;
            Optional <double> totalComputableAmountForVAT = default;
            Optional <double> totalPayedAmount            = default;
            Optional <double> totalReAmount               = default;
            Optional <double> totalTaxableAmount          = default;
            Optional <double> totalVatAmount              = default;
            Optional <InvoiceApiModelType> type           = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("aeatAprovedFileId"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    aeatAprovedFileId = property.Value.GetInt64();
                    continue;
                }
                if (property.NameEquals("computablePercentage"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    computablePercentage = property.Value.GetDouble();
                    continue;
                }
                if (property.NameEquals("computablePercentageVAT"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    computablePercentageVAT = property.Value.GetDouble();
                    continue;
                }
                if (property.NameEquals("creationDate"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    creationDate = property.Value.GetDateTimeOffset("O");
                    continue;
                }
                if (property.NameEquals("entityString"))
                {
                    entityString = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("expirationDate"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    expirationDate = property.Value.GetDateTimeOffset("O");
                    continue;
                }
                if (property.NameEquals("footer"))
                {
                    footer = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("hasAeatAprovedFile"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    hasAeatAprovedFile = property.Value.GetBoolean();
                    continue;
                }
                if (property.NameEquals("id"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    id = property.Value.GetInt64();
                    continue;
                }
                if (property.NameEquals("invoiceClass"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    invoiceClass = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("invoiceClassDescription"))
                {
                    invoiceClassDescription = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("invoiceDate"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    invoiceDate = property.Value.GetDateTimeOffset("O");
                    continue;
                }
                if (property.NameEquals("isCashCriteria"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    isCashCriteria = property.Value.GetBoolean();
                    continue;
                }
                if (property.NameEquals("isRectificationInvoice"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    isRectificationInvoice = property.Value.GetBoolean();
                    continue;
                }
                if (property.NameEquals("issuer"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    issuer = DocumentEntityApiModel.DeserializeDocumentEntityApiModel(property.Value);
                    continue;
                }
                if (property.NameEquals("lastUpdateDate"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    lastUpdateDate = property.Value.GetDateTimeOffset("O");
                    continue;
                }
                if (property.NameEquals("lines"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <InvoiceLineApiModel> array = new List <InvoiceLineApiModel>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(InvoiceLineApiModel.DeserializeInvoiceLineApiModel(item));
                    }
                    lines = array;
                    continue;
                }
                if (property.NameEquals("notes"))
                {
                    notes = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("number"))
                {
                    number = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("numberingFormatId"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    numberingFormatId = property.Value.GetInt64();
                    continue;
                }
                if (property.NameEquals("operationDate"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    operationDate = property.Value.GetDateTimeOffset("O");
                    continue;
                }
                if (property.NameEquals("operationType"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    operationType = new InvoiceApiModelOperationType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("operationTypeDescription"))
                {
                    operationTypeDescription = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("originalIssuerEntityID"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    originalIssuerEntityID = property.Value.GetInt64();
                    continue;
                }
                if (property.NameEquals("originalTargetEntityID"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    originalTargetEntityID = property.Value.GetInt64();
                    continue;
                }
                if (property.NameEquals("payments"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <DocumentPaymentApiModel> array = new List <DocumentPaymentApiModel>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(DocumentPaymentApiModel.DeserializeDocumentPaymentApiModel(item));
                    }
                    payments = array;
                    continue;
                }
                if (property.NameEquals("period"))
                {
                    period = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("rectifiesInvoiceId"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    rectifiesInvoiceId = property.Value.GetInt64();
                    continue;
                }
                if (property.NameEquals("relatedEstimateId"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    relatedEstimateId = property.Value.GetInt64();
                    continue;
                }
                if (property.NameEquals("retentionAmount"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    retentionAmount = property.Value.GetDouble();
                    continue;
                }
                if (property.NameEquals("retentionPercentage"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    retentionPercentage = property.Value.GetDouble();
                    continue;
                }
                if (property.NameEquals("status"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    status = new InvoiceApiModelStatus(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("target"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    target = DocumentEntityApiModel.DeserializeDocumentEntityApiModel(property.Value);
                    continue;
                }
                if (property.NameEquals("totalAmount"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    totalAmount = property.Value.GetDouble();
                    continue;
                }
                if (property.NameEquals("totalAmountPerPay"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    totalAmountPerPay = property.Value.GetDouble();
                    continue;
                }
                if (property.NameEquals("totalComputableAmount"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    totalComputableAmount = property.Value.GetDouble();
                    continue;
                }
                if (property.NameEquals("totalComputableAmountForVAT"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    totalComputableAmountForVAT = property.Value.GetDouble();
                    continue;
                }
                if (property.NameEquals("totalPayedAmount"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    totalPayedAmount = property.Value.GetDouble();
                    continue;
                }
                if (property.NameEquals("totalReAmount"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    totalReAmount = property.Value.GetDouble();
                    continue;
                }
                if (property.NameEquals("totalTaxableAmount"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    totalTaxableAmount = property.Value.GetDouble();
                    continue;
                }
                if (property.NameEquals("totalVatAmount"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    totalVatAmount = property.Value.GetDouble();
                    continue;
                }
                if (property.NameEquals("type"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    type = new InvoiceApiModelType(property.Value.GetString());
                    continue;
                }
            }
            return(new InvoiceApiModel(Optional.ToNullable(aeatAprovedFileId), Optional.ToNullable(computablePercentage), Optional.ToNullable(computablePercentageVAT), Optional.ToNullable(creationDate), entityString.Value, Optional.ToNullable(expirationDate), footer.Value, Optional.ToNullable(hasAeatAprovedFile), Optional.ToNullable(id), Optional.ToNullable(invoiceClass), invoiceClassDescription.Value, Optional.ToNullable(invoiceDate), Optional.ToNullable(isCashCriteria), Optional.ToNullable(isRectificationInvoice), issuer.Value, Optional.ToNullable(lastUpdateDate), Optional.ToList(lines), notes.Value, number.Value, Optional.ToNullable(numberingFormatId), Optional.ToNullable(operationDate), Optional.ToNullable(operationType), operationTypeDescription.Value, Optional.ToNullable(originalIssuerEntityID), Optional.ToNullable(originalTargetEntityID), Optional.ToList(payments), period.Value, Optional.ToNullable(rectifiesInvoiceId), Optional.ToNullable(relatedEstimateId), Optional.ToNullable(retentionAmount), Optional.ToNullable(retentionPercentage), Optional.ToNullable(status), target.Value, Optional.ToNullable(totalAmount), Optional.ToNullable(totalAmountPerPay), Optional.ToNullable(totalComputableAmount), Optional.ToNullable(totalComputableAmountForVAT), Optional.ToNullable(totalPayedAmount), Optional.ToNullable(totalReAmount), Optional.ToNullable(totalTaxableAmount), Optional.ToNullable(totalVatAmount), Optional.ToNullable(type)));
        }