View Javadoc
1   /*
2    * Copyright 2005-2006 The Kuali Foundation
3    * 
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    * http://www.opensource.org/licenses/ecl2.php
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.kuali.ole.fp.businessobject;
18  
19  import java.util.HashMap;
20  import java.util.LinkedHashMap;
21  import java.util.Map;
22  
23  import org.apache.commons.lang.StringUtils;
24  import org.kuali.ole.fp.document.service.DisbursementVoucherPayeeService;
25  import org.kuali.ole.sys.OLEConstants;
26  import org.kuali.ole.sys.OLEPropertyConstants;
27  import org.kuali.ole.sys.context.SpringContext;
28  import org.kuali.ole.vnd.document.service.VendorService;
29  import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
30  import org.kuali.rice.krad.service.KualiModuleService;
31  import org.kuali.rice.krad.service.ModuleService;
32  import org.kuali.rice.krad.util.ObjectUtils;
33  import org.kuali.rice.location.api.LocationConstants;
34  import org.kuali.rice.location.framework.country.CountryEbo;
35  import org.kuali.rice.location.framework.postalcode.PostalCodeEbo;
36  import org.kuali.rice.location.framework.state.StateEbo;
37  
38  /**
39   * This class is used to represent a disbursement voucher payee detail.
40   */
41  public class DisbursementVoucherPayeeDetail extends PersistableBusinessObjectBase {
42  
43      private String documentNumber;
44      private String disbVchrPaymentReasonCode;
45  
46      private String disbVchrPayeeIdNumber;
47      private String disbVchrPayeePersonName;
48  
49      private String disbVchrPayeeLine1Addr;
50      private String disbVchrPayeeLine2Addr;
51      private String disbVchrPayeeCityName;
52      private String disbVchrPayeeStateCode;
53      private String disbVchrPayeeZipCode;
54      private String disbVchrPayeeCountryCode;
55  
56      private String disbVchrSpecialHandlingPersonName;
57      private String disbVchrSpecialHandlingLine1Addr;
58      private String disbVchrSpecialHandlingLine2Addr;
59      private String disbVchrSpecialHandlingCityName;
60      private String disbVchrSpecialHandlingStateCode;
61      private String disbVchrSpecialHandlingZipCode;
62      private String disbVchrSpecialHandlingCountryCode;
63  
64      private Boolean dvPayeeSubjectPaymentCode;
65      private Boolean disbVchrAlienPaymentCode;
66      private Boolean disbVchrPayeeEmployeeCode;
67      private Boolean disbVchrEmployeePaidOutsidePayrollCode;
68      private String disbursementVoucherPayeeTypeCode;
69  
70      private PaymentReasonCode disbVchrPaymentReason;
71  
72      // The following vendor-associated attributes are for convenience only and are not mapped to OJB or the DB.
73      private String disbVchrVendorHeaderIdNumber;
74      private String disbVchrVendorDetailAssignedIdNumber;
75      private String disbVchrVendorAddressIdNumber;
76      private boolean hasMultipleVendorAddresses = false;
77      
78      private StateEbo disbVchrPayeeState;
79      private CountryEbo disbVchrPayeeCountry;    
80      private PostalCodeEbo disbVchrPayeePostalZipCode;
81  
82      /**
83       * Default no-arg constructor.
84       */
85      public DisbursementVoucherPayeeDetail() {
86          super();
87      }
88  
89      /**
90       * Gets the documentNumber attribute.
91       * 
92       * @return Returns the documentNumber
93       */
94      public String getDocumentNumber() {
95          return documentNumber;
96      }
97  
98  
99      /**
100      * Sets the documentNumber attribute.
101      * 
102      * @param documentNumber The documentNumber to set.
103      */
104     public void setDocumentNumber(String documentNumber) {
105         this.documentNumber = documentNumber;
106     }
107 
108     /**
109      * Gets the disbVchrPaymentReasonCode attribute.
110      * 
111      * @return Returns the disbVchrPaymentReasonCode
112      */
113     public String getDisbVchrPaymentReasonCode() {
114         return disbVchrPaymentReasonCode;
115     }
116 
117 
118     /**
119      * Sets the disbVchrPaymentReasonCode attribute.
120      * 
121      * @param disbVchrPaymentReasonCode The disbVchrPaymentReasonCode to set.
122      */
123     public void setDisbVchrPaymentReasonCode(String disbVchrPaymentReasonCode) {
124         this.disbVchrPaymentReasonCode = disbVchrPaymentReasonCode;
125     }
126 
127     /**
128      * Gets the disbVchrPayeeIdNumber attribute.
129      * 
130      * @return Returns the disbVchrVendorIdNumber
131      */
132     public String getDisbVchrPayeeIdNumber() {
133         return disbVchrPayeeIdNumber;
134     }
135 
136 
137     /**
138      * Sets the disbVchrPayeeIdNumber attribute.
139      * 
140      * @param disbVchrPayeeIdNumber The disbVchrPayeeIdNumber to set.
141      */
142     public void setDisbVchrPayeeIdNumber(String disbVchrPayeeIdNumber) {
143         this.disbVchrPayeeIdNumber = disbVchrPayeeIdNumber;
144         // KFSMI-5976 : Blanking out these fields so they are re-derived upon next access 
145         disbVchrVendorHeaderIdNumber = null;
146         disbVchrVendorDetailAssignedIdNumber = null;
147     }
148 
149     /**
150      * This method...
151      * 
152      * @return
153      */
154     public String getDisbVchrVendorHeaderIdNumber() {
155         if (this.isVendor()) {
156             if (StringUtils.isBlank(disbVchrVendorHeaderIdNumber)) {
157                 int dashIndex = disbVchrPayeeIdNumber.indexOf('-');
158                 disbVchrVendorHeaderIdNumber = disbVchrPayeeIdNumber.substring(0, dashIndex);
159             }
160         }
161         else { // Return null if payee is not a vendor
162             return null;
163         }
164         return disbVchrVendorHeaderIdNumber;
165     }
166 
167     /**
168      * This method...
169      * 
170      * @param disbVchrVendorheaderIdNumber
171      */
172     public void setDisbVchrVendorHeaderIdNumber(String disbVchrVendorHeaderIdNumber) {
173         if (this.isVendor()) {
174             this.disbVchrVendorHeaderIdNumber = disbVchrVendorHeaderIdNumber;
175         }
176     }
177 
178     /**
179      * Gets the disbVchrVendorIdNumber attribute as an Integer.
180      * 
181      * @return Returns the disbVchrVendorIdNumber in Integer form. This is the format used on the VendorDetail.
182      */
183     public Integer getDisbVchrVendorHeaderIdNumberAsInteger() {
184         if (getDisbVchrVendorHeaderIdNumber() != null)
185             try {
186                 return new Integer(getDisbVchrVendorHeaderIdNumber());
187             }
188             catch (NumberFormatException nfe) {
189                 nfe.printStackTrace();
190             }
191         return null;
192     }
193 
194     /**
195      * This method...
196      * 
197      * @return
198      */
199     public String getDisbVchrVendorDetailAssignedIdNumber() {
200         if (this.isVendor()) {
201             if (StringUtils.isBlank(disbVchrVendorDetailAssignedIdNumber)) {
202                 int dashIndex = disbVchrPayeeIdNumber.indexOf('-');
203                 disbVchrVendorDetailAssignedIdNumber = disbVchrPayeeIdNumber.substring(dashIndex + 1);
204             }
205         }
206         else { // Return null if payee is not a vendor
207             return null;
208         }
209         return disbVchrVendorDetailAssignedIdNumber;
210     }
211 
212     /**
213      * This method...
214      * 
215      * @param disbVchrVendorDetailAssignedIdNumber
216      */
217     public void setDisbVchrVendorDetailAssignedIdNumber(String disbVchrVendorDetailAssignedIdNumber) {
218         // This field should only be set if the payee type is "V", otherwise, ignore any calls
219         if (this.isVendor()) {
220             this.disbVchrVendorDetailAssignedIdNumber = disbVchrVendorDetailAssignedIdNumber;
221         }
222     }
223 
224     /**
225      * This method...
226      * 
227      * @return
228      */
229     public Integer getDisbVchrVendorDetailAssignedIdNumberAsInteger() {
230         if (getDisbVchrVendorDetailAssignedIdNumber() != null)
231             try {
232                 return new Integer(getDisbVchrVendorDetailAssignedIdNumber());
233             }
234             catch (NumberFormatException nfe) {
235                 nfe.printStackTrace();
236             }
237         return null;
238     }
239 
240     /**
241      * This method should only be called for retrieving the id associated with the payee if the payee type is equal to "E".
242      * Otherwise, this method will return null.
243      * 
244      * @return The id of the universal user set as the payee on the DV, if the payee type code indicates the payee is an employee.
245      *         Otherwise, this method will return null.
246      */
247     public String getDisbVchrEmployeeIdNumber() {
248         if (this.isEmployee()) {
249             return disbVchrPayeeIdNumber;
250         }
251         else { // Return null if payee is not a employee
252             return null;
253         }
254     }
255 
256     /**
257      * Gets the disbVchrPayeePersonName attribute.
258      * 
259      * @return Returns the disbVchrPayeePersonName
260      */
261     public String getDisbVchrPayeePersonName() {
262         return disbVchrPayeePersonName;
263     }
264 
265     /**
266      * Sets the disbVchrPayeePersonName attribute.
267      * 
268      * @param disbVchrPayeePersonName The disbVchrPayeePersonName to set.
269      */
270     public void setDisbVchrPayeePersonName(String disbVchrPayeePersonName) {
271         this.disbVchrPayeePersonName = disbVchrPayeePersonName;
272     }
273 
274     /**
275      * Gets the disbVchrPayeeLine1Addr attribute.
276      * 
277      * @return Returns the disbVchrPayeeLine1Addr
278      */
279     public String getDisbVchrPayeeLine1Addr() {
280         return disbVchrPayeeLine1Addr;
281     }
282 
283     /**
284      * Sets the disbVchrPayeeLine1Addr attribute.
285      * 
286      * @param disbVchrPayeeLine1Addr The disbVchrPayeeLine1Addr to set.
287      */
288     public void setDisbVchrPayeeLine1Addr(String disbVchrPayeeLine1Addr) {
289         this.disbVchrPayeeLine1Addr = disbVchrPayeeLine1Addr;
290     }
291 
292     /**
293      * Gets the disbVchrPayeeLine2Addr attribute.
294      * 
295      * @return Returns the disbVchrPayeeLine2Addr
296      */
297     public String getDisbVchrPayeeLine2Addr() {
298         return disbVchrPayeeLine2Addr;
299     }
300 
301     /**
302      * Sets the disbVchrPayeeLine2Addr attribute.
303      * 
304      * @param disbVchrPayeeLine2Addr The disbVchrPayeeLine2Addr to set.
305      */
306     public void setDisbVchrPayeeLine2Addr(String disbVchrPayeeLine2Addr) {
307         this.disbVchrPayeeLine2Addr = disbVchrPayeeLine2Addr;
308     }
309 
310     /**
311      * Gets the disbVchrPayeeCityName attribute.
312      * 
313      * @return Returns the disbVchrPayeeCityName
314      */
315     public String getDisbVchrPayeeCityName() {
316         return disbVchrPayeeCityName;
317     }
318 
319 
320     /**
321      * Sets the disbVchrPayeeCityName attribute.
322      * 
323      * @param disbVchrPayeeCityName The disbVchrPayeeCityName to set.
324      */
325     public void setDisbVchrPayeeCityName(String disbVchrPayeeCityName) {
326         this.disbVchrPayeeCityName = disbVchrPayeeCityName;
327     }
328 
329     /**
330      * Gets the disbVchrPayeeStateCode attribute.
331      * 
332      * @return Returns the disbVchrPayeeStateCode
333      */
334     public String getDisbVchrPayeeStateCode() {
335         return disbVchrPayeeStateCode;
336     }
337 
338 
339     /**
340      * Sets the disbVchrPayeeStateCode attribute.
341      * 
342      * @param disbVchrPayeeStateCode The disbVchrPayeeStateCode to set.
343      */
344     public void setDisbVchrPayeeStateCode(String disbVchrPayeeStateCode) {
345         this.disbVchrPayeeStateCode = disbVchrPayeeStateCode;
346     }
347 
348     /**
349      * Gets the disbVchrPayeeZipCode attribute.
350      * 
351      * @return Returns the disbVchrPayeeZipCode
352      */
353     public String getDisbVchrPayeeZipCode() {
354         return disbVchrPayeeZipCode;
355     }
356 
357 
358     /**
359      * Sets the disbVchrPayeeZipCode attribute.
360      * 
361      * @param disbVchrPayeeZipCode The disbVchrPayeeZipCode to set.
362      */
363     public void setDisbVchrPayeeZipCode(String disbVchrPayeeZipCode) {
364         this.disbVchrPayeeZipCode = disbVchrPayeeZipCode;
365     }
366 
367     /**
368      * Gets the disbVchrPayeeCountryCode attribute.
369      * 
370      * @return Returns the disbVchrPayeeCountryCode
371      */
372     public String getDisbVchrPayeeCountryCode() {
373         return disbVchrPayeeCountryCode;
374     }
375 
376 
377     /**
378      * Sets the disbVchrPayeeCountryCode attribute.
379      * 
380      * @param disbVchrPayeeCountryCode The disbVchrPayeeCountryCode to set.
381      */
382     public void setDisbVchrPayeeCountryCode(String disbVchrPayeeCountryCode) {
383         this.disbVchrPayeeCountryCode = disbVchrPayeeCountryCode;
384     }
385 
386     /**
387      * Gets the disbVchrSpecialHandlingPersonName attribute.
388      * 
389      * @return Returns the disbVchrSpecialHandlingPersonName
390      */
391     public String getDisbVchrSpecialHandlingPersonName() {
392         return disbVchrSpecialHandlingPersonName;
393     }
394 
395 
396     /**
397      * Sets the disbVchrSpecialHandlingPersonName attribute.
398      * 
399      * @param disbVchrSpecialHandlingPersonName The disbVchrSpecialHandlingPersonName to set.
400      */
401     public void setDisbVchrSpecialHandlingPersonName(String disbVchrSpecialHandlingPersonName) {
402         this.disbVchrSpecialHandlingPersonName = disbVchrSpecialHandlingPersonName;
403     }
404 
405     /**
406      * Gets the disbVchrSpecialHandlingLine1Addr attribute.
407      * 
408      * @return Returns the disbVchrSpecialHandlingLine1Addr
409      */
410     public String getDisbVchrSpecialHandlingLine1Addr() {
411         return disbVchrSpecialHandlingLine1Addr;
412     }
413 
414 
415     /**
416      * Sets the disbVchrSpecialHandlingLine1Addr attribute.
417      * 
418      * @param disbVchrSpecialHandlingLine1Addr The disbVchrSpecialHandlingLine1Addr to set.
419      */
420     public void setDisbVchrSpecialHandlingLine1Addr(String disbVchrSpecialHandlingLine1Addr) {
421         this.disbVchrSpecialHandlingLine1Addr = disbVchrSpecialHandlingLine1Addr;
422     }
423 
424     /**
425      * Gets the disbVchrSpecialHandlingLine2Addr attribute.
426      * 
427      * @return Returns the disbVchrSpecialHandlingLine2Addr
428      */
429     public String getDisbVchrSpecialHandlingLine2Addr() {
430         return disbVchrSpecialHandlingLine2Addr;
431     }
432 
433 
434     /**
435      * Sets the disbVchrSpecialHandlingLine2Addr attribute.
436      * 
437      * @param disbVchrSpecialHandlingLine2Addr The disbVchrSpecialHandlingLine2Addr to set.
438      */
439     public void setDisbVchrSpecialHandlingLine2Addr(String disbVchrSpecialHandlingLine2Addr) {
440         this.disbVchrSpecialHandlingLine2Addr = disbVchrSpecialHandlingLine2Addr;
441     }
442 
443     /**
444      * Gets the disbVchrSpecialHandlingCityName attribute.
445      * 
446      * @return Returns the disbVchrSpecialHandlingCityName
447      */
448     public String getDisbVchrSpecialHandlingCityName() {
449         return disbVchrSpecialHandlingCityName;
450     }
451 
452 
453     /**
454      * Sets the disbVchrSpecialHandlingCityName attribute.
455      * 
456      * @param disbVchrSpecialHandlingCityName The disbVchrSpecialHandlingCityName to set.
457      */
458     public void setDisbVchrSpecialHandlingCityName(String disbVchrSpecialHandlingCityName) {
459         this.disbVchrSpecialHandlingCityName = disbVchrSpecialHandlingCityName;
460     }
461 
462     /**
463      * Gets the disbVchrSpecialHandlingStateCode attribute.
464      * 
465      * @return Returns the disbVchrSpecialHandlingStateCode
466      */
467     public String getDisbVchrSpecialHandlingStateCode() {
468         return disbVchrSpecialHandlingStateCode;
469     }
470 
471 
472     /**
473      * Sets the disbVchrSpecialHandlingStateCode attribute.
474      * 
475      * @param disbVchrSpecialHandlingStateCode The disbVchrSpecialHandlingStateCode to set.
476      */
477     public void setDisbVchrSpecialHandlingStateCode(String disbVchrSpecialHandlingStateCode) {
478         this.disbVchrSpecialHandlingStateCode = disbVchrSpecialHandlingStateCode;
479     }
480 
481     /**
482      * Gets the disbVchrSpecialHandlingZipCode attribute.
483      * 
484      * @return Returns the disbVchrSpecialHandlingZipCode
485      */
486     public String getDisbVchrSpecialHandlingZipCode() {
487         return disbVchrSpecialHandlingZipCode;
488     }
489 
490 
491     /**
492      * Sets the disbVchrSpecialHandlingZipCode attribute.
493      * 
494      * @param disbVchrSpecialHandlingZipCode The disbVchrSpecialHandlingZipCode to set.
495      */
496     public void setDisbVchrSpecialHandlingZipCode(String disbVchrSpecialHandlingZipCode) {
497         this.disbVchrSpecialHandlingZipCode = disbVchrSpecialHandlingZipCode;
498     }
499 
500     /**
501      * Gets the disbVchrSpecialHandlingCountryCode attribute.
502      * 
503      * @return Returns the disbVchrSpecialHandlingCountryCode
504      */
505     public String getDisbVchrSpecialHandlingCountryCode() {
506         return disbVchrSpecialHandlingCountryCode;
507     }
508 
509 
510     /**
511      * Sets the disbVchrSpecialHandlingCountryCode attribute.
512      * 
513      * @param disbVchrSpecialHandlingCountryCode The disbVchrSpecialHandlingCountryCode to set.
514      */
515     public void setDisbVchrSpecialHandlingCountryCode(String disbVchrSpecialHandlingCountryCode) {
516         this.disbVchrSpecialHandlingCountryCode = disbVchrSpecialHandlingCountryCode;
517     }
518 
519     /**
520      * Gets the disbVchrPayeeEmployeeCode attribute.
521      * 
522      * @return Returns true if the vendor associated with this DV is an employee of the institution.
523      */
524     public boolean isDisbVchrPayeeEmployeeCode() {
525         if (ObjectUtils.isNull(disbVchrPayeeEmployeeCode)) {
526             if (this.isEmployee()) {
527                 disbVchrPayeeEmployeeCode = true;
528             }
529             else if (this.isVendor()) {
530                 try {
531                     disbVchrPayeeEmployeeCode = SpringContext.getBean(VendorService.class).isVendorInstitutionEmployee(getDisbVchrVendorHeaderIdNumberAsInteger());
532                     this.setDisbVchrEmployeePaidOutsidePayrollCode(disbVchrPayeeEmployeeCode);
533                 }
534                 catch (Exception ex) {
535                     disbVchrPayeeEmployeeCode = false;
536                     ex.printStackTrace();
537                 }
538             }
539         }
540         return disbVchrPayeeEmployeeCode;
541     }
542 
543 
544     /**
545      * Sets the disbVchrPayeeEmployeeCode attribute.
546      * 
547      * @param disbVchrPayeeEmployeeCode The disbVchrPayeeEmployeeCode to set.
548      */
549     public void setDisbVchrPayeeEmployeeCode(boolean disbVchrPayeeEmployeeCode) {
550         this.disbVchrPayeeEmployeeCode = disbVchrPayeeEmployeeCode;
551     }
552 
553     /**
554      * Gets the disbVchrAlienPaymentCode attribute.
555      * 
556      * @return Returns the disbVchrAlienPaymentCode
557      */
558     public boolean isDisbVchrAlienPaymentCode() {
559         if (StringUtils.isNotBlank(this.getDisbVchrEmployeeIdNumber()) && this.isVendor()) {
560             try {
561                 disbVchrAlienPaymentCode = SpringContext.getBean(VendorService.class).isVendorForeign(getDisbVchrVendorHeaderIdNumberAsInteger());
562             }
563             catch (Exception ex) {
564                 disbVchrAlienPaymentCode = false;
565                 ex.printStackTrace();
566             }
567         }
568 
569         return ObjectUtils.isNull(disbVchrAlienPaymentCode) ? false : disbVchrAlienPaymentCode;
570     }
571 
572 
573     /**
574      * Sets the disbVchrAlienPaymentCode attribute.
575      * 
576      * @param disbVchrAlienPaymentCode The disbVchrAlienPaymentCode to set.
577      */
578     public void setDisbVchrAlienPaymentCode(boolean disbVchrAlienPaymentCode) {
579         this.disbVchrAlienPaymentCode = disbVchrAlienPaymentCode;
580     }
581 
582     /**
583      * Gets the dvPayeeSubjectPayment attribute.
584      * 
585      * @return Returns the dvPayeeSubjectPayment
586      */
587     public boolean isDvPayeeSubjectPaymentCode() {
588         if (ObjectUtils.isNull(dvPayeeSubjectPaymentCode) && (getDisbVchrVendorHeaderIdNumberAsInteger() != null)) {
589             dvPayeeSubjectPaymentCode = SpringContext.getBean(VendorService.class).isSubjectPaymentVendor(getDisbVchrVendorHeaderIdNumberAsInteger());
590         }
591         return dvPayeeSubjectPaymentCode;
592     }
593 
594     /**
595      * Sets the dvPayeeSubjectPayment attribute.
596      * 
597      * @param dvPayeeSubjectPayment The dvPayeeSubjectPayment to set.
598      */
599     public void setDvPayeeSubjectPaymentCode(boolean dvPayeeSubjectPaymentCode) {
600         this.dvPayeeSubjectPaymentCode = dvPayeeSubjectPaymentCode;
601     }
602 
603     /**
604      * Gets the disbVchrEmployeePaidOutsidePayrollCode attribute.
605      * 
606      * @return Returns the disbVchrEmployeePaidOutsidePayrollCode.
607      */
608     public boolean isDisbVchrEmployeePaidOutsidePayrollCode() {
609         return disbVchrEmployeePaidOutsidePayrollCode;
610     }
611 
612     /**
613      * Gets the disbVchrEmployeePaidOutsidePayrollCode attribute.
614      * 
615      * @return Returns the disbVchrEmployeePaidOutsidePayrollCode.
616      */
617     public boolean getDisbVchrEmployeePaidOutsidePayrollCode() {
618         return disbVchrEmployeePaidOutsidePayrollCode;
619     }
620 
621     /**
622      * Sets the disbVchrEmployeePaidOutsidePayrollCode attribute value.
623      * 
624      * @param disbVchrEmployeePaidOutsidePayrollCode The disbVchrEmployeePaidOutsidePayrollCode to set.
625      */
626     public void setDisbVchrEmployeePaidOutsidePayrollCode(boolean disbVchrEmployeePaidOutsidePayrollCode) {
627         this.disbVchrEmployeePaidOutsidePayrollCode = disbVchrEmployeePaidOutsidePayrollCode;
628     }
629 
630     /**
631      * Gets the disbVchrPaymentReason attribute.
632      * 
633      * @return Returns the disbVchrPaymentReason
634      */
635     public PaymentReasonCode getDisbVchrPaymentReason() {
636         return disbVchrPaymentReason;
637     }
638 
639 
640     /**
641      * Sets the disbVchrPaymentReason attribute.
642      * 
643      * @param disbVchrPaymentReason The disbVchrPaymentReason to set.
644      * @deprecated
645      */
646     public void setDisbVchrPaymentReason(PaymentReasonCode disbVchrPaymentReason) {
647         this.disbVchrPaymentReason = disbVchrPaymentReason;
648     }
649 
650     /**
651      * @return Returns the disbursementVoucherPayeeTypeCode.
652      */
653     public String getDisbursementVoucherPayeeTypeCode() {
654         return disbursementVoucherPayeeTypeCode;
655     }
656 
657     /**
658      * @param disbursementVoucherPayeeTypeCode The disbursementVoucherPayeeTypeCode to set.
659      */
660     public void setDisbursementVoucherPayeeTypeCode(String disbursementVoucherPayeeTypeCode) {
661         this.disbursementVoucherPayeeTypeCode = disbursementVoucherPayeeTypeCode;
662     }
663 
664     /**
665      * @return Returns the payee type name
666      */
667     public String getDisbursementVoucherPayeeTypeName() {
668         DisbursementVoucherPayeeService payeeService = SpringContext.getBean(DisbursementVoucherPayeeService.class);
669 
670         return payeeService.getPayeeTypeDescription(disbursementVoucherPayeeTypeCode);
671     }
672 
673     /**
674      * This method is a dummy method defined for OJB.
675      * 
676      * @param name
677      */
678     public void setDisbursementVoucherPayeeTypeName(String name) {
679     }
680 
681     /**
682      * Returns the name associated with the payment reason name
683      * 
684      * @return
685      */
686     public String getDisbVchrPaymentReasonName() {
687         this.refreshReferenceObject(OLEPropertyConstants.DISB_VCHR_PAYMENT_REASON);
688         return this.getDisbVchrPaymentReason().getCodeAndDescription();
689     }
690 
691     /**
692      * This method is a dummy method defined for OJB.
693      * 
694      * @param name
695      */
696     public void setDisbVchrPaymentReasonName(String name) {
697     }
698 
699     /**
700      * Gets the disbVchrVendorAddressIdNumber attribute.
701      * 
702      * @return Returns the disbVchrVendorAddressIdNumber.
703      */
704     public String getDisbVchrVendorAddressIdNumber() {
705         return disbVchrVendorAddressIdNumber;
706     }
707 
708     /**
709      * Gets the disbVchrVendorAddressIdNumber attribute.
710      * 
711      * @return Returns the disbVchrVendorAddressIdNumber.
712      */
713     public Integer getDisbVchrVendorAddressIdNumberAsInteger() {
714         if (getDisbVchrVendorAddressIdNumber() != null)
715             try {
716                 return new Integer(getDisbVchrVendorAddressIdNumber());
717             }
718             catch (NumberFormatException nfe) {
719                 nfe.printStackTrace();
720             }
721         return null;
722     }
723 
724     /**
725      * Sets the disbVchrVendorAddressIdNumber attribute value.
726      * 
727      * @param disbVchrVendorAddressIdNumber The disbVchrVendorAddressIdNumber to set.
728      */
729     public void setDisbVchrVendorAddressIdNumber(String disbVchrVendorAddressIdNumber) {
730         this.disbVchrVendorAddressIdNumber = disbVchrVendorAddressIdNumber;
731     }
732 
733     /**
734      * Gets the hasMultipleVendorAddresses attribute.
735      * 
736      * @return Returns the hasMultipleVendorAddresses.
737      */
738     public Boolean getHasMultipleVendorAddresses() {
739         return hasMultipleVendorAddresses;
740     }
741 
742     /**
743      * Sets the hasMultipleVendorAddresses attribute value.
744      * 
745      * @param hasMultipleVendorAddresses The hasMultipleVendorAddresses to set.
746      */
747     public void setHasMultipleVendorAddresses(boolean hasMultipleVendorAddresses) {
748         this.hasMultipleVendorAddresses = hasMultipleVendorAddresses;
749     }
750     
751     /**
752      * Gets the disbVchrPayeeState attribute. 
753      *
754      * @return Returns the disbVchrPayeeState.
755      */
756     public StateEbo getDisbVchrPayeeState() {
757         if ( StringUtils.isBlank(disbVchrPayeeStateCode) || StringUtils.isBlank(OLEConstants.COUNTRY_CODE_UNITED_STATES ) ) {
758             disbVchrPayeeState = null;
759         } else {
760             if ( disbVchrPayeeState == null || !StringUtils.equals( disbVchrPayeeState.getCode(),disbVchrPayeeStateCode) || !StringUtils.equals(disbVchrPayeeState.getCountryCode(), OLEConstants.COUNTRY_CODE_UNITED_STATES ) ) {
761                 ModuleService moduleService = SpringContext.getBean(KualiModuleService.class).getResponsibleModuleService(StateEbo.class);
762                 if ( moduleService != null ) {
763                     Map<String,Object> keys = new HashMap<String, Object>(2);
764                     keys.put(LocationConstants.PrimaryKeyConstants.COUNTRY_CODE, OLEConstants.COUNTRY_CODE_UNITED_STATES);/*RICE20_REFACTORME*/
765                     keys.put(LocationConstants.PrimaryKeyConstants.CODE, disbVchrPayeeStateCode);
766                     disbVchrPayeeState = moduleService.getExternalizableBusinessObject(StateEbo.class, keys);
767                 } else {
768                     throw new RuntimeException( "CONFIGURATION ERROR: No responsible module found for EBO class.  Unable to proceed." );
769                 }
770             }
771         }
772         
773         return disbVchrPayeeState;
774     }
775 
776     /**
777      * Sets the disbVchrPayeeState attribute value.
778      * @param disbVchrPayeeState The disbVchrPayeeState to set.
779      */
780     public void setDisbVchrPayeeState(StateEbo disbVchrPayeeState) {
781         this.disbVchrPayeeState = disbVchrPayeeState;
782     }
783 
784     /**
785      * Gets the disbVchrPayeeCountry attribute. 
786      *
787      * @return Returns the disbVchrPayeeCountry.
788      */
789     public CountryEbo getDisbVchrPayeeCountry() {
790         if ( StringUtils.isBlank(disbVchrPayeeCountryCode) ) {
791             disbVchrPayeeCountry = null;
792         } else {
793             if ( disbVchrPayeeCountry == null || !StringUtils.equals( disbVchrPayeeCountry.getCode(),disbVchrPayeeCountryCode) ) {
794                 ModuleService moduleService = SpringContext.getBean(KualiModuleService.class).getResponsibleModuleService(CountryEbo.class);
795                 if ( moduleService != null ) {
796                     Map<String,Object> keys = new HashMap<String, Object>(1);
797                     keys.put(LocationConstants.PrimaryKeyConstants.CODE, disbVchrPayeeCountryCode);
798                     disbVchrPayeeCountry = moduleService.getExternalizableBusinessObject(CountryEbo.class, keys);
799                 } else {
800                     throw new RuntimeException( "CONFIGURATION ERROR: No responsible module found for EBO class.  Unable to proceed." );
801                 }
802             }
803         }
804         return disbVchrPayeeCountry;
805     }
806 
807     /**
808      * Sets the disbVchrPayeeCountry attribute value.
809      * @param disbVchrPayeeCountry The disbVchrPayeeCountry to set.
810      */
811     public void setDisbVchrPayeeCountry(CountryEbo disbVchrPayeeCountry) {
812         this.disbVchrPayeeCountry = disbVchrPayeeCountry;
813     }
814 
815     
816     /**
817      * Gets the disbVchrPayeePostalZipCode attribute. 
818      *
819      * @return Returns the disbVchrPayeePostalZipCode.
820      */
821     public PostalCodeEbo getDisbVchrPayeePostalZipCode() {
822         if ( StringUtils.isBlank(disbVchrPayeeZipCode) || StringUtils.isBlank(OLEConstants.COUNTRY_CODE_UNITED_STATES ) ) {
823             disbVchrPayeePostalZipCode = null;
824         } else {
825             if ( disbVchrPayeePostalZipCode == null || !StringUtils.equals( disbVchrPayeePostalZipCode.getCode(), disbVchrPayeeZipCode) || !StringUtils.equals(disbVchrPayeePostalZipCode.getCountryCode(), OLEConstants.COUNTRY_CODE_UNITED_STATES ) ) {
826                 ModuleService moduleService = SpringContext.getBean(KualiModuleService.class).getResponsibleModuleService(PostalCodeEbo.class);
827                 if ( moduleService != null ) {
828                     Map<String,Object> keys = new HashMap<String, Object>(2);
829                     keys.put(LocationConstants.PrimaryKeyConstants.COUNTRY_CODE, OLEConstants.COUNTRY_CODE_UNITED_STATES);/*RICE20_REFACTORME*/
830                     keys.put(LocationConstants.PrimaryKeyConstants.CODE, disbVchrPayeeZipCode);
831                     disbVchrPayeePostalZipCode = moduleService.getExternalizableBusinessObject(PostalCodeEbo.class, keys);
832                 } else {
833                     throw new RuntimeException( "CONFIGURATION ERROR: No responsible module found for EBO class.  Unable to proceed." );
834                 }
835             }
836         }
837         
838         return disbVchrPayeePostalZipCode;
839     }
840 
841     /**
842      * Sets the disbVchrPayeePostalZipCode attribute value.
843      * @param disbVchrPayeePostalZipCode The disbVchrPayeePostalZipCode to set.
844      */
845     public void setDisbVchrPayeePostalZipCode(PostalCodeEbo disbVchrPayeePostalZipCode) {
846         this.disbVchrPayeePostalZipCode = disbVchrPayeePostalZipCode;
847     }
848     
849 
850     /**
851      * Checks the payee type code for vendor type
852      */
853     public boolean isVendor() {
854         return SpringContext.getBean(DisbursementVoucherPayeeService.class).isVendor(this);
855     }
856 
857     /**
858      * Checks the payee type code for employee type
859      */
860     public boolean isEmployee() {
861         return SpringContext.getBean(DisbursementVoucherPayeeService.class).isEmployee(this);
862     }
863 
864     /**
865      * @see org.kuali.rice.krad.bo.BusinessObjectBase#toStringMapper()
866      */
867     protected LinkedHashMap toStringMapper_RICE20_REFACTORME() {
868         LinkedHashMap m = new LinkedHashMap();
869         m.put(OLEPropertyConstants.DOCUMENT_NUMBER, this.documentNumber);
870         return m;
871     }
872 
873     /**
874      * This method...
875      * 
876      * @param compareDetail
877      * @return
878      */
879     public boolean hasSameAddress(DisbursementVoucherPayeeDetail compareDetail) {
880         boolean isEqual = true;
881 
882         isEqual &= nullSafeEquals(this.getDisbVchrPayeeLine1Addr(), compareDetail.getDisbVchrPayeeLine1Addr());
883         isEqual &= nullSafeEquals(this.getDisbVchrPayeeLine2Addr(), compareDetail.getDisbVchrPayeeLine2Addr());
884         isEqual &= nullSafeEquals(this.getDisbVchrPayeeCityName(), compareDetail.getDisbVchrPayeeCityName());
885         isEqual &= nullSafeEquals(this.getDisbVchrPayeeStateCode(), compareDetail.getDisbVchrPayeeStateCode());
886         isEqual &= nullSafeEquals(this.getDisbVchrPayeeZipCode(), compareDetail.getDisbVchrPayeeZipCode());
887         isEqual &= nullSafeEquals(this.getDisbVchrPayeeCountryCode(), compareDetail.getDisbVchrPayeeCountryCode());
888 
889         return isEqual;
890     }
891 
892     /**
893      * Returns the equality of the two given objects, automatically handling when one or both of the objects is null.
894      * 
895      * @param obj1
896      * @param obj2
897      * 
898      * @return true if both objects are null or both are equal
899      */
900     private boolean nullSafeEquals(Object obj1, Object obj2) {
901         if (obj1 != null && obj2 != null) {
902             return obj1.equals(obj2);
903         }
904         else {
905             return (obj1 == obj2);
906         }
907     }
908     
909     /**
910      * This method creates a string representation of the address assigned to this payee.
911      * 
912      * @return
913      */
914     public String getAddressAsString() {
915         StringBuffer address = new StringBuffer();
916 
917         address.append(this.getDisbVchrPayeeLine1Addr()).append(", ");
918         address.append(this.getDisbVchrPayeeLine2Addr()).append(", ");
919         address.append(this.getDisbVchrPayeeCityName()).append(", ");
920         address.append(this.getDisbVchrPayeeStateCode()).append(" ");
921         address.append(this.getDisbVchrPayeeZipCode()).append(", ");
922         address.append(this.getDisbVchrPayeeCountryCode());
923 
924         return address.toString();
925     }
926 }