Search in sources :

Example 21 with Person

use of org.kuali.kfs.kim.api.identity.Person in project cu-kfs by CU-CommunityApps.

the class IWantDocumentAction method setCollegeAndDepartmentBasedOnPrimaryDepartment.

/**
 * Sets the College and Department based on the initiator primary department.
 *
 * @param documentForm
 */
private void setCollegeAndDepartmentBasedOnPrimaryDepartment(IWantDocumentForm documentForm) {
    IWantDocumentService iWantDocumentService = SpringContext.getBean(IWantDocumentService.class);
    String primaryDeptOrg = null;
    IWantDocument iWantDocument = null;
    if (documentForm != null && documentForm.getDocument() != null) {
        iWantDocument = (IWantDocument) documentForm.getDocument();
    }
    if (iWantDocument != null && StringUtils.isEmpty(iWantDocument.getCollegeLevelOrganization())) {
        Person currentUser = GlobalVariables.getUserSession().getPerson();
        Entity entityInfo = KimApiServiceLocator.getIdentityService().getEntityByPrincipalId(currentUser.getPrincipalId());
        if (ObjectUtils.isNotNull(entityInfo)) {
            if (ObjectUtils.isNotNull(entityInfo.getEmploymentInformation()) && entityInfo.getEmploymentInformation().size() > 0) {
                EntityEmployment employmentInformation = entityInfo.getEmploymentInformation().get(0);
                String primaryDepartment = employmentInformation.getPrimaryDepartmentCode();
                primaryDeptOrg = primaryDepartment.substring(primaryDepartment.lastIndexOf('-') + 1, primaryDepartment.length());
                String cLevelOrg = iWantDocumentService.getCLevelOrganizationForDLevelOrg(primaryDepartment);
                ((IWantDocument) documentForm.getDocument()).setCollegeLevelOrganization(cLevelOrg);
            }
        }
    }
    if (iWantDocument != null && StringUtils.isNotEmpty(iWantDocument.getCollegeLevelOrganization())) {
        String cLevelOrg = iWantDocument.getCollegeLevelOrganization();
        documentForm.getDeptOrgKeyLabels().clear();
        documentForm.getDeptOrgKeyLabels().add(new ConcreteKeyValue("", "Please Select"));
        List<LevelOrganization> dLevelOrgs = iWantDocumentService.getDLevelOrganizations(cLevelOrg);
        for (LevelOrganization levelOrganization : dLevelOrgs) {
            documentForm.getDeptOrgKeyLabels().add(new ConcreteKeyValue(levelOrganization.getCode(), levelOrganization.getCodeAndDescription()));
        }
        if (primaryDeptOrg != null) {
            iWantDocument.setDepartmentLevelOrganization(primaryDeptOrg);
        }
    }
}
Also used : ConcreteKeyValue(org.kuali.kfs.core.api.util.ConcreteKeyValue) Entity(org.kuali.kfs.kim.impl.identity.entity.Entity) LevelOrganization(edu.cornell.kfs.module.purap.businessobject.LevelOrganization) EntityEmployment(org.kuali.kfs.kim.impl.identity.employment.EntityEmployment) Person(org.kuali.kfs.kim.api.identity.Person) IWantDocumentService(edu.cornell.kfs.module.purap.document.service.IWantDocumentService) IWantDocument(edu.cornell.kfs.module.purap.document.IWantDocument) PurApFavoriteAccountLineBuilderForIWantDocument(edu.cornell.kfs.module.purap.util.PurApFavoriteAccountLineBuilderForIWantDocument)

Example 22 with Person

use of org.kuali.kfs.kim.api.identity.Person in project cu-kfs by CU-CommunityApps.

the class PayeeACHAccountDocumentServiceImpl method createAndRoutePayeeACHAccountDocument.

