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);
}
}
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);
}
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;
}
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;
}
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;
}
Aggregations