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.kuali.ole.sys.context.SpringContext;
23  import org.kuali.rice.core.api.datetime.DateTimeService;
24  import org.kuali.rice.core.api.util.type.KualiDecimal;
25  import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
26  
27  import java.sql.Timestamp;
28  import java.util.LinkedHashMap;
29  
30  public class ElectronicInvoiceLoadSummary extends PersistableBusinessObjectBase {
31  
32      private Integer invoiceLoadSummaryIdentifier;
33      private String vendorDunsNumber; 
34      private Integer vendorHeaderGeneratedIdentifier;
35      private Integer vendorDetailAssignedIdentifier;
36      private String vendorName;
37      private Integer invoiceLoadSuccessCount = new Integer(0);
38      private KualiDecimal invoiceLoadSuccessAmount = new KualiDecimal(0.00);
39      private Integer invoiceLoadFailCount = new Integer(0);
40      private KualiDecimal invoiceLoadFailAmount = new KualiDecimal(0.00);
41      private Boolean isEmpty = Boolean.TRUE;
42      private Timestamp fileProcessTimestamp;
43  
44      public ElectronicInvoiceLoadSummary() {
45          super();
46      }
47  
48      public ElectronicInvoiceLoadSummary(String vendorDunsNumber) {
49          super();
50          this.vendorDunsNumber = vendorDunsNumber;
51      }
52  
53      public void addSuccessfulInvoiceOrder(KualiDecimal amount,
54                                            ElectronicInvoice eInvoice) {
55          isEmpty = Boolean.FALSE;
56          invoiceLoadSuccessCount = new Integer(invoiceLoadSuccessCount.intValue() + 1);
57          fileProcessTimestamp = SpringContext.getBean(DateTimeService.class).getCurrentTimestamp();
58  
59          if (amount != null) {
60              invoiceLoadSuccessAmount = invoiceLoadSuccessAmount.add(amount);
61          }
62  
63          setupVendorInformation(eInvoice);
64      }
65  
66      public void addFailedInvoiceOrder(KualiDecimal amount,
67                                        ElectronicInvoice eInvoice) {
68          isEmpty = Boolean.FALSE;
69          invoiceLoadFailCount = new Integer(invoiceLoadFailCount.intValue() + 1);
70          fileProcessTimestamp = SpringContext.getBean(DateTimeService.class).getCurrentTimestamp();
71  
72          if (amount != null) {
73              invoiceLoadFailAmount = invoiceLoadFailAmount.add(amount);
74          }
75  
76          setupVendorInformation(eInvoice);
77      }
78  
79      public void addFailedInvoiceOrder(ElectronicInvoice ei) {
80          this.addFailedInvoiceOrder(new KualiDecimal(0), ei);
81      }
82  
83      public void addFailedInvoiceOrder() {
84          this.addFailedInvoiceOrder(new KualiDecimal(0), null);
85      }
86  
87      private void setupVendorInformation(ElectronicInvoice eInvoice) {
88  
89          if (eInvoice != null &&
90                  getVendorHeaderGeneratedIdentifier() == null &&
91                  getVendorDetailAssignedIdentifier() == null) {
92  
93              setVendorHeaderGeneratedIdentifier(eInvoice.getVendorHeaderID());
94              setVendorDetailAssignedIdentifier(eInvoice.getVendorDetailID());
95              setVendorName(eInvoice.getVendorName());
96  
97          }
98      }
99  
100     public String getVendorDescriptor() {
101         String kualiDescriptor = null;
102         if ((this.vendorName != null) && (this.vendorHeaderGeneratedIdentifier != null) && (this.vendorDetailAssignedIdentifier != null)) {
103             kualiDescriptor = "  (Kuali Match:  " + this.vendorName + "  ~  " + vendorHeaderGeneratedIdentifier + "-" + vendorDetailAssignedIdentifier + ")";
104         } else if ((this.vendorHeaderGeneratedIdentifier != null) && (this.vendorDetailAssignedIdentifier != null)) {
105             kualiDescriptor = "  (Kuali Match:  " + vendorHeaderGeneratedIdentifier + "-" + vendorDetailAssignedIdentifier + ")";
106         } else if (this.vendorName != null) {
107             kualiDescriptor = "  (Kuali Match:  " + this.vendorName + ")";
108         }
109         return this.getVendorDunsNumber() + ((kualiDescriptor != null) ? kualiDescriptor : "");
110     }
111 
112     
113 
114 
115     public Integer getVendorDetailAssignedIdentifier() {
116         return vendorDetailAssignedIdentifier;
117     }
118 
119     
120 
121 
122     public void setVendorDetailAssignedIdentifier(Integer kualiVendorDetailId) {
123         this.vendorDetailAssignedIdentifier = kualiVendorDetailId;
124     }
125 
126     
127 
128 
129     public Integer getVendorHeaderGeneratedIdentifier() {
130         return vendorHeaderGeneratedIdentifier;
131     }
132 
133     
134 
135 
136 
137     public void setVendorHeaderGeneratedIdentifier(Integer kualiVendorHeaderId) {
138         this.vendorHeaderGeneratedIdentifier = kualiVendorHeaderId;
139     }
140 
141     
142 
143 
144     public String getVendorName() {
145         return vendorName;
146     }
147 
148     
149 
150 
151     public void setVendorName(String kualiVendorName) {
152         this.vendorName = kualiVendorName;
153     }
154 
155     
156 
157 
158     public KualiDecimal getInvoiceLoadFailAmount() {
159         return invoiceLoadFailAmount;
160     }
161 
162     
163 
164 
165     public void setInvoiceLoadFailAmount(KualiDecimal failAmount) {
166         this.invoiceLoadFailAmount = failAmount;
167     }
168 
169     
170 
171 
172     public Integer getInvoiceLoadFailCount() {
173         return invoiceLoadFailCount;
174     }
175 
176     
177 
178 
179     public void setInvoiceLoadFailCount(Integer failCount) {
180         this.invoiceLoadFailCount = failCount;
181     }
182 
183     
184 
185 
186     public Integer getInvoiceLoadSummaryIdentifier() {
187         return invoiceLoadSummaryIdentifier;
188     }
189 
190     
191 
192 
193     public void setInvoiceLoadSummaryIdentifier(Integer id) {
194         this.invoiceLoadSummaryIdentifier = id;
195     }
196 
197     
198 
199 
200     public Boolean isEmpty() {
201         return isEmpty;
202     }
203 
204     
205 
206 
207     public void setIsEmpty(Boolean isEmpty) {
208         this.isEmpty = isEmpty;
209     }
210 
211     
212 
213 
214     public KualiDecimal getInvoiceLoadSuccessAmount() {
215         return invoiceLoadSuccessAmount;
216     }
217 
218     
219 
220 
221     public void setInvoiceLoadSuccessAmount(KualiDecimal successAmount) {
222         this.invoiceLoadSuccessAmount = successAmount;
223     }
224 
225     
226 
227 
228     public Integer getInvoiceLoadSuccessCount() {
229         return invoiceLoadSuccessCount;
230     }
231 
232     
233 
234 
235     public void setInvoiceLoadSuccessCount(Integer successCount) {
236         this.invoiceLoadSuccessCount = successCount;
237     }
238 
239     
240 
241 
242     public String getVendorDunsNumber() {
243         return vendorDunsNumber;
244     }
245 
246     
247 
248 
249     public void setVendorDunsNumber(String vendorDunsNumber) {
250         this.vendorDunsNumber = vendorDunsNumber;
251     }
252 
253     public Timestamp getFileProcessTimestamp() {
254         return fileProcessTimestamp;
255     }
256 
257     public void setFileProcessTimestamp(Timestamp fileProcessTimestamp) {
258         this.fileProcessTimestamp = fileProcessTimestamp;
259     }
260 
261     
262 
263 
264     protected LinkedHashMap toStringMapper_RICE20_REFACTORME() {
265         LinkedHashMap m = new LinkedHashMap();
266         m.put("invoiceLoadSummaryIdentifier", this.invoiceLoadSummaryIdentifier);
267         return m;
268     }
269 }