public List<BillingDetails> getBillingDetails(SearchCriteria criteria) { logger.info("In BillingDetailsDAO-getBillingDetails()..."); List<BillingDetails> billingDetailsList = new ArrayList<BillingDetails>(); List<AccountNames> accountNamesList = new ArrayList<AccountNames>(); try { String asOfDate = criteria.getAsOfDate(); asOfDate = DateUtility.convertAsMySqlDateTime(asOfDate); asOfDate = asOfDate.replace("00:00:00", "23:59:59"); logger.info("asOfDate in BillingDetailsDAO-getBillingDetails() : " + asOfDate); String searchString = criteria.getSearchString(); logger.info("searchString in BillingDetailsDAO-getBillingDetails() : " + searchString); String accountName = criteria.getAccountName(); /*if(accountName.contains("'")) accountName = accountName.replace("'", "\'");*/ logger.info("accountName in BillingDetailsDAO-getBillingDetails() : " + accountName); if (searchString.equalsIgnoreCase("allBillable")) { String accountNamesQry = "select distinct name from Account where accountingType='Billable' and isActive='1'"; accountNamesList = jdbcTemplate.query( accountNamesQry, new Object[] {}, new RowMapper<AccountNames>() { public AccountNames mapRow(ResultSet rs, int rowNum) throws SQLException { AccountNames accountName = new AccountNames(); accountName.setAccountName( (rs.getString("name") != null) ? rs.getString("name") : ""); return accountName; } }); logger.info("accountNamesList.size() : " + accountNamesList.size()); if (accountNamesList.size() > 0) { for (int i = 0; i < accountNamesList.size(); i++) { BillingDetails billingDetails = new BillingDetails(); billingDetails = getBillingDetailsByAccount(accountNamesList.get(i).getAccountName(), asOfDate); if (billingDetails.getBillingInfoDetailsList().size() > 0) billingDetailsList.add(billingDetails); } } } else if (searchString.equalsIgnoreCase("byAccount")) { BillingDetails billingDetails = new BillingDetails(); billingDetails = getBillingDetailsByAccount(accountName, asOfDate); if (billingDetails.getBillingInfoDetailsList().size() > 0) billingDetailsList.add(billingDetails); } logger.info("billingDetailsList.size() : " + billingDetailsList.size()); } catch (Exception e) { logger.error(e); e.printStackTrace(); } return billingDetailsList; }
@RequestMapping(value = "/displayReceipts", method = RequestMethod.POST) public ModelAndView getReceiptsDetails(SearchCriteria criteria, ModelAndView model) { logger.info("In AllInvoicesController-getAllInvoicesList()..."); try { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); SimpleDateFormat sdf1 = new SimpleDateFormat("MM/dd/yyyy"); Receipts receipts = receiptsService.getReceiptsDetails(criteria); Date fromDate = sdf.parse(receipts.getFromDate()); model.addObject("fromDate", sdf1.format(fromDate)); Date toDate = sdf.parse(receipts.getToDate()); model.addObject("toDate", sdf1.format(toDate)); model.addObject("location", criteria.getLocation()); logger.info("receipts.getReceiptDetails().size() : " + receipts.getReceiptDetails().size()); model.addObject("receiptDetails", receipts.getReceiptDetails()); model.addObject("receiptTotals", receipts.getReceiptsTotals()); model.addObject("paymentTypeTotal", receipts.getPaymentTypeTotal()); model.setViewName("receipts"); } catch (Exception e) { logger.error(e); e.printStackTrace(); } return model; }