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;
}
Aggregations