use of edu.cornell.kfs.coa.businessobject.AppropriationAccount in project cu-kfs by CU-CommunityApps.
the class CUAccountMaintainableImpl method saveBusinessObject.
@Override
public void saveBusinessObject() {
boolean isClosingAccount = isClosingAccount();
Account account = (Account) getBusinessObject();
AccountExtendedAttribute aea = (AccountExtendedAttribute) (account.getExtension());
BusinessObjectService bos = SpringContext.getBean(BusinessObjectService.class);
HashMap<String, String> keys = new HashMap<String, String>();
keys.put("programCode", aea.getProgramCode());
keys.put(SUB_FUND_GROUP_CODE, aea.getSubFundGroupCode());
SubFundProgram sfp = (SubFundProgram) bos.findByPrimaryKey(SubFundProgram.class, keys);
aea.setSubFundProgram(sfp);
aea.setSubFundGroupCode(account.getSubFundGroupCode());
keys = new HashMap<String, String>();
keys.put("appropriationAccountNumber", aea.getAppropriationAccountNumber());
keys.put(SUB_FUND_GROUP_CODE, aea.getSubFundGroupCode());
AppropriationAccount aan = (AppropriationAccount) bos.findByPrimaryKey(AppropriationAccount.class, keys);
aea.setAppropriationAccount(aan);
if (account.isClosed() && aea.getAccountClosedDate() == null) {
aea.setAccountClosedDate(SpringContext.getBean(DateTimeService.class).getCurrentSqlDate());
} else if (!account.isClosed() && aea.getAccountClosedDate() != null) {
aea.setAccountClosedDate(null);
}
super.saveBusinessObject();
// trickle down Account Reversion inactivation
if (isClosingAccount) {
SpringContext.getBean(AccountReversionTrickleDownInactivationService.class).trickleDownInactivateAccountReversions((Account) getBusinessObject(), getDocumentNumber());
}
// content and will display any future notes on account edits as well
try {
Document document = SpringContext.getBean(DocumentService.class).getByDocumentHeaderId(getDocumentNumber());
Account xmlaccount = (Account) ((MaintenanceDocument) document).getNewMaintainableObject().getBusinessObject();
if (ObjectUtils.isNull(xmlaccount.getObjectId()) && (KFSConstants.MAINTENANCE_NEW_ACTION.equals(getMaintenanceAction()) || KFSConstants.MAINTENANCE_COPY_ACTION.equals(getMaintenanceAction()))) {
((MaintenanceDocument) document).getNewMaintainableObject().setBusinessObject(account);
SpringContext.getBean(DocumentService.class).saveDocument(document);
}
} catch (Exception e) {
LOG.error("Account doc not saved successfully " + e.getMessage());
}
}
use of edu.cornell.kfs.coa.businessobject.AppropriationAccount in project cu-kfs by CU-CommunityApps.
the class AccountGlobalRule method checkAccountExtensionApprAcct.
private boolean checkAccountExtensionApprAcct(Account account, String subFundGroupCode, String appropriationAccountNumber) {
boolean success = true;
if (StringUtils.isBlank(subFundGroupCode)) {
if (StringUtils.isNotBlank(appropriationAccountNumber)) {
AppropriationAccount appropriationAcct = getMatchedRecord(AppropriationAccount.class, account.getSubFundGroupCode(), CUKFSPropertyConstants.APPROPRIATION_ACCT_NUMBER, appropriationAccountNumber);
if (appropriationAcct == null) {
success = false;
GlobalVariables.getMessageMap().putError(KFSPropertyConstants.ACCOUNT_NUMBER, CUKFSKeyConstants.ERROR_DOCUMENT_ACCMAINT_ACCT_APPROP_ACCT_NOT_GROUP_CODE, new String[] { appropriationAccountNumber, account.getSubFundGroupCode(), account.getAccountNumber() });
} else {
if (!appropriationAcct.isActive()) {
putFieldError(CUKFSPropertyConstants.APPROPRIATION_ACCT_NUMBER, KFSKeyConstants.ERROR_INACTIVE, getFieldLabel(AccountGlobal.class, CUKFSPropertyConstants.APPROPRIATION_ACCT_NUMBER));
success = false;
}
}
}
} else {
AccountExtendedAttribute accountExtension = (AccountExtendedAttribute) account.getExtension();
if (StringUtils.isBlank(appropriationAccountNumber)) {
if (StringUtils.isNotBlank(accountExtension.getAppropriationAccountNumber())) {
AppropriationAccount appropriationAcct = getMatchedRecord(AppropriationAccount.class, subFundGroupCode, CUKFSPropertyConstants.APPROPRIATION_ACCT_NUMBER, accountExtension.getAppropriationAccountNumber());
if (appropriationAcct == null) {
success = false;
GlobalVariables.getMessageMap().putError(KFSPropertyConstants.ACCOUNT_NUMBER, CUKFSKeyConstants.ERROR_DOCUMENT_ACCMAINT_ACCT_APPROP_ACCT_NOT_GROUP_CODE, new String[] { accountExtension.getAppropriationAccountNumber(), subFundGroupCode, account.getAccountNumber() });
}
}
}
}
return success;
}
use of edu.cornell.kfs.coa.businessobject.AppropriationAccount in project cu-kfs by CU-CommunityApps.
the class AccountExtensionRule method checkAppropriationAccount.
protected boolean checkAppropriationAccount(MaintenanceDocument document) {
boolean success = true;
String subFundGroupCode = newAccount.getSubFundGroupCode();
String appropriationAccountNumber = ((AccountExtendedAttribute) newAccount.getExtension()).getAppropriationAccountNumber();
BusinessObjectService bos = SpringContext.getBean(BusinessObjectService.class);
if (!StringUtils.isBlank(appropriationAccountNumber)) {
Map fieldValues = new HashMap();
fieldValues.put("subFundGroupCode", subFundGroupCode);
fieldValues.put("appropriationAccountNumber", appropriationAccountNumber);
Collection<AppropriationAccount> retVals = bos.findMatching(AppropriationAccount.class, fieldValues);
if (retVals.isEmpty()) {
success = false;
putFieldError("extension.appropriationAccountNumber", CUKFSKeyConstants.ERROR_DOCUMENT_ACCMAINT_APPROP_ACCT_NOT_GROUP_CODE, new String[] { appropriationAccountNumber, subFundGroupCode });
} else {
for (AppropriationAccount sfp : retVals) {
if (!sfp.isActive()) {
putFieldError("extension.appropriationAccountNumber", KFSKeyConstants.ERROR_INACTIVE, getFieldLabel(Account.class, "extension.appropriationAccountNumber"));
success = false;
}
}
}
}
return success;
}
use of edu.cornell.kfs.coa.businessobject.AppropriationAccount in project cu-kfs by CU-CommunityApps.
the class AccountGlobalRule method checkAppropriationAccount.
protected boolean checkAppropriationAccount(MaintenanceDocument document) {
boolean success = true;
String subFundGroupCode = newAccountGlobal.getSubFundGroupCode();
String appropriationAccountNumber = newAccountGlobal.getAppropriationAccountNumber();
BusinessObjectService businessObjectService = SpringContext.getBean(BusinessObjectService.class);
if (StringUtils.isNotBlank(appropriationAccountNumber) && StringUtils.isNotBlank(subFundGroupCode)) {
Map<String, String> fieldValues = new HashMap<String, String>();
fieldValues.put(KFSPropertyConstants.SUB_FUND_GROUP_CODE, subFundGroupCode);
fieldValues.put(CUKFSPropertyConstants.APPROPRIATION_ACCT_NUMBER, appropriationAccountNumber);
Collection<AppropriationAccount> retVals = businessObjectService.findMatching(AppropriationAccount.class, fieldValues);
if (retVals.isEmpty()) {
success = false;
putFieldError(CUKFSPropertyConstants.APPROPRIATION_ACCT_NUMBER, CUKFSKeyConstants.ERROR_DOCUMENT_ACCMAINT_APPROP_ACCT_NOT_GROUP_CODE, new String[] { appropriationAccountNumber, subFundGroupCode });
} else {
for (AppropriationAccount appropriationAccount : retVals) {
if (!appropriationAccount.isActive()) {
putFieldError(CUKFSPropertyConstants.APPROPRIATION_ACCT_NUMBER, KFSKeyConstants.ERROR_INACTIVE, getFieldLabel(AccountGlobal.class, CUKFSPropertyConstants.APPROPRIATION_ACCT_NUMBER));
success = false;
break;
}
}
}
}
return success;
}
Aggregations