View Javadoc
1   /*
2    * Copyright 2006-2009 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  /*
17   * Created on Mar 7, 2006
18   *
19   */
20  package org.kuali.ole.module.purap.service.impl;
21  
22  import org.kuali.ole.module.purap.businessobject.ElectronicInvoice;
23  import org.kuali.ole.module.purap.businessobject.ElectronicInvoiceItem;
24  import org.kuali.ole.module.purap.businessobject.ElectronicInvoiceOrder;
25  import org.kuali.ole.module.purap.dataaccess.ElectronicInvoicingDao;
26  import org.kuali.ole.module.purap.service.ElectronicInvoiceMappingService;
27  import org.springframework.transaction.annotation.Transactional;
28  
29  import java.util.Map;
30  
31  @Transactional
32  public class ElectronicInvoiceMappingServiceImpl implements ElectronicInvoiceMappingService {
33      private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(ElectronicInvoiceMappingServiceImpl.class);
34  
35      private ElectronicInvoicingDao electronicInvoicingDao;
36  
37      public void setElectronicInvoicingDao(ElectronicInvoicingDao electronicInvoicingDao) {
38          this.electronicInvoicingDao = electronicInvoicingDao;
39      }
40  
41      public Map getDefaultItemMappingMap() {
42          LOG.debug("getDefaultItemMappingMap() started");
43          return electronicInvoicingDao.getDefaultItemMappingMap();
44      }
45  
46      public Map getItemMappingMap(Integer vendorHeaderId, Integer vendorDetailId) {
47          if (LOG.isDebugEnabled()) {
48              LOG.debug("getItemMappingMap() started for vendor id " + vendorHeaderId + "-" + vendorDetailId);
49          }
50          return electronicInvoicingDao.getItemMappingMap(vendorHeaderId, vendorDetailId);
51      }
52  
53      public boolean acceptAmountType(String cxmlAmountType) {
54          return ((cxmlAmountType != null) && (!(cxmlAmountType.equalsIgnoreCase(ITEM_TYPE_RETURN_VALUE_UNACCEPTED))));
55      }
56  
57      /**
58       * This method defines which field out of the ElectronicInvoiceOrder that the
59       * purchase order number is coming in as
60       *
61       * @param invoiceOrder ElectronicInvoiceOrder we need to get the PO ID from
62       * @return the String value of the purchase order id
63       */
64      public String getInvoicePurchaseOrderID(ElectronicInvoiceOrder invoiceOrder) {
65          return invoiceOrder.getOrderReferenceOrderID();
66      }
67  
68      /**
69       * This method defines which field out of the ElectronicInvoiceItem that the
70       * catalog number is coming in as
71       *
72       * @param eii ElectronicInvoiceItem we need to get the catalog number from
73       * @return catalog number value
74       */
75      public String getCatalogNumber(ElectronicInvoiceItem item) {
76          return item.getReferenceItemIDSupplierPartID();
77      }
78  
79      /**
80       * This method defines which field out of the ElectronicInvoice that the
81       * customer number field is coming in as
82       *
83       * @param ei ElectronicInvoice we need to get the customer number from
84       * @return customer number value
85       */
86      public String getInvoiceCustomerNumber(ElectronicInvoice ei) {
87          // TODO: Future Release - Enter valid location for Customer Number from E-Invoice
88          return null;
89      }
90  
91      /**
92       * This method contains the mapping check for valid Currency Code(s)
93       */
94      public String checkCodeForValidCurrency(String code) {
95          if (!(this.isCodeValidCurrency(code))) {
96              return code;
97          } else {
98              return null;
99          }
100     }
101 
102     /**
103      * This method contains the mapping check for valid Currency Code(s)
104      */
105     public boolean isCodeValidCurrency(String code) {
106         if (code != null) {
107             for (int i = 0; i < CXML_VALID_CURRENCY_CODES.length; i++) {
108                 String validCode = CXML_VALID_CURRENCY_CODES[i];
109                 if (code.equalsIgnoreCase(validCode)) {
110                     return true;
111                 }
112             }
113         }
114         return false;
115     }
116 
117 
118 }