use of org.kuali.rice.kim.api.identity.Person in project cu-kfs by CU-CommunityApps.
the class SubmitTripWebServiceImpl method isValidDocumentInitiator.
/**
* NOTE: The current document names that are supported by KFS are
* - Disbursement Voucher
* - Distribution of Income and Expense
*/
public boolean isValidDocumentInitiator(String initiatorNetId, String documentName) throws Exception {
Person initiator = SpringContext.getBean(PersonService.class).getPersonByPrincipalName(initiatorNetId);
Class docClass;
if (StringUtils.equalsIgnoreCase(documentName, "Disbursement Voucher")) {
docClass = DisbursementVoucherDocument.class;
} else if (StringUtils.equalsIgnoreCase(documentName, "Distribution of Income and Expense")) {
docClass = CuDistributionOfIncomeAndExpenseDocument.class;
}
String documentTypeName = SpringContext.getBean(DataDictionaryService.class).getDocumentTypeNameByClass(DisbursementVoucherDocument.class);
DocumentAuthorizer documentAuthorizer = SpringContext.getBean(DocumentHelperService.class).getDocumentAuthorizer(documentTypeName);
return documentAuthorizer.canInitiate(documentTypeName, initiator);
}
use of org.kuali.rice.kim.api.identity.Person in project cu-kfs by CU-CommunityApps.
the class CuDisbursementVoucherDocument method initiateDocument.
public void initiateDocument() {
PhoneNumberService phoneNumberService = SpringContext.getBean(PhoneNumberService.class);
Person currentUser = GlobalVariables.getUserSession().getPerson();
setDisbVchrContactPersonName(currentUser.getName());
setDisbVchrContactEmailId(currentUser.getEmailAddressUnmasked());
String phoneNumber = currentUser.getPhoneNumber();
if (StringUtils.isNotBlank(phoneNumber) && !StringUtils.equalsIgnoreCase("null", phoneNumber)) {
if (!phoneNumberService.isDefaultFormatPhoneNumber(currentUser.getPhoneNumber())) {
setDisbVchrContactPhoneNumber(phoneNumberService.formatNumberIfPossible(currentUser.getPhoneNumber()));
} else if (StringUtils.equalsIgnoreCase(phoneNumber, "null")) {
// do nothing... we don't want phone number set to invalid value
} else {
setDisbVchrContactPhoneNumber(phoneNumber);
}
}
if (!phoneNumberService.isDefaultFormatPhoneNumber(currentUser.getPhoneNumber())) {
setDisbVchrContactPhoneNumber(phoneNumberService.formatNumberIfPossible(currentUser.getPhoneNumber()));
}
setDisbVchrContactEmailId(currentUser.getEmailAddress());
ChartOrgHolder chartOrg = SpringContext.getBean(org.kuali.kfs.sys.service.FinancialSystemUserService.class).getPrimaryOrganization(currentUser, KFSConstants.ParameterNamespaces.FINANCIAL);
// the campus code via the business object service.
if (chartOrg != null && chartOrg.getOrganization() != null) {
setCampusCode(chartOrg.getOrganization().getOrganizationPhysicalCampusCode());
} else // A valid campus code was not found; therefore, use the default affiliated
// campus code.
{
String affiliatedCampusCode = currentUser.getCampusCode();
setCampusCode(affiliatedCampusCode);
}
// due date
Calendar calendar = getDateTimeService().getCurrentCalendar();
calendar.add(Calendar.DAY_OF_MONTH, 1);
setDisbursementVoucherDueDate(new Date(calendar.getTimeInMillis()));
// default doc location
if (StringUtils.isBlank(getDisbursementVoucherDocumentationLocationCode())) {
setDisbursementVoucherDocumentationLocationCode(getParameterService().getParameterValueAsString(DisbursementVoucherDocument.class, DisbursementVoucherConstants.DEFAULT_DOC_LOCATION_PARM_NM));
}
// default bank code
Bank defaultBank = SpringContext.getBean(BankService.class).getDefaultBankByDocType(this.getClass());
if (defaultBank != null) {
this.disbVchrBankCode = defaultBank.getBankCode();
this.bank = defaultBank;
}
}
use of org.kuali.rice.kim.api.identity.Person 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 org.kuali.rice.kim.api.identity.Person 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 org.kuali.rice.kim.api.identity.Person in project cu-kfs by CU-CommunityApps.
the class DisbursementVoucherAction method setupPayeeAsEmployee.
/**
* setup the payee as an employee with the given id number
*/
protected void setupPayeeAsEmployee(DisbursementVoucherForm dvForm, String payeeIdNumber) {
Person person = SpringContext.getBean(PersonService.class).getPersonByEmployeeId(payeeIdNumber);
if (person != null) {
((DisbursementVoucherDocument) dvForm.getDocument()).templateEmployee(person);
dvForm.setTempPayeeIdNumber(payeeIdNumber);
dvForm.setOldPayeeType(KFSConstants.PaymentPayeeTypes.EMPLOYEE);
} else {
LOG.error("Exception while attempting to retrieve universal user by universal user id " + payeeIdNumber);
}
}
Aggregations