use of org.kuali.kfs.sys.exception.InvalidFlexibleOffsetException in project cu-kfs by CU-CommunityApps.
the class CuScrubberProcessImpl method generateCostShareEntries.
/**
* Overridden to update cost share source account entries so that they will post to the
* continuation account if the cost share account is closed.
*
* @see org.kuali.kfs.gl.batch.service.impl.ScrubberProcessImpl#generateCostShareEntries(
* org.kuali.kfs.gl.businessobject.OriginEntryInformation, org.kuali.kfs.gl.service.ScrubberReportData)
*/
@Override
protected ScrubberProcessTransactionError generateCostShareEntries(OriginEntryInformation scrubbedEntry, ScrubberReportData scrubberReport) {
// 3000-COST-SHARE to 3100-READ-OFSD in the cobol Generate Cost Share Entries
LOG.debug("generateCostShareEntries() started");
try {
OriginEntryFull costShareEntry = OriginEntryFull.copyFromOriginEntryable(scrubbedEntry);
SystemOptions scrubbedEntryOption = accountingCycleCachingService.getSystemOptions(scrubbedEntry.getUniversityFiscalYear());
A21SubAccount scrubbedEntryA21SubAccount = accountingCycleCachingService.getA21SubAccount(scrubbedEntry.getChartOfAccountsCode(), scrubbedEntry.getAccountNumber(), scrubbedEntry.getSubAccountNumber());
costShareEntry.setFinancialObjectCode(parameterService.getParameterValueAsString(ScrubberStep.class, GeneralLedgerConstants.GlScrubberGroupParameters.COST_SHARE_OBJECT_CODE_PARM_NM));
costShareEntry.setFinancialSubObjectCode(KFSConstants.getDashFinancialSubObjectCode());
costShareEntry.setFinancialObjectTypeCode(scrubbedEntryOption.getFinancialObjectTypeTransferExpenseCd());
costShareEntry.setTransactionLedgerEntrySequenceNumber(new Integer(0));
StringBuffer description = new StringBuffer();
description.append(costShareDescription);
description.append(" ").append(scrubbedEntry.getAccountNumber());
description.append(offsetString);
costShareEntry.setTransactionLedgerEntryDescription(description.toString());
costShareEntry.setTransactionLedgerEntryAmount(scrubCostShareAmount);
if (scrubCostShareAmount.isPositive()) {
costShareEntry.setTransactionDebitCreditCode(KFSConstants.GL_DEBIT_CODE);
} else {
costShareEntry.setTransactionDebitCreditCode(KFSConstants.GL_CREDIT_CODE);
costShareEntry.setTransactionLedgerEntryAmount(scrubCostShareAmount.negated());
}
costShareEntry.setTransactionDate(runDate);
costShareEntry.setOrganizationDocumentNumber(null);
costShareEntry.setProjectCode(KFSConstants.getDashProjectCode());
costShareEntry.setOrganizationReferenceId(null);
costShareEntry.setReferenceFinancialDocumentTypeCode(null);
costShareEntry.setReferenceFinancialSystemOriginationCode(null);
costShareEntry.setReferenceFinancialDocumentNumber(null);
costShareEntry.setFinancialDocumentReversalDate(null);
costShareEntry.setTransactionEncumbranceUpdateCode(null);
createOutputEntry(costShareEntry, OUTPUT_GLE_FILE_ps);
scrubberReport.incrementCostShareEntryGenerated();
OriginEntryFull costShareOffsetEntry = new OriginEntryFull(costShareEntry);
costShareOffsetEntry.setTransactionLedgerEntryDescription(getOffsetMessage());
OffsetDefinition offsetDefinition = accountingCycleCachingService.getOffsetDefinition(scrubbedEntry.getUniversityFiscalYear(), scrubbedEntry.getChartOfAccountsCode(), KFSConstants.TRANSFER_FUNDS, scrubbedEntry.getFinancialBalanceTypeCode());
if (offsetDefinition != null) {
if (offsetDefinition.getFinancialObject() == null) {
StringBuffer objectCodeKey = new StringBuffer();
objectCodeKey.append(offsetDefinition.getUniversityFiscalYear());
objectCodeKey.append("-").append(offsetDefinition.getChartOfAccountsCode());
objectCodeKey.append("-").append(offsetDefinition.getFinancialObjectCode());
Message m = new Message(configurationService.getPropertyValueAsString(KFSKeyConstants.ERROR_OFFSET_DEFINITION_OBJECT_CODE_NOT_FOUND) + " (" + objectCodeKey.toString() + ")", Message.TYPE_FATAL);
LOG.debug("generateCostShareEntries() Error 1 object not found");
return new ScrubberProcessTransactionError(costShareEntry, m);
}
costShareOffsetEntry.setFinancialObjectCode(offsetDefinition.getFinancialObjectCode());
costShareOffsetEntry.setFinancialObject(offsetDefinition.getFinancialObject());
costShareOffsetEntry.setFinancialSubObjectCode(KFSConstants.getDashFinancialSubObjectCode());
} else {
Map<Transaction, List<Message>> errors = new HashMap<Transaction, List<Message>>();
StringBuffer offsetKey = new StringBuffer("cost share transfer ");
offsetKey.append(scrubbedEntry.getUniversityFiscalYear());
offsetKey.append("-");
offsetKey.append(scrubbedEntry.getChartOfAccountsCode());
offsetKey.append("-TF-");
offsetKey.append(scrubbedEntry.getFinancialBalanceTypeCode());
Message m = new Message(configurationService.getPropertyValueAsString(KFSKeyConstants.ERROR_OFFSET_DEFINITION_NOT_FOUND) + " (" + offsetKey.toString() + ")", Message.TYPE_FATAL);
LOG.debug("generateCostShareEntries() Error 2 offset not found");
return new ScrubberProcessTransactionError(costShareEntry, m);
}
costShareOffsetEntry.setFinancialObjectTypeCode(offsetDefinition.getFinancialObject().getFinancialObjectTypeCode());
if (costShareEntry.isCredit()) {
costShareOffsetEntry.setTransactionDebitCreditCode(KFSConstants.GL_DEBIT_CODE);
} else {
costShareOffsetEntry.setTransactionDebitCreditCode(KFSConstants.GL_CREDIT_CODE);
}
try {
flexibleOffsetAccountService.updateOffset(costShareOffsetEntry);
} catch (InvalidFlexibleOffsetException e) {
Message m = new Message(e.getMessage(), Message.TYPE_FATAL);
if (LOG.isDebugEnabled()) {
LOG.debug("generateCostShareEntries() Cost Share Transfer Flexible Offset Error: " + e.getMessage());
}
return new ScrubberProcessTransactionError(costShareEntry, m);
}
createOutputEntry(costShareOffsetEntry, OUTPUT_GLE_FILE_ps);
scrubberReport.incrementCostShareEntryGenerated();
OriginEntryFull costShareSourceAccountEntry = new OriginEntryFull(costShareEntry);
description = new StringBuffer();
description.append(costShareDescription);
description.append(" ").append(scrubbedEntry.getAccountNumber());
description.append(offsetString);
costShareSourceAccountEntry.setTransactionLedgerEntryDescription(description.toString());
// CU Customization: If Cost Share account is closed, use its continuation account instead.
ScrubberProcessTransactionError continuationError = setupEntryWithPotentialContinuation(costShareSourceAccountEntry, scrubbedEntryA21SubAccount);
if (continuationError != null) {
return continuationError;
}
setCostShareObjectCode(costShareSourceAccountEntry, scrubbedEntry);
if (StringHelper.isNullOrEmpty(costShareSourceAccountEntry.getSubAccountNumber())) {
costShareSourceAccountEntry.setSubAccountNumber(KFSConstants.getDashSubAccountNumber());
}
costShareSourceAccountEntry.setFinancialSubObjectCode(KFSConstants.getDashFinancialSubObjectCode());
costShareSourceAccountEntry.setFinancialObjectTypeCode(scrubbedEntryOption.getFinancialObjectTypeTransferExpenseCd());
costShareSourceAccountEntry.setTransactionLedgerEntrySequenceNumber(new Integer(0));
costShareSourceAccountEntry.setTransactionLedgerEntryAmount(scrubCostShareAmount);
if (scrubCostShareAmount.isPositive()) {
costShareSourceAccountEntry.setTransactionDebitCreditCode(KFSConstants.GL_CREDIT_CODE);
} else {
costShareSourceAccountEntry.setTransactionDebitCreditCode(KFSConstants.GL_DEBIT_CODE);
costShareSourceAccountEntry.setTransactionLedgerEntryAmount(scrubCostShareAmount.negated());
}
costShareSourceAccountEntry.setTransactionDate(runDate);
costShareSourceAccountEntry.setOrganizationDocumentNumber(null);
costShareSourceAccountEntry.setProjectCode(KFSConstants.getDashProjectCode());
costShareSourceAccountEntry.setOrganizationReferenceId(null);
costShareSourceAccountEntry.setReferenceFinancialDocumentTypeCode(null);
costShareSourceAccountEntry.setReferenceFinancialSystemOriginationCode(null);
costShareSourceAccountEntry.setReferenceFinancialDocumentNumber(null);
costShareSourceAccountEntry.setFinancialDocumentReversalDate(null);
costShareSourceAccountEntry.setTransactionEncumbranceUpdateCode(null);
createOutputEntry(costShareSourceAccountEntry, OUTPUT_GLE_FILE_ps);
scrubberReport.incrementCostShareEntryGenerated();
OriginEntryFull costShareSourceAccountOffsetEntry = new OriginEntryFull(costShareSourceAccountEntry);
costShareSourceAccountOffsetEntry.setTransactionLedgerEntryDescription(getOffsetMessage());
// Lookup the new offset definition.
offsetDefinition = accountingCycleCachingService.getOffsetDefinition(scrubbedEntry.getUniversityFiscalYear(), scrubbedEntry.getChartOfAccountsCode(), KFSConstants.TRANSFER_FUNDS, scrubbedEntry.getFinancialBalanceTypeCode());
if (offsetDefinition != null) {
if (offsetDefinition.getFinancialObject() == null) {
Map<Transaction, List<Message>> errors = new HashMap<Transaction, List<Message>>();
StringBuffer objectCodeKey = new StringBuffer();
objectCodeKey.append(costShareEntry.getUniversityFiscalYear());
objectCodeKey.append("-").append(scrubbedEntry.getChartOfAccountsCode());
objectCodeKey.append("-").append(scrubbedEntry.getFinancialObjectCode());
Message m = new Message(configurationService.getPropertyValueAsString(KFSKeyConstants.ERROR_OFFSET_DEFINITION_OBJECT_CODE_NOT_FOUND) + " (" + objectCodeKey.toString() + ")", Message.TYPE_FATAL);
LOG.debug("generateCostShareEntries() Error 3 object not found");
return new ScrubberProcessTransactionError(costShareSourceAccountEntry, m);
}
costShareSourceAccountOffsetEntry.setFinancialObjectCode(offsetDefinition.getFinancialObjectCode());
costShareSourceAccountOffsetEntry.setFinancialObject(offsetDefinition.getFinancialObject());
costShareSourceAccountOffsetEntry.setFinancialSubObjectCode(KFSConstants.getDashFinancialSubObjectCode());
} else {
Map<Transaction, List<Message>> errors = new HashMap<Transaction, List<Message>>();
StringBuffer offsetKey = new StringBuffer("cost share transfer source ");
offsetKey.append(scrubbedEntry.getUniversityFiscalYear());
offsetKey.append("-");
offsetKey.append(scrubbedEntry.getChartOfAccountsCode());
offsetKey.append("-TF-");
offsetKey.append(scrubbedEntry.getFinancialBalanceTypeCode());
Message m = new Message(configurationService.getPropertyValueAsString(KFSKeyConstants.ERROR_OFFSET_DEFINITION_NOT_FOUND) + " (" + offsetKey.toString() + ")", Message.TYPE_FATAL);
LOG.debug("generateCostShareEntries() Error 4 offset not found");
return new ScrubberProcessTransactionError(costShareSourceAccountEntry, m);
}
costShareSourceAccountOffsetEntry.setFinancialObjectTypeCode(offsetDefinition.getFinancialObject().getFinancialObjectTypeCode());
if (scrubbedEntry.isCredit()) {
costShareSourceAccountOffsetEntry.setTransactionDebitCreditCode(KFSConstants.GL_DEBIT_CODE);
} else {
costShareSourceAccountOffsetEntry.setTransactionDebitCreditCode(KFSConstants.GL_CREDIT_CODE);
}
try {
flexibleOffsetAccountService.updateOffset(costShareSourceAccountOffsetEntry);
} catch (InvalidFlexibleOffsetException e) {
Message m = new Message(e.getMessage(), Message.TYPE_FATAL);
if (LOG.isDebugEnabled()) {
LOG.debug("generateCostShareEntries() Cost Share Transfer Account Flexible Offset Error: " + e.getMessage());
}
return new ScrubberProcessTransactionError(costShareEntry, m);
}
createOutputEntry(costShareSourceAccountOffsetEntry, OUTPUT_GLE_FILE_ps);
scrubberReport.incrementCostShareEntryGenerated();
scrubCostShareAmount = KualiDecimal.ZERO;
} catch (IOException ioe) {
LOG.error("generateCostShareEntries() Stopped: " + ioe.getMessage());
throw new RuntimeException("generateCostShareEntries() Stopped: " + ioe.getMessage(), ioe);
}
LOG.debug("generateCostShareEntries() successful");
return null;
}
use of org.kuali.kfs.sys.exception.InvalidFlexibleOffsetException in project cu-kfs by CU-CommunityApps.
the class YearEndGeneralLedgerPendingEntriesServiceImpl method generateCGBalanceForwardPendingEntry.
/**
* Generates the CG Balance Forward entry.
*
* @param document
* @param postable
* @param sequenceNumber
* @param fiscalYear
* @return The GL pending entry
*/
public GeneralLedgerPendingEntry generateCGBalanceForwardPendingEntry(AccountingDocumentBase document, AccountingLine postable, Integer sequenceNumber, Integer fiscalYear) {
/*
* Much of the code below was copied from BalanceForwardRuleHelper.generateCumulativeForwardOriginEntry,
* and adapted for generating a YEJV GL pending entry instead of a full origin entry.
*/
GeneralLedgerPendingEntry entry = new GeneralLedgerPendingEntry();
// Populate a temporary OriginEntryFull object so that we can use the FlexibleOffsetAccountService functionality.
OriginEntryFull originEntry = new OriginEntryFull();
originEntry.setUniversityFiscalYear(new Integer(fiscalYear + 1));
originEntry.setChartOfAccountsCode(postable.getChartOfAccountsCode());
originEntry.setAccountNumber(postable.getAccountNumber());
originEntry.setSubAccountNumber(StringUtils.isBlank(postable.getSubAccountNumber()) ? KFSConstants.getDashSubAccountNumber() : postable.getSubAccountNumber());
originEntry.setFinancialObjectCode(postable.getFinancialObjectCode());
originEntry.setFinancialSubObjectCode(StringUtils.isBlank(postable.getFinancialSubObjectCode()) ? KFSConstants.getDashFinancialSubObjectCode() : postable.getFinancialSubObjectCode());
originEntry.setFinancialBalanceTypeCode(postable.getBalanceTypeCode());
originEntry.setFinancialObjectTypeCode(postable.getObjectCode().getFinancialObjectTypeCode());
// Use the FlexibleOffsetAccountService to make updates as needed.
try {
getFlexibleOffsetAccountService().updateOffset(originEntry);
} catch (InvalidFlexibleOffsetException e) {
if (LOG.isDebugEnabled()) {
LOG.debug("generateCGBalanceForwardPendingEntry() Balance Forward Flexible Offset Error: " + e.getMessage());
}
}
// Copy the potentially-changed data into the GL pending entry accordingly.
entry.setUniversityFiscalYear(originEntry.getUniversityFiscalYear());
entry.setChartOfAccountsCode(originEntry.getChartOfAccountsCode());
entry.setAccountNumber(originEntry.getAccountNumber());
entry.setSubAccountNumber(originEntry.getSubAccountNumber());
entry.setFinancialObjectCode(originEntry.getFinancialObjectCode());
entry.setFinancialSubObjectCode(originEntry.getFinancialSubObjectCode());
entry.setFinancialBalanceTypeCode(originEntry.getFinancialBalanceTypeCode());
entry.setFinancialObjectTypeCode(originEntry.getFinancialObjectTypeCode());
// Continue with regular setup.
entry.setUniversityFiscalPeriodCode(KFSConstants.PERIOD_CODE_CG_BEGINNING_BALANCE);
entry.setFinancialDocumentTypeCode(document.getFinancialSystemDocumentHeader().getWorkflowDocument().getDocumentTypeName());
entry.setFinancialSystemOriginationCode(homeOriginationService.getHomeOrigination().getFinSystemHomeOriginationCode());
entry.setDocumentNumber(new StringBuilder(KFSConstants.BALANCE_TYPE_ACTUAL).append(postable.getAccountNumber()).toString());
entry.setTransactionLedgerEntrySequenceNumber(sequenceNumber);
entry.setTransactionLedgerEntryDescription(new StringBuilder("BEG C & G BAL BROUGHT FORWARD FROM ").append(fiscalYear).toString());
entry.setTransactionLedgerEntryAmount(postable.getAmount());
if (KFSConstants.BALANCE_TYPE_CURRENT_BUDGET.equals(postable.getBalanceTypeCode()) || KFSConstants.BALANCE_TYPE_BASE_BUDGET.equals(postable.getBalanceTypeCode())) {
entry.setTransactionDebitCreditCode(null);
} else {
entry.setTransactionDebitCreditCode(postable.getDebitCreditCode());
}
Timestamp transactionTimestamp = new Timestamp(dateTimeService.getCurrentDate().getTime());
entry.setTransactionDate(new java.sql.Date(transactionTimestamp.getTime()));
entry.setOrganizationDocumentNumber(null);
entry.setProjectCode(KFSConstants.getDashProjectCode());
entry.setOrganizationReferenceId(null);
entry.setReferenceFinancialDocumentNumber(null);
entry.setReferenceFinancialSystemOriginationCode(null);
entry.setReferenceFinancialDocumentNumber(null);
entry.setFinancialDocumentReversalDate(null);
String transactionEncumbranceUpdateCode = KFSConstants.ENCUMB_UPDT_NO_ENCUMBRANCE_CD;
entry.setTransactionEncumbranceUpdateCode(transactionEncumbranceUpdateCode);
if (KFSConstants.BALANCE_TYPE_AUDIT_TRAIL.equals(postable.getBalanceTypeCode())) {
entry.setFinancialBalanceTypeCode(KFSConstants.BALANCE_TYPE_ACTUAL);
}
if (entry.getTransactionLedgerEntryAmount().isNegative()) {
if (KFSConstants.BALANCE_TYPE_ACTUAL.equals(entry.getFinancialBalanceTypeCode())) {
entry.setTransactionLedgerEntryAmount(entry.getTransactionLedgerEntryAmount().negated());
}
}
return entry;
}
use of org.kuali.kfs.sys.exception.InvalidFlexibleOffsetException in project cu-kfs by CU-CommunityApps.
the class CuPosterServiceImpl method generateTransactions.
@Override
protected void generateTransactions(ExpenditureTransaction et, IndirectCostRecoveryRateDetail icrRateDetail, KualiDecimal generatedTransactionAmount, Date runDate, PrintStream group, IndirectCostRecoveryGenerationMetadata icrGenerationMetadata) {
BigDecimal pct = new BigDecimal(icrRateDetail.getAwardIndrCostRcvyRatePct().toString());
pct = pct.divide(BDONEHUNDRED);
OriginEntryFull e = new OriginEntryFull();
e.setTransactionLedgerEntrySequenceNumber(0);
// means we use the ICR field from the account record, otherwise, use the field in the icrRateDetail
if (GeneralLedgerConstants.PosterService.SYMBOL_USE_EXPENDITURE_ENTRY.equals(icrRateDetail.getFinancialObjectCode()) || GeneralLedgerConstants.PosterService.SYMBOL_USE_ICR_FROM_ACCOUNT.equals(icrRateDetail.getFinancialObjectCode())) {
e.setFinancialObjectCode(et.getObjectCode());
e.setFinancialSubObjectCode(et.getSubObjectCode());
} else {
e.setFinancialObjectCode(icrRateDetail.getFinancialObjectCode());
e.setFinancialSubObjectCode(icrRateDetail.getFinancialSubObjectCode());
}
if (GeneralLedgerConstants.PosterService.SYMBOL_USE_EXPENDITURE_ENTRY.equals(icrRateDetail.getAccountNumber())) {
e.setAccountNumber(et.getAccountNumber());
e.setChartOfAccountsCode(et.getChartOfAccountsCode());
e.setSubAccountNumber(et.getSubAccountNumber());
} else if (GeneralLedgerConstants.PosterService.SYMBOL_USE_ICR_FROM_ACCOUNT.equals(icrRateDetail.getAccountNumber())) {
e.setAccountNumber(icrGenerationMetadata.getIndirectCostRecoveryAcctNbr());
e.setChartOfAccountsCode(icrGenerationMetadata.getIndirectCostRcvyFinCoaCode());
e.setSubAccountNumber(KFSConstants.getDashSubAccountNumber());
} else {
e.setAccountNumber(icrRateDetail.getAccountNumber());
e.setSubAccountNumber(icrRateDetail.getSubAccountNumber());
e.setChartOfAccountsCode(icrRateDetail.getChartOfAccountsCode());
// TODO Reporting thing line 1946
}
// take care of infinite recursive error case - do not generate entries
if ((et.getAccountNumber().equals(e.getAccountNumber())) && (et.getChartOfAccountsCode().equals(e.getChartOfAccountsCode())) && (et.getSubAccountNumber().equals(e.getSubAccountNumber())) && (et.getObjectCode().equals(e.getFinancialObjectCode())) && (et.getSubObjectCode().equals(e.getFinancialSubObjectCode()))) {
List<Message> warnings = new ArrayList<Message>();
warnings.add(new Message("Infinite recursive encumbrance error " + et.getChartOfAccountsCode() + " " + et.getAccountNumber() + " " + et.getSubAccountNumber() + " " + et.getObjectCode() + " " + et.getSubObjectCode(), Message.TYPE_WARNING));
reportWriterService.writeError(et, warnings);
return;
}
e.setFinancialDocumentTypeCode(parameterService.getParameterValueAsString(PosterIndirectCostRecoveryEntriesStep.class, KFSConstants.SystemGroupParameterNames.GL_INDIRECT_COST_RECOVERY));
e.setFinancialSystemOriginationCode(parameterService.getParameterValueAsString(KfsParameterConstants.GENERAL_LEDGER_BATCH.class, KFSConstants.SystemGroupParameterNames.GL_ORIGINATION_CODE));
SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_STRING);
/*CUMod - start*/
StringBuffer docNbr = new StringBuffer(ICR_EDOC_PREFIX);
docNbr.append(sdf.format(runDate));
e.setDocumentNumber(docNbr.toString());
LOG.debug("CuPosterServiceImpl.generateTransactions: setDocumentNumber = '" + docNbr.toString() + "'");
/*CUMod - stop*/
if (KFSConstants.GL_DEBIT_CODE.equals(icrRateDetail.getTransactionDebitIndicator())) {
e.setTransactionLedgerEntryDescription(getChargeDescription(pct, et.getObjectCode(), icrGenerationMetadata.getIndirectCostRecoveryTypeCode(), et.getAccountObjectDirectCostAmount().abs()));
} else {
e.setTransactionLedgerEntryDescription(getOffsetDescription(pct, et.getAccountObjectDirectCostAmount().abs(), et.getChartOfAccountsCode(), et.getAccountNumber()));
}
e.setTransactionDate(new java.sql.Date(runDate.getTime()));
e.setTransactionDebitCreditCode(icrRateDetail.getTransactionDebitIndicator());
e.setFinancialBalanceTypeCode(et.getBalanceTypeCode());
e.setUniversityFiscalYear(et.getUniversityFiscalYear());
e.setUniversityFiscalPeriodCode(et.getUniversityFiscalAccountingPeriod());
ObjectCode oc = objectCodeService.getByPrimaryId(e.getUniversityFiscalYear(), e.getChartOfAccountsCode(), e.getFinancialObjectCode());
if (oc == null) {
LOG.warn(configurationService.getPropertyValueAsString(KFSKeyConstants.ERROR_OBJECT_CODE_NOT_FOUND_FOR) + e.getUniversityFiscalYear() + "," + e.getChartOfAccountsCode() + "," + e.getFinancialObjectCode());
// this will be written out the ICR file. Then, when that file attempts to post, the transaction won't validate and will end up in the icr error file
e.setFinancialObjectCode(icrRateDetail.getFinancialObjectCode());
} else {
e.setFinancialObjectTypeCode(oc.getFinancialObjectTypeCode());
}
if (generatedTransactionAmount.isNegative()) {
if (KFSConstants.GL_DEBIT_CODE.equals(icrRateDetail.getTransactionDebitIndicator())) {
e.setTransactionDebitCreditCode(KFSConstants.GL_CREDIT_CODE);
} else {
e.setTransactionDebitCreditCode(KFSConstants.GL_DEBIT_CODE);
}
e.setTransactionLedgerEntryAmount(generatedTransactionAmount.negated());
} else {
e.setTransactionLedgerEntryAmount(generatedTransactionAmount);
}
if (et.getBalanceTypeCode().equals(et.getOption().getExtrnlEncumFinBalanceTypCd()) || et.getBalanceTypeCode().equals(et.getOption().getIntrnlEncumFinBalanceTypCd()) || et.getBalanceTypeCode().equals(et.getOption().getPreencumbranceFinBalTypeCd()) || et.getBalanceTypeCode().equals(et.getOption().getCostShareEncumbranceBalanceTypeCd())) {
e.setDocumentNumber(parameterService.getParameterValueAsString(PosterIndirectCostRecoveryEntriesStep.class, KFSConstants.SystemGroupParameterNames.GL_INDIRECT_COST_RECOVERY));
}
e.setProjectCode(et.getProjectCode());
if (GeneralLedgerConstants.getDashOrganizationReferenceId().equals(et.getOrganizationReferenceId())) {
e.setOrganizationReferenceId(null);
} else {
e.setOrganizationReferenceId(et.getOrganizationReferenceId());
}
// TODO 2031-2039
try {
createOutputEntry(e, group);
} catch (IOException ioe) {
LOG.error("generateTransactions Stopped: " + ioe.getMessage());
throw new RuntimeException("generateTransactions Stopped: " + ioe.getMessage(), ioe);
}
// Now generate Offset
e = new OriginEntryFull(e);
if (KFSConstants.GL_DEBIT_CODE.equals(e.getTransactionDebitCreditCode())) {
e.setTransactionDebitCreditCode(KFSConstants.GL_CREDIT_CODE);
} else {
e.setTransactionDebitCreditCode(KFSConstants.GL_DEBIT_CODE);
}
e.setFinancialSubObjectCode(KFSConstants.getDashFinancialSubObjectCode());
String offsetBalanceSheetObjectCodeNumber = determineIcrOffsetBalanceSheetObjectCodeNumber(e, et, icrRateDetail);
e.setFinancialObjectCode(offsetBalanceSheetObjectCodeNumber);
ObjectCode balSheetObjectCode = objectCodeService.getByPrimaryId(icrRateDetail.getUniversityFiscalYear(), e.getChartOfAccountsCode(), offsetBalanceSheetObjectCodeNumber);
if (balSheetObjectCode == null) {
List<Message> warnings = new ArrayList<Message>();
warnings.add(new Message(configurationService.getPropertyValueAsString(KFSKeyConstants.ERROR_INVALID_OFFSET_OBJECT_CODE) + icrRateDetail.getUniversityFiscalYear() + "-" + e.getChartOfAccountsCode() + "-" + offsetBalanceSheetObjectCodeNumber, Message.TYPE_WARNING));
reportWriterService.writeError(et, warnings);
} else {
e.setFinancialObjectTypeCode(balSheetObjectCode.getFinancialObjectTypeCode());
}
if (KFSConstants.GL_DEBIT_CODE.equals(icrRateDetail.getTransactionDebitIndicator())) {
e.setTransactionLedgerEntryDescription(getChargeDescription(pct, et.getObjectCode(), icrGenerationMetadata.getIndirectCostRecoveryTypeCode(), et.getAccountObjectDirectCostAmount().abs()));
} else {
e.setTransactionLedgerEntryDescription(getOffsetDescription(pct, et.getAccountObjectDirectCostAmount().abs(), et.getChartOfAccountsCode(), et.getAccountNumber()));
}
try {
flexibleOffsetAccountService.updateOffset(e);
} catch (InvalidFlexibleOffsetException ex) {
List<Message> warnings = new ArrayList<Message>();
warnings.add(new Message("FAILED TO GENERATE FLEXIBLE OFFSETS " + ex.getMessage(), Message.TYPE_WARNING));
reportWriterService.writeError(et, warnings);
LOG.warn("FAILED TO GENERATE FLEXIBLE OFFSETS FOR EXPENDITURE TRANSACTION " + et.toString(), ex);
}
try {
createOutputEntry(e, group);
} catch (IOException ioe) {
LOG.error("generateTransactions Stopped: " + ioe.getMessage());
throw new RuntimeException("generateTransactions Stopped: " + ioe.getMessage(), ioe);
}
}
Aggregations