Search in sources :

Example 1 with EntityAddress

use of org.kuali.kfs.kim.impl.identity.address.EntityAddress in project cu-kfs by CU-CommunityApps.

the class CuDisbursementVoucherDocument method templateStudent.

/**
 * Convenience method to set dv payee detail fields based on a given student.
 *
 * @param student
 */
public void templateStudent(Person student) {
    if (student == null) {
        return;
    }
    this.getDvPayeeDetail().setDisbursementVoucherPayeeTypeCode(CuDisbursementVoucherConstants.DV_PAYEE_TYPE_STUDENT);
    this.getDvPayeeDetail().setDisbVchrPayeeIdNumber(student.getPrincipalId());
    ((CuDisbursementVoucherPayeeDetailExtension) this.getDvPayeeDetail().getExtension()).setDisbVchrPayeeIdType(CuDisbursementVoucherConstants.DV_PAYEE_ID_TYP_ENTITY);
    ((CuDisbursementVoucherPayeeDetailExtension) this.getDvPayeeDetail().getExtension()).setPayeeTypeSuffix(StringUtils.EMPTY);
    this.getDvPayeeDetail().setDisbVchrPayeePersonName(student.getNameUnmasked());
    final ParameterService parameterService = this.getParameterService();
    // Use the same parameter as for employees even though this is a student as basic intention is the same
    if (parameterService.parameterExists(DisbursementVoucherDocument.class, FPParameterConstants.USE_DEFAULT_EMPLOYEE_ADDRESS) && parameterService.getParameterValueAsBoolean(DisbursementVoucherDocument.class, FPParameterConstants.USE_DEFAULT_EMPLOYEE_ADDRESS)) {
        this.getDvPayeeDetail().setDisbVchrPayeeLine1Addr(student.getAddressLine1Unmasked());
        this.getDvPayeeDetail().setDisbVchrPayeeLine2Addr(student.getAddressLine2Unmasked());
        this.getDvPayeeDetail().setDisbVchrPayeeCityName(student.getAddressCityUnmasked());
        this.getDvPayeeDetail().setDisbVchrPayeeStateCode(student.getAddressStateProvinceCodeUnmasked());
        this.getDvPayeeDetail().setDisbVchrPayeeZipCode(student.getAddressPostalCodeUnmasked());
        this.getDvPayeeDetail().setDisbVchrPayeeCountryCode(student.getAddressCountryCodeUnmasked());
    } else {
        final EntityAddress address = getNonDefaultAddress(student);
        if (address != null) {
            this.getDvPayeeDetail().setDisbVchrPayeeLine1Addr(address.getLine1Unmasked());
            this.getDvPayeeDetail().setDisbVchrPayeeLine2Addr(address.getLine2Unmasked());
            this.getDvPayeeDetail().setDisbVchrPayeeCityName(address.getCityUnmasked());
            this.getDvPayeeDetail().setDisbVchrPayeeStateCode(address.getStateProvinceCodeUnmasked());
            this.getDvPayeeDetail().setDisbVchrPayeeZipCode(student.getAddressPostalCodeUnmasked());
            this.getDvPayeeDetail().setDisbVchrPayeeCountryCode(address.getCountryCodeUnmasked());
        } else {
            this.getDvPayeeDetail().setDisbVchrPayeeLine1Addr("");
            this.getDvPayeeDetail().setDisbVchrPayeeLine2Addr("");
            this.getDvPayeeDetail().setDisbVchrPayeeCityName("");
            this.getDvPayeeDetail().setDisbVchrPayeeStateCode("");
            this.getDvPayeeDetail().setDisbVchrPayeeZipCode("");
            this.getDvPayeeDetail().setDisbVchrPayeeCountryCode("");
        }
    }
    // I'm assuming that if a tax id type code other than 'TAX' is present, then the student must be foreign
    for (String externalIdentifierTypeCode : student.getExternalIdentifiers().keySet()) {
        if (KimConstants.PersonExternalIdentifierTypes.TAX.equals(externalIdentifierTypeCode)) {
            this.getDvPayeeDetail().setDisbVchrNonresidentPaymentCode(false);
        }
    }
    // Determine if student is a research subject
    ParameterEvaluator researchPaymentReasonCodeEvaluator = SpringContext.getBean(ParameterEvaluatorService.class).getParameterEvaluator(DisbursementVoucherDocument.class, FPParameterConstants.RESEARCH_PAYMENT_REASONS);
    if (researchPaymentReasonCodeEvaluator.evaluationSucceeds()) {
        if (getParameterService().parameterExists(DisbursementVoucherDocument.class, FPParameterConstants.RESEARCH_NON_VENDOR_PAY_LIMIT_AMOUNT)) {
            String researchPayLimit = getParameterService().getParameterValueAsString(DisbursementVoucherDocument.class, FPParameterConstants.RESEARCH_NON_VENDOR_PAY_LIMIT_AMOUNT);
            if (StringUtils.isNotBlank(researchPayLimit)) {
                KualiDecimal payLimit = new KualiDecimal(researchPayLimit);
                if (getDisbVchrCheckTotalAmount().isLessThan(payLimit)) {
                    this.getDvPayeeDetail().setDvPayeeSubjectPaymentCode(true);
                }
            }
        }
    }
    this.disbVchrPayeeTaxControlCode = "";
    this.disbVchrPayeeW9CompleteCode = true;
}
Also used : ParameterService(org.kuali.kfs.coreservice.framework.parameter.ParameterService) CuDisbursementVoucherPayeeDetailExtension(edu.cornell.kfs.fp.businessobject.CuDisbursementVoucherPayeeDetailExtension) EntityAddress(org.kuali.kfs.kim.impl.identity.address.EntityAddress) KualiDecimal(org.kuali.kfs.core.api.util.type.KualiDecimal) ParameterEvaluator(org.kuali.kfs.core.api.parameter.ParameterEvaluator) ParameterEvaluatorService(org.kuali.kfs.core.api.parameter.ParameterEvaluatorService) DisbursementVoucherDocument(org.kuali.kfs.fp.document.DisbursementVoucherDocument)

