use of org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntry in project cu-kfs by CU-CommunityApps.
the class CUPaymentMethodGeneralLedgerPendingEntryServiceImpl method generateFeeAssessmentEntries.
/**
* Generates the GL entries to charge the department for the foreign draft and credit the Wire Charge
* Fee Account as specified by system parameters.
*
* @param document Document into which to add the generated GL Entries.
*/
protected boolean generateFeeAssessmentEntries(PaymentMethod pm, AccountingDocument document, GeneralLedgerPendingEntry templatePendingEntry, GeneralLedgerPendingEntrySequenceHelper sequenceHelper, boolean reverseEntries) {
LOG.debug("generateForeignDraftChargeEntries started");
PaymentMethodChart pmc = pm.getPaymentMethodChartInfo(templatePendingEntry.getChartOfAccountsCode(), new java.sql.Date(document.getDocumentHeader().getWorkflowDocument().getDateCreated().getMillis()));
if (pmc == null) {
LOG.warn("No Applicable PaymentMethodChart found for chart: " + templatePendingEntry.getChartOfAccountsCode() + " and date: " + document.getDocumentHeader().getWorkflowDocument().getDateCreated());
return false;
}
// Get all the parameters which control these entries
String feeIncomeChartCode = pmc.getFeeIncomeChartOfAccountsCode();
String feeIncomeAccountNumber = pmc.getFeeIncomeAccountNumber();
String feeExpenseObjectCode = pmc.getFeeExpenseFinancialObjectCode();
String feeIncomeObjectCode = pmc.getFeeIncomeFinancialObjectCode();
KualiDecimal feeAmount = pmc.getFeeAmount();
// skip creation if the fee has been set to zero
if (!KualiDecimal.ZERO.equals(feeAmount)) {
// grab the explicit entry for the first accounting line and adjust for the foreign draft fee
GeneralLedgerPendingEntry chargeEntry = new GeneralLedgerPendingEntry(document.getGeneralLedgerPendingEntry(0));
chargeEntry.setTransactionLedgerEntrySequenceNumber(sequenceHelper.getSequenceCounter());
// change the object code (expense to the department)
chargeEntry.setFinancialObjectCode(feeExpenseObjectCode);
chargeEntry.setFinancialSubObjectCode(GENERAL_LEDGER_PENDING_ENTRY_CODE.getBlankFinancialSubObjectCode());
chargeEntry.setTransactionLedgerEntryDescription(StringUtils.left("Automatic debit for " + pm.getPaymentMethodName() + " fee", 40));
chargeEntry.setFinancialBalanceTypeCode(KFSConstants.BALANCE_TYPE_ACTUAL);
// retrieve object type
ObjectCode objectCode = objectCodeService.getByPrimaryIdForCurrentYear(chargeEntry.getChartOfAccountsCode(), chargeEntry.getFinancialObjectCode());
if (objectCode == null) {
LOG.fatal("Specified offset object code: " + chargeEntry.getChartOfAccountsCode() + "-" + chargeEntry.getFinancialObjectCode() + " does not exist - failed to generate foreign draft fee entries", new RuntimeException());
return false;
}
chargeEntry.setFinancialObjectTypeCode(objectCode.getFinancialObjectTypeCode());
// Set the amount from the parameter
chargeEntry.setTransactionLedgerEntryAmount(feeAmount);
chargeEntry.setTransactionDebitCreditCode(reverseEntries ? GL_CREDIT_CODE : GL_DEBIT_CODE);
document.addPendingEntry(chargeEntry);
sequenceHelper.increment();
// handle the offset entry
GeneralLedgerPendingEntry offsetEntry = new GeneralLedgerPendingEntry(chargeEntry);
generalLedgerPendingEntryService.populateOffsetGeneralLedgerPendingEntry(document.getPostingYear(), chargeEntry, sequenceHelper, offsetEntry);
document.addPendingEntry(offsetEntry);
sequenceHelper.increment();
// Now, create the income entry in the AP Foreign draft fee account
GeneralLedgerPendingEntry feeIncomeEntry = new GeneralLedgerPendingEntry(document.getGeneralLedgerPendingEntry(0));
feeIncomeEntry.setTransactionLedgerEntrySequenceNumber(sequenceHelper.getSequenceCounter());
feeIncomeEntry.setChartOfAccountsCode(feeIncomeChartCode);
feeIncomeEntry.setAccountNumber(feeIncomeAccountNumber);
feeIncomeEntry.setFinancialObjectCode(feeIncomeObjectCode);
feeIncomeEntry.setFinancialSubObjectCode(GENERAL_LEDGER_PENDING_ENTRY_CODE.getBlankFinancialSubObjectCode());
feeIncomeEntry.setSubAccountNumber(GENERAL_LEDGER_PENDING_ENTRY_CODE.getBlankSubAccountNumber());
feeIncomeEntry.setProjectCode(GENERAL_LEDGER_PENDING_ENTRY_CODE.getBlankProjectCode());
// retrieve object type
objectCode = objectCodeService.getByPrimaryIdForCurrentYear(feeIncomeChartCode, feeIncomeObjectCode);
if (objectCode == null) {
LOG.fatal("Specified income object code: " + feeIncomeChartCode + "-" + feeIncomeObjectCode + " does not exist - failed to generate foreign draft income entries", new RuntimeException());
return false;
}
feeIncomeEntry.setFinancialObjectTypeCode(objectCode.getFinancialObjectTypeCode());
feeIncomeEntry.setTransactionLedgerEntryAmount(feeAmount);
feeIncomeEntry.setTransactionDebitCreditCode(KFSConstants.GL_CREDIT_CODE);
feeIncomeEntry.setFinancialBalanceTypeCode(KFSConstants.BALANCE_TYPE_ACTUAL);
document.addPendingEntry(feeIncomeEntry);
sequenceHelper.increment();
// create the offset entry
offsetEntry = new GeneralLedgerPendingEntry(feeIncomeEntry);
generalLedgerPendingEntryService.populateOffsetGeneralLedgerPendingEntry(document.getPostingYear(), feeIncomeEntry, sequenceHelper, offsetEntry);
document.addPendingEntry(offsetEntry);
sequenceHelper.increment();
}
return true;
}
use of org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntry in project cu-kfs by CU-CommunityApps.
the class CuPendingTransactionServiceImpl method generateDisbursementVoucherReversalEntries.
/**
* Generates the reversal entries for the given input DisbursementVoucherDocument.
*
* @param doc
* the DisbursementVoucherDocument for which we generate the reversal entries
* @param sequenceHelper
*/
protected void generateDisbursementVoucherReversalEntries(DisbursementVoucherDocument doc, GeneralLedgerPendingEntrySequenceHelper sequenceHelper) {
// generate all the pending entries for the document
SpringContext.getBean(GeneralLedgerPendingEntryService.class).generateGeneralLedgerPendingEntries(doc);
// for each pending entry, opposite-ify it and reattach it to the document
List<GeneralLedgerPendingEntry> glpes = doc.getGeneralLedgerPendingEntries();
if (glpes != null && glpes.size() > 0) {
for (GeneralLedgerPendingEntry glpe : glpes) {
if (KFSConstants.GL_CREDIT_CODE.equalsIgnoreCase(glpe.getTransactionDebitCreditCode())) {
glpe.setTransactionDebitCreditCode(KFSConstants.GL_DEBIT_CODE);
} else if (KFSConstants.GL_DEBIT_CODE.equalsIgnoreCase(glpe.getTransactionDebitCreditCode())) {
glpe.setTransactionDebitCreditCode(KFSConstants.GL_CREDIT_CODE);
}
glpe.setTransactionLedgerEntrySequenceNumber(sequenceHelper.getSequenceCounter());
sequenceHelper.increment();
Date transactionTimestamp = new Date(getDateTimeService().getCurrentDate().getTime());
AccountingPeriod fiscalPeriod = getAccountingPeriodService().getByDate(new java.sql.Date(transactionTimestamp.getTime()));
glpe.setFinancialDocumentApprovedCode(KFSConstants.PENDING_ENTRY_APPROVED_STATUS_CODE.APPROVED);
glpe.setUniversityFiscalYear(fiscalPeriod.getUniversityFiscalYear());
glpe.setUniversityFiscalPeriodCode(fiscalPeriod.getUniversityFiscalPeriodCode());
getBusinessObjectService().save(glpe);
}
}
}
use of org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntry in project cu-kfs by CU-CommunityApps.
the class DisbursementVoucherDocument method getPendingLedgerEntriesForSufficientFundsChecking.
@Override
public List<GeneralLedgerPendingEntry> getPendingLedgerEntriesForSufficientFundsChecking() {
List<GeneralLedgerPendingEntry> ples = new ArrayList<>();
FlexibleOffsetAccountService flexibleOffsetAccountService = SpringContext.getBean(FlexibleOffsetAccountService.class);
ObjectTypeService objectTypeService = SpringContext.getBean(ObjectTypeService.class);
for (GeneralLedgerPendingEntry ple : this.getGeneralLedgerPendingEntries()) {
List<String> expenseObjectTypes = objectTypeService.getExpenseObjectTypes(ple.getUniversityFiscalYear());
if (expenseObjectTypes.contains(ple.getFinancialObjectTypeCode())) {
// is an expense object type, keep checking
ple.refreshNonUpdateableReferences();
if (ple.getAccount().isPendingAcctSufficientFundsIndicator() && ple.getAccount().getAccountSufficientFundsCode().equals(KFSConstants.SF_TYPE_CASH_AT_ACCOUNT)) {
// is a cash account
if (flexibleOffsetAccountService.getByPrimaryIdIfEnabled(ple.getChartOfAccountsCode(), ple.getAccountNumber(), ple.getChart().getFinancialCashObjectCode()) == null && flexibleOffsetAccountService.getByPrimaryIdIfEnabled(ple.getChartOfAccountsCode(), ple.getAccountNumber(), ple.getChart().getFinAccountsPayableObjectCode()) == null) {
// does not have a flexible offset for cash or liability, set the object code to cash and add
// to list of PLEs to check for SF
GeneralLedgerPendingEntry newPle = new GeneralLedgerPendingEntry(ple);
newPle.setFinancialObjectCode(newPle.getChart().getFinancialCashObjectCode());
newPle.setTransactionDebitCreditCode(newPle.getTransactionDebitCreditCode().equals(KFSConstants.GL_DEBIT_CODE) ? KFSConstants.GL_CREDIT_CODE : KFSConstants.GL_DEBIT_CODE);
ples.add(newPle);
}
} else {
// is not a cash account, process as normal
ples.add(ple);
}
}
}
return ples;
}
Aggregations