Search in sources :

Example 16 with AccountingLine

use of org.kuali.kfs.sys.businessobject.AccountingLine in project cu-kfs by CU-CommunityApps.

the class PurchasingAccountsPayableDocumentBase method generateEvents.

// KFSUPGRADE-503 copied from AccountingDocumentBase and change
protected List generateEvents(List persistedLines, List currentLines, String errorPathPrefix, TransactionalDocument document) {
    List addEvents = new ArrayList();
    List updateEvents = new ArrayList();
    List reviewEvents = new ArrayList();
    List deleteEvents = new ArrayList();
    errorPathPrefix = KFSConstants.DOCUMENT_PROPERTY_NAME + ".item[";
    // 
    // generate events
    Map persistedLineMap = buildAccountingLineMap(persistedLines);
    // (iterate through current lines to detect additions and updates, removing affected lines from persistedLineMap as we go
    // so deletions can be detected by looking at whatever remains in persistedLineMap)
    int index = 0;
    for (Iterator i = currentLines.iterator(); i.hasNext(); index++) {
        // String indexedErrorPathPrefix = errorPathPrefix + "[" + index + "]";
        AccountingLine currentLine = (AccountingLine) i.next();
        Integer key = currentLine.getSequenceNumber();
        String indexedErrorPathPrefix = getIndexedErrorPathPrefix(errorPathPrefix, currentLine);
        AccountingLine persistedLine = (AccountingLine) persistedLineMap.get(key);
        // if line is both current and persisted...
        if (persistedLine != null) {
            // ...check for updates
            if (!currentLine.isLike(persistedLine)) {
                UpdateAccountingLineEvent updateEvent = new UpdateAccountingLineEvent(indexedErrorPathPrefix, document, persistedLine, currentLine);
                updateEvents.add(updateEvent);
            } else {
                ReviewAccountingLineEvent reviewEvent = new ReviewAccountingLineEvent(indexedErrorPathPrefix, document, currentLine);
                reviewEvents.add(reviewEvent);
            }
            persistedLineMap.remove(key);
        } else {
            // it must be a new addition
            AddAccountingLineEvent addEvent = new AddAccountingLineEvent(indexedErrorPathPrefix, document, currentLine);
            addEvents.add(addEvent);
        }
    }
    // detect deletions
    for (Iterator i = persistedLineMap.entrySet().iterator(); i.hasNext(); ) {
        // the deleted line is not displayed on the page, so associate the error with the whole group
        String groupErrorPathPrefix = errorPathPrefix + KFSConstants.ACCOUNTING_LINE_GROUP_SUFFIX;
        Map.Entry e = (Map.Entry) i.next();
        AccountingLine persistedLine = (AccountingLine) e.getValue();
        DeleteAccountingLineEvent deleteEvent = new DeleteAccountingLineEvent(groupErrorPathPrefix, document, persistedLine, true);
        deleteEvents.add(deleteEvent);
    }
    // 
    // merge the lists
    List lineEvents = new ArrayList();
    lineEvents.addAll(reviewEvents);
    lineEvents.addAll(updateEvents);
    lineEvents.addAll(addEvents);
    lineEvents.addAll(deleteEvents);
    return lineEvents;
}
Also used : SourceAccountingLine(org.kuali.kfs.sys.businessobject.SourceAccountingLine) AccountingLine(org.kuali.kfs.sys.businessobject.AccountingLine) PurApAccountingLine(org.kuali.kfs.module.purap.businessobject.PurApAccountingLine) ArrayList(java.util.ArrayList) UpdateAccountingLineEvent(org.kuali.kfs.sys.document.validation.event.UpdateAccountingLineEvent) ReviewAccountingLineEvent(org.kuali.kfs.sys.document.validation.event.ReviewAccountingLineEvent) AddAccountingLineEvent(org.kuali.kfs.sys.document.validation.event.AddAccountingLineEvent) GeneralLedgerPendingEntry(org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntry) Iterator(java.util.Iterator) DeleteAccountingLineEvent(org.kuali.kfs.sys.document.validation.event.DeleteAccountingLineEvent) List(java.util.List) ArrayList(java.util.ArrayList) Map(java.util.Map) HashMap(java.util.HashMap)

Example 17 with AccountingLine

use of org.kuali.kfs.sys.businessobject.AccountingLine in project cu-kfs by CU-CommunityApps.

the class AccountingLineAccessibleValidation method onlyObjectCodeChanged.

/**
 * Checks to see if the object code is the only difference between the original accounting line and the updated accounting line.
 *
 * @param accountingLine
 * @param updatedAccountingLine
 * @return true if only the object code has changed on the accounting line, false otherwise
 */
protected boolean onlyObjectCodeChanged(AccountingLine accountingLine, AccountingLine updatedAccountingLine) {
    // no changes, return false
    if (accountingLine.isLike(updatedAccountingLine)) {
        return false;
    }
    // copy the updatedAccountLine so we can set the object code on the copy of the updated accounting line
    // to be the original value for comparison purposes
    AccountingLine updatedLine = null;
    if (updatedAccountingLine.isSourceAccountingLine()) {
        updatedLine = new SourceAccountingLine();
    } else {
        updatedLine = new TargetAccountingLine();
    }
    updatedLine.copyFrom(updatedAccountingLine);
    updatedLine.setFinancialObjectCode(accountingLine.getFinancialObjectCode());
    // if they're the same, the only change was the object code
    return (accountingLine.isLike(updatedLine));
}
Also used : SourceAccountingLine(org.kuali.kfs.sys.businessobject.SourceAccountingLine) TargetAccountingLine(org.kuali.kfs.sys.businessobject.TargetAccountingLine) AccountingLine(org.kuali.kfs.sys.businessobject.AccountingLine) TargetAccountingLine(org.kuali.kfs.sys.businessobject.TargetAccountingLine) SourceAccountingLine(org.kuali.kfs.sys.businessobject.SourceAccountingLine)

