org.kuali.kfs.module.purap.document.service.impl
Class CreditMemoServiceImpl

java.lang.Object
  extended by org.kuali.kfs.module.purap.document.service.impl.CreditMemoServiceImpl
All Implemented Interfaces:
AccountsPayableDocumentSpecificService, CreditMemoService

@Transactional
public class CreditMemoServiceImpl
extends Object
implements CreditMemoService

Provides services to support the creation of a Credit Memo Document.


Constructor Summary
CreditMemoServiceImpl()
           
 
Method Summary
 VendorCreditMemoDocument addHoldOnCreditMemo(VendorCreditMemoDocument cmDocument, String note)
          Marks a credit memo as on hold.
 void calculateCreditMemo(VendorCreditMemoDocument cmDocument)
          Performs the credit memo item extended price calculation.
 void cancelExtractedCreditMemo(VendorCreditMemoDocument cmDocument, String note)
          This is called by PDP to cancel a CreditMemoDocument that has already been extracted
 String creditMemoDuplicateMessages(VendorCreditMemoDocument cmDocument)
          Makes call to dao to check for duplicate credit memos, and if one is found a message is returned.
 void generateGLEntriesCreateAccountsPayableDocument(AccountsPayableDocument apDocument)
          The given document here needs to be a Credit Memo.
 VendorCreditMemoDocument getCreditMemoByDocumentNumber(String documentNumber)
          Get a credit memo by document number.
 VendorCreditMemoDocument getCreditMemoDocumentById(Integer purchasingDocumentIdentifier)
          Retrieves the Credit Memo document by the purapDocumentIdentifier.
 Iterator<VendorCreditMemoDocument> getCreditMemosToExtract(String chartCode)
          Gets the Credit memos that can be extracted.
 Collection<VendorCreditMemoDocument> getCreditMemosToExtractByVendor(String chartCode, VendorGroupingHelper vendor)
          Pulls all extractable credit memo documents for a given vendor.
 org.kuali.rice.kim.bo.Person getPersonForCancel(AccountsPayableDocument apDoc)
           
 List<PurchaseOrderItem> getPOInvoicedItems(PurchaseOrderDocument poDocument)
          Iterates through the items of the purchase order document and checks for items that have been invoiced.
 Set<VendorGroupingHelper> getVendorsOnCreditMemosToExtract(String chartCode)
          Pulls a distinct list of all vendors on CM documents which are ready for extraction.
 boolean hasActiveCreditMemosForPurchaseOrder(Integer purchaseOrderIdentifier)
          Determines if there are active credit memos for a purchase order.
protected  void logAndThrowRuntimeException(String errorMessage)
          Records the specified error message into the Log file and throws a runtime exception.
protected  void logAndThrowRuntimeException(String errorMessage, Exception e)
          Records the specified error message into the Log file and throws the specified runtime exception.
 void markPaid(VendorCreditMemoDocument cm, Date processDate)
          Mark a credit memo is being used on a payment
 boolean poItemEligibleForAp(AccountsPayableDocument apDoc, PurchaseOrderItem poItem)
           
 void populateAndSaveCreditMemo(VendorCreditMemoDocument document)
          Persists the credit memo with business rule checks.
 void populateDocumentAfterInit(VendorCreditMemoDocument cmDocument)
          Populates the document from either the associated payment request document, purchase order document, or vendor detail based on the credit memo type.
protected  void populateDocumentDescription(VendorCreditMemoDocument cmDocument)
          Defaults the document description based on the credit memo source type.
protected  void populateDocumentFromPO(VendorCreditMemoDocument cmDocument, HashMap<String,ExpiredOrClosedAccountEntry> expiredOrClosedAccountList)
          Populate Credit Memo of type Purchase Order.
protected  void populateDocumentFromPreq(VendorCreditMemoDocument cmDocument, HashMap<String,ExpiredOrClosedAccountEntry> expiredOrClosedAccountList)
          Populate Credit Memo of type Payment Request.
protected  void populateDocumentFromVendor(VendorCreditMemoDocument cmDocument)
          Populate Credit Memo of type Vendor.
protected  void populateItemLinesFromPO(VendorCreditMemoDocument cmDocument, HashMap<String,ExpiredOrClosedAccountEntry> expiredOrClosedAccountList)
          Populates the credit memo items from the payment request items.
