org.kuali.kfs.module.purap.service.impl
Class ElectronicInvoiceHelperServiceImpl

java.lang.Object
  extended by org.kuali.kfs.module.purap.service.impl.ElectronicInvoiceHelperServiceImpl
All Implemented Interfaces:
ElectronicInvoiceHelperService

@Transactional
public class ElectronicInvoiceHelperServiceImpl
extends Object
implements ElectronicInvoiceHelperService

This is a helper service to parse electronic invoice file, match it with a PO and create PREQs based on the eInvoice. Also, it provides helper methods to the reject document to match it with a PO and create PREQ.


Field Summary
protected  BatchInputFileService batchInputFileService
           
protected  org.kuali.rice.kns.service.DateTimeService dateTimeService
           
protected  ElectronicInvoiceInputFileType electronicInvoiceInputFileType
           
protected  ElectronicInvoicingDao electronicInvoicingDao
           
protected  String INVOICE_FILE_MIME_TYPE
           
protected  org.kuali.rice.kns.service.KualiConfigurationService kualiConfigurationService
           
protected  org.kuali.rice.kns.service.MailService mailService
           
protected  ElectronicInvoiceMatchingService matchingService
           
protected  org.kuali.rice.kns.service.ParameterService parameterService
           
protected  PaymentRequestService paymentRequestService
           
protected  PurchaseOrderService purchaseOrderService
           
protected  String UNKNOWN_DUNS_IDENTIFIER
           
protected  VendorService vendorService
           
 
Constructor Summary
ElectronicInvoiceHelperServiceImpl()
           
 
Method Summary
protected  void addMissingMappedItems(List<PurApItem> preqItems, ElectronicInvoiceOrderHolder orderHolder)
          Ensures that the mapped items, item type code, exist as a payment request item so they're process correctly within populateItemDetails
protected  byte[] addNamespaceDefinition(ElectronicInvoiceLoad eInvoiceLoad, File invoiceFile)
           
protected  void addRejectReasonsToNote(String rejectReasons, ElectronicInvoiceRejectDocument eInvoiceRejectDocument)
           
protected  void addShipToNotes(PaymentRequestDocument preqDoc, ElectronicInvoiceOrderHolder orderHolder)
           
protected  void addToListIfExists(List itemTypeCodeList, String invoiceItemTypeCode, ElectronicInvoiceOrderHolder orderHolder)
          Utility method to add a kuali item type code to a list from a invoice item type code
protected  void attachInvoiceXMLWithRejectDoc(ElectronicInvoiceRejectDocument eInvoiceRejectDocument, File attachmentFile, String noteText)
           
protected  String checkDescriptionLengthAndStripIfNeeded(String description)
           
protected  boolean checkForCompleteFailure(ElectronicInvoiceLoad electronicInvoiceLoad, ElectronicInvoice electronicInvoice, File invoiceFile)
           
protected  List createInvoiceRequiresItemTypeCodeList(ElectronicInvoiceOrderHolder orderHolder)
          Creates a list of item types the eInvoice requirs on the payment request due to valid amounts.
protected  PaymentRequestDocument createPaymentRequest(ElectronicInvoiceOrderHolder orderHolder)
           
 boolean createPaymentRequest(ElectronicInvoiceRejectDocument rejectDocument)
           
 ElectronicInvoiceRejectDocument createRejectDocument(ElectronicInvoice eInvoice, ElectronicInvoiceOrder electronicInvoiceOrder, ElectronicInvoiceLoad eInvoiceLoad)
           
protected  void deleteDoneFile(File invoiceFile)
           
 boolean doMatchingProcess(ElectronicInvoiceRejectDocument rejectDocument)
          This method is responsible for the matching process for a reject document
protected  String generatePREQDocumentDescription(PurchaseOrderDocument poDocument)
           
protected  String generateRejectDocumentDescription(ElectronicInvoice eInvoice, ElectronicInvoiceOrder electronicInvoiceOrder)
           
protected  String generateRejectDocumentDescription(ElectronicInvoiceRejectDocument rejectDoc)
           
protected  String getAcceptDirName()
           
protected  String getBaseDirName()
           
protected  String getErrorMessages(Map<String,org.kuali.rice.kns.util.TypedArrayList> errorMap)
          returns a list of all error messages as a string
protected  File getInvoiceFile(String fileName)
           
protected  Map getItemTypeMappings(Integer vendorHeaderId, Integer vendorDetailId)
           
protected  Map<String,ItemType> getKualiItemTypes()
           