Example 18 with AccountingLine

use of org.kuali.kfs.sys.businessobject.AccountingLine in project cu-kfs by CU-CommunityApps.

the class KualiAccountingDocumentActionBase method processAccountingLineOverrides.

/**
 * @param accountingLines
 */
protected void processAccountingLineOverrides(AccountingDocument financialDocument, List accountingLines) {
    if (!accountingLines.isEmpty()) {
        for (Iterator i = accountingLines.iterator(); i.hasNext(); ) {
            AccountingLine line = (AccountingLine) i.next();
            // line.refreshReferenceObject("account");
            SpringContext.getBean(PersistenceService.class).retrieveReferenceObjects(line, AccountingLineOverride.REFRESH_FIELDS);
            AccountingLineOverride.processForOutput(financialDocument, line);
        }
    }
}
Also used : PersistenceService(org.kuali.kfs.krad.service.PersistenceService) SourceAccountingLine(org.kuali.kfs.sys.businessobject.SourceAccountingLine) AccountingLine(org.kuali.kfs.sys.businessobject.AccountingLine) TargetAccountingLine(org.kuali.kfs.sys.businessobject.TargetAccountingLine) Iterator(java.util.Iterator)

Example 19 with AccountingLine

use of org.kuali.kfs.sys.businessobject.AccountingLine in project cu-kfs by CU-CommunityApps.

the class KualiAccountingDocumentActionBase method handleSalesTaxRequiredAllLines.

/**
 * This method is called from the createDocument and processes through all the accouting lines and checks to see if they need
 * sales tax fields
 *
 * @param kualiDocumentFormBase
 * @param baselineSourceLines
 */
protected void handleSalesTaxRequiredAllLines(KualiDocumentFormBase kualiDocumentFormBase, List<AccountingLine> baselineAcctingLines) {
    AccountingDocument accoutingDocument = (AccountingDocument) kualiDocumentFormBase.getDocument();
    int index = 0;
    for (AccountingLine accountingLine : baselineAcctingLines) {
        boolean source = false;
        if (accountingLine.isSourceAccountingLine()) {
            source = true;
        }
        handleSalesTaxRequired(accoutingDocument, accountingLine, source, false, index);
        index++;
    }
}
Also used : SourceAccountingLine(org.kuali.kfs.sys.businessobject.SourceAccountingLine) AccountingLine(org.kuali.kfs.sys.businessobject.AccountingLine) TargetAccountingLine(org.kuali.kfs.sys.businessobject.TargetAccountingLine) AccountingDocument(org.kuali.kfs.sys.document.AccountingDocument)

Example 20 with AccountingLine

use of org.kuali.kfs.sys.businessobject.AccountingLine in project cu-kfs by CU-CommunityApps.

the class KualiAccountingDocumentActionBase method checkSalesTaxRequiredAllLines.

protected boolean checkSalesTaxRequiredAllLines(KualiDocumentFormBase kualiDocumentFormBase, List<AccountingLine> baselineAcctingLines) {
    AccountingDocument accoutingDocument = (AccountingDocument) kualiDocumentFormBase.getDocument();
    boolean passed = true;
    int index = 0;
    for (AccountingLine accountingLine : baselineAcctingLines) {
        boolean source = false;
        if (accountingLine.isSourceAccountingLine()) {
            source = true;
        }
        passed &= checkSalesTax(accoutingDocument, accountingLine, source, false, index);
        index++;
    }
    return passed;
}
Also used : SourceAccountingLine(org.kuali.kfs.sys.businessobject.SourceAccountingLine) AccountingLine(org.kuali.kfs.sys.businessobject.AccountingLine) TargetAccountingLine(org.kuali.kfs.sys.businessobject.TargetAccountingLine) AccountingDocument(org.kuali.kfs.sys.document.AccountingDocument)

Aggregations

AccountingLine (org.kuali.kfs.sys.businessobject.AccountingLine)22 SourceAccountingLine (org.kuali.kfs.sys.businessobject.SourceAccountingLine)13 ArrayList (java.util.ArrayList)12 List (java.util.List)10 Iterator (java.util.Iterator)9 TargetAccountingLine (org.kuali.kfs.sys.businessobject.TargetAccountingLine)7 KualiDecimal (org.kuali.rice.core.api.util.type.KualiDecimal)6 HashMap (java.util.HashMap)5 AccountingDocument (org.kuali.kfs.sys.document.AccountingDocument)5 GeneralLedgerPendingEntrySequenceHelper (org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntrySequenceHelper)4 Map (java.util.Map)3 PurApItemUseTax (org.kuali.kfs.module.purap.businessobject.PurApItemUseTax)3 PurapAccountingService (org.kuali.kfs.module.purap.service.PurapAccountingService)3 SummaryAccount (org.kuali.kfs.module.purap.util.SummaryAccount)3 UseTaxContainer (org.kuali.kfs.module.purap.util.UseTaxContainer)3 GeneralLedgerPendingEntry (org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntry)3 ParameterEvaluator (org.kuali.rice.core.api.parameter.ParameterEvaluator)3 ParameterEvaluatorService (org.kuali.rice.core.api.parameter.ParameterEvaluatorService)3 CuPaymentRequestDocument (edu.cornell.kfs.module.purap.document.CuPaymentRequestDocument)2 PurApAccountingLine (org.kuali.kfs.module.purap.businessobject.PurApAccountingLine)2