protected  void populateItemLinesFromPreq(VendorCreditMemoDocument cmDocument, HashMap<String,ExpiredOrClosedAccountEntry> expiredOrClosedAccountList)
          Populates the credit memo items from the payment request items.
 VendorCreditMemoDocument removeHoldOnCreditMemo(VendorCreditMemoDocument cmDocument, String note)
          Removes a hold on the credit memo document.
 void reopenClosedPO(VendorCreditMemoDocument cmDocument)
          Reopens the purchase order document related to the given credit memo document if it is closed.
 void resetExtractedCreditMemo(VendorCreditMemoDocument cmDocument, String note)
          This is called by PDP to cancel a CreditMemoDocument that has already been extracted
 void setAccountsPayableService(AccountsPayableService accountsPayableService)
           
 void setCreditMemoDao(CreditMemoDao creditMemoDao)
           
 void setDataDictionaryService(org.kuali.rice.kns.service.DataDictionaryService dataDictionaryService)
           
 void setDocumentService(org.kuali.rice.kns.service.DocumentService documentService)
           
 void setKualiConfigurationService(org.kuali.rice.kns.service.KualiConfigurationService kualiConfigurationService)
           
 void setNoteService(org.kuali.rice.kns.service.NoteService noteService)
           
 void setPaymentRequestService(PaymentRequestService paymentRequestService)
           
 void setPurapAccountingService(PurapAccountingService purapAccountingService)
           
 void setPurapGeneralLedgerService(PurapGeneralLedgerService purapGeneralLedgerService)
           
 void setPurapService(PurapService purapService)
           
 void setPurchaseOrderService(PurchaseOrderService purchaseOrderService)
           
 void setVendorService(VendorService vendorService)
           
 void setWorkflowDocumentService(org.kuali.rice.kns.workflow.service.WorkflowDocumentService workflowDocumentService)
           
 boolean shouldPurchaseOrderBeReversed(AccountsPayableDocument apDoc)
           
 void takePurchaseOrderCancelAction(AccountsPayableDocument apDoc)
           
 String updateStatusByNode(String currentNodeName, AccountsPayableDocument apDoc)
           
protected  String updateStatusByNode(String currentNodeName, VendorCreditMemoDocument cmDoc)
          Updates the status of a credit memo document, currently this is used by the cancel action
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CreditMemoServiceImpl

public CreditMemoServiceImpl()
Method Detail

setAccountsPayableService

public void setAccountsPayableService(AccountsPayableService accountsPayableService)

setCreditMemoDao

public void setCreditMemoDao(CreditMemoDao creditMemoDao)

setDataDictionaryService

public void setDataDictionaryService(org.kuali.rice.kns.service.DataDictionaryService dataDictionaryService)

setDocumentService

public void setDocumentService(org.kuali.rice.kns.service.DocumentService documentService)

setKualiConfigurationService

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

setNoteService

public void setNoteService(org.kuali.rice.kns.service.NoteService noteService)

setPaymentRequestService

public void setPaymentRequestService(PaymentRequestService paymentRequestService)

setPurapAccountingService

public void setPurapAccountingService(PurapAccountingService purapAccountingService)

setPurapGeneralLedgerService

public void setPurapGeneralLedgerService(PurapGeneralLedgerService purapGeneralLedgerService)

setPurapService

public void setPurapService(PurapService purapService)

setPurchaseOrderService

public void setPurchaseOrderService(PurchaseOrderService purchaseOrderService)

setVendorService

public void setVendorService(VendorService vendorService)

setWorkflowDocumentService

public void setWorkflowDocumentService(org.kuali.rice.kns.workflow.service.WorkflowDocumentService workflowDocumentService)

getCreditMemosToExtract

public Iterator<VendorCreditMemoDocument> getCreditMemosToExtract(String chartCode)
Description copied from interface: CreditMemoService
Gets the Credit memos that can be extracted.

Specified by:
getCreditMemosToExtract in interface CreditMemoService
Parameters:
chartCode - Chart to select from.
Returns:
Iterator of credit memos.
See Also:
CreditMemoService.getCreditMemosToExtract(java.lang.String)

getCreditMemosToExtractByVendor

public Collection<VendorCreditMemoDocument> getCreditMemosToExtractByVendor(String chartCode,
                                                                            VendorGroupingHelper vendor)
Description copied from interface: CreditMemoService
Pulls all extractable credit memo documents for a given vendor.

Specified by:
getCreditMemosToExtractByVendor in interface CreditMemoService
Returns:

getVendorsOnCreditMemosToExtract

public Set<VendorGroupingHelper> getVendorsOnCreditMemosToExtract(String chartCode)
Description copied from interface: CreditMemoService
Pulls a distinct list of all vendors on CM documents which are ready for extraction.

