1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.module.purap.document;
17
18 import org.kuali.ole.module.purap.businessobject.*;
19 import org.kuali.ole.module.purap.document.service.ReceivingService;
20 import org.kuali.ole.sys.OLEPropertyConstants;
21 import org.kuali.ole.sys.context.SpringContext;
22 import org.kuali.ole.vnd.businessobject.CampusParameter;
23 import org.kuali.ole.vnd.businessobject.VendorDetail;
24 import org.kuali.rice.kew.framework.postprocessor.DocumentRouteStatusChange;
25 import org.kuali.rice.krad.util.ObjectUtils;
26 import org.kuali.rice.location.framework.country.CountryEbo;
27
28 import java.sql.Date;
29 import java.util.ArrayList;
30 import java.util.List;
31
32
33
34
35 public class CorrectionReceivingDocument extends ReceivingDocumentBase {
36
37 protected String lineItemReceivingDocumentNumber;
38
39 protected List<CorrectionReceivingItem> items;
40
41 protected LineItemReceivingDocument lineItemReceivingDocument;
42
43
44
45
46 public CorrectionReceivingDocument() {
47 super();
48 items = new ArrayList<CorrectionReceivingItem>();
49 }
50
51 public void populateCorrectionReceivingFromReceivingLine(LineItemReceivingDocument rlDoc) {
52
53
54 this.setPurchaseOrderIdentifier(rlDoc.getPurchaseOrderIdentifier());
55 this.getDocumentHeader().setDocumentDescription(rlDoc.getDocumentHeader().getDocumentDescription());
56 this.getDocumentHeader().setOrganizationDocumentNumber(rlDoc.getDocumentHeader().getOrganizationDocumentNumber());
57 this.setAccountsPayablePurchasingDocumentLinkIdentifier(rlDoc.getAccountsPayablePurchasingDocumentLinkIdentifier());
58 this.setLineItemReceivingDocumentNumber(rlDoc.getDocumentNumber());
59
60
61 for (LineItemReceivingItem rli : (List<LineItemReceivingItem>) rlDoc.getItems()) {
62 this.getItems().add(new CorrectionReceivingItem(rli, this));
63 }
64
65 }
66
67
68 @Override
69 public void doRouteStatusChange(DocumentRouteStatusChange statusChangeEvent) {
70
71 if (this.getFinancialSystemDocumentHeader().getWorkflowDocument().isProcessed()) {
72 SpringContext.getBean(ReceivingService.class).completeCorrectionReceivingDocument(this);
73 }
74 super.doRouteStatusChange(statusChangeEvent);
75 }
76
77
78
79
80
81
82 public String getLineItemReceivingDocumentNumber() {
83 return lineItemReceivingDocumentNumber;
84 }
85
86
87
88
89
90
91
92 public void setLineItemReceivingDocumentNumber(String lineItemReceivingDocumentNumber) {
93 this.lineItemReceivingDocumentNumber = lineItemReceivingDocumentNumber;
94 }
95
96
97
98
99
100
101 public LineItemReceivingDocument getLineItemReceivingDocument() {
102 refreshLineReceivingDocument();
103 return lineItemReceivingDocument;
104 }
105
106 @Override
107 public void processAfterRetrieve() {
108 super.processAfterRetrieve();
109 refreshLineReceivingDocument();
110 }
111
112 protected void refreshLineReceivingDocument() {
113 if (ObjectUtils.isNull(lineItemReceivingDocument) || lineItemReceivingDocument.getDocumentNumber() == null) {
114 this.refreshReferenceObject("lineItemReceivingDocument");
115 if (ObjectUtils.isNull(lineItemReceivingDocument.getDocumentHeader().getDocumentNumber())) {
116 lineItemReceivingDocument.refreshReferenceObject(OLEPropertyConstants.DOCUMENT_HEADER);
117 }
118 } else {
119 if (ObjectUtils.isNull(lineItemReceivingDocument.getDocumentHeader().getDocumentNumber())) {
120 lineItemReceivingDocument.refreshReferenceObject(OLEPropertyConstants.DOCUMENT_HEADER);
121 }
122 }
123 }
124
125 @Override
126 public Integer getPurchaseOrderIdentifier() {
127 if (ObjectUtils.isNull(super.getPurchaseOrderIdentifier())) {
128 refreshLineReceivingDocument();
129 if (ObjectUtils.isNotNull(lineItemReceivingDocument)) {
130 setPurchaseOrderIdentifier(lineItemReceivingDocument.getPurchaseOrderIdentifier());
131 }
132 }
133 return super.getPurchaseOrderIdentifier();
134 }
135
136
137
138
139
140
141
142 public void setLineItemReceivingDocument(LineItemReceivingDocument lineItemReceivingDocument) {
143 this.lineItemReceivingDocument = lineItemReceivingDocument;
144 }
145
146 @Override
147 public Class getItemClass() {
148 return CorrectionReceivingItem.class;
149 }
150
151 @Override
152 public List getItems() {
153 return items;
154 }
155
156 @Override
157 public void setItems(List items) {
158 this.items = items;
159 }
160
161 @Override
162 public ReceivingItem getItem(int pos) {
163 return (ReceivingItem) items.get(pos);
164 }
165
166 public void addItem(ReceivingItem item) {
167 getItems().add(item);
168 }
169
170 public void deleteItem(int lineNum) {
171 if (getItems().remove(lineNum) == null) {
172
173 }
174 }
175
176 @Override
177 public Integer getAlternateVendorDetailAssignedIdentifier() {
178 return getLineItemReceivingDocument().getAlternateVendorDetailAssignedIdentifier();
179 }
180
181 @Override
182 public Integer getAlternateVendorHeaderGeneratedIdentifier() {
183 return getLineItemReceivingDocument().getAlternateVendorHeaderGeneratedIdentifier();
184 }
185
186 @Override
187 public String getAlternateVendorName() {
188 return getLineItemReceivingDocument().getAlternateVendorName();
189 }
190
191 @Override
192 public String getAlternateVendorNumber() {
193 return getLineItemReceivingDocument().getAlternateVendorNumber();
194 }
195
196 @Override
197 public Carrier getCarrier() {
198 return getLineItemReceivingDocument().getCarrier();
199 }
200
201 @Override
202 public String getCarrierCode() {
203 return getLineItemReceivingDocument().getCarrierCode();
204 }
205
206 @Override
207 public String getDeliveryBuildingCode() {
208 return getLineItemReceivingDocument().getDeliveryBuildingCode();
209 }
210
211 @Override
212 public String getDeliveryBuildingLine1Address() {
213 return getLineItemReceivingDocument().getDeliveryBuildingLine1Address();
214 }
215
216 @Override
217 public String getDeliveryBuildingLine2Address() {
218 return getLineItemReceivingDocument().getDeliveryBuildingLine2Address();
219 }
220
221 @Override
222 public String getDeliveryBuildingName() {
223 return getLineItemReceivingDocument().getDeliveryBuildingName();
224 }
225
226 @Override
227 public String getDeliveryBuildingRoomNumber() {
228 return getLineItemReceivingDocument().getDeliveryBuildingRoomNumber();
229 }
230
231 @Override
232 public CampusParameter getDeliveryCampus() {
233 return getLineItemReceivingDocument().getDeliveryCampus();
234 }
235
236 @Override
237 public String getDeliveryCampusCode() {
238 return getLineItemReceivingDocument().getDeliveryCampusCode();
239 }
240
241 @Override
242 public String getDeliveryCityName() {
243 return getLineItemReceivingDocument().getDeliveryCityName();
244 }
245
246 @Override
247 public String getDeliveryCountryCode() {
248 return getLineItemReceivingDocument().getDeliveryCountryCode();
249 }
250
251 @Override
252 public String getDeliveryInstructionText() {
253 return getLineItemReceivingDocument().getDeliveryInstructionText();
254 }
255
256 @Override
257 public String getDeliveryPostalCode() {
258 return getLineItemReceivingDocument().getDeliveryPostalCode();
259 }
260
261 @Override
262 public Date getDeliveryRequiredDate() {
263 return getLineItemReceivingDocument().getDeliveryRequiredDate();
264 }
265
266 @Override
267 public DeliveryRequiredDateReason getDeliveryRequiredDateReason() {
268 return getLineItemReceivingDocument().getDeliveryRequiredDateReason();
269 }
270
271 @Override
272 public String getDeliveryRequiredDateReasonCode() {
273 return getLineItemReceivingDocument().getDeliveryRequiredDateReasonCode();
274 }
275
276 @Override
277 public String getDeliveryStateCode() {
278 return getLineItemReceivingDocument().getDeliveryStateCode();
279 }
280
281 @Override
282 public String getDeliveryToEmailAddress() {
283 return getLineItemReceivingDocument().getDeliveryToEmailAddress();
284 }
285
286 @Override
287 public String getDeliveryToName() {
288 return getLineItemReceivingDocument().getDeliveryToName();
289 }
290
291 @Override
292 public String getDeliveryToPhoneNumber() {
293 return getLineItemReceivingDocument().getDeliveryToPhoneNumber();
294 }
295
296 @Override
297 public String getShipmentBillOfLadingNumber() {
298 return getLineItemReceivingDocument().getShipmentBillOfLadingNumber();
299 }
300
301 @Override
302 public String getShipmentPackingSlipNumber() {
303 return getLineItemReceivingDocument().getShipmentPackingSlipNumber();
304 }
305
306 @Override
307 public Date getShipmentReceivedDate() {
308 return getLineItemReceivingDocument().getShipmentReceivedDate();
309 }
310
311 @Override
312 public String getShipmentReferenceNumber() {
313 return getLineItemReceivingDocument().getShipmentReferenceNumber();
314 }
315
316 @Override
317 public Integer getVendorAddressGeneratedIdentifier() {
318 return getLineItemReceivingDocument().getVendorAddressGeneratedIdentifier();
319 }
320
321 @Override
322 public String getVendorCityName() {
323 return getLineItemReceivingDocument().getVendorCityName();
324 }
325
326 @Override
327 public CountryEbo getVendorCountry() {
328 return getLineItemReceivingDocument().getVendorCountry();
329 }
330
331 @Override
332 public String getVendorCountryCode() {
333 return getLineItemReceivingDocument().getVendorCountryCode();
334 }
335
336 @Override
337 public VendorDetail getVendorDetail() {
338 return getLineItemReceivingDocument().getVendorDetail();
339 }
340
341 @Override
342 public Integer getVendorDetailAssignedIdentifier() {
343 return getLineItemReceivingDocument().getVendorDetailAssignedIdentifier();
344 }
345
346 @Override
347 public Integer getVendorHeaderGeneratedIdentifier() {
348 return getLineItemReceivingDocument().getVendorHeaderGeneratedIdentifier();
349 }
350
351 @Override
352 public String getVendorLine1Address() {
353 return getLineItemReceivingDocument().getVendorLine1Address();
354 }
355
356 @Override
357 public String getVendorLine2Address() {
358 return getLineItemReceivingDocument().getVendorLine2Address();
359 }
360
361 @Override
362 public String getVendorName() {
363 return getLineItemReceivingDocument().getVendorName();
364 }
365
366 @Override
367 public String getVendorNumber() {
368 return getLineItemReceivingDocument().getVendorNumber();
369 }
370
371 @Override
372 public String getVendorPostalCode() {
373 return getLineItemReceivingDocument().getVendorPostalCode();
374 }
375
376 @Override
377 public String getVendorStateCode() {
378 return getLineItemReceivingDocument().getVendorStateCode();
379 }
380
381 @Override
382 public List buildListOfDeletionAwareLists() {
383 List managedLists = super.buildListOfDeletionAwareLists();
384 managedLists.add(this.getItems());
385 return managedLists;
386 }
387
388 }