Search in sources :

Example 1 with CheckReconciliationReport

use of com.rsmart.kuali.kfs.cr.businessobject.CheckReconciliationReport in project cu-kfs by CU-CommunityApps.

the class CheckReconciliationReportAction method performReport.

/**
 * Generates the CR Report and returns pdf.
 *
 * @param mapping
 * @param form
 * @param request
 * @param response
 * @return
 * @throws Exception
 */
public ActionForward performReport(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    CheckReconciliationReportForm crForm = (CheckReconciliationReportForm) form;
    CheckReconciliationReportService serv = SpringContext.getBean(CheckReconciliationReportService.class);
    List<CheckReconciliationReport> reportSet = serv.buildReports(crForm.getStartDate(), crForm.getEndDate());
    if (LOG.isDebugEnabled()) {
        int reportSize = reportSet != null ? reportSet.size() : 0;
        LOG.debug("performReport, the size of the report: " + reportSize);
    }
    if (reportSet != null && reportSet.isEmpty()) {
        GlobalVariables.getMessageMap().putError("startDate", KFSKeyConstants.ERROR_CUSTOM, "No Check Records Found");
    } else if (reportSet != null) {
        // Sort results by check number before building reports
        Collections.sort(reportSet);
        if ("excel".equals(crForm.getFormat())) {
            response.setContentType("application/unknown");
            response.setHeader("Pragma", "No-cache");
            response.setHeader("Cache-Control", "no-cache");
            response.setHeader("Content-Disposition", "attachment; filename=checkreconreport.csv");
            java.io.PrintWriter out = response.getWriter();
            boolean newAccount = false;
            boolean newMonth = true;
            double acctAmtTotal = 0.00;
            double monAmtTotal = 0.00;
            int monIssuedTotal = 0;
            int acctIssuedTotal = 0;
            CheckReconciliationReport temp = null;
            Iterator<CheckReconciliationReport> iter = reportSet.iterator();
            temp = iter.next();
            out.println("Check No,Payee Id,Payee Type,Payee Name,Status,Account No,Date,Amount");
            out.println(temp.getCheckNumber() + COMMA + temp.getPayeeId() + COMMA + temp.getPayeeType() + COMMA + "\"" + temp.getPayeeName() + "\"" + COMMA + temp.getStatusDesc() + COMMA + temp.getBankAccountNumber() + COMMA + temp.getCheckDate() + COMMA + temp.getAmount());
            String tempAcct = temp.getBankAccountNumber();
            String tempMon = temp.getCheckMonth();
            monAmtTotal += temp.getSubTotal();
            acctAmtTotal += temp.getSubTotal();
            monIssuedTotal += temp.getIssued();
            acctIssuedTotal += temp.getIssued();
            while (iter.hasNext()) {
                temp = iter.next();
                newMonth = !tempMon.equals(temp.getCheckMonth());
                newAccount = !tempAcct.equals(temp.getBankAccountNumber());
                if ((newMonth || newAccount)) {
                    out.println("Sub-total " + tempMon + COMMA + "Outstanding" + COMMA + monIssuedTotal + COMMA + COMMA + CheckReconciliationReport.DF.format(monAmtTotal));
                    monAmtTotal = 0.00;
                    monIssuedTotal = 0;
                }
                if (newAccount) {
                    out.println("Bank " + tempAcct + COMMA + "Total Outstanding" + COMMA + acctIssuedTotal + COMMA + COMMA + CheckReconciliationReport.DF.format(acctAmtTotal));
                    out.println(",,,,");
                    monAmtTotal = 0.00;
                    acctAmtTotal = 0.00;
                    monIssuedTotal = 0;
                    acctIssuedTotal = 0;
                }
                if (newMonth) {
                    out.println("Check No,Payee Id,Payee Name,Payee Type,Status,Account No,Date,Amount");
                }
                out.println(temp.getCheckNumber() + COMMA + temp.getPayeeId() + COMMA + "\"" + temp.getPayeeName() + "\"" + COMMA + temp.getPayeeType() + COMMA + temp.getStatusDesc() + COMMA + temp.getBankAccountNumber() + COMMA + temp.getCheckDate() + COMMA + temp.getAmount());
                monAmtTotal += temp.getSubTotal();
                acctAmtTotal += temp.getSubTotal();
                monIssuedTotal += temp.getIssued();
                acctIssuedTotal += temp.getIssued();
                tempAcct = temp.getBankAccountNumber();
                tempMon = temp.getCheckMonth();
            }
            out.println("Sub-total " + tempMon + COMMA + "Outstanding" + COMMA + monIssuedTotal + COMMA + COMMA + CheckReconciliationReport.DF.format(monAmtTotal));
            out.println("Bank " + tempAcct + COMMA + "Total Outstanding" + COMMA + acctIssuedTotal + COMMA + COMMA + CheckReconciliationReport.DF.format(acctAmtTotal));
            out.close();
            return null;
        } else {
            // build pdf and stream back
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            ResourceBundle resourceBundle = ResourceBundle.getBundle(CRConstants.REPORT_MESSAGES_CLASSPATH, Locale.getDefault());
            Map<String, Object> reportData = new HashMap<String, Object>();
            reportData.put(JRParameter.REPORT_RESOURCE_BUNDLE, resourceBundle);
            reportData.put("REPORT_END_DATE", new SimpleDateFormat("MM/dd/yyyy").format(crForm.getEndDate()));
            SpringContext.getBean(ReportGenerationService.class).generateReportToOutputStream(reportData, reportSet, CRConstants.REPORT_TEMPLATE_CLASSPATH + CRConstants.REPORT_FILE_NAME, baos);
            WebUtils.saveMimeOutputStreamAsFile(response, ReportGeneration.PDF_MIME_TYPE, baos, CRConstants.REPORT_FILE_NAME + ReportGeneration.PDF_FILE_EXTENSION);
            return null;
        }
    } else {
        GlobalVariables.getMessageMap().putError("startDate", KFSKeyConstants.ERROR_CUSTOM, "No Check Records Found");
    }
    return mapping.findForward(KFSConstants.MAPPING_BASIC);
}
Also used : ByteArrayOutputStream(java.io.ByteArrayOutputStream) CheckReconciliationReportService(com.rsmart.kuali.kfs.cr.document.service.CheckReconciliationReportService) Iterator(java.util.Iterator) ResourceBundle(java.util.ResourceBundle) CheckReconciliationReport(com.rsmart.kuali.kfs.cr.businessobject.CheckReconciliationReport) HashMap(java.util.HashMap) Map(java.util.Map) SimpleDateFormat(java.text.SimpleDateFormat)

