All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.zuora.model.Invoice Maven / Gradle / Ivy

There is a newer version: 3.2.1
Show newest version
/*
 * Zuora API Reference
 * REST API reference for the Zuora Billing, Payments, and Central Platform! Check out the [REST API Overview](https://www.zuora.com/developer/api-references/api/overview/).
 *
 * The version of the OpenAPI document: 2024-05-20
 * Contact: [email protected]
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */


package com.zuora.model;

import java.util.Objects;
import com.google.gson.TypeAdapter;
import com.google.gson.annotations.JsonAdapter;
import com.google.gson.annotations.SerializedName;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import com.zuora.model.BillingDocumentStatus;
import com.zuora.model.EInvoiceStatus;
import com.zuora.model.TaxStatus;
import com.zuora.model.TransferredToAccountingStatus;
import java.io.IOException;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.Arrays;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonArray;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import com.google.gson.TypeAdapterFactory;
import com.google.gson.reflect.TypeToken;
import com.google.gson.TypeAdapter;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;

import com.zuora.JSON;

/**
 * Invoice
 */
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.6.0")
public class Invoice {
  public static final String SERIALIZED_NAME_INTEGRATION_ID_N_S = "IntegrationId__NS";
  @SerializedName(SERIALIZED_NAME_INTEGRATION_ID_N_S)
  private String integrationIdNS;

  public static final String SERIALIZED_NAME_INTEGRATION_STATUS_N_S = "IntegrationStatus__NS";
  @SerializedName(SERIALIZED_NAME_INTEGRATION_STATUS_N_S)
  private String integrationStatusNS;

  public static final String SERIALIZED_NAME_SYNC_DATE_N_S = "SyncDate__NS";
  @SerializedName(SERIALIZED_NAME_SYNC_DATE_N_S)
  private String syncDateNS;

  public static final String SERIALIZED_NAME_ACCOUNT_ID = "accountId";
  @SerializedName(SERIALIZED_NAME_ACCOUNT_ID)
  private String accountId;

  public static final String SERIALIZED_NAME_ADJUSTMENT_AMOUNT = "adjustmentAmount";
  @SerializedName(SERIALIZED_NAME_ADJUSTMENT_AMOUNT)
  private BigDecimal adjustmentAmount;

  public static final String SERIALIZED_NAME_AMOUNT = "amount";
  @SerializedName(SERIALIZED_NAME_AMOUNT)
  private BigDecimal amount;

  public static final String SERIALIZED_NAME_AMOUNT_WITHOUT_TAX = "amountWithoutTax";
  @SerializedName(SERIALIZED_NAME_AMOUNT_WITHOUT_TAX)
  private BigDecimal amountWithoutTax;

  public static final String SERIALIZED_NAME_AUTO_PAY = "autoPay";
  @SerializedName(SERIALIZED_NAME_AUTO_PAY)
  private Boolean autoPay;

  public static final String SERIALIZED_NAME_BALANCE = "balance";
  @SerializedName(SERIALIZED_NAME_BALANCE)
  private BigDecimal balance;

  public static final String SERIALIZED_NAME_BILL_RUN_ID = "billRunId";
  @SerializedName(SERIALIZED_NAME_BILL_RUN_ID)
  private String billRunId;

  public static final String SERIALIZED_NAME_BILL_TO_CONTACT_ID = "billToContactId";
  @SerializedName(SERIALIZED_NAME_BILL_TO_CONTACT_ID)
  private String billToContactId;

  public static final String SERIALIZED_NAME_BILL_TO_CONTACT_SNAPSHOT_ID = "billToContactSnapshotId";
  @SerializedName(SERIALIZED_NAME_BILL_TO_CONTACT_SNAPSHOT_ID)
  private String billToContactSnapshotId;

  public static final String SERIALIZED_NAME_COMMENTS = "comments";
  @SerializedName(SERIALIZED_NAME_COMMENTS)
  private String comments;

  public static final String SERIALIZED_NAME_CREATED_BY_ID = "createdById";
  @SerializedName(SERIALIZED_NAME_CREATED_BY_ID)
  private String createdById;

  public static final String SERIALIZED_NAME_CREATED_DATE = "createdDate";
  @SerializedName(SERIALIZED_NAME_CREATED_DATE)
  private String createdDate;

  public static final String SERIALIZED_NAME_CREDIT_BALANCE_ADJUSTMENT_AMOUNT = "creditBalanceAdjustmentAmount";
  @SerializedName(SERIALIZED_NAME_CREDIT_BALANCE_ADJUSTMENT_AMOUNT)
  private BigDecimal creditBalanceAdjustmentAmount;

  public static final String SERIALIZED_NAME_CREDIT_MEMO_AMOUNT = "creditMemoAmount";
  @SerializedName(SERIALIZED_NAME_CREDIT_MEMO_AMOUNT)
  private BigDecimal creditMemoAmount;

  public static final String SERIALIZED_NAME_CURRENCY = "currency";
  @SerializedName(SERIALIZED_NAME_CURRENCY)
  private String currency;

  public static final String SERIALIZED_NAME_DISCOUNT = "discount";
  @SerializedName(SERIALIZED_NAME_DISCOUNT)
  private BigDecimal discount;

  public static final String SERIALIZED_NAME_DUE_DATE = "dueDate";
  @SerializedName(SERIALIZED_NAME_DUE_DATE)
  private LocalDate dueDate;

  public static final String SERIALIZED_NAME_E_INVOICE_STATUS = "eInvoiceStatus";
  @SerializedName(SERIALIZED_NAME_E_INVOICE_STATUS)
  private EInvoiceStatus eInvoiceStatus;

  public static final String SERIALIZED_NAME_E_INVOICE_ERROR_CODE = "eInvoiceErrorCode";
  @SerializedName(SERIALIZED_NAME_E_INVOICE_ERROR_CODE)
  private String eInvoiceErrorCode;

  public static final String SERIALIZED_NAME_E_INVOICE_ERROR_MESSAGE = "eInvoiceErrorMessage";
  @SerializedName(SERIALIZED_NAME_E_INVOICE_ERROR_MESSAGE)
  private String eInvoiceErrorMessage;

  public static final String SERIALIZED_NAME_E_INVOICE_FILE_ID = "eInvoiceFileId";
  @SerializedName(SERIALIZED_NAME_E_INVOICE_FILE_ID)
  private String eInvoiceFileId;

  public static final String SERIALIZED_NAME_ID = "id";
  @SerializedName(SERIALIZED_NAME_ID)
  private String id;

  public static final String SERIALIZED_NAME_INCLUDES_ONE_TIME = "includesOneTime";
  @SerializedName(SERIALIZED_NAME_INCLUDES_ONE_TIME)
  private Boolean includesOneTime;

  public static final String SERIALIZED_NAME_INCLUDES_RECURRING = "includesRecurring";
  @SerializedName(SERIALIZED_NAME_INCLUDES_RECURRING)
  private Boolean includesRecurring;

  public static final String SERIALIZED_NAME_INCLUDES_USAGE = "includesUsage";
  @SerializedName(SERIALIZED_NAME_INCLUDES_USAGE)
  private Boolean includesUsage;

  public static final String SERIALIZED_NAME_INVOICE_DATE = "invoiceDate";
  @SerializedName(SERIALIZED_NAME_INVOICE_DATE)
  private LocalDate invoiceDate;

  public static final String SERIALIZED_NAME_INVOICE_GROUP_NUMBER = "invoiceGroupNumber";
  @SerializedName(SERIALIZED_NAME_INVOICE_GROUP_NUMBER)
  private String invoiceGroupNumber;

  public static final String SERIALIZED_NAME_INVOICE_NUMBER = "invoiceNumber";
  @SerializedName(SERIALIZED_NAME_INVOICE_NUMBER)
  private String invoiceNumber;

  public static final String SERIALIZED_NAME_LAST_EMAIL_SENT_DATE = "lastEmailSentDate";
  @SerializedName(SERIALIZED_NAME_LAST_EMAIL_SENT_DATE)
  private String lastEmailSentDate;

  public static final String SERIALIZED_NAME_PAYMENT_AMOUNT = "paymentAmount";
  @SerializedName(SERIALIZED_NAME_PAYMENT_AMOUNT)
  private BigDecimal paymentAmount;

  public static final String SERIALIZED_NAME_PAYMENT_TERM = "paymentTerm";
  @SerializedName(SERIALIZED_NAME_PAYMENT_TERM)
  private String paymentTerm;

  public static final String SERIALIZED_NAME_POSTED_BY = "postedBy";
  @SerializedName(SERIALIZED_NAME_POSTED_BY)
  private String postedBy;

  public static final String SERIALIZED_NAME_POSTED_DATE = "postedDate";
  @SerializedName(SERIALIZED_NAME_POSTED_DATE)
  private LocalDate postedDate;

  public static final String SERIALIZED_NAME_REFUND_AMOUNT = "refundAmount";
  @SerializedName(SERIALIZED_NAME_REFUND_AMOUNT)
  private BigDecimal refundAmount;

