use of org.kuali.kfs.module.ld.businessobject.PositionObjectBenefit in project cu-kfs by CU-CommunityApps.
the class CuLaborPendingEntryGenerator method generateBenefitPendingEntries.
public static List<LaborLedgerPendingEntry> generateBenefitPendingEntries(LaborLedgerPostingDocument document, ExpenseTransferAccountingLine accountingLine, GeneralLedgerPendingEntrySequenceHelper sequenceHelper) {
accountingLine.refreshReferenceObject(KFSPropertyConstants.LABOR_OBJECT);
if (ObjectUtils.isNull(accountingLine.getLaborObject())) {
return null;
}
String FringeOrSalaryCode = accountingLine.getLaborObject().getFinancialObjectFringeOrSalaryCode();
if (!LaborConstants.SalaryExpenseTransfer.LABOR_LEDGER_SALARY_CODE.equals(FringeOrSalaryCode)) {
return null;
}
Integer payrollFiscalyear = accountingLine.getPayrollEndDateFiscalYear();
String chartOfAccountsCode = accountingLine.getChartOfAccountsCode();
String objectCode = accountingLine.getFinancialObjectCode();
Collection<PositionObjectBenefit> positionObjectBenefits = SpringContext.getBean(LaborPositionObjectBenefitService.class).getActivePositionObjectBenefits(payrollFiscalyear, chartOfAccountsCode, objectCode);
List<LaborLedgerPendingEntry> benefitPendingEntries = new ArrayList<LaborLedgerPendingEntry>();
for (PositionObjectBenefit positionObjectBenefit : positionObjectBenefits) {
positionObjectBenefit.setLaborBenefitRateCategoryCode(accountingLine.getAccount().getLaborBenefitRateCategoryCode());
String fringeBenefitObjectCode = retrieveFringeBenefitObjectCode(accountingLine, chartOfAccountsCode);
KualiDecimal benefitAmount = SpringContext.getBean(LaborBenefitsCalculationService.class).calculateFringeBenefit(positionObjectBenefit, accountingLine.getAmount(), accountingLine.getAccountNumber(), accountingLine.getSubAccountNumber());
if (benefitAmount.isNonZero() && positionObjectBenefit.getBenefitsCalculation().isActive()) {
ParameterService parameterService = SpringContext.getBean(ParameterService.class);
Boolean enableFringeBenefitCalculationByBenefitRate = parameterService.getParameterValueAsBoolean(KfsParameterConstants.FINANCIAL_SYSTEM_ALL.class, LaborConstants.BenefitCalculation.ENABLE_FRINGE_BENEFIT_CALC_BY_BENEFIT_RATE_CATEGORY_PARAMETER);
// If fringeBenefitObjectCode is empty and its enable to use calculation by benefit rate
if (StringUtils.isEmpty(fringeBenefitObjectCode) && enableFringeBenefitCalculationByBenefitRate) {
String laborBenefitRateCategoryCode = positionObjectBenefit.getLaborBenefitRateCategoryCode();
// Use parameter default if labor benefit rate category code is blank
if (StringUtils.isBlank(laborBenefitRateCategoryCode)) {
laborBenefitRateCategoryCode = parameterService.getParameterValueAsString(Account.class, LaborConstants.BenefitCalculation.DEFAULT_BENEFIT_RATE_CATEGORY_CODE_PARAMETER);
}
// create a map for the search criteria to lookup the fringe benefit percentage
Map<String, Object> fieldValues = new HashMap<String, Object>();
fieldValues.put(KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR, positionObjectBenefit.getUniversityFiscalYear());
fieldValues.put(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE, positionObjectBenefit.getChartOfAccountsCode());
fieldValues.put(LaborPropertyConstants.POSITION_BENEFIT_TYPE_CODE, positionObjectBenefit.getFinancialObjectBenefitsTypeCode());
fieldValues.put(LaborPropertyConstants.LABOR_BENEFIT_RATE_CATEGORY_CODE, laborBenefitRateCategoryCode);
BenefitsCalculation bc = (BenefitsCalculation) SpringContext.getBean(BusinessObjectService.class).findByPrimaryKey(BenefitsCalculation.class, fieldValues);
fringeBenefitObjectCode = bc.getPositionFringeBenefitObjectCode();
}
List<LaborLedgerPendingEntry> pendingEntries = generateBenefitPendingEntries(document, accountingLine, sequenceHelper, benefitAmount, fringeBenefitObjectCode);
benefitPendingEntries.addAll(pendingEntries);
}
}
return benefitPendingEntries;
}
use of org.kuali.kfs.module.ld.businessobject.PositionObjectBenefit in project cu-kfs by CU-CommunityApps.
the class CuLaborPendingEntryGenerator method updateBenefitAmountSumObject.
protected static void updateBenefitAmountSumObject(Map<String, Map<String, KualiDecimal>> benefitAmountSumByBenefitType, ExpenseTransferAccountingLine accountingLine) {
accountingLine.refreshReferenceObject(KFSPropertyConstants.LABOR_OBJECT);
if (ObjectUtils.isNull(accountingLine.getLaborObject())) {
return;
}
String fringeOrSalaryCode = accountingLine.getLaborObject().getFinancialObjectFringeOrSalaryCode();
if (!LaborConstants.SalaryExpenseTransfer.LABOR_LEDGER_SALARY_CODE.equals(fringeOrSalaryCode)) {
return;
}
Integer payrollFiscalyear = accountingLine.getPayrollEndDateFiscalYear();
String chartOfAccountsCode = accountingLine.getChartOfAccountsCode();
String objectCode = accountingLine.getFinancialObjectCode();
String fringeBenefitObjectCode = retrieveFringeBenefitObjectCode(accountingLine, chartOfAccountsCode);
Collection<PositionObjectBenefit> positionObjectBenefits = SpringContext.getBean(LaborPositionObjectBenefitService.class).getPositionObjectBenefits(payrollFiscalyear, chartOfAccountsCode, objectCode);
for (PositionObjectBenefit positionObjectBenefit : positionObjectBenefits) {
String tmpLaborBenefitRateCategoryCode = accountingLine.getAccount().getLaborBenefitRateCategoryCode();
positionObjectBenefit.setLaborBenefitRateCategoryCode(tmpLaborBenefitRateCategoryCode);
String benefitTypeCode = positionObjectBenefit.getBenefitsCalculation().getPositionBenefitTypeCode();
Map<String, KualiDecimal> benefitSumsByObjectCode = new HashMap<String, KualiDecimal>();
KualiDecimal benefitAmount = SpringContext.getBean(LaborBenefitsCalculationService.class).calculateFringeBenefit(positionObjectBenefit, accountingLine.getAmount(), accountingLine.getAccountNumber(), accountingLine.getSubAccountNumber());
if (benefitAmountSumByBenefitType.containsKey(benefitTypeCode)) {
benefitSumsByObjectCode = benefitAmountSumByBenefitType.get(benefitTypeCode);
if (benefitSumsByObjectCode.containsKey(fringeBenefitObjectCode)) {
benefitAmount = benefitAmount.add(benefitSumsByObjectCode.get(fringeBenefitObjectCode));
}
benefitSumsByObjectCode.put(fringeBenefitObjectCode, benefitAmount);
} else {
benefitSumsByObjectCode.put(fringeBenefitObjectCode, benefitAmount);
benefitAmountSumByBenefitType.put(benefitTypeCode, benefitSumsByObjectCode);
}
benefitAmountSumByBenefitType.put(benefitTypeCode, benefitSumsByObjectCode);
}
}
use of org.kuali.kfs.module.ld.businessobject.PositionObjectBenefit in project cu-kfs by CU-CommunityApps.
the class CuFileEnterpriseFeederHelperServiceImpl method generateOffsets.
protected List<LaborOriginEntry> generateOffsets(LaborOriginEntry wageEntry, String offsetDocTypes) {
List<LaborOriginEntry> offsetEntries = new ArrayList<LaborOriginEntry>();
String benefitRateCategoryCode = laborBenefitsCalculationService.getBenefitRateCategoryCode(wageEntry.getChartOfAccountsCode(), wageEntry.getAccountNumber(), wageEntry.getSubAccountNumber());
Collection<PositionObjectBenefit> positionObjectBenefits = laborPositionObjectBenefitService.getActivePositionObjectBenefits(wageEntry.getUniversityFiscalYear(), wageEntry.getChartOfAccountsCode(), wageEntry.getFinancialObjectCode());
if (positionObjectBenefits == null || positionObjectBenefits.isEmpty()) {
return offsetEntries;
}
for (PositionObjectBenefit positionObjectBenefit : positionObjectBenefits) {
Map<String, Object> fieldValues = new HashMap<String, Object>();
fieldValues.put(KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR, wageEntry.getUniversityFiscalYear());
fieldValues.put(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE, wageEntry.getChartOfAccountsCode());
fieldValues.put(LaborPropertyConstants.POSITION_BENEFIT_TYPE_CODE, positionObjectBenefit.getFinancialObjectBenefitsTypeCode());
fieldValues.put(LaborPropertyConstants.LABOR_BENEFIT_RATE_CATEGORY_CODE, benefitRateCategoryCode);
BenefitsCalculation benefitsCalculation = (org.kuali.kfs.module.ld.businessobject.BenefitsCalculation) SpringContext.getBean(BusinessObjectService.class).findByPrimaryKey(BenefitsCalculation.class, fieldValues);
if (ObjectUtils.isNull(benefitsCalculation))
continue;
LaborOriginEntry offsetEntry = new LaborOriginEntry(wageEntry);
offsetEntry.setFinancialObjectCode(benefitsCalculation.getPositionFringeBenefitObjectCode());
// calculate the offsetAmount amount (ledger amt * (benfit pct/100) )
KualiDecimal fringeBenefitPercent = benefitsCalculation.getPositionFringeBenefitPercent();
KualiDecimal offsetAmount = fringeBenefitPercent.multiply(wageEntry.getTransactionLedgerEntryAmount()).divide(KFSConstants.ONE_HUNDRED.kualiDecimalValue());
offsetEntry.setTransactionLedgerEntryAmount(offsetAmount.abs());
offsetEntry.setAccountNumber(benefitsCalculation.getAccountCodeOffset());
offsetEntry.setFinancialObjectCode(benefitsCalculation.getObjectCodeOffset());
// Set all the fields required to process through the scrubber and poster jobs
offsetEntry.setUniversityFiscalPeriodCode(wageEntry.getUniversityFiscalPeriodCode());
offsetEntry.setChartOfAccountsCode(wageEntry.getChartOfAccountsCode());
offsetEntry.setUniversityFiscalYear(wageEntry.getUniversityFiscalYear());
offsetEntry.setSubAccountNumber("-----");
offsetEntry.setFinancialSubObjectCode("---");
offsetEntry.setOrganizationReferenceId("");
offsetEntry.setProjectCode("");
offsetEntry.setTransactionLedgerEntryDescription("GENERATED BENEFIT OFFSET");
String originCode = parameterService.getParameterValueAsString(LaborEnterpriseFeedStep.class, LdConstants.LABOR_BENEFIT_OFFSET_ORIGIN_CODE);
offsetEntry.setFinancialSystemOriginationCode(originCode);
offsetEntry.setDocumentNumber(wageEntry.getDocumentNumber());
if (!wageEntry.getTransactionDebitCreditCode().equalsIgnoreCase("D")) {
offsetAmount = offsetAmount.multiply(new KualiDecimal(-1));
}
if (offsetAmount.isGreaterThan(new KualiDecimal(0))) {
offsetEntry.setTransactionDebitCreditCode("C");
} else if (offsetAmount.isLessThan(new KualiDecimal(0))) {
offsetEntry.setTransactionDebitCreditCode("D");
}
String docTypeCode = offsetDocTypes;
if (offsetDocTypes.contains(",")) {
String[] splits = offsetDocTypes.split(",");
for (String split : splits) {
if (!StringUtils.isEmpty(split)) {
docTypeCode = split;
break;
}
}
}
offsetEntry.setFinancialDocumentTypeCode(docTypeCode);
offsetEntries.add(offsetEntry);
}
return offsetEntries;
}
use of org.kuali.kfs.module.ld.businessobject.PositionObjectBenefit in project cu-kfs by CU-CommunityApps.
the class CuLaborPendingEntryConverterServiceImpl method getOffsetPendingEntries.
/**
* convert the given document and accounting line into the benefit pending entries
*
* @param document the given accounting document
* @param accountingLine the given accounting line
* @param sequenceHelper the given sequence helper
* @param benefitAmount the given benefit amount
* @param fringeBenefitObjectCode the given fringe benefit object code
* @return a set of benefit pending entries
*/
public List<LaborLedgerPendingEntry> getOffsetPendingEntries(LaborLedgerPendingEntry pendingEntry, GeneralLedgerPendingEntrySequenceHelper sequenceHelper) {
List<LaborLedgerPendingEntry> offsetEntries = new ArrayList<LaborLedgerPendingEntry>();
String benefitRateCategoryCode = SpringContext.getBean(LaborBenefitsCalculationService.class).getBenefitRateCategoryCode(pendingEntry.getChartOfAccountsCode(), pendingEntry.getAccountNumber(), pendingEntry.getSubAccountNumber());
Collection<PositionObjectBenefit> positionObjectBenefits = SpringContext.getBean(LaborPositionObjectBenefitService.class).getActivePositionObjectBenefits(pendingEntry.getUniversityFiscalYear(), pendingEntry.getChartOfAccountsCode(), pendingEntry.getFinancialObjectCode());
if (positionObjectBenefits == null || positionObjectBenefits.isEmpty()) {
return offsetEntries;
}
for (PositionObjectBenefit positionObjectBenefit : positionObjectBenefits) {
Map<String, Object> fieldValues = new HashMap<String, Object>();
fieldValues.put(KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR, pendingEntry.getUniversityFiscalYear());
fieldValues.put(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE, pendingEntry.getChartOfAccountsCode());
fieldValues.put(LaborPropertyConstants.POSITION_BENEFIT_TYPE_CODE, positionObjectBenefit.getFinancialObjectBenefitsTypeCode());
fieldValues.put(LaborPropertyConstants.LABOR_BENEFIT_RATE_CATEGORY_CODE, benefitRateCategoryCode);
BenefitsCalculation benefitsCalculation = SpringContext.getBean(BusinessObjectService.class).findByPrimaryKey(BenefitsCalculation.class, fieldValues);
if (ObjectUtils.isNull(benefitsCalculation)) {
continue;
}
LaborLedgerPendingEntry offsetEntry = new LaborLedgerPendingEntry();
// Copy values from pending entry
offsetEntry.setReferenceFinancialDocumentNumber(pendingEntry.getReferenceFinancialDocumentNumber());
offsetEntry.setReferenceFinancialDocumentTypeCode(pendingEntry.getReferenceFinancialDocumentTypeCode());
offsetEntry.setFinancialDocumentReversalDate(pendingEntry.getFinancialDocumentReversalDate());
offsetEntry.setFinancialBalanceTypeCode(pendingEntry.getFinancialBalanceTypeCode());
offsetEntry.setFinancialObjectTypeCode(pendingEntry.getFinancialObjectTypeCode());
offsetEntry.setReferenceFinancialSystemOriginationCode(pendingEntry.getReferenceFinancialSystemOriginationCode());
offsetEntry.setOrganizationDocumentNumber(pendingEntry.getOrganizationDocumentNumber());
offsetEntry.setTransactionDate(pendingEntry.getTransactionDate());
offsetEntry.setTransactionDebitCreditCode(pendingEntry.getTransactionDebitCreditCode());
offsetEntry.setTransactionEncumbranceUpdateCode(pendingEntry.getTransactionEncumbranceUpdateCode());
offsetEntry.setPositionNumber(pendingEntry.getPositionNumber());
offsetEntry.setTransactionPostingDate(pendingEntry.getTransactionPostingDate());
offsetEntry.setPayPeriodEndDate(pendingEntry.getPayPeriodEndDate());
offsetEntry.setTransactionTotalHours(pendingEntry.getTransactionTotalHours());
offsetEntry.setPayrollEndDateFiscalYear(pendingEntry.getPayrollEndDateFiscalYear());
offsetEntry.setPayrollEndDateFiscalPeriodCode(pendingEntry.getPayrollEndDateFiscalPeriodCode());
offsetEntry.setEmplid(pendingEntry.getEmplid());
offsetEntry.setEmployeeRecord(pendingEntry.getEmployeeRecord());
offsetEntry.setEarnCode(pendingEntry.getEarnCode());
offsetEntry.setPayGroup(pendingEntry.getPayGroup());
offsetEntry.setSalaryAdministrationPlan(pendingEntry.getSalaryAdministrationPlan());
offsetEntry.setGrade(pendingEntry.getGrade());
offsetEntry.setRunIdentifier(pendingEntry.getRunIdentifier());
offsetEntry.setLaborLedgerOriginalChartOfAccountsCode(pendingEntry.getLaborLedgerOriginalChartOfAccountsCode());
offsetEntry.setLaborLedgerOriginalAccountNumber(pendingEntry.getLaborLedgerOriginalAccountNumber());
offsetEntry.setLaborLedgerOriginalSubAccountNumber(pendingEntry.getLaborLedgerOriginalSubAccountNumber());
offsetEntry.setLaborLedgerOriginalFinancialObjectCode(pendingEntry.getLaborLedgerOriginalFinancialObjectCode());
offsetEntry.setLaborLedgerOriginalFinancialSubObjectCode(pendingEntry.getLaborLedgerOriginalFinancialSubObjectCode());
offsetEntry.setHrmsCompany(pendingEntry.getHrmsCompany());
offsetEntry.setSetid(pendingEntry.getSetid());
offsetEntry.setTransactionEntryOffsetCode(pendingEntry.getTransactionEntryOffsetCode());
offsetEntry.setPayrollEndDateFiscalPeriod(pendingEntry.getPayrollEndDateFiscalPeriod());
// New offset values
offsetEntry.setFinancialObjectCode(benefitsCalculation.getPositionFringeBenefitObjectCode());
offsetEntry.setTransactionLedgerEntrySequenceNumber(getNextSequenceNumber(sequenceHelper));
// calculate the offsetAmount amount (ledger amt * (benfit pct/100) )
KualiDecimal fringeBenefitPercent = benefitsCalculation.getPositionFringeBenefitPercent();
KualiDecimal offsetAmount = fringeBenefitPercent.multiply(pendingEntry.getTransactionLedgerEntryAmount()).divide(KFSConstants.ONE_HUNDRED.kualiDecimalValue());
offsetEntry.setTransactionLedgerEntryAmount(offsetAmount.abs());
offsetEntry.setAccountNumber(benefitsCalculation.getAccountCodeOffset());
offsetEntry.setFinancialObjectCode(benefitsCalculation.getObjectCodeOffset());
// Set all the fields required to process through the scrubber and poster jobs
offsetEntry.setUniversityFiscalPeriodCode(pendingEntry.getUniversityFiscalPeriodCode());
offsetEntry.setChartOfAccountsCode(pendingEntry.getChartOfAccountsCode());
offsetEntry.setUniversityFiscalYear(pendingEntry.getUniversityFiscalYear());
offsetEntry.setSubAccountNumber("-----");
offsetEntry.setFinancialSubObjectCode("---");
offsetEntry.setOrganizationReferenceId("");
offsetEntry.setProjectCode("");
offsetEntry.setTransactionLedgerEntryDescription("GENERATED BENEFIT OFFSET");
ParameterService parameterService = SpringContext.getBean(ParameterService.class);
String originCode = parameterService.getParameterValueAsString(LaborEnterpriseFeedStep.class, LdConstants.LABOR_BENEFIT_OFFSET_ORIGIN_CODE);
offsetEntry.setFinancialSystemOriginationCode(originCode);
DateTimeService dateTimeService = SpringContext.getBean(DateTimeService.class);
offsetEntry.setDocumentNumber(dateTimeService.toString(dateTimeService.getCurrentDate(), "yyyyMMddhhmmssSSS"));
if (pendingEntry.getTransactionDebitCreditCode().equalsIgnoreCase("D")) {
offsetAmount = offsetAmount;
} else {
offsetAmount = offsetAmount.multiply(new KualiDecimal(-1));
}
if (offsetAmount.isGreaterThan(new KualiDecimal(0))) {
offsetEntry.setTransactionDebitCreditCode("C");
} else if (offsetAmount.isLessThan(new KualiDecimal(0))) {
offsetEntry.setTransactionDebitCreditCode("D");
}
String offsetDocTypes = null;
if (StringUtils.isNotEmpty(parameterService.getParameterValueAsString(LaborEnterpriseFeedStep.class, LdConstants.LABOR_BENEFIT_OFFSET_DOCTYPE))) {
offsetDocTypes = "," + parameterService.getParameterValueAsString(LaborEnterpriseFeedStep.class, LdConstants.LABOR_BENEFIT_OFFSET_DOCTYPE).replace(";", ",").replace("|", ",") + ",";
}
String docTypeCode = offsetDocTypes;
if (offsetDocTypes.contains(",")) {
String[] splits = offsetDocTypes.split(",");
for (String split : splits) {
if (!StringUtils.isEmpty(split)) {
docTypeCode = split;
break;
}
}
}
offsetEntry.setFinancialDocumentTypeCode(docTypeCode);
offsetEntries.add(offsetEntry);
}
return offsetEntries;
}
use of org.kuali.kfs.module.ld.businessobject.PositionObjectBenefit in project cu-kfs by CU-CommunityApps.
the class CuLaborPendingEntryGenerator method retrieveFringeBenefitObjectCode.
private static String retrieveFringeBenefitObjectCode(ExpenseTransferAccountingLine accountingLine, String chartOfAccountsCode) {
String fringeBenefitObjectCode = "";
Collection<PositionObjectBenefit> positionObjectBenefits = SpringContext.getBean(LaborPositionObjectBenefitService.class).getPositionObjectBenefits(accountingLine.getPayrollEndDateFiscalYear(), chartOfAccountsCode, accountingLine.getFinancialObjectCode());
for (PositionObjectBenefit positionObjectBenefit : positionObjectBenefits) {
String tmpLaborBenefitRateCategoryCode = accountingLine.getAccount().getLaborBenefitRateCategoryCode();
BenefitsCalculation benefitsCalculation = positionObjectBenefit.getBenefitsCalculation(tmpLaborBenefitRateCategoryCode);
positionObjectBenefit.setLaborLedgerBenefitsCalculation(benefitsCalculation);
positionObjectBenefit.setLaborBenefitRateCategoryCode(tmpLaborBenefitRateCategoryCode);
fringeBenefitObjectCode = positionObjectBenefit.getBenefitsCalculation().getPositionFringeBenefitObjectCode();
}
return fringeBenefitObjectCode;
}
Aggregations