use of org.kuali.kfs.core.api.parameter.ParameterEvaluator 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;
}
use of org.kuali.kfs.core.api.parameter.ParameterEvaluator in project cu-kfs by CU-CommunityApps.
the class CuDisbursementVoucherDocument method isTravelReviewRequired.
public boolean isTravelReviewRequired() {
List<AccountingLine> theList = (List<AccountingLine>) this.sourceAccountingLines;
for (AccountingLine alb : theList) {
ParameterEvaluator objectCodes = SpringContext.getBean(ParameterEvaluatorService.class).getParameterEvaluator("KFS-FP", "DisbursementVoucher", OBJECT_CODES_REQUIRING_TRAVEL_REVIEW, alb.getFinancialObjectCode());
if (objectCodes.evaluationSucceeds()) {
LOG.info("Object Code " + alb.getFinancialObjectCode() + " requires this document to undergo Travel review.");
return true;
}
}
boolean overDollarThreshold = false;
String dollarThreshold = getParameterService().getParameterValueAsString("KFS-FP", "DisbursementVoucher", DOLLAR_THRESHOLD_REQUIRING_TRAVEL_REVIEW);
KualiDecimal dollarThresholdDecimal = new KualiDecimal(dollarThreshold);
if (this.disbVchrCheckTotalAmount.isGreaterEqual(dollarThresholdDecimal)) {
overDollarThreshold = true;
}
String paymentReasonCode = this.getDvPayeeDetail().getDisbVchrPaymentReasonCode();
return (this.getDisbursementVoucherPaymentReasonService().isPrepaidTravelPaymentReason(paymentReasonCode) || this.getDisbursementVoucherPaymentReasonService().isNonEmployeeTravelPaymentReason(paymentReasonCode) && overDollarThreshold);
}
use of org.kuali.kfs.core.api.parameter.ParameterEvaluator 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 ((pd.isVendor() && vendorService.isVendorInstitutionEmployee(pd.getDisbVchrVendorHeaderIdNumberAsInteger())) || document.getDvPayeeDetail().isEmployee()) {
// If the payee is an employee, set these flags accordingly
pg.setEmployeeIndicator(Boolean.TRUE);
pg.setPayeeIdTypeCd(PdpConstants.PayeeIdTypeCodes.EMPLOYEE);
pg.setTaxablePayment(parameterEvaluatorService.getParameterEvaluator(DisbursementVoucherDocument.class, FPParameterConstants.RESEARCH_PAYMENT_REASONS, rc).evaluationSucceeds() && !parameterService.getParameterValueAsString(DisbursementVoucherDocument.class, FPParameterConstants.PAYMENT_REASON_CODE_RENTAL_PAYMENT).equals(rc) && !parameterService.getParameterValueAsString(DisbursementVoucherDocument.class, FPParameterConstants.PAYMENT_REASON_CODE_ROYALTIES).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(!parameterEvaluatorService.getParameterEvaluator(CuDisbursementVoucherDocument.class, FPParameterConstants.RESEARCH_PAYMENT_REASONS, rc).evaluationSucceeds() && !CuDisbursementVoucherConstants.PaymentReasonCodes.RENTAL_PAYMENT.equals(rc) && !CuDisbursementVoucherConstants.PaymentReasonCodes.ROYALTIES.equals(rc));
} else {
// These are taxable
VendorDetail vendDetail = vendorService.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*/
parameterEvaluatorService.getParameterEvaluator(DvToPdpExtractStep.class, FPParameterConstants.TAXABLE_PAYMENT_REASON_CODES_BY_OWNERSHIP_CODES, FPParameterConstants.NON_TAXABLE_PAYMENT_REASON_CODES_BY_OWNERSHIP_CODES, vendorOwnerCode, payReasonCode);
ParameterEvaluator parameterEvaluator2 = /*REFACTORME*/
parameterEvaluatorService.getParameterEvaluator(DvToPdpExtractStep.class, FPParameterConstants.TAXABLE_PAYMENT_REASON_CODES_BY_CORPORATION_OWNERSHIP_TYPE_CATEGORY, FPParameterConstants.NON_TAXABLE_PAYMENT_REASON_CODES_BY_CORPORATION_OWNERSHIP_TYPE_CATEGORY, vendorOwnerCategoryCode, payReasonCode);
if (parameterEvaluator1.evaluationSucceeds()) {
pg.setTaxablePayment(Boolean.TRUE);
} else if (parameterService.getParameterValueAsString(DvToPdpExtractStep.class, FPParameterConstants.CORPORATION_OWNERSHIP_TYPE).equals("CP") && StringUtils.isEmpty(vendorOwnerCategoryCode) && /*REFACTORME*/
parameterEvaluatorService.getParameterEvaluator(DvToPdpExtractStep.class, FPParameterConstants.TAXABLE_PAYMENT_REASON_CODES_FOR_BLANK_CORPORATION_OWNERSHIP_TYPE_CATEGORIES, payReasonCode).evaluationSucceeds()) {
pg.setTaxablePayment(Boolean.TRUE);
} else if (parameterService.getParameterValueAsString(DvToPdpExtractStep.class, FPParameterConstants.CORPORATION_OWNERSHIP_TYPE).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.setNonresidentPayment(pd.isDisbVchrNonresidentPaymentCode());
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 org.kuali.kfs.core.api.parameter.ParameterEvaluator in project cu-kfs by CU-CommunityApps.
the class CuBalanceServiceImpl method findReversionBalancesForFiscalYear.
/**
* Returns all of the balances to be forwarded for the organization reversion process
* @param year the year of balances to find
* @param endOfYear whether the organization reversion process is running end of year (before the fiscal year change over) or
* beginning of year (after the fiscal year change over)
* @return an iterator of balances to put through the strenuous organization reversion process
* @see org.kuali.kfs.gl.service.BalanceService#findOrganizationReversionBalancesForFiscalYear(java.lang.Integer, boolean)
*/
public Iterator<Balance> findReversionBalancesForFiscalYear(Integer year, boolean endOfYear) {
SystemOptions options = optionsService.getOptions(year);
List<ParameterEvaluator> parameterEvaluators = new ArrayList<ParameterEvaluator>();
int i = 1;
boolean moreParams = true;
while (moreParams) {
if (parameterService.parameterExists(Reversion.class, PARAMETER_PREFIX + i)) {
ParameterEvaluator parameterEvaluator = getParameterEvaluatorService().getParameterEvaluator(Reversion.class, PARAMETER_PREFIX + i);
parameterEvaluators.add(parameterEvaluator);
} else {
moreParams = false;
}
i++;
}
return ((CuBalanceDao) balanceDao).findReversionBalancesForFiscalYear(year, endOfYear, options, parameterEvaluators);
}
use of org.kuali.kfs.core.api.parameter.ParameterEvaluator in project cu-kfs by CU-CommunityApps.
the class CuBalanceDaoOjb method findReversionBalancesForFiscalYear.
/**
* Returns a list of balances to return for the Organization Reversion year end job to process
*
* @param year the university fiscal year to find balances for
* @param endOfYear if true, use currrent year accounts, otherwise use prior year accounts
* @return an Iterator of Balances to process
* @see org.kuali.kfs.gl.dataaccess.BalanceDao#findOrganizationReversionBalancesForFiscalYear(java.lang.Integer, boolean,
* org.kuali.kfs.sys.businessobject.SystemOptions, java.util.List)
*/
@SuppressWarnings({ "deprecation", "unchecked" })
public Iterator<Balance> findReversionBalancesForFiscalYear(Integer year, boolean endOfYear, SystemOptions options, List<ParameterEvaluator> parameterEvaluators) {
LOG.debug("findReversionBalancesForFiscalYear() started");
Criteria c = new Criteria();
c.addEqualTo(KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR, year);
for (ParameterEvaluator parameterEvaluator : parameterEvaluators) {
String currentRule = parameterEvaluator.getValue();
if (endOfYear) {
currentRule = currentRule.replaceAll("account\\.", "priorYearAccount.");
}
if (StringUtils.isNotBlank(currentRule)) {
String propertyName = StringUtils.substringBefore(currentRule, "=");
List<String> ruleValues = Arrays.asList(StringUtils.substringAfter(currentRule, "=").split(";"));
if (propertyName != null && propertyName.length() > 0 && ruleValues.size() > 0 && !StringUtils.isBlank(ruleValues.get(0))) {
if (parameterEvaluator.constraintIsAllow()) {
c.addIn(propertyName, ruleValues);
} else {
c.addNotIn(propertyName, ruleValues);
}
}
}
}
// we only ever calculate on CB, AC, and encumbrance types, so let's only select those
List<String> reversionBalancesToSelect = new ArrayList<String>();
reversionBalancesToSelect.add(options.getActualFinancialBalanceTypeCd());
reversionBalancesToSelect.add(options.getFinObjTypeExpenditureexpCd());
reversionBalancesToSelect.add(options.getCostShareEncumbranceBalanceTypeCd());
reversionBalancesToSelect.add(options.getIntrnlEncumFinBalanceTypCd());
reversionBalancesToSelect.add(KFSConstants.BALANCE_TYPE_CURRENT_BUDGET);
c.addIn(KFSPropertyConstants.BALANCE_TYPE_CODE, reversionBalancesToSelect);
QueryByCriteria query = QueryFactory.newQuery(Balance.class, c);
query.addOrderByAscending(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE);
query.addOrderByAscending(KFSPropertyConstants.ACCOUNT_NUMBER);
query.addOrderByAscending(KFSPropertyConstants.SUB_ACCOUNT_NUMBER);
query.addOrderByAscending(KFSPropertyConstants.OBJECT_CODE);
query.addOrderByAscending(KFSPropertyConstants.SUB_OBJECT_CODE);
query.addOrderByAscending(KFSPropertyConstants.BALANCE_TYPE_CODE);
query.addOrderByAscending(KFSPropertyConstants.OBJECT_TYPE_CODE);
return getPersistenceBrokerTemplate().getIteratorByQuery(query);
}
Aggregations