  public static final String SERIALIZED_NAME_SEQUENCE_SET_ID = "sequenceSetId";
  @SerializedName(SERIALIZED_NAME_SEQUENCE_SET_ID)
  private String sequenceSetId;

  public static final String SERIALIZED_NAME_SHIP_TO_CONTACT_ID = "shipToContactId";
  @SerializedName(SERIALIZED_NAME_SHIP_TO_CONTACT_ID)
  private String shipToContactId;

  public static final String SERIALIZED_NAME_SHIP_TO_CONTACT_SNAPSHOT_ID = "shipToContactSnapshotId";
  @SerializedName(SERIALIZED_NAME_SHIP_TO_CONTACT_SNAPSHOT_ID)
  private String shipToContactSnapshotId;

  public static final String SERIALIZED_NAME_SOLD_TO_CONTACT_ID = "soldToContactId";
  @SerializedName(SERIALIZED_NAME_SOLD_TO_CONTACT_ID)
  private String soldToContactId;

  public static final String SERIALIZED_NAME_SOLD_TO_CONTACT_SNAPSHOT_ID = "soldToContactSnapshotId";
  @SerializedName(SERIALIZED_NAME_SOLD_TO_CONTACT_SNAPSHOT_ID)
  private String soldToContactSnapshotId;

  /**
   * The source of the invoice.
   */
  @JsonAdapter(SourceEnum.Adapter.class)
  public enum SourceEnum {
    BILLRUN("BillRun"),
    
    API("API"),
    
    APISUBSCRIBE("ApiSubscribe"),
    
    APIAMEND("ApiAmend");

    private String value;

    SourceEnum(String value) {
      this.value = value;
    }

    public String getValue() {
      return value;
    }

    @Override
    public String toString() {
      return String.valueOf(value);
    }

    public static SourceEnum fromValue(String value) {
      for (SourceEnum b : SourceEnum.values()) {
        if (b.value.equals(value)) {
          return b;
        }
      }
      throw new IllegalArgumentException("Unexpected value '" + value + "'");
    }

    public static class Adapter extends TypeAdapter {
      @Override
      public void write(final JsonWriter jsonWriter, final SourceEnum enumeration) throws IOException {
        jsonWriter.value(enumeration.getValue());
      }

      @Override
      public SourceEnum read(final JsonReader jsonReader) throws IOException {
        String value =  jsonReader.nextString();
        return SourceEnum.fromValue(value);
      }
    }

    public static void validateJsonElement(JsonElement jsonElement) throws IOException {
      String value = jsonElement.getAsString();
      SourceEnum.fromValue(value);
    }
  }

  public static final String SERIALIZED_NAME_SOURCE = "source";
  @SerializedName(SERIALIZED_NAME_SOURCE)
  private SourceEnum source;

  public static final String SERIALIZED_NAME_SOURCE_ID = "sourceId";
  @SerializedName(SERIALIZED_NAME_SOURCE_ID)
  private String sourceId;

  /**
   * The type of the invoice source.
   */
  @JsonAdapter(SourceTypeEnum.Adapter.class)
  public enum SourceTypeEnum {
    SUBSCRIPTION("Subscription"),
    
    STANDALONE("Standalone"),
    
    ORDER("Order"),
    
    CONSOLIDATION("Consolidation");

    private String value;

    SourceTypeEnum(String value) {
      this.value = value;
    }

    public String getValue() {
      return value;
    }

    @Override
    public String toString() {
      return String.valueOf(value);
    }

    public static SourceTypeEnum fromValue(String value) {
      for (SourceTypeEnum b : SourceTypeEnum.values()) {
        if (b.value.equals(value)) {
          return b;
        }
      }
      throw new IllegalArgumentException("Unexpected value '" + value + "'");
    }

    public static class Adapter extends TypeAdapter {
      @Override
      public void write(final JsonWriter jsonWriter, final SourceTypeEnum enumeration) throws IOException {
        jsonWriter.value(enumeration.getValue());
      }

      @Override
      public SourceTypeEnum read(final JsonReader jsonReader) throws IOException {
        String value =  jsonReader.nextString();
        return SourceTypeEnum.fromValue(value);
      }
    }

    public static void validateJsonElement(JsonElement jsonElement) throws IOException {
      String value = jsonElement.getAsString();
      SourceTypeEnum.fromValue(value);
    }
  }

  public static final String SERIALIZED_NAME_SOURCE_TYPE = "sourceType";
  @SerializedName(SERIALIZED_NAME_SOURCE_TYPE)
  private SourceTypeEnum sourceType;

  public static final String SERIALIZED_NAME_STATUS = "status";
  @SerializedName(SERIALIZED_NAME_STATUS)
  private BillingDocumentStatus status;

  public static final String SERIALIZED_NAME_TARGET_DATE = "targetDate";
  @SerializedName(SERIALIZED_NAME_TARGET_DATE)
  private LocalDate targetDate;

  public static final String SERIALIZED_NAME_TAX_AMOUNT = "taxAmount";
  @SerializedName(SERIALIZED_NAME_TAX_AMOUNT)
  private BigDecimal taxAmount;

  public static final String SERIALIZED_NAME_TAX_EXEMPT_AMOUNT = "taxExemptAmount";
  @SerializedName(SERIALIZED_NAME_TAX_EXEMPT_AMOUNT)
  private BigDecimal taxExemptAmount;

  public static final String SERIALIZED_NAME_TAX_MESSAGE = "taxMessage";
  @SerializedName(SERIALIZED_NAME_TAX_MESSAGE)
  private String taxMessage;

  public static final String SERIALIZED_NAME_TAX_STATUS = "taxStatus";
  @SerializedName(SERIALIZED_NAME_TAX_STATUS)
  private TaxStatus taxStatus;

  public static final String SERIALIZED_NAME_TEMPLATE_ID = "templateId";
  @SerializedName(SERIALIZED_NAME_TEMPLATE_ID)
  private String templateId;

  public static final String SERIALIZED_NAME_TRANSFERRED_TO_ACCOUNTING = "transferredToAccounting";
  @SerializedName(SERIALIZED_NAME_TRANSFERRED_TO_ACCOUNTING)
  private TransferredToAccountingStatus transferredToAccounting;

  public static final String SERIALIZED_NAME_UPDATED_BY_ID = "updatedById";
  @SerializedName(SERIALIZED_NAME_UPDATED_BY_ID)
  private String updatedById;

  public static final String SERIALIZED_NAME_UPDATED_DATE = "updatedDate";
  @SerializedName(SERIALIZED_NAME_UPDATED_DATE)
  private String updatedDate;

  public Invoice() {
  }

  public Invoice integrationIdNS(String integrationIdNS) {
    this.integrationIdNS = integrationIdNS;
    return this;
  }

  /**
   * ID of the corresponding object in NetSuite. Only available if you have installed the [Zuora Connector for NetSuite](https://www.zuora.com/connect/app/?appId=265). 
   * @return integrationIdNS
   */
  @javax.annotation.Nullable
  public String getIntegrationIdNS() {
    return integrationIdNS;
  }

  public void setIntegrationIdNS(String integrationIdNS) {
    this.integrationIdNS = integrationIdNS;
  }


  public Invoice integrationStatusNS(String integrationStatusNS) {
    this.integrationStatusNS = integrationStatusNS;
    return this;
  }

  /**
   * Status of the invoice's synchronization with NetSuite. Only available if you have installed the [Zuora Connector for NetSuite](https://www.zuora.com/connect/app/?appId=265). 
   * @return integrationStatusNS
   */
  @javax.annotation.Nullable
  public String getIntegrationStatusNS() {
    return integrationStatusNS;
  }

  public void setIntegrationStatusNS(String integrationStatusNS) {
    this.integrationStatusNS = integrationStatusNS;
  }


  public Invoice syncDateNS(String syncDateNS) {
    this.syncDateNS = syncDateNS;
    return this;
  }

  /**
   * Date when the invoice was synchronized with NetSuite. Only available if you have installed the [Zuora Connector for NetSuite](https://www.zuora.com/connect/app/?appId=265). 
   * @return syncDateNS
   */
  @javax.annotation.Nullable
  public String getSyncDateNS() {
    return syncDateNS;
  }

  public void setSyncDateNS(String syncDateNS) {
    this.syncDateNS = syncDateNS;
  }


  public Invoice accountId(String accountId) {
    this.accountId = accountId;
    return this;
  }

  /**
   * The ID of the customer account associated with the invoice.
   * @return accountId
   */
  @javax.annotation.Nullable
  public String getAccountId() {
    return accountId;
  }

  public void setAccountId(String accountId) {
    this.accountId = accountId;
  }


  public Invoice adjustmentAmount(BigDecimal adjustmentAmount) {
    this.adjustmentAmount = adjustmentAmount;
    return this;
  }