protected String createAndRoutePayeeACHAccountDocument(PayeeACHData achData, BiConsumer<MaintenanceDocument, PayeeACHData> documentConfigurer) {
    try {
        MaintenanceDocument paatDocument = (MaintenanceDocument) documentService.getNewDocument(CUPdpConstants.PAYEE_ACH_ACCOUNT_EXTRACT_MAINT_DOC_TYPE);
        documentConfigurer.accept(paatDocument, achData);
        Person payee = achData.getPayee();
        PayeeACHAccount achAccount = (PayeeACHAccount) paatDocument.getNewMaintainableObject().getDataObject();
        paatDocument.getDocumentHeader().setDocumentDescription(buildDocumentDescription(payee, achAccount, paatDocument));
        addNote(paatDocument, getPayeeACHAccountExtractParameter(CUPdpParameterConstants.GENERATED_PAYEE_ACH_ACCOUNT_DOC_NOTE_TEXT));
        paatDocument = (MaintenanceDocument) documentService.routeDocument(paatDocument, CUPdpConstants.PAYEE_ACH_ACCOUNT_EXTRACT_ROUTE_ANNOTATION, null);
        achAccount = (PayeeACHAccount) paatDocument.getNewMaintainableObject().getDataObject();
        sendPayeeACHAccountAddOrUpdateEmail((PayeeACHAccount) paatDocument.getNewMaintainableObject().getDataObject(), payee, paatDocument);
        LOG.info("createAndRoutePayeeACHAccountDocument: " + getSuccessMessageStart(paatDocument) + "ACH Account of type " + achAccount.getPayeeIdentifierTypeCode() + " for payee " + payee.getPrincipalName());
    } catch (Exception e) {
        LOG.error("createAndRoutePayeeACHAccountDocument: " + getFailRequestMessage(e), e);
        return "createAndRoutePayeeACHAccountDocument: " + achData.getAchDetail().getLogData() + " STE was generated. " + getFailRequestMessage(e);
    }
    return StringUtils.EMPTY;
}
Also used : MaintenanceDocument(org.kuali.kfs.kns.document.MaintenanceDocument) PayeeACHAccount(org.kuali.kfs.pdp.businessobject.PayeeACHAccount) Person(org.kuali.kfs.kim.api.identity.Person) ValidationException(org.kuali.kfs.krad.exception.ValidationException)

Example 23 with Person

use of org.kuali.kfs.kim.api.identity.Person in project cu-kfs by CU-CommunityApps.

the class PayeeACHAccountDocumentServiceImpl method setupDocumentForACHCreate.

protected void setupDocumentForACHCreate(MaintenanceDocument paatDocument, PayeeACHData achData) {
    Person payee = achData.getPayee();
    PayeeACHAccountExtractDetail achDetail = achData.getAchDetail();
    String payeeType = achData.getPayeeType();
    PayeeACHAccountMaintainableImpl maintainable = (PayeeACHAccountMaintainableImpl) paatDocument.getNewMaintainableObject();
    maintainable.setMaintenanceAction(KFSConstants.MAINTENANCE_NEW_ACTION);
    PayeeACHAccount achAccount = (PayeeACHAccount) maintainable.getDataObject();
    if (StringUtils.equals(PayeeIdTypeCodes.ENTITY, payeeType)) {
        achAccount.setPayeeIdNumber(payee.getEntityId());
    } else if (StringUtils.equals(PayeeIdTypeCodes.EMPLOYEE, payeeType)) {
        achAccount.setPayeeIdNumber(payee.getEmployeeId());
    } else {
        throw new RuntimeException("Invalid payee ID type: " + payeeType);
    }
    achAccount.setPayeeIdentifierTypeCode(payeeType);
    Long newId = sequenceAccessorService.getNextAvailableSequenceNumber(PdpConstants.ACH_ACCOUNT_IDENTIFIER_SEQUENCE_NAME);
    achAccount.setAchAccountGeneratedIdentifier(new KualiInteger(newId));
    achAccount.setAchTransactionType(getDirectDepositTransactionType());
    achAccount.setBankRoutingNumber(achDetail.getBankRoutingNumber());
    achAccount.setBankAccountNumber(achDetail.getBankAccountNumber());
    achAccount.setBankAccountTypeCode(getACHTransactionCode(achDetail.getBankAccountType()));
    if (StringUtils.isNotBlank(payee.getNameUnmasked())) {
        achAccount.setPayeeName(payee.getNameUnmasked());
    }
    if (StringUtils.isNotBlank(payee.getEmailAddressUnmasked())) {
        achAccount.setPayeeEmailAddress(payee.getEmailAddressUnmasked());
    }
    achAccount.setActive(true);
}
Also used : PayeeACHAccountMaintainableImpl(org.kuali.kfs.pdp.document.PayeeACHAccountMaintainableImpl) PayeeACHAccount(org.kuali.kfs.pdp.businessobject.PayeeACHAccount) KualiInteger(org.kuali.kfs.core.api.util.type.KualiInteger) PayeeACHAccountExtractDetail(edu.cornell.kfs.pdp.businessobject.PayeeACHAccountExtractDetail) Person(org.kuali.kfs.kim.api.identity.Person)

