use of org.kuali.kfs.module.ld.businessobject.LaborLedgerPendingEntry in project cu-kfs by CU-CommunityApps.
the class CuSalaryExpenseTransferDocument method generateLaborLedgerPendingEntries.
@Override
public boolean generateLaborLedgerPendingEntries(AccountingLine accountingLine, GeneralLedgerPendingEntrySequenceHelper sequenceHelper) {
LOG.debug("started generateLaborLedgerPendingEntries()");
boolean isSuccessful = true;
ExpenseTransferAccountingLine expenseTransferAccountingLine = (ExpenseTransferAccountingLine) accountingLine;
List<LaborLedgerPendingEntry> expensePendingEntries = CuLaborPendingEntryGenerator.generateExpensePendingEntries(this, expenseTransferAccountingLine, sequenceHelper);
if (expensePendingEntries != null && !expensePendingEntries.isEmpty()) {
isSuccessful &= this.getLaborLedgerPendingEntries().addAll(expensePendingEntries);
}
List<LaborLedgerPendingEntry> benefitPendingEntries = CuLaborPendingEntryGenerator.generateBenefitPendingEntries(this, expenseTransferAccountingLine, sequenceHelper);
if (benefitPendingEntries != null && !benefitPendingEntries.isEmpty()) {
isSuccessful &= this.getLaborLedgerPendingEntries().addAll(benefitPendingEntries);
}
return isSuccessful;
}
use of org.kuali.kfs.module.ld.businessobject.LaborLedgerPendingEntry 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.LaborLedgerPendingEntry in project cu-kfs by CU-CommunityApps.
the class CuLaborPendingEntryGenerator method generateBenefitClearingPendingEntries.
public static List<LaborLedgerPendingEntry> generateBenefitClearingPendingEntries(LaborLedgerPostingDocument document, GeneralLedgerPendingEntrySequenceHelper sequenceHelper, String accountNumber, String chartOfAccountsCode) {
List<LaborLedgerPendingEntry> benefitClearingPendingEntries = new ArrayList<LaborLedgerPendingEntry>();
Map<String, Map<String, KualiDecimal>> sourceLineBenefitAmountSumByObjectCode = new HashMap<String, Map<String, KualiDecimal>>();
List<ExpenseTransferSourceAccountingLine> sourceAccountingLines = document.getSourceAccountingLines();
for (ExpenseTransferSourceAccountingLine accountingLine : sourceAccountingLines) {
updateBenefitAmountSumObject(sourceLineBenefitAmountSumByObjectCode, accountingLine);
}
Map<String, Map<String, KualiDecimal>> targetLineBenefitAmountSumByObjectCode = new HashMap<String, Map<String, KualiDecimal>>();
List<ExpenseTransferTargetAccountingLine> targetAccountingLines = document.getTargetAccountingLines();
for (ExpenseTransferTargetAccountingLine accountingLine : targetAccountingLines) {
updateBenefitAmountSumObject(targetLineBenefitAmountSumByObjectCode, accountingLine);
}
Set<String> benefitTypeCodes = new HashSet<String>();
for (String key : targetLineBenefitAmountSumByObjectCode.keySet()) {
benefitTypeCodes.add(key);
}
for (String key : sourceLineBenefitAmountSumByObjectCode.keySet()) {
benefitTypeCodes.add(key);
}
for (String benefitTypeCode : benefitTypeCodes) {
KualiDecimal targetAmount = KualiDecimal.ZERO;
Map<String, KualiDecimal> targetBenefitSumsByObjectCode = new HashMap<String, KualiDecimal>();
if (targetLineBenefitAmountSumByObjectCode.containsKey(benefitTypeCode)) {
targetBenefitSumsByObjectCode = targetLineBenefitAmountSumByObjectCode.get(benefitTypeCode);
for (String objCode : targetBenefitSumsByObjectCode.keySet()) {
if (targetBenefitSumsByObjectCode.containsKey(objCode)) {
targetAmount = targetAmount.add(targetBenefitSumsByObjectCode.get(objCode));
}
}
}
KualiDecimal sourceAmount = KualiDecimal.ZERO;
Map<String, KualiDecimal> sourceBenefitSumsByObjectCode = new HashMap<String, KualiDecimal>();
if (sourceLineBenefitAmountSumByObjectCode.containsKey(benefitTypeCode)) {
sourceBenefitSumsByObjectCode = sourceLineBenefitAmountSumByObjectCode.get(benefitTypeCode);
for (String objCode : sourceBenefitSumsByObjectCode.keySet()) {
if (sourceBenefitSumsByObjectCode.containsKey(objCode)) {
sourceAmount = sourceAmount.add(sourceBenefitSumsByObjectCode.get(objCode));
}
}
}
KualiDecimal clearingAmount = sourceAmount.subtract(targetAmount);
KualiDecimal amountForObjectCode = KualiDecimal.ZERO;
if (clearingAmount.isNonZero() && ObjectUtils.isNotNull(benefitTypeCode)) {
for (String objCode : sourceBenefitSumsByObjectCode.keySet()) {
amountForObjectCode = sourceBenefitSumsByObjectCode.get(objCode);
benefitClearingPendingEntries.add(((CuLaborPendingEntryConverterServiceImpl) SpringContext.getBean(LaborPendingEntryConverterService.class)).getBenefitClearingPendingEntry(document, sequenceHelper, accountNumber, chartOfAccountsCode, benefitTypeCode, amountForObjectCode, objCode));
}
for (String objCode : targetBenefitSumsByObjectCode.keySet()) {
amountForObjectCode = targetBenefitSumsByObjectCode.get(objCode);
benefitClearingPendingEntries.add(((CuLaborPendingEntryConverterServiceImpl) SpringContext.getBean(LaborPendingEntryConverterService.class)).getBenefitClearingPendingEntry(document, sequenceHelper, accountNumber, chartOfAccountsCode, benefitTypeCode, amountForObjectCode.negated(), objCode));
}
}
}
// refresh nonupdateable references for financial object...
refreshObjectCodeNonUpdateableReferences(benefitClearingPendingEntries);
return benefitClearingPendingEntries;
}
use of org.kuali.kfs.module.ld.businessobject.LaborLedgerPendingEntry in project cu-kfs by CU-CommunityApps.
the class CuLaborPendingEntryConverterServiceImpl method getBenefitClearingPendingEntry.
public LaborLedgerPendingEntry getBenefitClearingPendingEntry(LaborLedgerPostingDocument document, GeneralLedgerPendingEntrySequenceHelper sequenceHelper, String accountNumber, String chartOfAccountsCode, String benefitTypeCode, KualiDecimal clearingAmount, String objectCode) {
LaborLedgerPendingEntry pendingEntry = super.getBenefitClearingPendingEntry(document, sequenceHelper, accountNumber, chartOfAccountsCode, benefitTypeCode, clearingAmount);
pendingEntry.setPositionNumber(document.getLaborLedgerPendingEntry(0).getPositionNumber());
pendingEntry.setEmplid(document.getLaborLedgerPendingEntry(0).getEmplid());
pendingEntry.setFinancialObjectCode(objectCode);
return pendingEntry;
}
use of org.kuali.kfs.module.ld.businessobject.LaborLedgerPendingEntry in project cu-kfs by CU-CommunityApps.
the class CuLaborPendingEntryConverterServiceImplTest method testGetBenefitClearingPendingEntry.
public void testGetBenefitClearingPendingEntry() throws IllegalAccessException, InstantiationException, WorkflowException {
CuSalaryExpenseTransferDocument document = CuSalaryExpenseTransferDocumentFixture.GOOD_ST.createSalaryExpenseDocument();
AccountingDocumentTestUtils.saveDocument(document, documentService);
GeneralLedgerPendingEntrySequenceHelper sequenceHelper = new GeneralLedgerPendingEntrySequenceHelper();
LaborLedgerPendingEntry laborLedgerPendingEntry = ((CuLaborPendingEntryConverterServiceImpl) laborPendingEntryConverterService).getBenefitClearingPendingEntry(document, sequenceHelper, "R704750", "IT", "MX", new KualiDecimal(6916.68), "5200");
assertEquals("1", laborLedgerPendingEntry.getEmplid());
}
Aggregations