Example 2 with EntityAddress

use of org.kuali.kfs.kim.impl.identity.address.EntityAddress in project cu-kfs by CU-CommunityApps.

the class IWantDocumentServiceImpl method getPersonCampusAddress.

/**
 * @see edu.cornell.kfs.module.purap.document.service.IWantDocumentService#getPersonCampusAddress(java.lang.String)
 */
public String getPersonCampusAddress(String principalName) {
    EntityAddress foundAddress = getPersonEntityAddress(principalName);
    String addressLine1 = foundAddress.getLine1Unmasked();
    String addressLine2 = foundAddress.getLine2Unmasked();
    String city = foundAddress.getCityUnmasked();
    String stateCode = foundAddress.getStateProvinceCodeUnmasked();
    String postalCode = foundAddress.getPostalCodeUnmasked();
    String countryCode = foundAddress.getCountryCodeUnmasked();
    String initiatorAddress = new StringBuilder(100).append(addressLine1).append(KRADConstants.NEWLINE).append(addressLine2).append(KRADConstants.NEWLINE).append(city).append(KRADConstants.NEWLINE).append(stateCode).append(KRADConstants.NEWLINE).append(postalCode).append(KRADConstants.NEWLINE).append(countryCode).toString();
    return initiatorAddress;
}
Also used : EntityAddress(org.kuali.kfs.kim.impl.identity.address.EntityAddress)

Example 3 with EntityAddress

use of org.kuali.kfs.kim.impl.identity.address.EntityAddress in project cu-kfs by CU-CommunityApps.

the class DisbursementVoucherDocument method getNonDefaultAddress.

/**
 * Finds the address for the given employee, matching the type in the
 * KFS-FP / Disbursement Voucher/ DEFAULT_EMPLOYEE_ADDRESS_TYPE parameter, to use as the address for the employee
 *
 * @param employee the employee to find a non-default address for
 * @return the non-default address, or null if not found
 */
