use of edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument in project cu-kfs by CU-CommunityApps.
the class RecurringDisbursementVoucherDocumentServiceImpl method buildCuDisbursementVoucherDocument.
private CuDisbursementVoucherDocument buildCuDisbursementVoucherDocument(RecurringDisbursementVoucherDocument recurringDV) throws WorkflowException {
CuDisbursementVoucherDocument dv = (CuDisbursementVoucherDocument) getDocumentService().getNewDocument(CuDisbursementVoucherDocument.class);
dv.setDisbVchrContactPersonName(recurringDV.getDisbVchrContactPersonName());
dv.setDisbVchrContactPhoneNumber(recurringDV.getDisbVchrContactPhoneNumber());
dv.setDisbVchrContactEmailId(recurringDV.getDisbVchrContactEmailId());
dv.setDisbVchrAttachmentCode(recurringDV.isDisbVchrAttachmentCode());
dv.setDisbVchrSpecialHandlingCode(recurringDV.isDisbVchrSpecialHandlingCode());
dv.setDisbVchrForeignCurrencyInd(recurringDV.isDisbVchrForeignCurrencyInd());
dv.setDisbursementVoucherDocumentationLocationCode(recurringDV.getDisbursementVoucherDocumentationLocationCode());
dv.setDisbVchrCheckStubText(recurringDV.getDisbVchrCheckStubText());
dv.setDvCheckStubOverflowCode(recurringDV.getDvCheckStubOverflowCode());
dv.setCampusCode(recurringDV.getCampusCode());
dv.setDisbVchrPayeeTaxControlCode(recurringDV.getDisbVchrPayeeTaxControlCode());
dv.setDisbVchrPayeeChangedInd(recurringDV.isDisbVchrPayeeChangedInd());
dv.setExceptionIndicator(recurringDV.isExceptionIndicator());
dv.setDisbursementVoucherPdpStatus(recurringDV.getDisbursementVoucherPdpStatus());
dv.setDisbVchrBankCode(recurringDV.getDisbVchrBankCode());
dv.setPayeeAssigned(recurringDV.isPayeeAssigned());
dv.setEditW9W8BENbox(recurringDV.isEditW9W8BENbox());
dv.setDisbVchrPdpBankCode(recurringDV.getDisbVchrPdpBankCode());
dv.setImmediatePaymentIndicator(recurringDV.isImmediatePaymentIndicator());
dv.setDisbExcptAttachedIndicator(recurringDV.isDisbExcptAttachedIndicator());
dv.setDisbVchrPayeeW9CompleteCode(recurringDV.getDisbVchrPayeeW9CompleteCode());
dv.setDisbVchrPaymentMethodCode(recurringDV.getDisbVchrPaymentMethodCode());
CuDisbursementVoucherPayeeDetail payeeDetail = (CuDisbursementVoucherPayeeDetail) ObjectUtils.deepCopy(recurringDV.getDvPayeeDetail());
payeeDetail.setDocumentNumber(dv.getDocumentNumber());
dv.setDvPayeeDetail(payeeDetail);
PaymentSourceWireTransfer wireTransfer = (PaymentSourceWireTransfer) ObjectUtils.deepCopy(recurringDV.getWireTransfer());
wireTransfer.setDocumentNumber(dv.getDocumentNumber());
dv.setWireTransfer(wireTransfer);
DisbursementVoucherNonEmployeeTravel nonEmployeeTravel = (DisbursementVoucherNonEmployeeTravel) ObjectUtils.deepCopy(recurringDV.getDvNonEmployeeTravel());
nonEmployeeTravel.setDocumentNumber(dv.getDocumentNumber());
dv.setDvNonEmployeeTravel(nonEmployeeTravel);
DisbursementVoucherNonResidentAlienTax nonAlienTax = (DisbursementVoucherNonResidentAlienTax) ObjectUtils.deepCopy(recurringDV.getDvNonResidentAlienTax());
nonAlienTax.setDocumentNumber(dv.getDocumentNumber());
dv.setDvNonResidentAlienTax(nonAlienTax);
DisbursementVoucherPreConferenceDetail conferenceDetail = (DisbursementVoucherPreConferenceDetail) ObjectUtils.deepCopy(recurringDV.getDvPreConferenceDetail());
conferenceDetail.setDocumentNumber(dv.getDocumentNumber());
dv.setDvPreConferenceDetail(conferenceDetail);
return dv;
}
use of edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument in project cu-kfs by CU-CommunityApps.
the class RecurringDisbursementVoucherDocumentServiceImpl method autoApproveDisbursementVouchersSpawnedByRecurringDvs.
@Override
public boolean autoApproveDisbursementVouchersSpawnedByRecurringDvs() {
LOG.info("autoApproveDisbursementVouchersSpawnedByRecurringDvs: Entered.");
int approvalCount = 0;
int errorCount = 0;
List<String> dvDocIdsCausingError = new ArrayList<String>();
Collection<String> dvDocIds = getRecurringDisbursementVoucherSearchDao().findSavedDvIdsSpawnedByRecurringDvForCurrentAndPastFiscalPeriods(getCurrentFiscalPeriodEndDate());
if (ObjectUtils.isNotNull(dvDocIds) && !(dvDocIds.isEmpty())) {
for (String dvDocId : dvDocIds) {
LOG.info("autoApproveDisbursementVouchersSpawnedByRecurringDvs: Processing start for DV ID:: " + dvDocId);
CuDisbursementVoucherDocument dv = null;
try {
dv = getDisbursementVoucher(dvDocId);
} catch (WorkflowException e) {
dvDocIdsCausingError.add(new String("DocId=" + dvDocId));
errorCount++;
}
if (ObjectUtils.isNotNull(dv)) {
if (isKfsSystemUserDvInitiator(dv)) {
try {
addNoteToAutoApproveDv(dv, "Batch job Submit and Blanket Approve performed for DV spawned by Recurring DV.");
try {
blanketApproveDisbursementVoucherDocument(dv);
approvalCount++;
} catch (WorkflowException e) {
dvDocIdsCausingError.add(new String("DocId=" + dvDocId));
errorCount++;
}
} catch (WorkflowException e) {
dvDocIdsCausingError.add(new String("DocId=" + dvDocId));
errorCount++;
}
} else {
LOG.error("autoApproveDisbursementVouchersSpawnedByRecurringDvs: Detected document initiator was not KFS System user. Auto blanket approval was NOT attemtped for document ID: " + dv.getDocumentNumber());
dvDocIdsCausingError.add(new String("DocId=" + dvDocId));
errorCount++;
}
}
}
} else {
LOG.info("autoApproveDisbursementVouchersSpawnedByRecurringDvs: No DV's spwned by Recurring DV found. Nothing will be auto approved. ");
}
LOG.info("autoApproveDisbursementVouchersSpawnedByRecurringDvs: **************** Batch Job Processing Results ****************");
LOG.info("autoApproveDisbursementVouchersSpawnedByRecurringDvs: Number of Disbursement Vouchers that generated Errors:: " + errorCount);
for (Iterator iterator = dvDocIdsCausingError.iterator(); iterator.hasNext(); ) {
LOG.info("autoApproveDisbursementVouchersSpawnedByRecurringDvs: Erroring " + (String) iterator.next());
}
LOG.info("autoApproveDisbursementVouchersSpawnedByRecurringDvs: Number of Disbursement Vouchers successfuly Blanket Approved (fully processed):: " + approvalCount);
LOG.info("autoApproveDisbursementVouchersSpawnedByRecurringDvs: Leaving.");
return errorCount == 0;
}
use of edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument in project cu-kfs by CU-CommunityApps.
the class CuDisbursementVoucherEmployeeInformationValidation method validate.
public boolean validate(AttributedDocumentEvent event) {
LOG.debug("validate start");
boolean isValid = true;
CuDisbursementVoucherDocument document = (CuDisbursementVoucherDocument) getAccountingDocumentForValidation();
DisbursementVoucherPayeeDetail payeeDetail = document.getDvPayeeDetail();
if (!payeeDetail.isEmployee() || payeeDetail.isVendor() || !(document.getDocumentHeader().getWorkflowDocument().isInitiated() || document.getDocumentHeader().getWorkflowDocument().isSaved())) {
return true;
}
String employeeId = payeeDetail.getDisbVchrPayeeIdNumber();
Person employee = SpringContext.getBean(PersonService.class).getPersonByEmployeeId(employeeId);
MessageMap errors = GlobalVariables.getMessageMap();
errors.addToErrorPath(KFSPropertyConstants.DOCUMENT);
WorkflowDocument workflowDocument = document.getDocumentHeader().getWorkflowDocument();
boolean stateIsInitiated = workflowDocument.isInitiated() || workflowDocument.isSaved();
if (ObjectUtils.isNull(employee)) {
employee = SpringContext.getBean(PersonService.class).getPerson(employeeId);
} else {
if (!KFSConstants.EMPLOYEE_ACTIVE_STATUS.equals(employee.getEmployeeStatusCode()) && !CUKFSConstants.EMPLOYEE_RETIRED_STATUS.equals(employee.getEmployeeStatusCode())) {
// If employee is found, then check that employee is active or retired if the doc has not already been routed.
if (stateIsInitiated) {
String label = SpringContext.getBean(DataDictionaryService.class).getAttributeLabel(DisbursementVoucherPayeeDetail.class, KFSPropertyConstants.DISB_VCHR_PAYEE_ID_NUMBER);
errors.putError(DV_PAYEE_ID_NUMBER_PROPERTY_PATH, KFSKeyConstants.ERROR_INACTIVE, label);
isValid = false;
}
}
}
// check existence of employee
if (employee == null) {
// If employee is not found, report existence error
String label = SpringContext.getBean(DataDictionaryService.class).getAttributeLabel(DisbursementVoucherPayeeDetail.class, KFSPropertyConstants.DISB_VCHR_PAYEE_ID_NUMBER);
errors.putError(DV_PAYEE_ID_NUMBER_PROPERTY_PATH, KFSKeyConstants.ERROR_EXISTENCE, label);
isValid = false;
}
errors.removeFromErrorPath(KFSPropertyConstants.DOCUMENT);
return isValid;
}
use of edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument in project cu-kfs by CU-CommunityApps.
the class CuDisbursementVoucherPayeeInitiatorValidation method validate.
public boolean validate(AttributedDocumentEvent event) {
LOG.debug("validate start");
boolean isValid = true;
CuDisbursementVoucherDocument document = (CuDisbursementVoucherDocument) accountingDocumentForValidation;
CuDisbursementVoucherPayeeDetail payeeDetail = document.getDvPayeeDetail();
MessageMap errors = GlobalVariables.getMessageMap();
errors.addToErrorPath(KFSPropertyConstants.DOCUMENT);
String uuid = null;
// If payee is a vendor, then look up SSN and look for SSN in the employee table
if (payeeDetail.isVendor() && StringUtils.isNotBlank(payeeDetail.getDisbVchrVendorHeaderIdNumber())) {
VendorDetail dvVendor = retrieveVendorDetail(payeeDetail.getDisbVchrVendorHeaderIdNumberAsInteger(), payeeDetail.getDisbVchrVendorDetailAssignedIdNumberAsInteger());
// if the vendor tax type is SSN, then check the tax number
if (dvVendor != null && TAX_TYPE_SSN.equals(dvVendor.getVendorHeader().getVendorTaxTypeCode())) {
// check ssn against employee table
Person user = retrieveEmployeeBySSN(dvVendor.getVendorHeader().getVendorTaxNumber());
if (user != null) {
uuid = user.getPrincipalId();
}
}
} else if (payeeDetail.isEmployee()) {
Person employee = SpringContext.getBean(PersonService.class).getPersonByEmployeeId(payeeDetail.getDisbVchrEmployeeIdNumber());
uuid = employee.getPrincipalId();
} else if (payeeDetail.isStudent() || payeeDetail.isAlumni()) {
uuid = payeeDetail.getDisbVchrPayeeIdNumber();
}
// If a uuid was found for payee, check it against the initiator uuid
if (StringUtils.isNotBlank(uuid)) {
Person initUser = getInitiator(document);
if (uuid.equals(initUser.getPrincipalId())) {
errors.putError(DV_PAYEE_ID_NUMBER_PROPERTY_PATH, KFSKeyConstants.ERROR_PAYEE_INITIATOR);
isValid = false;
}
}
errors.removeFromErrorPath(KFSPropertyConstants.DOCUMENT);
return isValid;
}
use of edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument in project cu-kfs by CU-CommunityApps.
the class CuDisbursementVoucherAction method setupPayeeAsStudent.
/**
* setup the payee as an student with the given id number
*/
protected void setupPayeeAsStudent(CuDisbursementVoucherForm dvForm, String payeeIdNumber) {
Person person = (Person) SpringContext.getBean(PersonService.class).getPerson(payeeIdNumber);
if (person != null) {
((CuDisbursementVoucherDocument) dvForm.getDocument()).templateStudent(person);
dvForm.setTempPayeeIdNumber(payeeIdNumber);
dvForm.setOldPayeeType(CuDisbursementVoucherConstants.DV_PAYEE_TYPE_STUDENT);
} else {
LOG.error("Exception while attempting to retrieve universal user by universal user id " + payeeIdNumber);
}
}
Aggregations