Search in sources :

Example 1 with CuVendorCreditMemoDocument

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

the class CuCreditMemoServiceImpl method populateDocumentAfterInit.

/**
 * @see org.kuali.kfs.module.purap.document.service.CreditMemoCreateService#populateDocumentAfterInit(org.kuali.kfs.module.purap.document.CreditMemoDocument)
 */
@Override
public void populateDocumentAfterInit(VendorCreditMemoDocument cmDocument) {
    // make a call to search for expired/closed accounts
    HashMap<String, ExpiredOrClosedAccountEntry> expiredOrClosedAccountList = accountsPayableService.getExpiredOrClosedAccountList(cmDocument);
    if (cmDocument.isSourceDocumentPaymentRequest()) {
        populateDocumentFromPreq(cmDocument, expiredOrClosedAccountList);
    } else if (cmDocument.isSourceDocumentPurchaseOrder()) {
        populateDocumentFromPO(cmDocument, expiredOrClosedAccountList);
    } else {
        populateDocumentFromVendor(cmDocument);
    }
    // KFSPTS-1891
    VendorDetail vendorDetail = vendorService.getVendorDetail(cmDocument.getVendorHeaderGeneratedIdentifier(), cmDocument.getVendorDetailAssignedIdentifier());
    if (ObjectUtils.isNotNull(vendorDetail) && ObjectUtils.isNotNull(vendorDetail.getExtension())) {
        if (vendorDetail.getExtension() instanceof VendorDetailExtension && StringUtils.isNotBlank(((VendorDetailExtension) vendorDetail.getExtension()).getDefaultB2BPaymentMethodCode())) {
            ((CuVendorCreditMemoDocument) cmDocument).setPaymentMethodCode(((VendorDetailExtension) vendorDetail.getExtension()).getDefaultB2BPaymentMethodCode());
        }
    }
    populateDocumentDescription(cmDocument);
    // write a note for expired/closed accounts if any exist and add a message stating there were expired/closed accounts at the
    // top of the document
    accountsPayableService.generateExpiredOrClosedAccountNote(cmDocument, expiredOrClosedAccountList);
    // set indicator so a message is displayed for accounts that were replaced due to expired/closed status
    if (ObjectUtils.isNotNull(expiredOrClosedAccountList) && !expiredOrClosedAccountList.isEmpty()) {
        cmDocument.setContinuationAccountIndicator(true);
    }
}
Also used : VendorDetail(org.kuali.kfs.vnd.businessobject.VendorDetail) CuVendorCreditMemoDocument(edu.cornell.kfs.module.purap.document.CuVendorCreditMemoDocument) VendorDetailExtension(edu.cornell.kfs.vnd.businessobject.VendorDetailExtension) ExpiredOrClosedAccountEntry(org.kuali.kfs.module.purap.util.ExpiredOrClosedAccountEntry)

Example 2 with CuVendorCreditMemoDocument

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

the class CuVendorCreditMemoAction method calculate.

@Override
public ActionForward calculate(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    VendorCreditMemoForm cmForm = (VendorCreditMemoForm) form;
    CuVendorCreditMemoDocument creditMemoDocument = (CuVendorCreditMemoDocument) cmForm.getDocument();
    if (creditMemoDocument.getDocumentHeader().getWorkflowDocument().isInitiated() || creditMemoDocument.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(creditMemoDocument);
        if (!docAuth.isAuthorizedByTemplate(creditMemoDocument, KFSConstants.ParameterNamespaces.KFS, KFSConstants.PermissionTemplate.EDIT_BANK_CODE.name, GlobalVariables.getUserSession().getPrincipalId())) {
            creditMemoDocument.synchronizeBankCodeWithPaymentMethod();
        } else {
            // ensure that the name is updated properly
            creditMemoDocument.refreshReferenceObject("bank");
        }
    }
    return super.calculate(mapping, form, request, response);
}
Also used : CuVendorCreditMemoDocument(edu.cornell.kfs.module.purap.document.CuVendorCreditMemoDocument) DocumentAuthorizer(org.kuali.kfs.krad.document.DocumentAuthorizer) VendorCreditMemoForm(org.kuali.kfs.module.purap.document.web.struts.VendorCreditMemoForm) DocumentHelperService(org.kuali.kfs.kns.service.DocumentHelperService)