protected EntityAddress getNonDefaultAddress(Person employee) {
    final String addressType = getParameterService().getParameterValueAsString(DisbursementVoucherDocument.class, FPParameterConstants.DEFAULT_EMPLOYEE_ADDRESS_TYPE);
    final Entity entity = getIdentityService().getEntityByPrincipalId(employee.getPrincipalId());
    if (entity != null) {
        final EntityTypeContactInfo entityEntityType = getPersonEntityEntityType(entity);
        if (entityEntityType != null) {
            final List<EntityAddress> addresses = entityEntityType.getAddresses();
            return findAddressByType(addresses, addressType);
        }
    }
    return null;
}
Also used : Entity(org.kuali.kfs.kim.impl.identity.entity.Entity) EntityAddress(org.kuali.kfs.kim.impl.identity.address.EntityAddress) EntityTypeContactInfo(org.kuali.kfs.kim.impl.identity.type.EntityTypeContactInfo)

Example 4 with EntityAddress

use of org.kuali.kfs.kim.impl.identity.address.EntityAddress in project cu-kfs by CU-CommunityApps.

the class DisbursementVoucherDocument method templateEmployee.

/**
 * Convenience method to set dv payee detail fields based on a given Employee.
 *
 * @param employee
 */
public void templateEmployee(Person employee) {
    if (employee == null) {
        return;
    }
    this.getDvPayeeDetail().setDisbursementVoucherPayeeTypeCode(KFSConstants.PaymentPayeeTypes.EMPLOYEE);
    this.getDvPayeeDetail().setDisbVchrPayeeIdNumber(employee.getEmployeeId());
    this.getDvPayeeDetail().setDisbVchrPayeePersonName(employee.getName());
    final ParameterService parameterService = this.getParameterService();
    if (parameterService.parameterExists(DisbursementVoucherDocument.class, FPParameterConstants.USE_DEFAULT_EMPLOYEE_ADDRESS) && parameterService.getParameterValueAsBoolean(DisbursementVoucherDocument.class, FPParameterConstants.USE_DEFAULT_EMPLOYEE_ADDRESS)) {
        this.getDvPayeeDetail().setDisbVchrPayeeLine1Addr(employee.getAddressLine1Unmasked());
        this.getDvPayeeDetail().setDisbVchrPayeeLine2Addr(employee.getAddressLine2Unmasked());
        this.getDvPayeeDetail().setDisbVchrPayeeCityName(employee.getAddressCityUnmasked());
        this.getDvPayeeDetail().setDisbVchrPayeeStateCode(employee.getAddressStateProvinceCodeUnmasked());
        this.getDvPayeeDetail().setDisbVchrPayeeZipCode(employee.getAddressPostalCodeUnmasked());
        this.getDvPayeeDetail().setDisbVchrPayeeCountryCode(employee.getAddressCountryCodeUnmasked());
    } else {
        final EntityAddress address = getNonDefaultAddress(employee);
        if (address != null) {
            this.getDvPayeeDetail().setDisbVchrPayeeLine1Addr(address.getLine1Unmasked());
            this.getDvPayeeDetail().setDisbVchrPayeeLine2Addr(address.getLine2Unmasked());
            this.getDvPayeeDetail().setDisbVchrPayeeCityName(address.getCityUnmasked());
            this.getDvPayeeDetail().setDisbVchrPayeeStateCode(address.getStateProvinceCodeUnmasked());
            this.getDvPayeeDetail().setDisbVchrPayeeZipCode(address.getPostalCodeUnmasked());
            this.getDvPayeeDetail().setDisbVchrPayeeCountryCode(address.getCountryCodeUnmasked());
        } else {
            this.getDvPayeeDetail().setDisbVchrPayeeLine1Addr("");
            this.getDvPayeeDetail().setDisbVchrPayeeLine2Addr("");
            this.getDvPayeeDetail().setDisbVchrPayeeCityName("");
            this.getDvPayeeDetail().setDisbVchrPayeeStateCode("");
            this.getDvPayeeDetail().setDisbVchrPayeeZipCode("");
            this.getDvPayeeDetail().setDisbVchrPayeeCountryCode("");
        }
    }
    // "Is this payee an employee" = No
    if (employee.isActive()) {
        this.getDvPayeeDetail().setDisbVchrPayeeEmployeeCode(true);
    } else {
        this.getDvPayeeDetail().setDisbVchrPayeeEmployeeCode(false);
    }
    // I'm assuming that if a tax id type code other than 'TAX' is present, then the employee must be foreign
    for (String externalIdentifierTypeCode : employee.getExternalIdentifiers().keySet()) {
        if (KimConstants.PersonExternalIdentifierTypes.TAX.equals(externalIdentifierTypeCode)) {
            this.getDvPayeeDetail().setDisbVchrNonresidentPaymentCode(false);
        }
    }
    // Determine if employee is a research subject
    ParameterEvaluator researchPaymentReasonCodeEvaluator = /*REFACTORME*/
    SpringContext.getBean(ParameterEvaluatorService.class).getParameterEvaluator(DisbursementVoucherDocument.class, FPParameterConstants.RESEARCH_PAYMENT_REASONS, this.getDvPayeeDetail().getDisbVchrPaymentReasonCode());
    if (researchPaymentReasonCodeEvaluator.evaluationSucceeds()) {
        if (getParameterService().parameterExists(DisbursementVoucherDocument.class, FPParameterConstants.RESEARCH_NON_VENDOR_PAY_LIMIT_AMOUNT)) {
            String researchPayLimit = getParameterService().getParameterValueAsString(DisbursementVoucherDocument.class, FPParameterConstants.RESEARCH_NON_VENDOR_PAY_LIMIT_AMOUNT);
            if (StringUtils.isNotBlank(researchPayLimit)) {
                KualiDecimal payLimit = new KualiDecimal(researchPayLimit);
                if (getDisbVchrCheckTotalAmount().isLessThan(payLimit)) {
                    this.getDvPayeeDetail().setDvPayeeSubjectPaymentCode(true);
                }
            }
        }
    }
    this.disbVchrPayeeTaxControlCode = "";
    this.disbVchrPayeeW9CompleteCode = true;
}
Also used : ParameterService(org.kuali.kfs.coreservice.framework.parameter.ParameterService) EntityAddress(org.kuali.kfs.kim.impl.identity.address.EntityAddress) KualiDecimal(org.kuali.kfs.core.api.util.type.KualiDecimal) ParameterEvaluator(org.kuali.kfs.core.api.parameter.ParameterEvaluator) ParameterEvaluatorService(org.kuali.kfs.core.api.parameter.ParameterEvaluatorService)

