use of org.kuali.kfs.coa.service.ObjectTypeService 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