Example 3 with CuVendorCreditMemoDocument

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

the class CreditMemoForeignDraftValidation method validate.

/**
 * @see org.kuali.kfs.sys.document.validation.Validation#validate(org.kuali.kfs.sys.document.validation.event.AttributedDocumentEvent)
 */
public boolean validate(AttributedDocumentEvent event) {
    if (LOG.isDebugEnabled()) {
        LOG.debug("validate start");
    }
    boolean isValid = true;
    VendorCreditMemoDocument document = (VendorCreditMemoDocument) accountingDocumentForValidation;
    if (!PaymentMethod.PM_CODE_FOREIGN_DRAFT.equals(((CuVendorCreditMemoDocument) document).getPaymentMethodCode())) {
        return true;
    }
    MessageMap errors = GlobalVariables.getMessageMap();
    errors.addToErrorPath(KFSPropertyConstants.DOCUMENT);
    errors.addToErrorPath(CUPurapPropertyConstants.CM_WIRE_TRANSFER);
    /* currency type code required */
    if (StringUtils.isBlank(((CuVendorCreditMemoDocument) document).getCmWireTransfer().getCmForeignCurrencyTypeCode())) {
        errors.putError(CUPurapPropertyConstants.CM_FD_CURRENCY_TYPE_CODE, KFSKeyConstants.ERROR_PAYMENT_SOURCE_CURRENCY_TYPE_CODE);
        isValid = false;
    }
    /* currency type name required */
    if (StringUtils.isBlank(((CuVendorCreditMemoDocument) document).getCmWireTransfer().getCmForeignCurrencyTypeName())) {
        errors.putError(CUPurapPropertyConstants.CM_FD_CURRENCY_TYPE_NAME, KFSKeyConstants.ERROR_PAYMENT_SOURCE_CURRENCY_TYPE_NAME);
        isValid = false;
    }
    errors.removeFromErrorPath(CUPurapPropertyConstants.CM_WIRE_TRANSFER);
    errors.removeFromErrorPath(KFSPropertyConstants.DOCUMENT);
    return isValid;
}
Also used : CuVendorCreditMemoDocument(edu.cornell.kfs.module.purap.document.CuVendorCreditMemoDocument) VendorCreditMemoDocument(org.kuali.kfs.module.purap.document.VendorCreditMemoDocument) CuVendorCreditMemoDocument(edu.cornell.kfs.module.purap.document.CuVendorCreditMemoDocument) MessageMap(org.kuali.kfs.krad.util.MessageMap)

Example 4 with CuVendorCreditMemoDocument

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

the class CreditMemoWireTransferValidation method validate.

/**
 * @see org.kuali.kfs.sys.document.validation.Validation#validate(org.kuali.kfs.sys.document.validation.event.AttributedDocumentEvent)
 */
