Search in sources :

Example 6 with PaymentRequestDocument

use of org.kuali.kfs.module.purap.document.PaymentRequestDocument in project cu-kfs by CU-CommunityApps.

the class PaymentRequestWireTransferValidation method validate.

/**
 * @see org.kuali.kfs.sys.document.validation.Validation#validate(org.kuali.kfs.sys.document.validation.event.AttributedDocumentEvent)
 */
public boolean validate(AttributedDocumentEvent event) {
    LOG.debug("validate start");
    boolean isValid = true;
    PaymentRequestDocument document = (PaymentRequestDocument) accountingDocumentForValidation;
    PaymentRequestWireTransfer wireTransfer = ((CuPaymentRequestDocument) document).getPreqWireTransfer();
    if (!PaymentMethod.PM_CODE_WIRE.equals(((CuPaymentRequestDocument) document).getPaymentMethodCode())) {
        return isValid;
    }
    MessageMap errors = GlobalVariables.getMessageMap();
    errors.addToErrorPath(KFSPropertyConstants.DOCUMENT);
    errors.addToErrorPath(CUPurapPropertyConstants.PREQ_WIRE_TRANSFER);
    isValid &= isValid(wireTransfer.getPreqBankName(), CUPurapConstants.LABEL_BANK_NAME, CUPurapPropertyConstants.PREQ_BANK_NAME);
    isValid &= isValid(wireTransfer.getPreqBankCityName(), CUPurapConstants.LABEL_BANK_CITY, CUPurapPropertyConstants.PREQ_BANK_CITY_NAME);
    isValid &= isValid(wireTransfer.getPreqBankCountryCode(), CUPurapConstants.LABEL_BANK_COUNTRY, CUPurapPropertyConstants.PREQ_BANK_COUNTRY_CODE);
    isValid &= isValid(wireTransfer.getPreqCurrencyTypeName(), CUPurapConstants.LABEL_CURRENCY, CUPurapPropertyConstants.PREQ_CURRENCY_TYPE_NAME);
    isValid &= isValid(wireTransfer.getPreqPayeeAccountNumber(), CUPurapConstants.LABEL_BANK_ACCT_NUMBER, CUPurapPropertyConstants.PREQ_PAYEE_ACCT_NUMBER);
    isValid &= isValid(wireTransfer.getPreqPayeeAccountName(), CUPurapConstants.LABEL_BANK_ACCT_NAME, CUPurapPropertyConstants.PREQ_PAYEE_ACCT_NAME);
    if (KFSConstants.COUNTRY_CODE_UNITED_STATES.equals(wireTransfer.getPreqBankCountryCode()) && StringUtils.isBlank(wireTransfer.getPreqBankRoutingNumber())) {
        errors.putError(CUPurapPropertyConstants.PREQ_BANK_ROUTING_NUMBER, KFSKeyConstants.ERROR_PAYMENT_SOURCE_BANK_ROUTING_NUMBER);
        isValid = false;
    }
    if (KFSConstants.COUNTRY_CODE_UNITED_STATES.equals(wireTransfer.getPreqBankCountryCode()) && StringUtils.isBlank(wireTransfer.getPreqBankStateCode())) {
        errors.putError(CUPurapPropertyConstants.PREQ_BANK_STATE_CODE, KFSKeyConstants.ERROR_REQUIRED, "Bank State");
        isValid = false;
    }
    errors.removeFromErrorPath(CUPurapPropertyConstants.PREQ_WIRE_TRANSFER);
    errors.removeFromErrorPath(KFSPropertyConstants.DOCUMENT);
    return isValid;
}
Also used : PaymentRequestWireTransfer(edu.cornell.kfs.module.purap.businessobject.PaymentRequestWireTransfer) CuPaymentRequestDocument(edu.cornell.kfs.module.purap.document.CuPaymentRequestDocument) CuPaymentRequestDocument(edu.cornell.kfs.module.purap.document.CuPaymentRequestDocument) PaymentRequestDocument(org.kuali.kfs.module.purap.document.PaymentRequestDocument) MessageMap(org.kuali.kfs.krad.util.MessageMap)

Example 7 with PaymentRequestDocument

use of org.kuali.kfs.module.purap.document.PaymentRequestDocument in project cu-kfs by CU-CommunityApps.

the class CuBatchExtractServiceImpl method findPaymentRequestDocument.

