Search in sources :

Example 11 with ElectronicInvoiceRejectReason

use of org.kuali.kfs.module.purap.businessobject.ElectronicInvoiceRejectReason in project cu-kfs by CU-CommunityApps.

the class CuElectronicInvoiceMatchingServiceImpl method validateNonQtyBasedItem.

protected void validateNonQtyBasedItem(ElectronicInvoiceItemHolder itemHolder) {
    PurchaseOrderItem poItem = itemHolder.getPurchaseOrderItem();
    String fileName = itemHolder.getInvoiceOrderHolder().getFileName();
    ElectronicInvoiceOrderHolder orderHolder = itemHolder.getInvoiceOrderHolder();
    // Only validation is that the invoice amount (amount of PayReq) can not be greater than the extended cost minus amount paid
    if (itemHolder.getInvoiceItemSubTotalAmount().setScale(KualiDecimal.SCALE, KualiDecimal.ROUND_BEHAVIOR).compareTo(poItem.getExtendedPrice().subtract(poItem.getItemInvoicedTotalAmount()).bigDecimalValue()) > 0) {
        String extraDescription = "Invoice Item Line Number:" + itemHolder.getInvoiceItemLineNumber();
        ElectronicInvoiceRejectReason rejectReason = createRejectReason(PurapConstants.ElectronicInvoice.PO_ITEM_AMT_LESSTHAN_INVOICE_ITEM_AMT, extraDescription, orderHolder.getFileName());
        orderHolder.addInvoiceOrderRejectReason(rejectReason, PurapConstants.ElectronicInvoice.RejectDocumentFields.INVOICE_ITEM_LINE_NUMBER, PurapKeyConstants.ERROR_REJECT_POITEM_LESS_OUTSTANDING_EMCUMBERED_AMOUNT);
        return;
    }
    if ((KualiDecimal.ZERO.compareTo(poItem.getItemOutstandingEncumberedAmount())) >= 0) {
        // we have no dollars left encumbered on the po item
        String extraDescription = "Invoice Item Line Number:" + itemHolder.getInvoiceItemLineNumber();
        ElectronicInvoiceRejectReason rejectReason = createRejectReason(PurapConstants.ElectronicInvoice.OUTSTANDING_ENCUMBERED_AMT_AVAILABLE, extraDescription, orderHolder.getFileName());
        orderHolder.addInvoiceOrderRejectReason(rejectReason, PurapConstants.ElectronicInvoice.RejectDocumentFields.INVOICE_ITEM_LINE_NUMBER, PurapKeyConstants.ERROR_REJECT_POITEM_OUTSTANDING_EMCUMBERED_AMOUNT);
        return;
    } else {
        // KFSUPGRADE-485
        if (((itemHolder.getInvoiceItemSubTotalAmount().setScale(KualiDecimal.SCALE, KualiDecimal.ROUND_BEHAVIOR)).compareTo(poItem.getItemOutstandingEncumberedAmount().bigDecimalValue())) > 0 || ((getItemTotalAmount(itemHolder).setScale(KualiDecimal.SCALE, KualiDecimal.ROUND_BEHAVIOR)).compareTo(poItem.getItemOutstandingEncumberedAmount().bigDecimalValue())) > 0) {
            String extraDescription = "Invoice Item Line Number:" + itemHolder.getInvoiceItemLineNumber();
            ElectronicInvoiceRejectReason rejectReason = createRejectReason(PurapConstants.ElectronicInvoice.PO_ITEM_AMT_LESSTHAN_INVOICE_ITEM_AMT, extraDescription, orderHolder.getFileName());
            orderHolder.addInvoiceOrderRejectReason(rejectReason, PurapConstants.ElectronicInvoice.RejectDocumentFields.INVOICE_ITEM_LINE_NUMBER, PurapKeyConstants.ERROR_REJECT_POITEM_LESS_OUTSTANDING_EMCUMBERED_AMOUNT);
            return;
        }
    }
}
Also used : PurchaseOrderItem(org.kuali.kfs.module.purap.businessobject.PurchaseOrderItem) ElectronicInvoiceRejectReason(org.kuali.kfs.module.purap.businessobject.ElectronicInvoiceRejectReason) ElectronicInvoiceOrderHolder(org.kuali.kfs.module.purap.service.impl.ElectronicInvoiceOrderHolder)

Aggregations

ElectronicInvoiceRejectReason (org.kuali.kfs.module.purap.businessobject.ElectronicInvoiceRejectReason)11 PurchaseOrderItem (org.kuali.kfs.module.purap.businessobject.PurchaseOrderItem)5 ArrayList (java.util.ArrayList)4 ElectronicInvoiceOrderHolder (org.kuali.kfs.module.purap.service.impl.ElectronicInvoiceOrderHolder)4 CuElectronicInvoiceRejectDocument (edu.cornell.kfs.module.purap.document.CuElectronicInvoiceRejectDocument)3 DocumentService (org.kuali.kfs.krad.service.DocumentService)3 WorkflowDocumentService (org.kuali.kfs.krad.workflow.service.WorkflowDocumentService)3 FinancialSystemDocumentService (org.kuali.kfs.sys.document.service.FinancialSystemDocumentService)3 WorkflowException (org.kuali.rice.kew.api.exception.WorkflowException)3 HashMap (java.util.HashMap)2 DataDictionaryService (org.kuali.kfs.krad.service.DataDictionaryService)2 PaymentRequestItem (org.kuali.kfs.module.purap.businessobject.PaymentRequestItem)2 ElectronicInvoiceRejectDocument (org.kuali.kfs.module.purap.document.ElectronicInvoiceRejectDocument)2 PurchaseOrderDocument (org.kuali.kfs.module.purap.document.PurchaseOrderDocument)2 KualiDecimal (org.kuali.rice.core.api.util.type.KualiDecimal)2 CuPaymentRequestItemExtension (edu.cornell.kfs.module.purap.businessobject.CuPaymentRequestItemExtension)1 CuPaymentRequestDocument (edu.cornell.kfs.module.purap.document.CuPaymentRequestDocument)1 VendorDetailExtension (edu.cornell.kfs.vnd.businessobject.VendorDetailExtension)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1