1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.coa.document.validation.impl;
17
18 import java.sql.Date;
19 import java.sql.Timestamp;
20 import java.util.Calendar;
21 import java.util.Collection;
22 import java.util.HashMap;
23 import java.util.Map;
24
25 import org.apache.commons.lang.StringUtils;
26 import org.apache.commons.lang.time.DateUtils;
27 import org.kuali.ole.coa.businessobject.Account;
28 import org.kuali.ole.coa.businessobject.AccountDescription;
29 import org.kuali.ole.coa.businessobject.AccountGuideline;
30 import org.kuali.ole.coa.businessobject.FundGroup;
31 import org.kuali.ole.coa.businessobject.IndirectCostRecoveryAccount;
32 import org.kuali.ole.coa.businessobject.IndirectCostRecoveryRateDetail;
33 import org.kuali.ole.coa.businessobject.SubFundGroup;
34 import org.kuali.ole.coa.service.AccountService;
35 import org.kuali.ole.coa.service.SubFundGroupService;
36 import org.kuali.ole.gl.service.BalanceService;
37 import org.kuali.ole.gl.service.EncumbranceService;
38 import org.kuali.ole.integration.cg.ContractsAndGrantsModuleService;
39 import org.kuali.ole.select.OleSelectConstant;
40 import org.kuali.ole.sys.OLEConstants;
41 import org.kuali.ole.sys.OLEKeyConstants;
42 import org.kuali.ole.sys.OLEPropertyConstants;
43 import org.kuali.ole.sys.businessobject.Building;
44 import org.kuali.ole.sys.context.SpringContext;
45 import org.kuali.ole.sys.service.GeneralLedgerPendingEntryService;
46 import org.kuali.ole.sys.service.UniversityDateService;
47 import org.kuali.rice.core.api.datetime.DateTimeService;
48 import org.kuali.rice.core.api.parameter.ParameterEvaluator;
49 import org.kuali.rice.core.api.parameter.ParameterEvaluatorService;
50 import org.kuali.rice.coreservice.framework.parameter.ParameterService;
51 import org.kuali.rice.kim.api.identity.Person;
52 import org.kuali.rice.kns.document.MaintenanceDocument;
53 import org.kuali.rice.kns.service.DataDictionaryService;
54 import org.kuali.rice.kns.service.DictionaryValidationService;
55 import org.kuali.rice.krad.util.GlobalVariables;
56 import org.kuali.rice.krad.util.MessageMap;
57 import org.kuali.rice.krad.util.ObjectUtils;
58
59
60
61
62 public class AccountRule extends IndirectCostRecoveryAccountsRule {
63
64 protected static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(AccountRule.class);
65
66 protected static final String ACCT_PREFIX_RESTRICTION = "PREFIXES";
67 protected static final String ACCT_CAPITAL_SUBFUNDGROUP = "CAPITAL_SUB_FUND_GROUPS";
68
69 @Deprecated
70 protected static final String RESTRICTED_CD_TEMPORARILY_RESTRICTED = "T";
71
72 protected static SubFundGroupService subFundGroupService;
73 protected static ParameterService parameterService;
74 protected EncumbranceService encumbranceService;
75
76 protected GeneralLedgerPendingEntryService generalLedgerPendingEntryService;
77 protected BalanceService balanceService;
78 protected AccountService accountService;
79
80 protected ContractsAndGrantsModuleService contractsAndGrantsModuleService;
81
82 protected Account oldAccount;
83 protected Account newAccount;
84
85 public AccountRule() {
86
87
88
89
90
91
92
93 this.setGeneralLedgerPendingEntryService(SpringContext.getBean(GeneralLedgerPendingEntryService.class));
94 this.setBalanceService(SpringContext.getBean(BalanceService.class));
95 this.setAccountService(SpringContext.getBean(AccountService.class));
96 this.setContractsAndGrantsModuleService(SpringContext.getBean(ContractsAndGrantsModuleService.class));
97 }
98
99
100
101
102
103
104 @Override
105 public void setupConvenienceObjects() {
106
107
108 oldAccount = (Account) super.getOldBo();
109 refreshSubObjects(oldAccount);
110
111 newAccount = (Account) super.getNewBo();
112 refreshSubObjects(newAccount);
113
114 setActiveIndirectCostRecoveryAccountList(newAccount.getActiveIndirectCostRecoveryAccounts());
115 setBoFieldPath(OLEPropertyConstants.INDIRECT_COST_RECOVERY_ACCOUNTS);
116 }
117
118
119
120
121
122
123
124 protected void refreshSubObjects(Account account) {
125 if(account.getBudgetRecordingLevelCode()==null){
126 account.setBudgetRecordingLevelCode(OleSelectConstant.BUDGET_RECORDING_LEVEL_CODE);
127 }
128 if (account != null) {
129
130 if (account.getIndirectCostRecoveryAccounts() != null) {
131 for (IndirectCostRecoveryAccount icra : account.getIndirectCostRecoveryAccounts()) {
132 icra.refreshNonUpdateableReferences();
133 }
134 }
135 }
136 }
137
138
139
140
141
142
143 @Override
144 protected boolean processCustomSaveDocumentBusinessRules(MaintenanceDocument document) {
145
146 LOG.debug("processCustomSaveDocumentBusinessRules called");
147
148 processCustomRouteDocumentBusinessRules(document);
149
150
151 return true;
152 }
153
154
155
156
157
158
159
160
161 @Override
162 protected boolean processCustomRouteDocumentBusinessRules(MaintenanceDocument document) {
163
164 LOG.debug("processCustomRouteDocumentBusinessRules called");
165 setupConvenienceObjects();
166
167
168 boolean success = true;
169
170
171 success &= checkAccountGuidelinesValidation(newAccount.getAccountGuideline());
172
173 success &= checkEmptyValues(document);
174 success &= checkGeneralRules(document);
175 success &= checkCloseAccount(document);
176 success &= checkContractsAndGrants(document);
177 success &= checkExpirationDate(document);
178 success &= checkFundGroup(document);
179 success &= checkSubFundGroup(document);
180 success &= checkVendorNameForSubFundGroup(document);
181 success &= checkIncomeStreamAccountRule();
182 success &= checkUniqueAccountNumber(document);
183 success &= checkOpenEncumbrances();
184 success &= checkAccountRestrictedStatusDateIsGreaterThanCurrentDate();
185 success &= validateSufficientFundCheckTab();
186
187
188 success &= super.processCustomRouteDocumentBusinessRules(document);
189
190 return success;
191 }
192
193
194
195
196
197
198
199
200
201
202 protected boolean checkEmptyValues(MaintenanceDocument maintenanceDocument) {
203
204 LOG.debug("checkEmptyValues called");
205
206 boolean success = true;
207
208
209
210 boolean guidelinesRequired = areGuidelinesRequired((Account) maintenanceDocument.getNewMaintainableObject().getBusinessObject());
211
212
213 if (guidelinesRequired) {
214 success &= checkEmptyBOField("accountGuideline.accountExpenseGuidelineText", newAccount.getAccountGuideline().getAccountExpenseGuidelineText(), "Expense Guideline");
215
216
217
218 }
219
220
221
222 success &= checkForPartiallyFilledOutReferenceForeignKeys(OLEPropertyConstants.CONTINUATION_ACCOUNT);
223 success &= checkForPartiallyFilledOutReferenceForeignKeys(OLEPropertyConstants.INCOME_STREAM_ACCOUNT);
224 success &= checkForPartiallyFilledOutReferenceForeignKeys(OLEPropertyConstants.ENDOWMENT_INCOME_ACCOUNT);
225 success &= checkForPartiallyFilledOutReferenceForeignKeys(OLEPropertyConstants.REPORTS_TO_ACCOUNT);
226 success &= checkForPartiallyFilledOutReferenceForeignKeys(OLEPropertyConstants.CONTRACT_CONTROL_ACCOUNT);
227
228 return success;
229 }
230
231
232
233
234
235
236
237 protected boolean checkAccountGuidelinesValidation(AccountGuideline accountGuideline) {
238 MessageMap map = GlobalVariables.getMessageMap();
239 int errorCount = map.getErrorCount();
240 GlobalVariables.getMessageMap().addToErrorPath("document.newMaintainableObject.accountGuideline");
241 dictionaryValidationService.validateBusinessObject(accountGuideline, false);
242 GlobalVariables.getMessageMap().removeFromErrorPath("document.newMaintainableObject.accountGuideline");
243 return map.getErrorCount() == errorCount;
244 }
245
246
247
248
249
250
251
252 protected boolean areGuidelinesRequired(Account account) {
253
254 boolean result = true;
255
256 if (account.getAccountExpirationDate() != null) {
257 Timestamp today = getDateTimeService().getCurrentTimestamp();
258 today.setTime(DateUtils.truncate(today, Calendar.DAY_OF_MONTH).getTime());
259 if (account.getAccountExpirationDate().before(today)) {
260 result = false;
261 }
262 }
263 return result;
264 }
265
266
267
268
269
270
271
272
273
274 protected boolean accountNumberStartsWithAllowedPrefix(String accountNumber, Collection<String> illegalValues) {
275 boolean result = true;
276 for (String illegalValue : illegalValues) {
277 if (accountNumber.startsWith(illegalValue)) {
278 result = false;
279 putFieldError("accountNumber", OLEKeyConstants.ERROR_DOCUMENT_ACCMAINT_ACCT_NMBR_NOT_ALLOWED, new String[] { accountNumber, illegalValue });
280 }
281 }
282 return result;
283 }
284
285
286
287
288
289
290
291
292
293
294 protected boolean isNonSystemSupervisorEditingAClosedAccount(MaintenanceDocument document, Person user) {
295 if (document.isEdit()) {
296
297 if (oldAccount.isClosed() ) {
298 return !getDocumentHelperService().getDocumentAuthorizer(document).isAuthorized(document, OLEConstants.PermissionNames.EDIT_INACTIVE_ACCOUNT.namespace, OLEConstants.PermissionNames.EDIT_INACTIVE_ACCOUNT.name, user.getPrincipalId());
299 }
300 return false;
301 }
302 return false;
303 }
304
305
306
307
308
309
310
311
312 protected boolean hasTemporaryRestrictedStatusCodeButNoRestrictedStatusDate(Account account) {
313
314 boolean result = false;
315
316 if (StringUtils.isNotBlank(account.getAccountRestrictedStatusCode())) {
317 if (RESTRICTED_CD_TEMPORARILY_RESTRICTED.equalsIgnoreCase(account.getAccountRestrictedStatusCode().trim())) {
318 if (account.getAccountRestrictedStatusDate() == null) {
319 result = true;
320 }
321 }
322 }
323 return result;
324 }
325
326
327
328
329
330
331
332
333 protected boolean hasTemporaryRestrictedStatusCodeButRestrictedStatusDateisGreaterThanCurrentDate(Account account){
334
335 boolean result = false;
336
337 if(StringUtils.isNotBlank(account.getAccountRestrictedStatusCode())){
338 if(RESTRICTED_CD_TEMPORARILY_RESTRICTED.equalsIgnoreCase(account.getAccountRestrictedStatusCode().trim())){
339 if(account.getAccountRestrictedStatusDate().compareTo(SpringContext.getBean(DateTimeService.class).getCurrentSqlDate())>0){
340 result = true;
341 }
342 }
343 }
344 return result;
345 }
346
347
348
349
350
351
352
353
354 protected boolean hasDefaultRestrictedStatusCode(Account account) {
355 boolean result = false;
356
357 if (StringUtils.isNotBlank(account.getAccountRestrictedStatusCode())) {
358 result = account.getAccountRestrictedStatusCode().equals(account.getSubFundGroup().getAccountRestrictedStatusCode());
359 }
360
361 return result;
362 }
363
364
365
366
367
368
369
370
371
372
373
374 protected boolean checkGeneralRules(MaintenanceDocument maintenanceDocument) {
375
376 LOG.debug("checkGeneralRules called");
377 Person fiscalOfficer = newAccount.getAccountFiscalOfficerUser();
378 Person accountManager = newAccount.getAccountManagerUser();
379 Person accountSupervisor = newAccount.getAccountSupervisoryUser();
380
381 boolean success = true;
382
383
384
385
386 if (!StringUtils.isBlank(newAccount.getAccountNumber())) {
387
388 success &= accountNumberStartsWithAllowedPrefix(newAccount.getAccountNumber(), getParameterService().getParameterValuesAsString(Account.class, ACCT_PREFIX_RESTRICTION));
389 }
390
391 Boolean isFridgeBenefitCalculationEnable = accountService.isFridgeBenefitCalculationEnable();
392
393 if (isFridgeBenefitCalculationEnable){
394
395 if (ObjectUtils.isNull(newAccount.getLaborBenefitRateCategoryCode())) {
396 putFieldError(OLEPropertyConstants.LABOR_BENEFIT_RATE_CATEGORY_CODE, OLEKeyConstants.ERROR_EMPTY_LABOR_BENEFIT_CATEGORY_CODE);
397 success &= false;
398 }
399 }
400
401
402
403 if (isNonSystemSupervisorEditingAClosedAccount(maintenanceDocument, GlobalVariables.getUserSession().getPerson())) {
404 success &= false;
405 putFieldError("closed", OLEKeyConstants.ERROR_DOCUMENT_ACCMAINT_ONLY_SUPERVISORS_CAN_EDIT);
406 }
407
408
409 success &= checkFringeBenefitAccountRule(newAccount);
410
411 if (ObjectUtils.isNotNull(fiscalOfficer) && fiscalOfficer.getPrincipalId() != null && !getDocumentHelperService().getDocumentAuthorizer(maintenanceDocument).isAuthorized(maintenanceDocument, OLEConstants.PermissionNames.SERVE_AS_FISCAL_OFFICER.namespace, OLEConstants.PermissionNames.SERVE_AS_FISCAL_OFFICER.name, fiscalOfficer.getPrincipalId())) {
412 super.putFieldError("accountFiscalOfficerUser.principalName", OLEKeyConstants.ERROR_USER_MISSING_PERMISSION, new String[] {fiscalOfficer.getName(), OLEConstants.PermissionNames.SERVE_AS_FISCAL_OFFICER.namespace, OLEConstants.PermissionNames.SERVE_AS_FISCAL_OFFICER.name});
413 success = false;
414 }
415
416
417
418
419
420
421
422
423
424
425
426 if (isSupervisorSameAsFiscalOfficer(newAccount)) {
427 success &= false;
428 putFieldError("accountsSupervisorySystemsIdentifier", OLEKeyConstants.ERROR_DOCUMENT_ACCMAINT_ACCT_SUPER_CANNOT_BE_FISCAL_OFFICER);
429 }
430 if (isSupervisorSameAsManager(newAccount)) {
431 success &= false;
432 putFieldError("accountManagerSystemIdentifier", OLEKeyConstants.ERROR_DOCUMENT_ACCMAINT_ACCT_SUPER_CANNOT_BE_ACCT_MGR);
433 }
434
435
436 if (ObjectUtils.isNotNull(newAccount.getContinuationFinChrtOfAcctCd()) &&
437 ObjectUtils.isNotNull(newAccount.getAccountNumber())){
438 if (isAccountAndContinuationAccountAreSame(newAccount)){
439 success &= false;
440 putFieldError("continuationAccountNumber", OLEKeyConstants.ERROR_DOCUMENT_ACCMAINT_ACCT_CONT_ACCOUNT_CANNOT_BE_SAME);
441 } else {
442
443 if (isContinuationAccountExpired(newAccount)) {
444 success &= false;
445 putFieldError("continuationAccountNumber", OLEKeyConstants.ERROR_DOCUMENT_ACCMAINT_ACCOUNT_EXPIRED_CONTINUATION);
446 }
447 }
448 }
449 return success;
450 }
451
452
453
454
455
456
457
458 protected boolean isAccountAndContinuationAccountAreSame(Account newAccount) {
459
460 return (newAccount.getChartOfAccountsCode().equals(newAccount.getContinuationFinChrtOfAcctCd()))
461 && (newAccount.getAccountNumber().equals(newAccount.getContinuationAccountNumber()));
462 }
463
464
465
466
467
468
469
470 protected boolean isContinuationAccountExpired(Account newAccount) {
471
472 boolean result = false;
473
474 String chartCode = newAccount.getContinuationFinChrtOfAcctCd();
475 String accountNumber = newAccount.getContinuationAccountNumber();
476
477
478
479 if (StringUtils.isBlank(chartCode) || StringUtils.isBlank(accountNumber)) {
480 return result;
481 }
482
483
484 Account continuation = accountService.getByPrimaryId(chartCode, accountNumber);
485
486
487 if (ObjectUtils.isNull(continuation)) {
488 return result;
489 }
490
491
492
493 result = continuation.isExpired();
494
495 return result;
496 }
497
498
499
500
501
502
503
504
505
506 protected boolean checkFringeBenefitAccountRule(Account newAccount) {
507
508 boolean result = true;
509
510
511
512
513 if (newAccount.isAccountsFringesBnftIndicator()) {
514 return true;
515 }
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557 return true;
558 }
559
560
561
562
563
564
565
566
567 protected boolean isSupervisorSameAsFiscalOfficer(Account account) {
568 return areTwoUsersTheSame(account.getAccountSupervisoryUser(), account.getAccountFiscalOfficerUser());
569 }
570
571
572
573
574
575
576
577
578 protected boolean isSupervisorSameAsManager(Account account) {
579 return areTwoUsersTheSame(account.getAccountSupervisoryUser(), account.getAccountManagerUser());
580 }
581
582
583
584
585
586
587
588
589 protected boolean areTwoUsersTheSame(Person user1, Person user2) {
590 if (ObjectUtils.isNull(user1) || user1.getPrincipalId() == null ) {
591 return false;
592 }
593 if (ObjectUtils.isNull(user2) || user2.getPrincipalId() == null ) {
594 return false;
595 }
596 return user1.getPrincipalId().equals(user2.getPrincipalId());
597 }
598
599
600
601
602
603
604
605
606 protected boolean checkCloseAccount(MaintenanceDocument maintenanceDocument) {
607
608 LOG.debug("checkCloseAccount called");
609
610 boolean success = true;
611 boolean isBeingClosed = false;
612
613
614
615 if (oldAccount.isActive() && !newAccount.isActive()) {
616 isBeingClosed = true;
617 }
618
619 if (!isBeingClosed) {
620 return true;
621 }
622
623
624 success &= checkAccountExpirationDateValidTodayOrEarlier(newAccount);
625
626
627 if (StringUtils.isBlank(newAccount.getContinuationAccountNumber())) {
628 putFieldError("continuationAccountNumber", OLEKeyConstants.ERROR_DOCUMENT_ACCMAINT_ACCT_CLOSE_CONTINUATION_ACCT_REQD);
629 success &= false;
630 }
631 if (StringUtils.isBlank(newAccount.getContinuationFinChrtOfAcctCd())) {
632 putFieldError("continuationFinChrtOfAcctCd", OLEKeyConstants.ERROR_DOCUMENT_ACCMAINT_ACCT_CLOSE_CONTINUATION_ACCT_REQD);
633 success &= false;
634 }
635
636
637 if (generalLedgerPendingEntryService.hasPendingGeneralLedgerEntry(newAccount)) {
638 putGlobalError(OLEKeyConstants.ERROR_DOCUMENT_ACCMAINT_ACCOUNT_CLOSED_PENDING_LEDGER_ENTRIES);
639 success &= false;
640 }
641
642
643 if (!balanceService.beginningBalanceLoaded(newAccount)) {
644 putGlobalError(OLEKeyConstants.ERROR_DOCUMENT_ACCMAINT_ACCOUNT_CLOSED_NO_LOADED_BEGINNING_BALANCE);
645 success &= false;
646 }
647
648
649
650
651
652 if (balanceService.hasAssetLiabilityFundBalanceBalances(newAccount)) {
653 putGlobalError(OLEKeyConstants.ERROR_DOCUMENT_ACCMAINT_ACCOUNT_CLOSED_NO_FUND_BALANCES);
654 success &= false;
655 }
656
657 return success;
658 }
659
660
661
662
663
664
665
666 protected boolean checkAccountExpirationDateValidTodayOrEarlier(Account newAccount) {
667
668
669 Date todaysDate = new Date(getDateTimeService().getCurrentDate().getTime());
670 todaysDate.setTime(DateUtils.truncate(todaysDate, Calendar.DAY_OF_MONTH).getTime());
671
672
673
674 Date expirationDate = newAccount.getAccountExpirationDate();
675 if (ObjectUtils.isNull(expirationDate)) {
676 putFieldError("accountExpirationDate", OLEKeyConstants.ERROR_DOCUMENT_ACCMAINT_ACCT_CANNOT_BE_CLOSED_EXP_DATE_INVALID);
677 return false;
678 }
679
680
681 expirationDate.setTime(DateUtils.truncate(expirationDate, Calendar.DAY_OF_MONTH).getTime());
682 if (expirationDate.after(todaysDate)) {
683 putFieldError("accountExpirationDate", OLEKeyConstants.ERROR_DOCUMENT_ACCMAINT_ACCT_CANNOT_BE_CLOSED_EXP_DATE_INVALID);
684 return false;
685 }
686
687 return true;
688 }
689
690
691
692
693
694
695
696
697 protected boolean checkContractsAndGrants(MaintenanceDocument maintenanceDocument) {
698
699 LOG.debug("checkContractsAndGrants called");
700
701 boolean success = true;
702
703
704 success &= checkCgRequiredFields(newAccount);
705
706
707
708 success &= checkIncomeStreamValid(newAccount);
709
710
711 if (!ObjectUtils.isNull(newAccount)) {
712 final boolean hasValidAccountResponsibility = contractsAndGrantsModuleService.hasValidAccountReponsiblityIdIfNotNull(newAccount);
713 if (!hasValidAccountResponsibility) {
714 success &= hasValidAccountResponsibility;
715 putFieldError("contractsAndGrantsAccountResponsibilityId", OLEKeyConstants.ERROR_DOCUMENT_ACCTMAINT_INVALID_CG_RESPONSIBILITY , new String[] { newAccount.getContractsAndGrantsAccountResponsibilityId().toString(), newAccount.getChartOfAccountsCode(), newAccount.getAccountNumber() });
716 }
717 }
718
719 return success;
720 }
721
722
723
724
725
726
727
728 protected boolean checkIncomeStreamValid(Account newAccount) {
729
730 if (ObjectUtils.isNull(newAccount.getSubFundGroup())) {
731 return true;
732 }
733
734 boolean valid = true;
735
736
737 if (StringUtils.isNotBlank(newAccount.getSubFundGroupCode()) && StringUtils.isNotBlank(newAccount.getSubFundGroup().getFundGroupCode())) {
738 String subFundGroupCode = newAccount.getSubFundGroupCode().trim();
739 String fundGroupCode = newAccount.getSubFundGroup().getFundGroupCode().trim();
740
741 if (SpringContext.getBean(ParameterEvaluatorService.class).getParameterEvaluator(Account.class, OLEConstants.ChartApcParms.INCOME_STREAM_ACCOUNT_REQUIRING_FUND_GROUPS, fundGroupCode).evaluationSucceeds()) {
742 if (SpringContext.getBean(ParameterEvaluatorService.class).getParameterEvaluator(Account.class, OLEConstants.ChartApcParms.INCOME_STREAM_ACCOUNT_REQUIRING_SUB_FUND_GROUPS, subFundGroupCode).evaluationSucceeds()) {
743 if (StringUtils.isBlank(newAccount.getIncomeStreamFinancialCoaCode())) {
744 putFieldError(OLEPropertyConstants.INCOME_STREAM_CHART_OF_ACCOUNTS_CODE, OLEKeyConstants.ERROR_DOCUMENT_ACCMAINT_INCOME_STREAM_ACCT_COA_CANNOT_BE_EMPTY, new String[] { getDdService().getAttributeLabel(FundGroup.class, OLEConstants.FUND_GROUP_CODE_PROPERTY_NAME), fundGroupCode, getDdService().getAttributeLabel(SubFundGroup.class, OLEConstants.SUB_FUND_GROUP_CODE_PROPERTY_NAME), subFundGroupCode });
745 valid = false;
746 }
747 if (StringUtils.isBlank(newAccount.getIncomeStreamAccountNumber())) {
748 putFieldError(OLEPropertyConstants.INCOME_STREAM_ACCOUNT_NUMBER, OLEKeyConstants.ERROR_DOCUMENT_ACCMAINT_INCOME_STREAM_ACCT_NBR_CANNOT_BE_EMPTY, new String[] { getDdService().getAttributeLabel(FundGroup.class, OLEConstants.FUND_GROUP_CODE_PROPERTY_NAME), fundGroupCode, getDdService().getAttributeLabel(SubFundGroup.class, OLEConstants.SUB_FUND_GROUP_CODE_PROPERTY_NAME), subFundGroupCode});
749 valid = false;
750 }
751 }
752 }
753
754 if (valid && (StringUtils.isNotBlank(newAccount.getIncomeStreamFinancialCoaCode()) || StringUtils.isNotBlank(newAccount.getIncomeStreamAccountNumber()))) {
755 if(!(StringUtils.equals( newAccount.getIncomeStreamAccountNumber(), newAccount.getAccountNumber())
756 && StringUtils.equals( newAccount.getIncomeStreamFinancialCoaCode(), newAccount.getChartOfAccountsCode()))) {
757 if (!super.getDictionaryValidationService().validateReferenceExists(newAccount, OLEPropertyConstants.INCOME_STREAM_ACCOUNT)) {
758 putFieldError(OLEPropertyConstants.INCOME_STREAM_ACCOUNT_NUMBER, OLEKeyConstants.ERROR_EXISTENCE, new StringBuffer(getDdService().getAttributeLabel(SubFundGroup.class, OLEPropertyConstants.INCOME_STREAM_ACCOUNT_NUMBER)).append(": ").append(newAccount.getIncomeStreamFinancialCoaCode()).append("-").append(newAccount.getIncomeStreamAccountNumber()).toString());
759 valid = false;
760 }
761 }
762 }
763 }
764
765 return valid;
766 }
767
768
769
770
771
772
773
774 protected boolean checkCgRequiredFields(Account newAccount) {
775
776 boolean result = true;
777
778
779 if (ObjectUtils.isNotNull(newAccount.getSubFundGroup())) {
780 if (getSubFundGroupService().isForContractsAndGrants(newAccount.getSubFundGroup())) {
781 result &= checkEmptyBOField("acctIndirectCostRcvyTypeCd", newAccount.getAcctIndirectCostRcvyTypeCd(), replaceTokens(OLEKeyConstants.ERROR_DOCUMENT_ACCMAINT_ICR_TYPE_CODE_CANNOT_BE_EMPTY));
782 result &= checkEmptyBOField("financialIcrSeriesIdentifier", newAccount.getFinancialIcrSeriesIdentifier(), replaceTokens(OLEKeyConstants.ERROR_DOCUMENT_ACCMAINT_ICR_SERIES_IDENTIFIER_CANNOT_BE_EMPTY));
783
784
785 if (checkEmptyBOField(OLEPropertyConstants.FINANCIAL_ICR_SERIES_IDENTIFIER, newAccount.getFinancialIcrSeriesIdentifier(), replaceTokens(OLEKeyConstants.ERROR_DOCUMENT_ACCMAINT_ICR_SERIES_IDENTIFIER_CANNOT_BE_EMPTY))) {
786 String fiscalYear = StringUtils.EMPTY + SpringContext.getBean(UniversityDateService.class).getCurrentFiscalYear();
787 String icrSeriesId = newAccount.getFinancialIcrSeriesIdentifier();
788
789 Map<String, String> pkMap = new HashMap<String, String>();
790 pkMap.put(OLEPropertyConstants.UNIVERSITY_FISCAL_YEAR, fiscalYear);
791 pkMap.put(OLEPropertyConstants.FINANCIAL_ICR_SERIES_IDENTIFIER, icrSeriesId);
792 Collection<IndirectCostRecoveryRateDetail> icrRateDetails = getBoService().findMatching(IndirectCostRecoveryRateDetail.class, pkMap);
793
794 if (ObjectUtils.isNull(icrRateDetails) || icrRateDetails.isEmpty()) {
795 String label = SpringContext.getBean(DataDictionaryService.class).getAttributeLabel(Account.class, OLEPropertyConstants.FINANCIAL_ICR_SERIES_IDENTIFIER);
796 putFieldError(OLEPropertyConstants.FINANCIAL_ICR_SERIES_IDENTIFIER, OLEKeyConstants.ERROR_EXISTENCE, label + " (" + icrSeriesId + ")");
797 result &= false;
798 }
799 else {
800 for(IndirectCostRecoveryRateDetail icrRateDetail : icrRateDetails) {
801 if(ObjectUtils.isNull(icrRateDetail.getIndirectCostRecoveryRate())){
802 putFieldError(OLEPropertyConstants.FINANCIAL_ICR_SERIES_IDENTIFIER, OLEKeyConstants.IndirectCostRecovery.ERROR_DOCUMENT_ICR_RATE_NOT_FOUND, new String[]{fiscalYear, icrSeriesId});
803 result &= false;
804 break;
805 }
806 }
807 }
808 }
809
810
811 result &= checkICRCollectionExistWithErrorMessage(true, OLEKeyConstants.ERROR_DOCUMENT_ACCMAINT_ICR_CHART_CODE_CANNOT_BE_EMPTY,
812 replaceTokens(OLEKeyConstants.ERROR_DOCUMENT_ACCMAINT_ICR_CHART_CODE_CANNOT_BE_EMPTY));
813 result &= checkContractControlAccountNumberRequired(newAccount);
814
815 }
816 else {
817
818 result &= checkCGFieldNotFilledIn(newAccount, "acctIndirectCostRcvyTypeCd");
819 result &= checkCGFieldNotFilledIn(newAccount, "financialIcrSeriesIdentifier");
820
821
822 result &= checkICRCollectionExistWithErrorMessage(false, OLEKeyConstants.ERROR_DOCUMENT_ACCMAINT_CG_ICR_FIELDS_FILLED_FOR_NON_CG_ACCOUNT, newAccount.getSubFundGroupCode());
823
824 }
825 }
826 return result;
827 }
828
829
830
831
832
833
834
835 protected String replaceTokens(String errorConstant) {
836 String cngLabel = getSubFundGroupService().getContractsAndGrantsDenotingAttributeLabel();
837 String cngValue = getSubFundGroupService().getContractsAndGrantsDenotingValueForMessage();
838 String result = getConfigService().getPropertyValueAsString(errorConstant);
839 result = StringUtils.replace(result, "{0}", cngLabel);
840 result = StringUtils.replace(result, "{1}", cngValue);
841 return result;
842 }
843
844
845
846
847
848
849
850
851 protected boolean checkContractControlAccountNumberRequired(Account newAccount) {
852
853 boolean result = true;
854
855
856
857 if (ObjectUtils.isNull(newAccount.getContractControlFinCoaCode())) {
858 return result;
859 }
860 if (ObjectUtils.isNull(newAccount.getContractControlAccountNumber())) {
861 return result;
862 }
863 if ((newAccount.getContractControlFinCoaCode().equals(newAccount.getChartOfAccountsCode())) && (newAccount.getContractControlAccountNumber().equals(newAccount.getAccountNumber()))) {
864 return result;
865 }
866
867
868 DictionaryValidationService dvService = super.getDictionaryValidationService();
869 boolean referenceExists = dvService.validateReferenceExists(newAccount, "contractControlAccount");
870 if (!referenceExists) {
871 putFieldError("contractControlAccountNumber", OLEKeyConstants.ERROR_EXISTENCE, "Contract Control Account: " + newAccount.getContractControlFinCoaCode() + "-" + newAccount.getContractControlAccountNumber());
872 result &= false;
873 }
874
875 return result;
876 }
877
878
879
880
881
882
883
884 protected boolean checkExpirationDate(MaintenanceDocument maintenanceDocument) {
885
886 LOG.debug("checkExpirationDate called");
887
888 boolean success = true;
889
890 Date oldExpDate = oldAccount.getAccountExpirationDate();
891 Date newExpDate = newAccount.getAccountExpirationDate();
892 Date today = new Date(getDateTimeService().getCurrentTimestamp().getTime());
893 today.setTime(DateUtils.truncate(today, Calendar.DAY_OF_MONTH).getTime());
894
895
896
897
898
899
900 if (isUpdatedExpirationDateInvalid(maintenanceDocument)) {
901 Account newAccount = (Account) maintenanceDocument.getNewMaintainableObject().getBusinessObject();
902 if(newAccount.isClosed()){
903
904 putFieldError("accountExpirationDate", OLEKeyConstants.ERROR_DOCUMENT_ACCMAINT_ACCT_CANNOT_BE_CLOSED_EXP_DATE_INVALID);
905 }
906 else{
907
908 putFieldError("accountExpirationDate", OLEKeyConstants.ERROR_DOCUMENT_ACCMAINT_EXP_DATE_TODAY_LATER);
909 }
910 success &= false;
911 }
912
913
914 if (ObjectUtils.isNotNull(newExpDate)) {
915 if (StringUtils.isBlank(newAccount.getContinuationAccountNumber())) {
916 putFieldError("continuationAccountNumber", OLEKeyConstants.ERROR_DOCUMENT_ACCMAINT_CONTINUATION_ACCT_REQD_IF_EXP_DATE_COMPLETED);
917 }
918 if (StringUtils.isBlank(newAccount.getContinuationFinChrtOfAcctCd())) {
919 putFieldError("continuationFinChrtOfAcctCd", OLEKeyConstants.ERROR_DOCUMENT_ACCMAINT_CONTINUATION_FINCODE_REQD_IF_EXP_DATE_COMPLETED);
920
921 success &= false;
922 }
923 }
924
925
926
927 if (maintenanceDocument.isNew() && ObjectUtils.isNotNull(newExpDate)) {
928 if (!newExpDate.after(today) && !newExpDate.equals(today)) {
929 putFieldError("accountExpirationDate", OLEKeyConstants.ERROR_DOCUMENT_ACCMAINT_EXP_DATE_TODAY_LATER);
930
931 success &= false;
932 }
933 }
934
935
936 Date effectiveDate = newAccount.getAccountEffectiveDate();
937 if (ObjectUtils.isNotNull(effectiveDate) && ObjectUtils.isNotNull(newExpDate)) {
938 if (newExpDate.before(effectiveDate)) {
939 putFieldError("accountExpirationDate", OLEKeyConstants.ERROR_DOCUMENT_ACCMAINT_EXP_DATE_CANNOT_BE_BEFORE_EFFECTIVE_DATE);
940
941 success &= false;
942 }
943 }
944
945 return success;
946 }
947
948
949
950
951
952
953
954 protected boolean isUpdatedExpirationDateInvalid(MaintenanceDocument maintDoc) {
955
956
957 if (!maintDoc.isEdit()) {
958 return false;
959 }
960
961 Date oldExpDate = oldAccount.getAccountExpirationDate();
962 Date newExpDate = newAccount.getAccountExpirationDate();
963 Date today = new Date(getDateTimeService().getCurrentDate().getTime());
964 today.setTime(DateUtils.truncate(today, Calendar.DAY_OF_MONTH).getTime());
965
966
967
968
969 boolean expDateHasChanged = false;
970
971
972
973 if (ObjectUtils.isNull(oldExpDate) && ObjectUtils.isNotNull(newExpDate)) {
974 expDateHasChanged = true;
975 }
976
977
978 else if (ObjectUtils.isNotNull(oldExpDate) && ObjectUtils.isNotNull(newExpDate)) {
979 if (!oldExpDate.equals(newExpDate)) {
980 expDateHasChanged = true;
981 }
982 }
983
984
985 if (!expDateHasChanged) {
986 return false;
987 }
988
989
990 Account newAccount = (Account) maintDoc.getNewMaintainableObject().getBusinessObject();
991
992
993 if (newExpDate.equals(today) || newExpDate.after(today)) {
994 return false;
995 }
996 else {
997 return true;
998 }
999 }
1000
1001
1002
1003
1004
1005
1006
1007
1008 protected boolean checkFundGroup(MaintenanceDocument maintenanceDocument) {
1009
1010 LOG.debug("checkFundGroup called");
1011
1012 boolean success = true;
1013 SubFundGroup subFundGroup = newAccount.getSubFundGroup();
1014
1015 if (ObjectUtils.isNotNull(subFundGroup)) {
1016
1017
1018 String fundGroupCode = "";
1019 String restrictedStatusCode = "";
1020 if (StringUtils.isNotBlank(subFundGroup.getFundGroupCode())) {
1021 fundGroupCode = subFundGroup.getFundGroupCode().trim();
1022 }
1023 if (StringUtils.isNotBlank(newAccount.getAccountRestrictedStatusCode())) {
1024 restrictedStatusCode = newAccount.getAccountRestrictedStatusCode().trim();
1025 }
1026 }
1027
1028 return success;
1029 }
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039 protected boolean checkSubFundGroup(MaintenanceDocument maintenanceDocument) {
1040
1041 LOG.debug("checkSubFundGroup called");
1042
1043 boolean success = true;
1044
1045 String subFundGroupCode = newAccount.getSubFundGroupCode();
1046
1047 if (newAccount.getAccountDescription() != null) {
1048
1049 String campusCode = newAccount.getAccountDescription().getCampusCode();
1050 String buildingCode = newAccount.getAccountDescription().getBuildingCode();
1051
1052
1053 if (StringUtils.isBlank(subFundGroupCode)) {
1054
1055
1056 if (!StringUtils.isBlank(campusCode) || !StringUtils.isBlank(buildingCode)) {
1057
1058
1059 if (!StringUtils.isBlank(campusCode)) {
1060 putFieldError("accountDescription.campusCode", OLEKeyConstants.ERROR_DOCUMENT_ACCMAINT_BLANK_SUBFUNDGROUP_WITH_CAMPUS_CD_FOR_BLDG, subFundGroupCode);
1061 success &= false;
1062 }
1063
1064
1065 if (!StringUtils.isBlank(buildingCode)) {
1066 putFieldError("accountDescription.buildingCode", OLEKeyConstants.ERROR_DOCUMENT_ACCMAINT_BLANK_SUBFUNDGROUP_WITH_BUILDING_CD, subFundGroupCode);
1067 success &= false;
1068 }
1069
1070 }
1071 else {
1072
1073
1074 return success;
1075 }
1076
1077 }
1078 else if (!StringUtils.isBlank(subFundGroupCode) && !ObjectUtils.isNull(newAccount.getSubFundGroup())) {
1079
1080
1081
1082
1083 ParameterEvaluator evaluator = SpringContext.getBean(ParameterEvaluatorService.class).getParameterEvaluator(Account.class, ACCT_CAPITAL_SUBFUNDGROUP, subFundGroupCode.trim());
1084
1085 if (evaluator.evaluationSucceeds()) {
1086
1087
1088 if (StringUtils.isBlank(campusCode)) {
1089 putFieldError("accountDescription.campusCode", OLEKeyConstants.ERROR_DOCUMENT_ACCMAINT_CAMS_SUBFUNDGROUP_WITH_MISSING_CAMPUS_CD_FOR_BLDG, subFundGroupCode);
1090 success &= false;
1091 }
1092
1093
1094 if (StringUtils.isBlank(buildingCode)) {
1095 putFieldError("accountDescription.buildingCode", OLEKeyConstants.ERROR_DOCUMENT_ACCMAINT_CAMS_SUBFUNDGROUP_WITH_MISSING_BUILDING_CD, subFundGroupCode);
1096 success &= false;
1097 }
1098
1099
1100 if (!StringUtils.isBlank(campusCode) && !StringUtils.isBlank(buildingCode)) {
1101
1102
1103 org.kuali.rice.krad.service.DataDictionaryService dds = getDdService();
1104 Boolean buildingCodeForceUppercase = dds.getAttributeForceUppercase(AccountDescription.class, OLEPropertyConstants.BUILDING_CODE);
1105 if (StringUtils.isNotBlank(buildingCode) && buildingCodeForceUppercase != null && buildingCodeForceUppercase.booleanValue() == true) {
1106 buildingCode = buildingCode.toUpperCase();
1107 }
1108
1109 Boolean campusCodeForceUppercase = dds.getAttributeForceUppercase(AccountDescription.class, OLEPropertyConstants.CAMPUS_CODE);
1110 if (StringUtils.isNotBlank(campusCode) && campusCodeForceUppercase != null && campusCodeForceUppercase.booleanValue() == true) {
1111 campusCode = campusCode.toUpperCase();
1112 }
1113
1114 Map<String, String> pkMap = new HashMap<String, String>();
1115 pkMap.put("campusCode", campusCode);
1116 pkMap.put("buildingCode", buildingCode);
1117
1118 Building building = getBoService().findByPrimaryKey(Building.class, pkMap);
1119 if (building == null) {
1120 putFieldError("accountDescription.campusCode", OLEKeyConstants.ERROR_EXISTENCE, campusCode);
1121 putFieldError("accountDescription.buildingCode", OLEKeyConstants.ERROR_EXISTENCE, buildingCode);
1122 success &= false;
1123 }
1124 }
1125 }
1126 else {
1127
1128
1129 if (!StringUtils.isBlank(campusCode)) {
1130 putFieldError("accountDescription.campusCode", OLEKeyConstants.ERROR_DOCUMENT_ACCMAINT_NONCAMS_SUBFUNDGROUP_WITH_CAMPUS_CD_FOR_BLDG, subFundGroupCode);
1131 success &= false;
1132 }
1133
1134
1135 if (!StringUtils.isBlank(buildingCode)) {
1136 putFieldError("accountDescription.buildingCode", OLEKeyConstants.ERROR_DOCUMENT_ACCMAINT_NONCAMS_SUBFUNDGROUP_WITH_BUILDING_CD, subFundGroupCode);
1137 success &= false;
1138 }
1139 }
1140 }
1141
1142 }
1143
1144 return success;
1145 }
1146
1147
1148
1149
1150
1151
1152 protected boolean checkVendorNameForSubFundGroup(MaintenanceDocument maintenanceDocument) {
1153 LOG.debug("checkVendorName called");
1154 boolean success = true;
1155 if (StringUtils.isNotBlank(newAccount.getSubFundGroupCode())) {
1156 String fundGroupCode=null;
1157 String subFundGroupCode = newAccount.getSubFundGroupCode();
1158 SubFundGroup subFundGroup = getBoService().findBySinglePrimaryKey(SubFundGroup.class, subFundGroupCode);
1159 if(subFundGroup!=null){
1160 fundGroupCode = newAccount.getSubFundGroup().getFundGroupCode();
1161 }
1162 String fundGroupParameter = getParameterService().getParameterValueAsString(Account.class, OleSelectConstant.FUND_GRP_CD);
1163 String subFundGroupParameter = getParameterService().getParameterValueAsString(Account.class,
1164 OleSelectConstant.SUB_FUND_GRP_CD);
1165 if ((subFundGroupCode.equalsIgnoreCase(subFundGroupParameter) && fundGroupCode
1166 .equalsIgnoreCase(fundGroupParameter))) {
1167 if (newAccount.getVendorHeaderGeneratedIdentifier() != null) {
1168 return success;
1169 }
1170 putFieldError(OleSelectConstant.VENDOR_NAME,
1171 OLEKeyConstants.ERROR_DOCUMENT_ACCMAINT_VENDOR_NAME_NEEDED_FOR_SELECTED_SUBFUNDGROUP);
1172 success = false;
1173 return success;
1174 }
1175 else if (newAccount.getVendorHeaderGeneratedIdentifier() != null) {
1176 putFieldError(OleSelectConstant.VENDOR_NAME,
1177 OLEKeyConstants.ERROR_DOCUMENT_ACCMAINT_INVALID_SUBFUNDGROUP_WITH_VENDOR_NAME, subFundGroupCode);
1178 success = false;
1179 return success;
1180 }
1181 }
1182 return success;
1183 }
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193 protected boolean checkIncomeStreamAccountRule() {
1194
1195 if ( ObjectUtils.isNotNull(newAccount.getSubFundGroup()) && StringUtils.isNotBlank(newAccount.getSubFundGroup().getFundGroupCode())) {
1196 if (ObjectUtils.isNull(newAccount.getIncomeStreamAccount())) {
1197 String incomeStreamRequiringFundGroupCode = SpringContext.getBean(ParameterService.class).getParameterValueAsString(Account.class, OLEConstants.ChartApcParms.INCOME_STREAM_ACCOUNT_REQUIRING_FUND_GROUPS);
1198 if (StringUtils.containsIgnoreCase(newAccount.getSubFundGroup().getFundGroupCode(), incomeStreamRequiringFundGroupCode)) {
1199 GlobalVariables.getMessageMap().putError(OLEPropertyConstants.ACCOUNT_NUMBER, OLEKeyConstants.ERROR_DOCUMENT_BA_NO_INCOME_STREAM_ACCOUNT, newAccount.getAccountNumber());
1200 return false;
1201 }
1202 }
1203 }
1204 return true;
1205 }
1206
1207
1208
1209
1210
1211
1212
1213
1214 protected boolean checkCGFieldNotFilledIn(Account account, String propertyName) {
1215 boolean success = true;
1216 Object value = ObjectUtils.getPropertyValue(account, propertyName);
1217 if ((value instanceof String && !StringUtils.isBlank(value.toString())) || (value != null)) {
1218 success = false;
1219 putFieldError(propertyName, OLEKeyConstants.ERROR_DOCUMENT_ACCMAINT_CG_FIELDS_FILLED_FOR_NON_CG_ACCOUNT, new String[] { account.getSubFundGroupCode() });
1220 }
1221
1222 return success;
1223 }
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234 protected boolean checkUniqueAccountNumber(MaintenanceDocument maintenanceDocument) {
1235 boolean success = true;
1236 String accountNumber = newAccount.getAccountNumber();
1237
1238 if (maintenanceDocument.isNew() &&
1239
1240 !accountService.accountsCanCrossCharts() &&
1241
1242 !accountService.getAccountsForAccountNumber(accountNumber).isEmpty()) {
1243
1244 success = false;
1245 putFieldError("accountNumber", OLEKeyConstants.ERROR_DOCUMENT_ACCMAINT_ACCT_NMBR_NOT_UNIQUE, accountNumber);
1246 }
1247
1248 return success;
1249 }
1250
1251 protected boolean checkOpenEncumbrances() {
1252 boolean success = true;
1253 if(!oldAccount.isClosed() && newAccount.isClosed()){
1254 Map<String, String> pkMap = new HashMap<String, String>();
1255 pkMap.put(OLEPropertyConstants.ACCOUNT_NUMBER, oldAccount.getAccountNumber());
1256 int encumbranceCount = getEncumbranceService().getOpenEncumbranceRecordCount(pkMap, false);
1257 if ( encumbranceCount > 0){
1258 success = false;
1259 putFieldError("closed", OLEKeyConstants.ERROR_DOCUMENT_ACCMAINT_ACCOUNT_CANNOT_CLOSE_OPEN_ENCUMBRANCE);
1260
1261 }
1262 }
1263 return success;
1264 }
1265
1266
1267
1268
1269
1270
1271
1272 protected boolean checkAccountRestrictedStatusDateIsGreaterThanCurrentDate(){
1273 boolean success = true;
1274 if(StringUtils.isNotBlank(newAccount.getAccountRestrictedStatusCode())){
1275 if(RESTRICTED_CD_TEMPORARILY_RESTRICTED.equalsIgnoreCase(newAccount.getAccountRestrictedStatusCode().trim())){
1276 if(newAccount.getAccountRestrictedStatusDate()==null){
1277 success = false;
1278 putFieldError("accountRestrictedStatusDate", OLEKeyConstants.ERROR_DOCUMENT_ACCMAINT_ACCOUNT_TEMPORARY_RESTRICTED_STATUS_DATE_NOTNULL);
1279 }
1280 else if(newAccount.getAccountRestrictedStatusDate().compareTo(newAccount.getAccountCreateDate())<0){
1281 success = false;
1282 putFieldError("accountRestrictedStatusDate", OLEKeyConstants.ERROR_DOCUMENT_ACCMAINT_ACCOUNT_TEMPORARY_RESTRICTED_STATUS_DATE_GREATERTHAN_CURRENTDATE);
1283 }
1284 }
1285 }
1286 return success;
1287 }
1288
1289
1290
1291
1292
1293
1294 public void setGeneralLedgerPendingEntryService(GeneralLedgerPendingEntryService generalLedgerPendingEntryService) {
1295 this.generalLedgerPendingEntryService = generalLedgerPendingEntryService;
1296 }
1297
1298
1299
1300
1301
1302
1303 public void setBalanceService(BalanceService balanceService) {
1304 this.balanceService = balanceService;
1305 }
1306
1307
1308
1309
1310
1311
1312 public final void setAccountService(AccountService accountService) {
1313 this.accountService = accountService;
1314 }
1315
1316
1317
1318
1319
1320 public void setContractsAndGrantsModuleService(ContractsAndGrantsModuleService contractsAndGrantsModuleService) {
1321 this.contractsAndGrantsModuleService = contractsAndGrantsModuleService;
1322 }
1323
1324 public SubFundGroupService getSubFundGroupService() {
1325 if ( subFundGroupService == null ) {
1326 subFundGroupService = SpringContext.getBean(SubFundGroupService.class);
1327 }
1328 return subFundGroupService;
1329 }
1330
1331 public ParameterService getParameterService() {
1332 if ( parameterService == null ) {
1333 parameterService = SpringContext.getBean(ParameterService.class);
1334 }
1335 return parameterService;
1336 }
1337
1338 public EncumbranceService getEncumbranceService() {
1339 if ( encumbranceService == null ) {
1340 encumbranceService = SpringContext.getBean(EncumbranceService.class);
1341 }
1342 return encumbranceService;
1343 }
1344
1345 public boolean validateSufficientFundCheckTab() {
1346
1347
1348 boolean returnFlag = true;
1349 if (newAccount.isPendingAcctSufficientFundsIndicator() == true) {
1350
1351 if (newAccount.getOleSufficientFundCheck().getEncumbExpenseMethod() == null) {
1352 GlobalVariables.getMessageMap().putError(OLEConstants.SUFF_FUND_CHECK, OLEConstants.ERROR_SELECT_EMCUM_METHOD);
1353 returnFlag = (returnFlag)&false;
1354 }
1355
1356 if (newAccount.getOleSufficientFundCheck().getEncumbExpenseConstraintType() == null) {
1357 GlobalVariables.getMessageMap().putError(OLEConstants.SUFF_FUND_CHECK, OLEConstants.ERROR_SELECT_EMCUM_CON_TYP);
1358 returnFlag = (returnFlag)&false;
1359 }
1360
1361 if (newAccount.getOleSufficientFundCheck().getEncumbranceAmount() == null) {
1362 GlobalVariables.getMessageMap().putError(OLEConstants.SUFF_FUND_CHECK, OLEConstants.ERROR_SELECT_EMCUM_AMT);
1363 returnFlag = (returnFlag)&false;
1364
1365 }
1366 if (newAccount.getOleSufficientFundCheck().getExpenseAmount() == null) {
1367 GlobalVariables.getMessageMap().putError(OLEConstants.SUFF_FUND_CHECK, OLEConstants.ERROR_SELECT_EXP_AMT);
1368 returnFlag = (returnFlag)&false;
1369
1370 }
1371 if (newAccount.getOleSufficientFundCheck().getNotificationOption() == null) {
1372 GlobalVariables.getMessageMap().putError(OLEConstants.SUFF_FUND_CHECK, OLEConstants.ERROR_SELECT_NOT_TYP);
1373 returnFlag = (returnFlag)&false;
1374 }
1375 }
1376 return returnFlag;
1377 }
1378 }
1379