Example 2 with CheckReconciliationReport

use of com.rsmart.kuali.kfs.cr.businessobject.CheckReconciliationReport in project cu-kfs by CU-CommunityApps.

the class CheckReconciliationReportServiceImpl method buildReports.

/**
 * Build Reports
 *
 * @see com.rsmart.kuali.kfs.cr.document.service.CheckReconciliationReportService#buildReports(com.rsmart.kuali.kfs.cr.document.web.struts.CheckReconciliationForm)
 */
public List<CheckReconciliationReport> buildReports(Date startDate, Date endDate) {
    List<CheckReconciliationReport> data = new ArrayList<CheckReconciliationReport>();
    List list = checkReconciliationDao.getAllCheckReconciliationForSearchCriteria(startDate, endDate);
    for (int i = 0; i < list.size(); i++) {
        data.add(new CheckReconciliationReport((CheckReconciliation) list.get(i)));
    }
    return data;
}
Also used : ArrayList(java.util.ArrayList) CheckReconciliation(com.rsmart.kuali.kfs.cr.businessobject.CheckReconciliation) List(java.util.List) ArrayList(java.util.ArrayList) CheckReconciliationReport(com.rsmart.kuali.kfs.cr.businessobject.CheckReconciliationReport)

Example 3 with CheckReconciliationReport

use of com.rsmart.kuali.kfs.cr.businessobject.CheckReconciliationReport in project cu-kfs by CU-CommunityApps.

the class CRBeanFactory method createBeanCollection.

public static Vector createBeanCollection() {
    java.util.Vector coll = new java.util.Vector();
    CheckReconciliationReport yourBean = new CheckReconciliationReport();
    yourBean.setStatus(CRConstants.CANCELLED);
    yourBean.setBankAccountNumber("1010000");
    yourBean.setCheckDate("11/11/2008");
    yourBean.setSubTotal(12.07);
    yourBean.setCheckNumber("10001");
    yourBean.setCheckMonth("2008/11");
    coll.add(yourBean);
    CheckReconciliationReport myBean = new CheckReconciliationReport();
    myBean.setStatus(CRConstants.CLEARED);
    myBean.setBankAccountNumber("1010000");
    myBean.setCheckDate("12/12/2008");
    myBean.setSubTotal(100.00);
    myBean.setCheckNumber("10000");
    myBean.setCheckMonth("2008/12");
    coll.add(myBean);
    CheckReconciliationReport hisBean = new CheckReconciliationReport();
    hisBean.setStatus(CRConstants.ISSUED);
    hisBean.setBankAccountNumber("1010000");
    hisBean.setCheckDate("01/01/2009");
    hisBean.setSubTotal(33.00);
    hisBean.setCheckNumber("10002");
    hisBean.setCheckMonth("2009/01");
    coll.add(hisBean);
    CheckReconciliationReport herBean = new CheckReconciliationReport();
    herBean.setStatus(CRConstants.CLEARED);
    herBean.setBankAccountNumber("1010000");
    herBean.setCheckDate("01/02/2009");
    herBean.setSubTotal(1000.05);
    herBean.setCheckNumber("10003");
    herBean.setCheckMonth("2009/01");
    coll.add(herBean);
    CheckReconciliationReport aBean = new CheckReconciliationReport();
    aBean.setStatus(CRConstants.CLEARED);
    aBean.setBankAccountNumber("1111111");
    aBean.setCheckDate("01/02/2009");
    aBean.setSubTotal(99.99);
    aBean.setCheckNumber("10004");
    aBean.setCheckMonth("2009/01");
    coll.add(aBean);
    return coll;
}
Also used : Vector(java.util.Vector) Vector(java.util.Vector) CheckReconciliationReport(com.rsmart.kuali.kfs.cr.businessobject.CheckReconciliationReport)

Aggregations

CheckReconciliationReport (com.rsmart.kuali.kfs.cr.businessobject.CheckReconciliationReport)3 CheckReconciliation (com.rsmart.kuali.kfs.cr.businessobject.CheckReconciliation)1 CheckReconciliationReportService (com.rsmart.kuali.kfs.cr.document.service.CheckReconciliationReportService)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 SimpleDateFormat (java.text.SimpleDateFormat)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Map (java.util.Map)1 ResourceBundle (java.util.ResourceBundle)1 Vector (java.util.Vector)1