use of org.kuali.kfs.coa.businessobject.SubAccount in project cu-kfs by CU-CommunityApps.
the class CuSubAccountMaintainableImpl method isSubAccountTypeCodeCostShare.
// KFSPTS-1740 added
/**
* Answers true for the following conditions:
* a) New or Copy of SubAccount with a CS SubAccount type enforce route to Award split-node.
* b) Any Edit of an existing SubAccount type code to change it from-or-to a cost share enforces
* split-node route to Award (i.e. old=EX to new=CS OR old=CS to new=EX OR old=CS to new=CS).
*
* @return true when code is CS for old or new value; otherwise return false
*/
private boolean isSubAccountTypeCodeCostShare() {
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.COST_SHARE)) {
// retrieve data we need for split-node route to work, contractsAndGrantsAccountResponsibilityId is
// not a sub-account attribute and we must populate the account attribute on sub-account
subAccount.setAccount(getAccountService().getByPrimaryIdWithCaching(subAccount.getChartOfAccountsCode(), subAccount.getAccountNumber()));
retval = true;
}
} else if (maintAction.equalsIgnoreCase(KRADConstants.MAINTENANCE_EDIT_ACTION)) {
// need "new" bo for data comparisons
SubAccount subAccount = (SubAccount) super.getBusinessObject();
// need "old" bo for data comparisons
A21SubAccount oldSubAccount = this.getA21SubAccountService().getByPrimaryKey(subAccount.getChartOfAccountsCode(), subAccount.getAccountNumber(), subAccount.getSubAccountNumber());
if ((subAccount.getA21SubAccount().getSubAccountTypeCode().equals(KFSConstants.SubAccountType.COST_SHARE)) || (oldSubAccount.getSubAccountTypeCode().equals(KFSConstants.SubAccountType.COST_SHARE))) {
// retrieve data we need for split-node route to work, contractsAndGrantsAccountResponsibilityId is
// not a sub-account attribute and we must populate the account attribute on sub-account
subAccount.setAccount(getAccountService().getByPrimaryIdWithCaching(subAccount.getChartOfAccountsCode(), subAccount.getAccountNumber()));
retval = true;
}
}
return retval;
}
use of org.kuali.kfs.coa.businessobject.SubAccount in project cu-kfs by CU-CommunityApps.
the class SubAccountGlobalMaintainableImpl method isSubAccountTypeCodeCostShare.
/**
* @return true when code is CS; otherwise return false
*/
private boolean isSubAccountTypeCodeCostShare() {
boolean retval = false;
SubAccountGlobal subAccountGlobal = (SubAccountGlobal) getBusinessObject();
for (SubAccountGlobalDetail detail : subAccountGlobal.getSubAccountGlobalDetails()) {
detail.refreshReferenceObject(KFSPropertyConstants.SUB_ACCOUNT);
SubAccount subAccount = detail.getSubAccount();
if (subAccount.getA21SubAccount().getSubAccountTypeCode().equals(KFSConstants.SubAccountType.COST_SHARE)) {
retval = true;
subAccount.refreshReferenceObject(KFSPropertyConstants.ACCOUNT);
break;
}
}
return retval;
}
use of org.kuali.kfs.coa.businessobject.SubAccount in project cu-kfs by CU-CommunityApps.
the class SubAccountGlobalRule method checkCgRules.
/**
* Checks to make sure that if cgAuthorized is false it succeeds immediately, otherwise it checks that all the information
* for CG is correctly entered and identified including:
* <ul>
* <li>If the {@link SubFundGroup} isn't for Contracts and Grants then check to make sure that the cost share and ICR fields are
* not empty</li>
* <li>If it isn't a child of CG, then the SubAccount must be of type ICR</li>
* </ul>
*
* @param document
* @return true if the user is not authorized to change CG fields, otherwise it checks the above conditions
*/
protected boolean checkCgRules(SubAccountGlobal newSubAccountGlobal, SubAccountGlobalDetail subAccountGlobalDetail) {
boolean success = true;
// short circuit if the parent account is NOT part of a CG fund group
boolean a21SubAccountRefreshed = false;
subAccountGlobalDetail.refreshReferenceObject(KFSPropertyConstants.ACCOUNT);
if (ObjectUtils.isNotNull(subAccountGlobalDetail.getAccount())) {
Account account = subAccountGlobalDetail.getAccount();
account.refreshReferenceObject(KFSPropertyConstants.SUB_FUND_GROUP);
if (ObjectUtils.isNotNull(account.getSubFundGroup())) {
// compare them, exit if the account isn't for contracts and grants
if (!getSubFundGroupService().isForContractsAndGrants(account.getSubFundGroup())) {
if (checkCgCostSharingIsEmpty(subAccountGlobalDetail) == false) {
putFieldError(KFSPropertyConstants.A21_SUB_ACCOUNT + "." + KFSPropertyConstants.COST_SHARE_SOURCE_CHART_OF_ACCOUNTS_CODE, KFSKeyConstants.ERROR_DOCUMENT_SUBACCTMAINT_NON_FUNDED_ACCT_CS_INVALID, new String[] { getSubFundGroupService().getContractsAndGrantsDenotingAttributeLabel(), getSubFundGroupService().getContractsAndGrantsDenotingValueForMessage() });
success = false;
}
if (checkCgIcrIsEmpty() == false) {
putFieldError(KFSPropertyConstants.A21_SUB_ACCOUNT + "." + KFSPropertyConstants.INDIRECT_COST_RECOVERY_TYPE_CODE, KFSKeyConstants.ERROR_DOCUMENT_SUBACCTMAINT_NON_FUNDED_ACCT_ICR_INVALID, new String[] { getSubFundGroupService().getContractsAndGrantsDenotingAttributeLabel(), getSubFundGroupService().getContractsAndGrantsDenotingValueForMessage() });
success = false;
}
if (newSubAccountGlobal.getIndirectCostRecoveryAccounts().isEmpty() == false) {
putFieldError(KFSPropertyConstants.INDIRECT_COST_RECOVERY_ACCOUNTS, KFSKeyConstants.ERROR_DOCUMENT_SUBACCTMAINT_NON_FUNDED_ACCT_ICR_INVALID, new String[] { getSubFundGroupService().getContractsAndGrantsDenotingAttributeLabel(), getSubFundGroupService().getContractsAndGrantsDenotingValueForMessage() });
success = false;
}
return success;
}
}
}
subAccountGlobalDetail.refreshReferenceObject(KFSPropertyConstants.SUB_ACCOUNT);
if (ObjectUtils.isNull(subAccountGlobalDetail.getSubAccount())) {
return success;
}
SubAccount subAccount = subAccountGlobalDetail.getSubAccount();
subAccount.refreshReferenceObject(KFSPropertyConstants.A21_SUB_ACCOUNT);
A21SubAccount a21 = subAccount.getA21SubAccount();
// short circuit if there is no A21SubAccount object at all (ie, null)
if (ObjectUtils.isNull(a21)) {
return success;
}
if (!a21SubAccountRefreshed) {
// preserve the ICRAccounts before refresh to prevent the list from dropping
List<A21IndirectCostRecoveryAccount> icrAccounts = a21.getA21IndirectCostRecoveryAccounts();
a21.refresh();
a21.setA21IndirectCostRecoveryAccounts(icrAccounts);
}
// get a convenience reference to this code
String cgA21TypeCode = a21.getSubAccountTypeCode();
// if this is a Cost Sharing SubAccount, run the Cost Sharing rules
if (KFSConstants.SubAccountType.COST_SHARE.trim().equalsIgnoreCase(StringUtils.trim(cgA21TypeCode))) {
success &= checkCgCostSharingRules(cgA21TypeCode);
}
// if this is an ICR subaccount, run the ICR rules
if (KFSConstants.SubAccountType.EXPENSE.trim().equals(StringUtils.trim(cgA21TypeCode))) {
success &= checkCgIcrRules(cgA21TypeCode, subAccountGlobalDetail);
}
return success;
}
use of org.kuali.kfs.coa.businessobject.SubAccount in project cu-kfs by CU-CommunityApps.
the class SubAccountGlobal method generateGlobalChangesToPersist.
/**
* @see org.kuali.kfs.krad.bo.GlobalBusinessObject#generateGlobalChangesToPersist()
*/
@Override
public List<PersistableBusinessObject> generateGlobalChangesToPersist() {
List<PersistableBusinessObject> changesToPersist = new ArrayList<PersistableBusinessObject>();
this.refreshReferenceObject(KFSPropertyConstants.A21_SUB_ACCOUNT);
for (SubAccountGlobalDetail subAccountGlobalDetail : subAccountGlobalDetails) {
subAccountGlobalDetail.refreshReferenceObject(KFSPropertyConstants.SUB_ACCOUNT);
SubAccount subAccount = subAccountGlobalDetail.getSubAccount();
if (inactivate) {
subAccount.setActive(false);
}
if (StringUtils.isNotBlank(subAccountName)) {
subAccount.setSubAccountName(subAccountName);
}
if (a21SubAccount.offCampusCode) {
subAccount.getA21SubAccount().setOffCampusCode(true);
}
if (StringUtils.isNotBlank(financialReportChartCode)) {
subAccount.setFinancialReportChartCode(financialReportChartCode);
}
if (StringUtils.isNotBlank(finReportOrganizationCode)) {
subAccount.setFinReportOrganizationCode(finReportOrganizationCode);
}
if (StringUtils.isNotBlank(financialReportingCode)) {
subAccount.setFinancialReportingCode(financialReportingCode);
}
if (StringUtils.isNotBlank(a21SubAccount.indirectCostRecoveryTypeCode)) {
subAccount.getA21SubAccount().setIndirectCostRecoveryTypeCode(a21SubAccount.indirectCostRecoveryTypeCode);
}
if (StringUtils.isNotBlank(a21SubAccount.financialIcrSeriesIdentifier)) {
subAccount.getA21SubAccount().setFinancialIcrSeriesIdentifier(a21SubAccount.financialIcrSeriesIdentifier);
}
if (StringUtils.isNotBlank(a21SubAccount.costShareChartOfAccountCode)) {
subAccount.getA21SubAccount().setCostShareChartOfAccountCode(a21SubAccount.costShareChartOfAccountCode);
}
if (StringUtils.isNotBlank(a21SubAccount.costShareSourceAccountNumber)) {
subAccount.getA21SubAccount().setCostShareSourceAccountNumber(a21SubAccount.costShareSourceAccountNumber);
}
if (StringUtils.isNotBlank(a21SubAccount.costShareSourceSubAccountNumber)) {
subAccount.getA21SubAccount().setCostShareSourceSubAccountNumber(a21SubAccount.costShareSourceSubAccountNumber);
}
List<IndirectCostRecoveryAccount> icrAccounts = new ArrayList<IndirectCostRecoveryAccount>();
for (IndirectCostRecoveryAccount icrAccount : subAccountGlobalDetail.getSubAccount().getA21SubAccount().getA21IndirectCostRecoveryAccounts()) {
icrAccounts.add(icrAccount);
}
updateIcrAccounts(subAccountGlobalDetail, icrAccounts);
changesToPersist.add(subAccount);
}
return changesToPersist;
}
use of org.kuali.kfs.coa.businessobject.SubAccount in project cu-kfs by CU-CommunityApps.
the class MockSubAccountService method getByPrimaryId.
@Override
public SubAccount getByPrimaryId(String chartOfAccountsCode, String accountNumber, String subAccountNumber) {
SubAccount subAccount = null;
if (ConcurAccountValidationTestConstants.VALID_CHART.equalsIgnoreCase(chartOfAccountsCode) && ConcurAccountValidationTestConstants.VALID_ACCT_NBR.equalsIgnoreCase(accountNumber) && ConcurAccountValidationTestConstants.VALID_SUB_ACCT.equalsIgnoreCase(subAccountNumber)) {
subAccount = createSubAccount(chartOfAccountsCode, accountNumber, subAccountNumber);
subAccount.setActive(true);
}
if (ConcurAccountValidationTestConstants.VALID_CHART.equalsIgnoreCase(chartOfAccountsCode) && ConcurAccountValidationTestConstants.VALID_ACCT_NBR.equalsIgnoreCase(accountNumber) && ConcurAccountValidationTestConstants.INACTIVE_SUB_ACCT.equalsIgnoreCase(subAccountNumber)) {
subAccount = createSubAccount(chartOfAccountsCode, accountNumber, subAccountNumber);
subAccount.setActive(false);
}
return subAccount;
}
Aggregations