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;
}
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;
}
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;
}
Aggregations