  /**
   * The amount of the invoice adjustments associated with the invoice.
   * @return adjustmentAmount
   */
  @javax.annotation.Nullable
  public BigDecimal getAdjustmentAmount() {
    return adjustmentAmount;
  }

  public void setAdjustmentAmount(BigDecimal adjustmentAmount) {
    this.adjustmentAmount = adjustmentAmount;
  }


  public Invoice amount(BigDecimal amount) {
    this.amount = amount;
    return this;
  }

  /**
   * The total amount of the invoice.
   * @return amount
   */
  @javax.annotation.Nullable
  public BigDecimal getAmount() {
    return amount;
  }

  public void setAmount(BigDecimal amount) {
    this.amount = amount;
  }


  public Invoice amountWithoutTax(BigDecimal amountWithoutTax) {
    this.amountWithoutTax = amountWithoutTax;
    return this;
  }

  /**
   * The invoice amount excluding tax.
   * @return amountWithoutTax
   */
  @javax.annotation.Nullable
  public BigDecimal getAmountWithoutTax() {
    return amountWithoutTax;
  }

  public void setAmountWithoutTax(BigDecimal amountWithoutTax) {
    this.amountWithoutTax = amountWithoutTax;
  }


  public Invoice autoPay(Boolean autoPay) {
    this.autoPay = autoPay;
    return this;
  }

  /**
   * Whether invoices are automatically picked up for processing in the corresponding payment run.
   * @return autoPay
   */
  @javax.annotation.Nullable
  public Boolean getAutoPay() {
    return autoPay;
  }

  public void setAutoPay(Boolean autoPay) {
    this.autoPay = autoPay;
  }


  public Invoice balance(BigDecimal balance) {
    this.balance = balance;
    return this;
  }

  /**
   * The remaining balance of the invoice after all payments, adjustments and refunds are applied.
   * @return balance
   */
  @javax.annotation.Nullable
  public BigDecimal getBalance() {
    return balance;
  }

  public void setBalance(BigDecimal balance) {
    this.balance = balance;
  }


  public Invoice billRunId(String billRunId) {
    this.billRunId = billRunId;
    return this;
  }

  /**
   * The id of bill run if the invoice is generated by a bill run.
   * @return billRunId
   */
  @javax.annotation.Nullable
  public String getBillRunId() {
    return billRunId;
  }

  public void setBillRunId(String billRunId) {
    this.billRunId = billRunId;
  }


  public Invoice billToContactId(String billToContactId) {
    this.billToContactId = billToContactId;
    return this;
  }

  /**
   * The ID of the bill-to contact associated with the invoice.
   * @return billToContactId
   */
  @javax.annotation.Nullable
  public String getBillToContactId() {
    return billToContactId;
  }

  public void setBillToContactId(String billToContactId) {
    this.billToContactId = billToContactId;
  }


  public Invoice billToContactSnapshotId(String billToContactSnapshotId) {
    this.billToContactSnapshotId = billToContactSnapshotId;
    return this;
  }

  /**
   * The ID of the bill-to contact snapshot associated with the invoice.
   * @return billToContactSnapshotId
   */
  @javax.annotation.Nullable
  public String getBillToContactSnapshotId() {
    return billToContactSnapshotId;
  }

  public void setBillToContactSnapshotId(String billToContactSnapshotId) {
    this.billToContactSnapshotId = billToContactSnapshotId;
  }


  public Invoice comments(String comments) {
    this.comments = comments;
    return this;
  }

  /**
   * Comments about the invoice.
   * @return comments
   */
  @javax.annotation.Nullable
  public String getComments() {
    return comments;
  }

  public void setComments(String comments) {
    this.comments = comments;
  }


  public Invoice createdById(String createdById) {
    this.createdById = createdById;
    return this;
  }

  /**
   * The user ID of the person who created the invoice. If a bill run generated the invoice, then the value is the user ID of person who created the bill run.
   * @return createdById
   */
  @javax.annotation.Nullable
  public String getCreatedById() {
    return createdById;
  }

  public void setCreatedById(String createdById) {
    this.createdById = createdById;
  }


  public Invoice createdDate(String createdDate) {
    this.createdDate = createdDate;
    return this;
  }

  /**
   * The date and time when the invoice was created, in `yyyy-mm-dd hh:mm:ss` format. For example, 2017-03-01 15:31:10.
   * @return createdDate
   */
  @javax.annotation.Nullable
  public String getCreatedDate() {
    return createdDate;
  }

  public void setCreatedDate(String createdDate) {
    this.createdDate = createdDate;
  }


  public Invoice creditBalanceAdjustmentAmount(BigDecimal creditBalanceAdjustmentAmount) {
    this.creditBalanceAdjustmentAmount = creditBalanceAdjustmentAmount;
    return this;
  }

  /**
   * The currency amount of the adjustment applied to the customer's credit balance.   **Note:** This field is only available if you have the Credit Balance feature enabled and the Invoice Settlement feature disabled. 
   * @return creditBalanceAdjustmentAmount
   */
  @javax.annotation.Nullable
  public BigDecimal getCreditBalanceAdjustmentAmount() {
    return creditBalanceAdjustmentAmount;
  }

  public void setCreditBalanceAdjustmentAmount(BigDecimal creditBalanceAdjustmentAmount) {
    this.creditBalanceAdjustmentAmount = creditBalanceAdjustmentAmount;
  }


  public Invoice creditMemoAmount(BigDecimal creditMemoAmount) {
    this.creditMemoAmount = creditMemoAmount;
    return this;
  }

  /**
   * The currency amount of all credit memos applied to this invoice. **Note:** This field is only available if you have [Invoice Settlement](https://knowledgecenter.zuora.com/Billing/Billing_and_Payments/Invoice_Settlement) enabled. The Invoice Settlement feature is generally available as of Zuora Billing Release 296 (March 2021). This feature includes Unapplied Payments, Credit and Debit Memo, and Invoice Item Settlement. If you want to enable Invoice Settlement, see [Invoice Settlement Enablement and Checklist Guide](https://knowledgecenter.zuora.com/Billing/Billing_and_Payments/Invoice_Settlement/Invoice_Settlement_Migration_Checklist_and_Guide) for more information.
   * @return creditMemoAmount
   */
  @javax.annotation.Nullable
  public BigDecimal getCreditMemoAmount() {
    return creditMemoAmount;
  }

  public void setCreditMemoAmount(BigDecimal creditMemoAmount) {
    this.creditMemoAmount = creditMemoAmount;
  }


  public Invoice currency(String currency) {
    this.currency = currency;
    return this;
  }

  /**
   * A currency defined in the web-based UI administrative settings.
   * @return currency
   */
  @javax.annotation.Nullable
  public String getCurrency() {
    return currency;
  }

  public void setCurrency(String currency) {
    this.currency = currency;
  }


  public Invoice discount(BigDecimal discount) {
    this.discount = discount;
    return this;
  }

  /**
   * the invoice discount amount.
   * @return discount
   */
  @javax.annotation.Nullable
  public BigDecimal getDiscount() {
    return discount;
  }

  public void setDiscount(BigDecimal discount) {
    this.discount = discount;
  }


  public Invoice dueDate(LocalDate dueDate) {
    this.dueDate = dueDate;
    return this;
  }

  /**
   * The date by which the payment for this invoice is due, in `yyyy-mm-dd` format.
   * @return dueDate
   */
  @javax.annotation.Nullable
  public LocalDate getDueDate() {
    return dueDate;
  }

  public void setDueDate(LocalDate dueDate) {
    this.dueDate = dueDate;
  }


  public Invoice eInvoiceStatus(EInvoiceStatus eInvoiceStatus) {
    this.eInvoiceStatus = eInvoiceStatus;
    return this;
  }

  /**
   * Get eInvoiceStatus
   * @return eInvoiceStatus
   */
  @javax.annotation.Nullable
  public EInvoiceStatus geteInvoiceStatus() {
    return eInvoiceStatus;
  }

  public void seteInvoiceStatus(EInvoiceStatus eInvoiceStatus) {
    this.eInvoiceStatus = eInvoiceStatus;
  }


  public Invoice eInvoiceErrorCode(String eInvoiceErrorCode) {
    this.eInvoiceErrorCode = eInvoiceErrorCode;
    return this;
  }

  /**
   * Get eInvoiceErrorCode
   * @return eInvoiceErrorCode
   */
  @javax.annotation.Nullable
  public String geteInvoiceErrorCode() {
    return eInvoiceErrorCode;
  }

  public void seteInvoiceErrorCode(String eInvoiceErrorCode) {
    this.eInvoiceErrorCode = eInvoiceErrorCode;
  }


  public Invoice eInvoiceErrorMessage(String eInvoiceErrorMessage) {
    this.eInvoiceErrorMessage = eInvoiceErrorMessage;
    return this;
  }

  /**
   * Get eInvoiceErrorMessage
   * @return eInvoiceErrorMessage
   */
  @javax.annotation.Nullable
  public String geteInvoiceErrorMessage() {
    return eInvoiceErrorMessage;
  }

