use of org.kuali.rice.kim.api.identity.Person in project cu-kfs by CU-CommunityApps.
the class CuSubAccountPreRules method copyICRFromAccount.
@SuppressWarnings("deprecation")
protected void copyICRFromAccount(MaintenanceDocument document) {
Person user = GlobalVariables.getUserSession().getPerson();
// get a new instance of MaintenanceDocumentAuthorizations for this context
MaintenanceDocumentRestrictions auths = SpringContext.getBean(BusinessObjectAuthorizationService.class).getMaintenanceDocumentRestrictions(document, user);
// don't need to copy if the user does not have the authority to edit the fields
if (!auths.getFieldRestriction("a21SubAccount.financialIcrSeriesIdentifier").isReadOnly()) {
// only need to do this of the account sub type is EX
A21SubAccount a21SubAccount = newSubAccount.getA21SubAccount();
Account account = newSubAccount.getAccount();
if (KFSConstants.SubAccountType.EXPENSE.equals(a21SubAccount.getSubAccountTypeCode())) {
if (ObjectUtils.isNull(account) || StringUtils.isBlank(account.getAccountNumber())) {
account = getAccountService().getByPrimaryId(newSubAccount.getChartOfAccountsCode(), newSubAccount.getAccountNumber());
}
if (ObjectUtils.isNotNull(account)) {
if (a21SubAccount.getA21ActiveIndirectCostRecoveryAccounts().isEmpty()) {
for (IndirectCostRecoveryAccount icrAccount : account.getActiveIndirectCostRecoveryAccounts()) {
A21IndirectCostRecoveryAccount copyAccount = A21IndirectCostRecoveryAccount.copyICRAccount(icrAccount);
copyAccount.setNewCollectionRecord(true);
a21SubAccount.getA21IndirectCostRecoveryAccounts().add(copyAccount);
}
}
if (StringUtils.isBlank(a21SubAccount.getFinancialIcrSeriesIdentifier())) {
a21SubAccount.setFinancialIcrSeriesIdentifier(account.getFinancialIcrSeriesIdentifier());
}
if (StringUtils.isBlank(a21SubAccount.getIndirectCostRecoveryTypeCode())) {
a21SubAccount.setIndirectCostRecoveryTypeCode(account.getAcctIndirectCostRcvyTypeCd());
}
}
}
}
}
use of org.kuali.rice.kim.api.identity.Person in project cu-kfs by CU-CommunityApps.
the class ConcurEmployeeInfoValidationServiceImpl method validPdpAddress.
@Override
public boolean validPdpAddress(String employeeId) {
Person employee = findPerson(employeeId);
boolean validPerson = validPerson(employee);
boolean validAddress = validPerson;
if (validPerson) {
String state = employee.getAddressStateProvinceCodeUnmasked();
String country = employee.getAddressCountryCodeUnmasked();
if (StringUtils.isBlank(state) && StringUtils.isBlank(country)) {
validAddress = false;
LOG.error("validPdpAddress, " + employee.getName() + " does not have a Country Code or a State/Province code.");
} else {
if (LOG.isDebugEnabled()) {
StringBuilder sb = new StringBuilder("validPdpAddress, The employee ");
sb.append(employee.getName()).append(" has a valid PDP address. The state code was '").append(state);
sb.append("' and the country code was '").append(country).append("'.");
LOG.debug(sb.toString());
}
}
}
return validAddress;
}
use of org.kuali.rice.kim.api.identity.Person in project cu-kfs by CU-CommunityApps.
the class AccountingDocumentGeneratorBase method buildDocumentNote.
protected Note buildDocumentNote(AccountingXmlDocumentNote xmlNote) {
Person systemUser = personService.getPersonByPrincipalName(KFSConstants.SYSTEM_USER);
Note note = emptyNoteGenerator.get();
note.setNoteText(xmlNote.getDescription());
note.setAuthorUniversalIdentifier(systemUser.getPrincipalId());
note.setNotePostedTimestampToCurrent();
return note;
}
use of org.kuali.rice.kim.api.identity.Person in project cu-kfs by CU-CommunityApps.
the class DisbursementVoucherDocumentBatchServiceImpl method populateDisbursementVoucherFields.
/**
* Populates fields on the disbursement voucher document and performs validation
*
* @param disbursementVoucherDocument disbursement voucher document to populate
* @param batchDisbursementVoucherDocument batch dv document to pull values from
* @param batchDefault contains default values to use if value in feed is empty
* @param MessageMap MessageMap for adding encountered errors
*/
protected void populateDisbursementVoucherFields(DisbursementVoucherDocument disbursementVoucherDocument, BatchDisbursementVoucherDocument batchDisbursementVoucherDocument, DisbursementVoucherBatchDefault batchDefault, MessageMap MessageMap) {
disbursementVoucherDocument.getDocumentHeader().setDocumentDescription(kualiConfigurationService.getPropertyValueAsString(FPKeyConstants.MESSAGE_DV_BATCH_DOCUMENT_DESCRIPTION));
// populate fields of document from batch instance
disbursementVoucherDocument.getDocumentHeader().setExplanation(batchDisbursementVoucherDocument.getDocumentHeader().getExplanation());
disbursementVoucherDocument.getDocumentHeader().setOrganizationDocumentNumber(batchDisbursementVoucherDocument.getDocumentHeader().getOrganizationDocumentNumber());
disbursementVoucherDocument.setDisbVchrContactPersonName(batchDisbursementVoucherDocument.getDisbVchrContactPersonName());
disbursementVoucherDocument.setDisbVchrContactPhoneNumber(batchDisbursementVoucherDocument.getDisbVchrContactPhoneNumber());
disbursementVoucherDocument.setDisbVchrContactEmailId(batchDisbursementVoucherDocument.getDisbVchrContactEmailId());
disbursementVoucherDocument.setDisbursementVoucherDueDate(batchDisbursementVoucherDocument.getDisbursementVoucherDueDate());
disbursementVoucherDocument.setDisbVchrAttachmentCode(batchDisbursementVoucherDocument.isDisbVchrAttachmentCode());
disbursementVoucherDocument.setDisbVchrSpecialHandlingCode(batchDisbursementVoucherDocument.isDisbVchrSpecialHandlingCode());
disbursementVoucherDocument.setDisbVchrCheckTotalAmount(batchDisbursementVoucherDocument.getDisbVchrCheckTotalAmount());
disbursementVoucherDocument.setDisbursementVoucherDocumentationLocationCode(batchDisbursementVoucherDocument.getDisbursementVoucherDocumentationLocationCode());
disbursementVoucherDocument.setDisbVchrPaymentMethodCode(batchDisbursementVoucherDocument.getDisbVchrPaymentMethodCode());
disbursementVoucherDocument.setCampusCode(batchDisbursementVoucherDocument.getCampusCode());
disbursementVoucherDocument.setDisbVchrCheckStubText(batchDisbursementVoucherDocument.getDisbVchrCheckStubText());
disbursementVoucherDocument.setDisbVchrBankCode(batchDisbursementVoucherDocument.getDisbVchrBankCode());
disbursementVoucherDocument.getDvPayeeDetail().setDocumentNumber(disbursementVoucherDocument.getDocumentNumber());
disbursementVoucherDocument.getDvPayeeDetail().setDisbVchrPaymentReasonCode(batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrPaymentReasonCode());
String payeeTypeCode = batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbursementVoucherPayeeTypeCode();
String payeeIdNumber = batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrPayeeIdNumber();
if (KFSConstants.PaymentPayeeTypes.VENDOR.equals(payeeTypeCode)) {
if (StringUtils.contains(payeeIdNumber, "-")) {
VendorDetail vendorDetail = vendorService.getVendorDetail(payeeIdNumber);
if (vendorDetail != null) {
VendorAddress vendorAddress = vendorService.getVendorDefaultAddress(vendorDetail.getVendorHeaderGeneratedIdentifier(), vendorDetail.getVendorDetailAssignedIdentifier(), VendorConstants.AddressTypes.PURCHASE_ORDER, disbursementVoucherDocument.getCampusCode());
if (vendorAddress == null) {
vendorAddress = vendorService.getVendorDefaultAddress(vendorDetail.getVendorHeaderGeneratedIdentifier(), vendorDetail.getVendorDetailAssignedIdentifier(), VendorConstants.AddressTypes.REMIT, disbursementVoucherDocument.getCampusCode());
}
if (vendorAddress != null) {
disbursementVoucherDocument.templateVendor(vendorDetail, vendorAddress);
}
} else {
batchFeedHelperService.addExistenceError(KFSPropertyConstants.DISB_VCHR_PAYEE_ID_NUMBER, payeeIdNumber, MessageMap);
}
} else {
batchFeedHelperService.addExistenceError(KFSPropertyConstants.DISB_VCHR_PAYEE_ID_NUMBER, payeeIdNumber, MessageMap);
}
} else if (KFSConstants.PaymentPayeeTypes.EMPLOYEE.equals(payeeTypeCode)) {
Person person = personService.getPersonByEmployeeId(payeeIdNumber);
if (person != null) {
disbursementVoucherDocument.templateEmployee(person);
} else {
batchFeedHelperService.addExistenceError(KFSPropertyConstants.DISB_VCHR_PAYEE_ID_NUMBER, payeeIdNumber, MessageMap);
}
}
// override payee details with values from feed if given (not blank)
if (StringUtils.isNotBlank(batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrPayeeLine1Addr())) {
disbursementVoucherDocument.getDvPayeeDetail().setDisbVchrPayeeLine1Addr(batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrPayeeLine1Addr());
}
if (StringUtils.isNotBlank(batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrPayeeLine2Addr())) {
disbursementVoucherDocument.getDvPayeeDetail().setDisbVchrPayeeLine2Addr(batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrPayeeLine2Addr());
}
if (StringUtils.isNotBlank(batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrPayeeCityName())) {
disbursementVoucherDocument.getDvPayeeDetail().setDisbVchrPayeeCityName(batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrPayeeCityName());
}
if (StringUtils.isNotBlank(batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrPayeeStateCode())) {
disbursementVoucherDocument.getDvPayeeDetail().setDisbVchrPayeeStateCode(batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrPayeeStateCode());
}
if (StringUtils.isNotBlank(batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrPayeeZipCode())) {
disbursementVoucherDocument.getDvPayeeDetail().setDisbVchrPayeeZipCode(batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrPayeeZipCode());
}
if (StringUtils.isNotBlank(batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrPayeeCountryCode())) {
disbursementVoucherDocument.getDvPayeeDetail().setDisbVchrPayeeCountryCode(batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrPayeeCountryCode());
}
// set special handling fields
disbursementVoucherDocument.getDvPayeeDetail().setDisbVchrSpecialHandlingPersonName(batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrSpecialHandlingPersonName());
disbursementVoucherDocument.getDvPayeeDetail().setDisbVchrSpecialHandlingLine1Addr(batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrSpecialHandlingLine1Addr());
disbursementVoucherDocument.getDvPayeeDetail().setDisbVchrSpecialHandlingLine2Addr(batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrSpecialHandlingLine2Addr());
disbursementVoucherDocument.getDvPayeeDetail().setDisbVchrSpecialHandlingCityName(batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrSpecialHandlingCityName());
disbursementVoucherDocument.getDvPayeeDetail().setDisbVchrSpecialHandlingZipCode(batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrSpecialHandlingZipCode());
disbursementVoucherDocument.getDvPayeeDetail().setDisbVchrSpecialHandlingStateCode(batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrSpecialHandlingStateCode());
disbursementVoucherDocument.getDvPayeeDetail().setDisbVchrSpecialHandlingCountryCode(batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrSpecialHandlingCountryCode());
disbursementVoucherDocument.setDvNonResidentAlienTax(batchDisbursementVoucherDocument.getDvNonResidentAlienTax());
disbursementVoucherDocument.getDvNonResidentAlienTax().setDocumentNumber(disbursementVoucherDocument.getDocumentNumber());
// set defaults
if (batchDefault != null) {
if (StringUtils.isBlank(disbursementVoucherDocument.getDisbVchrContactPersonName())) {
disbursementVoucherDocument.setDisbVchrContactPersonName(batchDefault.getDisbVchrContactPersonName());
}
if (StringUtils.isBlank(disbursementVoucherDocument.getDisbVchrContactPhoneNumber())) {
disbursementVoucherDocument.setDisbVchrContactPhoneNumber(batchDefault.getDisbVchrContactPhoneNumber());
}
if (StringUtils.isBlank(disbursementVoucherDocument.getDisbVchrContactEmailId())) {
disbursementVoucherDocument.setDisbVchrContactEmailId(batchDefault.getDisbVchrContactEmailId());
}
if (StringUtils.isBlank(disbursementVoucherDocument.getCampusCode())) {
disbursementVoucherDocument.setCampusCode(batchDefault.getCampusCode());
}
if (StringUtils.isBlank(disbursementVoucherDocument.getDisbVchrPaymentMethodCode())) {
disbursementVoucherDocument.setDisbVchrPaymentMethodCode(batchDefault.getDisbVchrPaymentMethodCode());
}
if (StringUtils.isBlank(disbursementVoucherDocument.getDisbursementVoucherDocumentationLocationCode())) {
disbursementVoucherDocument.setDisbursementVoucherDocumentationLocationCode(batchDefault.getDisbursementVoucherDocumentationLocationCode());
}
if (StringUtils.isBlank(disbursementVoucherDocument.getDisbVchrBankCode())) {
disbursementVoucherDocument.setDisbVchrBankCode(batchDefault.getDisbVchrBankCode());
}
}
// set accounting
for (Iterator iterator = batchDisbursementVoucherDocument.getSourceAccountingLines().iterator(); iterator.hasNext(); ) {
SourceAccountingLine batchAccountingLine = (SourceAccountingLine) iterator.next();
SourceAccountingLine accountingLine = new SourceAccountingLine();
accountingLine.setChartOfAccountsCode(batchAccountingLine.getChartOfAccountsCode());
accountingLine.setAccountNumber(batchAccountingLine.getAccountNumber());
if (StringUtils.isNotBlank(batchAccountingLine.getSubAccountNumber())) {
accountingLine.setSubAccountNumber(batchAccountingLine.getSubAccountNumber());
}
accountingLine.setFinancialObjectCode(batchAccountingLine.getFinancialObjectCode());
if (StringUtils.isNotBlank(batchAccountingLine.getFinancialSubObjectCode())) {
accountingLine.setFinancialSubObjectCode(batchAccountingLine.getFinancialSubObjectCode());
}
if (StringUtils.isNotBlank(batchAccountingLine.getProjectCode())) {
accountingLine.setProjectCode(batchAccountingLine.getProjectCode());
}
accountingLine.setOrganizationReferenceId(batchAccountingLine.getOrganizationReferenceId());
accountingLine.setFinancialDocumentLineDescription(batchAccountingLine.getFinancialDocumentLineDescription());
accountingLine.setAmount(batchAccountingLine.getAmount());
// set accounting defaults
if (batchDefault != null) {
if (StringUtils.isBlank(accountingLine.getChartOfAccountsCode())) {
accountingLine.setChartOfAccountsCode(batchDefault.getChartOfAccountsCode());
}
if (StringUtils.isBlank(accountingLine.getAccountNumber())) {
accountingLine.setAccountNumber(batchDefault.getAccountNumber());
}
if (StringUtils.isBlank(accountingLine.getFinancialObjectCode())) {
accountingLine.setFinancialObjectCode(batchDefault.getFinancialObjectCode());
}
if (StringUtils.isBlank(accountingLine.getFinancialDocumentLineDescription())) {
accountingLine.setFinancialDocumentLineDescription(batchDefault.getFinancialDocumentLineDescription());
}
}
accountingLine.setPostingYear(disbursementVoucherDocument.getPostingYear());
accountingLine.setDocumentNumber(disbursementVoucherDocument.getDocumentNumber());
disbursementVoucherDocument.addSourceAccountingLine(accountingLine);
}
// set notes
for (Iterator iterator = batchDisbursementVoucherDocument.getNotes().iterator(); iterator.hasNext(); ) {
Note note = (Note) iterator.next();
note.setRemoteObjectIdentifier(disbursementVoucherDocument.getObjectId());
note.setAuthorUniversalIdentifier(batchFeedHelperService.getSystemUser().getPrincipalId());
note.setNoteTypeCode(KFSConstants.NoteTypeEnum.BUSINESS_OBJECT_NOTE_TYPE.getCode());
note.setNotePostedTimestampToCurrent();
disbursementVoucherDocument.addNote(note);
}
}
use of org.kuali.rice.kim.api.identity.Person in project cu-kfs by CU-CommunityApps.
the class CUSimpleChartValuesFinder method getKeyValues.
/**
* Creates a list of {@link Chart}s using their code as their key, and their code as the display value
*
* @see org.kuali.kfs.kns.lookup.keyvalues.KeyValuesFinder#getKeyValues()
*/
public List<KeyValue> getKeyValues() {
parameterService = SpringContext.getBean(ParameterService.class);
String defaultChartCode = "";
String defaultChartCodeMethod = "";
try {
defaultChartCode = parameterService.getParameterValueAsString(KfsParameterConstants.FINANCIAL_SYSTEM_DOCUMENT.class, CUKFSParameterKeyConstants.DEFAULT_CHART_CODE);
defaultChartCodeMethod = parameterService.getParameterValueAsString(KfsParameterConstants.FINANCIAL_SYSTEM_DOCUMENT.class, CUKFSParameterKeyConstants.DEFAULT_CHART_CODE_METHOD);
} catch (Exception e) {
// Do nothing
}
KeyValuesService boService = SpringContext.getBean(KeyValuesService.class);
Collection<Chart> chartCodes = boService.findAll(Chart.class);
List<KeyValue> chartKeyLabels = new ArrayList<KeyValue>();
// If the DEFAULT_CHART_CODE_METHOD parameter DNE or has no value assigned to it, no default
if (defaultChartCodeMethod.equals("")) {
chartKeyLabels.add(new ConcreteKeyValue("", ""));
for (Iterator<Chart> iter = chartCodes.iterator(); iter.hasNext(); ) {
Chart element = (Chart) iter.next();
if (element.isActive()) {
// only show active charts
chartKeyLabels.add(new ConcreteKeyValue(element.getChartOfAccountsCode(), element.getChartOfAccountsCode()));
}
}
}
// populate with the default chart
if (defaultChartCodeMethod.equals("1")) {
chartKeyLabels.add(new ConcreteKeyValue(defaultChartCode, defaultChartCode));
for (Iterator<Chart> iter = chartCodes.iterator(); iter.hasNext(); ) {
Chart element = (Chart) iter.next();
if (element.isActive() && !element.getChartOfAccountsCode().equals(defaultChartCode)) {
// only show active charts
chartKeyLabels.add(new ConcreteKeyValue(element.getChartOfAccountsCode(), element.getChartOfAccountsCode()));
}
}
}
// populate with chart code of the user's primary department
if (defaultChartCodeMethod.equals("2")) {
Person currentUser = GlobalVariables.getUserSession().getPerson();
String primaryDepartmentChartCode = SpringContext.getBean(FinancialSystemUserService.class).getPrimaryOrganization(currentUser, "KFS-SYS").getChartOfAccountsCode();
chartKeyLabels.add(new ConcreteKeyValue(primaryDepartmentChartCode, primaryDepartmentChartCode));
for (Iterator<Chart> iter = chartCodes.iterator(); iter.hasNext(); ) {
Chart element = (Chart) iter.next();
if (element.isActive() && !element.getChartOfAccountsCode().equals(primaryDepartmentChartCode)) {
// only show active charts
chartKeyLabels.add(new ConcreteKeyValue(element.getChartOfAccountsCode(), element.getChartOfAccountsCode()));
}
}
}
// populate with the default chart unless user's primary department has been defined
if (defaultChartCodeMethod.equals("3")) {
Person currentUser = GlobalVariables.getUserSession().getPerson();
String primaryDepartmentChartCode = SpringContext.getBean(FinancialSystemUserService.class).getPrimaryOrganization(currentUser, "KFS-SYS").getChartOfAccountsCode();
String chartUsed = null;
if (primaryDepartmentChartCode != null && !primaryDepartmentChartCode.equals("")) {
chartUsed = primaryDepartmentChartCode;
} else {
chartUsed = defaultChartCode;
}
chartKeyLabels.add(new ConcreteKeyValue(chartUsed, chartUsed));
for (Iterator<Chart> iter = chartCodes.iterator(); iter.hasNext(); ) {
Chart element = (Chart) iter.next();
if (element.isActive() && !element.getChartOfAccountsCode().equals(chartUsed)) {
// only show active charts
chartKeyLabels.add(new ConcreteKeyValue(element.getChartOfAccountsCode(), element.getChartOfAccountsCode()));
}
}
}
return chartKeyLabels;
}
Aggregations