1   
2   
3   
4   
5   
6   
7   
8   
9   
10  
11  
12  
13  
14  
15  
16  package org.kuali.ole.module.purap.document;
17  
18  import org.apache.commons.lang.StringUtils;
19  import org.apache.commons.lang.math.NumberUtils;
20  import org.kuali.ole.module.purap.PurapParameterConstants;
21  import org.kuali.ole.module.purap.businessobject.*;
22  import org.kuali.ole.module.purap.document.service.PurchaseOrderService;
23  import org.kuali.ole.module.purap.service.ElectronicInvoiceMappingService;
24  import org.kuali.ole.module.purap.util.ElectronicInvoiceUtils;
25  import org.kuali.ole.module.purap.util.PurApRelatedViews;
26  import org.kuali.ole.module.purap.util.PurapSearchUtils;
27  import org.kuali.ole.sys.OLEConstants.AdHocPaymentIndicator;
28  import org.kuali.ole.sys.ObjectUtil;
29  import org.kuali.ole.sys.context.SpringContext;
30  import org.kuali.ole.sys.document.FinancialSystemTransactionalDocumentBase;
31  import org.kuali.ole.sys.service.impl.OleParameterConstants;
32  import org.kuali.ole.vnd.businessobject.CampusParameter;
33  import org.kuali.ole.vnd.businessobject.VendorDetail;
34  import org.kuali.ole.vnd.document.service.VendorService;
35  import org.kuali.rice.core.api.datetime.DateTimeService;
36  import org.kuali.rice.core.api.util.type.KualiDecimal;
37  import org.kuali.rice.coreservice.framework.parameter.ParameterService;
38  import org.kuali.rice.kew.framework.postprocessor.DocumentRouteStatusChange;
39  import org.kuali.rice.krad.bo.Note;
40  import org.kuali.rice.krad.document.SessionDocument;
41  import org.kuali.rice.krad.util.NoteType;
42  import org.kuali.rice.krad.util.ObjectUtils;
43  
44  import java.math.BigDecimal;
45  import java.sql.Timestamp;
46  import java.text.MessageFormat;
47  import java.text.ParseException;
48  import java.util.ArrayList;
49  import java.util.Date;
50  import java.util.Iterator;
51  import java.util.List;
52  
53  public class ElectronicInvoiceRejectDocument extends FinancialSystemTransactionalDocumentBase implements SessionDocument {
54      protected static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(ElectronicInvoiceRejectDocument.class);
55      protected static BigDecimal zero = new BigDecimal(0);
56  
57      
58      protected Integer purapDocumentIdentifier;
59      protected Integer accountsPayablePurchasingDocumentLinkIdentifier;
60      protected Integer invoiceLoadSummaryIdentifier;
61      protected Timestamp invoiceProcessTimestamp;
62      protected Boolean invoiceFileHeaderTypeIndicator = Boolean.FALSE;
63      protected Boolean invoiceFileInformationOnlyIndicator = Boolean.FALSE;
64      protected Boolean invoiceFileTaxInLineIndicator = Boolean.FALSE;
65      protected Boolean invoiceFileSpecialHandlingInLineIndicator = Boolean.FALSE;
66      protected Boolean invoiceFileShippingInLineIndicator = Boolean.FALSE;
67      protected Boolean invoiceFileDiscountInLineIndicator = Boolean.FALSE;
68  
69      protected String invoiceFileName;
70      protected String vendorDunsNumber;
71      protected Integer vendorHeaderGeneratedIdentifier;
72      protected Integer vendorDetailAssignedIdentifier;
73      protected String invoiceFileDate;
74      protected String invoiceFileNumber;
75      protected String invoiceFilePurposeIdentifier;
76      protected String invoiceFileOperationIdentifier;
77      protected String invoiceFileDeploymentModeValue;
78      protected String invoiceOrderReferenceOrderIdentifier;
79      protected String invoiceOrderReferenceDocumentReferencePayloadIdentifier;
80      protected String invoiceOrderReferenceDocumentReferenceText;
81      protected String invoiceOrderMasterAgreementReferenceIdentifier;
82      protected String invoiceOrderMasterAgreementReferenceDate;
83      protected String invoiceOrderMasterAgreementInformationIdentifier;
84      protected String invoiceOrderMasterAgreementInformationDate;
85      protected String invoiceOrderPurchaseOrderIdentifier;
86      protected String invoiceOrderPurchaseOrderDate;
87      protected String invoiceOrderSupplierOrderInformationIdentifier;
88      protected String invoiceShipDate;
89      protected String invoiceShipToAddressName;
90      protected String invoiceShipToAddressType;
91      protected String invoiceShipToAddressLine1;
92      protected String invoiceShipToAddressLine2;
93      protected String invoiceShipToAddressLine3;
94      protected String invoiceShipToAddressCityName;
95      protected String invoiceShipToAddressStateCode;
96      protected String invoiceShipToAddressPostalCode;
97      protected String invoiceShipToAddressCountryCode;
98      protected String invoiceShipToAddressCountryName;
99      protected String invoiceBillToAddressName;
100     protected String invoiceBillToAddressType;
101     protected String invoiceBillToAddressLine1;
102     protected String invoiceBillToAddressLine2;
103     protected String invoiceBillToAddressLine3;
104     protected String invoiceBillToAddressCityName;
105     protected String invoiceBillToAddressStateCode;
106     protected String invoiceBillToAddressPostalCode;
107     protected String invoiceBillToAddressCountryCode;
108     protected String invoiceBillToAddressCountryName;
109     protected String invoiceRemitToAddressName;
110     protected String invoiceRemitToAddressType;
111     protected String invoiceRemitToAddressLine1;
112     protected String invoiceRemitToAddressLine2;
113     protected String invoiceRemitToAddressLine3;
114     protected String invoiceRemitToAddressCityName;
115     protected String invoiceRemitToAddressStateCode;
116     protected String invoiceRemitToAddressPostalCode;
117     protected String invoiceRemitToAddressCountryCode;
118     protected String invoiceRemitToAddressCountryName;
119 
120     protected Integer paymentRequestIdentifier;
121 
122     protected String invoiceCustomerNumber;
123     protected String invoicePurchaseOrderNumber;
124     protected Integer purchaseOrderIdentifier;
125     protected String purchaseOrderDeliveryCampusCode;
126 
127     protected String invoiceItemSubTotalCurrencyCode;
128     protected String invoiceItemSpecialHandlingCurrencyCode;
129     protected String invoiceItemSpecialHandlingDescription;
130     protected String invoiceItemShippingCurrencyCode;
131     protected String invoiceItemShippingDescription;
132     protected String invoiceItemTaxCurrencyCode;
133     protected String invoiceItemTaxDescription;
134     protected String invoiceItemGrossCurrencyCode;
135     protected String invoiceItemDiscountCurrencyCode;
136     protected String invoiceItemNetCurrencyCode;
137 
138     protected BigDecimal invoiceItemSubTotalAmount;
139     protected BigDecimal invoiceItemSpecialHandlingAmount;
140     protected BigDecimal invoiceItemShippingAmount;
141     protected BigDecimal invoiceItemTaxAmount;
142     protected BigDecimal invoiceItemGrossAmount;
143     protected BigDecimal invoiceItemDiscountAmount;
144     protected BigDecimal invoiceItemNetAmount;
145 
146     protected boolean invoiceNumberAcceptIndicator = false;
147     protected boolean invoiceResearchIndicator = false;
148     protected Timestamp invoiceFileTimeStampForSearch;
149 
150     protected Timestamp accountsPayableApprovalTimestamp;
151 
152     protected transient PurApRelatedViews relatedViews;
153     protected PurchaseOrderDocument currentPurchaseOrderDocument;
154 
155     protected VendorDetail vendorDetail;
156     protected ElectronicInvoiceLoadSummary invoiceLoadSummary;
157     protected List<ElectronicInvoiceRejectItem> invoiceRejectItems = new ArrayList<ElectronicInvoiceRejectItem>();
158     protected List<ElectronicInvoiceRejectReason> invoiceRejectReasons = new ArrayList<ElectronicInvoiceRejectReason>();
159 
160     protected boolean isDocumentCreationInProgress = false;
161 
162     protected String vendorNumber;
163 
164     protected CampusParameter purchaseOrderDeliveryCampus;
165 
166     
167 
168 
169     public ElectronicInvoiceRejectDocument() {
170         super();
171     }
172 
173     public void setFileLevelData(ElectronicInvoice ei) {
174         DateTimeService dateTimeService = SpringContext.getBean(DateTimeService.class);
175         this.invoiceProcessTimestamp = dateTimeService.getCurrentTimestamp();
176         this.invoiceFileHeaderTypeIndicator = new Boolean(ei.getInvoiceDetailRequestHeader().isHeaderInvoiceIndicator());
177         this.invoiceFileInformationOnlyIndicator = new Boolean(ei.getInvoiceDetailRequestHeader().isInformationOnly());
178         this.invoiceFileTaxInLineIndicator = new Boolean(ei.getInvoiceDetailRequestHeader().isTaxInLine());
179         this.invoiceFileSpecialHandlingInLineIndicator = new Boolean(ei.getInvoiceDetailRequestHeader().isSpecialHandlingInLine());
180         this.invoiceFileShippingInLineIndicator = new Boolean(ei.getInvoiceDetailRequestHeader().isShippingInLine());
181         this.invoiceFileDiscountInLineIndicator = new Boolean(ei.getInvoiceDetailRequestHeader().isDiscountInLine());
182 
183         this.invoiceFileName = ei.getFileName();
184         this.vendorDunsNumber = ei.getDunsNumber();
185         this.vendorHeaderGeneratedIdentifier = ei.getVendorHeaderID();
186         this.vendorDetailAssignedIdentifier = ei.getVendorDetailID();
187         this.invoiceFileDate = ei.getInvoiceDateDisplayText();
188         this.invoiceFileNumber = ei.getInvoiceDetailRequestHeader().getInvoiceId();
189         this.invoiceFilePurposeIdentifier = ei.getInvoiceDetailRequestHeader().getPurpose();
190         this.invoiceFileOperationIdentifier = ei.getInvoiceDetailRequestHeader().getOperation();
191         this.invoiceFileDeploymentModeValue = ei.getDeploymentMode();
192         this.invoiceCustomerNumber = ei.getCustomerNumber();
193 
194         for (ElectronicInvoiceRejectReason eirr : ei.getFileRejectReasons()) {
195             ElectronicInvoiceRejectReason newReason = new ElectronicInvoiceRejectReason();
196             ObjectUtil.buildObject(newReason, eirr);
197             this.invoiceRejectReasons.add(newReason);
198         }
199     }
200 
201     public void setInvoiceOrderLevelData(ElectronicInvoice ei, ElectronicInvoiceOrder eio) {
202         this.invoiceOrderReferenceOrderIdentifier = eio.getOrderReferenceOrderID();
203         this.invoiceOrderReferenceDocumentReferencePayloadIdentifier = eio.getOrderReferenceDocumentRefPayloadID();
204         this.invoiceOrderReferenceDocumentReferenceText = eio.getOrderReferenceDocumentRef();
205         this.invoiceOrderMasterAgreementReferenceIdentifier = eio.getMasterAgreementReferenceID();
206         this.invoiceOrderMasterAgreementReferenceDate = ei.getMasterAgreementReferenceDateDisplayText(eio);
207         this.invoiceOrderMasterAgreementInformationIdentifier = eio.getMasterAgreementIDInfoID();
208         this.invoiceOrderMasterAgreementInformationDate = ei.getMasterAgreementIDInfoDateDisplayText(eio);
209         this.invoiceOrderPurchaseOrderIdentifier = eio.getOrderIDInfoID();
210         this.invoiceOrderPurchaseOrderDate = ei.getOrderIDInfoDateDisplayText(eio);
211         this.invoiceOrderSupplierOrderInformationIdentifier = eio.getSupplierOrderInfoID();
212         this.invoiceShipDate = ei.getShippingDateDisplayText(eio);
213 
214         ElectronicInvoiceContact shipToContact = ei.getCxmlContact(eio, ElectronicInvoiceMappingService.CXML_ADDRESS_SHIP_TO_ROLE_ID);
215         ElectronicInvoicePostalAddress shipToAddress = this.getCxmlPostalAddressByAddressName(shipToContact, ElectronicInvoiceMappingService.CXML_ADDRESS_SHIP_TO_NAME);
216         
217         
218         
219         if (shipToAddress != null) {
220             this.invoiceShipToAddressName = shipToContact.getName();
221             this.invoiceShipToAddressType = shipToAddress.getType();
222             this.invoiceShipToAddressLine1 = shipToAddress.getLine1();
223             this.invoiceShipToAddressLine2 = shipToAddress.getLine2();
224             this.invoiceShipToAddressLine3 = shipToAddress.getLine3();
225             this.invoiceShipToAddressCityName = shipToAddress.getCityName();
226             this.invoiceShipToAddressStateCode = shipToAddress.getStateCode();
227             this.invoiceShipToAddressPostalCode = shipToAddress.getPostalCode();
228             this.invoiceShipToAddressCountryCode = shipToAddress.getCountryCode();
229             this.invoiceShipToAddressCountryName = shipToAddress.getCountryName();
230         }
231 
232         ElectronicInvoiceContact billToContact = ei.getCxmlContact(eio, ElectronicInvoiceMappingService.CXML_ADDRESS_BILL_TO_ROLE_ID);
233         ElectronicInvoicePostalAddress billToAddress = this.getCxmlPostalAddressByAddressName(billToContact, ElectronicInvoiceMappingService.CXML_ADDRESS_BILL_TO_NAME);
234         
235         
236         
237         if (billToAddress != null) {
238             this.invoiceBillToAddressName = billToContact.getName();
239             this.invoiceBillToAddressType = billToAddress.getType();
240             this.invoiceBillToAddressLine1 = billToAddress.getLine1();
241             this.invoiceBillToAddressLine2 = billToAddress.getLine2();
242             this.invoiceBillToAddressLine3 = billToAddress.getLine3();
243             this.invoiceBillToAddressCityName = billToAddress.getCityName();
244             this.invoiceBillToAddressStateCode = billToAddress.getStateCode();
245             this.invoiceBillToAddressPostalCode = billToAddress.getPostalCode();
246             this.invoiceBillToAddressCountryCode = billToAddress.getCountryCode();
247             this.invoiceBillToAddressCountryName = billToAddress.getCountryName();
248         }
249 
250         ElectronicInvoiceContact remitToContact = ei.getCxmlContact(eio, ElectronicInvoiceMappingService.CXML_ADDRESS_REMIT_TO_ROLE_ID);
251         ElectronicInvoicePostalAddress remitToAddress = this.getCxmlPostalAddressByAddressName(remitToContact, ElectronicInvoiceMappingService.CXML_ADDRESS_REMIT_TO_NAME);
252         
253         
254         
255         if (remitToAddress != null) {
256             this.invoiceRemitToAddressName = remitToContact.getName();
257             this.invoiceRemitToAddressType = remitToAddress.getType();
258             this.invoiceRemitToAddressLine1 = remitToAddress.getLine1();
259             this.invoiceRemitToAddressLine2 = remitToAddress.getLine2();
260             this.invoiceRemitToAddressLine3 = remitToAddress.getLine3();
261             this.invoiceRemitToAddressCityName = remitToAddress.getCityName();
262             this.invoiceRemitToAddressStateCode = remitToAddress.getStateCode();
263             this.invoiceRemitToAddressPostalCode = remitToAddress.getPostalCode();
264             this.invoiceRemitToAddressCountryCode = remitToAddress.getCountryCode();
265             this.invoiceRemitToAddressCountryName = remitToAddress.getCountryName();
266         }
267         this.invoicePurchaseOrderNumber = eio.getInvoicePurchaseOrderID();
268         this.purchaseOrderIdentifier = eio.getPurchaseOrderID();
269         this.purchaseOrderDeliveryCampusCode = eio.getPurchaseOrderCampusCode();
270 
271         try {
272             this.invoiceItemSubTotalAmount = ei.getInvoiceSubTotalAmount(eio);
273             this.invoiceItemSubTotalCurrencyCode = ei.getInvoiceSubTotalCurrencyIfNotValid(eio);
274         } catch (Exception e) {
275             this.invoiceItemSubTotalAmount = null;
276             this.invoiceItemSubTotalCurrencyCode = "INVALID Amount";
277         }
278         try {
279             this.invoiceItemSpecialHandlingAmount = ei.getInvoiceSpecialHandlingAmount(eio);
280             this.invoiceItemSpecialHandlingCurrencyCode = ei.getInvoiceSpecialHandlingCurrencyIfNotValid(eio);
281         } catch (Exception e) {
282             this.invoiceItemSpecialHandlingAmount = null;
283             this.invoiceItemSpecialHandlingCurrencyCode = "INVALID AMOUNT";
284         }
285         this.invoiceItemSpecialHandlingDescription = ei.getInvoiceSpecialHandlingDescription(eio);
286         try {
287             this.invoiceItemShippingAmount = ei.getInvoiceShippingAmount(eio);
288             this.invoiceItemShippingCurrencyCode = ei.getInvoiceShippingCurrencyIfNotValid(eio);
289         } catch (Exception e) {
290             this.invoiceItemShippingAmount = null;
291             this.invoiceItemShippingCurrencyCode = "INVALID AMOUNT";
292         }
293         this.invoiceItemShippingDescription = ei.getInvoiceShippingDescription(eio);
294         try {
295             this.invoiceItemTaxAmount = ei.getInvoiceTaxAmount(eio);
296             this.invoiceItemTaxCurrencyCode = ei.getInvoiceTaxCurrencyIfNotValid(eio);
297         } catch (Exception e) {
298             this.invoiceItemTaxAmount = null;
299             this.invoiceItemTaxCurrencyCode = "INVALID AMOUNT";
300         }
301         this.invoiceItemTaxDescription = ei.getInvoiceTaxDescription(eio);
302         try {
303             this.invoiceItemGrossAmount = ei.getInvoiceGrossAmount(eio);
304             this.invoiceItemGrossCurrencyCode = ei.getInvoiceGrossCurrencyIfNotValid(eio);
305         } catch (Exception e) {
306             this.invoiceItemGrossAmount = null;
307             this.invoiceItemGrossCurrencyCode = "INVALID AMOUNT";
308         }
309         try {
310             this.invoiceItemDiscountAmount = ei.getInvoiceDiscountAmount(eio);
311             this.invoiceItemDiscountCurrencyCode = ei.getInvoiceDiscountCurrencyIfNotValid(eio);
312         } catch (Exception e) {
313             this.invoiceItemDiscountAmount = null;
314             this.invoiceItemDiscountCurrencyCode = "INVALID AMOUNT";
315         }
316         try {
317             this.invoiceItemNetAmount = ei.getInvoiceNetAmount(eio);
318             this.invoiceItemNetCurrencyCode = ei.getInvoiceNetCurrencyIfNotValid(eio);
319         } catch (Exception e) {
320             this.invoiceItemNetAmount = null;
321             this.invoiceItemNetCurrencyCode = "INVALID AMOUNT";
322         }
323 
324         for (ElectronicInvoiceItem eii : eio.getInvoiceItems()) {
325             ElectronicInvoiceRejectItem eiri = new ElectronicInvoiceRejectItem(this, eii);
326             this.invoiceRejectItems.add(eiri);
327         }
328 
329         for (ElectronicInvoiceRejectReason eirr : eio.getOrderRejectReasons()) {
330             eirr.setElectronicInvoiceRejectDocument(this);
331             this.invoiceRejectReasons.add(eirr);
332         }
333     }
334 
335     
336 
337 
338     @Override
339     public String getDocumentTitle() {
340         if (SpringContext.getBean(ParameterService.class).getParameterValueAsBoolean(ElectronicInvoiceRejectDocument.class, PurapParameterConstants.PURAP_OVERRIDE_EIRT_DOC_TITLE)) {
341             return getCustomDocumentTitle();
342         }
343 
344         return this.buildDocumentTitle(super.getDocumentTitle());
345     }
346 
347     
348 
349 
350 
351 
352     protected String getCustomDocumentTitle() {
353         String poID = StringUtils.isEmpty(getInvoicePurchaseOrderNumber()) ? "UNKNOWN" : getInvoicePurchaseOrderNumber();
354         String researchInd = isInvoiceResearchIndicator() ? "Y" : "N";
355 
356         
357         VendorDetail vendorDetail = getVendorDetail();
358         Integer headerId = getVendorHeaderGeneratedIdentifier();
359         Integer detailId = getVendorDetailAssignedIdentifier();
360         if (vendorDetail == null && headerId != null && detailId != null) {
361             vendorDetail = SpringContext.getBean(VendorService.class).getVendorDetail(headerId, detailId);
362         }
363         String vendorName = vendorDetail == null || StringUtils.isEmpty(vendorDetail.getVendorName()) ? "UNKNOWN" : vendorDetail.getVendorName();
364 
365         
366         String documentTitle = "Vendor: " + vendorName + " PO: " + poID + " " + researchInd;
367         return documentTitle;
368     }
369 
370     
371 
372 
373 
374 
375 
376     protected String buildDocumentTitle(String title) {
377         if (this.getVendorDetail() == null) {
378             return title;
379         }
380 
381         Integer vendorHeaderGeneratedIdentifier = this.getVendorDetail().getVendorHeaderGeneratedIdentifier();
382         VendorService vendorService = SpringContext.getBean(VendorService.class);
383 
384         Object[] indicators = new String[2];
385 
386         boolean isEmployeeVendor = vendorService.isVendorInstitutionEmployee(vendorHeaderGeneratedIdentifier);
387         indicators[0] = isEmployeeVendor ? AdHocPaymentIndicator.EMPLOYEE_VENDOR : AdHocPaymentIndicator.OTHER;
388 
389         boolean isVendorForeign = vendorService.isVendorForeign(vendorHeaderGeneratedIdentifier);
390         indicators[1] = isVendorForeign ? AdHocPaymentIndicator.ALIEN_VENDOR : AdHocPaymentIndicator.OTHER;
391 
392         for (Object indicator : indicators) {
393             if (!AdHocPaymentIndicator.OTHER.equals(indicator)) {
394                 String titlePattern = title + " [{0}:{1}]";
395                 return MessageFormat.format(titlePattern, indicators);
396             }
397         }
398 
399         return title;
400     }
401 
402     protected ElectronicInvoicePostalAddress getCxmlPostalAddressByAddressName(ElectronicInvoiceContact contact, String addressName) {
403         if (contact != null) {
404             for (ElectronicInvoicePostalAddress cpa : contact.getPostalAddresses()) {
405                 if (addressName == null) {
406                     return cpa;
407                 } else {
408                     if (addressName.equalsIgnoreCase(cpa.getName())) {
409                         return cpa;
410                     }
411                 }
412             }
413         }
414         return null;
415     }
416 
417     public KualiDecimal getTotalAmount() {
418         KualiDecimal returnValue = new KualiDecimal(zero);
419         try {
420             for (ElectronicInvoiceRejectItem eiri : this.invoiceRejectItems) {
421                 BigDecimal toAddAmount1 = eiri.getInvoiceItemSubTotalAmount();
422                 KualiDecimal toAddAmount = KualiDecimal.ZERO;
423                 if (toAddAmount1 != null) {
424                     toAddAmount = new KualiDecimal(toAddAmount1.setScale(KualiDecimal.SCALE, KualiDecimal.ROUND_BEHAVIOR));
425                 }
426                 if (LOG.isDebugEnabled()) {
427                     LOG.debug("getTotalAmount() setting returnValue with arithmatic => '" + returnValue.doubleValue() + "' + '" + toAddAmount.doubleValue() + "'");
428                 }
429                 returnValue = returnValue.add(toAddAmount);
430             }
431             if (LOG.isDebugEnabled()) {
432                 LOG.debug("getTotalAmount() returning amount " + returnValue.doubleValue());
433             }
434             return returnValue;
435         } catch (NumberFormatException n) {
436             
437             LOG.error("getTotalAmount() Error attempting to calculate total amount for invoice with filename " + this.invoiceFileName);
438             return new KualiDecimal(zero);
439         }
440     }
441 
442     public void setTotalAmount(KualiDecimal amount) {
443         
444     }
445 
446     public KualiDecimal getGrandTotalAmount() {
447         KualiDecimal returnValue = new KualiDecimal(zero);
448         try {
449             for (ElectronicInvoiceRejectItem eiri : this.invoiceRejectItems) {
450                 KualiDecimal toAddAmount = new KualiDecimal(eiri.getInvoiceItemNetAmount());
451                 if (LOG.isDebugEnabled()) {
452                     LOG.debug("getTotalAmount() setting returnValue with arithmatic => '" + returnValue.doubleValue() + "' + '" + toAddAmount.doubleValue() + "'");
453                 }
454                 returnValue = returnValue.add(toAddAmount);
455             }
456             if (LOG.isDebugEnabled()) {
457                 LOG.debug("getTotalAmount() returning amount " + returnValue.doubleValue());
458             }
459 
460             if (this.getInvoiceItemSpecialHandlingAmount() != null && zero.compareTo(this.getInvoiceItemSpecialHandlingAmount()) != 0) {
461                 returnValue = returnValue.add(new KualiDecimal(this.getInvoiceItemSpecialHandlingAmount()));
462             }
463             if (this.getInvoiceItemShippingAmount() != null && zero.compareTo(this.getInvoiceItemShippingAmount()) != 0) {
464                 returnValue = returnValue.add(new KualiDecimal(this.getInvoiceItemShippingAmount()));
465             }
466             
467             
468             
469             if (this.getInvoiceItemDiscountAmount() != null && zero.compareTo(this.getInvoiceItemDiscountAmount()) != 0) {
470                 returnValue = returnValue.subtract(new KualiDecimal(this.getInvoiceItemDiscountAmount()));
471             }
472             if (LOG.isDebugEnabled()) {
473                 LOG.debug("getGrandTotalAmount() returning amount " + returnValue.doubleValue());
474             }
475             return returnValue;
476         } catch (NumberFormatException n) {
477             
478             LOG.error("getTotalAmount() Error attempting to calculate total amount for invoice with filename " + this.invoiceFileName);
479             return new KualiDecimal(zero);
480         }
481     }
482 
483     public void setGrandTotalAmount(KualiDecimal amount) {
484         
485     }
486 
487     
488 
489 
490     public Integer getInvoiceLoadSummaryIdentifier() {
491         return invoiceLoadSummaryIdentifier;
492     }
493 
494     
495 
496 
497     public void setInvoiceLoadSummaryIdentifier(Integer loadSummaryId) {
498         this.invoiceLoadSummaryIdentifier = loadSummaryId;
499     }
500 
501     public PurchaseOrderDocument getCurrentPurchaseOrderDocument() {
502 
503         if (StringUtils.isEmpty(getInvoicePurchaseOrderNumber()) ||
504                 !NumberUtils.isDigits(getInvoicePurchaseOrderNumber())) {
505             currentPurchaseOrderDocument = null;
506         } else if (currentPurchaseOrderDocument == null) {
507             currentPurchaseOrderDocument = SpringContext.getBean(PurchaseOrderService.class).getCurrentPurchaseOrder(new Integer(getInvoicePurchaseOrderNumber()));
508         } else if (!StringUtils.equals(getInvoicePurchaseOrderNumber(), currentPurchaseOrderDocument.getPurapDocumentIdentifier().toString())) {
509             currentPurchaseOrderDocument = SpringContext.getBean(PurchaseOrderService.class).getCurrentPurchaseOrder(new Integer(getInvoicePurchaseOrderNumber()));
510         }
511 
512         return currentPurchaseOrderDocument;
513     }
514 
515     public VendorDetail getVendorDetail() {
516         return vendorDetail;
517     }
518 
519     public void setVendorDetail(VendorDetail vendorDetail) {
520         this.vendorDetail = vendorDetail;
521     }
522 
523     
524 
525 
526     public ElectronicInvoiceLoadSummary getInvoiceLoadSummary() {
527         return invoiceLoadSummary;
528     }
529 
530     
531 
532 
533     public void setInvoiceLoadSummary(ElectronicInvoiceLoadSummary electronicInvoiceLoadSummary) {
534         this.invoiceLoadSummary = electronicInvoiceLoadSummary;
535         this.invoiceLoadSummaryIdentifier = electronicInvoiceLoadSummary.getInvoiceLoadSummaryIdentifier();
536     }
537 
538     
539 
540 
541     public String getInvoiceBillToAddressCityName() {
542         return invoiceBillToAddressCityName;
543     }
544 
545     
546 
547 
548     public void setInvoiceBillToAddressCityName(String billToAddressCityName) {
549         this.invoiceBillToAddressCityName = billToAddressCityName;
550     }
551 
552     
553 
554 
555     public String getInvoiceBillToAddressCountryCode() {
556         return invoiceBillToAddressCountryCode;
557     }
558 
559     
560 
561 
562 
563     public void setInvoiceBillToAddressCountryCode(String billToAddressCountryCode) {
564         this.invoiceBillToAddressCountryCode = billToAddressCountryCode;
565     }
566 
567     
568 
569 
570     public String getInvoiceBillToAddressCountryName() {
571         return invoiceBillToAddressCountryName;
572     }
573 
574     
575 
576 
577 
578     public void setInvoiceBillToAddressCountryName(String billToAddressCountryName) {
579         this.invoiceBillToAddressCountryName = billToAddressCountryName;
580     }
581 
582     
583 
584 
585     public String getInvoiceBillToAddressLine1() {
586         return invoiceBillToAddressLine1;
587     }
588 
589     
590 
591 
592     public void setInvoiceBillToAddressLine1(String billToAddressLine1) {
593         this.invoiceBillToAddressLine1 = billToAddressLine1;
594     }
595 
596     
597 
598 
599     public String getInvoiceBillToAddressLine2() {
600         return invoiceBillToAddressLine2;
601     }
602 
603     
604 
605 
606     public void setInvoiceBillToAddressLine2(String billToAddressLine2) {
607         this.invoiceBillToAddressLine2 = billToAddressLine2;
608     }
609 
610     
611 
612 
613     public String getInvoiceBillToAddressLine3() {
614         return invoiceBillToAddressLine3;
615     }
616 
617     
618 
619 
620     public void setInvoiceBillToAddressLine3(String billToAddressLine3) {
621         this.invoiceBillToAddressLine3 = billToAddressLine3;
622     }
623 
624     
625 
626 
627     public String getInvoiceBillToAddressName() {
628         return invoiceBillToAddressName;
629     }
630 
631     
632 
633 
634     public void setInvoiceBillToAddressName(String billToAddressName) {
635         this.invoiceBillToAddressName = billToAddressName;
636     }
637 
638     
639 
640 
641     public String getInvoiceBillToAddressPostalCode() {
642         return invoiceBillToAddressPostalCode;
643     }
644 
645     
646 
647 
648     public void setInvoiceBillToAddressPostalCode(String billToAddressPostalCode) {
649         this.invoiceBillToAddressPostalCode = billToAddressPostalCode;
650     }
651 
652     
653 
654 
655     public String getInvoiceBillToAddressStateCode() {
656         return invoiceBillToAddressStateCode;
657     }
658 
659     
660 
661 
662     public void setInvoiceBillToAddressStateCode(String billToAddressStateCode) {
663         this.invoiceBillToAddressStateCode = billToAddressStateCode;
664     }
665 
666     
667 
668 
669     public String getInvoiceBillToAddressType() {
670         return invoiceBillToAddressType;
671     }
672 
673     
674 
675 
676     public void setInvoiceBillToAddressType(String billToAddressType) {
677         this.invoiceBillToAddressType = billToAddressType;
678     }
679 
680     
681 
682 
683     public String getInvoiceFileDeploymentModeValue() {
684         return invoiceFileDeploymentModeValue;
685     }
686 
687     
688 
689 
690     public void setInvoiceFileDeploymentModeValue(String deploymentMode) {
691         this.invoiceFileDeploymentModeValue = deploymentMode;
692     }
693 
694     
695 
696 
697     public List<ElectronicInvoiceRejectItem> getInvoiceRejectItems() {
698         return invoiceRejectItems;
699     }
700 
701     
702 
703 
704     public void setInvoiceRejectItems(List<ElectronicInvoiceRejectItem> electronicInvoiceRejectItems) {
705         this.invoiceRejectItems = electronicInvoiceRejectItems;
706     }
707 
708     public ElectronicInvoiceRejectItem getInvoiceRejectItem(int index) {
709         while (getInvoiceRejectItems().size() <= index) {
710             getInvoiceRejectItems().add(new ElectronicInvoiceRejectItem());
711         }
712         return getInvoiceRejectItems().get(index);
713     }
714 
715     
716 
717 
718     public List<ElectronicInvoiceRejectReason> getInvoiceRejectReasons() {
719         return invoiceRejectReasons;
720     }
721 
722     
723 
724 
725     public void setInvoiceRejectReasons(List<ElectronicInvoiceRejectReason> electronicInvoiceRejectReasons) {
726         this.invoiceRejectReasons = electronicInvoiceRejectReasons;
727     }
728 
729     public ElectronicInvoiceRejectReason getInvoiceRejectReason(int index) {
730         while (getInvoiceRejectReasons().size() <= index) {
731             getInvoiceRejectReasons().add(new ElectronicInvoiceRejectReason());
732         }
733         return getInvoiceRejectReasons().get(index);
734     }
735 
736     
737 
738 
739 
740 
741     public Integer getPaymentRequestIdentifier() {
742         return paymentRequestIdentifier;
743     }
744 
745     
746 
747 
748 
749 
750     public void setPaymentRequestIdentifier(Integer paymentRequestIdentifier) {
751         this.paymentRequestIdentifier = paymentRequestIdentifier;
752     }
753 
754     
755 
756 
757     public String getPurchaseOrderDeliveryCampusCode() {
758         return purchaseOrderDeliveryCampusCode;
759     }
760 
761     
762 
763 
764 
765     public void setPurchaseOrderDeliveryCampusCode(String poDeliveryCampusCode) {
766         this.purchaseOrderDeliveryCampusCode = poDeliveryCampusCode;
767     }
768 
769     
770 
771 
772     public Integer getPurchaseOrderIdentifier() {
773         return purchaseOrderIdentifier;
774     }
775 
776     
777 
778 
779     public void setPurchaseOrderIdentifier(Integer purchaseOrderId) {
780         this.purchaseOrderIdentifier = purchaseOrderId;
781     }
782 
783     
784 
785 
786     public Boolean getInvoiceFileDiscountInLineIndicator() {
787         return invoiceFileDiscountInLineIndicator;
788     }
789 
790     public Boolean isInvoiceFileDiscountInLineIndicator() {
791         return invoiceFileDiscountInLineIndicator;
792     }
793 
794     
795 
796 
797 
798     public void setInvoiceFileDiscountInLineIndicator(Boolean fileDiscountInLineIndicator) {
799         this.invoiceFileDiscountInLineIndicator = fileDiscountInLineIndicator;
800     }
801 
802     
803 
804 
805     public Boolean getInvoiceFileHeaderTypeIndicator() {
806         return invoiceFileHeaderTypeIndicator;
807     }
808 
809     public Boolean isInvoiceFileHeaderTypeIndicator() {
810         return invoiceFileHeaderTypeIndicator;
811     }
812 
813     
814 
815 
816     public void setInvoiceFileHeaderTypeIndicator(Boolean fileHeaderTypeIndicator) {
817         this.invoiceFileHeaderTypeIndicator = fileHeaderTypeIndicator;
818     }
819 
820     
821 
822 
823     public Boolean getInvoiceFileInformationOnlyIndicator() {
824         return invoiceFileInformationOnlyIndicator;
825     }
826 
827     public Boolean isInvoiceFileInformationOnlyIndicator() {
828         return invoiceFileInformationOnlyIndicator;
829     }
830 
831     
832 
833 
834 
835     public void setInvoiceFileInformationOnlyIndicator(Boolean fileInformationOnlyIndicator) {
836         this.invoiceFileInformationOnlyIndicator = fileInformationOnlyIndicator;
837     }
838 
839     
840 
841 
842     public String getInvoiceFileOperationIdentifier() {
843         return invoiceFileOperationIdentifier;
844     }
845 
846     
847 
848 
849     public void setInvoiceFileOperationIdentifier(String fileOperationId) {
850         this.invoiceFileOperationIdentifier = fileOperationId;
851     }
852 
853     
854 
855 
856     public String getInvoiceFilePurposeIdentifier() {
857         return invoiceFilePurposeIdentifier;
858     }
859 
860     
861 
862 
863     public void setInvoiceFilePurposeIdentifier(String filePurposeId) {
864         this.invoiceFilePurposeIdentifier = filePurposeId;
865     }
866 
867     
868 
869 
870     public Boolean getInvoiceFileShippingInLineIndicator() {
871         return invoiceFileShippingInLineIndicator;
872     }
873 
874     public Boolean isInvoiceFileShippingInLineIndicator() {
875         return invoiceFileShippingInLineIndicator;
876     }
877 
878     
879 
880 
881 
882     public void setInvoiceFileShippingInLineIndicator(Boolean fileShippingInLineIndicator) {
883         this.invoiceFileShippingInLineIndicator = fileShippingInLineIndicator;
884     }
885 
886     
887 
888 
889     public Boolean getInvoiceFileSpecialHandlingInLineIndicator() {
890         return invoiceFileSpecialHandlingInLineIndicator;
891     }
892 
893     public Boolean isInvoiceFileSpecialHandlingInLineIndicator() {
894         return invoiceFileSpecialHandlingInLineIndicator;
895     }
896 
897     
898 
899 
900 
901     public void setInvoiceFileSpecialHandlingInLineIndicator(Boolean fileSpecHandlingInLineIndicator) {
902         this.invoiceFileSpecialHandlingInLineIndicator = fileSpecHandlingInLineIndicator;
903     }
904 
905     
906 
907 
908     public Boolean getInvoiceFileTaxInLineIndicator() {
909         return invoiceFileTaxInLineIndicator;
910     }
911 
912     public Boolean isInvoiceFileTaxInLineIndicator() {
913         return invoiceFileTaxInLineIndicator;
914     }
915 
916     
917 
918 
919     public void setInvoiceFileTaxInLineIndicator(Boolean fileTaxInLineIndicator) {
920         this.invoiceFileTaxInLineIndicator = fileTaxInLineIndicator;
921     }
922 
923     
924 
925 
926     public Integer getPurapDocumentIdentifier() {
927         return purapDocumentIdentifier;
928     }
929 
930     
931 
932 
933     public void setPurapDocumentIdentifier(Integer id) {
934         this.purapDocumentIdentifier = id;
935     }
936 
937     public Integer getAccountsPayablePurchasingDocumentLinkIdentifier() {
938         return accountsPayablePurchasingDocumentLinkIdentifier;
939     }
940 
941     public void setAccountsPayablePurchasingDocumentLinkIdentifier(Integer accountsPayablePurchasingDocumentLinkIdentifier) {
942         this.accountsPayablePurchasingDocumentLinkIdentifier = accountsPayablePurchasingDocumentLinkIdentifier;
943     }
944 
945     
946 
947 
948     public String getInvoiceCustomerNumber() {
949         return invoiceCustomerNumber;
950     }
951 
952     
953 
954 
955     public void setInvoiceCustomerNumber(String invoiceCustomerNumber) {
956         this.invoiceCustomerNumber = invoiceCustomerNumber;
957     }
958 
959     
960 
961 
962     public String getInvoiceFileDate() {
963         return invoiceFileDate;
964     }
965 
966     
967 
968 
969     public void setInvoiceFileDate(String invoiceDate) {
970         this.invoiceFileDate = invoiceDate;
971     }
972 
973     
974 
975 
976     public BigDecimal getInvoiceItemDiscountAmount() {
977         if (this.isInvoiceFileDiscountInLineIndicator()) {
978             BigDecimal returnValue = zero;
979             try {
980                 for (ElectronicInvoiceRejectItem eiri : this.invoiceRejectItems) {
981                     BigDecimal toAddAmount = eiri.getInvoiceItemDiscountAmount();
982                     if (LOG.isDebugEnabled()) {
983                         LOG.debug("getTotalAmount() setting returnValue with arithmatic => '" + returnValue.doubleValue() + "' + '" + toAddAmount.doubleValue() + "'");
984                     }
985                     returnValue = returnValue.add(toAddAmount);
986                 }
987                 if (LOG.isDebugEnabled()) {
988                     LOG.debug("getTotalAmount() returning amount " + returnValue.doubleValue());
989                 }
990                 return returnValue;
991             } catch (NumberFormatException n) {
992                 
993                 LOG.error("getTotalAmount() Error attempting to calculate total amount for invoice with filename " + this.invoiceFileName);
994                 return zero;
995             }
996         } else {
997             return invoiceItemDiscountAmount;
998         }
999     }
1000 
1001     
1002 
1003 
1004     public void setInvoiceItemDiscountAmount(BigDecimal invoiceDiscountAmount) {
1005         this.invoiceItemDiscountAmount = invoiceDiscountAmount;
1006     }
1007 
1008     
1009 
1010 
1011     public String getInvoiceItemDiscountCurrencyCode() {
1012         return invoiceItemDiscountCurrencyCode;
1013     }
1014 
1015     
1016 
1017 
1018 
1019     public void setInvoiceItemDiscountCurrencyCode(String invoiceDiscountAmountCurrency) {
1020         this.invoiceItemDiscountCurrencyCode = invoiceDiscountAmountCurrency;
1021     }
1022 
1023     
1024 
1025 
1026     public String getInvoiceFileName() {
1027         return invoiceFileName;
1028     }
1029 
1030     
1031 
1032 
1033     public void setInvoiceFileName(String invoiceFileName) {
1034         this.invoiceFileName = invoiceFileName;
1035     }
1036 
1037     
1038 
1039 
1040     public BigDecimal getInvoiceItemGrossAmount() {
1041         return invoiceItemGrossAmount;
1042     }
1043 
1044     
1045 
1046 
1047     public void setInvoiceItemGrossAmount(BigDecimal invoiceGrossAmount) {
1048         this.invoiceItemGrossAmount = invoiceGrossAmount;
1049     }
1050 
1051     
1052 
1053 
1054     public String getInvoiceItemGrossCurrencyCode() {
1055         return invoiceItemGrossCurrencyCode;
1056     }
1057 
1058     
1059 
1060 
1061     public void setInvoiceItemGrossCurrencyCode(String invoiceGrossAmountCurrency) {
1062         this.invoiceItemGrossCurrencyCode = invoiceGrossAmountCurrency;
1063     }
1064 
1065     
1066 
1067 
1068     public BigDecimal getInvoiceItemNetAmount() {
1069         return invoiceItemNetAmount;
1070     }
1071 
1072     
1073 
1074 
1075     public void setInvoiceItemNetAmount(BigDecimal invoiceNetAmount) {
1076         this.invoiceItemNetAmount = invoiceNetAmount;
1077     }
1078 
1079     public boolean isInvoiceNumberAcceptIndicator() {
1080         return invoiceNumberAcceptIndicator;
1081     }
1082 
1083     public void setInvoiceNumberAcceptIndicator(boolean invoiceNumberAcceptIndicator) {
1084         this.invoiceNumberAcceptIndicator = invoiceNumberAcceptIndicator;
1085     }
1086 
1087     public boolean isInvoiceResearchIndicator() {
1088         return invoiceResearchIndicator;
1089     }
1090 
1091     public boolean getInvoiceResearchIndicator() {
1092         return invoiceResearchIndicator;
1093     }
1094 
1095     public void setInvoiceResearchIndicator(boolean invoiceResearchIndicator) {
1096         this.invoiceResearchIndicator = invoiceResearchIndicator;
1097     }
1098 
1099     public Timestamp getAccountsPayableApprovalTimestamp() {
1100         return accountsPayableApprovalTimestamp;
1101     }
1102 
1103     public void setAccountsPayableApprovalTimestamp(Timestamp accountsPayableApprovalTimestamp) {
1104         this.accountsPayableApprovalTimestamp = accountsPayableApprovalTimestamp;
1105     }
1106 
1107     
1108 
1109 
1110     public String getInvoiceItemNetCurrencyCode() {
1111         return invoiceItemNetCurrencyCode;
1112     }
1113 
1114     
1115 
1116 
1117     public void setInvoiceItemNetCurrencyCode(String invoiceNetAmountCurrency) {
1118         this.invoiceItemNetCurrencyCode = invoiceNetAmountCurrency;
1119     }
1120 
1121     
1122 
1123 
1124     public String getInvoiceFileNumber() {
1125         return invoiceFileNumber;
1126     }
1127 
1128     
1129 
1130 
1131     public void setInvoiceFileNumber(String invoiceNumber) {
1132         this.invoiceFileNumber = invoiceNumber;
1133     }
1134 
1135     
1136 
1137 
1138     public String getInvoiceOrderPurchaseOrderDate() {
1139         return invoiceOrderPurchaseOrderDate;
1140     }
1141 
1142     
1143 
1144 
1145     public void setInvoiceOrderPurchaseOrderDate(String invoiceOrderDate) {
1146         this.invoiceOrderPurchaseOrderDate = invoiceOrderDate;
1147     }
1148 
1149     
1150 
1151 
1152     public String getInvoiceOrderPurchaseOrderIdentifier() {
1153         return invoiceOrderPurchaseOrderIdentifier;
1154     }
1155 
1156     
1157 
1158 
1159 
1160     public void setInvoiceOrderPurchaseOrderIdentifier(String invoiceOrderId) {
1161         this.invoiceOrderPurchaseOrderIdentifier = invoiceOrderId;
1162     }
1163 
1164     
1165 
1166 
1167     public Timestamp getInvoiceProcessTimestamp() {
1168         return invoiceProcessTimestamp;
1169     }
1170 
1171     
1172 
1173 
1174     public void setInvoiceProcessTimestamp(Timestamp invoiceProcessTimestamp) {
1175         this.invoiceProcessTimestamp = invoiceProcessTimestamp;
1176     }
1177 
1178     
1179 
1180 
1181     public String getInvoicePurchaseOrderNumber() {
1182         return invoicePurchaseOrderNumber;
1183     }
1184 
1185     
1186 
1187 
1188     public void setInvoicePurchaseOrderNumber(String invoicePurchaseOrderId) {
1189         this.invoicePurchaseOrderNumber = invoicePurchaseOrderId;
1190     }
1191 
1192     
1193 
1194 
1195     public String getInvoiceShipDate() {
1196         return invoiceShipDate;
1197     }
1198 
1199     
1200 
1201 
1202     public void setInvoiceShipDate(String invoiceShipDate) {
1203         this.invoiceShipDate = invoiceShipDate;
1204     }
1205 
1206     
1207 
1208 
1209     public BigDecimal getInvoiceItemShippingAmount() {
1210         if (this.isInvoiceFileShippingInLineIndicator()) {
1211             BigDecimal returnValue = zero;
1212             try {
1213                 for (ElectronicInvoiceRejectItem eiri : this.invoiceRejectItems) {
1214                     BigDecimal toAddAmount = eiri.getInvoiceItemShippingAmount();
1215                     if (LOG.isDebugEnabled()) {
1216                         LOG.debug("getTotalAmount() setting returnValue with arithmatic => '" + returnValue.doubleValue() + "' + '" + toAddAmount.doubleValue() + "'");
1217                     }
1218                     returnValue = returnValue.add(toAddAmount);
1219                 }
1220                 if (LOG.isDebugEnabled()) {
1221                     LOG.debug("getTotalAmount() returning amount " + returnValue.doubleValue());
1222                 }
1223                 return returnValue;
1224             } catch (NumberFormatException n) {
1225                 
1226                 LOG.error("getTotalAmount() Error attempting to calculate total amount for invoice with filename " + this.invoiceFileName);
1227                 return zero;
1228             }
1229         } else {
1230             return invoiceItemShippingAmount;
1231         }
1232     }
1233 
1234     
1235 
1236 
1237     public void setInvoiceItemShippingAmount(BigDecimal invoiceShippingAmount) {
1238         this.invoiceItemShippingAmount = invoiceShippingAmount;
1239     }
1240 
1241     
1242 
1243 
1244     public String getInvoiceItemShippingCurrencyCode() {
1245         return invoiceItemShippingCurrencyCode;
1246     }
1247 
1248     
1249 
1250 
1251 
1252     public void setInvoiceItemShippingCurrencyCode(String invoiceShippingAmountCurrency) {
1253         this.invoiceItemShippingCurrencyCode = invoiceShippingAmountCurrency;
1254     }
1255 
1256     
1257 
1258 
1259     public String getInvoiceItemShippingDescription() {
1260         return invoiceItemShippingDescription;
1261     }
1262 
1263     
1264 
1265 
1266     public void setInvoiceItemShippingDescription(String invoiceShippingDescription) {
1267         this.invoiceItemShippingDescription = invoiceShippingDescription;
1268     }
1269 
1270     
1271 
1272 
1273     public BigDecimal getInvoiceItemSpecialHandlingAmount() {
1274         if (this.isInvoiceFileSpecialHandlingInLineIndicator()) {
1275             BigDecimal returnValue = zero;
1276             try {
1277                 for (ElectronicInvoiceRejectItem eiri : this.invoiceRejectItems) {
1278                     BigDecimal toAddAmount = eiri.getInvoiceItemSpecialHandlingAmount();
1279                     if (LOG.isDebugEnabled()) {
1280                         LOG.debug("getTotalAmount() setting returnValue with arithmatic => '" + returnValue.doubleValue() + "' + '" + toAddAmount.doubleValue() + "'");
1281                     }
1282                     returnValue = returnValue.add(toAddAmount);
1283                 }
1284                 if (LOG.isDebugEnabled()) {
1285                     LOG.debug("getTotalAmount() returning amount " + returnValue.doubleValue());
1286                 }
1287                 return returnValue;
1288             } catch (NumberFormatException n) {
1289                 
1290                 LOG.error("getTotalAmount() Error attempting to calculate total amount for invoice with filename " + this.invoiceFileName);
1291                 return zero;
1292             }
1293         } else {
1294             return invoiceItemSpecialHandlingAmount;
1295         }
1296     }
1297 
1298     
1299 
1300 
1301 
1302     public void setInvoiceItemSpecialHandlingAmount(BigDecimal invoiceSpecialHandlingAmount) {
1303         this.invoiceItemSpecialHandlingAmount = invoiceSpecialHandlingAmount;
1304     }
1305 
1306     
1307 
1308 
1309     public String getInvoiceItemSpecialHandlingCurrencyCode() {
1310         return invoiceItemSpecialHandlingCurrencyCode;
1311     }
1312 
1313     
1314 
1315 
1316 
1317     public void setInvoiceItemSpecialHandlingCurrencyCode(String invoiceSpecialHandlingAmountCurrency) {
1318         this.invoiceItemSpecialHandlingCurrencyCode = invoiceSpecialHandlingAmountCurrency;
1319     }
1320 
1321     
1322 
1323 
1324     public String getInvoiceItemSpecialHandlingDescription() {
1325         return invoiceItemSpecialHandlingDescription;
1326     }
1327 
1328     
1329 
1330 
1331 
1332     public void setInvoiceItemSpecialHandlingDescription(String invoiceSpecialHandlingDescription) {
1333         this.invoiceItemSpecialHandlingDescription = invoiceSpecialHandlingDescription;
1334     }
1335 
1336     
1337 
1338 
1339     public BigDecimal getInvoiceItemSubTotalAmount() {
1340 
1341         return invoiceItemSubTotalAmount;
1342     }
1343 
1344     
1345 
1346 
1347     public void setInvoiceItemSubTotalAmount(BigDecimal invoiceSubTotalAmount) {
1348         this.invoiceItemSubTotalAmount = invoiceSubTotalAmount;
1349     }
1350 
1351     
1352 
1353 
1354     public String getInvoiceItemSubTotalCurrencyCode() {
1355         return invoiceItemSubTotalCurrencyCode;
1356     }
1357 
1358     
1359 
1360 
1361 
1362     public void setInvoiceItemSubTotalCurrencyCode(String invoiceSubTotalAmountCurrency) {
1363         this.invoiceItemSubTotalCurrencyCode = invoiceSubTotalAmountCurrency;
1364     }
1365 
1366     
1367 
1368 
1369     public BigDecimal getInvoiceItemTaxAmount() {
1370         BigDecimal returnValue = zero;
1371         boolean enableSalesTaxInd = SpringContext.getBean(ParameterService.class).getParameterValueAsBoolean(OleParameterConstants.PURCHASING_DOCUMENT.class, PurapParameterConstants.ENABLE_SALES_TAX_IND);
1372 
1373         try {
1374             
1375             if (enableSalesTaxInd) {
1376                 for (ElectronicInvoiceRejectItem eiri : this.invoiceRejectItems) {
1377                     BigDecimal toAddAmount = eiri.getInvoiceItemTaxAmount();
1378                     if (LOG.isDebugEnabled()) {
1379                         LOG.debug("getTotalAmount() setting returnValue with arithmatic => '" + returnValue.doubleValue() + "' + '" + toAddAmount.doubleValue() + "'");
1380                     }
1381                     returnValue = returnValue.add(toAddAmount);
1382                 }
1383             } else { 
1384                 returnValue = returnValue.add(this.invoiceItemTaxAmount);
1385             }
1386 
1387             if (LOG.isDebugEnabled()) {
1388                 LOG.debug("getTotalAmount() returning amount " + returnValue.doubleValue());
1389             }
1390             return returnValue;
1391         } catch (NumberFormatException n) {
1392             
1393             LOG.error("getTotalAmount() Error attempting to calculate total amount for invoice with filename " + this.invoiceFileName);
1394             return zero;
1395         }
1396         
1397     }
1398 
1399     
1400 
1401 
1402     public void setInvoiceItemTaxAmount(BigDecimal invoiceTaxAmount) {
1403         this.invoiceItemTaxAmount = invoiceTaxAmount;
1404     }
1405 
1406     
1407 
1408 
1409     public String getInvoiceItemTaxCurrencyCode() {
1410         return invoiceItemTaxCurrencyCode;
1411     }
1412 
1413     
1414 
1415 
1416     public void setInvoiceItemTaxCurrencyCode(String invoiceTaxAmountCurrency) {
1417         this.invoiceItemTaxCurrencyCode = invoiceTaxAmountCurrency;
1418     }
1419 
1420     
1421 
1422 
1423     public String getInvoiceItemTaxDescription() {
1424         return invoiceItemTaxDescription;
1425     }
1426 
1427     
1428 
1429 
1430     public void setInvoiceItemTaxDescription(String invoiceTaxDescription) {
1431         this.invoiceItemTaxDescription = invoiceTaxDescription;
1432     }
1433 
1434     
1435 
1436 
1437     public String getInvoiceOrderMasterAgreementInformationDate() {
1438         return invoiceOrderMasterAgreementInformationDate;
1439     }
1440 
1441     
1442 
1443 
1444 
1445     public void setInvoiceOrderMasterAgreementInformationDate(String masterAgreementInfoDate) {
1446         this.invoiceOrderMasterAgreementInformationDate = masterAgreementInfoDate;
1447     }
1448 
1449     
1450 
1451 
1452     public String getInvoiceOrderMasterAgreementInformationIdentifier() {
1453         return invoiceOrderMasterAgreementInformationIdentifier;
1454     }
1455 
1456     
1457 
1458 
1459 
1460     public void setInvoiceOrderMasterAgreementInformationIdentifier(String masterAgreementInfoId) {
1461         this.invoiceOrderMasterAgreementInformationIdentifier = masterAgreementInfoId;
1462     }
1463 
1464     
1465 
1466 
1467     public String getInvoiceOrderMasterAgreementReferenceDate() {
1468         return invoiceOrderMasterAgreementReferenceDate;
1469     }
1470 
1471     
1472 
1473 
1474 
1475     public void setInvoiceOrderMasterAgreementReferenceDate(String masterAgreementReferenceDate) {
1476         this.invoiceOrderMasterAgreementReferenceDate = masterAgreementReferenceDate;
1477     }
1478 
1479     
1480 
1481 
1482     public String getInvoiceOrderMasterAgreementReferenceIdentifier() {
1483         return invoiceOrderMasterAgreementReferenceIdentifier;
1484     }
1485 
1486     
1487 
1488 
1489 
1490     public void setInvoiceOrderMasterAgreementReferenceIdentifier(String masterAgreementReferenceId) {
1491         this.invoiceOrderMasterAgreementReferenceIdentifier = masterAgreementReferenceId;
1492     }
1493 
1494     
1495 
1496 
1497     public String getInvoiceOrderReferenceDocumentReferencePayloadIdentifier() {
1498         return invoiceOrderReferenceDocumentReferencePayloadIdentifier;
1499     }
1500 
1501     
1502 
1503 
1504 
1505 
1506     public void setInvoiceOrderReferenceDocumentReferencePayloadIdentifier(String referenceDocumentRefPayloadId) {
1507         this.invoiceOrderReferenceDocumentReferencePayloadIdentifier = referenceDocumentRefPayloadId;
1508     }
1509 
1510     
1511 
1512 
1513     public String getInvoiceOrderReferenceDocumentReferenceText() {
1514         return invoiceOrderReferenceDocumentReferenceText;
1515     }
1516 
1517     
1518 
1519 
1520 
1521     public void setInvoiceOrderReferenceDocumentReferenceText(String referenceDocumentRefText) {
1522         this.invoiceOrderReferenceDocumentReferenceText = referenceDocumentRefText;
1523     }
1524 
1525     
1526 
1527 
1528     public String getInvoiceOrderReferenceOrderIdentifier() {
1529         return invoiceOrderReferenceOrderIdentifier;
1530     }
1531 
1532     
1533 
1534 
1535 
1536     public void setInvoiceOrderReferenceOrderIdentifier(String referenceOrderId) {
1537         this.invoiceOrderReferenceOrderIdentifier = referenceOrderId;
1538     }
1539 
1540     
1541 
1542 
1543     public String getInvoiceRemitToAddressCityName() {
1544         return invoiceRemitToAddressCityName;
1545     }
1546 
1547     
1548 
1549 
1550     public void setInvoiceRemitToAddressCityName(String remitToAddressCityName) {
1551         this.invoiceRemitToAddressCityName = remitToAddressCityName;
1552     }
1553 
1554     
1555 
1556 
1557     public String getInvoiceRemitToAddressCountryCode() {
1558         return invoiceRemitToAddressCountryCode;
1559     }
1560 
1561     
1562 
1563 
1564 
1565     public void setInvoiceRemitToAddressCountryCode(String remitToAddressCountryCode) {
1566         this.invoiceRemitToAddressCountryCode = remitToAddressCountryCode;
1567     }
1568 
1569     
1570 
1571 
1572     public String getInvoiceRemitToAddressCountryName() {
1573         return invoiceRemitToAddressCountryName;
1574     }
1575 
1576     
1577 
1578 
1579 
1580     public void setInvoiceRemitToAddressCountryName(String remitToAddressCountryName) {
1581         this.invoiceRemitToAddressCountryName = remitToAddressCountryName;
1582     }
1583 
1584     
1585 
1586 
1587     public String getInvoiceRemitToAddressLine1() {
1588         return invoiceRemitToAddressLine1;
1589     }
1590 
1591     
1592 
1593 
1594     public void setInvoiceRemitToAddressLine1(String remitToAddressLine1) {
1595         this.invoiceRemitToAddressLine1 = remitToAddressLine1;
1596     }
1597 
1598     
1599 
1600 
1601     public String getInvoiceRemitToAddressLine2() {
1602         return invoiceRemitToAddressLine2;
1603     }
1604 
1605     
1606 
1607 
1608     public void setInvoiceRemitToAddressLine2(String remitToAddressLine2) {
1609         this.invoiceRemitToAddressLine2 = remitToAddressLine2;
1610     }
1611 
1612     
1613 
1614 
1615     public String getInvoiceRemitToAddressLine3() {
1616         return invoiceRemitToAddressLine3;
1617     }
1618 
1619     
1620 
1621 
1622     public void setInvoiceRemitToAddressLine3(String remitToAddressLine3) {
1623         this.invoiceRemitToAddressLine3 = remitToAddressLine3;
1624     }
1625 
1626     
1627 
1628 
1629     public String getInvoiceRemitToAddressName() {
1630         return invoiceRemitToAddressName;
1631     }
1632 
1633     
1634 
1635 
1636     public void setInvoiceRemitToAddressName(String remitToAddressName) {
1637         this.invoiceRemitToAddressName = remitToAddressName;
1638     }
1639 
1640     
1641 
1642 
1643     public String getInvoiceRemitToAddressPostalCode() {
1644         return invoiceRemitToAddressPostalCode;
1645     }
1646 
1647     
1648 
1649 
1650 
1651     public void setInvoiceRemitToAddressPostalCode(String remitToAddressPostalCode) {
1652         this.invoiceRemitToAddressPostalCode = remitToAddressPostalCode;
1653     }
1654 
1655     
1656 
1657 
1658     public String getInvoiceRemitToAddressStateCode() {
1659         return invoiceRemitToAddressStateCode;
1660     }
1661 
1662     
1663 
1664 
1665     public void setInvoiceRemitToAddressStateCode(String remitToAddressStateCode) {
1666         this.invoiceRemitToAddressStateCode = remitToAddressStateCode;
1667     }
1668 
1669     
1670 
1671 
1672     public String getInvoiceRemitToAddressType() {
1673         return invoiceRemitToAddressType;
1674     }
1675 
1676     
1677 
1678 
1679     public void setInvoiceRemitToAddressType(String remitToAddressType) {
1680         this.invoiceRemitToAddressType = remitToAddressType;
1681     }
1682 
1683     
1684 
1685 
1686     public String getInvoiceShipToAddressCityName() {
1687         return invoiceShipToAddressCityName;
1688     }
1689 
1690     
1691 
1692 
1693     public void setInvoiceShipToAddressCityName(String shipToAddressCityName) {
1694         this.invoiceShipToAddressCityName = shipToAddressCityName;
1695     }
1696 
1697     
1698 
1699 
1700     public String getInvoiceShipToAddressCountryCode() {
1701         return invoiceShipToAddressCountryCode;
1702     }
1703 
1704     
1705 
1706 
1707 
1708     public void setInvoiceShipToAddressCountryCode(String shipToAddressCountryCode) {
1709         this.invoiceShipToAddressCountryCode = shipToAddressCountryCode;
1710     }
1711 
1712     
1713 
1714 
1715     public String getInvoiceShipToAddressCountryName() {
1716         return invoiceShipToAddressCountryName;
1717     }
1718 
1719     
1720 
1721 
1722 
1723     public void setInvoiceShipToAddressCountryName(String shipToAddressCountryName) {
1724         this.invoiceShipToAddressCountryName = shipToAddressCountryName;
1725     }
1726 
1727     
1728 
1729 
1730     public String getInvoiceShipToAddressLine1() {
1731         return invoiceShipToAddressLine1;
1732     }
1733 
1734     
1735 
1736 
1737     public void setInvoiceShipToAddressLine1(String shipToAddressLine1) {
1738         this.invoiceShipToAddressLine1 = shipToAddressLine1;
1739     }
1740 
1741     
1742 
1743 
1744     public String getInvoiceShipToAddressLine2() {
1745         return invoiceShipToAddressLine2;
1746     }
1747 
1748     
1749 
1750 
1751     public void setInvoiceShipToAddressLine2(String shipToAddressLine2) {
1752         this.invoiceShipToAddressLine2 = shipToAddressLine2;
1753     }
1754 
1755     
1756 
1757 
1758     public String getInvoiceShipToAddressLine3() {
1759         return invoiceShipToAddressLine3;
1760     }
1761 
1762     
1763 
1764 
1765     public void setInvoiceShipToAddressLine3(String shipToAddressLine3) {
1766         this.invoiceShipToAddressLine3 = shipToAddressLine3;
1767     }
1768 
1769     
1770 
1771 
1772     public String getInvoiceShipToAddressName() {
1773         return invoiceShipToAddressName;
1774     }
1775 
1776     
1777 
1778 
1779     public void setInvoiceShipToAddressName(String shipToAddressName) {
1780         this.invoiceShipToAddressName = shipToAddressName;
1781     }
1782 
1783     
1784 
1785 
1786     public String getInvoiceShipToAddressPostalCode() {
1787         return invoiceShipToAddressPostalCode;
1788     }
1789 
1790     
1791 
1792 
1793     public void setInvoiceShipToAddressPostalCode(String shipToAddressPostalCode) {
1794         this.invoiceShipToAddressPostalCode = shipToAddressPostalCode;
1795     }
1796 
1797     
1798 
1799 
1800     public String getInvoiceShipToAddressStateCode() {
1801         return invoiceShipToAddressStateCode;
1802     }
1803 
1804     
1805 
1806 
1807     public void setInvoiceShipToAddressStateCode(String shipToAddressStateCode) {
1808         this.invoiceShipToAddressStateCode = shipToAddressStateCode;
1809     }
1810 
1811     
1812 
1813 
1814     public String getInvoiceShipToAddressType() {
1815         return invoiceShipToAddressType;
1816     }
1817 
1818     
1819 
1820 
1821     public void setInvoiceShipToAddressType(String shipToAddressType) {
1822         this.invoiceShipToAddressType = shipToAddressType;
1823     }
1824 
1825     
1826 
1827 
1828     public String getInvoiceOrderSupplierOrderInformationIdentifier() {
1829         return invoiceOrderSupplierOrderInformationIdentifier;
1830     }
1831 
1832     
1833 
1834 
1835 
1836     public void setInvoiceOrderSupplierOrderInformationIdentifier(String supplierOrderInfoId) {
1837         this.invoiceOrderSupplierOrderInformationIdentifier = supplierOrderInfoId;
1838     }
1839 
1840     
1841 
1842 
1843     public Integer getVendorDetailAssignedIdentifier() {
1844         return vendorDetailAssignedIdentifier;
1845     }
1846 
1847     
1848 
1849 
1850     public void setVendorDetailAssignedIdentifier(Integer vendorDetailID) {
1851         this.vendorDetailAssignedIdentifier = vendorDetailID;
1852     }
1853 
1854     
1855 
1856 
1857     public String getVendorDunsNumber() {
1858         return vendorDunsNumber;
1859     }
1860 
1861     
1862 
1863 
1864     public void setVendorDunsNumber(String vendorDunsNumber) {
1865         this.vendorDunsNumber = vendorDunsNumber;
1866     }
1867 
1868     
1869 
1870 
1871     public Integer getVendorHeaderGeneratedIdentifier() {
1872         return vendorHeaderGeneratedIdentifier;
1873     }
1874 
1875     
1876 
1877 
1878 
1879     public void setVendorHeaderGeneratedIdentifier(Integer vendorHeaderID) {
1880         this.vendorHeaderGeneratedIdentifier = vendorHeaderID;
1881     }
1882 
1883     public void addRejectItem(ElectronicInvoiceRejectItem item) {
1884         
1885         
1886         
1887         
1888         
1889 
1890         item.setPurapDocumentIdentifier(this.purapDocumentIdentifier);
1891         item.setElectronicInvoiceRejectDocument(this);
1892 
1893         invoiceRejectItems.add(item);
1894         
1895     }
1896 
1897     public void addRejectReason(ElectronicInvoiceRejectReason reason) {
1898         
1899         
1900         
1901         
1902         
1903 
1904         reason.setPurapDocumentIdentifier(this.purapDocumentIdentifier);
1905         reason.setElectronicInvoiceRejectDocument(this);
1906 
1907         invoiceRejectReasons.add(reason);
1908         
1909     }
1910 
1911     public PurApRelatedViews getRelatedViews() {
1912         if (relatedViews == null) {
1913             relatedViews = new PurApRelatedViews(this.documentNumber, this.accountsPayablePurchasingDocumentLinkIdentifier);
1914         }
1915         return relatedViews;
1916     }
1917 
1918     public void setRelatedViews(PurApRelatedViews relatedViews) {
1919         this.relatedViews = relatedViews;
1920     }
1921 
1922     public boolean isBoNotesSupport() {
1923         return true;
1924     }
1925 
1926     public boolean isDocumentCreationInProgress() {
1927         return isDocumentCreationInProgress;
1928     }
1929 
1930     public void setDocumentCreationInProgress(boolean isDocumentCreationInProgress) {
1931         this.isDocumentCreationInProgress = isDocumentCreationInProgress;
1932     }
1933 
1934     
1935 
1936 
1937 
1938 
1939     public String getVendorNumber() {
1940         if (StringUtils.isNotEmpty(vendorNumber)) {
1941             return vendorNumber;
1942         } else if (ObjectUtils.isNotNull(vendorDetail)) {
1943             return vendorDetail.getVendorNumber();
1944         } else if (getVendorHeaderGeneratedIdentifier() != null && getVendorDetailAssignedIdentifier() != null) {
1945             VendorDetail vendorDetail = new VendorDetail();
1946             vendorDetail.setVendorHeaderGeneratedIdentifier(getVendorHeaderGeneratedIdentifier());
1947             vendorDetail.setVendorDetailAssignedIdentifier(getVendorDetailAssignedIdentifier());
1948             return vendorDetail.getVendorNumber();
1949         } else {
1950             return "";
1951         }
1952     }
1953 
1954     public void setVendorNumber(String vendorNumber) {
1955         this.vendorNumber = vendorNumber;
1956     }
1957 
1958     
1959 
1960 
1961 
1962     public boolean getIsATypeOfPurAPRecDoc() {
1963         return false;
1964     }
1965 
1966     
1967 
1968 
1969 
1970     public boolean getIsATypeOfPurDoc() {
1971         return false;
1972     }
1973 
1974     
1975 
1976 
1977 
1978     public boolean getIsATypeOfPODoc() {
1979         return false;
1980     }
1981 
1982     
1983 
1984 
1985 
1986     public boolean getIsPODoc() {
1987         return false;
1988     }
1989 
1990     
1991 
1992 
1993 
1994     public boolean getIsReqsDoc() {
1995         return false;
1996     }
1997 
1998     public boolean isInvoiceResearchIndicatorForSearching() {
1999         return invoiceResearchIndicator;
2000     }
2001 
2002     public String getInvoiceResearchIndicatorForResult() {
2003         if (isInvoiceResearchIndicator()) {
2004             return "Yes";
2005         } else {
2006             return "No";
2007         }
2008     }
2009 
2010     public String getPurchaseOrderDeliveryCampusCodeForSearch() {
2011         return getPurchaseOrderDeliveryCampusCode();
2012     }
2013 
2014     public CampusParameter getPurchaseOrderDeliveryCampus() {
2015         return purchaseOrderDeliveryCampus;
2016     }
2017 
2018     public Date getAccountsPayableApprovalDateForSearch() {
2019         if (getAccountsPayableApprovalTimestamp() != null) {
2020             DateTimeService dateTimeService = SpringContext.getBean(DateTimeService.class);
2021             try {
2022                 return dateTimeService.convertToSqlDate(getAccountsPayableApprovalTimestamp());
2023             } catch (ParseException e) {
2024                 throw new RuntimeException("ParseException thrown when trying to convert Timestamp to sqlDate.", e);
2025             }
2026         }
2027         return null;
2028     }
2029 
2030     public Timestamp getInvoiceFileTimeStampForSearch() {
2031         Date invoiceDate = ElectronicInvoiceUtils.getDate(getInvoiceFileDate());
2032         if (invoiceDate != null) {
2033             return new Timestamp(invoiceDate.getTime());
2034         } else {
2035             return null;
2036         }
2037     }
2038 
2039     public void setInvoiceFileTimeStampForSearch(Timestamp invoiceFileTimeStamp) {
2040         
2041     }
2042 
2043     public String getWorkflowStatusForResult() {
2044         return PurapSearchUtils.getWorkFlowStatusString(getDocumentHeader());
2045     }
2046 
2047     
2048 
2049 
2050 
2051 
2052 
2053     public boolean getNeedWarningRelatedPOs() {
2054         List<PurchaseOrderView> poViews = getRelatedViews().getRelatedPurchaseOrderViews();
2055         for (PurchaseOrderView poView : poViews) {
2056             if (poView.getNeedWarning()) {
2057                 return true;
2058             }
2059         }
2060         return false;
2061     }
2062 
2063     
2064 
2065 
2066     @Override
2067     public void doRouteStatusChange(DocumentRouteStatusChange statusChangeEvent) {
2068         LOG.debug("doRouteStatusChange() started");
2069         super.doRouteStatusChange(statusChangeEvent);
2070         if (this.getFinancialSystemDocumentHeader().getWorkflowDocument().isApproved()) {
2071             
2072             this.setAccountsPayableApprovalTimestamp(SpringContext.getBean(DateTimeService.class).getCurrentTimestamp());
2073         }
2074 
2075     }
2076 
2077     
2078 
2079 
2080     @Override
2081     public List getNotes() {
2082         List notes = super.getNotes();
2083         if (!StringUtils.isBlank(this.getObjectId())) {
2084             for (Iterator iterator = notes.iterator(); iterator.hasNext(); ) {
2085                 Note note = (Note) iterator.next();
2086                 if (!StringUtils.isBlank(note.getObjectId())) {
2087                     note.refresh();
2088                 }
2089             }
2090         }
2091 
2092         return super.getNotes();
2093     }
2094 
2095 
2096     @Override
2097     public NoteType getNoteType() {
2098         return NoteType.BUSINESS_OBJECT;
2099     }
2100 
2101 }