Example 24 with Person

use of org.kuali.kfs.kim.api.identity.Person in project cu-kfs by CU-CommunityApps.

the class CuPayeeACHAccountMaintainableImpl method refresh.

@Override
public void refresh(String refreshCaller, Map fieldValues, MaintenanceDocument document) {
    super.refresh(refreshCaller, fieldValues, document);
    if (StringUtils.isNotEmpty(refreshCaller) && refreshCaller.equalsIgnoreCase("achPayeeLookupable")) {
        PayeeACHAccount payeeAchAccount = (PayeeACHAccount) document.getNewMaintainableObject().getBusinessObject();
        String payeeIdNumber = payeeAchAccount.getPayeeIdNumber();
        String payeeIdentifierTypeCode = payeeAchAccount.getPayeeIdentifierTypeCode();
        if (StringUtils.isNotEmpty(payeeAchAccount.getPayeeIdNumber())) {
            // for Employee, retrieve from Person table by employee ID
            if (StringUtils.equalsIgnoreCase(payeeIdentifierTypeCode, PayeeIdTypeCodes.EMPLOYEE)) {
                Person person = SpringContext.getBean(PersonService.class).getPersonByEmployeeId(payeeIdNumber);
                if (ObjectUtils.isNotNull(person)) {
                    payeeAchAccount.setPayeeEmailAddress(person.getEmailAddress());
                }
            } else // for Entity, retrieve from Entity table by entity ID then from Person table
            if (StringUtils.equalsIgnoreCase(payeeIdentifierTypeCode, PayeeIdTypeCodes.ENTITY)) {
                if (ObjectUtils.isNotNull(payeeIdNumber)) {
                    Entity entity = KimApiServiceLocator.getIdentityService().getEntity(payeeIdNumber);
                    if (ObjectUtils.isNotNull(entity)) {
                        List<Principal> principals = entity.getPrincipals();
                        if (principals.size() > 0 && ObjectUtils.isNotNull(principals.get(0))) {
                            String principalId = principals.get(0).getPrincipalId();
                            Person person = SpringContext.getBean(PersonService.class).getPerson(principalId);
                            if (ObjectUtils.isNotNull(person)) {
                                payeeAchAccount.setPayeeEmailAddress(person.getEmailAddress());
                            }
                        }
                    }
                }
            }
        }
    }
}
Also used : Entity(org.kuali.kfs.kim.impl.identity.entity.Entity) PayeeACHAccount(org.kuali.kfs.pdp.businessobject.PayeeACHAccount) PersonService(org.kuali.kfs.kim.api.identity.PersonService) List(java.util.List) Person(org.kuali.kfs.kim.api.identity.Person)

Example 25 with Person

use of org.kuali.kfs.kim.api.identity.Person in project cu-kfs by CU-CommunityApps.

the class CuPaymentFileValidationServiceImpl method processGroupValidation.

