Search in sources :

Example 1 with CuPaymentRequestItemExtension

use of edu.cornell.kfs.module.purap.businessobject.CuPaymentRequestItemExtension in project cu-kfs by CU-CommunityApps.

the class CuPaymentRequestDocument method prepareForSave.

public void prepareForSave(KualiDocumentEvent event) {
    // LOG.info("preqWireTransfer " + preqWireTransfer != null);
    try {
        // if (preqWireTransfer != null) {
        // if (!StringUtils.equals(preqWireTransfer.getDocumentNumber(),getDocumentNumber())) {
        preqWireTransfer.setDocumentNumber(getDocumentNumber());
    // }
    // }
    } catch (Exception e) {
        LOG.info("preqWireTransfer is null");
        preqWireTransfer = new PaymentRequestWireTransfer();
        preqWireTransfer.setDocumentNumber(getDocumentNumber());
    }
    super.prepareForSave(event);
    for (PaymentRequestItem item : (List<PaymentRequestItem>) getItems()) {
        if (item.getItemIdentifier() == null) {
            Integer generatedItemId = SpringContext.getBean(SequenceAccessorService.class).getNextAvailableSequenceNumber("PMT_RQST_ITM_ID").intValue();
            item.setItemIdentifier(generatedItemId);
            if (item.getExtension() == null) {
                item.setExtension(new CuPaymentRequestItemExtension());
            }
            ((CuPaymentRequestItemExtension) item.getExtension()).setItemIdentifier(generatedItemId);
        }
    }
    // KFSPTS-1891
    if (getDocumentHeader().getWorkflowDocument().isInitiated() || getDocumentHeader().getWorkflowDocument().isSaved()) {
        // need to check whether the user has the permission to edit the bank code
        // if so, don't synchronize since we can't tell whether the value coming in
        // was entered by the user or not.
        DocumentAuthorizer docAuth = SpringContext.getBean(DocumentHelperService.class).getDocumentAuthorizer(this);
        if (!docAuth.isAuthorizedByTemplate(this, KFSConstants.ParameterNamespaces.KFS, KFSConstants.PermissionTemplate.EDIT_BANK_CODE.name, GlobalVariables.getUserSession().getPrincipalId())) {
            synchronizeBankCodeWithPaymentMethod();
        } else {
            // ensure that the name is updated properly
            refreshReferenceObject("bank");
        }
    }
}
Also used : CuPaymentRequestItemExtension(edu.cornell.kfs.module.purap.businessobject.CuPaymentRequestItemExtension) PaymentRequestItem(org.kuali.kfs.module.purap.businessobject.PaymentRequestItem) PaymentRequestWireTransfer(edu.cornell.kfs.module.purap.businessobject.PaymentRequestWireTransfer) DocumentAuthorizer(org.kuali.kfs.kns.document.authorization.DocumentAuthorizer) List(java.util.List) WorkflowException(org.kuali.rice.kew.api.exception.WorkflowException) DocumentHelperService(org.kuali.kfs.kns.service.DocumentHelperService)

Example 2 with CuPaymentRequestItemExtension

use of edu.cornell.kfs.module.purap.businessobject.CuPaymentRequestItemExtension in project cu-kfs by CU-CommunityApps.

the class CuElectronicInvoiceHelperServiceImpl method createPaymentRequest.

