View Javadoc

1   package org.kuali.ole.deliver.bo;
2   
3   import org.kuali.ole.OLEConstants;
4   import org.kuali.ole.deliver.processor.LoanProcessor;
5   import org.kuali.ole.docstore.common.client.DocstoreClientLocator;
6   import org.kuali.ole.docstore.common.document.Bib;
7   import org.kuali.ole.docstore.common.document.ItemOleml;
8   import org.kuali.ole.docstore.common.search.SearchResponse;
9   import org.kuali.ole.docstore.common.search.SearchResult;
10  import org.kuali.ole.docstore.common.search.SearchResultField;
11  
12  import org.kuali.ole.service.impl.OlePatronBillMaintenanceDocumentServiceImpl;
13  import org.kuali.ole.sys.context.SpringContext;
14  import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
15  import org.kuali.rice.krad.bo.PersistableAttachment;
16  import org.kuali.rice.krad.bo.PersistableBusinessObject;
17  import org.kuali.rice.krad.maintenance.MaintenanceDocument;
18  import org.kuali.rice.krad.maintenance.MaintenanceUtils;
19  import org.kuali.rice.krad.service.BusinessObjectService;
20  import org.kuali.rice.krad.service.KRADServiceLocator;
21  import org.kuali.rice.krad.service.MaintenanceDocumentService;
22  import org.kuali.rice.krad.uif.UifParameters;
23  import org.kuali.rice.krad.uif.container.CollectionGroup;
24  import org.kuali.rice.krad.uif.util.ObjectPropertyUtils;
25  import org.kuali.rice.krad.uif.view.View;
26  import org.kuali.rice.krad.util.GlobalVariables;
27  import org.kuali.rice.krad.util.KRADConstants;
28  import org.kuali.rice.krad.web.controller.MaintenanceDocumentController;
29  import org.kuali.rice.krad.web.form.DocumentFormBase;
30  import org.kuali.rice.krad.web.form.MaintenanceDocumentForm;
31  import org.kuali.rice.krad.web.form.UifFormBase;
32  import org.springframework.stereotype.Controller;
33  import org.springframework.validation.BindingResult;
34  import org.springframework.web.bind.annotation.ModelAttribute;
35  import org.springframework.web.bind.annotation.RequestMapping;
36  import org.springframework.web.bind.annotation.RequestMethod;
37  import org.springframework.web.servlet.ModelAndView;
38  
39  import javax.servlet.http.HttpServletRequest;
40  import javax.servlet.http.HttpServletResponse;
41  import java.math.BigDecimal;
42  import java.util.*;
43  
44  /**
45   * Created with IntelliJ IDEA.
46   * User: ?
47   * Date: 10/5/12
48   * Time: 2:21 PM
49   * To change this template use File | Settings | File Templates.
50   */
51  @Controller
52  @RequestMapping(value = "/patronBillMaintenance")
53  public class PatronBillMaintenanceDocumentController extends MaintenanceDocumentController {
54  
55      private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(org.kuali.ole.deliver.bo.PatronBillMaintenanceDocumentController.class);
56      private BusinessObjectService businessObjectService;
57      private DocstoreClientLocator docstoreClientLocator;
58  
59      public DocstoreClientLocator getDocstoreClientLocator() {
60  
61          if (docstoreClientLocator == null) {
62              docstoreClientLocator = SpringContext.getBean(DocstoreClientLocator.class);
63  
64          }
65          return docstoreClientLocator;
66      }
67  
68      /**
69       * Gets the businessObjectService attribute.
70       *
71       * @return Returns the businessObjectService
72       */
73      public BusinessObjectService getBusinessObjectService() {
74          if (null == businessObjectService) {
75              businessObjectService = KRADServiceLocator.getBusinessObjectService();
76          }
77          return businessObjectService;
78      }
79  
80      /**
81       * Default method for controller that setups a new
82       * <code>MaintenanceView</code> with the default new action
83       */
84      @RequestMapping(params = "methodToCall=" + KRADConstants.Maintenance.METHOD_TO_CALL_NEW)
85      @Override
86      public ModelAndView start(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
87                                HttpServletRequest request, HttpServletResponse response) {
88          Date billDate = new Date();
89          MaintenanceDocumentForm maintenanceForm = (MaintenanceDocumentForm) form;
90          setupMaintenance(maintenanceForm, request, KRADConstants.MAINTENANCE_NEW_ACTION);
91          MaintenanceDocument document = (MaintenanceDocument) maintenanceForm.getDocument();
92          PatronBillPayment patronBillPayment = (PatronBillPayment) document.getDocumentDataObject();
93          Map patronMap = new HashMap();
94          patronMap.put(OLEConstants.OleDeliverRequest.PATRON_ID, request.getParameter(OLEConstants.PTRN_ID));
95          List<OlePatronDocument> olePatronDocumentList = (List<OlePatronDocument>) KRADServiceLocator.getBusinessObjectService().findMatching(OlePatronDocument.class, patronMap);
96          if (olePatronDocumentList != null && olePatronDocumentList.size() > 0) {
97              patronBillPayment.setOlePatron(olePatronDocumentList.get(0));
98          }
99          patronBillPayment.setPatronId(request.getParameter(OLEConstants.PTRN_ID));
100         patronBillPayment.setFirstName(request.getParameter(OLEConstants.PTRN_FN));
101         patronBillPayment.setLastName(request.getParameter(OLEConstants.PTRN_LN));
102         /*Map proxyPatronMap = new HashMap();
103         String firstName = "";
104         String lastName = "";
105         proxyPatronMap.put("olePatronId",request.getParameter(OLEConstants.PTRN_ID));
106         List<OleProxyPatronDocument> oleProxyPatronDocumentList = (List<OleProxyPatronDocument>) KRADServiceLocator.getBusinessObjectService().findMatching(OleProxyPatronDocument.class,proxyPatronMap);
107         String proxyPatronId = "";
108         if(oleProxyPatronDocumentList.size() > 0){
109             proxyPatronId = oleProxyPatronDocumentList.get(0).getProxyPatronId();
110             Map patronMap = new HashMap();
111             patronMap.put("olePatronId",proxyPatronId);
112             List<OlePatronDocument> olePatronDocumentList = (List<OlePatronDocument>) KRADServiceLocator.getBusinessObjectService().findMatching(OlePatronDocument.class,patronMap);
113             if(olePatronDocumentList.size() > 0){
114                  firstName = olePatronDocumentList.get(0).getEntity().getNames().get(0).getFirstName();
115                  lastName = olePatronDocumentList.get(0).getEntity().getNames().get(0).getLastName();
116                  patronBillPayment.setProxyFirstName(firstName);
117                  patronBillPayment.setProxyLastName(lastName);
118             }
119         }*/
120         patronBillPayment.setBillDate(new java.sql.Date(billDate.getTime()));
121         return getUIFModelAndView(maintenanceForm);
122     }
123 
124 
125     /**
126      * This method returns the instance of olePatronBillMaintenanceDocumentService
127      *
128      * @return olePatronMaintenanceDocumentService(MaintenanceDocumentService)
129      */
130     @Override
131     protected MaintenanceDocumentService getMaintenanceDocumentService() {
132         return GlobalResourceLoader.getService(OLEConstants.OlePatron.OLE_PTRN_BILL_MAIN_DOC_SER);
133     }
134 
135 
136     /**
137      * This method will add the patron bill  document to the existing list and also stores the attachment
138      * to the specified path.
139      *
140      * @param uifForm - MaintenanceDocumentForm
141      * @return ModelAndView
142      */
143     @RequestMapping(params = "methodToCall=addToTotalAmount")
144     public ModelAndView addToTotalAmount(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result,
145                                          HttpServletRequest request, HttpServletResponse response) throws Exception {
146         LOG.debug("Initialized addToTotalAmount method");
147         ModelAndView modelAndView = super.addLine(uifForm, result, request, response);
148         MaintenanceDocumentForm form = (MaintenanceDocumentForm) uifForm;
149         MaintenanceDocument document = (MaintenanceDocument) form.getDocument();
150         PatronBillPayment patronBillPayment = (PatronBillPayment) document.getNewMaintainableObject().getDataObject();
151         BigDecimal amount = new BigDecimal(0.0);
152         if (patronBillPayment.getFeeType() != null) {
153             List<FeeType> feeTypes = patronBillPayment.getFeeType();
154             for (int i = 0; i < feeTypes.size(); i++) {
155                 amount = amount.add(feeTypes.get(i).getFeeAmount());
156             }
157             patronBillPayment.setTotalAmount(amount);
158 
159         }
160         return modelAndView;
161     }
162 
163 
164     /**
165      * Called by the add line action for a new collection line. Method
166      * determines which collection the add action was selected for and invokes
167      * the view helper service to add the line
168      */
169     @Override
170     @RequestMapping(method = RequestMethod.POST, params = "methodToCall=addLine")
171     public ModelAndView addLine(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result,
172                                 HttpServletRequest request, HttpServletResponse response) {
173         LOG.debug("Initialized addLine method");
174         MaintenanceDocumentForm form = (MaintenanceDocumentForm) uifForm;
175         MaintenanceDocument document = (MaintenanceDocument) form.getDocument();
176         PatronBillPayment patronBillPayment = (PatronBillPayment) document.getNewMaintainableObject().getDataObject();
177         LoanProcessor loanProcessor = new LoanProcessor();
178         String selectedCollectionPath = form.getActionParamaterValue(UifParameters.SELLECTED_COLLECTION_PATH);
179         CollectionGroup collectionGroup = form.getPostedView().getViewIndex().getCollectionGroupByPath(
180                 selectedCollectionPath);
181         String addLinePath = collectionGroup.getAddLineBindingInfo().getBindingPath();
182         Object eventObject = ObjectPropertyUtils.getPropertyValue(form, addLinePath);
183         FeeType feeType = (FeeType) eventObject;
184         String itemBarcode = feeType.getItemBarcode();
185         String itemUUID = feeType.getItemUuid();
186         String itemType = feeType.getItemType();
187         String itemTitle = feeType.getItemTitle();
188         String feeAmount = feeType.getFeeAmount() != null ? feeType.getFeeAmount().toString() : "";
189         if (feeAmount.isEmpty()) {
190             GlobalVariables.getMessageMap().putErrorForSectionId(OLEConstants.OLE_PATRON_BILL_FEE_TYPE_SECTION_ID, OLEConstants.FEE_AMOUNT_REQUIRED, "FeeAmount Field");
191             return getUIFModelAndView(form);
192         }
193         feeType.setBalFeeAmount(feeType.getFeeAmount());
194         View view = form.getPostedView();
195         patronBillPayment.setErrorMessage(null);
196 
197         if ((itemBarcode != null && !itemBarcode.isEmpty()) && (itemUUID == null || itemUUID.isEmpty())) {
198 
199             try {
200 
201                 org.kuali.ole.docstore.common.document.Item item = new ItemOleml();
202                 org.kuali.ole.docstore.common.search.SearchParams search_Params = new org.kuali.ole.docstore.common.search.SearchParams();
203                 SearchResponse searchResponse = null;
204                 search_Params.getSearchConditions().add(search_Params.buildSearchCondition("", search_Params.buildSearchField(org.kuali.ole.docstore.common.document.content.enums.DocType.ITEM.getCode(), item.ITEM_BARCODE, itemBarcode), ""));
205 
206 
207                 search_Params.getSearchResultFields().add(search_Params.buildSearchResultField(org.kuali.ole.docstore.common.document.content.enums.DocType.ITEM.getCode(), "id"));
208                 search_Params.getSearchResultFields().add(search_Params.buildSearchResultField(org.kuali.ole.docstore.common.document.content.enums.DocType.BIB.getCode(), "title"));
209                 search_Params.getSearchResultFields().add(search_Params.buildSearchResultField(org.kuali.ole.docstore.common.document.content.enums.DocType.BIB.getCode(), "author"));
210                 search_Params.getSearchResultFields().add(search_Params.buildSearchResultField(org.kuali.ole.docstore.common.document.content.enums.DocType.ITEM.getCode(), "itemType"));
211                 search_Params.getSearchResultFields().add(search_Params.buildSearchResultField(org.kuali.ole.docstore.common.document.content.enums.DocType.ITEM.getCode(), "itemEnumeration"));
212                 search_Params.getSearchResultFields().add(search_Params.buildSearchResultField(org.kuali.ole.docstore.common.document.content.enums.DocType.ITEM.getCode(), "itemChronology"));
213                 search_Params.getSearchResultFields().add(search_Params.buildSearchResultField(org.kuali.ole.docstore.common.document.content.enums.DocType.ITEM.getCode(), "copyNumber"));
214                 search_Params.getSearchResultFields().add(search_Params.buildSearchResultField(org.kuali.ole.docstore.common.document.content.enums.DocType.ITEM.getCode(), "callNumber"));
215 
216 
217                 searchResponse = getDocstoreClientLocator().getDocstoreClient().search(search_Params);
218 
219 
220                 for (SearchResult searchResult : searchResponse.getSearchResults()) {
221                     for (SearchResultField searchResultField : searchResult.getSearchResultFields()) {
222                         String fieldName = searchResultField.getFieldName();
223                         String fieldValue = searchResultField.getFieldValue() != null ? searchResultField.getFieldValue() : "";
224 
225                         if (fieldName.equalsIgnoreCase("id") && !fieldValue.isEmpty() && searchResultField.getDocType().equalsIgnoreCase("item")) {
226 
227 
228                             feeType.setItemUuid(fieldValue);
229 
230 
231                         } else if (fieldName.equalsIgnoreCase("title") && !fieldValue.isEmpty() && searchResultField.getDocType().equalsIgnoreCase("bibliographic")) {
232                             feeType.setItemTitle(fieldValue);
233                         } else if (fieldName.equalsIgnoreCase("author") && !fieldValue.isEmpty() && searchResultField.getDocType().equalsIgnoreCase("bibliographic")) {
234                             feeType.setItemAuthor(fieldValue);
235                         } else if (fieldName.equalsIgnoreCase("itemChronology") && !fieldValue.isEmpty() && searchResultField.getDocType().equalsIgnoreCase("item")) {
236                             feeType.setItemChronologyOwnLocation(fieldValue);
237                         } else if (fieldName.equalsIgnoreCase("itemEnumration") && !fieldValue.isEmpty() && searchResultField.getDocType().equalsIgnoreCase("item")) {
238                             feeType.setItemEnumeration(fieldValue);
239                         } else if (fieldName.equalsIgnoreCase("callnumber") && !fieldValue.isEmpty() && searchResultField.getDocType().equalsIgnoreCase("item")) {
240                             feeType.setItemCallNumber(fieldValue);
241                         } else if (fieldName.equalsIgnoreCase("copynumber") && !fieldValue.isEmpty() && searchResultField.getDocType().equalsIgnoreCase("item")) {
242                             feeType.setItemCopyNumber(fieldValue);
243                         } else if (fieldName.equalsIgnoreCase("itemType") && !fieldValue.isEmpty() && searchResultField.getDocType().equalsIgnoreCase("item")) {
244                             feeType.setItemTitle(fieldValue);
245                         }
246 
247                     }
248                 }
249 
250 
251             } catch (Exception ex) {
252                 LOG.error(ex, ex);
253                 patronBillPayment.setErrorMessage(OLEConstants.OlePatron.INV_ITEM_BAR);
254                 return getUIFModelAndView(form);
255             }
256         }
257 
258         patronBillPayment.setErrorMessage(null);
259         view.getViewHelperService().processCollectionAddLine(view, form, selectedCollectionPath);
260         return getUIFModelAndView(form);
261     }
262 
263     /**
264      * This method will add the agreement document to the existing list and also stores the attachment
265      * to the specified path.
266      *
267      * @param uifForm - MaintenanceDocumentForm
268      * @return ModelAndView
269      */
270     @RequestMapping(params = "methodToCall=deleteFromTotalAmount")
271     public ModelAndView deleteFromTotalAmount(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result,
272                                               HttpServletRequest request, HttpServletResponse response) {
273 
274         ModelAndView modelAndView = super.deleteLine(uifForm, result, request, response);
275         MaintenanceDocumentForm form = (MaintenanceDocumentForm) uifForm;
276         MaintenanceDocument document = (MaintenanceDocument) form.getDocument();
277         PatronBillPayment patronBillPayment = (PatronBillPayment) document.getNewMaintainableObject().getDataObject();
278         BigDecimal amount = new BigDecimal(0.0);
279         String billNumber = "";
280         Map feeTypeId = new HashMap();
281         if (patronBillPayment.getFeeType() != null) {
282             List<FeeType> feeTypes = patronBillPayment.getFeeType();
283             for (int i = 0; i < feeTypes.size(); i++) {
284                 amount = amount.add(feeTypes.get(i).getFeeAmount());
285                 billNumber = feeTypes.get(i).getBillNumber();
286                 feeTypeId.put(OLEConstants.OlePatron.BILL_PAYMENT_ID, billNumber);
287             }
288             patronBillPayment.setTotalAmount(amount);
289             //getBusinessObjectService().deleteMatching(FeeType.class, feeTypeId);
290 
291         }
292         return modelAndView;
293     }
294 
295 
296     /**
297      * This method will add the all fee amount and calculate total
298      *
299      * @param uifForm - MaintenanceDocumentForm
300      * @return ModelAndView
301      */
302     @RequestMapping(params = "methodToCall=calculateTotal")
303     public ModelAndView calculateTotal(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result,
304                                        HttpServletRequest request, HttpServletResponse response) throws Exception {
305 
306         MaintenanceDocumentForm form = (MaintenanceDocumentForm) uifForm;
307         MaintenanceDocument document = (MaintenanceDocument) form.getDocument();
308         PatronBillPayment patronBillPayment = (PatronBillPayment) document.getNewMaintainableObject().getDataObject();
309         BigDecimal amount = new BigDecimal(0.0);
310         BigDecimal balAmount = new BigDecimal(0.0);
311         if (patronBillPayment.getFeeType() != null) {
312             List<FeeType> feeTypes = patronBillPayment.getFeeType();
313             for (FeeType feeType : feeTypes) {
314                 amount = amount.add(feeType.getFeeAmount());
315                 balAmount = balAmount.add(feeType.getBalFeeAmount());
316             }
317             patronBillPayment.setTotalAmount(amount);
318             patronBillPayment.setUnPaidBalance(balAmount);
319         }
320         return getUIFModelAndView(form);
321     }
322 
323 
324     @RequestMapping(params = "methodToCall=" + "maintenanceDelete")
325     public ModelAndView maintenanceDelete(@ModelAttribute("KualiForm") MaintenanceDocumentForm form, BindingResult result,
326                                           HttpServletRequest request, HttpServletResponse response) throws Exception {
327         setupMaintenanceForDelete(form, request, OLEConstants.OlePatron.OLE_PATRON_BILL_DELETE);
328         return getUIFModelAndView(form);
329     }
330 
331 
332     @RequestMapping(params = "methodToCall=" + "deleteDocument")
333     public ModelAndView deleteDocument(@ModelAttribute("KualiForm") MaintenanceDocumentForm form, BindingResult result,
334                                        HttpServletRequest request, HttpServletResponse response) throws Exception {
335         MaintenanceDocument document = form.getDocument();
336         PatronBillPayment patronBillPayment = new PatronBillPayment();
337         //OleProxyPatronDocument proxyPatronDocument = new OleProxyPatronDocument();
338 
339         if (document.getDocumentDataObject() != null) {
340             patronBillPayment = (PatronBillPayment) document.getDocumentDataObject();
341             if (patronBillPayment != null && patronBillPayment.getPatronId() != null) {
342                 KRADServiceLocator.getBusinessObjectService().delete(patronBillPayment);
343                 GlobalVariables.getMessageMap().putInfoWithoutFullErrorPath(KRADConstants.GLOBAL_ERRORS,
344                         OLEConstants.OleLicenseRequest.MSG_DELETE_DOC);
345             } else {
346                 GlobalVariables.getMessageMap().putErrorWithoutFullErrorPath(KRADConstants.GLOBAL_MESSAGES, OLEConstants.OleLicenseRequest.ERROR_CHECKLIST_NOT_FOUND);
347                 return getUIFModelAndView(form);
348             }
349         }
350         return back(form, result, request, response);
351     }
352 
353 
354     /**
355      * This method populates confirmation to delete the document.
356      *
357      * @param form
358      * @param request
359      * @param maintenanceAction
360      */
361     protected void setupMaintenanceForDelete(MaintenanceDocumentForm form, HttpServletRequest request, String maintenanceAction) {
362         MaintenanceDocument document = form.getDocument();
363 
364         if (document == null) {
365             document = getMaintenanceDocumentService()
366                     .setupNewMaintenanceDocument(form.getDataObjectClassName(), form.getDocTypeName(),
367                             maintenanceAction);
368 
369             form.setDocument(document);
370             form.setDocTypeName(document.getDocumentHeader().getWorkflowDocument().getDocumentTypeName());
371         }
372 
373         form.setMaintenanceAction(maintenanceAction);
374         OlePatronBillMaintenanceDocumentServiceImpl olePatronBillMaintenanceDocumentService = (OlePatronBillMaintenanceDocumentServiceImpl) getMaintenanceDocumentService();
375         olePatronBillMaintenanceDocumentService.setupMaintenanceObjectForDelete(document, maintenanceAction, request.getParameterMap());
376         MaintenanceUtils.checkForLockingDocument(document, false);
377     }
378 
379     /**
380      * Override route to retrieve the calculated total amount
381      * <p/>
382      * (DocumentFormBase, HttpServletRequest, HttpServletResponse)
383      */
384     @Override
385     @RequestMapping(params = "methodToCall=route")
386     public ModelAndView route(@ModelAttribute("KualiForm") DocumentFormBase form, BindingResult result,
387                               HttpServletRequest request, HttpServletResponse response) {
388         ModelAndView modelAndView;
389         MaintenanceDocumentForm maintenanceForm = (MaintenanceDocumentForm) form;
390 
391         try {
392             calculateTotal(form, result, request, response);
393         } catch (Exception e) {
394             LOG.error(e, e);
395         }
396         MaintenanceDocument document = (MaintenanceDocument) form.getDocument();
397         PatronBillPayment patronBillPayment = (PatronBillPayment) document.getNewMaintainableObject().getDataObject();
398         // patronBillPayment.setUnPaidBalance(patronBillPayment.getTotalAmount());
399         if (patronBillPayment.getFeeType() != null) {
400             List<FeeType> feeTypes = patronBillPayment.getFeeType();
401             if (feeTypes.size() == 0) {
402                 GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS, OLEConstants.ADD_FEE_TYPE);
403                 return getUIFModelAndView(maintenanceForm);
404             }
405         }
406         if (document.getNewMaintainableObject().getDataObject() instanceof PersistableAttachment) {
407             PersistableAttachment bo = (PersistableAttachment) getBusinessObjectService()
408                     .retrieve((PersistableBusinessObject) document.getNewMaintainableObject().getDataObject());
409             request.setAttribute(OLEConstants.OlePatron.FILE_NAME, bo.getFileName());
410         }
411         //modelAndView = getUIFModelAndView(form);
412 
413         LOG.info("****************************** Patron Id" + patronBillPayment.getBillNumber());
414         if (patronBillPayment.getBillNumber() != null) {
415             Map<String, String> map = new HashMap<String, String>();
416             map.put("billNumber", patronBillPayment.getBillNumber());
417             List<PatronBillPayment> patronBillPaymentdblist = (List<PatronBillPayment>) KRADServiceLocator.getBusinessObjectService().findMatching(PatronBillPayment.class, map);
418             if (patronBillPaymentdblist.size() > 0) {
419                 PatronBillPayment patronBillPaymentdb = patronBillPaymentdblist.get(0);
420                 List<FeeType> feeTypesdb = patronBillPaymentdb.getFeeType();
421                 for (FeeType feeTypedb : feeTypesdb) {
422                     boolean isFound = false;
423                     List<FeeType> feeTypesuser = patronBillPayment.getFeeType();
424                     for (FeeType userfeeType : feeTypesuser) {
425                         if (feeTypedb.getId().equals(userfeeType.getId())) {
426                             isFound = true;
427                         }
428                     }
429                     if (!isFound) {
430                         Map<String, String> deleteItemHistoryMap = new HashMap<String, String>();
431                         deleteItemHistoryMap.put("lineItemId", feeTypedb.getId());
432                         List<OleItemLevelBillPayment> oleItemLevelBillPaymentsDB = (List<OleItemLevelBillPayment>) KRADServiceLocator.getBusinessObjectService().findMatching(OleItemLevelBillPayment.class, deleteItemHistoryMap);
433                         if (oleItemLevelBillPaymentsDB.size() > 0) {
434                             KRADServiceLocator.getBusinessObjectService().deleteMatching(OleItemLevelBillPayment.class, deleteItemHistoryMap);
435                         }
436                         Map<String, String> deleteFeeTypeMap = new HashMap<String, String>();
437                         deleteFeeTypeMap.put("id", feeTypedb.getId());
438                         KRADServiceLocator.getBusinessObjectService().deleteMatching(FeeType.class, deleteFeeTypeMap);
439                     }
440                 }
441             }
442         }
443         patronBillPayment.setErrorMessage(null);
444         modelAndView = super.route(maintenanceForm, result, request, response);
445         return modelAndView;
446     }
447 }