@Override
protected void processGroupValidation(PaymentFileLoad paymentFile, MessageMap errorMap) {
    int groupCount = 0;
    for (PaymentGroup paymentGroup : paymentFile.getPaymentGroups()) {
        groupCount++;
        int noteLineCount = 0;
        int detailCount = 0;
        // We've encountered Payment Files that have address lines exceeding the column size in DB table;
        // so adding extra validation on payment group BO, especially the max length, based on DD definitions.
        // Check that PaymentGroup String properties don't exceed maximum allowed length
        checkPaymentGroupPropertyMaxLength(paymentGroup, errorMap);
        // verify payee id and owner code if customer requires them to be filled in
        if (paymentFile.getCustomer().getPayeeIdRequired() && StringUtils.isBlank(paymentGroup.getPayeeId())) {
            LOG.debug("processGroupValidation, No payee");
            errorMap.putError(KFSConstants.GLOBAL_ERRORS, PdpKeyConstants.ERROR_PAYMENT_LOAD_PAYEE_ID_REQUIRED, Integer.toString(groupCount));
        }
        if (paymentFile.getCustomer().getOwnershipCodeRequired() && StringUtils.isBlank(paymentGroup.getPayeeOwnerCd())) {
            LOG.debug("processGroupValidation, no ownership code");
            errorMap.putError(KFSConstants.GLOBAL_ERRORS, PdpKeyConstants.ERROR_PAYMENT_LOAD_PAYEE_OWNER_CODE, Integer.toString(groupCount));
        }
        // validate payee id type
        if (StringUtils.isNotBlank(paymentGroup.getPayeeIdTypeCd())) {
            PayeeType payeeType = businessObjectService.findBySinglePrimaryKey(PayeeType.class, paymentGroup.getPayeeIdTypeCd());
            if (payeeType == null) {
                LOG.debug("processGroupValidation, no payee type");
                errorMap.putError(KFSConstants.GLOBAL_ERRORS, PdpKeyConstants.ERROR_PAYMENT_LOAD_INVALID_PAYEE_ID_TYPE, Integer.toString(groupCount), paymentGroup.getPayeeIdTypeCd());
            }
        }
        // validate vendor id and customer institution number
        if (paymentGroup.getPayeeId().split("-").length > 1) {
            try {
                paymentGroup.validateVendorIdAndCustomerInstitutionIdentifier();
            } catch (RuntimeException e1) {
                LOG.error("processGroupValidation, there was an error validating customer institution information", e1);
                errorMap.putError(KFSConstants.GLOBAL_ERRORS, KFSKeyConstants.ERROR_BATCH_UPLOAD_PARSING, new String[] { e1.getMessage() });
            }
        } else {
            LOG.debug("processGroupValidation, found a non vendor number payee ID: " + paymentGroup.getPayeeId());
            if (cuPdpEmployeeService.shouldPayeeBeProcessedAsEmployeeForThisCustomer(paymentFile)) {
                Person employee = findPerson(paymentGroup.getPayeeId());
                if (ObjectUtils.isNull(employee)) {
                    LOG.error("processGroupValidation, unable to get a person from the employee id");
                    errorMap.putError(KFSConstants.GLOBAL_ERRORS, CUPdpKeyConstants.ERROR_PDP_PAYMENTLOAD_INVALID_EMPLOYEE_ID, paymentGroup.getPayeeId());
                }
            }
        }
        // validate bank
        String bankCode = paymentGroup.getBankCode();
        if (StringUtils.isNotBlank(bankCode)) {
            Bank bank = bankService.getByPrimaryId(bankCode);
            if (bank == null) {
                LOG.debug("processGroupValidation, no bank");
                errorMap.putError(KFSConstants.GLOBAL_ERRORS, PdpKeyConstants.ERROR_PAYMENT_LOAD_INVALID_BANK_CODE, Integer.toString(groupCount), bankCode);
            } else if (!bank.isActive()) {
                LOG.debug("processGroupValidation, bank isn't active");
                errorMap.putError(KFSConstants.GLOBAL_ERRORS, PdpKeyConstants.ERROR_PAYMENT_LOAD_INACTIVE_BANK_CODE, Integer.toString(groupCount), bankCode);
            }
        }
        KualiDecimal groupTotal = KualiDecimal.ZERO;
        for (PaymentDetail paymentDetail : paymentGroup.getPaymentDetails()) {
            detailCount++;
            // CU Customization: Check max lengths on Payment Detail properties.
            checkPaymentDetailPropertyMaxLength(paymentDetail, errorMap);
            // Add a line to print the invoice number
            noteLineCount++;
            noteLineCount = noteLineCount + paymentDetail.getNotes().size();
            if ((paymentDetail.getNetPaymentAmount() == null) && (!paymentDetail.isDetailAmountProvided())) {
                paymentDetail.setNetPaymentAmount(paymentDetail.getAccountTotal());
            } else if ((paymentDetail.getNetPaymentAmount() == null) && (paymentDetail.isDetailAmountProvided())) {
                paymentDetail.setNetPaymentAmount(paymentDetail.getCalculatedPaymentAmount());
            }
            // compare net to accounting segments
            if (paymentDetail.getAccountTotal().compareTo(paymentDetail.getNetPaymentAmount()) != 0) {
                LOG.debug("processGroupValidation, account total (" + paymentDetail.getAccountTotal() + ") not equal to net amount total (" + paymentDetail.getNetPaymentAmount() + ")");
                errorMap.putError(KFSConstants.GLOBAL_ERRORS, PdpKeyConstants.ERROR_PAYMENT_LOAD_DETAIL_TOTAL_MISMATCH, Integer.toString(groupCount), Integer.toString(detailCount), paymentDetail.getAccountTotal().toString(), paymentDetail.getNetPaymentAmount().toString());
            }
            // validate origin code if given
            if (StringUtils.isNotBlank(paymentDetail.getFinancialSystemOriginCode())) {
                OriginationCode originationCode = originationCodeService.getByPrimaryKey(paymentDetail.getFinancialSystemOriginCode());
                if (originationCode == null) {
                    LOG.debug("processGroupValidation, origination code is null");
                    errorMap.putError(KFSConstants.GLOBAL_ERRORS, PdpKeyConstants.ERROR_PAYMENT_LOAD_INVALID_ORIGIN_CODE, Integer.toString(groupCount), Integer.toString(detailCount), paymentDetail.getFinancialSystemOriginCode());
                }
            }
            // validate doc type if given
            if (StringUtils.isNotBlank(paymentDetail.getFinancialDocumentTypeCode())) {
                if (!documentTypeService.isActiveByName(paymentDetail.getFinancialDocumentTypeCode())) {
                    LOG.debug("processGroupValidation, " + paymentDetail.getFinancialDocumentTypeCode() + " is not active.");
                    errorMap.putError(KFSConstants.GLOBAL_ERRORS, PdpKeyConstants.ERROR_PAYMENT_LOAD_INVALID_DOC_TYPE, Integer.toString(groupCount), Integer.toString(detailCount), paymentDetail.getFinancialDocumentTypeCode());
                }
            }
            groupTotal = groupTotal.add(paymentDetail.getNetPaymentAmount());
        }
        // verify total for group is not negative
        if (groupTotal.doubleValue() < 0) {
            LOG.debug("processGroupValidation, group total less than zero");
            errorMap.putError(KFSConstants.GLOBAL_ERRORS, PdpKeyConstants.ERROR_PAYMENT_LOAD_NEGATIVE_GROUP_TOTAL, Integer.toString(groupCount));
        }
        // check that the number of detail items and note lines will fit on a check stub
        if (noteLineCount > getMaxNoteLines()) {
            LOG.debug("processGroupValidation, too many notes");
            errorMap.putError(KFSConstants.GLOBAL_ERRORS, PdpKeyConstants.ERROR_PAYMENT_LOAD_MAX_NOTE_LINES, Integer.toString(groupCount), Integer.toString(noteLineCount), Integer.toString(getMaxNoteLines()));
        }
        if (LOG.isDebugEnabled()) {
            LOG.debug("After processGroupValidation: " + printErrorMap(errorMap));
        }
    }
}
Also used : PaymentGroup(org.kuali.kfs.pdp.businessobject.PaymentGroup) Bank(org.kuali.kfs.sys.businessobject.Bank) PayeeType(org.kuali.kfs.pdp.businessobject.PayeeType) PaymentDetail(org.kuali.kfs.pdp.businessobject.PaymentDetail) OriginationCode(org.kuali.kfs.sys.businessobject.OriginationCode) KualiDecimal(org.kuali.kfs.core.api.util.type.KualiDecimal) Person(org.kuali.kfs.kim.api.identity.Person)

