Search in sources :

Example 6 with LaborLedgerPendingEntry

use of org.kuali.kfs.module.ld.businessobject.LaborLedgerPendingEntry in project cu-kfs by CU-CommunityApps.

the class SalaryExpenseTransferDocument method generateLaborLedgerPendingEntries.

/**
 * @see org.kuali.kfs.module.ld.document.LaborExpenseTransferDocumentBase#generateLaborLedgerPendingEntries(org.kuali.kfs.sys.businessobject.AccountingLine,
 *      org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntrySequenceHelper)
 */
@Override
public boolean generateLaborLedgerPendingEntries(AccountingLine accountingLine, GeneralLedgerPendingEntrySequenceHelper sequenceHelper) {
    LOG.debug("started generateLaborLedgerPendingEntries()");
    boolean isSuccessful = true;
    ExpenseTransferAccountingLine expenseTransferAccountingLine = (ExpenseTransferAccountingLine) accountingLine;
    List<LaborLedgerPendingEntry> expensePendingEntries = LaborPendingEntryGenerator.generateExpensePendingEntries(this, expenseTransferAccountingLine, sequenceHelper);
    if (expensePendingEntries != null && !expensePendingEntries.isEmpty()) {
        isSuccessful &= this.getLaborLedgerPendingEntries().addAll(expensePendingEntries);
    }
    List<LaborLedgerPendingEntry> benefitPendingEntries = LaborPendingEntryGenerator.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 7 with LaborLedgerPendingEntry

use of org.kuali.kfs.module.ld.businessobject.LaborLedgerPendingEntry in project cu-kfs by CU-CommunityApps.

the class CuLaborPendingEntryConverterServiceImpl method getBenefitPendingEntry.

@Override
public LaborLedgerPendingEntry getBenefitPendingEntry(LaborLedgerPostingDocument document, ExpenseTransferAccountingLine accountingLine, GeneralLedgerPendingEntrySequenceHelper sequenceHelper, KualiDecimal benefitAmount, String fringeBenefitObjectCode) {
    LaborLedgerPendingEntry pendingEntry = super.getBenefitPendingEntry(document, accountingLine, sequenceHelper, benefitAmount, fringeBenefitObjectCode);
    pendingEntry.setPositionNumber(accountingLine.getPositionNumber());
    pendingEntry.setEmplid(accountingLine.getEmplid());
    return pendingEntry;
}
Also used : LaborLedgerPendingEntry(org.kuali.kfs.module.ld.businessobject.LaborLedgerPendingEntry)

Example 8 with LaborLedgerPendingEntry

use of org.kuali.kfs.module.ld.businessobject.LaborLedgerPendingEntry 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;
}
Also used : BenefitsCalculation(org.kuali.kfs.module.ld.businessobject.BenefitsCalculation) LaborBenefitsCalculationService(org.kuali.kfs.module.ld.service.LaborBenefitsCalculationService) HashMap(java.util.HashMap) ParameterService(org.kuali.kfs.coreservice.framework.parameter.ParameterService) LaborEnterpriseFeedStep(org.kuali.kfs.module.ld.batch.LaborEnterpriseFeedStep) ArrayList(java.util.ArrayList) PositionObjectBenefit(org.kuali.kfs.module.ld.businessobject.PositionObjectBenefit) BusinessObjectService(org.kuali.kfs.krad.service.BusinessObjectService) 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) DateTimeService(org.kuali.rice.core.api.datetime.DateTimeService)

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