protected  org.kuali.rice.kns.bo.PersistableBusinessObject getNoteParent(ElectronicInvoiceRejectDocument document, org.kuali.rice.kns.bo.Note newNote)
           
 ElectronicInvoiceLoadSummary getOrCreateLoadSummary(ElectronicInvoiceLoad eInvoiceLoad, String fileDunsNumber)
           
protected  String getRejectDirName()
           
protected  ElectronicInvoiceRejectReasonType getRejectReasonType(String rejectReasonTypeCode)
           
protected  String getVendorNumber(Integer vendorHeaderId, Integer vendorDetailId)
           
protected  boolean isItemValidForUpdation(String itemTypeCode, String invoiceItemTypeCode, ElectronicInvoiceOrderHolder orderHolder)
           
protected  boolean isNullOrZero(BigDecimal value)
           
protected  boolean isNullOrZero(org.kuali.rice.kns.util.KualiDecimal value)
           
 ElectronicInvoice loadElectronicInvoice(byte[] xmlAsBytes)
           
 ElectronicInvoiceLoad loadElectronicInvoices()
           
protected  void logProcessElectronicInvoiceError(String msg)
           
protected  boolean moveFile(File fileForMove, String location)
           
protected  void moveFileList(Map filesToMove)
           
protected  void populateItemDetails(PaymentRequestDocument preqDocument, ElectronicInvoiceOrderHolder orderHolder)
           
protected  void processAboveTheLineItem(PaymentRequestItem purapItem, ElectronicInvoiceOrderHolder orderHolder)
           
protected  void processDepositItem(PaymentRequestItem preqItem, ElectronicInvoiceOrderHolder orderHolder)
           
protected  void processDiscountItem(PaymentRequestItem preqItem, ElectronicInvoiceOrderHolder orderHolder)
           
protected  void processDueItem(PaymentRequestItem preqItem, ElectronicInvoiceOrderHolder orderHolder)
           
protected  boolean processElectronicInvoice(ElectronicInvoiceLoad eInvoiceLoad, File invoiceFile, byte[] xmlAsBytes)
          This method processes a single electronic invoice file
protected  void processInvoiceItem(PaymentRequestItem preqItem, ElectronicInvoiceOrderHolder orderHolder)
          Finds the mapped item type code to invoice item type code and applies the appropriate values to the correct payment request item.
protected  void processItemsForDiscount(PaymentRequestDocument preqDocument, ElectronicInvoiceOrderHolder orderHolder)
           
protected  void processShippingItem(PaymentRequestItem preqItem, ElectronicInvoiceOrderHolder orderHolder)
           
protected  void processSpecialHandlingItem(PaymentRequestItem purapItem, ElectronicInvoiceOrderHolder orderHolder)
           
protected  void processTaxItem(PaymentRequestItem preqItem, ElectronicInvoiceOrderHolder orderHolder)
           
protected  void rejectElectronicInvoiceFile(ElectronicInvoiceLoad eInvoiceLoad, String fileDunsNumber, File filename, String rejectReasonTypeCode)
           
protected  void rejectElectronicInvoiceFile(ElectronicInvoiceLoad eInvoiceLoad, String fileDunsNumber, File invoiceFile, String extraDescription, String rejectReasonTypeCode)
           
protected  void removeEmptyItems(List<PurApItem> preqItems)
          Removes preq items from the list that have null or zero unit and extended price
protected  void routeRejectDocument(ElectronicInvoiceRejectDocument rejectDoc, Map savedLoadSummariesMap)
           
protected  ElectronicInvoiceLoadSummary saveElectronicInvoiceLoadSummary(ElectronicInvoiceLoadSummary eils)
           
protected  StringBuffer saveLoadSummary(ElectronicInvoiceLoad eInvoiceLoad)
           
protected  void sendSummary(StringBuffer message)
           
 void setBatchInputFileService(BatchInputFileService batchInputFileService)
           
 void setDateTimeService(org.kuali.rice.kns.service.DateTimeService dateTimeService)
           
 void setElectronicInvoiceInputFileType(ElectronicInvoiceInputFileType electronicInvoiceInputFileType)
           
 void setElectronicInvoiceMatchingService(ElectronicInvoiceMatchingService matchingService)
           
 void setElectronicInvoicingDao(ElectronicInvoicingDao electronicInvoicingDao)
           
