private void setCurrencyDetails(INVOrder invOrder, OleInvoiceRecord oleInvoiceRecord) {
   if (invOrder.getMessage() != null
       && invOrder.getMessage().getCurrencyDetails() != null
       && invOrder.getMessage().getCurrencyDetails().getCurrencyDetailsSupplierInformation()
           != null) {
     if (!StringUtils.isBlank(
         invOrder
             .getMessage()
             .getCurrencyDetails()
             .getCurrencyDetailsSupplierInformation()
             .getCurrencyType())) {
       Map<String, String> currencyTypeMap = new HashMap<>();
       currencyTypeMap.put(
           OLEConstants.CURR_ALPHA_CD,
           invOrder
               .getMessage()
               .getCurrencyDetails()
               .getCurrencyDetailsSupplierInformation()
               .getCurrencyType());
       List<OleCurrencyType> currencyTypeList =
           (List) getBusinessObjectService().findMatching(OleCurrencyType.class, currencyTypeMap);
       if (currencyTypeList != null && currencyTypeList.size() > 0) {
         oleInvoiceRecord.setCurrencyTypeId(
             currencyTypeList.get(0).getCurrencyTypeId().toString());
         oleInvoiceRecord.setCurrencyType(currencyTypeList.get(0).getCurrencyType());
         if (!oleInvoiceRecord
             .getCurrencyType()
             .equalsIgnoreCase(OleSelectConstant.CURRENCY_TYPE_NAME)) {
           oleInvoiceRecord.setForeignListPrice(oleInvoiceRecord.getListPrice());
         }
       }
     }
   }
 }
 private String getAdditionCharge(INVOrder invOrder) {
   if (invOrder.getMessage().getMonetary() != null) {
     if (invOrder.getMessage().getMonetary().getMonetaryInformation() != null) {
       return invOrder.getMessage().getMonetary().getMonetaryInformation().getAmount();
     }
   }
   return null;
 }
 private String getAdditionChargeCode(INVOrder invOrder) {
   if (invOrder.getMessage().getAllowanceOrCharge() != null) {
     if (invOrder.getMessage().getAllowanceOrCharge().getSpecialServiceIdentification() != null) {
       return invOrder
           .getMessage()
           .getAllowanceOrCharge()
           .getSpecialServiceIdentification()
           .getSpecialServiceCode();
     }
   }
   return null;
 }
 private String getSummaryCharge(INVOrder invOrder) {
   if (invOrder.getSummary() != null
       && invOrder.getSummary().getMonetarySummary() != null
       && invOrder.getSummary().getMonetarySummary().size() > 0) {
     if (invOrder
                 .getSummary()
                 .getMonetarySummary()
                 .get(invOrder.getSummary().getMonetarySummary().size() - 1)
                 .getMonetarySummaryInformation()
             != null
         && invOrder
                 .getSummary()
                 .getMonetarySummary()
                 .get(invOrder.getSummary().getMonetarySummary().size() - 1)
                 .getMonetarySummaryInformation()
                 .size()
             > 0) {
       invOrder
           .getSummary()
           .getMonetarySummary()
           .get(invOrder.getSummary().getMonetarySummary().size() - 1)
           .getMonetarySummaryInformation()
           .get(0)
           .getAmount();
     }
   }
   return null;
 }
 /**
  * This method gets the invoice Number from invoice Order.
  *
  * @param invOrder
  * @return
  */
 private String getInvoiceNumber(INVOrder invOrder) throws Exception {
   try {
     return invOrder
         .getMessage()
         .getMessageBeginning()
         .getMessageBeginningInterchangeControlReference();
   } catch (Exception e) {
     throw new Exception("Edifact file has no invoice number.", e);
   }
 }
 /**
  * This method gets the invoice date from invoice Order.
  *
  * @param invOrder
  * @return
  */
 private String getInvoiceDate(INVOrder invOrder) throws Exception {
   try {
     return invOrder
         .getMessage()
         .getMessageCreationInformation()
         .getMessageCreationInfoDetails()
         .getMessageCreationInfoDate();
   } catch (Exception e) {
     throw new Exception("Edifact file has no invoice date.", e);
   }
 }
 private String populateBillToCustomerId(INVOrder invOrder) {
   if (invOrder.getMessage() != null
       && invOrder.getMessage().getPartyQualifier() != null
       && invOrder.getMessage().getPartyQualifier().size() > 0) {
     for (int i = 0; i < invOrder.getMessage().getPartyQualifier().size(); i++) {
       if (invOrder.getMessage().getPartyQualifier().get(i).getPartyCode() != null
           && invOrder
               .getMessage()
               .getPartyQualifier()
               .get(i)
               .getPartyCode()
               .equalsIgnoreCase("BY")) {
         return invOrder
             .getMessage()
             .getPartyQualifier()
             .get(i)
             .getPartyInformation()
             .getCodeIdentification();
       } else if (invOrder.getMessage() != null
           && invOrder.getMessage().getBuyerAdditionalPartyIdentifier() != null
           && invOrder.getMessage().getBuyerAdditionalPartyIdentifier().getBuyerIdentifier()
               != null
           && invOrder
               .getMessage()
               .getBuyerAdditionalPartyIdentifier()
               .getBuyerIdentifier()
               .getBuyerReferenceQualifier()
               .equalsIgnoreCase("API")) {
         return invOrder
             .getMessage()
             .getBuyerAdditionalPartyIdentifier()
             .getBuyerIdentifier()
             .getBuyerReferenceNumber();
       }
     }
   }
   return null;
 }
 private String getVendorInvoiceAmount(INVOrder invOrder) {
   if (invOrder.getSummary() != null
       && invOrder.getSummary().getMonetarySummary() != null
       && invOrder.getSummary().getMonetarySummary().size() > 0) {
     for (int i = 0; i < invOrder.getSummary().getMonetarySummary().size(); i++) {
       MonetarySummary monetarySummary =
           (MonetarySummary) invOrder.getSummary().getMonetarySummary().get(i);
       if (monetarySummary.getMonetarySummaryInformation() != null
           && monetarySummary.getMonetarySummaryInformation().size() > 0) {
         for (int j = 0; j < monetarySummary.getMonetarySummaryInformation().size(); j++) {
           if (monetarySummary
               .getMonetarySummaryInformation()
               .get(0)
               .getAmountType()
               .equalsIgnoreCase("86")) {
             return monetarySummary.getMonetarySummaryInformation().get(0).getAmount();
           }
         }
       }
     }
   }
   return null;
 }
 private String getVendorAlias(INVOrder invOrder) throws Exception {
   if (invOrder.getMessage().getSupplierAdditionalPartyIdentifier() != null
       && invOrder.getMessage().getSupplierAdditionalPartyIdentifier().getSupplierIdentifier()
           != null
       && StringUtils.isNotEmpty(
           invOrder
               .getMessage()
               .getSupplierAdditionalPartyIdentifier()
               .getSupplierIdentifier()
               .getReferenceQualifier())
       && invOrder
           .getMessage()
           .getSupplierAdditionalPartyIdentifier()
           .getSupplierIdentifier()
           .getReferenceQualifier()
           .equalsIgnoreCase("API")) {
     return invOrder
         .getMessage()
         .getSupplierAdditionalPartyIdentifier()
         .getSupplierIdentifier()
         .getReferenceNumber();
   }
   return null;
 }
 private String getSummaryTax(INVOrder invOrder) {
   String summaryTaxAmount = "";
   Summary summary = invOrder.getSummary();
   if (summary != null) {
     MonetaryTaxSummary monetaryTaxSummary = summary.getMonetaryTaxSummary();
     if (monetaryTaxSummary != null) {
       MonetaryTaxSummaryDetails monetaryTaxSummaryDetails =
           monetaryTaxSummary.getMonetaryTaxSummaryDetails();
       if (monetaryTaxSummaryDetails != null
           && "124".equals(monetaryTaxSummaryDetails.getAmountType())) {
         summaryTaxAmount = monetaryTaxSummaryDetails.getAmount();
       }
     }
   }
   return summaryTaxAmount;
 }
 /**
  * This method gets the vendor Number from invoice Order.
  *
  * @param invOrder
  * @return
  */
 private String getVendorNumber(INVOrder invOrder, OleInvoiceRecord oleInvoiceRecord)
     throws Exception {
   try {
     for (int i = 0; i < invOrder.getMessage().getPartyQualifier().size(); i++) {
       if (invOrder.getMessage().getPartyQualifier().get(i).getPartyCode() != null
           && (invOrder
                   .getMessage()
                   .getPartyQualifier()
                   .get(i)
                   .getPartyCode()
                   .equalsIgnoreCase("SR")
               || invOrder
                   .getMessage()
                   .getPartyQualifier()
                   .get(i)
                   .getPartyCode()
                   .equalsIgnoreCase("SU"))) {
         if (StringUtils.isNotEmpty(
             invOrder
                 .getMessage()
                 .getPartyQualifier()
                 .get(i)
                 .getPartyInformation()
                 .getCodeIdentification())) {
           return invOrder
               .getMessage()
               .getPartyQualifier()
               .get(i)
               .getPartyInformation()
               .getCodeIdentification();
         }
       }
     }
   } catch (Exception e) {
     if (oleInvoiceRecord.getVendorItemIdentifier() == null)
       throw new Exception(
           "Edifact file has no vendor number for invoice number:: "
               + getInvoiceNumber(invOrder)
               + " and invoice date:: "
               + getInvoiceDate(invOrder),
           e);
   }
   return null;
 }