protected PaymentRequestDocument createPaymentRequest(ElectronicInvoiceOrderHolder orderHolder) {
    LOG.info("Creating Payment Request document");
    KNSGlobalVariables.getMessageList().clear();
    validateInvoiceOrderValidForPREQCreation(orderHolder);
    if (LOG.isInfoEnabled()) {
        if (orderHolder.isInvoiceRejected()) {
            LOG.info("Not possible to convert einvoice details into payment request");
        } else {
            LOG.info("Payment request document creation validation succeeded");
        }
    }
    if (orderHolder.isInvoiceRejected()) {
        return null;
    }
    PaymentRequestDocument preqDoc = null;
    try {
        preqDoc = (PaymentRequestDocument) SpringContext.getBean(DocumentService.class).getNewDocument("PREQ");
    } catch (WorkflowException e) {
        String extraDescription = "Error=" + e.getMessage();
        ElectronicInvoiceRejectReason rejectReason = matchingService.createRejectReason(PurapConstants.ElectronicInvoice.PREQ_WORKLOW_EXCEPTION, extraDescription, orderHolder.getFileName());
        orderHolder.addInvoiceOrderRejectReason(rejectReason);
        LOG.error("Error creating Payment request document - " + e.getMessage());
        return null;
    }
    PurchaseOrderDocument poDoc = orderHolder.getPurchaseOrderDocument();
    if (poDoc == null) {
        throw new RuntimeException("Purchase Order document (POId=" + poDoc.getPurapDocumentIdentifier() + ") does not exist in the system");
    }
    preqDoc.getDocumentHeader().setDocumentDescription(generatePREQDocumentDescription(poDoc));
    try {
        preqDoc.updateAndSaveAppDocStatus(PurapConstants.PaymentRequestStatuses.APPDOC_IN_PROCESS);
    } catch (WorkflowException we) {
        throw new RuntimeException("Unable to save route status data for document: " + preqDoc.getDocumentNumber(), we);
    }
    preqDoc.setInvoiceDate(orderHolder.getInvoiceDate());
    preqDoc.setInvoiceNumber(orderHolder.getInvoiceNumber());
    preqDoc.setVendorInvoiceAmount(new KualiDecimal(orderHolder.getInvoiceNetAmount()));
    preqDoc.setAccountsPayableProcessorIdentifier("E-Invoice");
    preqDoc.setVendorCustomerNumber(orderHolder.getCustomerNumber());
    preqDoc.setPaymentRequestElectronicInvoiceIndicator(true);
    if (orderHolder.getAccountsPayablePurchasingDocumentLinkIdentifier() != null) {
        preqDoc.setAccountsPayablePurchasingDocumentLinkIdentifier(orderHolder.getAccountsPayablePurchasingDocumentLinkIdentifier());
    }
    // Copied from PaymentRequestServiceImpl.populatePaymentRequest()
    // set bank code to default bank code in the system parameter
    // KFSPTS-1891
    boolean hasPaymentMethodCode = false;
    if (preqDoc instanceof PaymentRequestDocument) {
        String vendorPaymentMethodCode = ((VendorDetailExtension) poDoc.getVendorDetail().getExtension()).getDefaultB2BPaymentMethodCode();
        if (StringUtils.isNotEmpty(vendorPaymentMethodCode)) {
            ((CuPaymentRequestDocument) preqDoc).setPaymentMethodCode(vendorPaymentMethodCode);
            hasPaymentMethodCode = true;
        } else {
            ((CuPaymentRequestDocument) preqDoc).setPaymentMethodCode(DEFAULT_EINVOICE_PAYMENT_METHOD_CODE);
        }
    }
    Bank defaultBank = null;
    if (hasPaymentMethodCode) {
        defaultBank = SpringContext.getBean(CUPaymentMethodGeneralLedgerPendingEntryService.class).getBankForPaymentMethod(((CuPaymentRequestDocument) preqDoc).getPaymentMethodCode());
    } else {
        // default to baseline behavior - extended documents not in use
        // Copied from PaymentRequestServiceImpl.populatePaymentRequest()
        // set bank code to default bank code in the system parameter
        defaultBank = SpringContext.getBean(BankService.class).getDefaultBankByDocType(PaymentRequestDocument.class);
    }
    if (defaultBank != null) {
        preqDoc.setBankCode(defaultBank.getBankCode());
        preqDoc.setBank(defaultBank);
    }
    RequisitionDocument reqDoc = SpringContext.getBean(RequisitionService.class).getRequisitionById(poDoc.getRequisitionIdentifier());
    String reqDocInitiator = reqDoc.getDocumentHeader().getWorkflowDocument().getInitiatorPrincipalId();
    try {
        Person user = KimApiServiceLocator.getPersonService().getPerson(reqDocInitiator);
        setProcessingCampus(preqDoc, user.getCampusCode());
    } catch (Exception e) {
        String extraDescription = "Error setting processing campus code - " + e.getMessage();
        ElectronicInvoiceRejectReason rejectReason = matchingService.createRejectReason(PurapConstants.ElectronicInvoice.PREQ_ROUTING_VALIDATION_ERROR, extraDescription, orderHolder.getFileName());
        orderHolder.addInvoiceOrderRejectReason(rejectReason);
        return null;
    }
    HashMap<String, ExpiredOrClosedAccountEntry> expiredOrClosedAccountList = SpringContext.getBean(AccountsPayableService.class).expiredOrClosedAccountsList(poDoc);
    if (expiredOrClosedAccountList == null) {
        expiredOrClosedAccountList = new HashMap();
    }
    if (LOG.isInfoEnabled()) {
        LOG.info(expiredOrClosedAccountList.size() + " accounts has been found as Expired or Closed");
    }
    preqDoc.populatePaymentRequestFromPurchaseOrder(orderHolder.getPurchaseOrderDocument(), expiredOrClosedAccountList);
    // need to populate here for ext price.  it become per item
    // KFSPTS-1719.  convert 1st matching inv item that is qty, but po is non-qty
    checkQtyInvItemForNoQtyOrder(preqDoc, orderHolder);
    populateItemDetails(preqDoc, orderHolder);
    // KFSUPGRADE-485, KFSPTS-1719
    if (CollectionUtils.isNotEmpty(((CuElectronicInvoiceOrderHolder) orderHolder).getNonMatchItems())) {
        for (ElectronicInvoiceItemHolder invItem : ((CuElectronicInvoiceOrderHolder) orderHolder).getNonMatchItems()) {
            PurchaseOrderItem item = (PurchaseOrderItem) ObjectUtils.deepCopy((Serializable) orderHolder.getPurchaseOrderDocument().getItems().get(invItem.getInvoiceItemLineNumber() - 1));
            item.setItemLineNumber(invItem.getInvoiceItemLineNumber());
            item.setItemDescription(((CuElectronicInvoiceItemHolder) invItem).getReferenceDescription());
            // this will be populated to reqitem.poitemunitprice
            item.setItemUnitPrice(invItem.getInvoiceItemUnitPrice());
            PaymentRequestItem paymentRequestItem = new PaymentRequestItem(item, preqDoc, expiredOrClosedAccountList);
            ((CuPaymentRequestItemExtension) paymentRequestItem.getExtension()).setInvLineNumber(Integer.parseInt(((CuElectronicInvoiceItemHolder) invItem).getInvLineNumber()));
            // need following in case inv item is qty item
            paymentRequestItem.setItemQuantity(new KualiDecimal(invItem.getInvoiceItemQuantity()));
            paymentRequestItem.setItemUnitOfMeasureCode(invItem.getInvoiceItemUnitOfMeasureCode());
            paymentRequestItem.setPurchaseOrderItemUnitPrice(invItem.getInvoiceItemUnitPrice());
            // if non qty don't need this unit price set, then this need to have a check
            if (invItem.getInvoiceItemQuantity() != null && (new KualiDecimal(invItem.getInvoiceItemQuantity())).isPositive()) {
                paymentRequestItem.setItemUnitPrice(invItem.getInvoiceItemUnitPrice());
            }
            paymentRequestItem.setItemCatalogNumber(invItem.getCatalogNumberStripped());
            preqDoc.getItems().add(paymentRequestItem);
            ((CuElectronicInvoiceOrderHolder) orderHolder).setMisMatchItem((CuElectronicInvoiceItemHolder) invItem);
            populateItemDetailsForNonMatching(preqDoc, orderHolder);
            ((CuElectronicInvoiceOrderHolder) orderHolder).setMisMatchItem(null);
        }
    }
    /**
     * Validate totals,paydate
     */
    // PaymentRequestDocumentRule.processCalculateAccountsPayableBusinessRules
    SpringContext.getBean(KualiRuleService.class).applyRules(new AttributedCalculateAccountsPayableEvent(preqDoc));
    SpringContext.getBean(PaymentRequestService.class).calculatePaymentRequest(preqDoc, true);
    processItemsForDiscount(preqDoc, orderHolder);
    if (orderHolder.isInvoiceRejected()) {
        return null;
    }
    SpringContext.getBean(PaymentRequestService.class).calculatePaymentRequest(preqDoc, false);
    /**
     * PaymentRequestReview
     */
    // PaymentRequestDocumentRule.processRouteDocumentBusinessRules
    SpringContext.getBean(KualiRuleService.class).applyRules(new AttributedPaymentRequestForEInvoiceEvent(preqDoc));
    if (GlobalVariables.getMessageMap().hasErrors()) {
        if (LOG.isInfoEnabled()) {
            LOG.info("***************Error in rules processing - " + GlobalVariables.getMessageMap());
        }
        Map<String, AutoPopulatingList<ErrorMessage>> errorMessages = GlobalVariables.getMessageMap().getErrorMessages();
        String errors = errorMessages.toString();
        ElectronicInvoiceRejectReason rejectReason = matchingService.createRejectReason(PurapConstants.ElectronicInvoice.PREQ_ROUTING_VALIDATION_ERROR, errors, orderHolder.getFileName());
        orderHolder.addInvoiceOrderRejectReason(rejectReason);
        return null;
    }
    if (KNSGlobalVariables.getMessageList().size() > 0) {
        if (LOG.isInfoEnabled()) {
            LOG.info("Payment request contains " + KNSGlobalVariables.getMessageList().size() + " warning message(s)");
            for (int i = 0; i < KNSGlobalVariables.getMessageList().size(); i++) {
                LOG.info("Warning " + i + "  - " + KNSGlobalVariables.getMessageList().get(i));
            }
        }
    }
    addShipToNotes(preqDoc, orderHolder);
    try {
        // KFSUPGRADE-490: Do save-only operations for just non-EIRT-generated PREQs.
        if (orderHolder.isRejectDocumentHolder()) {
            SpringContext.getBean(DocumentService.class).routeDocument(preqDoc, null, null);
        } else {
            SpringContext.getBean(DocumentService.class).saveDocument(preqDoc, DocumentSystemSaveEvent.class);
        }
    } catch (WorkflowException e) {
        e.printStackTrace();
        ElectronicInvoiceRejectReason rejectReason = matchingService.createRejectReason(PurapConstants.ElectronicInvoice.PREQ_ROUTING_FAILURE, e.getMessage(), orderHolder.getFileName());
        orderHolder.addInvoiceOrderRejectReason(rejectReason);
        return null;
    } catch (ValidationException e) {
        String extraDescription = GlobalVariables.getMessageMap().toString();
        ElectronicInvoiceRejectReason rejectReason = matchingService.createRejectReason(PurapConstants.ElectronicInvoice.PREQ_ROUTING_VALIDATION_ERROR, extraDescription, orderHolder.getFileName());
        orderHolder.addInvoiceOrderRejectReason(rejectReason);
        return null;
    }
    return preqDoc;
}
Also used : Serializable(java.io.Serializable) Bank(org.kuali.kfs.sys.businessobject.Bank) ValidationException(org.kuali.kfs.krad.exception.ValidationException) ElectronicInvoiceItemHolder(org.kuali.kfs.module.purap.service.impl.ElectronicInvoiceItemHolder) HashMap(java.util.HashMap) RequisitionDocument(org.kuali.kfs.module.purap.document.RequisitionDocument) KualiRuleService(org.kuali.kfs.krad.service.KualiRuleService) CuPaymentRequestDocument(edu.cornell.kfs.module.purap.document.CuPaymentRequestDocument) PurchaseOrderDocument(org.kuali.kfs.module.purap.document.PurchaseOrderDocument) KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal) VendorDetailExtension(edu.cornell.kfs.vnd.businessobject.VendorDetailExtension) RequisitionService(org.kuali.kfs.module.purap.document.service.RequisitionService) ExpiredOrClosedAccountEntry(org.kuali.kfs.module.purap.util.ExpiredOrClosedAccountEntry) CuPaymentRequestItemExtension(edu.cornell.kfs.module.purap.businessobject.CuPaymentRequestItemExtension) AttributedCalculateAccountsPayableEvent(org.kuali.kfs.module.purap.document.validation.event.AttributedCalculateAccountsPayableEvent) PaymentRequestService(org.kuali.kfs.module.purap.document.service.PaymentRequestService) WorkflowException(org.kuali.rice.kew.api.exception.WorkflowException) CuPaymentRequestDocument(edu.cornell.kfs.module.purap.document.CuPaymentRequestDocument) PaymentRequestDocument(org.kuali.kfs.module.purap.document.PaymentRequestDocument) ElectronicInvoiceRejectReason(org.kuali.kfs.module.purap.businessobject.ElectronicInvoiceRejectReason) WorkflowDocumentService(org.kuali.kfs.krad.workflow.service.WorkflowDocumentService) DocumentService(org.kuali.kfs.krad.service.DocumentService) FinancialSystemDocumentService(org.kuali.kfs.sys.document.service.FinancialSystemDocumentService) ValidationException(org.kuali.kfs.krad.exception.ValidationException) IOException(java.io.IOException) WorkflowException(org.kuali.rice.kew.api.exception.WorkflowException) FileNotFoundException(java.io.FileNotFoundException) RemoteException(java.rmi.RemoteException) CxmlParseException(org.kuali.kfs.module.purap.exception.CxmlParseException) PurchaseOrderItem(org.kuali.kfs.module.purap.businessobject.PurchaseOrderItem) PaymentRequestItem(org.kuali.kfs.module.purap.businessobject.PaymentRequestItem) AttributedPaymentRequestForEInvoiceEvent(org.kuali.kfs.module.purap.document.validation.event.AttributedPaymentRequestForEInvoiceEvent) Person(org.kuali.rice.kim.api.identity.Person) AccountsPayableService(org.kuali.kfs.module.purap.document.service.AccountsPayableService) AutoPopulatingList(org.springframework.util.AutoPopulatingList)