protected  void setItemDefaultDescription(PaymentRequestItem preqItem)
           
 void setKualiConfigurationService(org.kuali.rice.kns.service.KualiConfigurationService kualiConfigurationService)
           
 void setMailService(org.kuali.rice.kns.service.MailService mailService)
           
protected  org.kuali.rice.kns.mail.MailMessage setMessageToAddressesAndSubject(org.kuali.rice.kns.mail.MailMessage message, List<String> toAddressList)
           
 void setParameterService(org.kuali.rice.kns.service.ParameterService parameterService)
           
 void setPaymentRequestService(PaymentRequestService paymentRequestService)
           
 void setPurchaseOrderService(PurchaseOrderService purchaseOrderService)
           
protected  void setVendorDetails(ElectronicInvoice eInvoice)
           
protected  void setVendorDUNSNumber(ElectronicInvoice eInvoice)
           
 void setVendorService(VendorService vendorService)
           
 void validateInvoiceOrderValidForPREQCreation(ElectronicInvoiceOrderHolder orderHolder)
          This validates an electronic invoice and makes sure it can be turned into a Payment Request
protected  void validateVendorDetails(ElectronicInvoiceRejectDocument rejectDocument)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UNKNOWN_DUNS_IDENTIFIER

protected final String UNKNOWN_DUNS_IDENTIFIER
See Also:
Constant Field Values

INVOICE_FILE_MIME_TYPE

protected final String INVOICE_FILE_MIME_TYPE
See Also:
Constant Field Values

electronicInvoiceInputFileType

protected ElectronicInvoiceInputFileType electronicInvoiceInputFileType

mailService

protected org.kuali.rice.kns.service.MailService mailService

matchingService

protected ElectronicInvoiceMatchingService matchingService

electronicInvoicingDao

protected ElectronicInvoicingDao electronicInvoicingDao

batchInputFileService

protected BatchInputFileService batchInputFileService

vendorService

protected VendorService vendorService

purchaseOrderService

protected PurchaseOrderService purchaseOrderService

paymentRequestService

protected PaymentRequestService paymentRequestService

kualiConfigurationService

protected org.kuali.rice.kns.service.KualiConfigurationService kualiConfigurationService

dateTimeService

protected org.kuali.rice.kns.service.DateTimeService dateTimeService

parameterService

protected org.kuali.rice.kns.service.ParameterService parameterService
Constructor Detail

ElectronicInvoiceHelperServiceImpl

public ElectronicInvoiceHelperServiceImpl()
Method Detail

loadElectronicInvoices

public ElectronicInvoiceLoad loadElectronicInvoices()
Specified by:
loadElectronicInvoices in interface ElectronicInvoiceHelperService

logProcessElectronicInvoiceError

protected void logProcessElectronicInvoiceError(String msg)

addNamespaceDefinition

protected byte[] addNamespaceDefinition(ElectronicInvoiceLoad eInvoiceLoad,
                                        File invoiceFile)

processElectronicInvoice

protected boolean processElectronicInvoice(ElectronicInvoiceLoad eInvoiceLoad,
                                           File invoiceFile,
                                           byte[] xmlAsBytes)
This method processes a single electronic invoice file

Parameters:
eInvoiceLoad - the load summary to be modified
Returns:
boolean where true means there has been some type of reject

setVendorDUNSNumber

protected void setVendorDUNSNumber(ElectronicInvoice eInvoice)

setVendorDetails

protected void setVendorDetails(ElectronicInvoice eInvoice)

validateVendorDetails

protected void validateVendorDetails(ElectronicInvoiceRejectDocument rejectDocument)

getItemTypeMappings

protected Map getItemTypeMappings(Integer vendorHeaderId,
                                  Integer vendorDetailId)

getVendorNumber

protected String getVendorNumber(Integer vendorHeaderId,
                                 Integer vendorDetailId)

getKualiItemTypes

protected Map<String,ItemType> getKualiItemTypes()

checkForCompleteFailure

protected boolean checkForCompleteFailure(ElectronicInvoiceLoad electronicInvoiceLoad,
                                          ElectronicInvoice electronicInvoice,
                                          File invoiceFile)

getRejectReasonType

protected ElectronicInvoiceRejectReasonType getRejectReasonType(String rejectReasonTypeCode)

rejectElectronicInvoiceFile

protected void rejectElectronicInvoiceFile(ElectronicInvoiceLoad eInvoiceLoad,
                                           String fileDunsNumber,
                                           File filename,
                                           String rejectReasonTypeCode)

rejectElectronicInvoiceFile