Aggregations

Person (org.kuali.kfs.kim.api.identity.Person)84 ArrayList (java.util.ArrayList)11 PersonService (org.kuali.kfs.kim.api.identity.PersonService)11 HashMap (java.util.HashMap)9 Note (org.kuali.kfs.krad.bo.Note)9 CuDisbursementVoucherDocument (edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument)8 WorkflowDocument (org.kuali.kfs.kew.api.WorkflowDocument)6 AdHocRoutePerson (org.kuali.kfs.krad.bo.AdHocRoutePerson)6 DateTimeService (org.kuali.kfs.core.api.datetime.DateTimeService)5 KualiDecimal (org.kuali.kfs.core.api.util.type.KualiDecimal)5 VendorDetail (org.kuali.kfs.vnd.businessobject.VendorDetail)5 DisbursementVoucherDocument (org.kuali.kfs.fp.document.DisbursementVoucherDocument)4 WorkflowException (org.kuali.kfs.kew.api.exception.WorkflowException)4 CustomerProfile (org.kuali.kfs.pdp.businessobject.CustomerProfile)4 IWantDocument (edu.cornell.kfs.module.purap.document.IWantDocument)3 PayeeACHAccount (org.kuali.kfs.pdp.businessobject.PayeeACHAccount)3 Bank (org.kuali.kfs.sys.businessobject.Bank)3 ChartOrgHolder (org.kuali.kfs.sys.businessobject.ChartOrgHolder)3 AccountingXmlDocumentNote (edu.cornell.kfs.fp.batch.xml.AccountingXmlDocumentNote)2 CuDisbursementPayee (edu.cornell.kfs.fp.businessobject.CuDisbursementPayee)2