Search in sources :

Example 6 with CuVendorCreditMemoDocument

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

the class CuCreditMemoServiceImplTest method setupVendorCreditMemoDocument.

private CuVendorCreditMemoDocument setupVendorCreditMemoDocument() {
    ArrayList<String> methodNames = new ArrayList<>();
    for (Method method : VendorCreditMemoDocument.class.getMethods()) {
        if (!Modifier.isFinal(method.getModifiers()) && !method.getName().startsWith("set") && !method.getName().startsWith("get") && !method.getName().startsWith("is")) {
            methodNames.add(method.getName());
        }
    }
    IMockBuilder<CuVendorCreditMemoDocument> builder = EasyMock.createMockBuilder(CuVendorCreditMemoDocument.class).addMockedMethods(methodNames.toArray(new String[0]));
    creditMemoDocument = builder.createNiceMock();
    creditMemoDocument.setDocumentHeader(new MockFinancialSystemDocumentHeader());
    creditMemoDocument.getDocumentHeader().setDocumentDescription("Description");
    creditMemoDocument.setVendorDetailAssignedIdentifier(0);
    creditMemoDocument.setVendorHeaderGeneratedIdentifier(4291);
    creditMemoDocument.setCreditMemoNumber("12345");
    creditMemoDocument.setCreditMemoDate(dateTimeService.getCurrentSqlDate());
    creditMemoDocument.setCreditMemoAmount(new KualiDecimal(100));
    return creditMemoDocument;
}
Also used : CuVendorCreditMemoDocument(edu.cornell.kfs.module.purap.document.CuVendorCreditMemoDocument) ArrayList(java.util.ArrayList) KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal) Method(java.lang.reflect.Method)

Example 7 with CuVendorCreditMemoDocument

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

the class CuAccountsPayableBankCodeValidation method validate.

@Override
public boolean validate(AttributedDocumentEvent event) {
    AccountsPayableDocumentBase apDocument = (AccountsPayableDocumentBase) getAccountingDocumentForValidation();
    // check if one of the extended UA documents, if so, take the payment method into account, otherwise, revert to baseline behavior
    boolean isValid = true;
    if (apDocument instanceof PaymentRequestDocument) {
        if (StringUtils.isNotBlank(apDocument.getBankCode())) {
            // PREQ bank code is not required
            isValid = CuBankCodeValidation.validate(apDocument.getBankCode(), "document." + PurapPropertyConstants.BANK_CODE, ((CuPaymentRequestDocument) apDocument).getPaymentMethodCode(), false, true);
            if (isValid) {
                if (!(event instanceof AttributedRouteDocumentEvent) && StringUtils.isNotBlank(apDocument.getBankCode()) && !CuBankCodeValidation.doesBankCodeNeedToBePopulated(((CuPaymentRequestDocument) apDocument).getPaymentMethodCode())) {
                    apDocument.setBank(null);
                    apDocument.setBankCode(null);
                }
            }
        }
    } else if (apDocument instanceof VendorCreditMemoDocument) {
        if (StringUtils.isNotBlank(apDocument.getBankCode())) {
            isValid = CuBankCodeValidation.validate(apDocument.getBankCode(), "document." + PurapPropertyConstants.BANK_CODE, ((CuVendorCreditMemoDocument) apDocument).getPaymentMethodCode(), false, true);
            if (isValid) {
                // clear out the bank code on the document if not needed (per the message set by the call above)
                if (StringUtils.isNotBlank(apDocument.getBankCode()) && !CuBankCodeValidation.doesBankCodeNeedToBePopulated(((CuVendorCreditMemoDocument) apDocument).getPaymentMethodCode())) {
                    apDocument.setBank(null);
                    apDocument.setBankCode(null);
                }
            }
        }
    } else {
        isValid = CuBankCodeValidation.validate(apDocument.getBankCode(), "document." + PurapPropertyConstants.BANK_CODE, false, true);
    }
    return isValid;
}
Also used : AccountsPayableDocumentBase(org.kuali.kfs.module.purap.document.AccountsPayableDocumentBase) CuVendorCreditMemoDocument(edu.cornell.kfs.module.purap.document.CuVendorCreditMemoDocument) VendorCreditMemoDocument(org.kuali.kfs.module.purap.document.VendorCreditMemoDocument) AttributedRouteDocumentEvent(org.kuali.kfs.sys.document.validation.event.AttributedRouteDocumentEvent) CuVendorCreditMemoDocument(edu.cornell.kfs.module.purap.document.CuVendorCreditMemoDocument) CuPaymentRequestDocument(edu.cornell.kfs.module.purap.document.CuPaymentRequestDocument) PaymentRequestDocument(org.kuali.kfs.module.purap.document.PaymentRequestDocument) CuPaymentRequestDocument(edu.cornell.kfs.module.purap.document.CuPaymentRequestDocument)

Aggregations

CuVendorCreditMemoDocument (edu.cornell.kfs.module.purap.document.CuVendorCreditMemoDocument)7 VendorCreditMemoDocument (org.kuali.kfs.module.purap.document.VendorCreditMemoDocument)3 CreditMemoWireTransfer (edu.cornell.kfs.module.purap.businessobject.CreditMemoWireTransfer)2 MessageMap (org.kuali.kfs.krad.util.MessageMap)2 CuPaymentRequestDocument (edu.cornell.kfs.module.purap.document.CuPaymentRequestDocument)1 VendorDetailExtension (edu.cornell.kfs.vnd.businessobject.VendorDetailExtension)1 Method (java.lang.reflect.Method)1 ArrayList (java.util.ArrayList)1 DocumentHelperService (org.kuali.kfs.kns.service.DocumentHelperService)1 DocumentAuthorizer (org.kuali.kfs.krad.document.DocumentAuthorizer)1 AccountsPayableDocumentBase (org.kuali.kfs.module.purap.document.AccountsPayableDocumentBase)1 PaymentRequestDocument (org.kuali.kfs.module.purap.document.PaymentRequestDocument)1 VendorCreditMemoForm (org.kuali.kfs.module.purap.document.web.struts.VendorCreditMemoForm)1 ExpiredOrClosedAccountEntry (org.kuali.kfs.module.purap.util.ExpiredOrClosedAccountEntry)1 AttributedRouteDocumentEvent (org.kuali.kfs.sys.document.validation.event.AttributedRouteDocumentEvent)1 VendorDetail (org.kuali.kfs.vnd.businessobject.VendorDetail)1 ConfigurationService (org.kuali.rice.core.api.config.property.ConfigurationService)1 KualiDecimal (org.kuali.rice.core.api.util.type.KualiDecimal)1