Specified by:
getVendorsOnCreditMemosToExtract in interface CreditMemoService
Returns:

creditMemoDuplicateMessages

public String creditMemoDuplicateMessages(VendorCreditMemoDocument cmDocument)
Description copied from interface: CreditMemoService
Makes call to dao to check for duplicate credit memos, and if one is found a message is returned. A duplicate error happens if there is an existing credit memo with the same vendor number and credit memo number as the one which is being created, or same vendor number and credit memo date.

Specified by:
creditMemoDuplicateMessages in interface CreditMemoService
Parameters:
cmDocument - - CreditMemoDocument to run duplicate check on.
Returns:
String - message indicating a duplicate was found.
See Also:
org.kuali.kfs.module.purap.document.service.CreditMemoService#creditMemoDuplicateMessages(org.kuali.kfs.module.purap.document.CreditMemoDocument)

getPOInvoicedItems

public List<PurchaseOrderItem> getPOInvoicedItems(PurchaseOrderDocument poDocument)
Description copied from interface: CreditMemoService
Iterates through the items of the purchase order document and checks for items that have been invoiced.

Specified by:
getPOInvoicedItems in interface CreditMemoService
Parameters:
poDocument - - purchase order document containing the lines to check.
Returns:
List - list of invoiced items found.
See Also:
CreditMemoService.getPOInvoicedItems(org.kuali.kfs.module.purap.document.PurchaseOrderDocument)

calculateCreditMemo

public void calculateCreditMemo(VendorCreditMemoDocument cmDocument)
Description copied from interface: CreditMemoService
Performs the credit memo item extended price calculation.

Specified by:
calculateCreditMemo in interface CreditMemoService
Parameters:
cmDocument - - credit memo document to calculate.
See Also:
org.kuali.kfs.module.purap.document.service.CreditMemoService#calculateCreditMemo(org.kuali.kfs.module.purap.document.CreditMemoDocument)

getCreditMemoByDocumentNumber

public VendorCreditMemoDocument getCreditMemoByDocumentNumber(String documentNumber)
Description copied from interface: CreditMemoService
Get a credit memo by document number.

Specified by:
getCreditMemoByDocumentNumber in interface CreditMemoService
Parameters:
documentNumber - The document number of the credit memo to be retrieved.
Returns:
The credit memo document whose document number matches the input parameter.
See Also:
CreditMemoService.getCreditMemoByDocumentNumber(java.lang.String)

getCreditMemoDocumentById

public VendorCreditMemoDocument getCreditMemoDocumentById(Integer purchasingDocumentIdentifier)
Description copied from interface: CreditMemoService
Retrieves the Credit Memo document by the purapDocumentIdentifier.

Specified by:
getCreditMemoDocumentById in interface CreditMemoService
Parameters:
purchasingDocumentIdentifier - The purapDocumentIdentifier of the credit memo to be retrieved.
Returns:
The credit memo document whose purapDocumentIdentifier matches the input parameter.
See Also:
CreditMemoService.getCreditMemoDocumentById(java.lang.Integer)

populateAndSaveCreditMemo

public void populateAndSaveCreditMemo(VendorCreditMemoDocument document)
Description copied from interface: CreditMemoService
Persists the credit memo with business rule checks.

Specified by:
populateAndSaveCreditMemo in interface CreditMemoService
Parameters:
document - - credit memo document to save.
See Also:
org.kuali.kfs.module.purap.document.service.CreditMemoService#saveDocument(org.kuali.kfs.module.purap.document.CreditMemoDocument)

reopenClosedPO

public void reopenClosedPO(VendorCreditMemoDocument cmDocument)
Description copied from interface: CreditMemoService
Reopens the purchase order document related to the given credit memo document if it is closed.

Specified by:
reopenClosedPO in interface CreditMemoService
Parameters:
cmDocument - The credit memo document to be used to obtained the purchase order document to be closed.
See Also:
org.kuali.kfs.module.purap.document.service.CreditMemoService#reopenClosedPO(org.kuali.kfs.module.purap.document.CreditMemoDocument)

addHoldOnCreditMemo

public VendorCreditMemoDocument addHoldOnCreditMemo(VendorCreditMemoDocument cmDocument,
                                                    String note)
                                             throws Exception
Description copied from interface: CreditMemoService
Marks a credit memo as on hold.