protected void rejectElectronicInvoiceFile(ElectronicInvoiceLoad eInvoiceLoad,
                                           String fileDunsNumber,
                                           File invoiceFile,
                                           String extraDescription,
                                           String rejectReasonTypeCode)

attachInvoiceXMLWithRejectDoc

protected void attachInvoiceXMLWithRejectDoc(ElectronicInvoiceRejectDocument eInvoiceRejectDocument,
                                             File attachmentFile,
                                             String noteText)

getNoteParent

protected org.kuali.rice.kns.bo.PersistableBusinessObject getNoteParent(ElectronicInvoiceRejectDocument document,
                                                                        org.kuali.rice.kns.bo.Note newNote)

createRejectDocument

public ElectronicInvoiceRejectDocument createRejectDocument(ElectronicInvoice eInvoice,
                                                            ElectronicInvoiceOrder electronicInvoiceOrder,
                                                            ElectronicInvoiceLoad eInvoiceLoad)

addRejectReasonsToNote

protected void addRejectReasonsToNote(String rejectReasons,
                                      ElectronicInvoiceRejectDocument eInvoiceRejectDocument)

generateRejectDocumentDescription

protected String generateRejectDocumentDescription(ElectronicInvoice eInvoice,
                                                   ElectronicInvoiceOrder electronicInvoiceOrder)

generateRejectDocumentDescription

protected String generateRejectDocumentDescription(ElectronicInvoiceRejectDocument rejectDoc)

checkDescriptionLengthAndStripIfNeeded

protected String checkDescriptionLengthAndStripIfNeeded(String description)

getOrCreateLoadSummary

public ElectronicInvoiceLoadSummary getOrCreateLoadSummary(ElectronicInvoiceLoad eInvoiceLoad,
                                                           String fileDunsNumber)

loadElectronicInvoice

public ElectronicInvoice loadElectronicInvoice(byte[] xmlAsBytes)
                                        throws CxmlParseException
Throws:
CxmlParseException

saveLoadSummary

protected StringBuffer saveLoadSummary(ElectronicInvoiceLoad eInvoiceLoad)

routeRejectDocument

protected void routeRejectDocument(ElectronicInvoiceRejectDocument rejectDoc,
                                   Map savedLoadSummariesMap)

sendSummary

protected void sendSummary(StringBuffer message)

setMessageToAddressesAndSubject

protected org.kuali.rice.kns.mail.MailMessage setMessageToAddressesAndSubject(org.kuali.rice.kns.mail.MailMessage message,
                                                                              List<String> toAddressList)

doMatchingProcess

public boolean doMatchingProcess(ElectronicInvoiceRejectDocument rejectDocument)
This method is responsible for the matching process for a reject document

Specified by:
doMatchingProcess in interface ElectronicInvoiceHelperService
Returns:
true if the matching process is succeed

createPaymentRequest

public boolean createPaymentRequest(ElectronicInvoiceRejectDocument rejectDocument)
Specified by:
createPaymentRequest in interface ElectronicInvoiceHelperService

createPaymentRequest

protected PaymentRequestDocument createPaymentRequest(ElectronicInvoiceOrderHolder orderHolder)

addShipToNotes

protected void addShipToNotes(PaymentRequestDocument preqDoc,
                              ElectronicInvoiceOrderHolder orderHolder)

processItemsForDiscount

protected void processItemsForDiscount(PaymentRequestDocument preqDocument,
                                       ElectronicInvoiceOrderHolder orderHolder)

populateItemDetails

protected void populateItemDetails(PaymentRequestDocument preqDocument,
                                   ElectronicInvoiceOrderHolder orderHolder)

removeEmptyItems

protected void removeEmptyItems(List<PurApItem> preqItems)
Removes preq items from the list that have null or zero unit and extended price

Parameters:
preqItems -

addMissingMappedItems

protected void addMissingMappedItems(List<PurApItem> preqItems,
                                     ElectronicInvoiceOrderHolder orderHolder)
Ensures that the mapped items, item type code, exist as a payment request item so they're process correctly within populateItemDetails

Parameters:
preqItems -
orderHolder -

createInvoiceRequiresItemTypeCodeList

protected List createInvoiceRequiresItemTypeCodeList(ElectronicInvoiceOrderHolder orderHolder)
Creates a list of item types the eInvoice requirs on the payment request due to valid amounts.


addToListIfExists

protected void addToListIfExists(List itemTypeCodeList,
                                 String invoiceItemTypeCode,
                                 ElectronicInvoiceOrderHolder orderHolder)
