1   
2   
3   
4   
5   
6   
7   
8   
9   
10  
11  
12  
13  
14  
15  
16  package org.kuali.ole.gl.businessobject;
17  
18  import java.sql.Date;
19  import java.sql.Timestamp;
20  import java.util.ArrayList;
21  import java.util.Collection;
22  
23  import org.kuali.ole.gl.GeneralLedgerConstants;
24  import org.kuali.ole.gl.batch.PosterEntriesStep;
25  import org.kuali.ole.sys.OLEConstants;
26  import org.kuali.ole.sys.context.SpringContext;
27  import org.kuali.rice.core.api.util.type.KualiDecimal;
28  import org.kuali.rice.coreservice.framework.parameter.ParameterService;
29  import org.kuali.rice.krad.util.ObjectUtils;
30  
31  
32  
33  
34  public class EncumbranceHistory extends Encumbrance {
35  
36      public EncumbranceHistory() {
37          super();
38          this.setAccountLineEncumbranceAmount(KualiDecimal.ZERO);
39          this.setAccountLineEncumbranceClosedAmount(KualiDecimal.ZERO);
40      }
41  
42      
43  
44  
45  
46  
47      public EncumbranceHistory(OriginEntryInformation originEntry) {
48          this();
49          this.setUniversityFiscalYear(originEntry.getUniversityFiscalYear());
50          this.setChartOfAccountsCode(originEntry.getChartOfAccountsCode());
51          this.setAccountNumber(originEntry.getAccountNumber());
52          this.setSubAccountNumber(originEntry.getSubAccountNumber());
53          this.setObjectCode(originEntry.getFinancialObjectCode());
54          this.setSubObjectCode(originEntry.getFinancialSubObjectCode());
55          this.setBalanceTypeCode(originEntry.getFinancialBalanceTypeCode());
56          this.setDocumentTypeCode(originEntry.getFinancialDocumentTypeCode());
57          this.setOriginCode(originEntry.getFinancialSystemOriginationCode());
58          this.setDocumentNumber(originEntry.getDocumentNumber());
59      }
60      
61      
62  
63  
64  
65      public void addAmount(OriginEntryInformation originEntry) {
66          
67          ParameterService parameterService = SpringContext.getBean(ParameterService.class);
68          Collection<String> encumbranceOpenAmountOeverridingDocTypes = new ArrayList<String>( parameterService.getParameterValuesAsString(PosterEntriesStep.class, GeneralLedgerConstants.PosterService.ENCUMBRANCE_OPEN_AMOUNT_OVERRIDING_DOCUMENT_TYPES) );
69          
70          if (OLEConstants.ENCUMB_UPDT_REFERENCE_DOCUMENT_CD.equals(originEntry.getTransactionEncumbranceUpdateCode()) 
71                  && !encumbranceOpenAmountOeverridingDocTypes.contains( originEntry.getFinancialDocumentTypeCode())) {
72              
73              
74              if (OLEConstants.GL_DEBIT_CODE.equals(originEntry.getTransactionDebitCreditCode())) {
75                  this.setAccountLineEncumbranceClosedAmount(this.getAccountLineEncumbranceClosedAmount().subtract(originEntry.getTransactionLedgerEntryAmount()));
76              }
77              else {
78                  this.setAccountLineEncumbranceClosedAmount(this.getAccountLineEncumbranceClosedAmount().add(originEntry.getTransactionLedgerEntryAmount()));
79              }
80          }
81          else {
82              
83              
84              if (OLEConstants.GL_DEBIT_CODE.equals(originEntry.getTransactionDebitCreditCode()) || OLEConstants.GL_BUDGET_CODE.equals(originEntry.getTransactionDebitCreditCode())) {
85                  this.setAccountLineEncumbranceAmount(this.getAccountLineEncumbranceAmount().add(originEntry.getTransactionLedgerEntryAmount()));
86              }
87              else {
88                  this.setAccountLineEncumbranceAmount(this.getAccountLineEncumbranceAmount().subtract(originEntry.getTransactionLedgerEntryAmount()));
89              }
90          }
91      }
92      
93      
94  
95  
96  
97      public boolean compareAmounts(Encumbrance encumbrance) {
98          if (ObjectUtils.isNotNull(encumbrance)
99                  && encumbrance.getAccountLineEncumbranceAmount().equals(this.getAccountLineEncumbranceAmount())
100                 && encumbrance.getAccountLineEncumbranceClosedAmount().equals(this.getAccountLineEncumbranceClosedAmount())) {
101             return true;
102         }
103         
104         return false;
105     }
106     
107     
108 
109 
110 
111     @Override
112     public String getAccountLineEncumbrancePurgeCode() {
113         throw new UnsupportedOperationException();
114     }
115 
116     
117 
118 
119 
120     @Override
121     public void setAccountLineEncumbrancePurgeCode(String accountLineEncumbrancePurgeCode) {
122         throw new UnsupportedOperationException();
123     }
124 
125     
126 
127 
128 
129     @Override
130     public Timestamp getTimestamp() {
131         throw new UnsupportedOperationException();
132     }
133 
134     
135 
136 
137 
138     @Override
139     public void setTimestamp(Timestamp timestamp) {
140         throw new UnsupportedOperationException();
141     }
142 
143     
144 
145 
146 
147     @Override
148     public Date getTransactionEncumbranceDate() {
149         throw new UnsupportedOperationException();
150     }
151 
152     
153 
154 
155 
156     @Override
157     public void setTransactionEncumbranceDate(Date transactionEncumbranceDate) {
158         throw new UnsupportedOperationException();
159     }
160 
161     
162 
163 
164 
165     @Override
166     public String getTransactionEncumbranceDescription() {
167         throw new UnsupportedOperationException();
168     }
169 
170     
171 
172 
173 
174     @Override
175     public void setTransactionEncumbranceDescription(String transactionEncumbranceDescription) {
176         throw new UnsupportedOperationException();
177     }
178 }