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