use of org.kuali.kfs.coa.businessobject.A21SubAccount in project cu-kfs by CU-CommunityApps.
the class CuSubAccountMaintainableImpl method refresh.
public void refresh(String refreshCaller, Map fieldValues, org.kuali.kfs.kns.document.MaintenanceDocument document) {
super.refresh(refreshCaller, fieldValues, document);
String maintAction = super.getMaintenanceAction();
if (maintAction.equalsIgnoreCase(KRADConstants.MAINTENANCE_NEW_ACTION)) {
SubAccount subAccount = (SubAccount) super.getBusinessObject();
A21SubAccount newSubAccount = subAccount.getA21SubAccount();
if (ObjectUtils.isNotNull(newSubAccount) && ObjectUtils.isNotNull(newSubAccount.getA21IndirectCostRecoveryAccounts()) && newSubAccount.getA21IndirectCostRecoveryAccounts().size() > 0) {
for (A21IndirectCostRecoveryAccount recoveryAccount : newSubAccount.getA21IndirectCostRecoveryAccounts()) {
// set the newCollectionRecord indicator to true so that the entries can be deleted
recoveryAccount.setNewCollectionRecord(true);
}
}
}
}
use of org.kuali.kfs.coa.businessobject.A21SubAccount in project cu-kfs by CU-CommunityApps.
the class CuSubAccountMaintainableImpl method hasIcrSectionChanged.
// KFSUPGRADE-765 : Route edits to indirect cost to CG Resp ID
private boolean hasIcrSectionChanged() {
String maintAction = super.getMaintenanceAction();
boolean retval = false;
if ((maintAction.equalsIgnoreCase(KRADConstants.MAINTENANCE_NEW_ACTION)) || (maintAction.equalsIgnoreCase(KRADConstants.MAINTENANCE_COPY_ACTION))) {
// need "new" bo for data comparisons
SubAccount subAccount = (SubAccount) super.getBusinessObject();
if (subAccount.getA21SubAccount().getSubAccountTypeCode().equals(KFSConstants.SubAccountType.EXPENSE)) {
// We need to route only when the ICR data the user is submitting does NOT match the ICR data on the account
// "new" subAccount for data comparisons
A21SubAccount newSubAccount = subAccount.getA21SubAccount();
// "existing" data that would have pre-populated
Account account = this.getAccountService().getByPrimaryIdWithCaching(subAccount.getChartOfAccountsCode(), subAccount.getAccountNumber());
if (ObjectUtils.isNotNull(account) && ObjectUtils.isNotNull(newSubAccount)) {
List<IndirectCostRecoveryAccount> acctIcr = account.getIndirectCostRecoveryAccounts();
List<A21IndirectCostRecoveryAccount> subAcctIcr = newSubAccount.getA21ActiveIndirectCostRecoveryAccounts();
if (CollectionUtils.isEmpty(subAcctIcr)) {
if (CollectionUtils.isEmpty(acctIcr)) {
retval = false;
} else {
retval = true;
}
} else {
if (CollectionUtils.isEmpty(acctIcr)) {
retval = true;
} else {
/*
* the ICR accounts on the sub account needs to match the active ICR accounts on the parent account.
*/
int activeAcctIcrCount = 0;
for (IndirectCostRecoveryAccount acct : acctIcr) {
if (acct.isActive()) {
activeAcctIcrCount++;
}
}
if (subAcctIcr.size() == activeAcctIcrCount) {
retval = isIcrSectionDataChanged(subAcctIcr, acctIcr);
} else {
retval = true;
}
}
}
}
}
} else if (maintAction.equalsIgnoreCase(KRADConstants.MAINTENANCE_EDIT_ACTION)) {
// need "new" bo for data comparisons
SubAccount subAccount = (SubAccount) super.getBusinessObject();
// "new" subAccount for data comparisons
A21SubAccount newSubAccount = subAccount.getA21SubAccount();
if (ObjectUtils.isNotNull(newSubAccount)) {
try {
MaintenanceDocument oldMaintDoc = (MaintenanceDocument) SpringContext.getBean(DocumentService.class).getByDocumentHeaderId(getDocumentNumber());
A21SubAccount oldSubAccount = (A21SubAccount) ((SubAccount) oldMaintDoc.getOldMaintainableObject().getDataObject()).getA21SubAccount();
retval = isIcrSectionChanged(newSubAccount, oldSubAccount);
} catch (Exception e) {
LOG.error("caught exception while getting subaccount old maintainable -> documentService.getByDocumentHeaderId(" + getDocumentNumber() + "). ", e);
}
}
}
return retval;
}
use of org.kuali.kfs.coa.businessobject.A21SubAccount in project cu-kfs by CU-CommunityApps.
the class CuSubAccountMaintainableImpl method getSections.
/**
* Overridden to force the old maintenance object to include the relevant A21 sub-account and ICR account sections
* if the new object has them. This is necessary to work around a section size mismatch issue, which can occur
* when the old sub-account has a type of "CS" but the new one has a type of "EX" and possibly under other circumstances.
*
* @see org.kuali.kfs.kns.maintenance.KualiMaintainableImpl#getSections(org.kuali.kfs.kns.document.MaintenanceDocument, Maintainable)
*/
@SuppressWarnings("rawtypes")
@Override
public List getSections(org.kuali.kfs.kns.document.MaintenanceDocument document, Maintainable oldMaintainable) {
// The special handling only applies to the old maintainable.
if (this == document.getOldMaintainableObject()) {
SubAccount oldAccount = (SubAccount) getDataObject();
SubAccount newAccount = (SubAccount) document.getNewMaintainableObject().getDataObject();
if (hasA21SubAccount(newAccount) && (doesNotHaveA21SubAccount(oldAccount) || (isCostShareSubAccount(oldAccount) && isExpenseSubAccount(newAccount)) || oldAccountHasFewerIndirectCostRecoveryAccounts(oldAccount, newAccount))) {
// If necessary, set up an A21 sub-account with sufficient ICR accounts on the old maintainable before generating the sections.
List sections;
A21SubAccount oldA21Account = oldAccount.getA21SubAccount();
A21SubAccount tempA21Account = ObjectUtils.isNull(oldA21Account) ? new A21SubAccount() : (A21SubAccount) ObjectUtils.deepCopy(oldA21Account);
for (int i = newAccount.getA21SubAccount().getA21IndirectCostRecoveryAccounts().size() - tempA21Account.getA21IndirectCostRecoveryAccounts().size() - 1; i >= 0; i--) {
tempA21Account.getA21IndirectCostRecoveryAccounts().add(new A21IndirectCostRecoveryAccount());
}
// Temporarily override the old A21 account as needed when generating the sections.
oldAccount.setA21SubAccount(tempA21Account);
sections = super.getSections(document, oldMaintainable);
oldAccount.setA21SubAccount(oldA21Account);
return sections;
}
}
return super.getSections(document, oldMaintainable);
}
use of org.kuali.kfs.coa.businessobject.A21SubAccount in project cu-kfs by CU-CommunityApps.
the class CuSubAccountRule method checkCgCostSharingRules.
@Override
protected boolean checkCgCostSharingRules() {
boolean success = true;
boolean allFieldsSet = false;
A21SubAccount a21 = newSubAccount.getA21SubAccount();
// check to see if all required fields are set
if (StringUtils.isNotEmpty(a21.getCostShareChartOfAccountCode()) && StringUtils.isNotEmpty(a21.getCostShareSourceAccountNumber())) {
allFieldsSet = true;
}
// Cost Sharing COA Code and Cost Sharing Account Number are required
success &= checkEmptyBOField("a21SubAccount.costShareChartOfAccountCode", a21.getCostShareChartOfAccountCode(), "Cost Share Chart of Accounts Code");
success &= checkEmptyBOField("a21SubAccount.costShareSourceAccountNumber", a21.getCostShareSourceAccountNumber(), "Cost Share AccountNumber");
// existence test on Cost Share Account
if (allFieldsSet) {
if (ObjectUtils.isNull(a21.getCostShareAccount())) {
putFieldError("a21SubAccount.costShareSourceAccountNumber", KFSKeyConstants.ERROR_EXISTENCE, getDisplayName("a21SubAccount.costShareSourceAccountNumber"));
success &= false;
}
}
// existence test on Cost Share SubAccount
if (allFieldsSet && StringUtils.isNotBlank(a21.getCostShareSourceSubAccountNumber())) {
if (ObjectUtils.isNull(a21.getCostShareSourceSubAccount())) {
putFieldError("a21SubAccount.costShareSourceSubAccountNumber", KFSKeyConstants.ERROR_EXISTENCE, getDisplayName("a21SubAccount.costShareSourceSubAccountNumber"));
success &= false;
}
}
return success;
}
use of org.kuali.kfs.coa.businessobject.A21SubAccount 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;
}
Aggregations