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