use of org.kuali.kfs.module.purap.document.PaymentRequestDocument 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 org.kuali.kfs.module.purap.document.PaymentRequestDocument in project cu-kfs by CU-CommunityApps.
the class CuBatchExtractServiceImpl method findPaymentRequestDocument.
/**
* Retrieves a payment request document for a specific document number
*
* @param entry GL Line
* @return PaymentRequestDocument
*/
@Override
protected PaymentRequestDocument findPaymentRequestDocument(Entry entry) {
PaymentRequestDocument paymentRequestDocument = null;
Map<String, String> keys = new LinkedHashMap<String, String>();
keys.put(CamsPropertyConstants.DOCUMENT_NUMBER, entry.getDocumentNumber());
Class<? extends Document> docClass = dataDictionaryService.getDocumentClassByTypeName(PurapConstants.PurapDocTypeCodes.PAYMENT_REQUEST_DOCUMENT);
Collection<? extends Document> matchingPreqs = businessObjectService.findMatching(docClass, keys);
if (matchingPreqs != null && matchingPreqs.size() == 1) {
paymentRequestDocument = (PaymentRequestDocument) matchingPreqs.iterator().next();
}
return paymentRequestDocument;
}
use of org.kuali.kfs.module.purap.document.PaymentRequestDocument in project cu-kfs by CU-CommunityApps.
the class CuPendingTransactionServiceImpl method reverseSourceDocumentsEntries.
/**
* Reverses the entries of the source documents
*
* @param paymentDetail
* @param sequenceHelper
*/
protected void reverseSourceDocumentsEntries(PaymentDetail paymentDetail, GeneralLedgerPendingEntrySequenceHelper sequenceHelper) {
// Need to reverse the payment document's GL entries if the check is stopped or cancelled
if (PurapConstants.PurapDocTypeCodes.PAYMENT_REQUEST_DOCUMENT.equalsIgnoreCase(paymentDetail.getFinancialDocumentTypeCode()) || CUPdpConstants.PdpDocumentTypes.DISBURSEMENT_VOUCHER.equalsIgnoreCase(paymentDetail.getFinancialDocumentTypeCode()) || CUPdpConstants.PdpDocumentTypes.CREDIT_MEMO.equalsIgnoreCase(paymentDetail.getFinancialDocumentTypeCode())) {
try {
String sourceDocumentNumber = paymentDetail.getCustPaymentDocNbr();
try {
Long.valueOf(sourceDocumentNumber);
} catch (NumberFormatException nfe) {
sourceDocumentNumber = null;
}
if (sourceDocumentNumber != null && StringUtils.isNotBlank(sourceDocumentNumber)) {
Document doc = (AccountingDocumentBase) SpringContext.getBean(DocumentService.class).getByDocumentHeaderId(paymentDetail.getCustPaymentDocNbr());
if (ObjectUtils.isNotNull(doc)) {
if (doc instanceof DisbursementVoucherDocument) {
// KFSUPGRADE-775
DisbursementVoucherDocument dv = (DisbursementVoucherDocument) doc;
generateDisbursementVoucherReversalEntries(dv, sequenceHelper);
// end KFSUPGRADE-775
} else if (doc instanceof VendorCreditMemoDocument) {
// KFSPTS-2719
String crCmCancelNote = parameterService.getParameterValueAsString(VendorCreditMemoDocument.class, CUPurapParameterConstants.PURAP_CR_CM_CANCEL_NOTE);
VendorCreditMemoDocument cmDocument = (VendorCreditMemoDocument) doc;
String crCancelMaintDocNbr = getCrCancelMaintenancedocumentNumber(paymentDetail);
crCmCancelNote = crCmCancelNote + crCancelMaintDocNbr;
try {
Note noteObj = documentService.createNoteFromDocument(cmDocument, crCmCancelNote);
cmDocument.addNote(noteObj);
noteService.save(noteObj);
} catch (Exception e) {
throw new RuntimeException(e.getMessage());
}
// KFSUPGRADE-775
VendorCreditMemoDocument cm = (VendorCreditMemoDocument) doc;
AccountsPayableDocumentSpecificService accountsPayableDocumentSpecificService = cm.getDocumentSpecificService();
accountsPayableDocumentSpecificService.updateStatusByNode("", cm);
// end KFSUPGRADE-775
generateCreditMemoReversalEntries((VendorCreditMemoDocument) doc);
} else if (doc instanceof PaymentRequestDocument) {
// KFSPTS-2719
String crPreqCancelNote = parameterService.getParameterValueAsString(PaymentRequestDocument.class, CUPurapParameterConstants.PURAP_CR_PREQ_CANCEL_NOTE);
PaymentRequestDocument paymentRequest = (PaymentRequestDocument) doc;
String crCancelMaintDocNbr = getCrCancelMaintenancedocumentNumber(paymentDetail);
crPreqCancelNote = crPreqCancelNote + crCancelMaintDocNbr;
try {
Note cancelNote = documentService.createNoteFromDocument(paymentRequest, crPreqCancelNote);
paymentRequest.addNote(cancelNote);
noteService.save(cancelNote);
} catch (Exception e) {
throw new RuntimeException(PurapConstants.REQ_UNABLE_TO_CREATE_NOTE + " " + e);
}
// cancel extracted should not reopen PO
paymentRequest.setReopenPurchaseOrderIndicator(false);
// KFSUPGRADE-775
AccountsPayableDocumentSpecificService accountsPayableDocumentSpecificService = paymentRequest.getDocumentSpecificService();
accountsPayableDocumentSpecificService.updateStatusByNode("", paymentRequest);
// end KFSUPGRADE-775
generatePaymentRequestReversalEntries(paymentRequest);
}
}
}
} catch (WorkflowException we) {
System.out.println("Exception retrieving document " + paymentDetail.getCustPaymentDocNbr());
}
}
}
use of org.kuali.kfs.module.purap.document.PaymentRequestDocument in project cu-kfs by CU-CommunityApps.
the class CuPaymentRequestServiceImplTest method testRemoveHoldOnPaymentRequest.
public void testRemoveHoldOnPaymentRequest() throws Exception {
changeCurrentUser(UserNameFixture.ccs1);
PurchaseOrderDocument po = PurchaseOrderFixture.PO_NON_B2B_OPEN.createPurchaseOrderdDocument(SpringContext.getBean(DocumentService.class));
po.setVendorShippingPaymentTermsCode("AL");
po.setVendorPaymentTermsCode("00N30");
po.refreshNonUpdateableReferences();
changeCurrentUser(UserNameFixture.mo14);
PaymentRequestDocument paymentRequestDocument = PaymentRequestFixture.PAYMENT_REQ_DOC.createPaymentRequestDocument(po.getPurapDocumentIdentifier());
paymentRequestDocument.initiateDocument();
paymentRequestDocument.populatePaymentRequestFromPurchaseOrder(po);
paymentRequestDocument.prepareForSave();
AccountingDocumentTestUtils.saveDocument(paymentRequestDocument, SpringContext.getBean(DocumentService.class));
paymentRequestService.removeHoldOnPaymentRequest(paymentRequestDocument, "test");
assertFalse(paymentRequestDocument.isHoldIndicator());
assertNull(paymentRequestDocument.getLastActionPerformedByPersonId());
}
use of org.kuali.kfs.module.purap.document.PaymentRequestDocument in project cu-kfs by CU-CommunityApps.
the class CuPaymentRequestServiceImplTest method testRemoveRequestCancelOnPaymentRequest.
public void testRemoveRequestCancelOnPaymentRequest() throws Exception {
changeCurrentUser(UserNameFixture.ccs1);
PurchaseOrderDocument po = PurchaseOrderFixture.PO_NON_B2B_OPEN.createPurchaseOrderdDocument(SpringContext.getBean(DocumentService.class));
po.setVendorShippingPaymentTermsCode("AL");
po.setVendorPaymentTermsCode("00N30");
po.refreshNonUpdateableReferences();
changeCurrentUser(UserNameFixture.mo14);
PaymentRequestDocument paymentRequestDocument = PaymentRequestFixture.PAYMENT_REQ_DOC.createPaymentRequestDocument(po.getPurapDocumentIdentifier());
paymentRequestDocument.initiateDocument();
paymentRequestDocument.populatePaymentRequestFromPurchaseOrder(po);
paymentRequestDocument.prepareForSave();
AccountingDocumentTestUtils.saveDocument(paymentRequestDocument, SpringContext.getBean(DocumentService.class));
paymentRequestService.removeRequestCancelOnPaymentRequest(paymentRequestDocument, "test");
assertFalse(paymentRequestDocument.isPaymentRequestedCancelIndicator());
assertNull(paymentRequestDocument.getLastActionPerformedByPersonId());
assertNull(paymentRequestDocument.getAccountsPayableRequestCancelIdentifier());
}
Aggregations