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.businessobject.AdvanceDepositDetail;
21 import org.kuali.ole.fp.document.AdvanceDepositDocument;
22 import org.kuali.ole.sys.OLEConstants;
23 import org.kuali.ole.sys.OLEKeyConstants;
24 import org.kuali.ole.sys.OLEPropertyConstants;
25 import org.kuali.ole.sys.businessobject.Bank;
26 import org.kuali.ole.sys.context.SpringContext;
27 import org.kuali.ole.sys.service.BankService;
28 import org.kuali.rice.core.api.config.property.ConfigurationService;
29 import org.kuali.rice.kns.rules.PromptBeforeValidationBase;
30 import org.kuali.rice.krad.document.Document;
31
32
33
34
35 public class AdvanceDepositDocumentPreRules extends PromptBeforeValidationBase {
36
37 @Override
38 public boolean doPrompts(Document document) {
39 boolean preRulesOK = true;
40
41 AdvanceDepositDocument adDocument = (AdvanceDepositDocument) document;
42
43 preRulesOK &= checkBankCodeActive(adDocument);
44
45 return preRulesOK;
46 }
47
48
49
50
51
52
53
54 protected boolean checkBankCodeActive(AdvanceDepositDocument adDocument) {
55 boolean continueRules = true;
56
57
58 if (!SpringContext.getBean(BankService.class).isBankSpecificationEnabled()) {
59 return continueRules;
60 }
61
62 int questionIndex = 0;
63 for (AdvanceDepositDetail advanceDeposit : adDocument.getAdvanceDeposits()) {
64 questionIndex++;
65
66
67 advanceDeposit.refreshReferenceObject(OLEPropertyConstants.BANK);
68 Bank bank = advanceDeposit.getBank();
69
70
71 if (bank != null && !bank.isActive() && bank.getContinuationBank().isActive()) {
72 String questionText = SpringContext.getBean(ConfigurationService.class).getPropertyValueAsString(OLEKeyConstants.QUESTION_BANK_INACTIVE);
73 questionText = MessageFormat.format(questionText, advanceDeposit.getFinancialDocumentBankCode(), bank.getContinuationBankCode());
74
75 boolean useContinuation = super.askOrAnalyzeYesNoQuestion(OLEConstants.USE_CONTINUATION_BANK_QUESTION + questionIndex, questionText);
76 if (useContinuation) {
77 advanceDeposit.setFinancialDocumentBankCode(bank.getContinuationBankCode());
78 }
79 }
80 }
81
82 return continueRules;
83 }
84
85 }