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 Mar 7, 2006
018 *
019 */
020 package org.kuali.kfs.module.purap.service.impl;
021
022 import java.util.Map;
023
024 import org.kuali.kfs.module.purap.businessobject.ElectronicInvoice;
025 import org.kuali.kfs.module.purap.businessobject.ElectronicInvoiceItem;
026 import org.kuali.kfs.module.purap.businessobject.ElectronicInvoiceOrder;
027 import org.kuali.kfs.module.purap.dataaccess.ElectronicInvoicingDao;
028 import org.kuali.kfs.module.purap.dataaccess.impl.ElectronicInvoicingDaoOjb;
029 import org.kuali.kfs.module.purap.service.ElectronicInvoiceMappingService;
030 import org.springframework.transaction.annotation.Transactional;
031
032 @Transactional
033 public class ElectronicInvoiceMappingServiceImpl implements ElectronicInvoiceMappingService {
034 private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(ElectronicInvoiceMappingServiceImpl.class);
035
036 private ElectronicInvoicingDao electronicInvoicingDao;
037
038 public void setElectronicInvoicingDao(ElectronicInvoicingDao electronicInvoicingDao) {
039 this.electronicInvoicingDao = electronicInvoicingDao;
040 }
041
042 public Map getDefaultItemMappingMap() {
043 LOG.debug("getDefaultItemMappingMap() started");
044 return electronicInvoicingDao.getDefaultItemMappingMap();
045 }
046
047 public Map getItemMappingMap(Integer vendorHeaderId, Integer vendorDetailId) {
048 LOG.debug("getItemMappingMap() started for vendor id " + vendorHeaderId + "-" + vendorDetailId);
049 return electronicInvoicingDao.getItemMappingMap(vendorHeaderId,vendorDetailId);
050 }
051
052 public boolean acceptAmountType(String cxmlAmountType) {
053 return ( (cxmlAmountType != null) && (!(cxmlAmountType.equalsIgnoreCase(ITEM_TYPE_RETURN_VALUE_UNACCEPTED))) );
054 }
055
056 /**
057 * This method defines which field out of the ElectronicInvoiceOrder that the
058 * purchase order number is coming in as
059 *
060 * @param invoiceOrder ElectronicInvoiceOrder we need to get the PO ID from
061 * @return the String value of the purchase order id
062 */
063 public String getInvoicePurchaseOrderID(ElectronicInvoiceOrder invoiceOrder) {
064 return invoiceOrder.getOrderReferenceOrderID();
065 }
066
067 /**
068 * This method defines which field out of the ElectronicInvoiceItem that the
069 * catalog number is coming in as
070 *
071 * @param eii ElectronicInvoiceItem we need to get the catalog number from
072 * @return catalog number value
073 */
074 public String getCatalogNumber(ElectronicInvoiceItem item) {
075 return item.getReferenceItemIDSupplierPartID();
076 }
077
078 /**
079 * This method defines which field out of the ElectronicInvoice that the
080 * customer number field is coming in as
081 *
082 * @param ei ElectronicInvoice we need to get the customer number from
083 * @return customer number value
084 */
085 public String getInvoiceCustomerNumber(ElectronicInvoice ei) {
086 // TODO: Future Release - Enter valid location for Customer Number from E-Invoice
087 return null;
088 }
089
090 /**
091 * This method contains the mapping check for valid Currency Code(s)
092 */
093 public String checkCodeForValidCurrency(String code) {
094 if (!(this.isCodeValidCurrency(code))) {
095 return code;
096 } else {
097 return null;
098 }
099 }
100
101 /**
102 * This method contains the mapping check for valid Currency Code(s)
103 */
104 public boolean isCodeValidCurrency(String code) {
105 if (code != null) {
106 for (int i = 0; i < CXML_VALID_CURRENCY_CODES.length; i++) {
107 String validCode = CXML_VALID_CURRENCY_CODES[i];
108 if (code.equalsIgnoreCase(validCode)) {
109 return true;
110 }
111 }
112 }
113 return false;
114 }
115
116
117 }