1 /* 2 * Copyright 2007 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 package org.kuali.ole.vnd.document.service; 17 18 import java.util.Collection; 19 import java.util.List; 20 21 import org.kuali.ole.sys.businessobject.Building; 22 import org.kuali.ole.vnd.businessobject.VendorAddress; 23 import org.kuali.ole.vnd.businessobject.VendorContract; 24 import org.kuali.ole.vnd.businessobject.VendorDetail; 25 import org.kuali.ole.vnd.businessobject.VendorHeader; 26 import org.kuali.ole.vnd.businessobject.VendorRoutingComparable; 27 import org.kuali.rice.core.api.util.type.KualiDecimal; 28 import org.kuali.rice.krad.bo.Note; 29 import org.kuali.rice.krad.document.Document; 30 31 public interface VendorService { 32 33 public void saveVendorHeader(VendorDetail vendorDetail); 34 35 /** 36 * get the vendor detail with the given vendor number 37 * @param vendorNumber the given vendor number 38 * @return the vendor detail with the given vendor number if the vendor exists, otherwise, return null 39 */ 40 public VendorDetail getByVendorNumber(String vendorNumber); 41 42 public VendorDetail getVendorDetail(String vendorNumber); 43 44 public VendorDetail getVendorDetail(Integer headerId, Integer detailId); 45 46 /** 47 * Retrieves the VendorDetail which is the parent vendor with the given headerId. This is the method to use when working 48 * backward from a division vendor to its parent vendor. This method throws RuntimeExceptions if there are found to be no parent 49 * vendor or more than one parent vendor for the associated corporate structure. 50 * 51 * @param vendorHeaderGeneratedIdentifier The Header Id in Integer form 52 * @return The VendorDetail of the parent vendor associated with the corporate structure indicated by the given Header Id, or 53 * null if there are no vendors associated with it. 54 */ 55 public VendorDetail getParentVendor(Integer vendorHeaderGeneratedIdentifier); 56 57 /** 58 * Retrieves the VendorDetail using its vendorDunsNumber. 59 * @param vendorDunsNumber the vendor's DUN number. 60 * @return 61 */ 62 public VendorDetail getVendorByDunsNumber(String vendorDunsNumber); 63 64 /** 65 * Gets the apo limit for the given parameters using the following logic:<br> 66 * <br> 67 * First it checks to see if an existing {@link org.kuali.ole.vnd.businessobject.VendorContractOrganization} object exists for the 68 * associated parameters. If one exists and it is not excluded (see 69 * {@link org.kuali.ole.vnd.businessobject.VendorContractOrganization#isVendorContractExcludeIndicator()}) this will return the value 70 * of {@link org.kuali.ole.vnd.businessobject.VendorContractOrganization#getVendorContractPurchaseOrderLimitAmount()}.<br> 71 * <br> 72 * If an associated {@link org.kuali.ole.vnd.businessobject.VendorContractOrganization} object cannot be found then a valid 73 * {@link org.kuali.ole.vnd.businessobject.VendorContract} object will be sought. If one is found this method will return the value of 74 * {@link org.kuali.ole.vnd.businessobject.VendorContract#getOrganizationAutomaticPurchaseOrderLimit()}.<br> 75 * <br> 76 * If no valid {@link org.kuali.ole.vnd.businessobject.VendorContractOrganization} or 77 * {@link org.kuali.ole.vnd.businessobject.VendorContract} objects can be found for the given parameters this method will return null. 78 * 79 * @param contractId id used to find {@link org.kuali.ole.vnd.businessobject.VendorContractOrganization} object and 80 * {@link org.kuali.ole.vnd.businessobject.VendorContract} object 81 * @param chart chart code for use in finding {@link org.kuali.ole.vnd.businessobject.VendorContractOrganization} object 82 * @param org org code for use in finding {@link org.kuali.ole.vnd.businessobject.VendorContractOrganization} object 83 * @return the automatic purchase order limit amount from the contract found using the parameters. If parameters do not find 84 * valid vendor contract objects then null is returned. 85 */ 86 public KualiDecimal getApoLimitFromContract(Integer contractId, String chart, String org); 87 88 /** 89 * Finds the addresses for the given vendor and then calls the method to determine the default address from this list. 90 * 91 * @param vendorHeaderId Integer - Header ID of vendor. 92 * @param vendorDetailId Integer - Detail ID of vendor. 93 * @param addressType String - Address type of desired default. 94 * @param campus String - Campus of desired default. 95 * @return VendorAddress Desired default address; return null is possible if no defaults set. 96 */ 97 public VendorAddress getVendorDefaultAddress(Integer vendorHeaderId, Integer vendorDetailId, String addressType, String campus); 98 99 /** 100 * Finds the default address for the given addressType and campus from the address list passed in based on the following logic: 101 * 1) The allDefaultAddress is defined by defaultAddressIndicator on VendorAddress. 2) If campus passed in is null, return 102 * allDefaultAddress if found. 3) If campus passed in is not null, look in campus lists of addresses to see if given campus is 103 * found for the given address type. If match found, return address. If no match found, return allDefaultAddress. 104 * 105 * @param addresses List of addresses for a vendor. 106 * @param addressType String - Address type of the desired default sought. 107 * @param campus String - Campus of the desired default sought. 108 * @return VendorAddress Desired default address; return null is possible if no defaults set. 109 */ 110 public VendorAddress getVendorDefaultAddress(Collection<VendorAddress> addresses, String addressType, String campus); 111 112 /** 113 * Checks to see if a the Vendor Document associated with the given document ID should route to the route path branch in 114 * workflow where the document will stop for approvals. 115 * 116 * @param documentId 117 * @return true if the vendor should be take the approval patch... false if the vendor can be 'auto approved' 118 */ 119 public boolean shouldVendorRouteForApproval(String documentId); 120 121 /** 122 * Compares lists which have an isEqualForRouting method by using that method. An Equals() method would be wrong for the purpose 123 * of comparing these because we want to compare only using certain specified attributes, which is what our isEqualForRouting 124 * methods will do. 125 * 126 * @param list_a A List which implements VendorRoutingComparable (specifies isEqualForRouting) 127 * @param list_b Another such list 128 * @return True if all the member objects in the given lists are equal (as far as routing is concerned) at the same locations in 129 * the lists. 130 */ 131 public boolean equalMemberLists(List<? extends VendorRoutingComparable> list_a, List<? extends VendorRoutingComparable> list_b); 132 133 /** 134 * This method is the place to put the calls to equality checks that are needed when deciding whether to route a vendor for 135 * approval or directly to final status on the basis of what has changed. This method has been split out from 136 * shouldVendorRouteForApproval for the convenience of unit testing, but might be useful for other purposes. 137 * 138 * @param newVDtl A VendorDetail object representing the state of the proposed change 139 * @param newVHdr A VendorHeader object representing the state of the proposed change 140 * @param oldVDtl A VendorDetail object from before the change 141 * @param oldVHdr A VendorHeader object from before the change 142 * @return True if no route-significant change occurred 143 */ 144 public boolean noRouteSignificantChangeOccurred(VendorDetail newVDtl, VendorHeader newVHdr, VendorDetail oldVDtl, VendorHeader oldVHdr); 145 146 /** 147 * Indicates whether the vendor identified by the given <code>vendorHeaderGeneratedIdentifier</code> is an employee of the 148 * institution. The vendor must have a valid tax id and it must be of type SSN (see 149 * {@link org.kuali.ole.vnd.VendorConstants#TAX_TYPE_SSN}). 150 * 151 * @param vendorHeaderGeneratedIdentifier The Header Id in Integer form 152 * @return true if the vendor identified by the <code>vendorHeaderGeneratedIdentifier</code> given is an employee of the 153 * institution 154 */ 155 public boolean isVendorInstitutionEmployee(Integer vendorHeaderGeneratedIdentifier); 156 157 /** 158 * Indicates whether the vendor identified by the given <code>vendorHeaderGeneratedIdentifier</code> is a non-resident alien 159 * by checking the value of {@link org.kuali.ole.vnd.businessobject.VendorHeader#getVendorForeignIndicator()}. 160 * 161 * @param vendorHeaderGeneratedIdentifier The Header Id in Integer form 162 * @return true if the vendor identified by the <code>vendorHeaderGeneratedIdentifier</code> given is valid and is marked as a 163 * foreign vendor 164 */ 165 public boolean isVendorForeign(Integer vendorHeaderGeneratedIdentifier); 166 167 /** 168 * Indicates whether the vendor identified by the given <code>vendorHeaderGeneratedIdentifier</code> is a subject payment vendor 169 * by checking the value of {@link org.kuali.ole.vnd.businessobject.VendorHeader#getVendorTypeCode()} to see if it equals "SP". 170 * 171 * @param vendorHeaderGeneratedIdentifier The Header Id in Integer form 172 * @return true if the vendor identified by the <code>vendorHeaderGeneratedIdentifier</code> given is valid and has a vendor type code of "SP" 173 */ 174 public boolean isSubjectPaymentVendor(Integer vendorHeaderGeneratedIdentifier); 175 176 /** 177 * Indicates whether the vendor identified by the given <code>vendorHeaderGeneratedIdentifier</code> is a revolving fund code vendor 178 * by checking the value of {@link org.kuali.ole.vnd.businessobject.VendorHeader#getVendorTypeCode()} to see if it equals "RF". 179 * 180 * @param vendorHeaderGeneratedIdentifier The Header Id in Integer form 181 * @return true if the vendor identified by the <code>vendorHeaderGeneratedIdentifier</code> given is valid and has a vendor type code of "RF" 182 */ 183 public boolean isRevolvingFundCodeVendor(Integer vendorHeaderGeneratedIdentifier); 184 185 /** 186 * This method retrieves the B2B Contract for the given Vendor (see method in VendorDao for criteria). 187 * 188 * @param vendorDetail Vendor info 189 * @param campus Campus 190 * @return VendorContract B2B Contract for given vendor 191 */ 192 public VendorContract getVendorB2BContract(VendorDetail vendorDetail, String campus); 193 194 public Building getBuildingDetails(String campusCode, String buildingCode); 195 196 List<Note> getVendorNotes(VendorDetail vendorDetail); 197 198 /** 199 * REQ should have failed APO rules and routed to Contract Mgr Assignment since the REQ had a contracted vendor 200 * used where the contract end date is expired (regardless of the Active Indicator). 201 * Notes tab should reflect that the vendor on REQ has an expired contract. 202 * 203 * @param poDocument 204 * @param vendorDetail 205 * @return true if vendor contract expired end date is not expired else retur false. 206 */ 207 public boolean isVendorContractExpired(Document document, VendorDetail vendorDetail); 208 }