Search in sources :

Example 1 with LaborLedgerPendingEntry

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;
}
Also used : ExpenseTransferAccountingLine(org.kuali.kfs.module.ld.businessobject.ExpenseTransferAccountingLine) LaborLedgerPendingEntry(org.kuali.kfs.module.ld.businessobject.LaborLedgerPendingEntry)

Example 2 with LaborLedgerPendingEntry

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;
}
Also used : Account(org.kuali.kfs.coa.businessobject.Account) BenefitsCalculation(org.kuali.kfs.module.ld.businessobject.BenefitsCalculation) LaborBenefitsCalculationService(org.kuali.kfs.module.ld.service.LaborBenefitsCalculationService) ParameterService(org.kuali.kfs.coreservice.framework.parameter.ParameterService) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) KfsParameterConstants(org.kuali.kfs.sys.service.impl.KfsParameterConstants) PositionObjectBenefit(org.kuali.kfs.module.ld.businessobject.PositionObjectBenefit) LaborLedgerPendingEntry(org.kuali.kfs.module.ld.businessobject.LaborLedgerPendingEntry) LaborPositionObjectBenefitService(org.kuali.kfs.module.ld.service.LaborPositionObjectBenefitService) KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal)

Example 3 with LaborLedgerPendingEntry

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;
}
Also used : ExpenseTransferSourceAccountingLine(org.kuali.kfs.module.ld.businessobject.ExpenseTransferSourceAccountingLine) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ExpenseTransferTargetAccountingLine(org.kuali.kfs.module.ld.businessobject.ExpenseTransferTargetAccountingLine) LaborLedgerPendingEntry(org.kuali.kfs.module.ld.businessobject.LaborLedgerPendingEntry) KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal) HashMap(java.util.HashMap) Map(java.util.Map) HashSet(java.util.HashSet)

Example 4 with LaborLedgerPendingEntry

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;
}
Also used : LaborLedgerPendingEntry(org.kuali.kfs.module.ld.businessobject.LaborLedgerPendingEntry)

Example 5 with LaborLedgerPendingEntry

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());
}
Also used : CuSalaryExpenseTransferDocument(edu.cornell.kfs.module.ld.document.CuSalaryExpenseTransferDocument) LaborLedgerPendingEntry(org.kuali.kfs.module.ld.businessobject.LaborLedgerPendingEntry) KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal) GeneralLedgerPendingEntrySequenceHelper(org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntrySequenceHelper)

Aggregations

LaborLedgerPendingEntry (org.kuali.kfs.module.ld.businessobject.LaborLedgerPendingEntry)8 KualiDecimal (org.kuali.rice.core.api.util.type.KualiDecimal)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 ParameterService (org.kuali.kfs.coreservice.framework.parameter.ParameterService)2 BenefitsCalculation (org.kuali.kfs.module.ld.businessobject.BenefitsCalculation)2 ExpenseTransferAccountingLine (org.kuali.kfs.module.ld.businessobject.ExpenseTransferAccountingLine)2 PositionObjectBenefit (org.kuali.kfs.module.ld.businessobject.PositionObjectBenefit)2 LaborBenefitsCalculationService (org.kuali.kfs.module.ld.service.LaborBenefitsCalculationService)2 LaborPositionObjectBenefitService (org.kuali.kfs.module.ld.service.LaborPositionObjectBenefitService)2 CuSalaryExpenseTransferDocument (edu.cornell.kfs.module.ld.document.CuSalaryExpenseTransferDocument)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 Account (org.kuali.kfs.coa.businessobject.Account)1 BusinessObjectService (org.kuali.kfs.krad.service.BusinessObjectService)1 LaborEnterpriseFeedStep (org.kuali.kfs.module.ld.batch.LaborEnterpriseFeedStep)1 ExpenseTransferSourceAccountingLine (org.kuali.kfs.module.ld.businessobject.ExpenseTransferSourceAccountingLine)1 ExpenseTransferTargetAccountingLine (org.kuali.kfs.module.ld.businessobject.ExpenseTransferTargetAccountingLine)1 GeneralLedgerPendingEntrySequenceHelper (org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntrySequenceHelper)1 KfsParameterConstants (org.kuali.kfs.sys.service.impl.KfsParameterConstants)1