Search in sources :

Example 6 with EntityAddress

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

the class CuDisbursementVoucherDocument method templateEmployee.

public void templateEmployee(Person employee) {
    if (employee == null) {
        return;
    }
    this.getDvPayeeDetail().setDisbursementVoucherPayeeTypeCode(KFSConstants.PaymentPayeeTypes.EMPLOYEE);
    if (StringUtils.isNotBlank(employee.getEmployeeId())) {
        this.getDvPayeeDetail().setDisbVchrPayeeIdNumber(employee.getEmployeeId());
        ((CuDisbursementVoucherPayeeDetailExtension) this.getDvPayeeDetail().getExtension()).setDisbVchrPayeeIdType(CuDisbursementVoucherConstants.DV_PAYEE_ID_TYP_EMPL);
    } else {
        this.getDvPayeeDetail().setDisbVchrPayeeIdNumber(employee.getPrincipalId());
        ((CuDisbursementVoucherPayeeDetailExtension) this.getDvPayeeDetail().getExtension()).setDisbVchrPayeeIdType(CuDisbursementVoucherConstants.DV_PAYEE_ID_TYP_ENTITY);
    }
    ((CuDisbursementVoucherPayeeDetailExtension) this.getDvPayeeDetail().getExtension()).setPayeeTypeSuffix(StringUtils.EMPTY);
    // Changed this from employee.getName to employee.getNameUnmasked() otherwise "Xxxxxx" appears on the DV!
    this.getDvPayeeDetail().setDisbVchrPayeePersonName(employee.getNameUnmasked());
    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 = 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) 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 7 with EntityAddress

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

the class CuDisbursementVoucherDocument method templateAlumni.

/**
 * Convenience method to set dv payee detail fields based on a given Alumnus.
 *
 * @param alumni
 */
public void templateAlumni(Person alumni) {
    if (alumni == null) {
        return;
    }
    this.getDvPayeeDetail().setDisbursementVoucherPayeeTypeCode(CuDisbursementVoucherConstants.DV_PAYEE_TYPE_ALUMNI);
    this.getDvPayeeDetail().setDisbVchrPayeeIdNumber(alumni.getPrincipalId());
    ((CuDisbursementVoucherPayeeDetailExtension) this.getDvPayeeDetail().getExtension()).setDisbVchrPayeeIdType(CuDisbursementVoucherConstants.DV_PAYEE_ID_TYP_ENTITY);
    ((CuDisbursementVoucherPayeeDetailExtension) this.getDvPayeeDetail().getExtension()).setPayeeTypeSuffix(StringUtils.EMPTY);
    // Changed this from employee.getName to employee.getNameUnmasked() otherwise "Xxxxxx" appears on the DV!
    this.getDvPayeeDetail().setDisbVchrPayeePersonName(alumni.getNameUnmasked());
    final ParameterService parameterService = this.getParameterService();
    // Use the same parameter as for employees even though this is a alumni 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(alumni.getAddressLine1Unmasked());
        this.getDvPayeeDetail().setDisbVchrPayeeLine2Addr(alumni.getAddressLine2Unmasked());
        this.getDvPayeeDetail().setDisbVchrPayeeCityName(alumni.getAddressCityUnmasked());
        this.getDvPayeeDetail().setDisbVchrPayeeStateCode(alumni.getAddressStateProvinceCodeUnmasked());
        this.getDvPayeeDetail().setDisbVchrPayeeZipCode(alumni.getAddressPostalCodeUnmasked());
        this.getDvPayeeDetail().setDisbVchrPayeeCountryCode(alumni.getAddressCountryCodeUnmasked());
    } else {
        final EntityAddress address = getNonDefaultAddress(alumni);
        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(alumni.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 alumni must be foreign
    for (String externalIdentifierTypeCode : alumni.getExternalIdentifiers().keySet()) {
        if (KimConstants.PersonExternalIdentifierTypes.TAX.equals(externalIdentifierTypeCode)) {
            this.getDvPayeeDetail().setDisbVchrNonresidentPaymentCode(false);
        }
    }
    // Determine if alumni is a research subject
    ParameterEvaluator researchPaymentReasonCodeEvaluator = 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) 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 8 with EntityAddress

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

the class IWantDocumentServiceImpl method getPersonEntityAddress.

/**
 * Gets Person entity address.
 *
 * @param entityEntityType
 * @return Person entity address
 */
protected EntityAddress getPersonEntityAddress(String principalName) {
    List<? extends EntityAddress> addresses = KimApiServiceLocator.getIdentityService().getEntityByPrincipalName(principalName).getEntityTypeContactInfoByTypeCode(KimConstants.EntityTypes.PERSON).getAddresses();
    EntityAddress foundAddress = null;
    int count = 0;
    while (count < addresses.size() && foundAddress == null) {
        final EntityAddress currentAddress = addresses.get(count);
        if (CMP_ADDRESS_TYPE.equals(currentAddress.getAddressType().getCode())) {
            foundAddress = currentAddress;
        }
        count += 1;
    }
    return foundAddress;
}
Also used : EntityAddress(org.kuali.kfs.kim.impl.identity.address.EntityAddress)

Example 9 with EntityAddress

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

the class PersonImpl method populateAddressInfo.

protected void populateAddressInfo(EntityTypeContactInfo contactInfoDefault) {
    if (contactInfoDefault != null) {
        EntityAddress defaultAddress = contactInfoDefault.getDefaultAddress();
        if (defaultAddress != null) {
            address = defaultAddress;
        } else {
            address = new EntityAddress();
            address.setEntityId(contactInfoDefault.getEntityId());
            address.setCity("");
            address.setCountryCode("");
            address.setLine1("");
            address.setLine2("");
            address.setLine3("");
            address.setCity("");
            address.setPostalCode("");
            address.setStateProvinceCode("");
            address.setActive(true);
        }
    }
}
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