Search in sources :

Example 6 with CuDisbursementVoucherPayeeDetailExtension

use of edu.cornell.kfs.fp.businessobject.CuDisbursementVoucherPayeeDetailExtension 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, DisbursementVoucherDocument.USE_DEFAULT_EMPLOYEE_ADDRESS_PARAMETER_NAME) && parameterService.getParameterValueAsBoolean(DisbursementVoucherDocument.class, DisbursementVoucherDocument.USE_DEFAULT_EMPLOYEE_ADDRESS_PARAMETER_NAME)) {
        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("");
        }
    }
    // KFSMI-8935: When an employee is inactive, the Payment Type field on DV documents should display the message "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().setDisbVchrAlienPaymentCode(false);
        }
    }
    // Determine if employee is a research subject
    ParameterEvaluator researchPaymentReasonCodeEvaluator = SpringContext.getBean(ParameterEvaluatorService.class).getParameterEvaluator(DisbursementVoucherDocument.class, DisbursementVoucherConstants.RESEARCH_PAYMENT_REASONS_PARM_NM, this.getDvPayeeDetail().getDisbVchrPaymentReasonCode());
    if (researchPaymentReasonCodeEvaluator.evaluationSucceeds()) {
        if (getParameterService().parameterExists(DisbursementVoucherDocument.class, DisbursementVoucherConstants.RESEARCH_NON_VENDOR_PAY_LIMIT_AMOUNT_PARM_NM)) {
            String researchPayLimit = getParameterService().getParameterValueAsString(DisbursementVoucherDocument.class, DisbursementVoucherConstants.RESEARCH_NON_VENDOR_PAY_LIMIT_AMOUNT_PARM_NM);
            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.rice.kim.api.identity.address.EntityAddress) KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal) ParameterEvaluator(org.kuali.rice.core.api.parameter.ParameterEvaluator) ParameterEvaluatorService(org.kuali.rice.core.api.parameter.ParameterEvaluatorService) DisbursementVoucherDocument(org.kuali.kfs.fp.document.DisbursementVoucherDocument)

Aggregations

CuDisbursementVoucherPayeeDetailExtension (edu.cornell.kfs.fp.businessobject.CuDisbursementVoucherPayeeDetailExtension)6 ParameterService (org.kuali.kfs.coreservice.framework.parameter.ParameterService)3 DisbursementVoucherDocument (org.kuali.kfs.fp.document.DisbursementVoucherDocument)3 ParameterEvaluator (org.kuali.rice.core.api.parameter.ParameterEvaluator)3 ParameterEvaluatorService (org.kuali.rice.core.api.parameter.ParameterEvaluatorService)3 KualiDecimal (org.kuali.rice.core.api.util.type.KualiDecimal)3 EntityAddress (org.kuali.rice.kim.api.identity.address.EntityAddress)3 TransactionalDocumentAuthorizer (org.kuali.kfs.kns.document.authorization.TransactionalDocumentAuthorizer)2 DisbursementVoucherWireTransferExtendedAttribute (edu.cornell.kfs.fp.businessobject.DisbursementVoucherWireTransferExtendedAttribute)1 VendorDetailExtension (edu.cornell.kfs.vnd.businessobject.VendorDetailExtension)1 Date (java.sql.Date)1 DocumentAuthorizer (org.kuali.kfs.kns.document.authorization.DocumentAuthorizer)1 AmountTotaling (org.kuali.kfs.sys.document.AmountTotaling)1 VendorDetail (org.kuali.kfs.vnd.businessobject.VendorDetail)1