use of org.kuali.kfs.coa.businessobject.IndirectCostRecoveryAccount in project cu-kfs by CU-CommunityApps.
the class CuSubAccountPreRules method copyICRFromAccount.
@SuppressWarnings("deprecation")
protected void copyICRFromAccount(MaintenanceDocument document) {
Person user = GlobalVariables.getUserSession().getPerson();
// get a new instance of MaintenanceDocumentAuthorizations for this context
MaintenanceDocumentRestrictions auths = SpringContext.getBean(BusinessObjectAuthorizationService.class).getMaintenanceDocumentRestrictions(document, user);
// don't need to copy if the user does not have the authority to edit the fields
if (!auths.getFieldRestriction("a21SubAccount.financialIcrSeriesIdentifier").isReadOnly()) {
// only need to do this of the account sub type is EX
A21SubAccount a21SubAccount = newSubAccount.getA21SubAccount();
Account account = newSubAccount.getAccount();
if (KFSConstants.SubAccountType.EXPENSE.equals(a21SubAccount.getSubAccountTypeCode())) {
if (ObjectUtils.isNull(account) || StringUtils.isBlank(account.getAccountNumber())) {
account = getAccountService().getByPrimaryId(newSubAccount.getChartOfAccountsCode(), newSubAccount.getAccountNumber());
}
if (ObjectUtils.isNotNull(account)) {
if (a21SubAccount.getA21ActiveIndirectCostRecoveryAccounts().isEmpty()) {
for (IndirectCostRecoveryAccount icrAccount : account.getActiveIndirectCostRecoveryAccounts()) {
A21IndirectCostRecoveryAccount copyAccount = A21IndirectCostRecoveryAccount.copyICRAccount(icrAccount);
copyAccount.setNewCollectionRecord(true);
a21SubAccount.getA21IndirectCostRecoveryAccounts().add(copyAccount);
}
}
if (StringUtils.isBlank(a21SubAccount.getFinancialIcrSeriesIdentifier())) {
a21SubAccount.setFinancialIcrSeriesIdentifier(account.getFinancialIcrSeriesIdentifier());
}
if (StringUtils.isBlank(a21SubAccount.getIndirectCostRecoveryTypeCode())) {
a21SubAccount.setIndirectCostRecoveryTypeCode(account.getAcctIndirectCostRcvyTypeCd());
}
}
}
}
}
use of org.kuali.kfs.coa.businessobject.IndirectCostRecoveryAccount in project cu-kfs by CU-CommunityApps.
the class GlobalIndirectCostRecoveryAccountsRule method buildCurrentActiveICRAccountsAfterICRUpdates.
protected List<IndirectCostRecoveryAccount> buildCurrentActiveICRAccountsAfterICRUpdates(List<IndirectCostRecoveryAccountChange> icrUpdates, List<IndirectCostRecoveryAccount> existingIcrAccounts, GlobalBusinessObjectDetailBase globalDetail, GlobalObjectWithIndirectCostRecoveryAccounts globalObjectWithIndirectCostRecoveryAccounts) {
List<IndirectCostRecoveryAccount> currentActiveIndirectCostRecoveryAccountList = new ArrayList<IndirectCostRecoveryAccount>();
List<IndirectCostRecoveryAccount> existingICRsToBeUpdated = new ArrayList<IndirectCostRecoveryAccount>();
List<IndirectCostRecoveryAccount> icrAccountsNotUpdated = new ArrayList<IndirectCostRecoveryAccount>();
for (IndirectCostRecoveryAccount icrAccount : existingIcrAccounts) {
icrAccountsNotUpdated.add(icrAccount);
}
List<IndirectCostRecoveryAccount> icrAccountsToBeUpdatedToActive = new ArrayList<IndirectCostRecoveryAccount>();
List<IndirectCostRecoveryAccount> icrAccountsToBeAddedAsActive = new ArrayList<IndirectCostRecoveryAccount>();
if (icrUpdates.size() > 0) {
// for each new icr on account global doc search for a matching icr on account to be updated
for (IndirectCostRecoveryAccountChange newICR : icrUpdates) {
boolean foundMatch = false;
existingICRsToBeUpdated.clear();
for (IndirectCostRecoveryAccount icrAccount : icrAccountsNotUpdated) {
existingICRsToBeUpdated.add(icrAccount);
}
IndirectCostRecoveryAccount matchingICRAccountWithSameActiveIndicator = null;
int currentPosition = 0;
int maxPosition = existingICRsToBeUpdated.size();
while (noMatchFoundOrSameActiveIndicatorMatchFoundAndStillHaveICRAccountsToCheck(currentPosition, maxPosition, foundMatch, matchingICRAccountWithSameActiveIndicator)) {
IndirectCostRecoveryAccount existingICR = existingICRsToBeUpdated.get(currentPosition);
if (newICR.matchesICRAccount(existingICR)) {
foundMatch = true;
if (newICR.isActive() == existingICR.isActive()) {
// both have the same active indicator, save in
// a temp and keep looking
matchingICRAccountWithSameActiveIndicator = existingICR;
} else {
// done stop looking
if (newICR.isActive()) {
// add to update active
IndirectCostRecoveryAccount icrAccount = globalObjectWithIndirectCostRecoveryAccounts.createIndirectCostRecoveryAccountFromChange(globalDetail, newICR);
icrAccountsToBeUpdatedToActive.add(icrAccount);
}
icrAccountsNotUpdated.remove(existingICR);
if (ObjectUtils.isNotNull(matchingICRAccountWithSameActiveIndicator)) {
matchingICRAccountWithSameActiveIndicator = null;
}
}
}
currentPosition++;
}
if (foundMatch && ObjectUtils.isNotNull(matchingICRAccountWithSameActiveIndicator)) {
// done stop looking
if (matchingICRAccountWithSameActiveIndicator.isActive()) {
// add to update active
IndirectCostRecoveryAccount icrAccount = globalObjectWithIndirectCostRecoveryAccounts.createIndirectCostRecoveryAccountFromChange(globalDetail, newICR);
icrAccountsToBeUpdatedToActive.add(icrAccount);
}
icrAccountsNotUpdated.remove(matchingICRAccountWithSameActiveIndicator);
}
if (!foundMatch) {
// done stop looking
if (newICR.isActive()) {
// add to update active
IndirectCostRecoveryAccount icrAccount = globalObjectWithIndirectCostRecoveryAccounts.createIndirectCostRecoveryAccountFromChange(globalDetail, newICR);
icrAccountsToBeAddedAsActive.add(icrAccount);
}
}
}
if (icrAccountsToBeUpdatedToActive.size() > 0) {
for (IndirectCostRecoveryAccount icrAccount : icrAccountsToBeUpdatedToActive) {
currentActiveIndirectCostRecoveryAccountList.add(icrAccount);
}
}
if (icrAccountsToBeAddedAsActive.size() > 0) {
for (IndirectCostRecoveryAccount icrAccount : icrAccountsToBeAddedAsActive) {
currentActiveIndirectCostRecoveryAccountList.add(icrAccount);
}
}
if (ObjectUtils.isNotNull(icrAccountsNotUpdated) && !icrAccountsNotUpdated.isEmpty()) {
for (IndirectCostRecoveryAccount icrAccount : icrAccountsNotUpdated) {
if (icrAccount.isActive()) {
currentActiveIndirectCostRecoveryAccountList.add(icrAccount);
}
}
}
}
return currentActiveIndirectCostRecoveryAccountList;
}
use of org.kuali.kfs.coa.businessobject.IndirectCostRecoveryAccount in project cu-kfs by CU-CommunityApps.
the class GlobalIndirectCostRecoveryAccountsRule method computeTotalDistribution.
protected BigDecimal computeTotalDistribution(List<IndirectCostRecoveryAccount> currentActiveIndirectCostRecoveryAccountList) {
LOG.info("Enter computeTotalDistribution");
BigDecimal totalDistribution = BigDecimal.ZERO;
if (ObjectUtils.isNotNull(currentActiveIndirectCostRecoveryAccountList) && (currentActiveIndirectCostRecoveryAccountList.size() > 0)) {
for (IndirectCostRecoveryAccount icra : currentActiveIndirectCostRecoveryAccountList) {
totalDistribution = totalDistribution.add(icra.getAccountLinePercent());
LOG.info("ICR account " + icra.getIndirectCostRecoveryFinCoaCode() + "-" + icra.getIndirectCostRecoveryAccountNumber() + " line percent: " + icra.getAccountLinePercent() + " active " + icra.isActive());
}
}
return totalDistribution;
}
use of org.kuali.kfs.coa.businessobject.IndirectCostRecoveryAccount 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.IndirectCostRecoveryAccount in project cu-kfs by CU-CommunityApps.
the class SubAccountGlobal method updateGlobalDetailICRAccountCollection.
@Override
public void updateGlobalDetailICRAccountCollection(GlobalBusinessObjectDetailBase globalDetail, List<IndirectCostRecoveryAccount> updatedIcrAccounts) {
SubAccountGlobalDetail subAccountGlobalDetail = (SubAccountGlobalDetail) globalDetail;
List<A21IndirectCostRecoveryAccount> updatedA21IcrAccounts = new ArrayList<A21IndirectCostRecoveryAccount>();
for (IndirectCostRecoveryAccount icrAccount : updatedIcrAccounts) {
updatedA21IcrAccounts.add(A21IndirectCostRecoveryAccount.copyICRAccount(icrAccount));
}
subAccountGlobalDetail.getSubAccount().getA21SubAccount().setA21IndirectCostRecoveryAccounts(updatedA21IcrAccounts);
}
Aggregations