Utility method to add a kuali item type code to a list from a invoice item type code

Parameters:
itemTypeCodeList -
invoiceItemTypeCode -
orderHolder -

processInvoiceItem

protected void processInvoiceItem(PaymentRequestItem preqItem,
                                  ElectronicInvoiceOrderHolder orderHolder)
Finds the mapped item type code to invoice item type code and applies the appropriate values to the correct payment request item.

Parameters:
preqItem -
orderHolder -

processAboveTheLineItem

protected void processAboveTheLineItem(PaymentRequestItem purapItem,
                                       ElectronicInvoiceOrderHolder orderHolder)

processSpecialHandlingItem

protected void processSpecialHandlingItem(PaymentRequestItem purapItem,
                                          ElectronicInvoiceOrderHolder orderHolder)

processTaxItem

protected void processTaxItem(PaymentRequestItem preqItem,
                              ElectronicInvoiceOrderHolder orderHolder)

processShippingItem

protected void processShippingItem(PaymentRequestItem preqItem,
                                   ElectronicInvoiceOrderHolder orderHolder)

processDiscountItem

protected void processDiscountItem(PaymentRequestItem preqItem,
                                   ElectronicInvoiceOrderHolder orderHolder)

processDepositItem

protected void processDepositItem(PaymentRequestItem preqItem,
                                  ElectronicInvoiceOrderHolder orderHolder)

processDueItem

protected void processDueItem(PaymentRequestItem preqItem,
                              ElectronicInvoiceOrderHolder orderHolder)

isNullOrZero

protected boolean isNullOrZero(BigDecimal value)

isNullOrZero

protected boolean isNullOrZero(org.kuali.rice.kns.util.KualiDecimal value)

setItemDefaultDescription

protected void setItemDefaultDescription(PaymentRequestItem preqItem)

isItemValidForUpdation

protected boolean isItemValidForUpdation(String itemTypeCode,
                                         String invoiceItemTypeCode,
                                         ElectronicInvoiceOrderHolder orderHolder)

generatePREQDocumentDescription

protected String generatePREQDocumentDescription(PurchaseOrderDocument poDocument)

validateInvoiceOrderValidForPREQCreation

public void validateInvoiceOrderValidForPREQCreation(ElectronicInvoiceOrderHolder orderHolder)
This validates an electronic invoice and makes sure it can be turned into a Payment Request


moveFileList

protected void moveFileList(Map filesToMove)

moveFile

protected boolean moveFile(File fileForMove,
                           String location)

deleteDoneFile

protected void deleteDoneFile(File invoiceFile)

getErrorMessages

protected String getErrorMessages(Map<String,org.kuali.rice.kns.util.TypedArrayList> errorMap)
returns a list of all error messages as a string

Parameters:
errorMap -
Returns:

getBaseDirName

protected String getBaseDirName()

getRejectDirName

protected String getRejectDirName()

getAcceptDirName

protected String getAcceptDirName()

getInvoiceFile

protected File getInvoiceFile(String fileName)

saveElectronicInvoiceLoadSummary

protected ElectronicInvoiceLoadSummary saveElectronicInvoiceLoadSummary(ElectronicInvoiceLoadSummary eils)

setElectronicInvoiceInputFileType

public void setElectronicInvoiceInputFileType(ElectronicInvoiceInputFileType electronicInvoiceInputFileType)

setMailService

public void setMailService(org.kuali.rice.kns.service.MailService mailService)

setElectronicInvoicingDao

public void setElectronicInvoicingDao(ElectronicInvoicingDao electronicInvoicingDao)

setBatchInputFileService

public void setBatchInputFileService(BatchInputFileService batchInputFileService)

setElectronicInvoiceMatchingService

public void setElectronicInvoiceMatchingService(ElectronicInvoiceMatchingService matchingService)

setVendorService

public void setVendorService(VendorService vendorService)

setPurchaseOrderService

public void setPurchaseOrderService(PurchaseOrderService purchaseOrderService)

setPaymentRequestService

public void setPaymentRequestService(PaymentRequestService paymentRequestService)

setKualiConfigurationService

public void setKualiConfigurationService(org.kuali.rice.kns.service.KualiConfigurationService kualiConfigurationService)

setDateTimeService

public void setDateTimeService(org.kuali.rice.kns.service.DateTimeService dateTimeService)

setParameterService

public void setParameterService(org.kuali.rice.kns.service.ParameterService parameterService)


Copyright © 2005-2012 The Kuali Foundation. All Rights Reserved.