1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.kuali.kfs.module.cab.businessobject;
20
21 import java.util.ArrayList;
22 import java.util.HashMap;
23 import java.util.LinkedHashMap;
24 import java.util.List;
25 import java.util.Map;
26
27 import org.apache.commons.lang.StringUtils;
28 import org.kuali.kfs.module.cab.CabConstants;
29 import org.kuali.kfs.module.cab.CabPropertyConstants;
30 import org.kuali.kfs.module.purap.document.PaymentRequestDocument;
31 import org.kuali.kfs.module.purap.document.VendorCreditMemoDocument;
32 import org.kuali.kfs.sys.businessobject.FinancialSystemDocumentHeader;
33 import org.kuali.kfs.sys.context.SpringContext;
34 import org.kuali.rice.kew.api.KewApiServiceLocator;
35 import org.kuali.rice.kew.api.doctype.DocumentType;
36 import org.kuali.rice.kew.doctype.bo.DocumentTypeEBO;
37 import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
38 import org.kuali.rice.krad.service.BusinessObjectService;
39 import org.kuali.rice.krad.util.ObjectUtils;
40
41
42
43
44 public class PurchasingAccountsPayableDocument extends PersistableBusinessObjectBase {
45
46 private String documentNumber;
47 private Integer purapDocumentIdentifier;
48 private Integer purchaseOrderIdentifier;
49 private String documentTypeCode;
50 private String activityStatusCode;
51
52
53 private DocumentTypeEBO financialSystemDocumentTypeCode;
54 private FinancialSystemDocumentHeader documentHeader;
55 private List<PurchasingAccountsPayableItemAsset> purchasingAccountsPayableItemAssets;
56
57
58 private boolean active;
59 private String purApContactEmailAddress;
60 private String purApContactPhoneNumber;
61 private String statusDescription;
62 private String capitalAssetSystemTypeCodeFromPurAp;
63
64 public PurchasingAccountsPayableDocument() {
65 this.purchasingAccountsPayableItemAssets = new ArrayList<PurchasingAccountsPayableItemAsset>();
66 }
67
68
69
70
71
72
73 public String getCapitalAssetSystemTypeCodeFromPurAp() {
74 return capitalAssetSystemTypeCodeFromPurAp;
75 }
76
77
78
79
80
81
82 public void setCapitalAssetSystemTypeCodeFromPurAp(String capitalAssetSystemTypeCodeFromPurAp) {
83 this.capitalAssetSystemTypeCodeFromPurAp = capitalAssetSystemTypeCodeFromPurAp;
84 }
85
86
87
88
89
90
91
92 public String getDocumentNumber() {
93 return documentNumber;
94 }
95
96
97
98
99
100
101
102 public void setDocumentNumber(String documentNumber) {
103 this.documentNumber = documentNumber;
104 }
105
106
107
108
109
110
111
112 public Integer getPurapDocumentIdentifier() {
113 return purapDocumentIdentifier;
114 }
115
116
117
118
119
120
121
122 public void setPurapDocumentIdentifier(Integer purapDocumentIdentifier) {
123 this.purapDocumentIdentifier = purapDocumentIdentifier;
124 }
125
126
127
128
129
130
131
132 public Integer getPurchaseOrderIdentifier() {
133 return purchaseOrderIdentifier;
134 }
135
136
137
138
139
140
141
142 public void setPurchaseOrderIdentifier(Integer purchaseOrderIdentifier) {
143 this.purchaseOrderIdentifier = purchaseOrderIdentifier;
144 }
145
146
147
148
149
150
151
152 public String getDocumentTypeCode() {
153 return documentTypeCode;
154 }
155
156
157
158
159
160
161
162 public void setDocumentTypeCode(String documentTypeCode) {
163 this.documentTypeCode = documentTypeCode;
164 }
165
166
167
168
169
170
171
172 public boolean isActive() {
173 return CabConstants.ActivityStatusCode.NEW.equalsIgnoreCase(this.getActivityStatusCode()) || CabConstants.ActivityStatusCode.MODIFIED.equalsIgnoreCase(this.getActivityStatusCode());
174 }
175
176
177
178
179
180
181
182 public String getActivityStatusCode() {
183 return activityStatusCode;
184 }
185
186
187
188
189
190
191
192 public void setActivityStatusCode(String activityStatusCode) {
193 this.activityStatusCode = activityStatusCode;
194 }
195
196
197
198
199
200
201
202 public DocumentTypeEBO getFinancialSystemDocumentTypeCode() {
203 if ( financialSystemDocumentTypeCode == null || !StringUtils.equals(financialSystemDocumentTypeCode.getName(), documentTypeCode) ) {
204 financialSystemDocumentTypeCode = null;
205 if ( StringUtils.isNotBlank(documentTypeCode) ) {
206 DocumentType docType = KewApiServiceLocator.getDocumentTypeService().getDocumentTypeByName(documentTypeCode);
207 if ( docType != null ) {
208 financialSystemDocumentTypeCode = org.kuali.rice.kew.doctype.bo.DocumentType.from(docType);
209 }
210 }
211 }
212 return financialSystemDocumentTypeCode;
213 }
214
215
216
217
218
219
220 public FinancialSystemDocumentHeader getDocumentHeader() {
221 return documentHeader;
222 }
223
224
225
226
227
228
229
230 public void setDocumentHeader(FinancialSystemDocumentHeader documentHeader) {
231 this.documentHeader = documentHeader;
232 }
233
234
235
236
237
238
239
240 public List<PurchasingAccountsPayableItemAsset> getPurchasingAccountsPayableItemAssets() {
241 return purchasingAccountsPayableItemAssets;
242 }
243
244
245
246
247
248
249
250 public void setPurchasingAccountsPayableItemAssets(List<PurchasingAccountsPayableItemAsset> purchasingAccountsPayableItemAssets) {
251 this.purchasingAccountsPayableItemAssets = purchasingAccountsPayableItemAssets;
252 }
253
254
255
256
257
258
259
260 public String getPurApContactEmailAddress() {
261 return purApContactEmailAddress;
262 }
263
264
265
266
267
268
269
270 public void setPurApContactEmailAddress(String purApContactEmailAddress) {
271 this.purApContactEmailAddress = purApContactEmailAddress;
272 }
273
274
275
276
277
278
279
280 public String getPurApContactPhoneNumber() {
281 return purApContactPhoneNumber;
282 }
283
284
285
286
287
288
289
290 public void setPurApContactPhoneNumber(String purApContactPhoneNumber) {
291 this.purApContactPhoneNumber = purApContactPhoneNumber;
292 }
293
294
295
296
297
298
299
300 public String getStatusDescription() {
301 String statusCode;
302
303 if (StringUtils.isNotBlank(this.statusDescription)) {
304 return this.statusDescription;
305 }
306 else {
307 Map objectKeys = new HashMap();
308 objectKeys.put(CabPropertyConstants.PurchasingAccountsPayableDocument.PURAP_DOCUMENT_IDENTIFIER, this.getPurapDocumentIdentifier());
309
310 if (CabConstants.PREQ.equals(this.documentTypeCode)) {
311
312 PaymentRequestDocument paymentRequestDocument = (PaymentRequestDocument) SpringContext.getBean(BusinessObjectService.class).findByPrimaryKey(PaymentRequestDocument.class, objectKeys);
313 if (ObjectUtils.isNotNull(paymentRequestDocument)) {
314 statusDescription = paymentRequestDocument.getApplicationDocumentStatus();
315 }
316 }
317 else {
318 VendorCreditMemoDocument vendorCreditMemoDocument = (VendorCreditMemoDocument) SpringContext.getBean(BusinessObjectService.class).findByPrimaryKey(VendorCreditMemoDocument.class, objectKeys);
319 if (ObjectUtils.isNotNull(vendorCreditMemoDocument)) {
320 statusDescription = vendorCreditMemoDocument.getApplicationDocumentStatus();
321 }
322 }
323 }
324
325 return statusDescription;
326 }
327
328
329
330
331
332
333
334 public void setStatusDescription(String statusDescription) {
335 this.statusDescription = statusDescription;
336 }
337
338
339
340
341
342
343
344
345 @Override
346 public List buildListOfDeletionAwareLists() {
347 List<List> managedLists = new ArrayList<List>();
348
349 managedLists.add(getPurchasingAccountsPayableItemAssets());
350 return managedLists;
351 }
352
353
354
355
356 protected LinkedHashMap toStringMapper_RICE20_REFACTORME() {
357 LinkedHashMap m = new LinkedHashMap();
358 m.put("documentNumber", this.documentNumber);
359 return m;
360 }
361
362 public PurchasingAccountsPayableItemAsset getPurchasingAccountsPayableItemAsset(int index) {
363 int size = getPurchasingAccountsPayableItemAssets().size();
364 while (size <= index || getPurchasingAccountsPayableItemAssets().get(index) == null) {
365 getPurchasingAccountsPayableItemAssets().add(size++, new PurchasingAccountsPayableItemAsset());
366 }
367 return getPurchasingAccountsPayableItemAssets().get(index);
368
369 }
370
371 }