1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.fp.document.validation.impl;
17
18 import java.text.MessageFormat;
19
20 import org.kuali.ole.fp.document.NonCheckDisbursementDocument;
21 import org.kuali.ole.sys.OLEConstants;
22 import org.kuali.ole.sys.OLEKeyConstants;
23 import org.kuali.ole.sys.OLEPropertyConstants;
24 import org.kuali.ole.sys.businessobject.Bank;
25 import org.kuali.ole.sys.context.SpringContext;
26 import org.kuali.ole.sys.service.BankService;
27 import org.kuali.rice.core.api.config.property.ConfigurationService;
28 import org.kuali.rice.kns.rules.PromptBeforeValidationBase;
29 import org.kuali.rice.krad.document.Document;
30
31
32
33
34 public class NonCheckDisbursementDocumentPreRules extends PromptBeforeValidationBase {
35
36 @Override
37 public boolean doPrompts(Document document) {
38 boolean preRulesOK = true;
39
40 NonCheckDisbursementDocument nonCheckDocument = (NonCheckDisbursementDocument) document;
41
42 preRulesOK &= checkBankCodeActive(nonCheckDocument);
43
44 return preRulesOK;
45 }
46
47
48
49
50
51
52
53
54 protected boolean checkBankCodeActive(NonCheckDisbursementDocument nonCheckDocument) {
55 boolean continueRules = true;
56
57
58 if (!SpringContext.getBean(BankService.class).isBankSpecificationEnabled()) {
59 return continueRules;
60 }
61
62
63 nonCheckDocument.refreshReferenceObject(OLEPropertyConstants.BANK);
64 Bank bank = nonCheckDocument.getBank();
65
66
67 if (bank != null && !bank.isActive() && bank.getContinuationBank().isActive()) {
68 String questionText = SpringContext.getBean(ConfigurationService.class).getPropertyValueAsString(OLEKeyConstants.QUESTION_BANK_INACTIVE);
69 questionText = MessageFormat.format(questionText, nonCheckDocument.getFinancialDocumentBankCode(), bank.getContinuationBankCode());
70
71 boolean useContinuation = super.askOrAnalyzeYesNoQuestion(OLEConstants.USE_CONTINUATION_BANK_QUESTION, questionText);
72 if (useContinuation) {
73 nonCheckDocument.setFinancialDocumentBankCode(bank.getContinuationBankCode());
74 }
75 }
76
77 return continueRules;
78 }
79
80 }