Example 3 with CuPaymentRequestItemExtension

use of edu.cornell.kfs.module.purap.businessobject.CuPaymentRequestItemExtension in project cu-kfs by CU-CommunityApps.

the class CuElectronicInvoiceHelperServiceImpl method processInvoiceItem.

protected void processInvoiceItem(PaymentRequestItem preqItem, ElectronicInvoiceOrderHolder orderHolder) {
    // TODO : 'no qty' po line item may have 'qty inv item'
    // force it to match like qty item.
    CuPaymentRequestItemExtension preqItemExt = (CuPaymentRequestItemExtension) preqItem.getExtension();
    // Need to populate if it is null
    if (preqItemExt == null) {
        preqItemExt = new CuPaymentRequestItemExtension();
        preqItem.setExtension(preqItemExt);
    }
    if ((preqItemExt.getInvLineNumber() == null && ((CuElectronicInvoiceOrderHolder) orderHolder).getMisMatchItem() == null) || (preqItemExt.getInvLineNumber() != null && StringUtils.equals(preqItemExt.getInvLineNumber().toString(), ((CuElectronicInvoiceItemHolder) ((CuElectronicInvoiceOrderHolder) orderHolder).getMisMatchItem()).getInvLineNumber()))) {
        if (StringUtils.equals(PurapConstants.ItemTypeCodes.ITEM_TYPE_SERVICE_CODE, preqItem.getItemTypeCode())) {
            if (preqItem.getItemQuantity() != null && preqItem.getItemQuantity().isPositive() && StringUtils.isNotBlank(preqItem.getItemUnitOfMeasureCode())) {
                preqItem.setItemTypeCode(PurapConstants.ItemTypeCodes.ITEM_TYPE_ITEM_CODE);
            }
        }
    }
    if (isItemValidForUpdation(preqItem.getItemTypeCode(), ElectronicInvoice.INVOICE_AMOUNT_TYPE_CODE_ITEM, orderHolder)) {
        if ((preqItemExt.getInvLineNumber() == null && ((CuElectronicInvoiceOrderHolder) orderHolder).getMisMatchItem() == null) || (preqItemExt.getInvLineNumber() != null && StringUtils.equals(preqItemExt.getInvLineNumber().toString(), ((CuElectronicInvoiceItemHolder) ((CuElectronicInvoiceOrderHolder) orderHolder).getMisMatchItem()).getInvLineNumber()))) {
            processAboveTheLineItem(preqItem, orderHolder);
            if (preqItem.getPurchaseOrderItem().isNoQtyItem()) {
                if (preqItemExt.getInvLineNumber() == null && orderHolder.getItemByLineNumber(preqItem.getItemLineNumber()) != null) {
                    // if there po is not in inv, then don't do this
                    preqItemExt.setInvLineNumber(Integer.parseInt(((CuElectronicInvoiceItemHolder) orderHolder.getItemByLineNumber(preqItem.getItemLineNumber())).getInvLineNumber()));
                    preqItem.setItemDescription(((CuElectronicInvoiceItemHolder) orderHolder.getItemByLineNumber(preqItem.getItemLineNumber())).getReferenceDescription());
                }
            } else {
                preqItemExt.setInvLineNumber(preqItem.getPurchaseOrderItem().getItemLineNumber());
            }
        }
    // KFSPTS-1719 : check if this works for nonqty for unitprice and extended price
    } else if (preqItem.isNoQtyItem()) {
        // TODO : need to try ti match the inv line to
        if ((preqItemExt.getInvLineNumber() == null && ((CuElectronicInvoiceOrderHolder) orderHolder).getMisMatchItem() == null) || (preqItemExt.getInvLineNumber() != null && StringUtils.equals(preqItemExt.getInvLineNumber().toString(), ((CuElectronicInvoiceOrderHolder) orderHolder).getMisMatchItem().getInvLineNumber()))) {
            processAboveTheLineItemForNonQty(preqItem, orderHolder);
            if (preqItemExt.getInvLineNumber() == null) {
                preqItemExt.setInvLineNumber(Integer.parseInt(((CuElectronicInvoiceItemHolder) orderHolder.getItemByLineNumber(preqItem.getItemLineNumber())).getInvLineNumber()));
                preqItem.setItemDescription(((CuElectronicInvoiceItemHolder) orderHolder.getItemByLineNumber(preqItem.getItemLineNumber())).getReferenceDescription());
            }
        }
    } else if (isItemValidForUpdation(preqItem.getItemTypeCode(), ElectronicInvoice.INVOICE_AMOUNT_TYPE_CODE_TAX, orderHolder)) {
        processTaxItem(preqItem, orderHolder);
    } else if (isItemValidForUpdation(preqItem.getItemTypeCode(), ElectronicInvoice.INVOICE_AMOUNT_TYPE_CODE_SHIPPING, orderHolder)) {
        processShippingItem(preqItem, orderHolder);
    } else if (isItemValidForUpdation(preqItem.getItemTypeCode(), ElectronicInvoice.INVOICE_AMOUNT_TYPE_CODE_SPECIAL_HANDLING, orderHolder)) {
        processSpecialHandlingItem(preqItem, orderHolder);
    } else if (isItemValidForUpdation(preqItem.getItemTypeCode(), ElectronicInvoice.INVOICE_AMOUNT_TYPE_CODE_DEPOSIT, orderHolder)) {
        processDepositItem(preqItem, orderHolder);
    } else if (isItemValidForUpdation(preqItem.getItemTypeCode(), ElectronicInvoice.INVOICE_AMOUNT_TYPE_CODE_DUE, orderHolder)) {
        processDueItem(preqItem, orderHolder);
    } else if (isItemValidForUpdation(preqItem.getItemTypeCode(), ElectronicInvoice.INVOICE_AMOUNT_TYPE_CODE_DISCOUNT, orderHolder)) {
        processDiscountItem(preqItem, orderHolder);
    } else if (isItemValidForUpdation(preqItem.getItemTypeCode(), ElectronicInvoice.INVOICE_AMOUNT_TYPE_CODE_EXMT, orderHolder)) {
        processAboveTheLineItem(preqItem, orderHolder);
    }
}
Also used : CuPaymentRequestItemExtension(edu.cornell.kfs.module.purap.businessobject.CuPaymentRequestItemExtension)

