use of org.kuali.kfs.module.ld.businessobject.ExpenseTransferSourceAccountingLine 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.ExpenseTransferSourceAccountingLine in project cu-kfs by CU-CommunityApps.
the class SalaryExpenseTransferAccountingLinesNotEmpty method hasEmptyAccountingLines.
@SuppressWarnings("unchecked")
protected boolean hasEmptyAccountingLines(AccountingDocument accountingDocument) {
LaborExpenseTransferDocumentBase expenseTransferDocument = (LaborExpenseTransferDocumentBase) accountingDocument;
List<ExpenseTransferSourceAccountingLine> sourceAccountingLines = expenseTransferDocument.getSourceAccountingLines();
List<ExpenseTransferTargetAccountingLine> targetAccountingLines = expenseTransferDocument.getTargetAccountingLines();
// If the lines are emoty the validation results should be false
boolean sourceAccountingLinesValidationResult = !sourceAccountingLines.isEmpty();
boolean targetAccountingLinesValidationResult = !targetAccountingLines.isEmpty();
if (!sourceAccountingLinesValidationResult) {
GlobalVariables.getMessageMap().putError(KFSPropertyConstants.SOURCE_ACCOUNTING_LINES, CuLaborKeyConstants.ERROR_ACCOUNTING_LINE_EMPTY);
}
if (!targetAccountingLinesValidationResult) {
GlobalVariables.getMessageMap().putError(KFSPropertyConstants.TARGET_ACCOUNTING_LINES, CuLaborKeyConstants.ERROR_ACCOUNTING_LINE_EMPTY);
}
return sourceAccountingLinesValidationResult && targetAccountingLinesValidationResult;
}
Aggregations