1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.sys.businessobject;
17
18 import java.sql.Date;
19
20 import org.apache.commons.lang.StringUtils;
21 import org.kuali.ole.sys.OLEConstants;
22 import org.kuali.ole.sys.context.SpringContext;
23 import org.kuali.rice.core.api.util.type.KualiDecimal;
24 import org.kuali.rice.kew.api.WorkflowDocument;
25 import org.kuali.rice.kew.api.exception.WorkflowException;
26 import org.kuali.rice.krad.bo.DocumentHeader;
27 import org.kuali.rice.krad.util.GlobalVariables;
28 import org.kuali.rice.krad.workflow.service.WorkflowDocumentService;
29
30
31
32
33 public class FinancialSystemDocumentHeader extends DocumentHeader {
34
35 protected KualiDecimal financialDocumentTotalAmount;
36 protected String correctedByDocumentId;
37 protected String financialDocumentInErrorNumber;
38 protected String financialDocumentStatusCode;
39
40
41
42
43
44 public FinancialSystemDocumentHeader() {
45 super();
46 financialDocumentStatusCode = OLEConstants.DocumentStatusCodes.INITIATED;
47 }
48
49
50
51
52
53 public KualiDecimal getFinancialDocumentTotalAmount() {
54 return financialDocumentTotalAmount;
55 }
56
57
58
59
60
61 public void setFinancialDocumentTotalAmount(KualiDecimal financialDocumentTotalAmount) {
62 this.financialDocumentTotalAmount = financialDocumentTotalAmount;
63 }
64
65
66
67
68
69 public String getCorrectedByDocumentId() {
70 return correctedByDocumentId;
71 }
72
73
74
75
76
77 public void setCorrectedByDocumentId(String correctedByDocumentId) {
78 this.correctedByDocumentId = correctedByDocumentId;
79 }
80
81
82
83
84
85 public String getFinancialDocumentInErrorNumber() {
86 return financialDocumentInErrorNumber;
87 }
88
89
90
91
92
93 public void setFinancialDocumentInErrorNumber(String financialDocumentInErrorNumber) {
94 this.financialDocumentInErrorNumber = financialDocumentInErrorNumber;
95 }
96
97
98
99
100
101 public String getFinancialDocumentStatusCode() {
102 return financialDocumentStatusCode;
103 }
104
105
106
107
108
109 public void setFinancialDocumentStatusCode(String financialDocumentStatusCode) {
110 this.financialDocumentStatusCode = financialDocumentStatusCode;
111 }
112
113
114
115
116
117 public Date getDocumentFinalDate() {
118 WorkflowDocument workflowDoc = this.getWorkflowDocument();
119 if (workflowDoc == null || (workflowDoc.getDateFinalized() == null)) {
120 return null;
121 }
122 return new java.sql.Date(workflowDoc.getDateFinalized().getMillis());
123 }
124
125
126
127
128
129
130
131 public String getApplicationDocumentStatus() {
132 WorkflowDocument document = getWorkflowDocument();
133 return StringUtils.trimToEmpty(document.getApplicationDocumentStatus());
134 }
135
136
137
138
139
140
141 public void setApplicationDocumentStatus(String applicationDocumentStatus) {
142 WorkflowDocument document = getWorkflowDocument();
143
144 document.setApplicationDocumentStatus(applicationDocumentStatus);
145 }
146
147
148
149
150
151
152 @Override
153 public WorkflowDocument getWorkflowDocument() {
154
155 WorkflowDocument workflowDocument = null;
156
157 if (hasWorkflowDocument()) {
158 workflowDocument = super.getWorkflowDocument();
159 }
160
161 try {
162 if (workflowDocument != null) {
163 return workflowDocument;
164 }
165 if ( StringUtils.isNotBlank(getDocumentNumber()) ) {
166 workflowDocument = SpringContext.getBean(WorkflowDocumentService.class).loadWorkflowDocument(getDocumentNumber(), GlobalVariables.getUserSession().getPerson());
167 } else {
168 throw new RuntimeException("Document number is blank/null. Unable to load a WorkflowDocument" );
169 }
170 }
171 catch (WorkflowException we) {
172 throw new RuntimeException("Unable to load a WorkflowDocument object for " + getDocumentNumber(), we);
173 }
174
175 return workflowDocument;
176 }
177
178
179
180
181
182
183
184 public void updateAndSaveAppDocStatus(String applicationDocumentStatus) throws WorkflowException {
185 setApplicationDocumentStatus(applicationDocumentStatus);
186
187
188
189 if ( !getWorkflowDocument().isInitiated() ) {
190 SpringContext.getBean(WorkflowDocumentService.class).saveRoutingData(getWorkflowDocument());
191 }
192 }
193
194 }