public boolean validate(AttributedDocumentEvent event) {
    if (LOG.isDebugEnabled()) {
        LOG.debug("validate start");
    }
    boolean isValid = true;
    VendorCreditMemoDocument document = (VendorCreditMemoDocument) accountingDocumentForValidation;
    CreditMemoWireTransfer wireTransfer = ((CuVendorCreditMemoDocument) document).getCmWireTransfer();
    if (!PaymentMethod.PM_CODE_WIRE.equals(((CuVendorCreditMemoDocument) document).getPaymentMethodCode())) {
        return isValid;
    }
    MessageMap errors = GlobalVariables.getMessageMap();
    errors.addToErrorPath(KFSPropertyConstants.DOCUMENT);
    errors.addToErrorPath(CUPurapPropertyConstants.CM_WIRE_TRANSFER);
    isValid &= isValid(wireTransfer.getCmBankName(), CUPurapConstants.LABEL_BANK_NAME, CUPurapPropertyConstants.CM_BANK_NAME);
    isValid &= isValid(wireTransfer.getCmBankCityName(), CUPurapConstants.LABEL_BANK_CITY, CUPurapPropertyConstants.CM_BANK_CITY_NAME);
    isValid &= isValid(wireTransfer.getCmBankCountryCode(), CUPurapConstants.LABEL_BANK_COUNTRY, CUPurapPropertyConstants.CM_BANK_COUNTRY_CODE);
    isValid &= isValid(wireTransfer.getCmCurrencyTypeName(), CUPurapConstants.LABEL_CURRENCY, CUPurapPropertyConstants.CM_CURRENCY_TYPE_NAME);
    isValid &= isValid(wireTransfer.getCmPayeeAccountNumber(), CUPurapConstants.LABEL_BANK_ACCT_NUMBER, CUPurapPropertyConstants.CM_PAYEE_ACCT_NUMBER);
    isValid &= isValid(wireTransfer.getCmPayeeAccountName(), CUPurapConstants.LABEL_BANK_ACCT_NAME, CUPurapPropertyConstants.CM_PAYEE_ACCT_NAME);
    if (KFSConstants.COUNTRY_CODE_UNITED_STATES.equals(wireTransfer.getCmBankCountryCode()) && StringUtils.isBlank(wireTransfer.getCmBankRoutingNumber())) {
        errors.putError(CUPurapPropertyConstants.CM_BANK_ROUTING_NUMBER, KFSKeyConstants.ERROR_PAYMENT_SOURCE_BANK_ROUTING_NUMBER);
        isValid = false;
    }
    if (KFSConstants.COUNTRY_CODE_UNITED_STATES.equals(wireTransfer.getCmBankCountryCode()) && StringUtils.isBlank(wireTransfer.getCmBankStateCode())) {
        errors.putError(CUPurapPropertyConstants.CM_BANK_STATE_CODE, KFSKeyConstants.ERROR_REQUIRED, "Bank State");
        isValid = false;
    }
    errors.removeFromErrorPath(CUPurapPropertyConstants.CM_WIRE_TRANSFER);
    errors.removeFromErrorPath(KFSPropertyConstants.DOCUMENT);
    return isValid;
}
Also used : CuVendorCreditMemoDocument(edu.cornell.kfs.module.purap.document.CuVendorCreditMemoDocument) VendorCreditMemoDocument(org.kuali.kfs.module.purap.document.VendorCreditMemoDocument) CuVendorCreditMemoDocument(edu.cornell.kfs.module.purap.document.CuVendorCreditMemoDocument) CreditMemoWireTransfer(edu.cornell.kfs.module.purap.businessobject.CreditMemoWireTransfer) MessageMap(org.kuali.kfs.krad.util.MessageMap)

Example 5 with CuVendorCreditMemoDocument

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

the class CuCreditMemoDocumentPreRules method checkWireTransferTabState.

// KFSUPGRADE-779
protected boolean checkWireTransferTabState(VendorCreditMemoDocument cmDocument) {
    boolean tabStatesOK = true;
    CreditMemoWireTransfer cmWireTransfer = ((CuVendorCreditMemoDocument) cmDocument).getCmWireTransfer();
    // if payment method is CHECK and wire tab contains data, ask user to clear tab
    if (!StringUtils.equals(PaymentMethod.PM_CODE_WIRE, ((CuVendorCreditMemoDocument) cmDocument).getPaymentMethodCode()) && hasWireTransferValues(cmWireTransfer)) {
        String questionText = SpringContext.getBean(ConfigurationService.class).getPropertyValueAsString(CUKFSKeyConstants.QUESTION_CLEAR_UNNEEDED_CM_WIRW_TAB);
        Object[] args = { CUPurapConstants.PAYMENT_METHOD, ((CuVendorCreditMemoDocument) cmDocument).getPaymentMethodCode(), CUPurapConstants.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(cmWireTransfer);
        } 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 : CuVendorCreditMemoDocument(edu.cornell.kfs.module.purap.document.CuVendorCreditMemoDocument) CreditMemoWireTransfer(edu.cornell.kfs.module.purap.businessobject.CreditMemoWireTransfer) ConfigurationService(org.kuali.rice.core.api.config.property.ConfigurationService)

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