001/*
002 * Copyright 2007 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 */
016package org.kuali.ole.module.purap.document.dataaccess;
017
018import org.kuali.ole.module.purap.document.VendorCreditMemoDocument;
019import org.kuali.ole.module.purap.util.VendorGroupingHelper;
020import org.kuali.rice.core.api.util.type.KualiDecimal;
021
022import java.sql.Date;
023import java.util.Collection;
024import java.util.List;
025
026/**
027 * Credit Memo DAO Interface. Defines DB access methods that a CreditMemoDaoImpl must implement.
028 */
029public interface CreditMemoDao {
030
031    /**
032     * Get all the credit memos that need to be extracted
033     *
034     * @param chartCode - if not null, limit results to a single chart
035     * @return - Iterator of credit memos
036     */
037    public List<VendorCreditMemoDocument> getCreditMemosToExtract(String chartCode);
038
039    /**
040     * Get all the credit memos that need to be extracted for a particular vendor record.
041     *
042     * @param chartCode                      - if not null, limit results to a single chart
043     * @param vendorHeaderGeneratedIdentifier
044     *
045     * @param vendorDetailAssignedIdentifier
046     * @return - Iterator of credit memos
047     */
048    public Collection<VendorCreditMemoDocument> getCreditMemosToExtractByVendor(String chartCode, VendorGroupingHelper vendor);
049
050    /**
051     * This method tests for a duplicate entry of a credit memo by the combination of vendorNumber HeaderId, vendorNumber and
052     * creditMemoNumber. This method accepts the three values as arguments, and returns a boolean, describing whether a duplicate
053     * exists in the system or not.
054     *
055     * @param vendorNumberHeaderId - vendor number header id
056     * @param vendorNumber         - the composite two-part vendorNumber (headerId-detailId)
057     * @param creditMemoNumber     - the vendor-supplied creditMemoNumber
058     * @return boolean - true if a match exists in the db, false if not
059     */
060    public boolean duplicateExists(Integer vendorNumberHeaderId, Integer vendorNumberDetailId, String creditMemoNumber);
061
062    /**
063     * This method tests for a duplicate entry of a credit memo by the combination of vendor number header id, vendor detail id,
064     * date and amount. This method accepts the values as arguments, and returns a boolean, describing whether a duplicate exists in
065     * the system or not.
066     *
067     * @param vendorNumberHeaderId
068     * @param vendorNumberDetailId
069     * @param date                 - date of transaction
070     * @param amount               - amount of transaction
071     * @return boolean - true if a match exists in the db, false if not
072     */
073    public boolean duplicateExists(Integer vendorNumberHeaderId, Integer vendorNumberDetailId, Date date, KualiDecimal amount);
074
075    /**
076     * This method returns a credit memo document number by id.
077     *
078     * @param id - credit memo id
079     * @return - document number
080     */
081    public String getDocumentNumberByCreditMemoId(Integer id);
082
083    /**
084     * Retrieves a list of potentially active credit memos for a purchase order by
085     * status code. Active being defined as being enroute and before final. The issue
086     * is that a status of vendor_tax_review may not mean that it's in review, but could be
087     * in final (as there isn't a final status code for payment request). Workflow status
088     * must be checked further after retrieval.
089     *
090     * @param purchaseOrderId
091     * @return
092     */
093    public List<String> getActiveCreditMemoDocumentNumbersForPurchaseOrder(Integer purchaseOrderId);
094}