use of org.kuali.kfs.sys.businessobject.AccountingLine in project cu-kfs by CU-CommunityApps.
the class CUPaymentMethodGeneralLedgerPendingEntryServiceImpl method generateFinalEntriesForPRNC.
/**
* Creates final entries for PRNC doc: Reverse all usage 2900 object codes Replaces with 1000 offset object code Generate
* Bank Offsets for total amounts
*
* @see edu.cornell.kfs.fp.service.CUPaymentMethodGeneralLedgerPendingEntryService#generateFinalEntriesForPRNC(org.kuali.kfs.module.purap.document.PaymentRequestDocument)
*/
public void generateFinalEntriesForPRNC(PaymentRequestDocument document) {
GeneralLedgerPendingEntrySequenceHelper sequenceHelper = new GeneralLedgerPendingEntrySequenceHelper(getNextAvailableSequence(document.getDocumentNumber()));
String documentType = CuPaymentRequestDocument.DOCUMENT_TYPE_NON_CHECK;
if (PaymentMethod.PM_CODE_INTERNAL_BILLING.equalsIgnoreCase(((CuPaymentRequestDocument) document).getPaymentMethodCode())) {
documentType = CuPaymentRequestDocument.DOCUMENT_TYPE_INTERNAL_BILLING;
}
// generate bank offset
if (PaymentMethod.PM_CODE_FOREIGN_DRAFT.equalsIgnoreCase(((CuPaymentRequestDocument) document).getPaymentMethodCode()) || PaymentMethod.PM_CODE_WIRE.equalsIgnoreCase(((CuPaymentRequestDocument) document).getPaymentMethodCode())) {
generateDocumentBankOffsetEntries((AccountingDocument) document, document.getBankCode(), KRADConstants.DOCUMENT_PROPERTY_NAME + "." + "bankCode", documentType, sequenceHelper, document.getTotalDollarAmount().negated());
}
// check for balance type Actual offset pending entries and replace the object code with chart cash object code (currently replacing object code 2900 with 1000)
List<GeneralLedgerPendingEntry> glpes = document.getGeneralLedgerPendingEntries();
for (GeneralLedgerPendingEntry glpe : glpes) {
OffsetDefinition offsetDefinition = SpringContext.getBean(OffsetDefinitionService.class).getByPrimaryId(glpe.getUniversityFiscalYear(), glpe.getChartOfAccountsCode(), documentType, KFSConstants.BALANCE_TYPE_ACTUAL);
if (glpe.getFinancialObjectCode().equalsIgnoreCase(offsetDefinition.getFinancialObjectCode())) {
if (ObjectUtils.isNull(glpe.getChart())) {
glpe.refreshReferenceObject(KFSPropertyConstants.CHART);
}
glpe.setFinancialObjectCode(glpe.getChart().getFinancialCashObjectCode());
glpe.refreshReferenceObject(KFSPropertyConstants.FINANCIAL_OBJECT);
glpe.setFinancialObjectTypeCode(glpe.getFinancialObject().getFinancialObjectTypeCode());
}
}
// reverse 2900
// check for posted entries and create reverse pending entries
// get all charts on document
List<AccountingLine> accountingLines = new ArrayList<AccountingLine>();
if (ObjectUtils.isNotNull(document.getSourceAccountingLines())) {
accountingLines.addAll(document.getSourceAccountingLines());
}
if (ObjectUtils.isNotNull(document.getTargetAccountingLines())) {
accountingLines.addAll(document.getTargetAccountingLines());
}
Map<String, String> chartOffsets = new HashMap<String, String>();
if (accountingLines.size() > 0) {
for (AccountingLine accountingLine : accountingLines) {
if (!chartOffsets.containsKey(accountingLine.getChartOfAccountsCode())) {
OffsetDefinition offsetDefinition = SpringContext.getBean(OffsetDefinitionService.class).getByPrimaryId(accountingLine.getPostingYear(), accountingLine.getChartOfAccountsCode(), documentType, KFSConstants.BALANCE_TYPE_ACTUAL);
chartOffsets.put(accountingLine.getChartOfAccountsCode(), offsetDefinition.getFinancialObjectCode());
}
}
}
for (String offsetObjectCode : chartOffsets.values()) {
Collection<Entry> glEntries = findMatchingGLEntries(document, offsetObjectCode);
if (glEntries != null && glEntries.size() > 0) {
for (Entry entry : glEntries) {
// create reversal
GeneralLedgerPendingEntry glpe = new GeneralLedgerPendingEntry();
boolean debit = KFSConstants.GL_CREDIT_CODE.equalsIgnoreCase(entry.getTransactionDebitCreditCode());
glpe = getGeneralLedgerPendingEntryService().buildGeneralLedgerPendingEntry((GeneralLedgerPostingDocument) document, entry.getAccount(), entry.getFinancialObject(), entry.getSubAccountNumber(), entry.getFinancialSubObjectCode(), entry.getOrganizationReferenceId(), entry.getProjectCode(), entry.getReferenceFinancialDocumentNumber(), entry.getReferenceFinancialDocumentTypeCode(), entry.getReferenceFinancialSystemOriginationCode(), entry.getTransactionLedgerEntryDescription(), debit, entry.getTransactionLedgerEntryAmount(), sequenceHelper);
glpe.setFinancialDocumentTypeCode(documentType);
document.addPendingEntry(glpe);
sequenceHelper.increment();
// create cash entry
GeneralLedgerPendingEntry cashGlpe = new GeneralLedgerPendingEntry();
cashGlpe = getGeneralLedgerPendingEntryService().buildGeneralLedgerPendingEntry((GeneralLedgerPostingDocument) document, entry.getAccount(), entry.getChart().getFinancialCashObject(), entry.getSubAccountNumber(), entry.getFinancialSubObjectCode(), entry.getOrganizationReferenceId(), entry.getProjectCode(), entry.getReferenceFinancialDocumentNumber(), entry.getReferenceFinancialDocumentTypeCode(), entry.getReferenceFinancialSystemOriginationCode(), entry.getTransactionLedgerEntryDescription(), !debit, entry.getTransactionLedgerEntryAmount(), sequenceHelper);
cashGlpe.setFinancialDocumentTypeCode(documentType);
document.addPendingEntry(cashGlpe);
sequenceHelper.increment();
}
}
}
if (document.getGeneralLedgerPendingEntries() != null && document.getGeneralLedgerPendingEntries().size() > 0) {
for (GeneralLedgerPendingEntry glpe : document.getGeneralLedgerPendingEntries()) {
glpe.setFinancialDocumentApprovedCode(KFSConstants.PENDING_ENTRY_APPROVED_STATUS_CODE.APPROVED);
}
}
}
use of org.kuali.kfs.sys.businessobject.AccountingLine in project cu-kfs by CU-CommunityApps.
the class YearEndGeneralLedgerPendingEntriesServiceImpl method generateYearEndGeneralLedgerPendingEntries.
/**
* @see edu.cornell.kfs.fp.document.service.YearEndGeneralLedgerPendingEntriesService#generateYearEndGeneralLedgerPendingEntries(org.kuali.kfs.sys.document.AccountingDocumentBase, java.lang.String, java.util.List, org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntrySequenceHelper, java.util.Collection)
*/
@Override
public boolean generateYearEndGeneralLedgerPendingEntries(AccountingDocumentBase document, String documentTypeCode, List<AccountingLine> accountingLines, GeneralLedgerPendingEntrySequenceHelper sequenceHelper, Collection<String> closingCharts) {
Integer fiscalYear = new Integer(getParameterService().getParameterValueAsString(KfsParameterConstants.GENERAL_LEDGER_BATCH.class, GeneralLedgerConstants.ANNUAL_CLOSING_FISCAL_YEAR_PARM));
List<String> nominalActivityObjectTypeCodes = objectTypeService.getNominalActivityClosingAllowedObjectTypes(fiscalYear);
List<String> balanceForwardObjectTypeCodes = objectTypeService.getGeneralForwardBalanceObjectTypes(fiscalYear);
List<String> expenseObjectCodeTypes = objectTypeService.getExpenseObjectTypes(fiscalYear);
List<String> incomeObjectCodeTypes = objectTypeService.getBasicIncomeObjectTypes(fiscalYear);
Map<String, AccountingLine> incomeAccounts = new HashMap<String, AccountingLine>();
Map<String, AccountingLine> expenseAccounts = new HashMap<String, AccountingLine>();
List<AccountingLine> bbAccounts = new ArrayList<AccountingLine>();
Map<String, AccountingLine> accountCredit = new HashMap<String, AccountingLine>();
Map<String, AccountingLine> accountDebit = new HashMap<String, AccountingLine>();
for (AccountingLine accountingLine : accountingLines) {
if (ObjectUtils.isNull(closingCharts) || closingCharts.isEmpty()) {
// do nothing
} else {
if (closingCharts.contains(accountingLine.getChartOfAccountsCode())) {
// BB
if (balanceForwardObjectTypeCodes.contains(accountingLine.getFinancialObjectCode()) && accountingLine.getAmount().isNonZero()) {
bbAccounts.add(accountingLine);
}
// get the expense accounts
if (expenseObjectCodeTypes.contains(accountingLine.getObjectCode().getFinancialObjectTypeCode()) && nominalActivityObjectTypeCodes.contains(accountingLine.getObjectCode().getFinancialObjectTypeCode())) {
String accountKey = accountingLine.getChartOfAccountsCode() + accountingLine.getAccountNumber() + accountingLine.getSubAccountNumber() + accountingLine.getFinancialSubObjectCode() + accountingLine.getProjectCode() + accountingLine.getOrganizationReferenceId();
if (expenseAccounts.containsKey(accountKey)) {
KualiDecimal expense = expenseAccounts.get(accountKey).getAmount();
KualiDecimal amount = accountingLine.getAmount();
// Expense will be positive with Debit (D) flag. If the flag is C it will be treated as a negative.
if (KFSConstants.GL_CREDIT_CODE.equalsIgnoreCase(accountingLine.getDebitCreditCode())) {
amount = amount.negated();
}
expenseAccounts.get(accountKey).setAmount(expense.add(amount));
expenseAccounts.put(accountKey, expenseAccounts.get(accountKey));
} else {
KualiDecimal expense = accountingLine.getAmount();
// Expense will be positive with Debit (D) flag. If the flag is C it will be treated as a negative.
if (KFSConstants.GL_CREDIT_CODE.equalsIgnoreCase(accountingLine.getDebitCreditCode())) {
expense = expense.negated();
}
SourceAccountingLine expenseAcctLine = new SourceAccountingLine();
expenseAcctLine.setChartOfAccountsCode(accountingLine.getChartOfAccountsCode());
expenseAcctLine.setAccountNumber(accountingLine.getAccountNumber());
expenseAcctLine.setSubAccountNumber(accountingLine.getSubAccountNumber());
expenseAcctLine.setFinancialSubObjectCode(accountingLine.getFinancialSubObjectCode());
expenseAcctLine.setProjectCode(accountingLine.getProjectCode());
expenseAcctLine.setOrganizationReferenceId(accountingLine.getOrganizationReferenceId());
expenseAcctLine.setAmount(expense);
expenseAccounts.put(accountKey, expenseAcctLine);
}
} else if (incomeObjectCodeTypes.contains(accountingLine.getObjectCode().getFinancialObjectTypeCode()) && nominalActivityObjectTypeCodes.contains(accountingLine.getObjectCode().getFinancialObjectTypeCode())) {
// get income
String accountKey = accountingLine.getChartOfAccountsCode() + accountingLine.getAccountNumber() + accountingLine.getSubAccountNumber() + accountingLine.getFinancialSubObjectCode() + accountingLine.getProjectCode() + accountingLine.getOrganizationReferenceId();
if (incomeAccounts.containsKey(accountKey)) {
KualiDecimal income = incomeAccounts.get(accountKey).getAmount();
KualiDecimal amount = accountingLine.getAmount();
// Income will be positive with Credit (C) flag. If the flag is D it will be treated as a negative.
if (KFSConstants.GL_DEBIT_CODE.equalsIgnoreCase(accountingLine.getDebitCreditCode())) {
amount = amount.negated();
}
incomeAccounts.get(accountKey).setAmount(income.add(amount));
incomeAccounts.put(accountKey, incomeAccounts.get(accountKey));
} else {
KualiDecimal income = accountingLine.getAmount();
// Income will be positive with Credit (C) flag. If the flag is D it will be treated as a negative.
if (KFSConstants.GL_DEBIT_CODE.equalsIgnoreCase(accountingLine.getDebitCreditCode())) {
income = income.negated();
}
SourceAccountingLine incomeAcctLine = new SourceAccountingLine();
incomeAcctLine.setChartOfAccountsCode(accountingLine.getChartOfAccountsCode());
incomeAcctLine.setAccountNumber(accountingLine.getAccountNumber());
incomeAcctLine.setSubAccountNumber(accountingLine.getSubAccountNumber());
incomeAcctLine.setFinancialSubObjectCode(accountingLine.getFinancialSubObjectCode());
incomeAcctLine.setProjectCode(accountingLine.getProjectCode());
incomeAcctLine.setOrganizationReferenceId(accountingLine.getOrganizationReferenceId());
incomeAcctLine.setAmount(income);
incomeAccounts.put(accountKey, incomeAcctLine);
}
}
// credit
if (KFSConstants.GL_CREDIT_CODE.equalsIgnoreCase(accountingLine.getDebitCreditCode())) {
String accountKey = accountingLine.getChartOfAccountsCode() + accountingLine.getAccountNumber() + accountingLine.getSubAccountNumber() + accountingLine.getFinancialSubObjectCode() + accountingLine.getProjectCode() + accountingLine.getOrganizationReferenceId();
if (accountCredit.containsKey(accountKey)) {
KualiDecimal credit = accountCredit.get(accountKey).getAmount();
KualiDecimal amount = accountingLine.getAmount();
accountCredit.get(accountKey).setAmount(credit.add(amount));
accountCredit.put(accountKey, accountCredit.get(accountKey));
} else {
KualiDecimal credit = accountingLine.getAmount();
SourceAccountingLine creditAcctLine = new SourceAccountingLine();
creditAcctLine.setChartOfAccountsCode(accountingLine.getChartOfAccountsCode());
creditAcctLine.setAccountNumber(accountingLine.getAccountNumber());
creditAcctLine.setSubAccountNumber(accountingLine.getSubAccountNumber());
creditAcctLine.setFinancialSubObjectCode(accountingLine.getFinancialSubObjectCode());
creditAcctLine.setProjectCode(accountingLine.getProjectCode());
creditAcctLine.setOrganizationReferenceId(accountingLine.getOrganizationReferenceId());
creditAcctLine.setAmount(credit);
accountCredit.put(accountKey, creditAcctLine);
}
}
// debit
if (KFSConstants.GL_DEBIT_CODE.equalsIgnoreCase(accountingLine.getDebitCreditCode())) {
String accountKey = accountingLine.getChartOfAccountsCode() + accountingLine.getAccountNumber() + accountingLine.getSubAccountNumber() + accountingLine.getFinancialSubObjectCode() + accountingLine.getProjectCode() + accountingLine.getOrganizationReferenceId();
if (accountDebit.containsKey(accountKey)) {
KualiDecimal debit = accountDebit.get(accountKey).getAmount();
KualiDecimal amount = accountingLine.getAmount();
accountDebit.get(accountKey).setAmount(debit.add(amount));
accountDebit.put(accountKey, accountDebit.get(accountKey));
} else {
KualiDecimal debit = accountingLine.getAmount();
SourceAccountingLine debitAcctLine = new SourceAccountingLine();
debitAcctLine.setChartOfAccountsCode(accountingLine.getChartOfAccountsCode());
debitAcctLine.setAccountNumber(accountingLine.getAccountNumber());
debitAcctLine.setSubAccountNumber(accountingLine.getSubAccountNumber());
debitAcctLine.setFinancialSubObjectCode(accountingLine.getFinancialSubObjectCode());
debitAcctLine.setProjectCode(accountingLine.getProjectCode());
debitAcctLine.setOrganizationReferenceId(accountingLine.getOrganizationReferenceId());
debitAcctLine.setAmount(debit);
accountDebit.put(accountKey, debitAcctLine);
}
}
}
}
// create gl entries
// create NB 4490 income entry and 3190 offset
List<GeneralLedgerPendingEntry> entries = createPendingEntries(document, accountingLine, sequenceHelper, closingCharts, fiscalYear);
for (GeneralLedgerPendingEntry entry : entries) {
document.addPendingEntry(entry);
}
}
Set<String> incomeExpenseSet = new HashSet<String>();
incomeExpenseSet.addAll(incomeAccounts.keySet());
incomeExpenseSet.addAll(expenseAccounts.keySet());
// create BB income - expense 3190 entry
for (String accountKey : incomeExpenseSet) {
KualiDecimal income = KualiDecimal.ZERO;
KualiDecimal expense = KualiDecimal.ZERO;
AccountingLine acctLine = ObjectUtils.isNull(incomeAccounts.get(accountKey)) ? expenseAccounts.get(accountKey) : incomeAccounts.get(accountKey);
if (ObjectUtils.isNotNull(incomeAccounts.get(accountKey))) {
income = incomeAccounts.get(accountKey).getAmount();
}
if (ObjectUtils.isNotNull(expenseAccounts.get(accountKey))) {
expense = expenseAccounts.get(accountKey).getAmount();
}
KualiDecimal amount = income.subtract(expense);
acctLine.setAmount(amount);
if (ObjectUtils.isNotNull(amount) && amount.isNonZero()) {
document.addPendingEntry(generateBBIncomeLessExpenseOffset(document, acctLine, sequenceHelper.getSequenceCounter(), fiscalYear));
sequenceHelper.increment();
}
}
Set<String> creditDebitSet = new HashSet<String>();
creditDebitSet.addAll(accountCredit.keySet());
creditDebitSet.addAll(accountDebit.keySet());
// create 1000 cash offset entry for remaining cash = credit - debit
for (String accountKey : creditDebitSet) {
KualiDecimal credit = KualiDecimal.ZERO;
KualiDecimal debit = KualiDecimal.ZERO;
AccountingLine acctLine = ObjectUtils.isNull(accountCredit.get(accountKey)) ? accountDebit.get(accountKey) : accountCredit.get(accountKey);
if (ObjectUtils.isNotNull(accountCredit.get(accountKey))) {
credit = accountCredit.get(accountKey).getAmount();
}
if (ObjectUtils.isNotNull(accountDebit.get(accountKey))) {
debit = accountDebit.get(accountKey).getAmount();
}
KualiDecimal amount = credit.subtract(debit);
acctLine.setAmount(amount);
if (ObjectUtils.isNotNull(amount) && amount.isNonZero()) {
document.addPendingEntry(generateBBCashOffset(document, acctLine, sequenceHelper.getSequenceCounter(), documentTypeCode, fiscalYear));
sequenceHelper.increment();
}
}
return true;
}
use of org.kuali.kfs.sys.businessobject.AccountingLine in project cu-kfs by CU-CommunityApps.
the class CuDisbursementVoucherDocument method isTravelReviewRequired.
public boolean isTravelReviewRequired() {
List<AccountingLine> theList = (List<AccountingLine>) this.sourceAccountingLines;
for (AccountingLine alb : theList) {
ParameterEvaluator objectCodes = SpringContext.getBean(ParameterEvaluatorService.class).getParameterEvaluator("KFS-FP", "DisbursementVoucher", OBJECT_CODES_REQUIRING_TRAVEL_REVIEW, alb.getFinancialObjectCode());
if (objectCodes.evaluationSucceeds()) {
LOG.info("Object Code " + alb.getFinancialObjectCode() + " requires this document to undergo Travel review.");
return true;
}
}
boolean overDollarThreshold = false;
String dollarThreshold = getParameterService().getParameterValueAsString("KFS-FP", "DisbursementVoucher", DOLLAR_THRESHOLD_REQUIRING_TRAVEL_REVIEW);
KualiDecimal dollarThresholdDecimal = new KualiDecimal(dollarThreshold);
if (this.disbVchrCheckTotalAmount.isGreaterEqual(dollarThresholdDecimal)) {
overDollarThreshold = true;
}
String paymentReasonCode = this.getDvPayeeDetail().getDisbVchrPaymentReasonCode();
return (this.getDisbursementVoucherPaymentReasonService().isPrepaidTravelPaymentReason(paymentReasonCode) || this.getDisbursementVoucherPaymentReasonService().isNonEmployeeTravelPaymentReason(paymentReasonCode) && overDollarThreshold);
}
use of org.kuali.kfs.sys.businessobject.AccountingLine in project cu-kfs by CU-CommunityApps.
the class CuPreEncumbranceAction method processAccountingLines.
protected void processAccountingLines(AccountingDocument transDoc, KualiAccountingDocumentFormBase transForm, String lineSet) {
// figure out which set of lines we're looking at
List formLines;
String pathPrefix;
boolean source;
if (lineSet.equals(KFSConstants.SOURCE)) {
formLines = transDoc.getSourceAccountingLines();
pathPrefix = KFSConstants.DOCUMENT_PROPERTY_NAME + dot + KFSConstants.EXISTING_SOURCE_ACCT_LINE_PROPERTY_NAME;
source = true;
} else {
formLines = transDoc.getTargetAccountingLines();
pathPrefix = KFSConstants.DOCUMENT_PROPERTY_NAME + dot + KFSConstants.EXISTING_TARGET_ACCT_LINE_PROPERTY_NAME;
source = false;
}
// find and process corresponding form and baselines
int index = 0;
for (Iterator i = formLines.iterator(); i.hasNext(); index++) {
AccountingLine formLine = (AccountingLine) i.next();
if (formLine.isSourceAccountingLine()) {
formLine.setReferenceNumber(transDoc.getDocumentNumber());
}
// update sales tax required attribute for view
// handleSalesTaxRequired(transDoc, formLine, source, false, index);
checkSalesTax(transDoc, formLine, source, false, index);
}
}
use of org.kuali.kfs.sys.businessobject.AccountingLine in project cu-kfs by CU-CommunityApps.
the class PurchaseOrderDocument method customizeExplicitGeneralLedgerPendingEntry.
/**
* @see org.kuali.module.purap.rules.PurapAccountingDocumentRuleBase#customizeExplicitGeneralLedgerPendingEntry(org.kuali.kfs.sys.document.AccountingDocument,
* org.kuali.kfs.sys.businessobject.AccountingLine, org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntry)
*/
@Override
public void customizeExplicitGeneralLedgerPendingEntry(GeneralLedgerPendingEntrySourceDetail postable, GeneralLedgerPendingEntry explicitEntry) {
super.customizeExplicitGeneralLedgerPendingEntry(postable, explicitEntry);
SpringContext.getBean(PurapGeneralLedgerService.class).customizeGeneralLedgerPendingEntry(this, (AccountingLine) postable, explicitEntry, getPurapDocumentIdentifier(), GL_DEBIT_CODE, PurapDocTypeCodes.PO_DOCUMENT, true);
KualiDecimal accountTotalGLEntryAmount = KualiDecimal.ZERO;
// for the updated amount or new items, not for the entire items' accounts.
if (PurapDocTypeCodes.PO_AMENDMENT_DOCUMENT.equals(explicitEntry.getFinancialDocumentTypeCode()) || PurapDocTypeCodes.PO_CLOSE_DOCUMENT.equals(explicitEntry.getFinancialDocumentTypeCode()) || PurapDocTypeCodes.PO_REOPEN_DOCUMENT.equals(explicitEntry.getFinancialDocumentTypeCode())) {
accountTotalGLEntryAmount = explicitEntry.getTransactionLedgerEntryAmount();
} else {
accountTotalGLEntryAmount = this.getAccountTotalGLEntryAmount((AccountingLine) postable);
}
explicitEntry.setTransactionLedgerEntryAmount(accountTotalGLEntryAmount);
handleNegativeEntryAmount(explicitEntry);
// don't think i should have to override this, but default isn't getting the right PO doc
explicitEntry.setFinancialDocumentTypeCode(PurapDocTypeCodes.PO_DOCUMENT);
}
Aggregations