Example 4 with CuPaymentRequestItemExtension

use of edu.cornell.kfs.module.purap.businessobject.CuPaymentRequestItemExtension in project cu-kfs by CU-CommunityApps.

the class CuElectronicInvoiceHelperServiceImpl method populateItemDetailsForNonMatching.

// for non matching items, the additional charge don't have to add it again.
protected void populateItemDetailsForNonMatching(PaymentRequestDocument preqDocument, ElectronicInvoiceOrderHolder orderHolder) {
    if (LOG.isInfoEnabled()) {
        LOG.info("Populating invoice order items into the payment request document");
    }
    List<PaymentRequestItem> preqItems = preqDocument.getItems();
    for (PaymentRequestItem preqItem : preqItems) {
        CuPaymentRequestItemExtension preqItemExt = (CuPaymentRequestItemExtension) preqItem.getExtension();
        // force it to match like qty item.
        if ((preqItemExt.getInvLineNumber() == null && ((CuElectronicInvoiceOrderHolder) orderHolder).getMisMatchItem() == null) || (preqItemExt.getInvLineNumber() != null && StringUtils.equals(preqItemExt.getInvLineNumber().toString(), ((CuElectronicInvoiceItemHolder) ((CuElectronicInvoiceOrderHolder) orderHolder).getMisMatchItem()).getInvLineNumber()))) {
            if (StringUtils.equals(PurapConstants.ItemTypeCodes.ITEM_TYPE_SERVICE_CODE, preqItem.getItemTypeCode())) {
                if (preqItem.getItemQuantity() != null && preqItem.getItemQuantity().isPositive() && StringUtils.isNotBlank(preqItem.getItemUnitOfMeasureCode())) {
                    preqItem.setItemTypeCode(PurapConstants.ItemTypeCodes.ITEM_TYPE_ITEM_CODE);
                }
            }
        }
        if (isItemValidForUpdation(preqItem.getItemTypeCode(), ElectronicInvoice.INVOICE_AMOUNT_TYPE_CODE_ITEM, orderHolder)) {
            if ((preqItemExt.getInvLineNumber() == null && ((CuElectronicInvoiceOrderHolder) orderHolder).getMisMatchItem() == null) || (preqItemExt.getInvLineNumber() != null && StringUtils.equals(preqItemExt.getInvLineNumber().toString(), ((CuElectronicInvoiceItemHolder) ((CuElectronicInvoiceOrderHolder) orderHolder).getMisMatchItem()).getInvLineNumber()))) {
                processAboveTheLineItem(preqItem, orderHolder);
                if (preqItemExt.getInvLineNumber() == null) {
                    preqItemExt.setInvLineNumber(Integer.parseInt(((CuElectronicInvoiceItemHolder) orderHolder.getItemByLineNumber(preqItem.getItemLineNumber())).getInvLineNumber()));
                    preqItem.setItemDescription(((CuElectronicInvoiceItemHolder) orderHolder.getItemByLineNumber(preqItem.getItemLineNumber())).getReferenceDescription());
                }
            }
        // KFSPTS-1719 : check if this works for nonqty for unitprice and extended price
        } else if (preqItem.isNoQtyItem()) {
            // TODO : need to try ti match the inv line to
            if ((preqItemExt.getInvLineNumber() == null && ((CuElectronicInvoiceOrderHolder) orderHolder).getMisMatchItem() == null) || (preqItemExt.getInvLineNumber() != null && StringUtils.equals(preqItemExt.getInvLineNumber().toString(), ((CuElectronicInvoiceItemHolder) ((CuElectronicInvoiceOrderHolder) orderHolder).getMisMatchItem()).getInvLineNumber()))) {
                processAboveTheLineItemForNonQty(preqItem, orderHolder);
                if (preqItemExt.getInvLineNumber() == null) {
                    preqItemExt.setInvLineNumber(Integer.parseInt(((CuElectronicInvoiceItemHolder) orderHolder.getItemByLineNumber(preqItem.getItemLineNumber())).getInvLineNumber()));
                    preqItem.setItemDescription(((CuElectronicInvoiceItemHolder) orderHolder.getItemByLineNumber(preqItem.getItemLineNumber())).getReferenceDescription());
                }
            }
        }
    }
    if (LOG.isInfoEnabled()) {
        LOG.info("Successfully populated the invoice order items");
    }
}
Also used : CuPaymentRequestItemExtension(edu.cornell.kfs.module.purap.businessobject.CuPaymentRequestItemExtension) PaymentRequestItem(org.kuali.kfs.module.purap.businessobject.PaymentRequestItem)