  public void seteInvoiceErrorMessage(String eInvoiceErrorMessage) {
    this.eInvoiceErrorMessage = eInvoiceErrorMessage;
  }


  public Invoice eInvoiceFileId(String eInvoiceFileId) {
    this.eInvoiceFileId = eInvoiceFileId;
    return this;
  }

  /**
   * Get eInvoiceFileId
   * @return eInvoiceFileId
   */
  @javax.annotation.Nullable
  public String geteInvoiceFileId() {
    return eInvoiceFileId;
  }

  public void seteInvoiceFileId(String eInvoiceFileId) {
    this.eInvoiceFileId = eInvoiceFileId;
  }


  public Invoice id(String id) {
    this.id = id;
    return this;
  }

  /**
   * The unique ID of the invoice.
   * @return id
   */
  @javax.annotation.Nullable
  public String getId() {
    return id;
  }

  public void setId(String id) {
    this.id = id;
  }


  public Invoice includesOneTime(Boolean includesOneTime) {
    this.includesOneTime = includesOneTime;
    return this;
  }

  /**
   * Specifies whether the invoice includes one-time charges.
   * @return includesOneTime
   */
  @javax.annotation.Nullable
  public Boolean getIncludesOneTime() {
    return includesOneTime;
  }

  public void setIncludesOneTime(Boolean includesOneTime) {
    this.includesOneTime = includesOneTime;
  }


  public Invoice includesRecurring(Boolean includesRecurring) {
    this.includesRecurring = includesRecurring;
    return this;
  }

  /**
   * Specifies whether the invoice includes recurring charges.
   * @return includesRecurring
   */
  @javax.annotation.Nullable
  public Boolean getIncludesRecurring() {
    return includesRecurring;
  }

  public void setIncludesRecurring(Boolean includesRecurring) {
    this.includesRecurring = includesRecurring;
  }


  public Invoice includesUsage(Boolean includesUsage) {
    this.includesUsage = includesUsage;
    return this;
  }

  /**
   * Specifies whether the invoice includes usage charges.
   * @return includesUsage
   */
  @javax.annotation.Nullable
  public Boolean getIncludesUsage() {
    return includesUsage;
  }

  public void setIncludesUsage(Boolean includesUsage) {
    this.includesUsage = includesUsage;
  }


  public Invoice invoiceDate(LocalDate invoiceDate) {
    this.invoiceDate = invoiceDate;
    return this;
  }

  /**
   * The date that appears on the invoice being created.
   * @return invoiceDate
   */
  @javax.annotation.Nullable
  public LocalDate getInvoiceDate() {
    return invoiceDate;
  }

  public void setInvoiceDate(LocalDate invoiceDate) {
    this.invoiceDate = invoiceDate;
  }


  public Invoice invoiceGroupNumber(String invoiceGroupNumber) {
    this.invoiceGroupNumber = invoiceGroupNumber;
    return this;
  }

  /**
   * The number of invoice group associated with the invoice.  **Note**: This field is available only if you have the <a href=\"https://knowledgecenter.zuora.com/Zuora_Billing/Bill_your_customers/Bill_customers_at_subscription_level/Flexible_Billing_Attributes\" target=\"_blank\">Flexible Billing Attributes</a> feature enabled. 
   * @return invoiceGroupNumber
   */
  @javax.annotation.Nullable
  public String getInvoiceGroupNumber() {
    return invoiceGroupNumber;
  }

  public void setInvoiceGroupNumber(String invoiceGroupNumber) {
    this.invoiceGroupNumber = invoiceGroupNumber;
  }


  public Invoice invoiceNumber(String invoiceNumber) {
    this.invoiceNumber = invoiceNumber;
    return this;
  }

  /**
   * The unique identification number of the invoice.
   * @return invoiceNumber
   */
  @javax.annotation.Nullable
  public String getInvoiceNumber() {
    return invoiceNumber;
  }

  public void setInvoiceNumber(String invoiceNumber) {
    this.invoiceNumber = invoiceNumber;
  }


  public Invoice lastEmailSentDate(String lastEmailSentDate) {
    this.lastEmailSentDate = lastEmailSentDate;
    return this;
  }

  /**
   * The date when the invoice was last emailed.
   * @return lastEmailSentDate
   */
  @javax.annotation.Nullable
  public String getLastEmailSentDate() {
    return lastEmailSentDate;
  }

  public void setLastEmailSentDate(String lastEmailSentDate) {
    this.lastEmailSentDate = lastEmailSentDate;
  }


  public Invoice paymentAmount(BigDecimal paymentAmount) {
    this.paymentAmount = paymentAmount;
    return this;
  }

  /**
   * The amount of payments applied to the invoice.
   * @return paymentAmount
   */
  @javax.annotation.Nullable
  public BigDecimal getPaymentAmount() {
    return paymentAmount;
  }

  public void setPaymentAmount(BigDecimal paymentAmount) {
    this.paymentAmount = paymentAmount;
  }


  public Invoice paymentTerm(String paymentTerm) {
    this.paymentTerm = paymentTerm;
    return this;
  }

  /**
   * The name of payment term associated with the invoice.
   * @return paymentTerm
   */
  @javax.annotation.Nullable
  public String getPaymentTerm() {
    return paymentTerm;
  }

  public void setPaymentTerm(String paymentTerm) {
    this.paymentTerm = paymentTerm;
  }


  public Invoice postedBy(String postedBy) {
    this.postedBy = postedBy;
    return this;
  }

  /**
   * The user ID of the person who moved the invoice to Posted status.
   * @return postedBy
   */
  @javax.annotation.Nullable
  public String getPostedBy() {
    return postedBy;
  }

  public void setPostedBy(String postedBy) {
    this.postedBy = postedBy;
  }


  public Invoice postedDate(LocalDate postedDate) {
    this.postedDate = postedDate;
    return this;
  }

  /**
   * The date when the invoice was posted.
   * @return postedDate
   */
  @javax.annotation.Nullable
  public LocalDate getPostedDate() {
    return postedDate;
  }

  public void setPostedDate(LocalDate postedDate) {
    this.postedDate = postedDate;
  }


  public Invoice refundAmount(BigDecimal refundAmount) {
    this.refundAmount = refundAmount;
    return this;
  }

  /**
   * Specifies the amount of a refund that was applied against an earlier payment on the invoice.
   * @return refundAmount
   */
  @javax.annotation.Nullable
  public BigDecimal getRefundAmount() {
    return refundAmount;
  }

  public void setRefundAmount(BigDecimal refundAmount) {
    this.refundAmount = refundAmount;
  }


  public Invoice sequenceSetId(String sequenceSetId) {
    this.sequenceSetId = sequenceSetId;
    return this;
  }

  /**
   * The ID of the sequence set associated with the invoice.
   * @return sequenceSetId
   */
  @javax.annotation.Nullable
  public String getSequenceSetId() {
    return sequenceSetId;
  }

  public void setSequenceSetId(String sequenceSetId) {
    this.sequenceSetId = sequenceSetId;
  }


  public Invoice shipToContactId(String shipToContactId) {
    this.shipToContactId = shipToContactId;
    return this;
  }

  /**
   * The ID of the ship-to contact associated with the invoice.
   * @return shipToContactId
   */
  @javax.annotation.Nullable
  public String getShipToContactId() {
    return shipToContactId;
  }

  public void setShipToContactId(String shipToContactId) {
    this.shipToContactId = shipToContactId;
  }


  public Invoice shipToContactSnapshotId(String shipToContactSnapshotId) {
    this.shipToContactSnapshotId = shipToContactSnapshotId;
    return this;
  }

  /**
   * The ID of the ship-to contact snapshot associated with the invoice.
   * @return shipToContactSnapshotId
   */
  @javax.annotation.Nullable
  public String getShipToContactSnapshotId() {
    return shipToContactSnapshotId;
  }

  public void setShipToContactSnapshotId(String shipToContactSnapshotId) {
    this.shipToContactSnapshotId = shipToContactSnapshotId;
  }


  public Invoice soldToContactId(String soldToContactId) {
    this.soldToContactId = soldToContactId;
    return this;
  }

  /**
   * The ID of the sold-to contact associated with the invoice.
   * @return soldToContactId
   */
  @javax.annotation.Nullable
  public String getSoldToContactId() {
    return soldToContactId;
  }

  public void setSoldToContactId(String soldToContactId) {
    this.soldToContactId = soldToContactId;
  }


  public Invoice soldToContactSnapshotId(String soldToContactSnapshotId) {
    this.soldToContactSnapshotId = soldToContactSnapshotId;
    return this;
  }

  /**
   * The ID of the sold-to contact snapshot associated with the invoice.
   * @return soldToContactSnapshotId
   */
  @javax.annotation.Nullable
  public String getSoldToContactSnapshotId() {
    return soldToContactSnapshotId;
  }

  public void setSoldToContactSnapshotId(String soldToContactSnapshotId) {
    this.soldToContactSnapshotId = soldToContactSnapshotId;
  }