/**
 * Retrieves a payment request document for a specific document number
 *
 * @param entry GL Line
 * @return PaymentRequestDocument
 */
@Override
protected PaymentRequestDocument findPaymentRequestDocument(Entry entry) {
    PaymentRequestDocument paymentRequestDocument = null;
    Map<String, String> keys = new LinkedHashMap<String, String>();
    keys.put(CamsPropertyConstants.DOCUMENT_NUMBER, entry.getDocumentNumber());
    Class<? extends Document> docClass = dataDictionaryService.getDocumentClassByTypeName(PurapConstants.PurapDocTypeCodes.PAYMENT_REQUEST_DOCUMENT);
    Collection<? extends Document> matchingPreqs = businessObjectService.findMatching(docClass, keys);
    if (matchingPreqs != null && matchingPreqs.size() == 1) {
        paymentRequestDocument = (PaymentRequestDocument) matchingPreqs.iterator().next();
    }
    return paymentRequestDocument;
}
Also used : PaymentRequestDocument(org.kuali.kfs.module.purap.document.PaymentRequestDocument) LinkedHashMap(java.util.LinkedHashMap)

Example 8 with PaymentRequestDocument

use of org.kuali.kfs.module.purap.document.PaymentRequestDocument in project cu-kfs by CU-CommunityApps.

the class CuPendingTransactionServiceImpl method reverseSourceDocumentsEntries.

/**
 * Reverses the entries of the source documents
 *
 * @param paymentDetail
 * @param sequenceHelper
 */
