View Javadoc
1   /*
2    * Copyright 2007 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  package org.kuali.ole.sys.businessobject;
17  
18  import java.io.Serializable;
19  import java.util.HashMap;
20  import java.util.Iterator;
21  import java.util.LinkedHashMap;
22  import java.util.Map;
23  
24  import org.apache.commons.lang.StringUtils;
25  import org.apache.commons.lang.builder.EqualsBuilder;
26  import org.apache.commons.lang.builder.HashCodeBuilder;
27  import org.apache.log4j.Logger;
28  import org.kuali.ole.coa.businessobject.Account;
29  import org.kuali.ole.coa.businessobject.BalanceType;
30  import org.kuali.ole.coa.businessobject.Chart;
31  import org.kuali.ole.coa.businessobject.ObjectCode;
32  import org.kuali.ole.coa.businessobject.ObjectType;
33  import org.kuali.ole.coa.businessobject.ProjectCode;
34  import org.kuali.ole.coa.businessobject.SubAccount;
35  import org.kuali.ole.coa.businessobject.SubObjectCode;
36  import org.kuali.ole.coa.service.AccountService;
37  import org.kuali.ole.fp.businessobject.SalesTax;
38  import org.kuali.ole.sys.OLEPropertyConstants;
39  import org.kuali.ole.sys.context.SpringContext;
40  import org.kuali.ole.sys.service.UniversityDateService;
41  import org.kuali.rice.core.api.util.type.KualiDecimal;
42  import org.kuali.rice.kew.api.doctype.DocumentTypeService;
43  import org.kuali.rice.kew.doctype.bo.DocumentType;
44  import org.kuali.rice.kew.doctype.bo.DocumentTypeEBO;
45  import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
46  import org.kuali.rice.krad.util.ObjectUtils;
47  
48  /**
49   * This is the generic class which contains all the elements on a typical line of accounting elements. These are all the accounting
50   * items necessary to create a pending entry to the G/L. All transaction documents will use this business object inherently.
51   */
52  public abstract class AccountingLineBase extends PersistableBusinessObjectBase implements Serializable, AccountingLine, GeneralLedgerPendingEntrySourceDetail {
53      private static final Logger LOG = Logger.getLogger(AccountingLineBase.class);
54  
55      protected String documentNumber;
56      protected Integer sequenceNumber; // relative to the grouping of acctng lines
57      protected Integer postingYear;
58      protected KualiDecimal amount;
59      protected String referenceOriginCode;
60      protected String referenceNumber;
61      protected String referenceTypeCode;
62      protected String overrideCode = AccountingLineOverride.CODE.NONE;
63      protected boolean accountExpiredOverride; // for the UI, persisted in overrideCode
64      protected boolean accountExpiredOverrideNeeded; // for the UI, not persisted
65      protected boolean nonFringeAccountOverride; // for the UI, persisted in overrideCode
66      protected boolean nonFringeAccountOverrideNeeded; // for the UI, not persisted
67      protected boolean objectBudgetOverride;
68      protected boolean objectBudgetOverrideNeeded;
69      protected String organizationReferenceId;
70      protected String debitCreditCode; // should only be set by the Journal Voucher or Auxiliary Voucher document
71      protected String encumbranceUpdateCode; // should only be set by the Journal Voucher document
72      protected String financialDocumentLineTypeCode;
73      protected String financialDocumentLineDescription;
74      protected boolean salesTaxRequired;
75  
76      protected String chartOfAccountsCode;
77      protected String accountNumber;
78      protected String financialObjectCode;
79      protected String subAccountNumber;
80      protected String financialSubObjectCode;
81      protected String projectCode;
82      protected String balanceTypeCode;
83  
84      // bo references
85      protected Chart chart;
86      protected Account account;
87      protected ObjectCode objectCode;
88      protected SubAccount subAccount;
89      protected SubObjectCode subObjectCode;
90      protected ProjectCode project;
91      protected BalanceType balanceTyp;
92      protected OriginationCode referenceOrigin;
93      protected DocumentTypeEBO referenceFinancialSystemDocumentTypeCode;
94      protected SalesTax salesTax;
95  
96      /**
97       * This constructor sets up empty instances for the dependent objects.
98       */
99      public AccountingLineBase() {
100         setAmount(KualiDecimal.ZERO);
101         chart = new Chart();
102         account = new Account();
103         objectCode = new ObjectCode();
104         subAccount = new SubAccount();
105         subObjectCode = new SubObjectCode();
106         project = new ProjectCode();
107 
108         balanceTyp = new BalanceType();
109         // salesTax = new SalesTax();
110         salesTaxRequired = false;
111     }
112 
113 
114     /**
115      * @return Returns the account.
116      */
117     @Override
118     public Account getAccount() {
119         return account;
120     }
121 
122     /**
123      * @param account The account to set.
124      * @deprecated
125      */
126     @Deprecated
127     @Override
128     public void setAccount(Account account) {
129         this.account = account;
130     }
131 
132     /**
133      * @return Returns the chartOfAccountsCode.
134      */
135     @Override
136     public Chart getChart() {
137         return chart;
138     }
139 
140     /**
141      * @param chart The chartOfAccountsCode to set.
142      * @deprecated
143      */
144     @Deprecated
145     @Override
146     public void setChart(Chart chart) {
147         this.chart = chart;
148     }
149 
150     /**
151      * @return Returns the documentNumber.
152      */
153     @Override
154     public String getDocumentNumber() {
155         return documentNumber;
156     }
157 
158     /**
159      * @return Returns the amount.
160      */
161     @Override
162     public KualiDecimal getAmount() {
163         return amount;
164     }
165 
166     /**
167      * @param amount The amount to set.
168      */
169     @Override
170     public void setAmount(KualiDecimal amount) {
171         this.amount = amount;
172     }
173 
174     /**
175      * @return Returns the balanceTyp.
176      */
177     @Override
178     public BalanceType getBalanceTyp() {
179         return balanceTyp;
180     }
181 
182     /**
183      * @param balanceTyp The balanceTyp to set.
184      * @deprecated
185      */
186     @Deprecated
187     @Override
188     public void setBalanceTyp(BalanceType balanceTyp) {
189         this.balanceTyp = balanceTyp;
190     }
191 
192     /**
193      * @return Returns the objectCode.
194      */
195     @Override
196     public ObjectCode getObjectCode() {
197         return objectCode;
198     }
199 
200     /**
201      * @param objectCode The objectCode to set.
202      * @deprecated
203      */
204     @Deprecated
205     @Override
206     public void setObjectCode(ObjectCode objectCode) {
207         this.objectCode = objectCode;
208     }
209 
210     /**
211      * @return Returns the referenceOriginCode.
212      */
213     @Override
214     public String getReferenceOriginCode() {
215         return referenceOriginCode;
216     }
217 
218     /**
219      * @param originCode The referenceOriginCode to set.
220      */
221     @Override
222     public void setReferenceOriginCode(String originCode) {
223         this.referenceOriginCode = originCode;
224     }
225 
226     /**
227      * This method returns the object related to referenceOriginCode
228      * 
229      * @return referenceOrigin
230      */
231     @Override
232     public OriginationCode getReferenceOrigin() {
233         return referenceOrigin;
234     }
235 
236     /**
237      * This method sets the referenceOrigin object, this is only to be used by OJB
238      * 
239      * @param referenceOrigin
240      * @deprecated
241      */
242     @Deprecated
243     @Override
244     public void setReferenceOrigin(OriginationCode referenceOrigin) {
245         this.referenceOrigin = referenceOrigin;
246     }
247 
248     /**
249      * Gets the referenceFinancialSystemDocumentTypeCode attribute. 
250      * @return Returns the referenceFinancialSystemDocumentTypeCode.
251      */
252     @Override
253     public DocumentTypeEBO getReferenceFinancialSystemDocumentTypeCode() {
254         if ( StringUtils.isBlank( referenceTypeCode ) ) {
255             referenceFinancialSystemDocumentTypeCode = null;
256         } else {
257             if ( referenceFinancialSystemDocumentTypeCode == null || !StringUtils.equals(referenceTypeCode, referenceFinancialSystemDocumentTypeCode.getName() ) ) {
258                 org.kuali.rice.kew.api.doctype.DocumentType temp = SpringContext.getBean(DocumentTypeService.class).getDocumentTypeByName(referenceTypeCode);
259                 if ( temp != null ) {
260                     referenceFinancialSystemDocumentTypeCode = DocumentType.from( temp );
261                 } else {
262                     referenceFinancialSystemDocumentTypeCode = null;
263                 }
264             }
265         }
266         return referenceFinancialSystemDocumentTypeCode;
267     }
268 
269     /**
270      * @return Returns the organizationReferenceId.
271      */
272     @Override
273     public String getOrganizationReferenceId() {
274         return organizationReferenceId;
275     }
276 
277     /**
278      * @param organizationReferenceId The organizationReferenceId to set.
279      */
280     @Override
281     public void setOrganizationReferenceId(String organizationReferenceId) {
282         this.organizationReferenceId = organizationReferenceId;
283     }
284 
285     /**
286      * @return Returns the overrideCode.
287      */
288     @Override
289     public String getOverrideCode() {
290         return overrideCode;
291     }
292 
293     /**
294      * @param overrideCode The overrideCode to set.
295      */
296     @Override
297     public void setOverrideCode(String overrideCode) {
298         this.overrideCode = overrideCode;
299     }
300 
301     /**
302      * @return Returns the postingYear.
303      */
304     @Override
305     public Integer getPostingYear() {
306         if (postingYear == null) {
307             postingYear = SpringContext.getBean(UniversityDateService.class).getCurrentFiscalYear();
308         }
309         return postingYear;
310     }
311 
312     /**
313      * @param postingYear The postingYear to set.
314      */
315     @Override
316     public void setPostingYear(Integer postingYear) {
317         this.postingYear = postingYear;
318     }
319 
320     /**
321      * @return Returns the projectCode.
322      */
323     @Override
324     public String getProjectCode() {
325         return projectCode;
326     }
327 
328     /**
329      * @param projectCode The projectCode to set.
330      */
331     @Override
332     public void setProjectCode(String projectCode) {
333         this.projectCode = projectCode;
334     }
335 
336     /**
337      * @return Returns the referenceNumber.
338      */
339     @Override
340     public String getReferenceNumber() {
341         return referenceNumber;
342     }
343 
344     /**
345      * @param referenceNumber The referenceNumber to set.
346      */
347     @Override
348     public void setReferenceNumber(String referenceNumber) {
349         this.referenceNumber = referenceNumber;
350     }
351 
352     /**
353      * @return Returns the referenceTypeCode.
354      */
355     @Override
356     public String getReferenceTypeCode() {
357         return referenceTypeCode;
358     }
359 
360     /**
361      * @param referenceTypeCode The referenceTypeCode to set.
362      */
363     @Override
364     public void setReferenceTypeCode(String referenceTypeCode) {
365         this.referenceTypeCode = referenceTypeCode;
366     }
367 
368     /**
369      * @return Returns the sequenceNumber.
370      */
371     @Override
372     public Integer getSequenceNumber() {
373         return sequenceNumber;
374     }
375 
376     /**
377      * @param sequenceNumber The sequenceNumber to set.
378      */
379     @Override
380     public void setSequenceNumber(Integer sequenceNumber) {
381         this.sequenceNumber = sequenceNumber;
382     }
383 
384     /**
385      * @return Returns the subAccount.
386      */
387     @Override
388     public SubAccount getSubAccount() {
389         return subAccount;
390     }
391 
392     /**
393      * @param subAccount The subAccount to set.
394      * @deprecated
395      */
396     @Deprecated
397     @Override
398     public void setSubAccount(SubAccount subAccount) {
399         this.subAccount = subAccount;
400     }
401 
402     /**
403      * @return Returns the subObjectCode.
404      */
405     @Override
406     public SubObjectCode getSubObjectCode() {
407         return subObjectCode;
408     }
409 
410     /**
411      * @param subObjectCode The subObjectCode to set.
412      * @deprecated
413      */
414     @Deprecated
415     @Override
416     public void setSubObjectCode(SubObjectCode subObjectCode) {
417         this.subObjectCode = subObjectCode;
418     }
419 
420 
421     /**
422      * @see org.kuali.ole.sys.businessobject.AccountingLine#getSalesTax()
423      */
424     @Override
425     public SalesTax getSalesTax() {
426         return salesTax;
427     }
428 
429     /**
430      * @see org.kuali.ole.sys.businessobject.AccountingLine#setSalesTax(org.kuali.ole.fp.businessobject.SalesTax)
431      * @deprecated
432      */
433     @Deprecated
434     @Override
435     public void setSalesTax(SalesTax salesTax) {
436         this.salesTax = salesTax;
437     }
438 
439     /**
440      * @see org.kuali.ole.sys.businessobject.AccountingLine#isSalesTaxRequired()
441      */
442     @Override
443     public boolean isSalesTaxRequired() {
444         return salesTaxRequired;
445     }
446 
447     /**
448      * @see org.kuali.ole.sys.businessobject.AccountingLine#setSalesTaxRequired(boolean)
449      */
450     @Override
451     public void setSalesTaxRequired(boolean salesTaxRequired) {
452         this.salesTaxRequired = salesTaxRequired;
453     }
454 
455 
456     /**
457      * @param documentNumber The documentNumber to set.
458      */
459     @Override
460     public void setDocumentNumber(String documentNumber) {
461         this.documentNumber = documentNumber;
462     }
463 
464     /**
465      * This method retrieves the debit/credit code for the accounting line. This method will only return a not null value for a
466      * Journal Voucher document.
467      * 
468      * @return A String code.
469      */
470     @Override
471     public String getDebitCreditCode() {
472         return debitCreditCode;
473     }
474 
475     /**
476      * This method sets the debit/credit code for the accounting line. This method should only be used for a Journal Voucher
477      * document.
478      * 
479      * @param debitCreditCode
480      */
481     @Override
482     public void setDebitCreditCode(String debitCreditCode) {
483         this.debitCreditCode = debitCreditCode;
484     }
485 
486     /**
487      * This method retrieves the encumbrance update code for the accounting line. This method will only return a not null value for
488      * a Journal Voucher document.
489      * 
490      * @return A String code.
491      */
492     @Override
493     public String getEncumbranceUpdateCode() {
494         return encumbranceUpdateCode;
495     }
496 
497     /**
498      * This method sets the debit/credit code for the accounting line. This method should only be used for a Journal Voucher
499      * document.
500      * 
501      * @param encumbranceUpdateCode
502      */
503     @Override
504     public void setEncumbranceUpdateCode(String encumbranceUpdateCode) {
505         this.encumbranceUpdateCode = encumbranceUpdateCode;
506     }
507 
508     /**
509      * This method retrieves the ObjectType for the accounting line. This method will only return a not null value for a Journal
510      * Voucher document.
511      * 
512      * @return An ObjectType instance.
513      */
514     @Override
515     public ObjectType getObjectType() {
516         if ( getObjectTypeCode() != null ) {
517             return objectCode.getFinancialObjectType();
518         }
519         return null;
520     }
521 
522     /**
523      * @return Returns the accountNumber.
524      */
525     @Override
526     public String getAccountNumber() {
527         return accountNumber;
528     }
529 
530     /**
531      * @param accountNumber The accountNumber to set.
532      */
533     @Override
534     public void setAccountNumber(String accountNumber) {
535         this.accountNumber = accountNumber;
536         // if accounts can't cross charts, set chart code whenever account number is set
537         SpringContext.getBean(AccountService.class).populateAccountingLineChartIfNeeded(this);
538     }
539 
540     /**
541      * @return Returns the balanceTypeCode.
542      */
543     @Override
544     public String getBalanceTypeCode() {
545         return balanceTypeCode;
546     }
547 
548     /**
549      * @param balanceTypeCode The balanceTypeCode to set.
550      */
551     @Override
552     public void setBalanceTypeCode(String balanceTypeCode) {
553         this.balanceTypeCode = balanceTypeCode;
554     }
555 
556     /**
557      * @return Returns the chartOfAccountsCode.
558      */
559     @Override
560     public String getChartOfAccountsCode() {
561         return chartOfAccountsCode;
562     }
563 
564     /**
565      * @param chartOfAccountsCode The chartOfAccountsCode to set.
566      */
567     @Override
568     public void setChartOfAccountsCode(String chartOfAccountsCode) {
569         this.chartOfAccountsCode = chartOfAccountsCode;
570     }
571 
572     /**
573      * @return Returns the financialObjectCode.
574      */
575     @Override
576     public String getFinancialObjectCode() {
577         return financialObjectCode;
578     }
579 
580     /**
581      * @param financialObjectCode The financialObjectCode to set.
582      */
583     @Override
584     public void setFinancialObjectCode(String financialObjectCode) {
585         this.financialObjectCode = financialObjectCode;
586     }
587 
588     /**
589      * @return Returns the financialSubObjectCode.
590      */
591     @Override
592     public String getFinancialSubObjectCode() {
593         return financialSubObjectCode;
594     }
595 
596     /**
597      * @param financialSubObjectCode The financialSubObjectCode to set.
598      */
599     @Override
600     public void setFinancialSubObjectCode(String financialSubObjectCode) {
601         this.financialSubObjectCode = financialSubObjectCode;
602     }
603 
604     /**
605      * @return Returns the objectTypeCode.
606      */
607     @Override
608     public String getObjectTypeCode() {
609         if ( ObjectUtils.isNull(objectCode)
610                 || !StringUtils.equals(getFinancialObjectCode(), objectCode.getFinancialObjectCode())
611                 || !StringUtils.equals(getChartOfAccountsCode(), objectCode.getChartOfAccountsCode())
612                 || !getPostingYear().equals(objectCode.getUniversityFiscalYear() )
613                         ) {
614             refreshReferenceObject("objectCode");
615         }
616        
617         if (!ObjectUtils.isNull(objectCode)) {
618             return objectCode.getFinancialObjectTypeCode();
619         }
620         return null;
621     }
622 
623     /**
624      * @return Returns the financialDocumentLineTypeCode.
625      */
626     @Override
627     public String getFinancialDocumentLineTypeCode() {
628         return financialDocumentLineTypeCode;
629     }
630 
631     /**
632      * @param financialDocumentLineTypeCode The financialDocumentLineTypeCode to set.
633      */
634     @Override
635     public void setFinancialDocumentLineTypeCode(String financialDocumentLineTypeCode) {
636         this.financialDocumentLineTypeCode = financialDocumentLineTypeCode;
637     }
638 
639     /**
640      * @return Returns the project.
641      */
642     @Override
643     public ProjectCode getProject() {
644         return project;
645     }
646 
647     /**
648      * @param project The project to set.
649      * @deprecated
650      */
651     @Deprecated
652     @Override
653     public void setProject(ProjectCode project) {
654         this.project = project;
655     }
656 
657     /**
658      * @return Returns the subAccountNumber.
659      */
660     @Override
661     public String getSubAccountNumber() {
662         return subAccountNumber;
663     }
664 
665     /**
666      * @param subAccountNumber The subAccountNumber to set.
667      */
668     @Override
669     public void setSubAccountNumber(String subAccountNumber) {
670         this.subAccountNumber = subAccountNumber;
671     }
672 
673     /**
674      * @return Returns the financialDocumentLineDescription.
675      */
676     @Override
677     public String getFinancialDocumentLineDescription() {
678         return financialDocumentLineDescription;
679     }
680 
681     /**
682      * @param financialDocumentLineDescription The financialDocumentLineDescription to set.
683      */
684     @Override
685     public void setFinancialDocumentLineDescription(String financialDocumentLineDescription) {
686         this.financialDocumentLineDescription = financialDocumentLineDescription;
687     }
688 
689     /**
690      * @see org.kuali.rice.krad.bo.BusinessObjectBase#toStringMapper()
691      */
692     protected LinkedHashMap toStringMapper_RICE20_REFACTORME() {
693         LinkedHashMap m = new LinkedHashMap();
694 
695         m.put(OLEPropertyConstants.DOCUMENT_NUMBER, documentNumber);
696 
697         m.put("sequenceNumber", sequenceNumber);
698         m.put("postingYear", postingYear);
699         m.put("amount", amount);
700         m.put("debitCreditCode", debitCreditCode);
701         m.put("encumbranceUpdateCode", encumbranceUpdateCode);
702         m.put("financialDocumentLineDescription", financialDocumentLineDescription);
703 
704         m.put("chart", getChartOfAccountsCode());
705         m.put("account", getAccountNumber());
706         m.put("objectCode", getFinancialObjectCode());
707         m.put("subAccount", getSubAccountNumber());
708         m.put("subObjectCode", getFinancialSubObjectCode());
709         m.put("projectCode", getProjectCode());
710         m.put("balanceTyp", getBalanceTypeCode());
711 
712         m.put("orgRefId", getOrganizationReferenceId());
713 
714         return m;
715     }
716 
717     /**
718      * @see org.kuali.rice.krad.bo.AccountingLine#isSourceAccountingLine()
719      */
720     @Override
721     public boolean isSourceAccountingLine() {
722         return (this instanceof SourceAccountingLine);
723     }
724 
725     /**
726      * @see org.kuali.rice.krad.bo.AccountingLine#isTargetAccountingLine()
727      */
728     @Override
729     public boolean isTargetAccountingLine() {
730         return (this instanceof TargetAccountingLine);
731     }
732 
733 
734     /**
735      * @see org.kuali.rice.krad.bo.AccountingLine#getAccountKey()
736      */
737     @Override
738     public String getAccountKey() {
739         String key = getChartOfAccountsCode() + ":" + getAccountNumber();
740         return key;
741     }
742 
743 
744     /**
745      * @see org.kuali.rice.krad.bo.AccountingLine#copyFrom(org.kuali.rice.krad.bo.AccountingLine)
746      */
747     @Override
748     public void copyFrom(AccountingLine other) {
749         if (other == null) {
750             throw new IllegalArgumentException("invalid (null) other");
751         }
752 
753         if (this != other) {
754             // primitive fields
755             setSequenceNumber(other.getSequenceNumber());
756             setDocumentNumber(other.getDocumentNumber());
757             setPostingYear(other.getPostingYear());
758             setAmount(other.getAmount());
759             setReferenceOriginCode(other.getReferenceOriginCode());
760             setReferenceNumber(other.getReferenceNumber());
761             setReferenceTypeCode(other.getReferenceTypeCode());
762             setOverrideCode(other.getOverrideCode());
763             setOrganizationReferenceId(other.getOrganizationReferenceId());
764             setDebitCreditCode(other.getDebitCreditCode());
765             setEncumbranceUpdateCode(other.getEncumbranceUpdateCode());
766             setFinancialDocumentLineTypeCode(other.getFinancialDocumentLineTypeCode());
767             setFinancialDocumentLineDescription(other.getFinancialDocumentLineDescription());
768             setAccountExpiredOverride(other.getAccountExpiredOverride());
769             setAccountExpiredOverrideNeeded(other.getAccountExpiredOverrideNeeded());
770             setObjectBudgetOverride(other.isObjectBudgetOverride());
771             setObjectBudgetOverrideNeeded(other.isObjectBudgetOverrideNeeded());
772 
773             // foreign keys
774             setChartOfAccountsCode(other.getChartOfAccountsCode());
775             setAccountNumber(other.getAccountNumber());
776             setFinancialObjectCode(other.getFinancialObjectCode());
777             setSubAccountNumber(other.getSubAccountNumber());
778             setFinancialSubObjectCode(other.getFinancialSubObjectCode());
779             setProjectCode(other.getProjectCode());
780             setBalanceTypeCode(other.getBalanceTypeCode());
781 
782             // sales tax
783             if (ObjectUtils.isNotNull(other.getSalesTax())) {
784                 SalesTax salesTax = getSalesTax();
785                 SalesTax origSalesTax = other.getSalesTax();
786                 if (salesTax != null) {
787                     salesTax.setAccountNumber(origSalesTax.getAccountNumber());
788                     salesTax.setChartOfAccountsCode(origSalesTax.getChartOfAccountsCode());
789                     salesTax.setFinancialDocumentGrossSalesAmount(origSalesTax.getFinancialDocumentGrossSalesAmount());
790                     salesTax.setFinancialDocumentTaxableSalesAmount(origSalesTax.getFinancialDocumentTaxableSalesAmount());
791                     salesTax.setFinancialDocumentSaleDate(origSalesTax.getFinancialDocumentSaleDate());
792 
793                     // primary keys
794                     salesTax.setDocumentNumber(other.getDocumentNumber());
795                     salesTax.setFinancialDocumentLineNumber(other.getSequenceNumber());
796                     salesTax.setFinancialDocumentLineTypeCode(other.getFinancialDocumentLineTypeCode());
797                 }
798                 else {
799                     salesTax = origSalesTax;
800                 }
801             }
802 
803             // object references
804             setChart(other.getChart());
805             setAccount(other.getAccount());
806             setObjectCode(other.getObjectCode());
807             setSubAccount(other.getSubAccount());
808             setSubObjectCode(other.getSubObjectCode());
809             setProject(other.getProject());
810             setBalanceTyp(other.getBalanceTyp());
811         }
812     }
813 
814 
815     /**
816      * @see org.kuali.rice.krad.bo.AccountingLine#isLike(org.kuali.rice.krad.bo.AccountingLine)
817      */
818     @Override
819     public boolean isLike(AccountingLine other) {
820         boolean isLike = false;
821 
822         if (other != null) {
823             if (other == this) {
824                 isLike = true;
825             }
826             else {
827                 Map thisValues = this.getValuesMap();
828                 Map otherValues = other.getValuesMap();
829 
830                 isLike = thisValues.equals(otherValues);
831 
832                 if (!isLike && LOG.isDebugEnabled()) {
833                     StringBuffer inequalities = new StringBuffer();
834                     boolean first = true;
835 
836                     for (Iterator i = thisValues.keySet().iterator(); i.hasNext();) {
837                         String key = (String) i.next();
838 
839                         Object thisValue = thisValues.get(key);
840                         Object otherValue = otherValues.get(key);
841                         if (!org.apache.commons.lang.ObjectUtils.equals(thisValue, otherValue)) {
842                             inequalities.append(key + "(" + thisValue + " != " + otherValue + ")");
843 
844                             if (first) {
845                                 first = false;
846                             }
847                             else {
848                                 inequalities.append(",");
849                             }
850                         }
851                     }
852 
853                     if (LOG.isDebugEnabled()) {
854                         LOG.debug("inequalities: " + inequalities);
855                     }
856                 }
857             }
858         }
859 
860         return isLike;
861     }
862 
863     /**
864      * @see AccountingLine#getAccountExpiredOverride()
865      */
866     @Override
867     public boolean getAccountExpiredOverride() {
868         return accountExpiredOverride;
869     }
870 
871     /**
872      * @see AccountingLine#setAccountExpiredOverride(boolean)
873      */
874     @Override
875     public void setAccountExpiredOverride(boolean b) {
876         accountExpiredOverride = b;
877     }
878 
879     /**
880      * @see AccountingLine#getAccountExpiredOverrideNeeded()
881      */
882     @Override
883     public boolean getAccountExpiredOverrideNeeded() {
884         return accountExpiredOverrideNeeded;
885     }
886 
887     /**
888      * @see AccountingLine#setAccountExpiredOverrideNeeded(boolean)
889      */
890     @Override
891     public void setAccountExpiredOverrideNeeded(boolean b) {
892         accountExpiredOverrideNeeded = b;
893     }
894 
895     /**
896      * @return Returns the objectBudgetOverride.
897      */
898     @Override
899     public boolean isObjectBudgetOverride() {
900         return objectBudgetOverride;
901     }
902 
903     /**
904      * @param objectBudgetOverride The objectBudgetOverride to set.
905      */
906     @Override
907     public void setObjectBudgetOverride(boolean objectBudgetOverride) {
908         this.objectBudgetOverride = objectBudgetOverride;
909     }
910 
911     /**
912      * @return Returns the objectBudgetOverrideNeeded.
913      */
914     @Override
915     public boolean isObjectBudgetOverrideNeeded() {
916         return objectBudgetOverrideNeeded;
917     }
918 
919     /**
920      * @param objectBudgetOverrideNeeded The objectBudgetOverrideNeeded to set.
921      */
922     @Override
923     public void setObjectBudgetOverrideNeeded(boolean objectBudgetOverrideNeeded) {
924         this.objectBudgetOverrideNeeded = objectBudgetOverrideNeeded;
925     }
926 
927     /**
928      * @see org.kuali.ole.sys.businessobject.AccountingLine#isNonFringeAccountOverride()
929      */
930     @Override
931     public boolean getNonFringeAccountOverride() {
932         return nonFringeAccountOverride;
933     }
934 
935     /**
936      * @see org.kuali.ole.sys.businessobject.AccountingLine#setNonFringeAccountOverride(boolean)
937      */
938     @Override
939     public void setNonFringeAccountOverride(boolean nonFringeAccountOverride) {
940         this.nonFringeAccountOverride = nonFringeAccountOverride;
941     }
942 
943     /**
944      * @see org.kuali.ole.sys.businessobject.AccountingLine#isNonFringeAccountOverrideNeeded()
945      */
946     @Override
947     public boolean getNonFringeAccountOverrideNeeded() {
948         return nonFringeAccountOverrideNeeded;
949     }
950 
951     /**
952      * @see org.kuali.ole.sys.businessobject.AccountingLine#setNonFringeAccountOverrideNeeded(boolean)
953      */
954     @Override
955     public void setNonFringeAccountOverrideNeeded(boolean nonFringeAccountOverrideNeeded) {
956         this.nonFringeAccountOverrideNeeded = nonFringeAccountOverrideNeeded;
957     }
958 
959     /**
960      * Returns a map with the primitive field names as the key and the primitive values as the map value.
961      * 
962      * @return Map
963      */
964     @Override
965     public Map getValuesMap() {
966         Map simpleValues = new HashMap();
967 
968         simpleValues.put("sequenceNumber", getSequenceNumber());
969         simpleValues.put(OLEPropertyConstants.DOCUMENT_NUMBER, getDocumentNumber());
970         simpleValues.put("postingYear", getPostingYear());
971         simpleValues.put("amount", getAmount());
972         simpleValues.put("referenceOriginCode", getReferenceOriginCode());
973         simpleValues.put("referenceNumber", getReferenceNumber());
974         simpleValues.put("referenceTypeCode", getReferenceTypeCode());
975         simpleValues.put("overrideCode", getOverrideCode());
976         // The override booleans are not in the map because they should not cause isLike() to fail and generate update events.
977         simpleValues.put("organizationReferenceId", getOrganizationReferenceId());
978         simpleValues.put("debitCreditCode", getDebitCreditCode());
979         simpleValues.put("encumbranceUpdateCode", getEncumbranceUpdateCode());
980         simpleValues.put("financialDocumentLineTypeCode", getFinancialDocumentLineTypeCode());
981         simpleValues.put("financialDocumentLineDescription", getFinancialDocumentLineDescription());
982 
983         simpleValues.put("chartOfAccountsCode", getChartOfAccountsCode());
984         simpleValues.put("accountNumber", getAccountNumber());
985         simpleValues.put("financialObjectCode", getFinancialObjectCode());
986         simpleValues.put("subAccountNumber", getSubAccountNumber());
987         simpleValues.put("financialSubObjectCode", getFinancialSubObjectCode());
988         simpleValues.put("projectCode", getProjectCode());
989         simpleValues.put("balanceTypeCode", getBalanceTypeCode());
990         simpleValues.put("objectTypeCode", getObjectTypeCode());
991 
992         return simpleValues;
993     }
994 
995     /**
996      * Override needed for PURAP GL entry creation (hjs) - please do not add "amount" to this method
997      * 
998      * @see java.lang.Object#equals(java.lang.Object)
999      */
1000     @Override
1001     public boolean equals(Object obj) {
1002         if (!(obj instanceof AccountingLine)) {
1003             return false;
1004         }
1005         AccountingLine accountingLine = (AccountingLine) obj;
1006         return new EqualsBuilder().append(this.chartOfAccountsCode, accountingLine.getChartOfAccountsCode()).append(this.accountNumber, accountingLine.getAccountNumber()).append(this.subAccountNumber, accountingLine.getSubAccountNumber()).append(this.financialObjectCode, accountingLine.getFinancialObjectCode()).append(this.financialSubObjectCode, accountingLine.getFinancialSubObjectCode()).append(this.projectCode, accountingLine.getProjectCode()).append(this.organizationReferenceId, accountingLine.getOrganizationReferenceId()).isEquals();
1007     }
1008 
1009     /**
1010      * Override needed for PURAP GL entry creation (hjs) - please do not add "amount" to this method
1011      * 
1012      * @see java.lang.Object#hashCode()
1013      */
1014     @Override
1015     public int hashCode() {
1016         return new HashCodeBuilder(37, 41).append(this.chartOfAccountsCode).append(this.accountNumber).append(this.subAccountNumber).append(this.financialObjectCode).append(this.financialSubObjectCode).append(this.projectCode).append(this.organizationReferenceId).toHashCode();
1017     }
1018 
1019 
1020     @Override
1021     public String toString() {
1022         StringBuilder builder = new StringBuilder();
1023         builder.append("AccountingLineBase [");
1024         if (documentNumber != null)
1025             builder.append("documentNumber=").append(documentNumber).append(", ");
1026         if (sequenceNumber != null)
1027             builder.append("sequenceNumber=").append(sequenceNumber).append(", ");
1028         if (postingYear != null)
1029             builder.append("postingYear=").append(postingYear).append(", ");
1030         if (amount != null)
1031             builder.append("amount=").append(amount).append(", ");
1032         if (debitCreditCode != null)
1033             builder.append("debitCreditCode=").append(debitCreditCode).append(", ");
1034         if (chartOfAccountsCode != null)
1035             builder.append("chartOfAccountsCode=").append(chartOfAccountsCode).append(", ");
1036         if (accountNumber != null)
1037             builder.append("accountNumber=").append(accountNumber).append(", ");
1038         if (subAccountNumber != null)
1039             builder.append("subAccountNumber=").append(subAccountNumber).append(", ");
1040         if (financialObjectCode != null)
1041             builder.append("financialObjectCode=").append(financialObjectCode).append(", ");
1042         if (financialSubObjectCode != null)
1043             builder.append("financialSubObjectCode=").append(financialSubObjectCode).append(", ");
1044         if (projectCode != null)
1045             builder.append("projectCode=").append(projectCode).append(", ");
1046         if (balanceTypeCode != null)
1047             builder.append("balanceTypeCode=").append(balanceTypeCode);
1048         builder.append("]");
1049         return builder.toString();
1050     }
1051 
1052 
1053 
1054 }