  public Invoice source(SourceEnum source) {
    this.source = source;
    return this;
  }

  /**
   * The source of the invoice.
   * @return source
   */
  @javax.annotation.Nullable
  public SourceEnum getSource() {
    return source;
  }

  public void setSource(SourceEnum source) {
    this.source = source;
  }


  public Invoice sourceId(String sourceId) {
    this.sourceId = sourceId;
    return this;
  }

  /**
   * The ID of the invoice source. If an invoice is generated from a bill run, the value is the number of the corresponding bill run.Otherwise, the value is `null`.
   * @return sourceId
   */
  @javax.annotation.Nullable
  public String getSourceId() {
    return sourceId;
  }

  public void setSourceId(String sourceId) {
    this.sourceId = sourceId;
  }


  public Invoice sourceType(SourceTypeEnum sourceType) {
    this.sourceType = sourceType;
    return this;
  }

  /**
   * The type of the invoice source.
   * @return sourceType
   */
  @javax.annotation.Nullable
  public SourceTypeEnum getSourceType() {
    return sourceType;
  }

  public void setSourceType(SourceTypeEnum sourceType) {
    this.sourceType = sourceType;
  }


  public Invoice status(BillingDocumentStatus status) {
    this.status = status;
    return this;
  }

  /**
   * Get status
   * @return status
   */
  @javax.annotation.Nullable
  public BillingDocumentStatus getStatus() {
    return status;
  }

  public void setStatus(BillingDocumentStatus status) {
    this.status = status;
  }


  public Invoice targetDate(LocalDate targetDate) {
    this.targetDate = targetDate;
    return this;
  }

  /**
   * This date is used to determine which charges are to be billed. All charges that are to be billed on this date or prior will be included in this bill run.
   * @return targetDate
   */
  @javax.annotation.Nullable
  public LocalDate getTargetDate() {
    return targetDate;
  }

  public void setTargetDate(LocalDate targetDate) {
    this.targetDate = targetDate;
  }


  public Invoice taxAmount(BigDecimal taxAmount) {
    this.taxAmount = taxAmount;
    return this;
  }

  /**
   * The amount of taxation.
   * @return taxAmount
   */
  @javax.annotation.Nullable
  public BigDecimal getTaxAmount() {
    return taxAmount;
  }

  public void setTaxAmount(BigDecimal taxAmount) {
    this.taxAmount = taxAmount;
  }


  public Invoice taxExemptAmount(BigDecimal taxExemptAmount) {
    this.taxExemptAmount = taxExemptAmount;
    return this;
  }

  /**
   * The calculated tax amount excluded due to the exemption.
   * @return taxExemptAmount
   */
  @javax.annotation.Nullable
  public BigDecimal getTaxExemptAmount() {
    return taxExemptAmount;
  }

  public void setTaxExemptAmount(BigDecimal taxExemptAmount) {
    this.taxExemptAmount = taxExemptAmount;
  }


  public Invoice taxMessage(String taxMessage) {
    this.taxMessage = taxMessage;
    return this;
  }

  /**
   * The message that the tax engine return if it calculates the taxes of this invoice fails.
   * @return taxMessage
   */
  @javax.annotation.Nullable
  public String getTaxMessage() {
    return taxMessage;
  }

  public void setTaxMessage(String taxMessage) {
    this.taxMessage = taxMessage;
  }


  public Invoice taxStatus(TaxStatus taxStatus) {
    this.taxStatus = taxStatus;
    return this;
  }

  /**
   * Get taxStatus
   * @return taxStatus
   */
  @javax.annotation.Nullable
  public TaxStatus getTaxStatus() {
    return taxStatus;
  }

  public void setTaxStatus(TaxStatus taxStatus) {
    this.taxStatus = taxStatus;
  }


  public Invoice templateId(String templateId) {
    this.templateId = templateId;
    return this;
  }

  /**
   * The ID of the invoice template.  - If you have the <a href=\"https://knowledgecenter.zuora.com/Zuora_Billing/Subscriptions/Flexible_Billing_Attributes\" target=\"_blank\">Flexible Billing Attributes</a> feature enabled, the value of this field depends on the configuration of the invoice template.    - If you specify an invoice template at the subscription level, the value of this field is automatically populated from the corresponding subscription.   - If you do not specify any invoice template at the subscription level, the value of this field is automatically populated from the corresponding account. - If you have the Flexible Billing Attributes feature disabled, the value of this field is `null`. 
   * @return templateId
   */
  @javax.annotation.Nullable
  public String getTemplateId() {
    return templateId;
  }

  public void setTemplateId(String templateId) {
    this.templateId = templateId;
  }


  public Invoice transferredToAccounting(TransferredToAccountingStatus transferredToAccounting) {
    this.transferredToAccounting = transferredToAccounting;
    return this;
  }

  /**
   * Get transferredToAccounting
   * @return transferredToAccounting
   */
  @javax.annotation.Nullable
  public TransferredToAccountingStatus getTransferredToAccounting() {
    return transferredToAccounting;
  }

  public void setTransferredToAccounting(TransferredToAccountingStatus transferredToAccounting) {
    this.transferredToAccounting = transferredToAccounting;
  }


  public Invoice updatedById(String updatedById) {
    this.updatedById = updatedById;
    return this;
  }

  /**
   * The ID of the Zuora user who last updated the invoice.
   * @return updatedById
   */
  @javax.annotation.Nullable
  public String getUpdatedById() {
    return updatedById;
  }

  public void setUpdatedById(String updatedById) {
    this.updatedById = updatedById;
  }


  public Invoice updatedDate(String updatedDate) {
    this.updatedDate = updatedDate;
    return this;
  }

  /**
   * The date when the invoice was last updated.
   * @return updatedDate
   */
  @javax.annotation.Nullable
  public String getUpdatedDate() {
    return updatedDate;
  }

  public void setUpdatedDate(String updatedDate) {
    this.updatedDate = updatedDate;
  }

  /**
   * A container for additional, undeclared properties.
   * This is a holder for any undeclared properties as specified with
   * the 'additionalProperties' keyword in the OAS document.
   */
  private Map additionalProperties;

  /**
   * Set the additional (undeclared) property with the specified name and value.
   * If the property does not already exist, create it otherwise replace it.
   *
   * @param key name of the property
   * @param value value of the property
   * @return the Invoice instance itself
   */
  public Invoice putAdditionalProperty(String key, Object value) {
    if (this.additionalProperties == null) {
        this.additionalProperties = new HashMap();
    }
    this.additionalProperties.put(key, value);
    return this;
  }

  /**
   * Return the additional (undeclared) property.
   *
   * @return a map of objects
   */
  public Map getAdditionalProperties() {
    return additionalProperties;
  }

  /**
   * Return the additional (undeclared) property with the specified name.
   *
   * @param key name of the property
   * @return an object
   */
  public Object getAdditionalProperty(String key) {
    if (this.additionalProperties == null) {
        return null;
    }
    return this.additionalProperties.get(key);
  }


