001package org.kuali.ole.ingest; 002 003import org.apache.commons.lang3.StringUtils; 004import org.apache.log4j.Logger; 005import org.kuali.ole.OLEConstants; 006import org.kuali.ole.pojo.OleInvoiceRecord; 007import org.kuali.ole.pojo.edi.*; 008import org.kuali.ole.select.OleSelectConstant; 009import org.kuali.ole.sys.context.SpringContext; 010import org.kuali.ole.vnd.businessobject.OleCurrencyType; 011import org.kuali.ole.vnd.businessobject.VendorAlias; 012import org.kuali.rice.krad.service.BusinessObjectService; 013import org.kuali.rice.krad.service.KRADServiceLocatorWeb; 014import org.kuali.rice.krad.service.LookupService; 015 016import java.text.NumberFormat; 017import java.text.ParsePosition; 018import java.util.HashMap; 019import java.util.List; 020import java.util.Map; 021 022/** 023 * Created with IntelliJ IDEA. 024 * User: palanivel 025 * Date: 7/27/13 026 * Time: 6:53 PM 027 * To change this template use File | Settings | File Templates. 028 */ 029public class OleInvoiceRecordBuilder { 030 private static final Logger LOG = Logger.getLogger(OleInvoiceRecordBuilder.class); 031 private static OleInvoiceRecordBuilder oleInvoiceRecordBuilder; 032 protected BusinessObjectService businessObjectService; 033 034 035 /** 036 * default constructor of OleInvoiceRecordBuilder. 037 */ 038 private OleInvoiceRecordBuilder(){ 039 040 } 041 042 /** 043 * Gets the instance of OleInvoiceRecordBuilder. 044 * If OleInvoiceRecordBuilder is null it returns new instance else it returns existing instance. 045 * @return 046 */ 047 public static OleInvoiceRecordBuilder getInstance() { 048 if (null == oleInvoiceRecordBuilder) { 049 oleInvoiceRecordBuilder = new OleInvoiceRecordBuilder(); 050 } 051 return oleInvoiceRecordBuilder; 052 } 053 054 protected BusinessObjectService getBusinessObjectService() { 055 if (businessObjectService == null) { 056 businessObjectService = SpringContext.getBean(BusinessObjectService.class); 057 } 058 return businessObjectService; 059 } 060 061 private LookupService getLookupService() { 062 return KRADServiceLocatorWeb.getLookupService(); 063 } 064 065 066 public OleInvoiceRecord build(LineItemOrder lineItemOrder, INVOrder invOrder) throws Exception { 067 068 OleInvoiceRecord oleInvoiceRecord = new OleInvoiceRecord(); 069 070 oleInvoiceRecord.setListPrice(getListPrice(lineItemOrder)); 071 oleInvoiceRecord.setUnitPrice(populateUnitPrice(lineItemOrder)); 072 oleInvoiceRecord.setQuantity(getQuantity(lineItemOrder)); 073 oleInvoiceRecord.setVendorItemIdentifier(getVendorItemIdentifier(lineItemOrder)!=null?getVendorItemIdentifier(lineItemOrder):getVendorIdentifierByPIA(lineItemOrder)); 074 oleInvoiceRecord.setBfnNumber(getBFNNumber(lineItemOrder)); 075 oleInvoiceRecord.setVendorNumber(getVendorNumber(invOrder,oleInvoiceRecord)); 076 if(StringUtils.isBlank(oleInvoiceRecord.getVendorNumber())){ 077 oleInvoiceRecord.setVendorAlias(getVendorAlias(invOrder)); 078 oleInvoiceRecord.setVendorNumber(getVendorNumberFromVendorAlias(oleInvoiceRecord,invOrder)); 079 } 080 oleInvoiceRecord.setItemChartCode(OLEConstants.OleInvoiceImport.ITM_CHART_CODE); 081 oleInvoiceRecord.setInvoiceNumber(getInvoiceNumber(invOrder)); 082 oleInvoiceRecord.setInvoiceDate(getInvoiceDate(invOrder)); 083 oleInvoiceRecord.setVendorInvoiceAmount(getVendorInvoiceAmount(invOrder)); // If vendor is foreign vendor, foreign vendor invoice amount is populated and vendor invoice amount is null. 084 // oleInvoiceRecord.setForeignVendorInvoiceAmount(getForeignInvoiceAmount(invOrder)); // If vendor is foreign vendor, foreign vendor invoice amount is populated and vendor invoice amount is null. 085 // oleInvoiceRecord.setAdditionalCharge(getForeignInvoiceAmount(invOrder)); 086 oleInvoiceRecord.setISBN(getISBN(lineItemOrder) == null? getLineItemISBN(lineItemOrder):getISBN(lineItemOrder)); 087 oleInvoiceRecord.setISSN(getISSN(lineItemOrder)); 088 //oleInvoiceRecord.setItemType(OLEConstants.OleInvoiceImport.QTY_TYP); 089 oleInvoiceRecord.setBillToCustomerID(populateBillToCustomerId(invOrder)); 090 oleInvoiceRecord.setItemDescription(getItemDescription(lineItemOrder)); 091 oleInvoiceRecord.setNumberOfCopiesOrdered(oleInvoiceRecord.getQuantity()); 092 //oleInvoiceRecord.setNumberOfParts(OLEConstants.OleInvoiceImport.NO_PARTS); 093 oleInvoiceRecord.setSubscriptionPeriodFrom(getSubscriptionDateFrom(lineItemOrder)); 094 oleInvoiceRecord.setSubscriptionPeriodTo(getSubscriptionDateTo(lineItemOrder)); 095 oleInvoiceRecord.setSummaryAmount(getSummaryCharge(invOrder)); 096 oleInvoiceRecord.setAdditionalChargeCode(getAdditionChargeCode(invOrder)); // Additional charge code from header Level. 097 oleInvoiceRecord.setAdditionalCharge(getAdditionCharge(invOrder)); // Monetary amount for additional charge from header level. 098 oleInvoiceRecord.setLineItemAdditionalChargeCode(populateLineItemChargeCode(lineItemOrder)); // Additional charge code from line item Level. 099 oleInvoiceRecord.setLineItemAdditionalCharge(populateLineItemAdditionalCharge(lineItemOrder)); // Monetary amount for additional charge from line item level. 100 oleInvoiceRecord.setPurchaseOrderNumber(getPurchaseOrderNumber(lineItemOrder)); 101 setCurrencyDetails(invOrder,oleInvoiceRecord); 102 return oleInvoiceRecord; 103 } 104 105 private String getVendorNumberFromVendorAlias(OleInvoiceRecord oleInvoiceRecord,INVOrder invOrder) throws Exception{ 106 if(StringUtils.isNotBlank(oleInvoiceRecord.getVendorAlias())){ 107 Map vendorAliasMap = new HashMap(); 108 vendorAliasMap.put(org.kuali.ole.sys.OLEConstants.VENDOR_ALIAS_NAME, oleInvoiceRecord.getVendorAlias()); 109 List<VendorAlias> vendorAliasList = (List<VendorAlias>) getLookupService().findCollectionBySearchHelper(VendorAlias.class, vendorAliasMap, true); 110 if (vendorAliasList != null && vendorAliasList.size() > 0) { 111 return vendorAliasList.get(0).getVendorHeaderGeneratedIdentifier() + "-" + vendorAliasList.get(0).getVendorDetailAssignedIdentifier(); 112 113 }else{ 114 if(oleInvoiceRecord.getVendorItemIdentifier() == null) 115 throw new Exception("The vendor alias in Edifact file doesn't match in database for invoice number:: "+getInvoiceNumber(invOrder)+" and invoice date:: "+getInvoiceDate(invOrder)); 116 } 117 } 118 return null; 119 } 120 121 private void setCurrencyDetails(INVOrder invOrder,OleInvoiceRecord oleInvoiceRecord){ 122 if(invOrder.getMessage() != null && invOrder.getMessage().getCurrencyDetails() != null && invOrder.getMessage().getCurrencyDetails().getCurrencyDetailsSupplierInformation() != null){ 123 if(!StringUtils.isBlank(invOrder.getMessage().getCurrencyDetails().getCurrencyDetailsSupplierInformation().getCurrencyType())){ 124 Map<String,String> currencyTypeMap = new HashMap<>(); 125 currencyTypeMap.put(OLEConstants.CURR_ALPHA_CD, invOrder.getMessage().getCurrencyDetails().getCurrencyDetailsSupplierInformation().getCurrencyType()); 126 List<OleCurrencyType> currencyTypeList = (List) getBusinessObjectService().findMatching(OleCurrencyType.class, currencyTypeMap); 127 if(currencyTypeList != null && currencyTypeList.size() >0){ 128 oleInvoiceRecord.setCurrencyTypeId(currencyTypeList.get(0).getCurrencyTypeId().toString()); 129 oleInvoiceRecord.setCurrencyType(currencyTypeList.get(0).getCurrencyType()); 130 if (!oleInvoiceRecord.getCurrencyType().equalsIgnoreCase(OleSelectConstant.CURRENCY_TYPE_NAME)) { 131 oleInvoiceRecord.setForeignListPrice(oleInvoiceRecord.getListPrice()); 132 } 133 } 134 } 135 } 136 } 137 138 private String populateBillToCustomerId(INVOrder invOrder){ 139 if(invOrder.getMessage() != null && invOrder.getMessage().getPartyQualifier() != null && invOrder.getMessage().getPartyQualifier().size() > 0){ 140 for(int i=0;i<invOrder.getMessage().getPartyQualifier().size();i++){ 141 if(invOrder.getMessage().getPartyQualifier().get(i).getPartyCode()!=null && invOrder.getMessage().getPartyQualifier().get(i).getPartyCode().equalsIgnoreCase("BY")){ 142 return invOrder.getMessage().getPartyQualifier().get(i).getPartyInformation().getCodeIdentification(); 143 } else if(invOrder.getMessage() != null && invOrder.getMessage().getBuyerAdditionalPartyIdentifier() != null && invOrder.getMessage().getBuyerAdditionalPartyIdentifier().getBuyerIdentifier() != null && 144 invOrder.getMessage().getBuyerAdditionalPartyIdentifier().getBuyerIdentifier().getBuyerReferenceQualifier().equalsIgnoreCase("API")){ 145 return invOrder.getMessage().getBuyerAdditionalPartyIdentifier().getBuyerIdentifier().getBuyerReferenceNumber(); 146 } 147 } 148 } 149 return null; 150 } 151 152 private Integer getPurchaseOrderNumber(LineItemOrder lineItemOrder)throws Exception{ 153 if(lineItemOrder.getSupplierReferenceInformation() != null && lineItemOrder.getSupplierReferenceInformation().size() > 0){ 154 for(int i=0;i<lineItemOrder.getSupplierReferenceInformation().size();i++){ 155 if(lineItemOrder.getSupplierReferenceInformation().get(i).getSupplierLineItemReference() != null && 156 lineItemOrder.getSupplierReferenceInformation().get(i).getSupplierLineItemReference().size() >0){ 157 for(int j=0;j<lineItemOrder.getSupplierReferenceInformation().get(i).getSupplierLineItemReference().size();j++){ 158 if(lineItemOrder.getSupplierReferenceInformation().get(i).getSupplierLineItemReference().get(j).getSuppliersOrderLine() != null && 159 lineItemOrder.getSupplierReferenceInformation().get(i).getSupplierLineItemReference().get(j).getSuppliersOrderLine().equals("ON")){ 160 try{ 161 if (lineItemOrder.getSupplierReferenceInformation().get(i).getSupplierLineItemReference().get(j).getVendorReferenceNumber() != null && 162 isNumeric(lineItemOrder.getSupplierReferenceInformation().get(i).getSupplierLineItemReference().get(j).getVendorReferenceNumber())) { 163 return Integer.parseInt(lineItemOrder.getSupplierReferenceInformation().get(i).getSupplierLineItemReference().get(j).getVendorReferenceNumber()); 164 } 165 else { 166 return 0; 167 } 168 169 170 }catch(Exception e){ 171 LOG.error("Purchase Order Number should be a number but invoice file has :"+lineItemOrder.getSupplierReferenceInformation().get(i).getSupplierLineItemReference().get(j).getVendorReferenceNumber()); 172 throw new Exception("Purchase Order Number should be a number but invoice file has :"+lineItemOrder.getSupplierReferenceInformation().get(i).getSupplierLineItemReference().get(j).getVendorReferenceNumber(),e); 173 } 174 } 175 } 176 177 } 178 } 179 180 } 181 /*if(invOrder.getMessage().getPurchaseOrderQualifier() != null){ 182 if(invOrder.getMessage().getPurchaseOrderQualifier().getPurchaseOrderReference() != null){ 183 return Integer.parseInt(invOrder.getMessage().getPurchaseOrderQualifier().getPurchaseOrderReference().getPurchaseOrderNumber()); 184 } 185 }*/ 186 return null; 187 } 188 189 private String populateUnitPrice(LineItemOrder lineItemOrder){ 190 if(lineItemOrder.getMonetaryDetail() != null){ 191 if(lineItemOrder.getMonetaryDetail().get(0).getMonetaryLineItemInformation() != null){ 192 return lineItemOrder.getMonetaryDetail().get(0).getMonetaryLineItemInformation().get(0).getAmount(); 193 } 194 } 195 return null; 196 } 197 198 private String populateLineItemChargeCode(LineItemOrder lineItemOrder){ 199 if(lineItemOrder.getLineItemAllowanceOrCharge() != null){ 200 if(lineItemOrder.getLineItemAllowanceOrCharge().get(0).getLineItemSpecialServiceIdentification()!= null){ 201 return lineItemOrder.getLineItemAllowanceOrCharge().get(0).getLineItemSpecialServiceIdentification().get(0).getSpecialServiceCode(); 202 } 203 } 204 return null; 205 } 206 207 private String populateLineItemAdditionalCharge(LineItemOrder lineItemOrder){ 208 if(lineItemOrder.getAllowanceMonetaryDetail()!= null){ 209 if(lineItemOrder.getAllowanceMonetaryDetail().get(0).getAllowanceMonetaryLineItemInformation() != null){ 210 return lineItemOrder.getAllowanceMonetaryDetail().get(0).getAllowanceMonetaryLineItemInformation().get(0).getAmount(); 211 } 212 } 213 return null; 214 } 215 216 217 private String getAdditionCharge(INVOrder invOrder) { 218 if(invOrder.getMessage().getMonetary() != null){ 219 if(invOrder.getMessage().getMonetary().getMonetaryInformation() != null){ 220 return invOrder.getMessage().getMonetary().getMonetaryInformation().getAmount(); 221 } 222 } 223 return null; 224 } 225 226 227 private String getAdditionChargeCode(INVOrder invOrder) { 228 if(invOrder.getMessage().getAllowanceOrCharge() != null){ 229 if(invOrder.getMessage().getAllowanceOrCharge().getSpecialServiceIdentification() != null){ 230 return invOrder.getMessage().getAllowanceOrCharge().getSpecialServiceIdentification().getSpecialServiceCode(); 231 } 232 } 233 return null; 234 } 235 236 237 /** 238 * This method returns ListPrice from the List of PriceInformation got from lineItemOrder. 239 * If there are no PriceInformation then it return null. 240 * @param lineItemOrder 241 * @return Price 242 */ 243 private String getListPrice(LineItemOrder lineItemOrder) { 244 List<PriceInformation> priceInformation = lineItemOrder.getPriceInformation(); 245 if (priceInformation !=null && priceInformation.size() > 0) { 246 List<ItemPrice> itemPrice = priceInformation.get(0).getItemPrice(); 247 248 if (itemPrice != null && itemPrice.size() > 0) { 249 String priceCode = itemPrice.get(0).getGrossPrice(); 250 if(priceCode != null && (priceCode.equalsIgnoreCase("AAB") || priceCode.equalsIgnoreCase("CAL"))){ 251 return itemPrice.get(0).getPrice(); 252 } 253 } 254 } 255 return null; 256 } 257 258 259 /** 260 * This method returns the Quantity from the list of QuantityInformation got from lineItemOrder. 261 * If there are no QuantityInformation then it return null. 262 * @param lineItemOrder 263 * @return Quantity 264 */ 265 private String getQuantity(LineItemOrder lineItemOrder) { 266 List<QuantityInformation> quantityInformation = lineItemOrder.getQuantityInformation(); 267 if (quantityInformation != null && quantityInformation.size() > 0) { 268 List<Qunatity> qunatity = quantityInformation.get(0).getQunatity(); 269 if (qunatity.size() > 0) { 270 return qunatity.get(0).getQuantity(); 271 } 272 } 273 return null; 274 } 275 276 private String getVendorIdentifierByPIA(LineItemOrder lineItemOrder) { 277 List<ProductFunction> productFunction = lineItemOrder.getProductFunction(); 278 if(productFunction != null && productFunction.size()>0){ 279 for(int i=0;i<productFunction.size();i++){ 280 if(productFunction.get(i).getProductArticleNumber() != null && productFunction.get(i).getProductArticleNumber().size()>0){ 281 if(productFunction.get(i).getProductArticleNumber().get(0).getProductItemNumberType().equalsIgnoreCase("SA")){ 282 return productFunction.get(i).getProductArticleNumber().get(0).getProductIsbn(); 283 } 284 } 285 } 286 } 287 return null; 288 } 289 290 public String getVendorItemIdentifier(LineItemOrder lineItemOrder) { 291 List<SupplierReferenceInformation> supplierReferenceInformationList = lineItemOrder.getSupplierReferenceInformation(); 292 if (supplierReferenceInformationList != null && supplierReferenceInformationList.size() > 0) { 293 for(int i=0;i<supplierReferenceInformationList.size();i++){ 294 SupplierReferenceInformation supplierReferenceInformation = supplierReferenceInformationList.get(i); 295 List<SupplierLineItemReference> supplierLineItemReferenceList = supplierReferenceInformation.getSupplierLineItemReference(); 296 if (supplierLineItemReferenceList != null && supplierLineItemReferenceList.size() > 0) { 297 SupplierLineItemReference supplierLineItemReferenceRef = supplierLineItemReferenceList.get(0); 298 String supplierOrderLine = supplierLineItemReferenceRef.getSuppliersOrderLine(); 299 String vendorItemReference = supplierLineItemReferenceRef.getVendorReferenceNumber(); 300 if (supplierOrderLine.equals("SNA")) { 301 return vendorItemReference; 302 } 303 } 304 } 305 } 306 return null; 307 } 308 309 public String getBFNNumber(LineItemOrder lineItemOrder) { 310 List<SupplierReferenceInformation> supplierReferenceInformationList = lineItemOrder.getSupplierReferenceInformation(); 311 if (supplierReferenceInformationList != null && supplierReferenceInformationList.size() > 0) { 312 for(int i=0;i<supplierReferenceInformationList.size();i++){ 313 SupplierReferenceInformation supplierReferenceInformation = supplierReferenceInformationList.get(i); 314 List<SupplierLineItemReference> supplierLineItemReferenceList = supplierReferenceInformation.getSupplierLineItemReference(); 315 if (supplierLineItemReferenceList != null && supplierLineItemReferenceList.size() > 0) { 316 SupplierLineItemReference supplierLineItemReferenceRef = supplierLineItemReferenceList.get(0); 317 String supplierOrderLine = supplierLineItemReferenceRef.getSuppliersOrderLine(); 318 String vendorItemReference = supplierLineItemReferenceRef.getVendorReferenceNumber(); 319 if (supplierOrderLine.equals("BFN")) { 320 return vendorItemReference; 321 } 322 } 323 } 324 } 325 return null; 326 } 327 328 private String getVendorAlias(INVOrder invOrder) throws Exception{ 329 if(invOrder.getMessage().getSupplierAdditionalPartyIdentifier() != null && invOrder.getMessage().getSupplierAdditionalPartyIdentifier().getSupplierIdentifier() != null && StringUtils.isNotEmpty(invOrder.getMessage().getSupplierAdditionalPartyIdentifier().getSupplierIdentifier().getReferenceQualifier()) && invOrder.getMessage().getSupplierAdditionalPartyIdentifier().getSupplierIdentifier().getReferenceQualifier().equalsIgnoreCase("API")){ 330 return invOrder.getMessage().getSupplierAdditionalPartyIdentifier().getSupplierIdentifier().getReferenceNumber(); 331 } 332 return null; 333 } 334 335 /** 336 * This method gets the vendor Number from invoice Order. 337 * @param invOrder 338 * @return 339 */ 340 private String getVendorNumber(INVOrder invOrder,OleInvoiceRecord oleInvoiceRecord) throws Exception{ 341 try{ 342 for(int i=0;i<invOrder.getMessage().getPartyQualifier().size();i++){ 343 if(invOrder.getMessage().getPartyQualifier().get(i).getPartyCode()!=null && (invOrder.getMessage().getPartyQualifier().get(i).getPartyCode().equalsIgnoreCase("SR") || invOrder.getMessage().getPartyQualifier().get(i).getPartyCode().equalsIgnoreCase("SU"))){ 344 if(StringUtils.isNotEmpty(invOrder.getMessage().getPartyQualifier().get(i).getPartyInformation().getCodeIdentification())){ 345 return invOrder.getMessage().getPartyQualifier().get(i).getPartyInformation().getCodeIdentification(); 346 } 347 } 348 } 349 }catch (Exception e){ 350 if(oleInvoiceRecord.getVendorItemIdentifier() == null) 351 throw new Exception("Edifact file has no vendor number for invoice number:: "+getInvoiceNumber(invOrder)+" and invoice date:: "+getInvoiceDate(invOrder),e); 352 } 353 return null; 354 } 355 356 357 /** 358 * This method gets the invoice Number from invoice Order. 359 * @param invOrder 360 * @return 361 */ 362 private String getInvoiceNumber(INVOrder invOrder)throws Exception{ 363 try{ 364 return invOrder.getMessage().getMessageBeginning().getMessageBeginningInterchangeControlReference(); 365 }catch (Exception e){ 366 throw new Exception("Edifact file has no invoice number.",e); 367 } 368 } 369 370 /** 371 * This method gets the invoice date from invoice Order. 372 * @param invOrder 373 * @return 374 */ 375 private String getInvoiceDate(INVOrder invOrder) throws Exception{ 376 try{ 377 return invOrder.getMessage().getMessageCreationInformation().getMessageCreationInfoDetails().getMessageCreationInfoDate(); 378 }catch (Exception e){ 379 throw new Exception("Edifact file has no invoice date.",e); 380 } 381 } 382 383 384 private String getForeignInvoiceAmount(INVOrder invOrder){ 385 // return invOrder.getMessage().getMonetary().getMonetaryInformation().getAmount(); 386 return null; 387 } 388 389 private String getVendorInvoiceAmount(INVOrder invOrder){ 390 if(invOrder.getSummary() != null && invOrder.getSummary().getMonetarySummary() != null && invOrder.getSummary().getMonetarySummary().size() > 0){ 391 for(int i=0;i<invOrder.getSummary().getMonetarySummary().size();i++){ 392 MonetarySummary monetarySummary = (MonetarySummary)invOrder.getSummary().getMonetarySummary().get(i); 393 if(monetarySummary.getMonetarySummaryInformation()!=null && monetarySummary.getMonetarySummaryInformation().size()>0){ 394 for(int j=0;j<monetarySummary.getMonetarySummaryInformation().size();j++){ 395 if(monetarySummary.getMonetarySummaryInformation().get(0).getAmountType().equalsIgnoreCase("86")){ 396 return monetarySummary.getMonetarySummaryInformation().get(0).getAmount(); 397 } 398 } 399 } 400 } 401 } 402 return null; 403 } 404 405 private String getLineItemISBN(LineItemOrder lineItemOrder){ 406 if(lineItemOrder.getLineItem() != null && lineItemOrder.getLineItem().get(0)!= null){ 407 if(lineItemOrder.getLineItem().get(0).getLineItemArticleNumber() != null && lineItemOrder.getLineItem().get(0).getLineItemArticleNumber().get(0)!=null){ 408 return lineItemOrder.getLineItem().get(0).getLineItemArticleNumber().get(0).getLineItemIsbn(); 409 } 410 } 411 return null; 412 } 413 414 private String getISBN(LineItemOrder lineItemOrder){ 415 if(lineItemOrder.getProductFunction()!= null && lineItemOrder.getProductFunction().size() > 0){ 416 if(lineItemOrder.getProductFunction().get(0).getProductArticleNumber() != null && lineItemOrder.getProductFunction().get(0).getProductArticleNumber().size() > 0){ 417 if(lineItemOrder.getProductFunction().get(0).getProductArticleNumber().get(0).getProductItemNumberType() != null){ 418 return lineItemOrder.getProductFunction().get(0).getProductArticleNumber().get(0).getProductIsbn(); 419 } 420 if(lineItemOrder.getProductFunction().get(0).getProductArticleNumber().get(0).getProductItemNumberType() == null && 421 lineItemOrder.getProductFunction().get(0).getProductArticleNumber().get(0).getProductIsbn() != null){ 422 return lineItemOrder.getProductFunction().get(0).getProductArticleNumber().get(0).getProductIsbn(); 423 } 424 } 425 } 426 return null; 427 } 428 429 private String getISSN(LineItemOrder lineItemOrder){ 430 if (lineItemOrder.getProductFunction()!= null && lineItemOrder.getProductFunction().size() > 0){ 431 if(lineItemOrder.getProductFunction().get(0).getSupplierArticleNumber() != null && lineItemOrder.getProductFunction().get(0).getSupplierArticleNumber().size() > 0){ 432 return lineItemOrder.getProductFunction().get(0).getSupplierArticleNumber().get(0).getIsbn(); 433 } 434 } 435 return null; 436 } 437 438 439 private String getItemDescription(LineItemOrder lineItemOrder){ 440 if(lineItemOrder.getItemDescriptionList() != null && lineItemOrder.getItemDescriptionList().size() > 0){ 441 return lineItemOrder.getItemDescriptionList().get(0).getData(); 442 } 443 return null; 444 } 445 446 private String getSubscriptionDateFrom(LineItemOrder lineItemOrder){ 447 if(lineItemOrder.getDateTimeDetail() != null && lineItemOrder.getDateTimeDetail().size() > 0){ 448 if(lineItemOrder.getDateTimeDetail().get(0).getDateTimeInformationList() != null && lineItemOrder.getDateTimeDetail().get(0).getDateTimeInformationList().size() > 0){ 449 return lineItemOrder.getDateTimeDetail().get(0).getDateTimeInformationList().get(0).getPeriod(); 450 } 451 } 452 return null; 453 } 454 455 private String getSubscriptionDateTo(LineItemOrder lineItemOrder){ 456 if(lineItemOrder.getDateTimeDetail()!= null && lineItemOrder.getDateTimeDetail().size() > 1){ 457 if(lineItemOrder.getDateTimeDetail().get(1).getDateTimeInformationList() != null && lineItemOrder.getDateTimeDetail().get(1).getDateTimeInformationList().size() > 0){ 458 return lineItemOrder.getDateTimeDetail().get(1).getDateTimeInformationList().get(0).getPeriod(); 459 } 460 } 461 return null; 462 } 463 464 private String getSummaryCharge(INVOrder invOrder){ 465 if(invOrder.getSummary()!= null && invOrder.getSummary().getMonetarySummary() != null && 466 invOrder.getSummary().getMonetarySummary().size()> 0){ 467 if(invOrder.getSummary().getMonetarySummary().get(invOrder.getSummary().getMonetarySummary().size()-1).getMonetarySummaryInformation() != null && invOrder.getSummary().getMonetarySummary().get(invOrder.getSummary().getMonetarySummary().size()-1).getMonetarySummaryInformation().size() > 0){ 468 invOrder.getSummary().getMonetarySummary().get(invOrder.getSummary().getMonetarySummary().size()-1).getMonetarySummaryInformation().get(0).getAmount(); 469 } 470 } 471 return null; 472 } 473 474 private static boolean isNumeric(String str) { 475 NumberFormat formatter = NumberFormat.getInstance(); 476 ParsePosition pos = new ParsePosition(0); 477 formatter.parse(str, pos); 478 return str.length() == pos.getIndex(); 479 } 480 481}