Search in sources :

Example 1 with CuElectronicInvoiceRejectDocument

use of edu.cornell.kfs.module.purap.document.CuElectronicInvoiceRejectDocument in project cu-kfs by CU-CommunityApps.

the class CuElectronicInvoiceHelperServiceImpl method doMatchingProcess.

// end KFSUPGRADE-484
// KFSUPGRADE-485
@Override
public boolean doMatchingProcess(ElectronicInvoiceRejectDocument rejectDocument) {
    /*
         * This is needed here since if the user changes the DUNS number.
         */
    validateVendorDetails(rejectDocument);
    Map itemTypeMappings = getItemTypeMappings(rejectDocument.getVendorHeaderGeneratedIdentifier(), rejectDocument.getVendorDetailAssignedIdentifier());
    Map kualiItemTypes = getKualiItemTypes();
    CuElectronicInvoiceOrderHolder rejectDocHolder = new CuElectronicInvoiceOrderHolder(rejectDocument, itemTypeMappings, kualiItemTypes);
    matchingService.doMatchingProcess(rejectDocHolder);
    // KFSPTS-1719 : save the nomatchingitems found during match process.
    ((CuElectronicInvoiceRejectDocument) rejectDocument).setNonMatchItems(((CuElectronicInvoiceOrderHolder) rejectDocHolder).getNonMatchItems());
    /*
         * Once we're through with the matching process, it's needed to check whether it's possible
         * to create PREQ for the reject doc
         */
    if (!rejectDocHolder.isInvoiceRejected()) {
        validateInvoiceOrderValidForPREQCreation(rejectDocHolder);
    }
    // determine which of the reject reasons we should suppress based on the parameter
    List<String> ignoreRejectTypes = new ArrayList<String>(parameterService.getParameterValuesAsString(PurapConstants.PURAP_NAMESPACE, "ElectronicInvoiceReject", "SUPPRESS_REJECT_REASON_CODES_ON_EIRT_APPROVAL"));
    List<ElectronicInvoiceRejectReason> rejectReasonsToDelete = new ArrayList<ElectronicInvoiceRejectReason>();
    for (ElectronicInvoiceRejectReason rejectReason : rejectDocument.getInvoiceRejectReasons()) {
        String rejectedReasonTypeCode = rejectReason.getInvoiceRejectReasonTypeCode();
        if (StringUtils.isNotBlank(rejectedReasonTypeCode)) {
            if (ignoreRejectTypes.contains(rejectedReasonTypeCode)) {
                rejectReasonsToDelete.add(rejectReason);
            }
        }
    }
    // remove the flagged reject reasons
    if (!rejectReasonsToDelete.isEmpty()) {
        rejectDocument.getInvoiceRejectReasons().removeAll(rejectReasonsToDelete);
    }
    // if no reject reasons, then clear error messages
    if (rejectDocument.getInvoiceRejectReasons().isEmpty()) {
        clearErrorMessagesToPreventSaveAndRouteErrors();
    }
    // this automatically returns false if there are no reject reasons
    return !rejectDocHolder.isInvoiceRejected();
}
Also used : ArrayList(java.util.ArrayList) CuElectronicInvoiceRejectDocument(edu.cornell.kfs.module.purap.document.CuElectronicInvoiceRejectDocument) ElectronicInvoiceRejectReason(org.kuali.kfs.module.purap.businessobject.ElectronicInvoiceRejectReason) Map(java.util.Map) HashMap(java.util.HashMap) NamedNodeMap(org.w3c.dom.NamedNodeMap)

Aggregations

CuElectronicInvoiceRejectDocument (edu.cornell.kfs.module.purap.document.CuElectronicInvoiceRejectDocument)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 ElectronicInvoiceRejectReason (org.kuali.kfs.module.purap.businessobject.ElectronicInvoiceRejectReason)1 NamedNodeMap (org.w3c.dom.NamedNodeMap)1