  @Override
  public boolean equals(Object o) {
    if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;
    }
    Invoice invoice = (Invoice) o;
    return Objects.equals(this.integrationIdNS, invoice.integrationIdNS) &&
        Objects.equals(this.integrationStatusNS, invoice.integrationStatusNS) &&
        Objects.equals(this.syncDateNS, invoice.syncDateNS) &&
        Objects.equals(this.accountId, invoice.accountId) &&
        Objects.equals(this.adjustmentAmount, invoice.adjustmentAmount) &&
        Objects.equals(this.amount, invoice.amount) &&
        Objects.equals(this.amountWithoutTax, invoice.amountWithoutTax) &&
        Objects.equals(this.autoPay, invoice.autoPay) &&
        Objects.equals(this.balance, invoice.balance) &&
        Objects.equals(this.billRunId, invoice.billRunId) &&
        Objects.equals(this.billToContactId, invoice.billToContactId) &&
        Objects.equals(this.billToContactSnapshotId, invoice.billToContactSnapshotId) &&
        Objects.equals(this.comments, invoice.comments) &&
        Objects.equals(this.createdById, invoice.createdById) &&
        Objects.equals(this.createdDate, invoice.createdDate) &&
        Objects.equals(this.creditBalanceAdjustmentAmount, invoice.creditBalanceAdjustmentAmount) &&
        Objects.equals(this.creditMemoAmount, invoice.creditMemoAmount) &&
        Objects.equals(this.currency, invoice.currency) &&
        Objects.equals(this.discount, invoice.discount) &&
        Objects.equals(this.dueDate, invoice.dueDate) &&
        Objects.equals(this.eInvoiceStatus, invoice.eInvoiceStatus) &&
        Objects.equals(this.eInvoiceErrorCode, invoice.eInvoiceErrorCode) &&
        Objects.equals(this.eInvoiceErrorMessage, invoice.eInvoiceErrorMessage) &&
        Objects.equals(this.eInvoiceFileId, invoice.eInvoiceFileId) &&
        Objects.equals(this.id, invoice.id) &&
        Objects.equals(this.includesOneTime, invoice.includesOneTime) &&
        Objects.equals(this.includesRecurring, invoice.includesRecurring) &&
        Objects.equals(this.includesUsage, invoice.includesUsage) &&
        Objects.equals(this.invoiceDate, invoice.invoiceDate) &&
        Objects.equals(this.invoiceGroupNumber, invoice.invoiceGroupNumber) &&
        Objects.equals(this.invoiceNumber, invoice.invoiceNumber) &&
        Objects.equals(this.lastEmailSentDate, invoice.lastEmailSentDate) &&
        Objects.equals(this.paymentAmount, invoice.paymentAmount) &&
        Objects.equals(this.paymentTerm, invoice.paymentTerm) &&
        Objects.equals(this.postedBy, invoice.postedBy) &&
        Objects.equals(this.postedDate, invoice.postedDate) &&
        Objects.equals(this.refundAmount, invoice.refundAmount) &&
        Objects.equals(this.sequenceSetId, invoice.sequenceSetId) &&
        Objects.equals(this.shipToContactId, invoice.shipToContactId) &&
        Objects.equals(this.shipToContactSnapshotId, invoice.shipToContactSnapshotId) &&
        Objects.equals(this.soldToContactId, invoice.soldToContactId) &&
        Objects.equals(this.soldToContactSnapshotId, invoice.soldToContactSnapshotId) &&
        Objects.equals(this.source, invoice.source) &&
        Objects.equals(this.sourceId, invoice.sourceId) &&
        Objects.equals(this.sourceType, invoice.sourceType) &&
        Objects.equals(this.status, invoice.status) &&
        Objects.equals(this.targetDate, invoice.targetDate) &&
        Objects.equals(this.taxAmount, invoice.taxAmount) &&
        Objects.equals(this.taxExemptAmount, invoice.taxExemptAmount) &&
        Objects.equals(this.taxMessage, invoice.taxMessage) &&
        Objects.equals(this.taxStatus, invoice.taxStatus) &&
        Objects.equals(this.templateId, invoice.templateId) &&
        Objects.equals(this.transferredToAccounting, invoice.transferredToAccounting) &&
        Objects.equals(this.updatedById, invoice.updatedById) &&
        Objects.equals(this.updatedDate, invoice.updatedDate)&&
        Objects.equals(this.additionalProperties, invoice.additionalProperties);
  }

  @Override
  public int hashCode() {
    return Objects.hash(integrationIdNS, integrationStatusNS, syncDateNS, accountId, adjustmentAmount, amount, amountWithoutTax, autoPay, balance, billRunId, billToContactId, billToContactSnapshotId, comments, createdById, createdDate, creditBalanceAdjustmentAmount, creditMemoAmount, currency, discount, dueDate, eInvoiceStatus, eInvoiceErrorCode, eInvoiceErrorMessage, eInvoiceFileId, id, includesOneTime, includesRecurring, includesUsage, invoiceDate, invoiceGroupNumber, invoiceNumber, lastEmailSentDate, paymentAmount, paymentTerm, postedBy, postedDate, refundAmount, sequenceSetId, shipToContactId, shipToContactSnapshotId, soldToContactId, soldToContactSnapshotId, source, sourceId, sourceType, status, targetDate, taxAmount, taxExemptAmount, taxMessage, taxStatus, templateId, transferredToAccounting, updatedById, updatedDate, additionalProperties);
  }

  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append("class Invoice {\n");
    sb.append("    integrationIdNS: ").append(toIndentedString(integrationIdNS)).append("\n");
    sb.append("    integrationStatusNS: ").append(toIndentedString(integrationStatusNS)).append("\n");
    sb.append("    syncDateNS: ").append(toIndentedString(syncDateNS)).append("\n");
    sb.append("    accountId: ").append(toIndentedString(accountId)).append("\n");
    sb.append("    adjustmentAmount: ").append(toIndentedString(adjustmentAmount)).append("\n");
    sb.append("    amount: ").append(toIndentedString(amount)).append("\n");
    sb.append("    amountWithoutTax: ").append(toIndentedString(amountWithoutTax)).append("\n");
    sb.append("    autoPay: ").append(toIndentedString(autoPay)).append("\n");
    sb.append("    balance: ").append(toIndentedString(balance)).append("\n");
    sb.append("    billRunId: ").append(toIndentedString(billRunId)).append("\n");
    sb.append("    billToContactId: ").append(toIndentedString(billToContactId)).append("\n");
    sb.append("    billToContactSnapshotId: ").append(toIndentedString(billToContactSnapshotId)).append("\n");
    sb.append("    comments: ").append(toIndentedString(comments)).append("\n");
    sb.append("    createdById: ").append(toIndentedString(createdById)).append("\n");
    sb.append("    createdDate: ").append(toIndentedString(createdDate)).append("\n");
    sb.append("    creditBalanceAdjustmentAmount: ").append(toIndentedString(creditBalanceAdjustmentAmount)).append("\n");
    sb.append("    creditMemoAmount: ").append(toIndentedString(creditMemoAmount)).append("\n");
    sb.append("    currency: ").append(toIndentedString(currency)).append("\n");
    sb.append("    discount: ").append(toIndentedString(discount)).append("\n");
    sb.append("    dueDate: ").append(toIndentedString(dueDate)).append("\n");
    sb.append("    eInvoiceStatus: ").append(toIndentedString(eInvoiceStatus)).append("\n");
    sb.append("    eInvoiceErrorCode: ").append(toIndentedString(eInvoiceErrorCode)).append("\n");
    sb.append("    eInvoiceErrorMessage: ").append(toIndentedString(eInvoiceErrorMessage)).append("\n");
    sb.append("    eInvoiceFileId: ").append(toIndentedString(eInvoiceFileId)).append("\n");
    sb.append("    id: ").append(toIndentedString(id)).append("\n");
    sb.append("    includesOneTime: ").append(toIndentedString(includesOneTime)).append("\n");
    sb.append("    includesRecurring: ").append(toIndentedString(includesRecurring)).append("\n");
    sb.append("    includesUsage: ").append(toIndentedString(includesUsage)).append("\n");
    sb.append("    invoiceDate: ").append(toIndentedString(invoiceDate)).append("\n");
    sb.append("    invoiceGroupNumber: ").append(toIndentedString(invoiceGroupNumber)).append("\n");
    sb.append("    invoiceNumber: ").append(toIndentedString(invoiceNumber)).append("\n");
    sb.append("    lastEmailSentDate: ").append(toIndentedString(lastEmailSentDate)).append("\n");
    sb.append("    paymentAmount: ").append(toIndentedString(paymentAmount)).append("\n");
    sb.append("    paymentTerm: ").append(toIndentedString(paymentTerm)).append("\n");
    sb.append("    postedBy: ").append(toIndentedString(postedBy)).append("\n");
    sb.append("    postedDate: ").append(toIndentedString(postedDate)).append("\n");
    sb.append("    refundAmount: ").append(toIndentedString(refundAmount)).append("\n");
    sb.append("    sequenceSetId: ").append(toIndentedString(sequenceSetId)).append("\n");
    sb.append("    shipToContactId: ").append(toIndentedString(shipToContactId)).append("\n");
    sb.append("    shipToContactSnapshotId: ").append(toIndentedString(shipToContactSnapshotId)).append("\n");
    sb.append("    soldToContactId: ").append(toIndentedString(soldToContactId)).append("\n");
    sb.append("    soldToContactSnapshotId: ").append(toIndentedString(soldToContactSnapshotId)).append("\n");
    sb.append("    source: ").append(toIndentedString(source)).append("\n");
    sb.append("    sourceId: ").append(toIndentedString(sourceId)).append("\n");
    sb.append("    sourceType: ").append(toIndentedString(sourceType)).append("\n");
    sb.append("    status: ").append(toIndentedString(status)).append("\n");
    sb.append("    targetDate: ").append(toIndentedString(targetDate)).append("\n");
    sb.append("    taxAmount: ").append(toIndentedString(taxAmount)).append("\n");
    sb.append("    taxExemptAmount: ").append(toIndentedString(taxExemptAmount)).append("\n");
    sb.append("    taxMessage: ").append(toIndentedString(taxMessage)).append("\n");
    sb.append("    taxStatus: ").append(toIndentedString(taxStatus)).append("\n");
    sb.append("    templateId: ").append(toIndentedString(templateId)).append("\n");
    sb.append("    transferredToAccounting: ").append(toIndentedString(transferredToAccounting)).append("\n");
    sb.append("    updatedById: ").append(toIndentedString(updatedById)).append("\n");
    sb.append("    updatedDate: ").append(toIndentedString(updatedDate)).append("\n");
    sb.append("    additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n");
    sb.append("}");
    return sb.toString();
  }

  /**
   * Convert the given object to string with each line indented by 4 spaces
   * (except the first line).
   */
  private String toIndentedString(Object o) {
    if (o == null) {
      return "null";
    }
    return o.toString().replace("\n", "\n    ");
  }


  public static HashSet openapiFields;
  public static HashSet openapiRequiredFields;

  static {
    // a set of all properties/fields (JSON key names)
    openapiFields = new HashSet();
    openapiFields.add("IntegrationId__NS");
    openapiFields.add("IntegrationStatus__NS");
    openapiFields.add("SyncDate__NS");
    openapiFields.add("accountId");
    openapiFields.add("adjustmentAmount");
    openapiFields.add("amount");
    openapiFields.add("amountWithoutTax");
    openapiFields.add("autoPay");
    openapiFields.add("balance");
    openapiFields.add("billRunId");
    openapiFields.add("billToContactId");
    openapiFields.add("billToContactSnapshotId");
    openapiFields.add("comments");
    openapiFields.add("createdById");
    openapiFields.add("createdDate");
    openapiFields.add("creditBalanceAdjustmentAmount");
    openapiFields.add("creditMemoAmount");
    openapiFields.add("currency");
    openapiFields.add("discount");
    openapiFields.add("dueDate");
    openapiFields.add("eInvoiceStatus");
    openapiFields.add("eInvoiceErrorCode");
    openapiFields.add("eInvoiceErrorMessage");
    openapiFields.add("eInvoiceFileId");
    openapiFields.add("id");
    openapiFields.add("includesOneTime");
    openapiFields.add("includesRecurring");
    openapiFields.add("includesUsage");
    openapiFields.add("invoiceDate");
    openapiFields.add("invoiceGroupNumber");
    openapiFields.add("invoiceNumber");
    openapiFields.add("lastEmailSentDate");
    openapiFields.add("paymentAmount");
    openapiFields.add("paymentTerm");
    openapiFields.add("postedBy");
    openapiFields.add("postedDate");
    openapiFields.add("refundAmount");
    openapiFields.add("sequenceSetId");
    openapiFields.add("shipToContactId");
    openapiFields.add("shipToContactSnapshotId");
    openapiFields.add("soldToContactId");
    openapiFields.add("soldToContactSnapshotId");
    openapiFields.add("source");
    openapiFields.add("sourceId");
    openapiFields.add("sourceType");
    openapiFields.add("status");
    openapiFields.add("targetDate");
    openapiFields.add("taxAmount");
    openapiFields.add("taxExemptAmount");
    openapiFields.add("taxMessage");
    openapiFields.add("taxStatus");
    openapiFields.add("templateId");
    openapiFields.add("transferredToAccounting");
    openapiFields.add("updatedById");
    openapiFields.add("updatedDate");

    // a set of required properties/fields (JSON key names)
    openapiRequiredFields = new HashSet();
  }

  /**
   * Validates the JSON Element and throws an exception if issues found
   *
   * @param jsonElement JSON Element
   * @throws IOException if the JSON Element is invalid with respect to Invoice
   */
  public static void validateJsonElement(JsonElement jsonElement) throws IOException {
      if (jsonElement == null) {
        if (!Invoice.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
          throw new IllegalArgumentException(String.format("The required field(s) %s in Invoice is not found in the empty JSON string", Invoice.openapiRequiredFields.toString()));
        }
      }
        JsonObject jsonObj = jsonElement.getAsJsonObject();
      if ((jsonObj.get("IntegrationId__NS") != null && !jsonObj.get("IntegrationId__NS").isJsonNull()) && !jsonObj.get("IntegrationId__NS").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `IntegrationId__NS` to be a primitive type in the JSON string but got `%s`", jsonObj.get("IntegrationId__NS").toString()));
      }
      if ((jsonObj.get("IntegrationStatus__NS") != null && !jsonObj.get("IntegrationStatus__NS").isJsonNull()) && !jsonObj.get("IntegrationStatus__NS").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `IntegrationStatus__NS` to be a primitive type in the JSON string but got `%s`", jsonObj.get("IntegrationStatus__NS").toString()));
      }
      if ((jsonObj.get("SyncDate__NS") != null && !jsonObj.get("SyncDate__NS").isJsonNull()) && !jsonObj.get("SyncDate__NS").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `SyncDate__NS` to be a primitive type in the JSON string but got `%s`", jsonObj.get("SyncDate__NS").toString()));
      }
      if ((jsonObj.get("accountId") != null && !jsonObj.get("accountId").isJsonNull()) && !jsonObj.get("accountId").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `accountId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("accountId").toString()));
      }
      if ((jsonObj.get("billRunId") != null && !jsonObj.get("billRunId").isJsonNull()) && !jsonObj.get("billRunId").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `billRunId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("billRunId").toString()));
      }
      if ((jsonObj.get("billToContactId") != null && !jsonObj.get("billToContactId").isJsonNull()) && !jsonObj.get("billToContactId").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `billToContactId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("billToContactId").toString()));
      }
      if ((jsonObj.get("billToContactSnapshotId") != null && !jsonObj.get("billToContactSnapshotId").isJsonNull()) && !jsonObj.get("billToContactSnapshotId").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `billToContactSnapshotId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("billToContactSnapshotId").toString()));
      }
      if ((jsonObj.get("comments") != null && !jsonObj.get("comments").isJsonNull()) && !jsonObj.get("comments").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `comments` to be a primitive type in the JSON string but got `%s`", jsonObj.get("comments").toString()));
      }
      if ((jsonObj.get("createdById") != null && !jsonObj.get("createdById").isJsonNull()) && !jsonObj.get("createdById").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `createdById` to be a primitive type in the JSON string but got `%s`", jsonObj.get("createdById").toString()));
      }
      if ((jsonObj.get("createdDate") != null && !jsonObj.get("createdDate").isJsonNull()) && !jsonObj.get("createdDate").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `createdDate` to be a primitive type in the JSON string but got `%s`", jsonObj.get("createdDate").toString()));
      }
      if ((jsonObj.get("currency") != null && !jsonObj.get("currency").isJsonNull()) && !jsonObj.get("currency").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `currency` to be a primitive type in the JSON string but got `%s`", jsonObj.get("currency").toString()));
      }
      if ((jsonObj.get("eInvoiceStatus") != null && !jsonObj.get("eInvoiceStatus").isJsonNull()) && !jsonObj.get("eInvoiceStatus").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `eInvoiceStatus` to be a primitive type in the JSON string but got `%s`", jsonObj.get("eInvoiceStatus").toString()));
      }
      // validate the optional field `eInvoiceStatus`
      if (jsonObj.get("eInvoiceStatus") != null && !jsonObj.get("eInvoiceStatus").isJsonNull()) {
        EInvoiceStatus.validateJsonElement(jsonObj.get("eInvoiceStatus"));
      }
      if ((jsonObj.get("eInvoiceErrorCode") != null && !jsonObj.get("eInvoiceErrorCode").isJsonNull()) && !jsonObj.get("eInvoiceErrorCode").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `eInvoiceErrorCode` to be a primitive type in the JSON string but got `%s`", jsonObj.get("eInvoiceErrorCode").toString()));
      }
      if ((jsonObj.get("eInvoiceErrorMessage") != null && !jsonObj.get("eInvoiceErrorMessage").isJsonNull()) && !jsonObj.get("eInvoiceErrorMessage").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `eInvoiceErrorMessage` to be a primitive type in the JSON string but got `%s`", jsonObj.get("eInvoiceErrorMessage").toString()));
      }
      if ((jsonObj.get("eInvoiceFileId") != null && !jsonObj.get("eInvoiceFileId").isJsonNull()) && !jsonObj.get("eInvoiceFileId").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `eInvoiceFileId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("eInvoiceFileId").toString()));
      }
      if ((jsonObj.get("id") != null && !jsonObj.get("id").isJsonNull()) && !jsonObj.get("id").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString()));
      }
      if ((jsonObj.get("invoiceGroupNumber") != null && !jsonObj.get("invoiceGroupNumber").isJsonNull()) && !jsonObj.get("invoiceGroupNumber").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `invoiceGroupNumber` to be a primitive type in the JSON string but got `%s`", jsonObj.get("invoiceGroupNumber").toString()));
      }
      if ((jsonObj.get("invoiceNumber") != null && !jsonObj.get("invoiceNumber").isJsonNull()) && !jsonObj.get("invoiceNumber").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `invoiceNumber` to be a primitive type in the JSON string but got `%s`", jsonObj.get("invoiceNumber").toString()));
      }
      if ((jsonObj.get("lastEmailSentDate") != null && !jsonObj.get("lastEmailSentDate").isJsonNull()) && !jsonObj.get("lastEmailSentDate").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `lastEmailSentDate` to be a primitive type in the JSON string but got `%s`", jsonObj.get("lastEmailSentDate").toString()));
      }
      if ((jsonObj.get("paymentTerm") != null && !jsonObj.get("paymentTerm").isJsonNull()) && !jsonObj.get("paymentTerm").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `paymentTerm` to be a primitive type in the JSON string but got `%s`", jsonObj.get("paymentTerm").toString()));
      }
      if ((jsonObj.get("postedBy") != null && !jsonObj.get("postedBy").isJsonNull()) && !jsonObj.get("postedBy").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `postedBy` to be a primitive type in the JSON string but got `%s`", jsonObj.get("postedBy").toString()));
      }
      if ((jsonObj.get("sequenceSetId") != null && !jsonObj.get("sequenceSetId").isJsonNull()) && !jsonObj.get("sequenceSetId").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `sequenceSetId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sequenceSetId").toString()));
      }
      if ((jsonObj.get("shipToContactId") != null && !jsonObj.get("shipToContactId").isJsonNull()) && !jsonObj.get("shipToContactId").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `shipToContactId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("shipToContactId").toString()));
      }
      if ((jsonObj.get("shipToContactSnapshotId") != null && !jsonObj.get("shipToContactSnapshotId").isJsonNull()) && !jsonObj.get("shipToContactSnapshotId").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `shipToContactSnapshotId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("shipToContactSnapshotId").toString()));
      }
      if ((jsonObj.get("soldToContactId") != null && !jsonObj.get("soldToContactId").isJsonNull()) && !jsonObj.get("soldToContactId").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `soldToContactId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("soldToContactId").toString()));
      }
      if ((jsonObj.get("soldToContactSnapshotId") != null && !jsonObj.get("soldToContactSnapshotId").isJsonNull()) && !jsonObj.get("soldToContactSnapshotId").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `soldToContactSnapshotId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("soldToContactSnapshotId").toString()));
      }
      if ((jsonObj.get("source") != null && !jsonObj.get("source").isJsonNull()) && !jsonObj.get("source").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `source` to be a primitive type in the JSON string but got `%s`", jsonObj.get("source").toString()));
      }
      // validate the optional field `source`
      if (jsonObj.get("source") != null && !jsonObj.get("source").isJsonNull()) {
        SourceEnum.validateJsonElement(jsonObj.get("source"));
      }
      if ((jsonObj.get("sourceId") != null && !jsonObj.get("sourceId").isJsonNull()) && !jsonObj.get("sourceId").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `sourceId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sourceId").toString()));
      }
      if ((jsonObj.get("sourceType") != null && !jsonObj.get("sourceType").isJsonNull()) && !jsonObj.get("sourceType").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `sourceType` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sourceType").toString()));
      }
      // validate the optional field `sourceType`
      if (jsonObj.get("sourceType") != null && !jsonObj.get("sourceType").isJsonNull()) {
        SourceTypeEnum.validateJsonElement(jsonObj.get("sourceType"));
      }
      if ((jsonObj.get("status") != null && !jsonObj.get("status").isJsonNull()) && !jsonObj.get("status").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString()));
      }
      // validate the optional field `status`
      if (jsonObj.get("status") != null && !jsonObj.get("status").isJsonNull()) {
        BillingDocumentStatus.validateJsonElement(jsonObj.get("status"));
      }
      if ((jsonObj.get("taxMessage") != null && !jsonObj.get("taxMessage").isJsonNull()) && !jsonObj.get("taxMessage").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `taxMessage` to be a primitive type in the JSON string but got `%s`", jsonObj.get("taxMessage").toString()));
      }
      if ((jsonObj.get("taxStatus") != null && !jsonObj.get("taxStatus").isJsonNull()) && !jsonObj.get("taxStatus").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `taxStatus` to be a primitive type in the JSON string but got `%s`", jsonObj.get("taxStatus").toString()));
      }
      // validate the optional field `taxStatus`
      if (jsonObj.get("taxStatus") != null && !jsonObj.get("taxStatus").isJsonNull()) {
        TaxStatus.validateJsonElement(jsonObj.get("taxStatus"));
      }
      if ((jsonObj.get("templateId") != null && !jsonObj.get("templateId").isJsonNull()) && !jsonObj.get("templateId").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `templateId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("templateId").toString()));
      }
      if ((jsonObj.get("transferredToAccounting") != null && !jsonObj.get("transferredToAccounting").isJsonNull()) && !jsonObj.get("transferredToAccounting").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `transferredToAccounting` to be a primitive type in the JSON string but got `%s`", jsonObj.get("transferredToAccounting").toString()));
      }
      // validate the optional field `transferredToAccounting`
      if (jsonObj.get("transferredToAccounting") != null && !jsonObj.get("transferredToAccounting").isJsonNull()) {
        TransferredToAccountingStatus.validateJsonElement(jsonObj.get("transferredToAccounting"));
      }
      if ((jsonObj.get("updatedById") != null && !jsonObj.get("updatedById").isJsonNull()) && !jsonObj.get("updatedById").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `updatedById` to be a primitive type in the JSON string but got `%s`", jsonObj.get("updatedById").toString()));
      }
      if ((jsonObj.get("updatedDate") != null && !jsonObj.get("updatedDate").isJsonNull()) && !jsonObj.get("updatedDate").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `updatedDate` to be a primitive type in the JSON string but got `%s`", jsonObj.get("updatedDate").toString()));
      }
  }

  public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
    @SuppressWarnings("unchecked")
    @Override
    public  TypeAdapter create(Gson gson, TypeToken type) {
       if (!Invoice.class.isAssignableFrom(type.getRawType())) {
         return null; // this class only serializes 'Invoice' and its subtypes
       }
       final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class);
       final TypeAdapter thisAdapter
                        = gson.getDelegateAdapter(this, TypeToken.get(Invoice.class));

       return (TypeAdapter) new TypeAdapter() {
           @Override
           public void write(JsonWriter out, Invoice value) throws IOException {
             JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
             obj.remove("additionalProperties");

             // support null values
             out.beginObject();
             Iterator iterator = obj.entrySet().iterator();
             while(iterator.hasNext()) {
                 Map.Entry e = (Map.Entry) iterator.next();
                 out.name((String)e.getKey());
                 elementAdapter.write(out, e.getValue());
             }

             // end

             // serialize additional properties
             if (value.getAdditionalProperties() != null) {
               // support null values
               boolean oldSerializeNulls = out.getSerializeNulls();
               out.setSerializeNulls(true); //force serialize
               // end
               for (Map.Entry entry : value.getAdditionalProperties().entrySet()) {
                 if (entry.getValue() instanceof String)
                   obj.addProperty(entry.getKey(), (String) entry.getValue());
                 else if (entry.getValue() instanceof Number)
                   obj.addProperty(entry.getKey(), (Number) entry.getValue());
                 else if (entry.getValue() instanceof Boolean)
                   obj.addProperty(entry.getKey(), (Boolean) entry.getValue());
                 else if (entry.getValue() instanceof Character)
                   obj.addProperty(entry.getKey(), (Character) entry.getValue());
                 else if (entry.getValue() == null)
                    obj.add(entry.getKey(), null);
                 else {
                   JsonElement jsonElement = gson.toJsonTree(entry.getValue());
                   if (jsonElement.isJsonArray()) {
                     obj.add(entry.getKey(), jsonElement.getAsJsonArray());
                   } else {
                     obj.add(entry.getKey(), jsonElement.getAsJsonObject());
                   }
                 }
                 out.name((String)entry.getKey());
                 elementAdapter.write(out, obj.get(entry.getKey()));
               }
               out.setSerializeNulls(oldSerializeNulls); //restore
             }
             out.endObject();

           }

           @Override
           public Invoice read(JsonReader in) throws IOException {
             JsonElement jsonElement = elementAdapter.read(in);
             validateJsonElement(jsonElement);
             JsonObject jsonObj = jsonElement.getAsJsonObject();
             // store additional fields in the deserialized instance
             Invoice instance = thisAdapter.fromJsonTree(jsonObj);
             for (Map.Entry entry : jsonObj.entrySet()) {
               if (!openapiFields.contains(entry.getKey())) {
                 if (entry.getValue().isJsonPrimitive()) { // primitive type
                   if (entry.getValue().getAsJsonPrimitive().isString())
                     instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString());
                   else if (entry.getValue().getAsJsonPrimitive().isNumber())
                     instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber());
                   else if (entry.getValue().getAsJsonPrimitive().isBoolean())
                     instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean());
                   else
                     throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString()));
                 } else if (entry.getValue().isJsonArray()) {
                     instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class));
                 } else { // JSON object
                     instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class));
                 }
               }
             }
             return instance;
           }

       }.nullSafe();
    }
  }

  /**
   * Create an instance of Invoice given an JSON string
   *
   * @param jsonString JSON string
   * @return An instance of Invoice
   * @throws IOException if the JSON string is invalid with respect to Invoice
   */
  public static Invoice fromJson(String jsonString) throws IOException {
    return JSON.getGson().fromJson(jsonString, Invoice.class);
  }

  /**
   * Convert an instance of Invoice to an JSON string
   *
   * @return JSON string
   */
  public String toJson() {
    return JSON.getGson().toJson(this);
  }
}





© 2015 - 2025 Weber Informatics LLC | Privacy Policy