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.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  
59  
60  
61  
62  
63  
64      public String getInvoicePurchaseOrderID(ElectronicInvoiceOrder invoiceOrder) {
65          return invoiceOrder.getOrderReferenceOrderID();
66      }
67  
68      
69  
70  
71  
72  
73  
74  
75      public String getCatalogNumber(ElectronicInvoiceItem item) {
76          return item.getReferenceItemIDSupplierPartID();
77      }
78  
79      
80  
81  
82  
83  
84  
85  
86      public String getInvoiceCustomerNumber(ElectronicInvoice ei) {
87          
88          return null;
89      }
90  
91      
92  
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 
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 }