class UBL20InvoiceHelper {

  public static void cloneInvoiceToCreditNote (@Nonnull final InvoiceType aSrc, @Nonnull final CreditNoteType aDst)
  {
    aDst.setAccountingCost (aSrc.getAccountingCost () == null ? null : aSrc.getAccountingCost ().clone ());
    aDst.setAccountingCostCode (aSrc.getAccountingCostCode () == null ? null : aSrc.getAccountingCostCode ().clone ());
    aDst.setAccountingCustomerParty (aSrc.getAccountingCustomerParty () == null ? null : aSrc.getAccountingCustomerParty ().clone ());
    aDst.setAccountingSupplierParty (aSrc.getAccountingSupplierParty () == null ? null : aSrc.getAccountingSupplierParty ().clone ());
    {
      final List <DocumentReferenceType> retAdditionalDocumentReference = new ArrayList <> ();
      for (final DocumentReferenceType aItem : aSrc.getAdditionalDocumentReference ())
        retAdditionalDocumentReference.add (aItem == null ? null : aItem.clone ());
      aDst.setAdditionalDocumentReference (retAdditionalDocumentReference);
    }
    {
      final List <AllowanceChargeType> retAllowanceCharge = new ArrayList <> ();
      for (final AllowanceChargeType aItem : aSrc.getAllowanceCharge ())
        retAllowanceCharge.add (aItem == null ? null : aItem.clone ());
      aDst.setAllowanceCharge (retAllowanceCharge);
    }
    {
      final List <BillingReferenceType> retBillingReference = new ArrayList <> ();
      for (final BillingReferenceType aItem : aSrc.getBillingReference ())
        retBillingReference.add (aItem == null ? null : aItem.clone ());
      aDst.setBillingReference (retBillingReference);
    }
    // Not present
    /*
     * ret.setBuyerCustomerParty (src.getBuyerCustomerParty () == null ? null :
     * src.getBuyerCustomerParty ().clone ());
     */
    {
      final List <DocumentReferenceType> retContractDocumentReference = new ArrayList <> ();
      for (final DocumentReferenceType aItem : aSrc.getContractDocumentReference ())
        retContractDocumentReference.add (aItem == null ? null : aItem.clone ());
      aDst.setContractDocumentReference (retContractDocumentReference);
    }
    aDst.setCopyIndicator (aSrc.getCopyIndicator () == null ? null : aSrc.getCopyIndicator ().clone ());
    aDst.setCustomizationID (aSrc.getCustomizationID () == null ? null : aSrc.getCustomizationID ().clone ());
    // Not present
    /*
     * { final List <DeliveryType> retDelivery = new ArrayList <> (); for (final
     * DeliveryType aItem : src.getDelivery ()) retDelivery.add (aItem == null ?
     * null : aItem.clone ()); ret.setDelivery (retDelivery); }
     */
    // Not present
    /*
     * ret.setDeliveryTerms (src.getDeliveryTerms () == null ? null :
     * src.getDeliveryTerms ().clone ());´
     */
    {
      final List <DocumentReferenceType> retDespatchDocumentReference = new ArrayList <> ();
      for (final DocumentReferenceType aItem : aSrc.getDespatchDocumentReference ())
        retDespatchDocumentReference.add (aItem == null ? null : aItem.clone ());
      aDst.setDespatchDocumentReference (retDespatchDocumentReference);
    }
    // DiscrepancyResponse is not present in Invoice
    aDst.setDocumentCurrencyCode (aSrc.getDocumentCurrencyCode () == null ? null : aSrc.getDocumentCurrencyCode ().clone ());
    aDst.setID (aSrc.getID () == null ? null : aSrc.getID ().clone ());
    // Name change
    {
      final List <CreditNoteLineType> retInvoiceLine = new ArrayList <> ();
      for (final InvoiceLineType aItem : aSrc.getInvoiceLine ())
        if (aItem == null)
          retInvoiceLine.add (null);
        else
        {
          final CreditNoteLineType aNewLine = new CreditNoteLineType ();
          cloneToCreditNoteLine (aItem, aNewLine);
          retInvoiceLine.add (aNewLine);
        }
      aDst.setCreditNoteLine (retInvoiceLine);
    }
    {
      final List <PeriodType> retInvoicePeriod = new ArrayList <> ();
      for (final PeriodType aItem : aSrc.getInvoicePeriod ())
      {
        retInvoicePeriod.add (aItem == null ? null : aItem.clone ());
      }
      aDst.setInvoicePeriod (retInvoicePeriod);
    }
    // Not present
    /*
     * ret.setInvoiceTypeCode (src.getInvoiceTypeCode () == null ? null :
     * src.getInvoiceTypeCode ().clone ());
     */
    aDst.setIssueDate (aSrc.getIssueDate () == null ? null : aSrc.getIssueDate ().clone ());
    aDst.setIssueTime (aSrc.getIssueTime () == null ? null : aSrc.getIssueTime ().clone ());
    aDst.setLegalMonetaryTotal (aSrc.getLegalMonetaryTotal () == null ? null : aSrc.getLegalMonetaryTotal ().clone ());
    aDst.setLineCountNumeric (aSrc.getLineCountNumeric () == null ? null : aSrc.getLineCountNumeric ().clone ());
    {
      final List <NoteType> retNote = new ArrayList <> ();
      for (final NoteType aItem : aSrc.getNote ())
        retNote.add (aItem == null ? null : aItem.clone ());
      aDst.setNote (retNote);
    }
    aDst.setOrderReference (aSrc.getOrderReference () == null ? null : aSrc.getOrderReference ().clone ());
    // Not present
    /*
     * { final List <DocumentReferenceType> retOriginatorDocumentReference = new
     * ArrayList <> (); for (final DocumentReferenceType aItem :
     * src.getOriginatorDocumentReference ()) retOriginatorDocumentReference.add
     * (aItem == null ? null : aItem.clone ());
     * ret.setOriginatorDocumentReference (retOriginatorDocumentReference); }
     */
    aDst.setPayeeParty (aSrc.getPayeeParty () == null ? null : aSrc.getPayeeParty ().clone ());
    aDst.setPaymentAlternativeCurrencyCode (aSrc.getPaymentAlternativeCurrencyCode () == null ? null
                                                                                              : aSrc.getPaymentAlternativeCurrencyCode ()
                                                                                                    .clone ());
    aDst.setPaymentAlternativeExchangeRate (aSrc.getPaymentAlternativeExchangeRate () == null ? null
                                                                                              : aSrc.getPaymentAlternativeExchangeRate ()
                                                                                                    .clone ());
    aDst.setPaymentCurrencyCode (aSrc.getPaymentCurrencyCode () == null ? null : aSrc.getPaymentCurrencyCode ().clone ());
    aDst.setPaymentExchangeRate (aSrc.getPaymentExchangeRate () == null ? null : aSrc.getPaymentExchangeRate ().clone ());
    // Not present
    /*
     * { final List <PaymentMeansType> retPaymentMeans = new ArrayList <> ();
     * for (final PaymentMeansType aItem : src.getPaymentMeans ())
     * retPaymentMeans.add (aItem == null ? null : aItem.clone ());
     * ret.setPaymentMeans (retPaymentMeans); }
     */
    // Not present
    /*
     * { final List <PaymentTermsType> retPaymentTerms = new ArrayList <> ();
     * for (final PaymentTermsType aItem : src.getPaymentTerms ())
     * retPaymentTerms.add (aItem == null ? null : aItem.clone ());
     * ret.setPaymentTerms (retPaymentTerms); }
     */
    // Not present
    /*
     * { final List <PaymentType> retPrepaidPayment = new ArrayList <> (); for
     * (final PaymentType aItem : src.getPrepaidPayment ())
     * retPrepaidPayment.add (aItem == null ? null : aItem.clone ());
     * ret.setPrepaidPayment (retPrepaidPayment); }
     */
    aDst.setPricingCurrencyCode (aSrc.getPricingCurrencyCode () == null ? null : aSrc.getPricingCurrencyCode ().clone ());
    aDst.setPricingExchangeRate (aSrc.getPricingExchangeRate () == null ? null : aSrc.getPricingExchangeRate ().clone ());
    aDst.setProfileID (aSrc.getProfileID () == null ? null : aSrc.getProfileID ().clone ());
    {
      final List <DocumentReferenceType> retReceiptDocumentReference = new ArrayList <> ();
      for (final DocumentReferenceType aItem : aSrc.getReceiptDocumentReference ())
        retReceiptDocumentReference.add (aItem == null ? null : aItem.clone ());
      aDst.setReceiptDocumentReference (retReceiptDocumentReference);
    }
    // Not present
    /*
     * ret.setSellerSupplierParty (src.getSellerSupplierParty () == null ? null
     * : src.getSellerSupplierParty ().clone ());
     */
    {
      final List <SignatureType> retSignature = new ArrayList <> ();
      for (final SignatureType aItem : aSrc.getSignature ())
        retSignature.add (aItem == null ? null : aItem.clone ());
      aDst.setSignature (retSignature);
    }
    aDst.setTaxCurrencyCode (aSrc.getTaxCurrencyCode () == null ? null : aSrc.getTaxCurrencyCode ().clone ());
    aDst.setTaxExchangeRate (aSrc.getTaxExchangeRate () == null ? null : aSrc.getTaxExchangeRate ().clone ());
    aDst.setTaxPointDate (aSrc.getTaxPointDate () == null ? null : aSrc.getTaxPointDate ().clone ());
    aDst.setTaxRepresentativeParty (aSrc.getTaxRepresentativeParty () == null ? null : aSrc.getTaxRepresentativeParty ().clone ());
    {
      final List <TaxTotalType> retTaxTotal = new ArrayList <> ();
      for (final TaxTotalType aItem : aSrc.getTaxTotal ())
        retTaxTotal.add (aItem == null ? null : aItem.clone ());
      aDst.setTaxTotal (retTaxTotal);
    }
    aDst.setUBLExtensions (aSrc.getUBLExtensions () == null ? null : aSrc.getUBLExtensions ().clone ());
    aDst.setUBLVersionID (aSrc.getUBLVersionID () == null ? null : aSrc.getUBLVersionID ().clone ());
    aDst.setUUID (aSrc.getUUID () == null ? null : aSrc.getUUID ().clone ());
  }

  private  UBL20InvoiceHelper();

}