Specified by:
addHoldOnCreditMemo in interface CreditMemoService
Parameters:
cmDocument - - credit memo document to hold.
note - - note explaining why the document is being put on hold.
Returns:
the CreditMemoDocument with updated information.
Throws:
Exception
See Also:
org.kuali.kfs.module.purap.document.service.CreditMemoService#addHoldOnPaymentRequest(org.kuali.kfs.module.purap.document.CreditMemoDocument, java.lang.String)

removeHoldOnCreditMemo

public VendorCreditMemoDocument removeHoldOnCreditMemo(VendorCreditMemoDocument cmDocument,
                                                       String note)
                                                throws Exception
Description copied from interface: CreditMemoService
Removes a hold on the credit memo document.

Specified by:
removeHoldOnCreditMemo in interface CreditMemoService
Parameters:
cmDocument - - credit memo document to remove hold on.
note - - note explaining why the credit memo is being taken off hold.
Returns:
the CreditMemoDocument with updated information.
Throws:
Exception
See Also:
org.kuali.kfs.module.purap.document.service.CreditMemoService#removeHoldOnCreditMemo(org.kuali.kfs.module.purap.document.CreditMemoDocument, java.lang.String)

updateStatusByNode

public String updateStatusByNode(String currentNodeName,
                                 AccountsPayableDocument apDoc)
Specified by:
updateStatusByNode in interface AccountsPayableDocumentSpecificService
See Also:
AccountsPayableDocumentSpecificService.updateStatusByNode(java.lang.String, org.kuali.kfs.module.purap.document.AccountsPayableDocument)

updateStatusByNode

protected String updateStatusByNode(String currentNodeName,
                                    VendorCreditMemoDocument cmDoc)
Updates the status of a credit memo document, currently this is used by the cancel action

Parameters:
currentNodeName - The string representing the current node to be used to obtain the canceled status code.
cmDoc - The credit memo document to be updated.
Returns:
The string representing the canceledStatusCode, if empty it is assumed to be not from workflow.

cancelExtractedCreditMemo

public void cancelExtractedCreditMemo(VendorCreditMemoDocument cmDocument,
                                      String note)
Description copied from interface: CreditMemoService
This is called by PDP to cancel a CreditMemoDocument that has already been extracted

Specified by:
cancelExtractedCreditMemo in interface CreditMemoService
Parameters:
cmDocument - The credit memo document to be canceled.
note - The note to be added to the document to be canceled.
See Also:
org.kuali.kfs.module.purap.document.service.CreditMemoService#cancelExtractedCreditMemo(org.kuali.kfs.module.purap.document.CreditMemoDocument, java.lang.String)

resetExtractedCreditMemo

public void resetExtractedCreditMemo(VendorCreditMemoDocument cmDocument,
                                     String note)
Description copied from interface: CreditMemoService
This is called by PDP to cancel a CreditMemoDocument that has already been extracted

Specified by:
resetExtractedCreditMemo in interface CreditMemoService
Parameters:
cmDocument - The credit memo document to be resetted.
note - The note to be added to the credit memo document.
See Also:
org.kuali.kfs.module.purap.document.service.CreditMemoService#resetExtractedCreditMemo(org.kuali.kfs.module.purap.document.CreditMemoDocument, java.lang.String)

shouldPurchaseOrderBeReversed

public boolean shouldPurchaseOrderBeReversed(AccountsPayableDocument apDoc)
Specified by:
shouldPurchaseOrderBeReversed in interface AccountsPayableDocumentSpecificService
See Also:
AccountsPayableDocumentSpecificService.shouldPurchaseOrderBeReversed(org.kuali.kfs.module.purap.document.AccountsPayableDocument)

getPersonForCancel

public org.kuali.rice.kim.bo.Person getPersonForCancel(AccountsPayableDocument apDoc)
Specified by:
getPersonForCancel in interface AccountsPayableDocumentSpecificService
See Also:
AccountsPayableDocumentSpecificService.getPersonForCancel(org.kuali.kfs.module.purap.document.AccountsPayableDocument)

takePurchaseOrderCancelAction

public void takePurchaseOrderCancelAction(AccountsPayableDocument apDoc)
Specified by:
takePurchaseOrderCancelAction in interface AccountsPayableDocumentSpecificService
See Also:
AccountsPayableDocumentSpecificService.takePurchaseOrderCancelAction(org.kuali.kfs.module.purap.document.AccountsPayableDocument)

markPaid

public void markPaid(VendorCreditMemoDocument cm,
                     Date processDate)
Description copied from interface: CreditMemoService
Mark a credit memo is being used on a payment