Example 5 with EntityAddress

use of org.kuali.kfs.kim.impl.identity.address.EntityAddress in project cu-kfs by CU-CommunityApps.

the class DisbursementVoucherDocument method findAddressByType.

/**
 * Given a List of KimEntityAddress and an address type, finds the address in the List with the given type (or null
 * if no matching KimEntityAddress is found)
 *
 * @param addresses   the List of KimEntityAddress records to search
 * @param addressType the address type of the address to return
 * @return the found KimEntityAddress, or null if not found
 */
protected EntityAddress findAddressByType(List<EntityAddress> addresses, String addressType) {
    EntityAddress foundAddress = null;
    int count = 0;
    while (count < addresses.size() && foundAddress == null) {
        final EntityAddress currentAddress = addresses.get(count);
        if (currentAddress.isActive() && currentAddress.getAddressType().getCode().equals(addressType)) {
            foundAddress = currentAddress;
        }
        count += 1;
    }
    return foundAddress;
}
Also used : EntityAddress(org.kuali.kfs.kim.impl.identity.address.EntityAddress)

Aggregations

EntityAddress (org.kuali.kfs.kim.impl.identity.address.EntityAddress)9 ParameterEvaluator (org.kuali.kfs.core.api.parameter.ParameterEvaluator)4 ParameterEvaluatorService (org.kuali.kfs.core.api.parameter.ParameterEvaluatorService)4 KualiDecimal (org.kuali.kfs.core.api.util.type.KualiDecimal)4 ParameterService (org.kuali.kfs.coreservice.framework.parameter.ParameterService)4 CuDisbursementVoucherPayeeDetailExtension (edu.cornell.kfs.fp.businessobject.CuDisbursementVoucherPayeeDetailExtension)3 DisbursementVoucherDocument (org.kuali.kfs.fp.document.DisbursementVoucherDocument)3 Entity (org.kuali.kfs.kim.impl.identity.entity.Entity)1 EntityTypeContactInfo (org.kuali.kfs.kim.impl.identity.type.EntityTypeContactInfo)1