Aggregations

CuPaymentRequestItemExtension (edu.cornell.kfs.module.purap.businessobject.CuPaymentRequestItemExtension)4 PaymentRequestItem (org.kuali.kfs.module.purap.businessobject.PaymentRequestItem)3 WorkflowException (org.kuali.rice.kew.api.exception.WorkflowException)2 PaymentRequestWireTransfer (edu.cornell.kfs.module.purap.businessobject.PaymentRequestWireTransfer)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 Serializable (java.io.Serializable)1 RemoteException (java.rmi.RemoteException)1 HashMap (java.util.HashMap)1 List (java.util.List)1 DocumentAuthorizer (org.kuali.kfs.kns.document.authorization.DocumentAuthorizer)1 DocumentHelperService (org.kuali.kfs.kns.service.DocumentHelperService)1 ValidationException (org.kuali.kfs.krad.exception.ValidationException)1 DocumentService (org.kuali.kfs.krad.service.DocumentService)1 KualiRuleService (org.kuali.kfs.krad.service.KualiRuleService)1 WorkflowDocumentService (org.kuali.kfs.krad.workflow.service.WorkflowDocumentService)1 ElectronicInvoiceRejectReason (org.kuali.kfs.module.purap.businessobject.ElectronicInvoiceRejectReason)1 PurchaseOrderItem (org.kuali.kfs.module.purap.businessobject.PurchaseOrderItem)1