001 /* 002 * Copyright 2011 The Kuali Foundation. 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 /* 017 * Created on Feb 28, 2006 018 * 019 */ 020 package org.kuali.kfs.module.purap.businessobject; 021 022 import java.sql.Timestamp; 023 import java.util.Date; 024 import java.util.LinkedHashMap; 025 026 import org.kuali.kfs.sys.context.SpringContext; 027 import org.kuali.rice.kns.bo.PersistableBusinessObjectBase; 028 import org.kuali.rice.kns.service.DateTimeService; 029 import org.kuali.rice.kns.util.KualiDecimal; 030 031 public class ElectronicInvoiceLoadSummary extends PersistableBusinessObjectBase { 032 033 private Integer invoiceLoadSummaryIdentifier; 034 private String vendorDunsNumber; // this is string constant if DUNS not found 035 private Integer vendorHeaderGeneratedIdentifier; 036 private Integer vendorDetailAssignedIdentifier; 037 private String vendorName; 038 private Integer invoiceLoadSuccessCount = new Integer(0); 039 private KualiDecimal invoiceLoadSuccessAmount = new KualiDecimal(0.00); 040 private Integer invoiceLoadFailCount = new Integer(0); 041 private KualiDecimal invoiceLoadFailAmount = new KualiDecimal(0.00); 042 private Boolean isEmpty = Boolean.TRUE; 043 private Timestamp fileProcessTimestamp; 044 045 public ElectronicInvoiceLoadSummary() { 046 super(); 047 } 048 049 public ElectronicInvoiceLoadSummary(String vendorDunsNumber) { 050 super(); 051 this.vendorDunsNumber = vendorDunsNumber; 052 } 053 054 public void addSuccessfulInvoiceOrder(KualiDecimal amount, 055 ElectronicInvoice eInvoice) { 056 isEmpty = Boolean.FALSE; 057 invoiceLoadSuccessCount = new Integer(invoiceLoadSuccessCount.intValue() + 1); 058 fileProcessTimestamp = SpringContext.getBean(DateTimeService.class).getCurrentTimestamp(); 059 060 if (amount != null) { 061 invoiceLoadSuccessAmount = invoiceLoadSuccessAmount.add(amount); 062 } 063 064 setupVendorInformation(eInvoice); 065 } 066 067 public void addFailedInvoiceOrder(KualiDecimal amount, 068 ElectronicInvoice eInvoice) { 069 isEmpty = Boolean.FALSE; 070 invoiceLoadFailCount = new Integer(invoiceLoadFailCount.intValue() + 1); 071 fileProcessTimestamp = SpringContext.getBean(DateTimeService.class).getCurrentTimestamp(); 072 073 if (amount != null) { 074 invoiceLoadFailAmount = invoiceLoadFailAmount.add(amount); 075 } 076 077 setupVendorInformation(eInvoice); 078 } 079 080 public void addFailedInvoiceOrder(ElectronicInvoice ei) { 081 this.addFailedInvoiceOrder(new KualiDecimal(0),ei); 082 } 083 084 public void addFailedInvoiceOrder() { 085 this.addFailedInvoiceOrder(new KualiDecimal(0),null); 086 } 087 088 private void setupVendorInformation(ElectronicInvoice eInvoice) { 089 090 if (eInvoice != null && 091 getVendorHeaderGeneratedIdentifier() == null && 092 getVendorDetailAssignedIdentifier() == null) { 093 094 setVendorHeaderGeneratedIdentifier(eInvoice.getVendorHeaderID()); 095 setVendorDetailAssignedIdentifier(eInvoice.getVendorDetailID()); 096 setVendorName(eInvoice.getVendorName()); 097 098 } 099 } 100 101 public String getVendorDescriptor() { 102 String kualiDescriptor = null; 103 if ( (this.vendorName != null) && (this.vendorHeaderGeneratedIdentifier != null) && (this.vendorDetailAssignedIdentifier != null) ) { 104 kualiDescriptor = " (Kuali Match: " + this.vendorName + " ~ " + vendorHeaderGeneratedIdentifier + "-" + vendorDetailAssignedIdentifier + ")"; 105 } else if ( (this.vendorHeaderGeneratedIdentifier != null) && (this.vendorDetailAssignedIdentifier != null) ) { 106 kualiDescriptor = " (Kuali Match: " + vendorHeaderGeneratedIdentifier + "-" + vendorDetailAssignedIdentifier + ")"; 107 } else if (this.vendorName != null) { 108 kualiDescriptor = " (Kuali Match: " + this.vendorName + ")"; 109 } 110 return this.getVendorDunsNumber() + ((kualiDescriptor != null) ? kualiDescriptor : ""); 111 } 112 113 /** 114 * @return the vendorDetailAssignedIdentifier 115 */ 116 public Integer getVendorDetailAssignedIdentifier() { 117 return vendorDetailAssignedIdentifier; 118 } 119 120 /** 121 * @param vendorDetailAssignedIdentifier the vendorDetailAssignedIdentifier to set 122 */ 123 public void setVendorDetailAssignedIdentifier(Integer kualiVendorDetailId) { 124 this.vendorDetailAssignedIdentifier = kualiVendorDetailId; 125 } 126 127 /** 128 * @return the vendorHeaderGeneratedIdentifier 129 */ 130 public Integer getVendorHeaderGeneratedIdentifier() { 131 return vendorHeaderGeneratedIdentifier; 132 } 133 134 /** 135 * @param vendorHeaderGeneratedIdentifier the vendorHeaderGeneratedIdentifier to set 136 */ 137 public void setVendorHeaderGeneratedIdentifier(Integer kualiVendorHeaderId) { 138 this.vendorHeaderGeneratedIdentifier = kualiVendorHeaderId; 139 } 140 141 /** 142 * @return the vendorName 143 */ 144 public String getVendorName() { 145 return vendorName; 146 } 147 148 /** 149 * @param vendorName the vendorName to set 150 */ 151 public void setVendorName(String kualiVendorName) { 152 this.vendorName = kualiVendorName; 153 } 154 155 /** 156 * @return the invoiceLoadFailAmount 157 */ 158 public KualiDecimal getInvoiceLoadFailAmount() { 159 return invoiceLoadFailAmount; 160 } 161 162 /** 163 * @param invoiceLoadFailAmount the invoiceLoadFailAmount to set 164 */ 165 public void setInvoiceLoadFailAmount(KualiDecimal failAmount) { 166 this.invoiceLoadFailAmount = failAmount; 167 } 168 169 /** 170 * @return the invoiceLoadFailCount 171 */ 172 public Integer getInvoiceLoadFailCount() { 173 return invoiceLoadFailCount; 174 } 175 176 /** 177 * @param invoiceLoadFailCount the invoiceLoadFailCount to set 178 */ 179 public void setInvoiceLoadFailCount(Integer failCount) { 180 this.invoiceLoadFailCount = failCount; 181 } 182 183 /** 184 * @return the invoiceLoadSummaryIdentifier 185 */ 186 public Integer getInvoiceLoadSummaryIdentifier() { 187 return invoiceLoadSummaryIdentifier; 188 } 189 190 /** 191 * @param invoiceLoadSummaryIdentifier the invoiceLoadSummaryIdentifier to set 192 */ 193 public void setInvoiceLoadSummaryIdentifier(Integer id) { 194 this.invoiceLoadSummaryIdentifier = id; 195 } 196 197 /** 198 * @return the isEmpty 199 */ 200 public Boolean isEmpty() { 201 return isEmpty; 202 } 203 204 /** 205 * @param isEmpty the isEmpty to set 206 */ 207 public void setIsEmpty(Boolean isEmpty) { 208 this.isEmpty = isEmpty; 209 } 210 211 /** 212 * @return the invoiceLoadSuccessAmount 213 */ 214 public KualiDecimal getInvoiceLoadSuccessAmount() { 215 return invoiceLoadSuccessAmount; 216 } 217 218 /** 219 * @param invoiceLoadSuccessAmount the invoiceLoadSuccessAmount to set 220 */ 221 public void setInvoiceLoadSuccessAmount(KualiDecimal successAmount) { 222 this.invoiceLoadSuccessAmount = successAmount; 223 } 224 225 /** 226 * @return the invoiceLoadSuccessCount 227 */ 228 public Integer getInvoiceLoadSuccessCount() { 229 return invoiceLoadSuccessCount; 230 } 231 232 /** 233 * @param invoiceLoadSuccessCount the invoiceLoadSuccessCount to set 234 */ 235 public void setInvoiceLoadSuccessCount(Integer successCount) { 236 this.invoiceLoadSuccessCount = successCount; 237 } 238 239 /** 240 * @return the vendorDunsNumber 241 */ 242 public String getVendorDunsNumber() { 243 return vendorDunsNumber; 244 } 245 246 /** 247 * @param vendorDunsNumber the vendorDunsNumber to set 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 * @see org.kuali.rice.kns.bo.BusinessObjectBase#toStringMapper() 263 */ 264 protected LinkedHashMap toStringMapper() { 265 LinkedHashMap m = new LinkedHashMap(); 266 m.put("invoiceLoadSummaryIdentifier", this.invoiceLoadSummaryIdentifier); 267 return m; 268 } 269 }