use of org.kuali.kfs.sys.businessobject.AccountingLine in project cu-kfs by CU-CommunityApps.
the class CuPendingTransactionServiceImpl method generateEntriesPaymentRequest.
/**
* Creates the general ledger entries for Payment Request actions.
*
* @param preq Payment Request document to create entries
* @param encumbrances List of encumbrance accounts if applies
* @param accountingLines List of preq accounts to create entries
* @param processType Type of process (create, modify, cancel)
* @return Boolean returned indicating whether entry creation succeeded
*/
protected boolean generateEntriesPaymentRequest(PaymentRequestDocument preq, List encumbrances, List summaryAccounts) {
LOG.debug("generateEntriesPaymentRequest() started");
boolean success = true;
preq.setGeneralLedgerPendingEntries(new ArrayList());
/*
* Can't let generalLedgerPendingEntryService just create all the entries because we need the sequenceHelper to carry over
* from the encumbrances to the actuals and also because we need to tell the PaymentRequestDocumentRule customize entry
* method how to customize differently based on if creating an encumbrance or actual.
*/
GeneralLedgerPendingEntrySequenceHelper sequenceHelper = new GeneralLedgerPendingEntrySequenceHelper(getNextAvailableSequence(preq.getDocumentNumber()));
// when cancelling a PREQ, do not book encumbrances if PO is CLOSED
if (encumbrances != null) {
// on cancel, use DEBIT code
preq.setDebitCreditCodeForGLEntries(GL_DEBIT_CODE);
preq.setGenerateEncumbranceEntries(true);
for (Iterator iter = encumbrances.iterator(); iter.hasNext(); ) {
AccountingLine accountingLine = (AccountingLine) iter.next();
preq.generateGeneralLedgerPendingEntries(accountingLine, sequenceHelper);
// increment for the next line
sequenceHelper.increment();
}
}
if (ObjectUtils.isNotNull(summaryAccounts) && !summaryAccounts.isEmpty()) {
LOG.debug("generateEntriesPaymentRequest() now book the actuals");
preq.setGenerateEncumbranceEntries(false);
// on cancel, use CREDIT code
preq.setDebitCreditCodeForGLEntries(GL_CREDIT_CODE);
for (Iterator iter = summaryAccounts.iterator(); iter.hasNext(); ) {
SummaryAccount summaryAccount = (SummaryAccount) iter.next();
preq.generateGeneralLedgerPendingEntries(summaryAccount.getAccount(), sequenceHelper);
// increment for the next line
sequenceHelper.increment();
}
// generate offset accounts for use tax if it exists (useTaxContainers will be empty if not a use tax document)
List<UseTaxContainer> useTaxContainers = SpringContext.getBean(PurapAccountingService.class).generateUseTaxAccount(preq);
for (UseTaxContainer useTaxContainer : useTaxContainers) {
PurApItemUseTax offset = useTaxContainer.getUseTax();
List<SourceAccountingLine> accounts = useTaxContainer.getAccounts();
for (SourceAccountingLine sourceAccountingLine : accounts) {
preq.generateGeneralLedgerPendingEntries(sourceAccountingLine, sequenceHelper, useTaxContainer.getUseTax());
// increment for the next line
sequenceHelper.increment();
}
}
}
// Manually save GL entries for Payment Request and encumbrances
LOG.debug("saveGLEntries() started");
businessObjectService.save(preq.getGeneralLedgerPendingEntries());
return success;
}
use of org.kuali.kfs.sys.businessobject.AccountingLine in project cu-kfs by CU-CommunityApps.
the class CUFinancialSystemDocumentServiceImpl method buildAccountingLineMap.
/**
* @param accountingLines
* @return Map containing accountingLines from the given List, indexed by their sequenceNumber
*/
protected Map buildAccountingLineMap(List<AccountingLine> accountingLines) {
Map lineMap = new HashMap();
for (Iterator i = accountingLines.iterator(); i.hasNext(); ) {
AccountingLine accountingLine = (AccountingLine) i.next();
Integer sequenceNumber = accountingLine.getSequenceNumber();
if (sequenceNumber != null) {
lineMap.put(sequenceNumber, accountingLine);
}
}
return lineMap;
}
Aggregations