use of edu.cornell.kfs.fp.businessobject.CuDisbursementVoucherPayeeDetail in project cu-kfs by CU-CommunityApps.
the class CuDisbursementVoucherExtractionHelperServiceImpl method createPaymentGroup.
@Override
public PaymentGroup createPaymentGroup(DisbursementVoucherDocument document, Date processRunDate) {
if (LOG.isDebugEnabled()) {
LOG.debug("createPaymentGroupForDisbursementVoucher() started");
}
PaymentGroup pg = new PaymentGroup();
pg.setCombineGroups(Boolean.TRUE);
pg.setCampusAddress(Boolean.FALSE);
CuDisbursementVoucherPayeeDetail pd = businessObjectService.findBySinglePrimaryKey(CuDisbursementVoucherPayeeDetail.class, document.getDocumentNumber());
String rc = pd.getDisbVchrPaymentReasonCode();
if (KFSConstants.PaymentPayeeTypes.CUSTOMER.equals(document.getDvPayeeDetail().getDisbursementVoucherPayeeTypeCode())) {
pg.setPayeeIdTypeCd(PdpConstants.PayeeIdTypeCodes.CUSTOMER);
pg.setTaxablePayment(Boolean.FALSE);
} else // If the payee is an employee, set these flags accordingly
if ((pd.isVendor() && SpringContext.getBean(VendorService.class).isVendorInstitutionEmployee(pd.getDisbVchrVendorHeaderIdNumberAsInteger())) || document.getDvPayeeDetail().isEmployee()) {
pg.setEmployeeIndicator(Boolean.TRUE);
pg.setPayeeIdTypeCd(PdpConstants.PayeeIdTypeCodes.EMPLOYEE);
pg.setTaxablePayment(!/*REFACTORME*/
getParameterEvaluatorService().getParameterEvaluator(DisbursementVoucherDocument.class, DisbursementVoucherConstants.RESEARCH_PAYMENT_REASONS_PARM_NM, rc).evaluationSucceeds() && !getParameterService().getParameterValueAsString(DisbursementVoucherDocument.class, DisbursementVoucherConstants.PAYMENT_REASON_CODE_RENTAL_PAYMENT_PARM_NM).equals(rc) && !getParameterService().getParameterValueAsString(DisbursementVoucherDocument.class, DisbursementVoucherConstants.PAYMENT_REASON_CODE_ROYALTIES_PARM_NM).equals(rc));
} else // If the payee is an alumni or student, set these flags accordingly
if (pd.isStudent() || pd.isAlumni()) {
pg.setPayeeIdTypeCd(PdpConstants.PayeeIdTypeCodes.ENTITY);
// All payments are taxable except research participant, rental & royalties
pg.setTaxablePayment(!SpringContext.getBean(ParameterEvaluatorService.class).getParameterEvaluator(CuDisbursementVoucherDocument.class, DisbursementVoucherConstants.RESEARCH_PAYMENT_REASONS_PARM_NM, rc).evaluationSucceeds() && !CuDisbursementVoucherConstants.PaymentReasonCodes.RENTAL_PAYMENT.equals(rc) && !CuDisbursementVoucherConstants.PaymentReasonCodes.ROYALTIES.equals(rc));
} else {
// These are taxable
VendorDetail vendDetail = getVendorService().getVendorDetail(pd.getDisbVchrVendorHeaderIdNumberAsInteger(), pd.getDisbVchrVendorDetailAssignedIdNumberAsInteger());
String vendorOwnerCode = vendDetail.getVendorHeader().getVendorOwnershipCode();
String vendorOwnerCategoryCode = vendDetail.getVendorHeader().getVendorOwnershipCategoryCode();
String payReasonCode = pd.getDisbVchrPaymentReasonCode();
pg.setPayeeIdTypeCd(PdpConstants.PayeeIdTypeCodes.VENDOR_ID);
// Assume it is not taxable until proven otherwise
pg.setTaxablePayment(Boolean.FALSE);
pg.setPayeeOwnerCd(vendorOwnerCode);
ParameterEvaluator parameterEvaluator1 = /*REFACTORME*/
getParameterEvaluatorService().getParameterEvaluator(DvToPdpExtractStep.class, PdpParameterConstants.TAXABLE_PAYMENT_REASON_CODES_BY_OWNERSHIP_CODES_PARAMETER_NAME, PdpParameterConstants.NON_TAXABLE_PAYMENT_REASON_CODES_BY_OWNERSHIP_CODES_PARAMETER_NAME, vendorOwnerCode, payReasonCode);
ParameterEvaluator parameterEvaluator2 = /*REFACTORME*/
getParameterEvaluatorService().getParameterEvaluator(DvToPdpExtractStep.class, PdpParameterConstants.TAXABLE_PAYMENT_REASON_CODES_BY_CORPORATION_OWNERSHIP_TYPE_CATEGORY_PARAMETER_NAME, PdpParameterConstants.NON_TAXABLE_PAYMENT_REASON_CODES_BY_CORPORATION_OWNERSHIP_TYPE_CATEGORY_PARAMETER_NAME, vendorOwnerCategoryCode, payReasonCode);
if (parameterEvaluator1.evaluationSucceeds()) {
pg.setTaxablePayment(Boolean.TRUE);
} else if (getParameterService().getParameterValueAsString(DvToPdpExtractStep.class, PdpParameterConstants.CORPORATION_OWNERSHIP_TYPE_PARAMETER_NAME).equals("CP") && StringUtils.isEmpty(vendorOwnerCategoryCode) && /*REFACTORME*/
getParameterEvaluatorService().getParameterEvaluator(DvToPdpExtractStep.class, PdpParameterConstants.TAXABLE_PAYMENT_REASON_CODES_FOR_BLANK_CORPORATION_OWNERSHIP_TYPE_CATEGORIES_PARAMETER_NAME, payReasonCode).evaluationSucceeds()) {
pg.setTaxablePayment(Boolean.TRUE);
} else if (getParameterService().getParameterValueAsString(DvToPdpExtractStep.class, PdpParameterConstants.CORPORATION_OWNERSHIP_TYPE_PARAMETER_NAME).equals("CP") && !StringUtils.isEmpty(vendorOwnerCategoryCode) && parameterEvaluator2.evaluationSucceeds()) {
pg.setTaxablePayment(Boolean.TRUE);
}
}
pg.setCity(pd.getDisbVchrPayeeCityName());
pg.setCountry(pd.getDisbVchrPayeeCountryCode());
pg.setLine1Address(pd.getDisbVchrPayeeLine1Addr());
pg.setLine2Address(pd.getDisbVchrPayeeLine2Addr());
pg.setPayeeName(pd.getDisbVchrPayeePersonName());
pg.setPayeeId(pd.getDisbVchrPayeeIdNumber());
pg.setState(pd.getDisbVchrPayeeStateCode());
pg.setZipCd(pd.getDisbVchrPayeeZipCode());
pg.setPaymentDate(document.getDisbursementVoucherDueDate());
pg.setProcessImmediate(document.isImmediatePaymentIndicator());
pg.setPymtAttachment(document.isDisbVchrAttachmentCode());
pg.setPymtSpecialHandling(document.isDisbVchrSpecialHandlingCode());
pg.setNraPayment(pd.isDisbVchrAlienPaymentCode());
pg.setBankCode(document.getDisbVchrBankCode());
pg.setPaymentStatusCode(PdpConstants.PaymentStatusCodes.OPEN);
// now add the payment detail
final PaymentDetail paymentDetail = buildPaymentDetail(document, processRunDate);
pg.addPaymentDetails(paymentDetail);
paymentDetail.setPaymentGroup(pg);
return pg;
}
use of edu.cornell.kfs.fp.businessobject.CuDisbursementVoucherPayeeDetail in project cu-kfs by CU-CommunityApps.
the class CuDisbursementVoucherPayeeInitiatorValidation method validate.
public boolean validate(AttributedDocumentEvent event) {
LOG.debug("validate start");
boolean isValid = true;
CuDisbursementVoucherDocument document = (CuDisbursementVoucherDocument) accountingDocumentForValidation;
CuDisbursementVoucherPayeeDetail payeeDetail = document.getDvPayeeDetail();
MessageMap errors = GlobalVariables.getMessageMap();
errors.addToErrorPath(KFSPropertyConstants.DOCUMENT);
String uuid = null;
// If payee is a vendor, then look up SSN and look for SSN in the employee table
if (payeeDetail.isVendor() && StringUtils.isNotBlank(payeeDetail.getDisbVchrVendorHeaderIdNumber())) {
VendorDetail dvVendor = retrieveVendorDetail(payeeDetail.getDisbVchrVendorHeaderIdNumberAsInteger(), payeeDetail.getDisbVchrVendorDetailAssignedIdNumberAsInteger());
// if the vendor tax type is SSN, then check the tax number
if (dvVendor != null && TAX_TYPE_SSN.equals(dvVendor.getVendorHeader().getVendorTaxTypeCode())) {
// check ssn against employee table
Person user = retrieveEmployeeBySSN(dvVendor.getVendorHeader().getVendorTaxNumber());
if (user != null) {
uuid = user.getPrincipalId();
}
}
} else if (payeeDetail.isEmployee()) {
Person employee = SpringContext.getBean(PersonService.class).getPersonByEmployeeId(payeeDetail.getDisbVchrEmployeeIdNumber());
uuid = employee.getPrincipalId();
} else if (payeeDetail.isStudent() || payeeDetail.isAlumni()) {
uuid = payeeDetail.getDisbVchrPayeeIdNumber();
}
// If a uuid was found for payee, check it against the initiator uuid
if (StringUtils.isNotBlank(uuid)) {
Person initUser = getInitiator(document);
if (uuid.equals(initUser.getPrincipalId())) {
errors.putError(DV_PAYEE_ID_NUMBER_PROPERTY_PATH, KFSKeyConstants.ERROR_PAYEE_INITIATOR);
isValid = false;
}
}
errors.removeFromErrorPath(KFSPropertyConstants.DOCUMENT);
return isValid;
}
use of edu.cornell.kfs.fp.businessobject.CuDisbursementVoucherPayeeDetail in project cu-kfs by CU-CommunityApps.
the class CuDisbursementVoucherDocumentTest method testClearPayee.
@Test
public void testClearPayee() throws Exception {
cuDisbursementVoucherDocument.setDvPayeeDetail(new CuDisbursementVoucherPayeeDetail());
cuDisbursementVoucherDocument.getDvPayeeDetail().setDisbVchrPayeeIdNumber("12345");
cuDisbursementVoucherDocument.clearDvPayeeIdType();
EasyMock.replay(cuDisbursementVoucherDocument);
cuDisbursementVoucherDocument.clearPayee(KFSKeyConstants.WARNING_DV_PAYEE_NONEXISTANT_CLEARED);
EasyMock.verify(cuDisbursementVoucherDocument);
assertTrue("Should be valid and have one error messages, but had " + KNSGlobalVariables.getMessageList().size(), KNSGlobalVariables.getMessageList().size() == 1);
assertEquals("The error message isn't what we expected.", KFSKeyConstants.WARNING_DV_PAYEE_NONEXISTANT_CLEARED, KNSGlobalVariables.getMessageList().get(0).getErrorKey());
assertEquals("DV Payee ID Number should be cleared", StringUtils.EMPTY, cuDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrPayeeIdNumber());
}
Aggregations