Search in sources :

Example 1 with PaymentRequestWireTransfer

use of edu.cornell.kfs.module.purap.businessobject.PaymentRequestWireTransfer 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 PaymentRequestWireTransfer

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

the class CuPaymentRequestDocument method getPreqWireTransfer.

public PaymentRequestWireTransfer getPreqWireTransfer() {
    if (ObjectUtils.isNull(preqWireTransfer)) {
        preqWireTransfer = new PaymentRequestWireTransfer();
        preqWireTransfer.setDocumentNumber(this.getDocumentNumber());
    }
    return preqWireTransfer;
}
Also used : PaymentRequestWireTransfer(edu.cornell.kfs.module.purap.businessobject.PaymentRequestWireTransfer)

Example 3 with PaymentRequestWireTransfer

use of edu.cornell.kfs.module.purap.businessobject.PaymentRequestWireTransfer 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 4 with PaymentRequestWireTransfer

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

the class CuPaymentRequestDocumentPreRules method checkWireTransferTabState.

protected boolean checkWireTransferTabState(PaymentRequestDocument preqDocument) {
    boolean tabStatesOK = true;
    PaymentRequestWireTransfer preqWireTransfer = ((CuPaymentRequestDocument) preqDocument).getPreqWireTransfer();
    // if payment method is CHECK and wire tab contains data, ask user to clear tab
    if (!StringUtils.equals(PaymentMethod.PM_CODE_WIRE, ((CuPaymentRequestDocument) preqDocument).getPaymentMethodCode()) && hasWireTransferValues(preqWireTransfer)) {
        String questionText = SpringContext.getBean(ConfigurationService.class).getPropertyValueAsString(CUKFSKeyConstants.QUESTION_CLEAR_UNNEEDED_WIRW_TAB);
        Object[] args = { "payment method", ((CuPaymentRequestDocument) preqDocument).getPaymentMethodCode(), "Wire Transfer", PaymentMethod.PM_CODE_WIRE };
        questionText = MessageFormat.format(questionText, args);
        boolean clearTab = super.askOrAnalyzeYesNoQuestion(KFSConstants.DisbursementVoucherDocumentConstants.CLEAR_WIRE_TRANSFER_TAB_QUESTION_ID, questionText);
        if (clearTab) {
            // NOTE: Can't replace with new instance because Foreign Draft uses same object
            clearWireTransferValues(preqWireTransfer);
        } else {
            // return to document if the user doesn't want to clear the Wire Transfer tab
            super.event.setActionForwardName(KFSConstants.MAPPING_BASIC);
            tabStatesOK = false;
        }
    }
    return tabStatesOK;
}
Also used : PaymentRequestWireTransfer(edu.cornell.kfs.module.purap.businessobject.PaymentRequestWireTransfer) CuPaymentRequestDocument(edu.cornell.kfs.module.purap.document.CuPaymentRequestDocument) ConfigurationService(org.kuali.rice.core.api.config.property.ConfigurationService)

Aggregations

PaymentRequestWireTransfer (edu.cornell.kfs.module.purap.businessobject.PaymentRequestWireTransfer)4 CuPaymentRequestDocument (edu.cornell.kfs.module.purap.document.CuPaymentRequestDocument)2 CuPaymentRequestItemExtension (edu.cornell.kfs.module.purap.businessobject.CuPaymentRequestItemExtension)1 List (java.util.List)1 DocumentAuthorizer (org.kuali.kfs.kns.document.authorization.DocumentAuthorizer)1 DocumentHelperService (org.kuali.kfs.kns.service.DocumentHelperService)1 MessageMap (org.kuali.kfs.krad.util.MessageMap)1 PaymentRequestItem (org.kuali.kfs.module.purap.businessobject.PaymentRequestItem)1 PaymentRequestDocument (org.kuali.kfs.module.purap.document.PaymentRequestDocument)1 ConfigurationService (org.kuali.rice.core.api.config.property.ConfigurationService)1 WorkflowException (org.kuali.rice.kew.api.exception.WorkflowException)1