Search in sources :

Example 1 with ExpenseTransferSourceAccountingLine

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;
}
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 2 with ExpenseTransferSourceAccountingLine

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

Aggregations

ExpenseTransferSourceAccountingLine (org.kuali.kfs.module.ld.businessobject.ExpenseTransferSourceAccountingLine)2 ExpenseTransferTargetAccountingLine (org.kuali.kfs.module.ld.businessobject.ExpenseTransferTargetAccountingLine)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 LaborLedgerPendingEntry (org.kuali.kfs.module.ld.businessobject.LaborLedgerPendingEntry)1 LaborExpenseTransferDocumentBase (org.kuali.kfs.module.ld.document.LaborExpenseTransferDocumentBase)1 KualiDecimal (org.kuali.rice.core.api.util.type.KualiDecimal)1