protected void reverseSourceDocumentsEntries(PaymentDetail paymentDetail, GeneralLedgerPendingEntrySequenceHelper sequenceHelper) {
    // Need to reverse the payment document's GL entries if the check is stopped or cancelled
    if (PurapConstants.PurapDocTypeCodes.PAYMENT_REQUEST_DOCUMENT.equalsIgnoreCase(paymentDetail.getFinancialDocumentTypeCode()) || CUPdpConstants.PdpDocumentTypes.DISBURSEMENT_VOUCHER.equalsIgnoreCase(paymentDetail.getFinancialDocumentTypeCode()) || CUPdpConstants.PdpDocumentTypes.CREDIT_MEMO.equalsIgnoreCase(paymentDetail.getFinancialDocumentTypeCode())) {
        try {
            String sourceDocumentNumber = paymentDetail.getCustPaymentDocNbr();
            try {
                Long.valueOf(sourceDocumentNumber);
            } catch (NumberFormatException nfe) {
                sourceDocumentNumber = null;
            }
            if (sourceDocumentNumber != null && StringUtils.isNotBlank(sourceDocumentNumber)) {
                Document doc = (AccountingDocumentBase) SpringContext.getBean(DocumentService.class).getByDocumentHeaderId(paymentDetail.getCustPaymentDocNbr());
                if (ObjectUtils.isNotNull(doc)) {
                    if (doc instanceof DisbursementVoucherDocument) {
                        // KFSUPGRADE-775
                        DisbursementVoucherDocument dv = (DisbursementVoucherDocument) doc;
                        generateDisbursementVoucherReversalEntries(dv, sequenceHelper);
                    // end KFSUPGRADE-775
                    } else if (doc instanceof VendorCreditMemoDocument) {
                        // KFSPTS-2719
                        String crCmCancelNote = parameterService.getParameterValueAsString(VendorCreditMemoDocument.class, CUPurapParameterConstants.PURAP_CR_CM_CANCEL_NOTE);
                        VendorCreditMemoDocument cmDocument = (VendorCreditMemoDocument) doc;
                        String crCancelMaintDocNbr = getCrCancelMaintenancedocumentNumber(paymentDetail);
                        crCmCancelNote = crCmCancelNote + crCancelMaintDocNbr;
                        try {
                            Note noteObj = documentService.createNoteFromDocument(cmDocument, crCmCancelNote);
                            cmDocument.addNote(noteObj);
                            noteService.save(noteObj);
                        } catch (Exception e) {
                            throw new RuntimeException(e.getMessage());
                        }
                        // KFSUPGRADE-775
                        VendorCreditMemoDocument cm = (VendorCreditMemoDocument) doc;
                        AccountsPayableDocumentSpecificService accountsPayableDocumentSpecificService = cm.getDocumentSpecificService();
                        accountsPayableDocumentSpecificService.updateStatusByNode("", cm);
                        // end KFSUPGRADE-775
                        generateCreditMemoReversalEntries((VendorCreditMemoDocument) doc);
                    } else if (doc instanceof PaymentRequestDocument) {
                        // KFSPTS-2719
                        String crPreqCancelNote = parameterService.getParameterValueAsString(PaymentRequestDocument.class, CUPurapParameterConstants.PURAP_CR_PREQ_CANCEL_NOTE);
                        PaymentRequestDocument paymentRequest = (PaymentRequestDocument) doc;
                        String crCancelMaintDocNbr = getCrCancelMaintenancedocumentNumber(paymentDetail);
                        crPreqCancelNote = crPreqCancelNote + crCancelMaintDocNbr;
                        try {
                            Note cancelNote = documentService.createNoteFromDocument(paymentRequest, crPreqCancelNote);
                            paymentRequest.addNote(cancelNote);
                            noteService.save(cancelNote);
                        } catch (Exception e) {
                            throw new RuntimeException(PurapConstants.REQ_UNABLE_TO_CREATE_NOTE + " " + e);
                        }
                        // cancel extracted should not reopen PO
                        paymentRequest.setReopenPurchaseOrderIndicator(false);
                        // KFSUPGRADE-775
                        AccountsPayableDocumentSpecificService accountsPayableDocumentSpecificService = paymentRequest.getDocumentSpecificService();
                        accountsPayableDocumentSpecificService.updateStatusByNode("", paymentRequest);
                        // end KFSUPGRADE-775
                        generatePaymentRequestReversalEntries(paymentRequest);
                    }
                }
            }
        } catch (WorkflowException we) {
            System.out.println("Exception retrieving document " + paymentDetail.getCustPaymentDocNbr());
        }
    }
}
Also used : VendorCreditMemoDocument(org.kuali.kfs.module.purap.document.VendorCreditMemoDocument) AccountsPayableDocumentSpecificService(org.kuali.kfs.module.purap.document.service.AccountsPayableDocumentSpecificService) Note(org.kuali.kfs.krad.bo.Note) WorkflowException(org.kuali.rice.kew.api.exception.WorkflowException) PaymentRequestDocument(org.kuali.kfs.module.purap.document.PaymentRequestDocument) AccountingDocumentBase(org.kuali.kfs.sys.document.AccountingDocumentBase) VendorCreditMemoDocument(org.kuali.kfs.module.purap.document.VendorCreditMemoDocument) DisbursementVoucherDocument(org.kuali.kfs.fp.document.DisbursementVoucherDocument) Document(org.kuali.kfs.krad.document.Document) PaymentRequestDocument(org.kuali.kfs.module.purap.document.PaymentRequestDocument) PurchaseOrderDocument(org.kuali.kfs.module.purap.document.PurchaseOrderDocument) DisbursementVoucherDocument(org.kuali.kfs.fp.document.DisbursementVoucherDocument) WorkflowException(org.kuali.rice.kew.api.exception.WorkflowException)

Example 9 with PaymentRequestDocument

use of org.kuali.kfs.module.purap.document.PaymentRequestDocument in project cu-kfs by CU-CommunityApps.

the class CuPaymentRequestServiceImplTest method testRemoveHoldOnPaymentRequest.

public void testRemoveHoldOnPaymentRequest() throws Exception {
    changeCurrentUser(UserNameFixture.ccs1);
    PurchaseOrderDocument po = PurchaseOrderFixture.PO_NON_B2B_OPEN.createPurchaseOrderdDocument(SpringContext.getBean(DocumentService.class));
    po.setVendorShippingPaymentTermsCode("AL");
    po.setVendorPaymentTermsCode("00N30");
    po.refreshNonUpdateableReferences();
    changeCurrentUser(UserNameFixture.mo14);
    PaymentRequestDocument paymentRequestDocument = PaymentRequestFixture.PAYMENT_REQ_DOC.createPaymentRequestDocument(po.getPurapDocumentIdentifier());
    paymentRequestDocument.initiateDocument();
    paymentRequestDocument.populatePaymentRequestFromPurchaseOrder(po);
    paymentRequestDocument.prepareForSave();
    AccountingDocumentTestUtils.saveDocument(paymentRequestDocument, SpringContext.getBean(DocumentService.class));
    paymentRequestService.removeHoldOnPaymentRequest(paymentRequestDocument, "test");
    assertFalse(paymentRequestDocument.isHoldIndicator());
    assertNull(paymentRequestDocument.getLastActionPerformedByPersonId());
}
Also used : PurchaseOrderDocument(org.kuali.kfs.module.purap.document.PurchaseOrderDocument) CuPaymentRequestDocument(edu.cornell.kfs.module.purap.document.CuPaymentRequestDocument) PaymentRequestDocument(org.kuali.kfs.module.purap.document.PaymentRequestDocument) DocumentService(org.kuali.kfs.krad.service.DocumentService)

