1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.kuali.ole.sys.businessobject;
18
19 import java.util.LinkedHashMap;
20
21 import org.apache.commons.lang.StringUtils;
22 import org.kuali.ole.coa.businessobject.AccountingPeriod;
23 import org.kuali.ole.fp.businessobject.AdvanceDepositDetail;
24 import org.kuali.ole.fp.document.AdvanceDepositDocument;
25 import org.kuali.ole.sys.OLEPropertyConstants;
26 import org.kuali.ole.sys.context.SpringContext;
27 import org.kuali.rice.kew.api.exception.WorkflowException;
28 import org.kuali.rice.krad.bo.DocumentHeader;
29 import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
30 import org.kuali.rice.krad.service.DocumentService;
31 import org.kuali.rice.krad.util.ObjectUtils;
32
33
34
35
36 public class ElectronicPaymentClaim extends PersistableBusinessObjectBase {
37
38 public final static class ClaimStatusCodes {
39 public final static String CLAIMED = "C";
40 public final static String UNCLAIMED = "U";
41 }
42
43 private String documentNumber;
44 private Integer financialDocumentLineNumber;
45 private String referenceFinancialDocumentNumber;
46 private Integer financialDocumentPostingYear;
47 private String financialDocumentPostingPeriodCode;
48 private String paymentClaimStatusCode;
49
50 private AdvanceDepositDocument generatingDocument;
51 private SourceAccountingLine generatingAccountingLine;
52 private AccountingPeriod financialDocumentPostingPeriod;
53 private DocumentHeader generatingDocumentHeader;
54
55
56
57
58 public ElectronicPaymentClaim() {}
59
60
61
62
63
64
65 public String getDocumentNumber() {
66 return documentNumber;
67 }
68
69
70
71
72
73
74 public void setDocumentNumber(String documentNumber) {
75 this.documentNumber = documentNumber;
76 }
77
78
79
80
81
82
83
84 public Integer getFinancialDocumentLineNumber() {
85 return financialDocumentLineNumber;
86 }
87
88
89
90
91
92
93 public void setFinancialDocumentLineNumber(Integer financialDocumentLineNumber) {
94 this.financialDocumentLineNumber = financialDocumentLineNumber;
95 }
96
97
98
99
100
101
102
103 public String getReferenceFinancialDocumentNumber() {
104 return referenceFinancialDocumentNumber;
105 }
106
107
108
109
110
111
112 public void setReferenceFinancialDocumentNumber(String referenceFinancialDocumentNumber) {
113 this.referenceFinancialDocumentNumber = referenceFinancialDocumentNumber;
114 }
115
116
117
118
119
120
121
122 public Integer getFinancialDocumentPostingYear() {
123 return financialDocumentPostingYear;
124 }
125
126
127
128
129
130
131 public void setFinancialDocumentPostingYear(Integer financialDocumentPostingYear) {
132 this.financialDocumentPostingYear = financialDocumentPostingYear;
133 }
134
135
136
137
138
139
140
141 public String getFinancialDocumentPostingPeriodCode() {
142 return financialDocumentPostingPeriodCode;
143 }
144
145
146
147
148
149
150 public void setFinancialDocumentPostingPeriodCode(String financialDocumentPostingPeriodCode) {
151 this.financialDocumentPostingPeriodCode = financialDocumentPostingPeriodCode;
152 }
153
154
155
156
157
158 public String getPaymentClaimStatusCode() {
159 return paymentClaimStatusCode;
160 }
161
162
163
164
165
166 public void setPaymentClaimStatusCode(String paymentClaimStatusCode) {
167 this.paymentClaimStatusCode = paymentClaimStatusCode;
168 }
169
170
171
172
173
174 public AdvanceDepositDocument getGeneratingDocument() {
175 final boolean docNumbersAreDifferentAndNotNull = (generatingDocumentHeader != null && !documentNumber.equals(this.generatingDocumentHeader.getDocumentNumber()));
176 if (StringUtils.isNotBlank(documentNumber) && (this.generatingDocument == null || docNumbersAreDifferentAndNotNull)) {
177 try {
178 generatingDocument = (AdvanceDepositDocument)SpringContext.getBean(DocumentService.class).getByDocumentHeaderId(documentNumber);
179 }
180 catch (WorkflowException we) {
181 throw new RuntimeException("Could not retrieve Document #"+documentNumber, we);
182 }
183 }
184 return this.generatingDocument;
185 }
186
187
188
189
190
191 public DocumentHeader getGeneratingDocumentHeader() {
192 return generatingDocumentHeader;
193 }
194
195
196
197
198
199
200 public void setGeneratingDocumentHeader(DocumentHeader generatingDocumentHeader) {
201 this.generatingDocumentHeader = generatingDocumentHeader;
202 }
203
204
205
206
207
208 public SourceAccountingLine getGeneratingAccountingLine() {
209 if (generatingAccountingLine == null) {
210 final AdvanceDepositDocument generatingDocument = getGeneratingDocument();
211 if (generatingDocument != null && generatingDocument.getSourceAccountingLines() != null) {
212 int count = 0;
213
214 while (generatingAccountingLine == null && count < generatingDocument.getSourceAccountingLines().size()) {
215 if (generatingDocument.getSourceAccountingLine(count).getSequenceNumber().equals(getFinancialDocumentLineNumber())) {
216 generatingAccountingLine = generatingDocument.getSourceAccountingLine(count);
217 }
218 count += 1;
219 }
220
221 }
222 }
223 return generatingAccountingLine;
224 }
225
226
227
228
229
230 public AdvanceDepositDetail getGeneratingAdvanceDepositDetail() {
231 final AdvanceDepositDocument generatingDocument = getGeneratingDocument();
232 if (generatingDocument != null && !ObjectUtils.isNull(generatingDocument.getAdvanceDeposits()) && !generatingDocument.getAdvanceDeposits().isEmpty()) {
233 return generatingDocument.getAdvanceDepositDetail(0);
234 }
235 return null;
236 }
237
238
239
240
241
242 public AccountingPeriod getFinancialDocumentPostingPeriod() {
243 return financialDocumentPostingPeriod;
244 }
245
246
247
248
249
250 public void setFinancialDocumentPostingPeriod(AccountingPeriod financialDocumentPostingPeriod) {
251 this.financialDocumentPostingPeriod = financialDocumentPostingPeriod;
252 }
253
254
255
256
257 protected LinkedHashMap toStringMapper_RICE20_REFACTORME() {
258 LinkedHashMap m = new LinkedHashMap();
259 m.put(OLEPropertyConstants.DOCUMENT_NUMBER, this.documentNumber);
260 if (this.financialDocumentLineNumber != null) {
261 m.put("financialDocumentLineNumber", this.financialDocumentLineNumber.toString());
262 }
263 return m;
264 }
265
266
267
268
269
270
271
272 public String getElectronicPaymentClaimRepresentation() {
273 StringBuilder representation = new StringBuilder();
274 representation.append(getDocumentNumber());
275 representation.append("::");
276 representation.append(getFinancialDocumentLineNumber());
277 return representation.toString();
278 }
279
280
281
282
283 public String getPaymentClaimStatus() {
284 return getPaymentClaimStatusCode().equals("C") ? "Claimed" : "Unclaimed";
285 }
286 }