Specified by:
markPaid in interface CreditMemoService
Parameters:
cm - The credit memo document to be marked as paid.
processDate - The date to be set as the credit memo's paid timestamp.
See Also:
org.kuali.kfs.module.purap.document.service.CreditMemoService#markPaid(org.kuali.kfs.module.purap.document.CreditMemoDocument, java.sql.Date)

poItemEligibleForAp

public boolean poItemEligibleForAp(AccountsPayableDocument apDoc,
                                   PurchaseOrderItem poItem)
Specified by:
poItemEligibleForAp in interface AccountsPayableDocumentSpecificService
See Also:
AccountsPayableDocumentSpecificService.poItemEligibleForAp(org.kuali.kfs.module.purap.document.AccountsPayableDocument, org.kuali.kfs.module.purap.businessobject.PurchaseOrderItem)

generateGLEntriesCreateAccountsPayableDocument

public void generateGLEntriesCreateAccountsPayableDocument(AccountsPayableDocument apDocument)
The given document here needs to be a Credit Memo.

Specified by:
generateGLEntriesCreateAccountsPayableDocument in interface AccountsPayableDocumentSpecificService
Parameters:
apDocument - An AccountsPayableDocument
See Also:
AccountsPayableDocumentSpecificService.generateGLEntriesCreateAccountsPayableDocument(org.kuali.kfs.module.purap.document.AccountsPayableDocument)

logAndThrowRuntimeException

protected void logAndThrowRuntimeException(String errorMessage)
Records the specified error message into the Log file and throws a runtime exception.

Parameters:
errorMessage - the error message to be logged.

logAndThrowRuntimeException

protected void logAndThrowRuntimeException(String errorMessage,
                                           Exception e)
Records the specified error message into the Log file and throws the specified runtime exception.

Parameters:
errorMessage - the specified error message.
e - the specified runtime exception.

hasActiveCreditMemosForPurchaseOrder

public boolean hasActiveCreditMemosForPurchaseOrder(Integer purchaseOrderIdentifier)
Description copied from interface: CreditMemoService
Determines if there are active credit memos for a purchase order.

Specified by:
hasActiveCreditMemosForPurchaseOrder in interface CreditMemoService
Returns:
See Also:
CreditMemoService.hasActiveCreditMemosForPurchaseOrder(java.lang.Integer)

populateDocumentAfterInit

public void populateDocumentAfterInit(VendorCreditMemoDocument cmDocument)
Description copied from interface: CreditMemoService
Populates the document from either the associated payment request document, purchase order document, or vendor detail based on the credit memo type.

Specified by:
populateDocumentAfterInit in interface CreditMemoService
Parameters:
cmDocument - - Credit Memo Document to Populate
See Also:
org.kuali.kfs.module.purap.document.service.CreditMemoCreateService#populateDocumentAfterInit(org.kuali.kfs.module.purap.document.CreditMemoDocument)

populateDocumentFromPreq

protected void populateDocumentFromPreq(VendorCreditMemoDocument cmDocument,
                                        HashMap<String,ExpiredOrClosedAccountEntry> expiredOrClosedAccountList)
Populate Credit Memo of type Payment Request.

Parameters:
cmDocument - - Credit Memo Document to Populate

populateItemLinesFromPreq

protected void populateItemLinesFromPreq(VendorCreditMemoDocument cmDocument,
                                         HashMap<String,ExpiredOrClosedAccountEntry> expiredOrClosedAccountList)
Populates the credit memo items from the payment request items.

Parameters:
cmDocument - - Credit Memo Document to Populate

populateDocumentFromPO

protected void populateDocumentFromPO(VendorCreditMemoDocument cmDocument,
                                      HashMap<String,ExpiredOrClosedAccountEntry> expiredOrClosedAccountList)
Populate Credit Memo of type Purchase Order.

Parameters:
cmDocument - - Credit Memo Document to Populate

populateItemLinesFromPO

protected void populateItemLinesFromPO(VendorCreditMemoDocument cmDocument,
                                       HashMap<String,ExpiredOrClosedAccountEntry> expiredOrClosedAccountList)
Populates the credit memo items from the payment request items.

Parameters:
cmDocument - - Credit Memo Document to Populate

populateDocumentFromVendor

protected void populateDocumentFromVendor(VendorCreditMemoDocument cmDocument)
Populate Credit Memo of type Vendor.

Parameters:
cmDocument - - Credit Memo Document to Populate

populateDocumentDescription

protected void populateDocumentDescription(VendorCreditMemoDocument cmDocument)
Defaults the document description based on the credit memo source type.

Parameters:
cmDocument - - Credit Memo Document to Populate


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