Example 10 with PaymentRequestDocument

use of org.kuali.kfs.module.purap.document.PaymentRequestDocument in project cu-kfs by CU-CommunityApps.

the class CuPaymentRequestServiceImplTest method testRemoveRequestCancelOnPaymentRequest.

public void testRemoveRequestCancelOnPaymentRequest() throws Exception {
    changeCurrentUser(UserNameFixture.ccs1);
    PurchaseOrderDocument po = PurchaseOrderFixture.PO_NON_B2B_OPEN.createPurchaseOrderdDocument(SpringContext.getBean(DocumentService.class));
    po.setVendorShippingPaymentTermsCode("AL");
    po.setVendorPaymentTermsCode("00N30");
    po.refreshNonUpdateableReferences();
    changeCurrentUser(UserNameFixture.mo14);
    PaymentRequestDocument paymentRequestDocument = PaymentRequestFixture.PAYMENT_REQ_DOC.createPaymentRequestDocument(po.getPurapDocumentIdentifier());
    paymentRequestDocument.initiateDocument();
    paymentRequestDocument.populatePaymentRequestFromPurchaseOrder(po);
    paymentRequestDocument.prepareForSave();
    AccountingDocumentTestUtils.saveDocument(paymentRequestDocument, SpringContext.getBean(DocumentService.class));
    paymentRequestService.removeRequestCancelOnPaymentRequest(paymentRequestDocument, "test");
    assertFalse(paymentRequestDocument.isPaymentRequestedCancelIndicator());
    assertNull(paymentRequestDocument.getLastActionPerformedByPersonId());
    assertNull(paymentRequestDocument.getAccountsPayableRequestCancelIdentifier());
}
Also used : PurchaseOrderDocument(org.kuali.kfs.module.purap.document.PurchaseOrderDocument) CuPaymentRequestDocument(edu.cornell.kfs.module.purap.document.CuPaymentRequestDocument) PaymentRequestDocument(org.kuali.kfs.module.purap.document.PaymentRequestDocument) DocumentService(org.kuali.kfs.krad.service.DocumentService)

Aggregations

PaymentRequestDocument (org.kuali.kfs.module.purap.document.PaymentRequestDocument)36 CuPaymentRequestDocument (edu.cornell.kfs.module.purap.document.CuPaymentRequestDocument)21 PurchaseOrderDocument (org.kuali.kfs.module.purap.document.PurchaseOrderDocument)15 DocumentService (org.kuali.kfs.krad.service.DocumentService)12 PaymentRequestItem (org.kuali.kfs.module.purap.businessobject.PaymentRequestItem)6 WorkflowException (org.kuali.rice.kew.api.exception.WorkflowException)5 VendorCreditMemoDocument (org.kuali.kfs.module.purap.document.VendorCreditMemoDocument)4 KualiDecimal (org.kuali.rice.core.api.util.type.KualiDecimal)4 RemoteException (java.rmi.RemoteException)3 KualiRuleService (org.kuali.kfs.krad.service.KualiRuleService)3 PurApItem (org.kuali.kfs.module.purap.businessobject.PurApItem)3 PaymentRequestService (org.kuali.kfs.module.purap.document.service.PaymentRequestService)3 FileNotFoundException (java.io.FileNotFoundException)2 IOException (java.io.IOException)2 BigDecimal (java.math.BigDecimal)2 HashMap (java.util.HashMap)2 ActionForward (org.apache.struts.action.ActionForward)2 ValidationException (org.kuali.kfs.krad.exception.ValidationException)2 MessageMap (org.kuali.kfs.krad.util.MessageMap)2 WorkflowDocumentService (org.kuali.kfs.krad.workflow.service.WorkflowDocumentService)2