1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.kuali.ole.module.purap.businessobject;
21
22 import org.apache.commons.lang.StringUtils;
23 import org.apache.commons.lang.builder.ToStringBuilder;
24 import org.kuali.ole.module.purap.util.ElectronicInvoiceUtils;
25 import org.kuali.ole.module.purap.util.cxml.CxmlExtrinsic;
26 import org.kuali.ole.sys.util.KfsDateUtils;
27
28 import java.util.ArrayList;
29 import java.util.Date;
30 import java.util.Iterator;
31 import java.util.List;
32
33 public class ElectronicInvoiceDetailRequestHeader {
34 private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(ElectronicInvoiceDetailRequestHeader.class);
35
36 private String invoiceId;
37 private String purpose = "standard";
38 private String operation = "new";
39 private String invoiceDateString;
40 private java.util.Date invoiceDate;
41
42 private boolean isInformationOnly;
43 private boolean isHeaderInvoiceIndicator;
44 private boolean isTaxInLine;
45 private boolean isSpecialHandlingInLine;
46 private boolean isShippingInLine;
47 private boolean isDiscountInLine;
48 private String shippingDateString;
49 private java.util.Date shippingDate;
50 private String invoiceCustomerNumber;
51
52 private List invoicePartnerContacts = new ArrayList();
53 private List invoiceShippingContacts = new ArrayList();
54 private List extrinsics = new ArrayList();
55
56
57
58
59 private boolean isAccountingInLine;
60 private String idReferenceCreator;
61 private String idReferenceDescription;
62 private String idReferenceDomain;
63 private String idReferenceIdentifier;
64 private int payInNumberOfDays;
65 private String percentageRate;
66
67 public ElectronicInvoiceDetailRequestHeader() {
68 super();
69 }
70
71
72
73
74
75
76
77 public ElectronicInvoiceDetailRequestHeader(String invoiceId, String invoiceDate, String purpose, String operation) {
78 super();
79 this.invoiceId = invoiceId;
80 this.purpose = purpose;
81 this.operation = operation;
82 this.setInvoiceDateString(invoiceDate);
83 }
84
85
86
87
88
89
90
91
92
93
94
95 public ElectronicInvoicePostalAddress getCxmlPostalAddressByRoleID(String roleID, String addressName) {
96 if (roleID != null) {
97 ElectronicInvoiceContact contact = this.getCxmlContactByRoleID(roleID);
98 if (contact != null) {
99 for (Iterator iterator = contact.getPostalAddresses().iterator(); iterator.hasNext(); ) {
100 ElectronicInvoicePostalAddress cpa = (ElectronicInvoicePostalAddress) iterator.next();
101 if (addressName == null) {
102 return cpa;
103 } else {
104 if (addressName.equalsIgnoreCase(cpa.getName())) {
105 return cpa;
106 }
107 }
108 }
109 }
110 }
111 return null;
112 }
113
114
115
116
117
118
119
120
121 public ElectronicInvoiceContact getCxmlContactByRoleID(String roleID) {
122 if (roleID != null) {
123 for (Iterator iter = this.invoicePartnerContacts.iterator(); iter.hasNext(); ) {
124 ElectronicInvoiceContact contact = (ElectronicInvoiceContact) iter.next();
125 if (roleID.equalsIgnoreCase(contact.getRole())) {
126 return contact;
127 }
128 }
129 for (Iterator shipIter = this.invoiceShippingContacts.iterator(); shipIter.hasNext(); ) {
130 ElectronicInvoiceContact shipContact = (ElectronicInvoiceContact) shipIter.next();
131 if (roleID.equalsIgnoreCase(shipContact.getRole())) {
132 return shipContact;
133 }
134 }
135 }
136 return null;
137 }
138
139
140
141
142 public String getInvoiceDateString() {
143 return invoiceDateString;
144 }
145
146
147
148
149 public void setInvoiceDateString(String invoiceDateString) {
150 this.invoiceDateString = invoiceDateString;
151 setInvoiceDate(ElectronicInvoiceUtils.getDate(invoiceDateString));
152 }
153
154
155
156
157 public String getShippingDateString() {
158 return shippingDateString;
159 }
160
161
162
163
164 public void setShippingDateString(String shippingDateString) {
165 this.shippingDateString = shippingDateString;
166
167
168
169
170
171
172
173
174
175
176
177
178 setShippingDate(ElectronicInvoiceUtils.getDate(shippingDateString));
179 }
180
181
182
183
184 public List getExtrinsics() {
185 return extrinsics;
186 }
187
188
189
190
191 public void setExtrinsics(List extrinsics) {
192 this.extrinsics = extrinsics;
193 }
194
195
196
197
198 public String getInvoiceCustomerNumber() {
199 return invoiceCustomerNumber;
200 }
201
202
203
204
205 public void setInvoiceCustomerNumber(String invoiceCustomerNumber) {
206 this.invoiceCustomerNumber = invoiceCustomerNumber;
207 }
208
209
210
211
212 public java.sql.Date getInvoiceDate() {
213 if (invoiceDate != null) {
214 return KfsDateUtils.convertToSqlDate(invoiceDate);
215 } else {
216 return null;
217 }
218 }
219
220
221
222
223 public void setInvoiceDate(Date invoiceDate) {
224 this.invoiceDate = invoiceDate;
225 }
226
227
228
229
230 public String getInvoiceId() {
231 return invoiceId;
232 }
233
234
235
236
237 public void setInvoiceId(String invoiceId) {
238 this.invoiceId = invoiceId;
239 }
240
241
242
243
244 public List getInvoicePartnerContacts() {
245 return invoicePartnerContacts;
246 }
247
248
249
250
251 public void setInvoicePartnerContacts(List invoicePartnerContacts) {
252 this.invoicePartnerContacts = invoicePartnerContacts;
253 }
254
255
256
257
258 public List getInvoiceShippingContacts() {
259 return invoiceShippingContacts;
260 }
261
262
263
264
265 public void setInvoiceShippingContacts(List invoiceShippingContacts) {
266 this.invoiceShippingContacts = invoiceShippingContacts;
267 }
268
269
270
271
272 public boolean isDiscountInLine() {
273 return isDiscountInLine;
274 }
275
276
277
278
279 public void setDiscountInfoProvidedIndicator(String isDiscountInLine) {
280 this.isDiscountInLine = StringUtils.equalsIgnoreCase(StringUtils.defaultString(isDiscountInLine), "yes");
281 ;
282 }
283
284
285
286
287 public boolean isHeaderInvoiceIndicator() {
288 return isHeaderInvoiceIndicator;
289 }
290
291
292
293
294 public void setHeaderInvoiceInd(String isHeaderInvoiceIndicator) {
295 this.isHeaderInvoiceIndicator = StringUtils.equalsIgnoreCase(StringUtils.defaultString(isHeaderInvoiceIndicator), "yes");
296 }
297
298
299
300
301 public boolean isInformationOnly() {
302 return isInformationOnly;
303 }
304
305
306
307
308 public void setbuyerInformationOnlyIndicator(String informationOnly) {
309
310
311
312 this.isInformationOnly = StringUtils.equalsIgnoreCase(StringUtils.defaultString(informationOnly), "yes");
313 }
314
315
316
317
318 public boolean isShippingInLine() {
319 return isShippingInLine;
320 }
321
322
323
324
325 public void setShippingInfoProvidedIndicator(String isShippingInLine) {
326 this.isShippingInLine = StringUtils.equalsIgnoreCase(StringUtils.defaultString(isShippingInLine), "yes");
327 }
328
329
330
331
332 public boolean isSpecialHandlingInLine() {
333 return isSpecialHandlingInLine;
334 }
335
336
337
338
339 public void setSpecialHandlingInfoProvidedIndicator(String isSpecialHandlingInLine) {
340 this.isSpecialHandlingInLine = StringUtils.equalsIgnoreCase(StringUtils.defaultString(isSpecialHandlingInLine), "yes");
341 }
342
343
344
345
346 public boolean isTaxInLine() {
347 return isTaxInLine;
348 }
349
350
351
352
353 public void setTaxInfoProvidedIndicator(String isTaxInLine) {
354 this.isTaxInLine = StringUtils.equalsIgnoreCase(StringUtils.defaultString(isTaxInLine), "yes");
355 }
356
357
358
359
360 public String getOperation() {
361 return operation;
362 }
363
364
365
366
367 public void setOperation(String operation) {
368 this.operation = operation;
369 }
370
371
372
373
374 public String getPurpose() {
375 return purpose;
376 }
377
378
379
380
381 public void setPurpose(String purpose) {
382 this.purpose = purpose;
383 }
384
385
386
387
388 public Date getShippingDate() {
389 return shippingDate;
390 }
391
392
393
394
395 public void setShippingDate(Date shippingDate) {
396 this.shippingDate = shippingDate;
397 }
398
399 public boolean isAccountingInLine() {
400 return isAccountingInLine;
401 }
402
403 public void setAccountingInfoProvidedIndicator(String isAccountingInLine) {
404 this.isAccountingInLine = StringUtils.equalsIgnoreCase(StringUtils.defaultString(isAccountingInLine), "yes");
405 ;
406 }
407
408 public String getIdReferenceCreator() {
409 return idReferenceCreator;
410 }
411
412 public void setIdReferenceCreator(String idReferenceCreator) {
413 this.idReferenceCreator = idReferenceCreator;
414 }
415
416 public String getIdReferenceDescription() {
417 return idReferenceDescription;
418 }
419
420 public void setIdReferenceDescription(String idReferenceDescription) {
421 this.idReferenceDescription = idReferenceDescription;
422 }
423
424 public String getIdReferenceDomain() {
425 return idReferenceDomain;
426 }
427
428 public void setIdReferenceDomain(String idReferenceDomain) {
429 this.idReferenceDomain = idReferenceDomain;
430 }
431
432 public String getIdReferenceIdentifier() {
433 return idReferenceIdentifier;
434 }
435
436 public void setIdReferenceIdentifier(String idReferenceIdentifier) {
437 this.idReferenceIdentifier = idReferenceIdentifier;
438 }
439
440 public void addInvoicePartnerContact(ElectronicInvoiceContact electronicInvoiceContact) {
441 if (electronicInvoiceContact != null) {
442 invoicePartnerContacts.add(electronicInvoiceContact);
443 }
444 }
445
446 public ElectronicInvoiceContact[] getInvoicePartnerContactsAsArray() {
447 if (invoicePartnerContacts.size() > 0) {
448 ElectronicInvoiceContact[] tempContacts = new ElectronicInvoiceContact[invoicePartnerContacts.size()];
449 invoicePartnerContacts.toArray(tempContacts);
450 return tempContacts;
451 }
452 return null;
453 }
454
455 public void addInvoiceShippingContacts(ElectronicInvoiceContact electronicInvoiceContact) {
456 invoiceShippingContacts.add(electronicInvoiceContact);
457 }
458
459 public ElectronicInvoiceContact[] getInvoiceShippingContactsAsArray() {
460 if (invoiceShippingContacts.size() > 0) {
461 ElectronicInvoiceContact[] tempContacts = new ElectronicInvoiceContact[invoiceShippingContacts.size()];
462 invoiceShippingContacts.toArray(tempContacts);
463 return tempContacts;
464 }
465 return null;
466 }
467
468 public void addExtrinsic(CxmlExtrinsic extrinsic) {
469 this.extrinsics.add(extrinsic);
470 }
471
472 public CxmlExtrinsic[] getExtrinsicAsArray() {
473 if (extrinsics.size() > 0) {
474 CxmlExtrinsic[] extrinsics = new CxmlExtrinsic[this.extrinsics.size()];
475 this.extrinsics.toArray(extrinsics);
476 return extrinsics;
477 }
478 return null;
479 }
480
481 public int getPayInNumberOfDays() {
482 return payInNumberOfDays;
483 }
484
485 public void setPayInNumberOfDays(int payInNumberOfDays) {
486 this.payInNumberOfDays = payInNumberOfDays;
487 }
488
489 public String getPercentageRate() {
490 return percentageRate;
491 }
492
493 public void setPercentageRate(String percentageRate) {
494 this.percentageRate = percentageRate;
495 }
496
497 public String toString() {
498
499 ToStringBuilder toString = new ToStringBuilder(this);
500
501 toString.append("invoiceID", getInvoiceId());
502 toString.append("purpose", getPurpose());
503 toString.append("operation", getOperation());
504 toString.append("invoiceDate", getInvoiceDateString());
505
506 toString.append("isInformationOnly", isInformationOnly());
507 toString.append("isHeaderInvoiceIndicator", isHeaderInvoiceIndicator());
508 toString.append("isTaxInLine", isTaxInLine());
509 toString.append("isSpecialHandlingInLine", isSpecialHandlingInLine());
510 toString.append("isShippingInLine", isShippingInLine());
511 toString.append("isDiscountInLine", isDiscountInLine());
512 toString.append("isAccountingInLine", isAccountingInLine());
513
514 toString.append("idReferenceCreator", getIdReferenceCreator());
515 toString.append("idReferenceDescription", getIdReferenceDescription());
516 toString.append("idReferenceDomain", getIdReferenceDomain());
517 toString.append("idReferenceIdentifier", getIdReferenceIdentifier());
518
519
520 toString.append("shippingDate", getShippingDateString());
521 toString.append("invoiceCustomerNumber", getInvoiceCustomerNumber());
522 toString.append("payInNumberOfDays", getPayInNumberOfDays());
523 toString.append("percentageRate", getPercentageRate());
524
525 toString.append("invoicePartnerContacts", getInvoicePartnerContacts());
526 toString.append("invoiceShippingContacts", getInvoiceShippingContacts());
527 toString.append("extrinsics", getExtrinsics());
528
529 return toString.toString();
530 }
531
532
533 }
534