1 /* 2 * Copyright 2006 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.module.purap.document.service; 17 18 import org.kuali.ole.integration.purap.CapitalAssetSystem; 19 import org.kuali.ole.module.purap.businessobject.*; 20 import org.kuali.ole.module.purap.document.ContractManagerAssignmentDocument; 21 import org.kuali.ole.module.purap.document.PurchaseOrderDocument; 22 import org.kuali.ole.module.purap.document.PurchaseOrderSplitDocument; 23 import org.kuali.ole.module.purap.document.RequisitionDocument; 24 import org.kuali.ole.select.document.OlePurchaseOrderDocument; 25 import org.kuali.ole.vnd.businessobject.VendorDetail; 26 import org.kuali.ole.vnd.businessobject.VendorTransmissionFormatDetail; 27 import org.kuali.rice.core.api.util.type.KualiDecimal; 28 import org.kuali.rice.krad.bo.Note; 29 30 import java.io.ByteArrayOutputStream; 31 import java.util.HashMap; 32 import java.util.List; 33 34 /** 35 * Defines methods that must be implemented by classes providing a PurchaseOrderService. 36 */ 37 public interface PurchaseOrderService extends PurchasingDocumentSpecificService { 38 39 public boolean isCommodityCodeRequiredOnPurchaseOrder(); 40 41 public boolean isPurchaseOrderOpenForProcessing(Integer poId); 42 43 public boolean isPurchaseOrderOpenForProcessing(PurchaseOrderDocument purchaseOrderDocument); 44 45 /** 46 * Creates an automatic purchase order document using the given requisition document 47 * 48 * @param reqDocument The requisition document that this method will use to create the Automated Purchase Order (APO). 49 */ 50 public void createAutomaticPurchaseOrderDocument(RequisitionDocument reqDocument); 51 52 /** 53 * Creates a PurchaseOrderDocument from given RequisitionDocument. Both documents need to be saved after this method is called. 54 * 55 * @param reqDocument The requisition document that this method will use to create the purchase order. 56 * @param newSessionUserId The session user id that we'll use to invoke the performLogicWithFakedUserSession method of 57 * PurapService. 58 * @param contractManagerCode The contract manager code that we'll need to set on the purchase order. 59 * @return The purchase order document object that is created by this method. 60 */ 61 public PurchaseOrderDocument createPurchaseOrderDocument(RequisitionDocument reqDocument, String newSessionUserId, Integer contractManagerCode); 62 63 /** 64 * Creates and saves the purchase order change document (for example, PurchaseOrderAmendmentDocument) based on an existing 65 * purchase order document. 66 * 67 * @param documentNumber The document number of the existing purchase order document from which we try to create a new change 68 * document. 69 * @param docType The document type of the new change document. 70 * @param newDocumentStatusCode The status code that we want to set on the existing purchase order document after the new change 71 * document is created. 72 * @return The resulting new purchase order change document created by this method. 73 */ 74 public PurchaseOrderDocument createAndSavePotentialChangeDocument(String documentNumber, String docType, String newDocumentStatusCode); 75 76 /** 77 * Creates and routes the purchase order change document (for example, PurchaseOrderCloseDocument) based on an existing purchase 78 * order document. 79 * 80 * @param 81 * @param documentNumber The document number of the existing purchase order document from which we try to create a new change 82 * document. 83 * @param docType The document type of the new change document. 84 * @param annotation The annotation that we'll use to invoke the routeDocument method of DocumentService. 85 * @param adhocRoutingRecipients The adhocRoutingRecipients that we'll use to invoke the routeDocument method of 86 * DocumentService. 87 * @param newDocumentStatusCode The status code that we want to set on the existing purchase order document after the new change 88 * document is created. 89 * @return The resulting new purchase order change document created by this method. 90 */ 91 public PurchaseOrderDocument createAndRoutePotentialChangeDocument(String documentNumber, String docType, String annotation, List adhocRoutingRecipients, String newDocumentStatusCode); 92 93 /** 94 * Creates and saves a Purchase Order Split document based on the old PO document, and the items from that PO that the 95 * new Split PO is to contain. 96 * 97 * @param newPOItems The List<PurchaseOrderItem> of the items that the new Split PO is to contain 98 * @param currentDocument The original PurchaseOrderDocument 99 * @param copyNotes A boolean. True if notes are to be copied from the old document to the new. 100 * @param splitNoteText A String containing the text of the note to be added to the old document. 101 * @return A PurchaseOrderSplitDocument containing the given list of items 102 */ 103 public PurchaseOrderSplitDocument createAndSavePurchaseOrderSplitDocument(List<PurchaseOrderItem> newPOItems, PurchaseOrderDocument currentDocument, boolean copyNotes, String splitNoteText); 104 105 /** 106 * Obtains the internal purchasing dollar limit amount for a purchase order document. 107 * 108 * @param po The purchase order document for which this method is obtaining the internal purchasing dollar limit. 109 * @return The internal purchasing dollar limit for the given purchase order document. 110 */ 111 public KualiDecimal getInternalPurchasingDollarLimit(PurchaseOrderDocument po); 112 113 public boolean printPurchaseOrderQuoteRequestsListPDF(String documentNumber, ByteArrayOutputStream baosPDF); 114 115 public boolean printPurchaseOrderQuotePDF(PurchaseOrderDocument po, PurchaseOrderVendorQuote povq, ByteArrayOutputStream baosPDF); 116 117 /** 118 * Creates and displays the pdf document for the purchase order, sets the transmit dates, calls the 119 * takeAllActionsForGivenCriteria method in PurApWorkflowIntegrationService to perform all the workflow related steps that are 120 * necessary as part of the document initial print transmission and then performs the setup of initial of open document of the 121 * purchase order. 122 * 123 * @param documentNumber The document number of the purchase order document that we want to perform the first transmit. 124 * @param baosPDF The ByteArrayOutputStream object that was passed in from the struts action so that we could display the pdf on 125 * the browser. 126 */ 127 public void performPurchaseOrderFirstTransmitViaPrinting(String documentNumber, ByteArrayOutputStream baosPDF); 128 129 /** 130 * Creates and displays the pdf document for the purchase order with a draft watermark 131 * 132 * @param documentNumber The document number of the purchase order document that we want to perform the first transmit. 133 * @param baosPDF The ByteArrayOutputStream object that was passed in from the struts action so that we could display the pdf on 134 * the browser. 135 */ 136 public void performPurchaseOrderPreviewPrinting(String documentNumber, ByteArrayOutputStream baosPDF); 137 138 /** 139 * Generates and displays the purchase order pdf by invoking the generatePurchaseOrderPdf method of the PrintService. 140 * 141 * @param documentNumber The document number of the purchase order document that we want to print the pdf. 142 * @param baosPDF The ByteArrayOutputStream object that we'll use to display the pdf on the browser. 143 */ 144 public void performPrintPurchaseOrderPDFOnly(String documentNumber, ByteArrayOutputStream baosPDF); 145 146 /** 147 * Generates and displays the purchase order retransmit pdf by invoking the generatePurchaseOrderPdfForRetransmission method of 148 * the PrintService. 149 * 150 * @param po The purchase order document to be retransmitted. 151 * @param baosPDF The ByteArrayOutputStream object that we'll use to display the pdf on the browser. 152 */ 153 public void retransmitPurchaseOrderPDF(PurchaseOrderDocument po, ByteArrayOutputStream baosPDF); 154 155 /** 156 * Performs the steps needed to complete the newly approved purchase order document, which consists of setting the current and 157 * pending indicators for the purchase order document and if the status is not pending transmission, then calls the 158 * attemptsSetupOfInitialOpenOfDocument to set the statuses, the initial open date and save the document. 159 * 160 * @param po The newly approved purchase order document that we want to complete. 161 */ 162 public void completePurchaseOrder(PurchaseOrderDocument po); 163 164 public void retransmitB2BPurchaseOrder(PurchaseOrderDocument po); 165 166 public void completePurchaseOrderAmendment(PurchaseOrderDocument po); 167 168 /** 169 * Obtains the purchase order document whose current indicator is true, given a purchase order id which is the 170 * purapDocumentIdentifier. 171 * 172 * @param id The po id (purapDocumentIdentifier) that we'll use to retrieve the current purchase order document. 173 * @return The current purchase order document (the po whose current indicator is true). 174 */ 175 public PurchaseOrderDocument getCurrentPurchaseOrder(Integer id); 176 177 /** 178 * Obtains the purchase order document given the document number. 179 * 180 * @param documentNumber The document number of the purchase order that we want to retrieve. 181 * @return The purchase order document whose document number is the given document number. 182 */ 183 public PurchaseOrderDocument getPurchaseOrderByDocumentNumber(String documentNumber); 184 185 /** 186 * Sets the current and pending indicators of the new purchase order and the old purchase order as well as its status, then save 187 * the purchase order. 188 * 189 * @param newPO The new purchase order document that has been approved. 190 */ 191 public void setCurrentAndPendingIndicatorsForApprovedPODocuments(PurchaseOrderDocument newPO); 192 193 /** 194 * Sets the current and pending indicators of the new purchase order and the old purchase order as well as their statuses, then 195 * save the purchase order. 196 * 197 * @param newPO The new purchase order document that has been disapproved. 198 */ 199 public void setCurrentAndPendingIndicatorsForDisapprovedChangePODocuments(PurchaseOrderDocument newPO); 200 201 /** 202 * Sets the current and pending indicators of the new purchase order and the old purchase order as well as their statuses, then 203 * save the purchase order. 204 * 205 * @param newPO The new purchase order document that has been canceled. 206 */ 207 public void setCurrentAndPendingIndicatorsForCancelledChangePODocuments(PurchaseOrderDocument newPO); 208 209 /** 210 * Sets the current and pending indicators of the new purchase order and the old purchase order as well as their statuses, then 211 * save the purchase order. 212 * 213 * @param newPO The new purchase order reopen document that has been canceled. 214 */ 215 public void setCurrentAndPendingIndicatorsForCancelledReopenPODocuments(PurchaseOrderDocument newPO); 216 217 /** 218 * Sets the current and pending indicators of the new purchase order and the old purchase order as well as their statuses, then 219 * save the purchase order. 220 * 221 * @param newPO The new purchase order reopen document that has been disapproved. 222 */ 223 public void setCurrentAndPendingIndicatorsForDisapprovedReopenPODocuments(PurchaseOrderDocument newPO); 224 225 /** 226 * Sets the current and pending indicators of the new purchase order and the old purchase order as well as their statuses, then 227 * save the purchase order 228 * 229 * @param newPO The new purchase order remove hold document that has been canceled. 230 */ 231 public void setCurrentAndPendingIndicatorsForCancelledRemoveHoldPODocuments(PurchaseOrderDocument newPO); 232 233 /** 234 * Sets the current and pending indicators of the new purchase order and the old purchase order as well as their statuses, then 235 * save the purchase order. 236 * 237 * @param newPO The new purchase order remove hold document that has been disapproved. 238 */ 239 public void setCurrentAndPendingIndicatorsForDisapprovedRemoveHoldPODocuments(PurchaseOrderDocument newPO); 240 241 /** 242 * Obtains the oldest purchase order given the purchase order object to be used to search, then calls the updateNotes method to 243 * set the notes on the oldest purchase order and finally return the oldest purchase order. 244 * 245 * @param po The current purchase order object from which we want to obtain the oldest purchase order. 246 * @param documentBusinessObject The documentBusinessObject of the current purchase order object. 247 * @return The oldest purchase order whose purchase order id is the same as the current purchase order's id. 248 */ 249 public PurchaseOrderDocument getOldestPurchaseOrder(PurchaseOrderDocument po, PurchaseOrderDocument documentBusinessObject); 250 251 /** 252 * Obtains all the notes that belong to this purchase order given the purchase order id. 253 * 254 * @param id The purchase order id (purapDocumentIdentifier). 255 * @return The list of notes that belong to this purchase order. 256 */ 257 public List<Note> getPurchaseOrderNotes(Integer id); 258 259 public List<PurchaseOrderQuoteStatus> getPurchaseOrderQuoteStatusCodes(); 260 261 /** 262 * Performs a threshold check on the purchase order to determine if any attribute on the purchase order 263 * falls within a defined threshold. This check is only perfromed if the receiving required flag is set to N. 264 * 265 * @param po 266 */ 267 public void setReceivingRequiredIndicatorForPurchaseOrder(PurchaseOrderDocument po); 268 269 /** 270 * If there are commodity codes on the items on the PurchaseOrderDocument that 271 * haven't existed yet on the vendor that the PurchaseOrderDocument is using, 272 * then we will spawn a new VendorDetailMaintenanceDocument automatically to 273 * update the vendor with the commodity codes that aren't already existing on 274 * the vendor. 275 * 276 * @param po The PurchaseOrderDocument containing the vendor that we want to update. 277 */ 278 public void updateVendorCommodityCode(PurchaseOrderDocument po); 279 280 /** 281 * Checks the item list for newly added unordered items. 282 * 283 * @param po 284 * @return 285 */ 286 public boolean hasNewUnorderedItem(PurchaseOrderDocument po); 287 288 /** 289 * Check whether each of the items contain commodity code, if so then loop 290 * through the vendor commodity codes on the vendor to find out whether the 291 * commodity code on the item has existed on the vendor. While doing that, 292 * also check whether there exists a default commodity code on the vendor, 293 * although we only need to check this until we find a vendor commodity code 294 * with default indicator set to true. If we didn't find any matching 295 * commodity code in the existing vendor commodity codes, then add the new 296 * commodity code to a List of commodity code, create a new vendor commodity 297 * code and set all of its attributes appropriately, including setting the 298 * default indicator to true if we had not found any existing default commodity 299 * code on the vendor, then add the newly created vendor commodity code to 300 * the vendor (which is a deep copy of the original vendor on the PO). 301 * After we're done with all of the items, if the List that contains the 302 * commodity code that were being added to the vendor is not empty, then 303 * for each entry on that list, we should create an empty VendorCommodityCode 304 * to be added to the old vendor (the original vendor that is on the PO document). 305 * The reason we're combining all of these processing here is so that we don't 306 * need to loop through items and vendor commodity codes too many times. 307 * 308 * @param po The PurchaseOrderDocument containing the vendor that we want to update. 309 * @return VendorDetail the vendorDetail object which is a deep copy of the original 310 * vendorDetail on the PurchaseOrderDocument, whose commodity codes have 311 * already been updated based on our findings on the items' commodity codes. 312 */ 313 public VendorDetail updateVendorWithMissingCommodityCodesIfNecessary(PurchaseOrderDocument po); 314 315 /** 316 * Determines if a purchase order item is new unordered item. 317 * 318 * @param poItem 319 * @return 320 */ 321 public boolean isNewUnorderedItem(PurchaseOrderItem poItem); 322 323 /** 324 * Determines if a purchase order item is newly added on 325 * the Purchase Order Amendment Document. 326 * 327 * @param poItem 328 * @return 329 */ 330 public boolean isNewItemForAmendment(PurchaseOrderItem poItem); 331 332 /** 333 * Used to provide sublists of the list of the original PO's items according to whether they 334 * are marked to be moved or not. Retrieving the item from the hash with the key of 'movingPOItems' 335 * will retrieve those Items which should move, using 'remainingPOItems'. 336 * 337 * @param items A List<PurchaseOrderItem> from the original PO of a Split. 338 * @return A HashMap<String, List<PurchaseOrderItem>> of categorized lists of items 339 */ 340 public HashMap<String, List<PurchaseOrderItem>> categorizeItemsForSplit(List<PurchaseOrderItem> items); 341 342 /** 343 * Creates a PurchaseOrderVendorQuote based on the data on the selected vendor and the document number. 344 * 345 * @param headerId The vendorHeaderGeneratedIdentifier of the selected vendor. 346 * @param detailId The vendorDetailAssignedIdentifier of the selected vendor. 347 * @param documentNumber The documentNumber of the PurchaseOrderDocument containing this quote. 348 * @return The resulting PurchaseOrderVendorQuote object. 349 */ 350 public PurchaseOrderVendorQuote populateQuoteWithVendor(Integer headerId, Integer detailId, String documentNumber); 351 352 /** 353 * This method takes care of creating PurchaseOrderDocuments from a list of Requisitions on an ACM 354 * 355 * @param acmDoc An assign a contract manager document 356 */ 357 public void processACMReq(ContractManagerAssignmentDocument acmDoc); 358 359 /** 360 * This gets a list of Purchase Orders in Open status and checks to see if their 361 * line item encumbrances are all fully disencumbered and if so then the Purchase 362 * Order is closed and notes added to indicate the change occurred in batch 363 * 364 * @return boolean true if the job is completed successfully and false otherwise. 365 */ 366 public boolean autoCloseFullyDisencumberedOrders(); 367 368 369 /** 370 * - PO status is OPEN 371 * - Recurring payment type code is not null 372 * - Vendor Choice is not Sub-Contract 373 * - PO End Date <= parm date (comes from system parameter) 374 * - Verify that the system parameter date entered is not greater than the current date minus three months. 375 * If the date entered is invalid, the batch process will halt and an error will be generated. 376 * - Close and disencumber all recurring PO's that have end dates less than 377 * the system parameter date. 378 * - Set the system parameter date to mm/dd/yyyy after processing. 379 * - Send email indicating that the job ran and which orders were closed. 380 * Mail it to the AUTO_CLOSE_RECURRING_PO_EMAIL_ADDRESSES in system parameter. 381 * 382 * @return boolean true if the job is completed successfully and false otherwise. 383 */ 384 public boolean autoCloseRecurringOrders(); 385 386 387 /** 388 * Return a list of PurchasingCapitalAssetItems where each item would have a CapitalAssetSystem. The CapitalAssetSystem provides 389 * the capital asset information such as asset numbers and asset type. 390 * 391 * @param poId Purchase Order ID used to retrieve the asset information for the current PO 392 * @return List of PurchasingCapitalAssetItems (each of which contain a CapitalAssetSystem) 393 */ 394 public List<PurchasingCapitalAssetItem> retrieveCapitalAssetItemsForIndividual(Integer poId); 395 396 397 /** 398 * Return a CapitalAssetSystem which provides the capital asset information such as asset numbers and asset type. 399 * 400 * @param poId Purchase Order ID used to retrieve the asset information for the current PO 401 * @return CapitalAssetSystem 402 */ 403 public CapitalAssetSystem retrieveCapitalAssetSystemForOneSystem(Integer poId); 404 405 406 /** 407 * Return a list of CapitalAssetSystems which provide the capital asset information such as asset numbers and asset type. 408 * 409 * @param poId Purchase Order ID used to retrieve the asset information for the current PO 410 * @return List of CapitalAssetSystems 411 */ 412 public List<CapitalAssetSystem> retrieveCapitalAssetSystemsForMultipleSystem(Integer poId); 413 414 415 /** 416 * This method gets all the Purchase orders that are waiting for faxing 417 * 418 * @return List of POs 419 */ 420 public List<PurchaseOrderDocument> getPendingPurchaseOrderFaxes(); 421 422 /** 423 * Retrieves the purchase orders current status 424 * 425 * @param poId 426 * @return 427 */ 428 public String getPurchaseOrderAppDocStatus(Integer poId); 429 430 /** 431 * This method is to send an FYI to fiscal officers for general ledger entries created for amend purchase order 432 * 433 * @param po 434 */ 435 public void sendFyiForGLEntries(PurchaseOrderDocument po); 436 437 public void initiateTransmission(PurchaseOrderDocument po, PurApItem item); 438 439 public boolean processFTPTransmission(VendorTransmissionFormatDetail vendorTransmissionFormatDetail, String file, String ediFileName); 440 441 public PurchaseOrderDocument createAndRoutePotentialChangeDocument(OlePurchaseOrderDocument olePurchaseOrderDocument, String docType, String annotation, List adhocRoutingRecipients, String currentDocumentStatusCode); 442 }