Fee Receipt Report

download Fee Receipt Report

If you can't read please download the document

description

Fee Receipt Report

Transcript of Fee Receipt Report

/* * To change this template, choose Tools | Templates * and open the template in the editor. */package com.jilit.irp.bso.report.sfm;import com.adobe.agl.text.SimpleDateFormat;import com.jilit.irp.bso.IService;import com.jilit.irp.Report.ReportManager;import com.jilit.irp.bso.biz.BusinessService;import com.jilit.irp.bso.biz.PrinterRunnable;import com.jilit.irp.bso.biz.UIService;import com.jilit.irp.data.GridData;import com.jilit.irp.persistence.dao.DAOFactory;import com.jilit.irp.persistence.dto.CurrencyMaster;import com.jilit.irp.persistence.dto.InstituteMaster;import com.jilit.irp.persistence.dto.RegistrationMaster;import com.jilit.irp.persistence.dto.StudentMaster;import com.jilit.irp.util.JIRPDateUtil;import com.jilit.irp.util.JIRPSession;import flex.messaging.io.amf.ASObject;import java.math.BigDecimal;import java.text.DecimalFormat;import java.util.ArrayList;import java.util.Date;import java.util.HashMap;import java.util.LinkedHashSet;import javax.servlet.ServletContext;import javax.servlet.ServletOutputStream;import org.springframework.web.context.ServletContextAware;import java.util.List;import java.util.Map;import java.util.Set;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;/** * * @author ibrahimb.shaik */public class FeeReceiptReportService extends ReportManager implements IService, ServletContextAware { DAOFactory daoFactory; private ServletContext context; BigDecimal amt = null; BigDecimal feecurrencyamount = null; String ddno = ""; String dddate = ""; String drawnon = ""; public void setDaoFactory(DAOFactory daoFactory) { this.daoFactory = daoFactory; } public void setServletContext(ServletContext context) { this.context = context; } public List getAllRegistrationCode() { String instituteid = JIRPSession.getLoginInfo().getUserProfile().getSelectedinstitutemaster().getInstituteid(); List retList = new ArrayList(); List list = (List) daoFactory.getUtilDAO().findSimpleData("findAllRegistrationCode_SFM", new Object[]{instituteid}); for (int i = 0; i < list.size(); i++) { retList.add(new GridData(new RegistrationMaster(list.get(i)), false, list.get(i).getIdStr())); } return retList; } public ASObject checkIfRegistrationCodeExist(String instituteid, String regCode) { ASObject retObj = null; List list = (List) daoFactory.getUtilDAO().findSimpleData("checkRegistrationCode_SFM", new Object[]{instituteid, regCode.toUpperCase()}); if (list.size() == 1) { retObj = new ASObject(); retObj.put("registrationid", list.get(0).getId().getRegistrationid()); retObj.put("registrationcode", list.get(0).getRegistrationcode()); retObj.put("registrationdesc", list.get(0).getRegistrationdesc()); } return retObj; } public List getAllEnrollmentNo(String regid) { String instituteid = JIRPSession.getLoginInfo().getUserProfile().getSelectedinstitutemaster().getInstituteid(); List list = (List) daoFactory.getFeeTransactionDAO().getAllEnrollmentNoForRegID(instituteid, regid); List retList = new ArrayList(); try { for (int i = 0; i < list.size(); i++) { Object obj[] = (Object[]) list.get(i); ASObject addldata = new ASObject(); addldata.put("studentid", obj[0]); addldata.put("enrollmentno", obj[1]); addldata.put("name", obj[2]); addldata.put("programcode", obj[3]); addldata.put("stynumber", obj[4]); addldata.put("branchcode", obj[5]); addldata.put("academicyear", obj[6]); retList.add(new GridData(new StudentMaster(obj[0].toString(), obj[1].toString(), obj[2].toString()), false, obj[0].toString(), addldata)); } } catch (Exception e) { e.printStackTrace(); } return retList; } public ASObject checkIfEnrollmentNoExist(String enrollmentno, String regid) { String instituteid = JIRPSession.getLoginInfo().getUserProfile().getSelectedinstitutemaster().getInstituteid(); List list = (List) daoFactory.getFeeTransactionDAO().checkIfEnrollmentNoExist(instituteid, regid, enrollmentno); ASObject retObj = null; try { if (list.size() == 1) { Object obj[] = (Object[]) list.get(0); retObj = new ASObject(); retObj.put("studentid", obj[0]); retObj.put("enrollmentno", obj[1]); retObj.put("name", obj[2]); retObj.put("programcode", obj[3]); retObj.put("stynumber", obj[4]); retObj.put("branchcode", obj[5]); } } catch (Exception e) { e.printStackTrace(); } return retObj; } @Override @SuppressWarnings("empty-statement") public void getReport(HttpServletRequest request, HttpServletResponse response) { try { amt = BigDecimal.valueOf(Double.parseDouble("0")).setScale(2); feecurrencyamount = BigDecimal.valueOf(Double.parseDouble("0")); BusinessService bs = new BusinessService(context, daoFactory); String username = request.getParameter("username"); String level = request.getParameter("level"); String instituteid = request.getParameter("instituteid"); String registrationid = request.getParameter("registrationid"); String registrationcode = request.getParameter("registrationcode"); String collectiondate = request.getParameter("collectiondate"); StudentMaster sm = (StudentMaster) daoFactory.getStudentMasterDAO().findByPrimaryKey(request.getParameter("studentid")); String enrollmentno =request.getParameter("enrollmentno").equals("") ? (sm==null?"":sm.getEnrollmentno()):request.getParameter("enrollmentno"); String studentid = request.getParameter("studentid").equals("")?"":request.getParameter("studentid"); String exportto = request.getParameter("exportto"); String reportby = request.getParameter("reportby"); String prid = request.getParameter("prid"); String prid1 = request.getParameter("prid1"); String receiptmode = request.getParameter("receiptmode"); String prnofrom = request.getParameter("prnofrom"); String prnoto = request.getParameter("prnoto"); String path = null; HashMap parameters = null; List data = null; parameters = new HashMap(); ASObject aSObject = null; UIService uiserviceobject = new UIService(); if (prid != null && !"".equals(prid)) { aSObject = getFeeReceiptReportData2(instituteid, registrationid, studentid, enrollmentno, reportby, prid, receiptmode); } else { aSObject = getFeeReceiptReportData(instituteid, registrationid, studentid, enrollmentno, prid1, prnofrom, prnoto, reportby); } data = (List) aSObject.get("list"); String amountinwords = uiserviceobject.amountToWord(Double.parseDouble(amt.toString()), null); InstituteMaster ims = (InstituteMaster) daoFactory.getInstituteMasterDAO().findByPrimaryKey(instituteid); parameters = new HashMap(); if (ims != null || data != null) { parameters.put("institutename", ims.getInstitutename()); parameters.put("address1", (ims.getAddress1() == null) ? "" : ims.getAddress1()); parameters.put("address2", (ims.getAddress2() == null) ? "" : ims.getAddress2()); parameters.put("address3", (ims.getAddress3() == null) ? "" : ims.getAddress3()); parameters.put("state", (ims.getState() == null) ? "" : ims.getState()); parameters.put("city", ims.getCity() == null ? "" : ims.getCity()); parameters.put("pin", ims.getPin() == null ? "" : ims.getPin()); parameters.put("username", bs.getPropertyValue("reportby", "campuslynx.properties") + ": " + username); parameters.put("image", context.getRealPath(ims.getLogofilename())); parameters.put("imageback", context.getRealPath(ims.getWatermarkfilename())); parameters.put("registrationcode", registrationcode == null ? "" : registrationcode); parameters.put("reporttitle", reportby.equals("P") ? "Fee Payment Receipt" : "Fee Collection Receipt"); parameters.put("amountinwords", amountinwords == null ? "" : amountinwords); parameters.put("amt", amt); parameters.put("feecurrencyamount", feecurrencyamount); parameters.put("ddno", ddno); parameters.put("dddate", dddate); parameters.put("drawnon", drawnon); } else { parameters.put("institutename", ""); parameters.put("sessioncode", ""); parameters.put("academicyear", ""); parameters.put("address1", ""); parameters.put("address2", ""); parameters.put("address3", ""); parameters.put("state", ""); parameters.put("city", ""); parameters.put("pin", ""); parameters.put("image", ""); }// if (level.equals("one")) {// path = request.getRealPath("/jrxml/FeeReceiptReport.jrxml");// } if (exportto.contains("P")) { // renderReport(PDF, path, data, response, parameters, "Fee Receipt Report");// response.setContentType("application/pdf"); response.setHeader("Content-Disposition", "inline;filename=" + username); String realPath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath(); request = null; getFeeReceiptReportData(response.getOutputStream(), realPath, instituteid, registrationid, enrollmentno, studentid, prnofrom, prnoto, receiptmode, prid, prid1, reportby, collectiondate); } else if (exportto.contains("H")) { renderReport(HTML, path, data, response, parameters, "Fee Receipt Report"); } else if (exportto.contains("W")) { renderReport(RTF, path, data, response, parameters, "Fee Receipt Report"); } else if (exportto.contains("E")) { renderReport(EXCEL, path, data, response, parameters, "Fee Receipt Report"); } } catch (Exception e) { e.printStackTrace(); } finally {// JIRPSession.removeAttributeFromSession(request.getSession(), "data"); } } public ASObject getFeeReceiptReportData(String instituteid, String registrationid, String studentid, String enrollmentno, String prid, String prnofrom, String prnoto, String reportby) { List retList = new ArrayList(); String prmode = ""; try { ddno = ""; dddate = ""; List l = (List) daoFactory.getFeeTransactionDAO().getFeeReceiptReportData(instituteid, registrationid, studentid, enrollmentno, prid, prnofrom, prnoto, reportby); for (int i = 0; i < l.size(); i++) { Object[] obj = (Object[]) l.get(i); ASObject object = new ASObject(); object.put("name", obj[0] == null ? "" : obj[0]); object.put("enrollmentno", obj[1] == null ? "" : obj[1]); object.put("semester", obj[2] == null ? (byte) 0 : Byte.valueOf(obj[2].toString())); object.put("prno", obj[3] == null ? "" : obj[3]); object.put("prdate", obj[4] == null ? "" : obj[4]); object.put("fathersname", obj[5] == null ? " " : obj[5]); // object.put("amount", obj[6] == null ? "" : obj[6]);// amt = amt.add(BigDecimal.valueOf(Double.parseDouble((obj[6]).toString())));// feecurrencyamount = feecurrencyamount.add(BigDecimal.valueOf(Double.parseDouble((obj[6]).toString()))); if(obj[12].equals("C")){// object.put("bankname", "Cash"); object.put("drawnon", "Cash"); object.put("particularsno", "Cash"); object.put("particularsdate", "Cash"); }else { object.put("drawnon", obj[14] == null ? "" : obj[14]); object.put("particularsno", obj[10] == null ? "" : obj[10]); object.put("particularsdate", obj[11] == null ? "" : obj[11]); } object.put("bankname", obj[6] == null ? "" : obj[6]); // object.put("feedetails", obj[8] == null ? "" : obj[8]); object.put("program", obj[7] == null ? "" : obj[7]); object.put("currencycode", obj[8] == null ? "" : obj[8]); prmode = obj[9] == null ? "NA" : obj[9].toString(); if (obj[12] != null) { if (obj[12].equals("C")) { object.put("receiptmode", "Cash"); } else if (obj[12].equals("B")) { object.put("receiptmode", "Cheque/DD"); } else { object.put("receiptmode", "JV"); } } else { object.put("receiptmode", ""); }// object.put("particularsno", obj[10] == null ? "" : obj[10]);// object.put("particularsdate", obj[11] == null ? "" : obj[11]); object.put("accountingcurrency", obj[13] == null ? "" : obj[13]); if (prmode.equals("C")) { object.put("prmode", "Cheque No:"); } else if (prmode.equals("D")) { object.put("prmode", "DD No:"); } else if (prmode.equals("E")) { object.put("prmode", "Electronic TrNo:"); } else if (prmode.equals("P")) { object.put("prmode", "Payment Gateway TrNo:"); }// object.put("drawnon", obj[14] == null ? "" : obj[14]); object.put("categorycode", obj[15] == null ? "" : obj[15]); object.put("employeename", obj[16] == null ? "" : obj[16]); object.put("studentid", obj[17] == null ? "" : obj[17]); object.put("prid", obj[18] == null ? "" : obj[18]); object.put("shortname", obj[19] == null ? "" : obj[19]); object.put("employeename", obj[20] == null ? "" : obj[20]); if (i == 0) { ddno = ddno.concat(obj[10] == null ? "" : obj[10].toString()); dddate = dddate.concat(obj[11] == null ? "" : JIRPDateUtil.convertDateFormat((Date) obj[11])); } else { ddno = ddno.concat(",".concat(obj[10] == null ? "" : obj[10].toString())); dddate = dddate.concat(",".concat(obj[11] == null ? "" : JIRPDateUtil.convertDateFormat((Date) obj[11]))); } if (reportby.equals("P")) { object.put("refundby", "Refunded "); } else { object.put("refundby", "with Thanks "); } retList.add(object); } } catch (Exception e) { e.printStackTrace(); } ASObject aSObject = new ASObject(); aSObject.put("list", retList); return aSObject; } public ASObject getFeeReceiptReportData2(String instituteid, String registrationid, String studentid, String enrollmentno, String reporttype, String prid, String receiptmode) { List retList = new ArrayList(); String prmode = ""; try { ddno = ""; dddate = ""; drawnon = ""; List l = (List) daoFactory.getFeeTransactionDAO().getFeeReceiptReportData2(instituteid, registrationid, studentid, reporttype, prid); List list = (List) daoFactory.getCurrencyMasterDAO().getAllCurrencyCode(); String accountingCurrency = ""; for (int i = 0; i < list.size(); i++) { CurrencyMaster cm = list.get(i); if ("Y".equals(cm.getAccountingcurrency())) { accountingCurrency = cm.getCurrencycode(); break; } } for (int i = 0; i < l.size(); i++) { Object[] obj = (Object[]) l.get(i); ASObject object = new ASObject(); object.put("accountingcurrency", accountingCurrency); object.put("name", obj[0] == null ? "" : obj[0]); object.put("enrollmentno", obj[1] == null ? "" : obj[1]); object.put("semester", obj[2] == null ? (byte) 0 : obj[2]); object.put("prno", obj[3] == null ? "" : obj[3]); object.put("prdate", obj[4] == null ? "" : obj[4]); object.put("fathersname", obj[5] == null ? " " : obj[5]); if ("A".equals(obj[12].toString())) { object.put("amount", obj[11] == null ? "" : obj[11]); } else { object.put("amount", obj[6] == null ? "" : obj[6]); } feecurrencyamount = feecurrencyamount.add(BigDecimal.valueOf(Double.parseDouble((obj[6]).toString()))); object.put("feedetails", obj[7] == null ? "" : obj[7]); object.put("program", obj[8] == null ? "" : obj[8]); object.put("currencycode", obj[9] == null ? "" : obj[9]); String slno = obj[10] == null ? "" : obj[10].toString(); object.put("prmode", prmode); if ("B".equals(receiptmode)) { object.put("receiptmode", "Bank"); } else if ("C".equals(receiptmode)) { object.put("receiptmode", "Cash"); } else { object.put("receiptmode", "JV"); } List particularsList = (List) daoFactory.getFeeTransactionDAO().getFeeParticularsReportData(instituteid, prid, slno); amt = amt.add(BigDecimal.valueOf(Double.parseDouble((obj[11]).toString()))); if (particularsList != null || particularsList.size() > 0) { for (int j = 0; j < particularsList.size(); j++) { Object[] objArr = particularsList.get(j); prmode = objArr[0] == null ? "NA" : objArr[0].toString(); if (prmode.equals("C")) { object.put("prmode", "Cheque No:"); } else if (prmode.equals("D")) { object.put("prmode", "DD No:"); } else if (prmode.equals("E")) { object.put("prmode", "Electronic TrNo:"); } else if (prmode.equals("P")) { object.put("prmode", "Payment Gateway TrNo:"); } if (i == 0 && j == 0) { ddno = ddno.concat(objArr[1] == null ? "" : objArr[1].toString()); dddate = dddate.concat(objArr[2] == null ? "" : JIRPDateUtil.convertDateFormat((Date) objArr[2])); drawnon = drawnon.concat(objArr[3] == null ? "" : objArr[3].toString()); } else { ddno = ddno.concat(",".concat(objArr[1] == null ? "" : objArr[1].toString())); dddate = dddate.concat(",".concat(objArr[2] == null ? "" : JIRPDateUtil.convertDateFormat((Date) objArr[2]))); drawnon = drawnon.concat(",".concat(objArr[3] == null ? "" : objArr[3].toString())); } } } if (reporttype.equals("P")) { object.put("refundby", "Refunded "); } else { object.put("refundby", "with Thanks "); } retList.add(object); } } catch (Exception e) { e.printStackTrace(); } ASObject aSObject = new ASObject(); aSObject.put("list", retList); return aSObject; } /** * Desc::Method for DMT Printer. * @param repObj */ public void printFeeReciept(ASObject repObj) { SimpleDateFormat df = new SimpleDateFormat("dd-MM-yyyy"); DecimalFormat df1 = new DecimalFormat(); df1.setMaximumFractionDigits(2); int total = 0; BigDecimal totalf = new BigDecimal(0.00); try { amt = BigDecimal.valueOf(Double.parseDouble("0")).setScale(2); feecurrencyamount = BigDecimal.valueOf(Double.parseDouble("0")); String username = repObj.get("username").toString(); String instituteid = repObj.get("instituteid").toString(); String registrationid = repObj.get("registrationid").toString(); String registrationcode = repObj.get("registrationcode") == "" ? "" : repObj.get("registrationcode").toString(); String enrollmentno = repObj.get("enrollmentno").toString(); String studentid = ""; if (repObj.get("studentid") != null) { studentid = repObj.get("studentid") == "" ? "" : repObj.get("studentid").toString(); } String reportby = repObj.get("reportby").toString(); String prid = repObj.get("prid") == null ? "" : repObj.get("prid").toString(); String prid1 = repObj.get("prid1") == null ? "" : repObj.get("prid1").toString(); //request.getParameter("prid1"); String receiptmode = repObj.get("receiptmode") == null ? "" : repObj.get("receiptmode").toString(); String prnofrom = repObj.get("prnofrom") == null ? "" : repObj.get("prnofrom").toString(); String prnoto = repObj.get("prnoto") == null ? "" : repObj.get("prnoto").toString(); List data = null; ASObject aSObject = null; UIService uiserviceobject = new UIService(); if (prid != null && !"".equals(prid)) { aSObject = getFeeReceiptReportData2(instituteid, registrationid, studentid, enrollmentno, reportby, prid, receiptmode); } else { aSObject = getFeeReceiptReportData(instituteid, registrationid, studentid, enrollmentno, prid1, prnofrom, prnoto, reportby); } data = (List) aSObject.get("list"); String amountinwords = "";//uiserviceobject.amountToWord(Double.parseDouble(amt.toString()), null); InstituteMaster ims = (InstituteMaster) daoFactory.getInstituteMasterDAO().findByPrimaryKey(instituteid); StringBuilder sb = new StringBuilder(); Set stdIdSet = new LinkedHashSet(); if (data != null && !data.isEmpty() && data.size() > 0) { for (int i = 0; i < data.size(); i++) { sb.append("\n\n\n\n\n\n\n\n\n"); sb.append(filler(data.get(i).get("enrollmentno").toString(), 26, "L", 7) + filler(data.get(i).get("enrollmentno").toString(), 34, "L", 8) + "\n"); sb.append(filler(data.get(i).get("name").toString(), 24, "L", 9) + filler(data.get(i).get("name").toString(), 34, "L", 9) + "\n"); sb.append(filler(data.get(i).get("semester").toString() + "/" + df.format(new Date()).substring(8, 10), 7, "L", 9) + filler(data.get(i).get("prno").toString(), 17, "L", 0) + filler(data.get(i).get("semester").toString() + "/" + df.format(new Date()).substring(8, 10), 19, "L", 7) + filler(data.get(i).get("prno").toString(), 18, "L", 3) + "\n"); sb.append(filler(data.get(i).get("categorycode").toString(), 10, "L", 9) + filler(df.format(new Date()), 12, "L", 3) + filler(data.get(i).get("categorycode").toString(), 19, "L", 7) + filler(df.format(new Date()), 13, "L", 8) + "\n"); sb.append(filler(data.get(i).get("program").toString(), 23, "L", 10) + filler(data.get(i).get("program").toString(), 33, "L", 9) + "\n"); sb.append("\n\n\n"); List feeDetailsAndAmtList = (List) daoFactory.getFeeTransactionDAO().getFeeReceiptReportFeeDetailsAndAmtData(instituteid, registrationid, data.get(i).get("studentid").toString(), data.get(i).get("enrollmentno").toString(), data.get(i).get("prid").toString(), prnofrom, prnoto, reportby); if (feeDetailsAndAmtList != null && feeDetailsAndAmtList.size() > 0 && !feeDetailsAndAmtList.isEmpty()) { for (int x = 0; x < feeDetailsAndAmtList.size(); x++) { Object[] obj = (Object[]) feeDetailsAndAmtList.get(x); if (feeDetailsAndAmtList.size() > 14) { sb.append(filler(obj[1].toString(), 22, "L", 0) + filler(((BigDecimal) obj[0]).setScale(2, BigDecimal.ROUND_HALF_UP).toString(), 11, "R", 0) + filler(obj[1].toString(), 31, "L", 2) + filler(((BigDecimal) obj[0]).setScale(2, BigDecimal.ROUND_HALF_UP).toString(), 12, "R", 0) + "\n"); total += Integer.parseInt(obj[0].toString()); totalf = totalf.add(((BigDecimal) obj[0]).setScale(2, BigDecimal.ROUND_HALF_UP)); if (feeDetailsAndAmtList.size() == 14) { for (int j = 0; j < (35); j++) { sb.append("\n"); } } } else { sb.append(filler(obj[1].toString(), 22, "L", 0) + filler(((BigDecimal) obj[0]).setScale(2, BigDecimal.ROUND_HALF_UP).toString(), 11, "R", 0) + filler(obj[1].toString(), 31, "L", 2) + filler(((BigDecimal) obj[0]).setScale(2, BigDecimal.ROUND_HALF_UP).toString(), 12, "R", 0) + "\n"); total += Integer.parseInt(obj[0].toString()); totalf = totalf.add(((BigDecimal) obj[0]).setScale(2, BigDecimal.ROUND_HALF_UP)); } } amountinwords = uiserviceobject.amountToWord(Double.parseDouble(totalf.toString()), null); } if (feeDetailsAndAmtList.size() < 14) { for (int n = 0; n < (14 - feeDetailsAndAmtList.size()); n++) { sb.append("\n"); } } else { for (int l = 0; l < 14 - (feeDetailsAndAmtList.size() - 14); l++) { sb.append("\n"); } } sb.append(filler(String.valueOf(totalf), 15, "R", 18) + filler(String.valueOf(totalf).toString(), 14, "R", 31) + "\n");// sb.append("\n"); String amountinwords1 = amountinwords; String amountinwords2 = amountinwords; String amountinword = amountinwords; if (amountinwords.length() > 0) { if (amountinwords.length() < 35) { for (int a = 0; a < (35 - amountinwords.length()); a++) { amountinwords2 = amountinwords2 + " "; amountinword = amountinword + " "; } if (amountinwords.length() < 25) { for (int b = 0; b < (25 - amountinwords.length()); b++) { amountinwords1 = amountinwords1 + " "; } } } sb.append(filler(amountinwords1.substring(0, 25).toString(), 30, "L", 3) + filler(amountinwords2.subSequence(0, 35).toString(), 36, "L", 9) + "\n"); sb.append(filler(amountinwords1.substring(25).toString(), 30, "L", 3) + filler(amountinwords2.substring(35).toString(), 36, "L", 9) + "\n"); }// sb.append("\n"); sb.append(filler(data.get(i).get("drawnon").toString(), 26, "L", 7) + filler(data.get(i).get("drawnon").toString(), 37, "L", 8) + "\n"); sb.append(filler(data.get(i).get("particularsno").toString(), 8, "L", 7) + filler(data.get(i).get("particularsdate") == "" ? "" : df.format(df.parse(data.get(i).get("particularsdate").toString())), 11, "L", 4) + filler(data.get(i).get("particularsno").toString(), 5, "L", 10) + filler(data.get(i).get("particularsdate") == "" ? "" : df.format(df.parse(data.get(i).get("particularsdate").toString())), 18, "L", 12) + "\n"); sb.append(filler(data.get(i).get("employeename").toString(), 21, "L", 12) + filler(data.get(i).get("employeename").toString(), 33, "L", 12) + "\n"); sb.append(filler(ims.getInstitutename().toString(), 25, "L", 8) + filler(ims.getInstitutename().toString(), 37, "L", 8) + ""); for (int s = 0; s < 9; s++) { sb.append("\n"); } } } Map map = new HashMap(); map.put("printdata", sb.toString()); map.put("noofcopies", 1); System.out.println("Printing Text" + sb.toString()); new Thread(new PrinterRunnable("10.1.30.9", 7077, map, map), "PrintThread").start(); System.out.println("Done"); } catch (Exception e) { e.printStackTrace(); } } private String filler(String s, int size, String alignment, int minGap) { String finalString = ""; for (int i = 0; i < minGap; i++) { finalString = finalString + " "; } if (alignment.equals("L")) { if (s.length() == size) { return (finalString + s); } else if (s.length() > size) { //String s3=s.substring(10, s.length()).length()>10? return (finalString + s.substring(0, size)); } else if (s.length() < size) { String s1 = ""; for (int i = s.length(); i < size; i++) { s1 = s1 + " "; } return (finalString + s + s1); } } else { if (s.length() == size) { return (finalString + s); } else if (s.length() > size) { //String s3=s.substring(10, s.length()).length()>10? return (finalString + s.substring(0, size)); } else if (s.length() < size) { String s1 = ""; for (int i = s.length(); i < size; i++) { s1 = s1 + " "; } return (s1 + (finalString + s)); } } return null; } public List getPrNoOnPrid(String studentid, String instid) { List rtnlist = new ArrayList(); ASObject objt = null; try { List excntrList = daoFactory.getFeeTransactionDAO().getPrNoOnPrid(studentid, instid); if (excntrList != null && excntrList.size() > 0) { for (int i = 0; i < excntrList.size(); i++) { objt = new ASObject(); objt.put("data", excntrList.get(i)[0] == null ? "" : excntrList.get(i)[0].toString()); objt.put("label", excntrList.get(i)[1] == null ? "" : excntrList.get(i)[1].toString()); rtnlist.add(objt); } } } catch (Exception e) { e.printStackTrace(); } return rtnlist; } public List getPrNoOnPridAll(String instid) { List rtnlist = new ArrayList(); ASObject objt = null; try { List excntrList = daoFactory.getFeeTransactionDAO().getPrNoOnPridAll(instid); if (excntrList != null && excntrList.size() > 0) { for (int i = 0; i < excntrList.size(); i++) { objt = new ASObject(); objt.put("data", excntrList.get(i)[0] == null ? "" : excntrList.get(i)[0].toString()); objt.put("label", excntrList.get(i)[1] == null ? "" : excntrList.get(i)[1].toString()); rtnlist.add(objt); } } } catch (Exception e) { e.printStackTrace(); } return rtnlist; } private void getFeeReceiptReportData(ServletOutputStream outputStream, String realPath, String instituteid, String registrationid, String enrollmentno, String studentid, String prnofrom, String prnoto, String receiptmode, String prid, String prid1, String reportby, String collectiondate) { List data = null; SimpleDateFormat df = new SimpleDateFormat("dd-MM-yyyy"); DecimalFormat df1 = new DecimalFormat(); df1.setMaximumFractionDigits(2); ASObject aSObject = null; UIService uiserviceobject = new UIService(); if (prid != null && !"".equals(prid)) { aSObject = getFeeReceiptReportData2(instituteid, registrationid, studentid, enrollmentno, reportby, prid, receiptmode); } else { aSObject = getFeeReceiptReportData(instituteid, registrationid, studentid, enrollmentno, prid1, prnofrom, prnoto, reportby); } data = (List) aSObject.get("list"); String amountinwords = "";//uiserviceobject.amountToWord(Double.parseDouble(amt.toString()), null); InstituteMaster ims = (InstituteMaster) daoFactory.getInstituteMasterDAO().findByPrimaryKey(instituteid); StringBuilder sb = new StringBuilder(); try { sb.append(""); sb.append(""); sb.append(""); sb.append(""); sb.append(""); if (data != null && !data.isEmpty() && data.size() > 0) { for (int i = 0; i < data.size(); i++) { int total = 0; int total1 = 0; BigDecimal totalf = new BigDecimal(0.00); BigDecimal totalf1 = new BigDecimal(0.00); sb.append(""); sb.append(""); sb.append(""); sb.append(""); sb.append("");// sb.append("" + ims.getInstitutename() + ""); sb.append("FEE RECEIPT"); sb.append(""); sb.append(""); sb.append("ROLL NO:" + data.get(i).get("enrollmentno").toString().toUpperCase() + ""); sb.append("STUD NAME:" + data.get(i).get("name").toString().toUpperCase() + ""); sb.append(""); sb.append(""); sb.append("SEMESTER:" + data.get(i).get("semester").toString() + "/" + df.format(new Date()).substring(8, 10) + "RECEIPT NO.:" + data.get(i).get("prno").toString().toUpperCase() + ""); sb.append("CATEGORY:" + data.get(i).get("categorycode").toString().toUpperCase() + " DATE:" +(collectiondate==null?df.format(data.get(i).get("prdate")):collectiondate) + ""); sb.append("PROGRAME:" + data.get(i).get("program").toString().toUpperCase() + ""); sb.append(""); sb.append(""); sb.append("Received Fees as Per Following"); sb.append(""); List feeDetailsAndAmtList = (List) daoFactory.getFeeTransactionDAO().getFeeReceiptReportFeeDetailsAndAmtData(instituteid, registrationid, data.get(i).get("studentid").toString(), data.get(i).get("enrollmentno").toString(), data.get(i).get("prid").toString(), prnofrom, prnoto, reportby); sb.append(""); sb.append("PARTICULARS AMOUNT"); if (feeDetailsAndAmtList != null && feeDetailsAndAmtList.size() > 0 && !feeDetailsAndAmtList.isEmpty()) { for (int x = 0; x < feeDetailsAndAmtList.size(); x++) { Object[] obj = (Object[]) feeDetailsAndAmtList.get(x); if (feeDetailsAndAmtList.size() > 14) { if (obj[1].toString().length() > 50) { sb.append("" + (obj[1].toString()).substring(0, 50) + "\n" + (obj[1].toString()).substring(51) + "" + ((BigDecimal) obj[0]).setScale(2, BigDecimal.ROUND_HALF_UP).toString() + ""); } else { sb.append("" + obj[1].toString() + "" + ((BigDecimal) obj[0]).setScale(2, BigDecimal.ROUND_HALF_UP).toString() + ""); } total += Integer.parseInt(obj[0].toString()); totalf = totalf.add(((BigDecimal) obj[0]).setScale(2, BigDecimal.ROUND_HALF_UP)); if (feeDetailsAndAmtList.size() == 14) { for (int j = 0; j < (25); j++) { sb.append(""); } } } else { if (obj[1].toString().length() > 50) { sb.append("" + (obj[1].toString()).substring(0, 50) + "\n" + (obj[1].toString()).substring(51) + "" + ((BigDecimal) obj[0]).setScale(2, BigDecimal.ROUND_HALF_UP).toString() + ""); } else { sb.append("" + obj[1].toString() + "" + ((BigDecimal) obj[0]).setScale(2, BigDecimal.ROUND_HALF_UP).toString() + ""); } total += Integer.parseInt(obj[0].toString()); totalf = totalf.add(((BigDecimal) obj[0]).setScale(2, BigDecimal.ROUND_HALF_UP)); } } sb.append("TOTAL" + String.valueOf(totalf) + "");// sb.append(""); sb.append(""); amountinwords = uiserviceobject.amountToWord(Double.parseDouble(totalf.toString()), null); } sb.append(""); if (feeDetailsAndAmtList.size()< 14) { for (int j = 0; j < (30); j++) { sb.append(""); } } if (feeDetailsAndAmtList.size() < 14) { for (int n = 0; n < (14 - feeDetailsAndAmtList.size()); n++) { sb.append(""); } } else { for (int l = 0; l < 14 - (feeDetailsAndAmtList.size() - 14); l++) { sb.append(""); } } sb.append("Amount in Words:" + amountinwords.toUpperCase() + ""); sb.append("Drawn on:" + data.get(i).get("drawnon").toString().toUpperCase() + ""); sb.append(""); sb.append(""); if(data.get(i).get("particularsdate").equals("Cash")) { sb.append("Cheque No:" + data.get(i).get("particularsno").toString().toUpperCase() + "&nbspDate:" + (data.get(i).get("particularsdate").equals("Cash") ? (collectiondate==null?df.format(data.get(i).get("prdate")):collectiondate): df.format((data.get(i).get("particularsdate")))) + ""); }else { sb.append("Cheque No:" + data.get(i).get("particularsno").toString().toUpperCase() + "&nbspDate:" + (data.get(i).get("particularsdate")=="" ? "": df.format((data.get(i).get("particularsdate")))) + ""); } sb.append("Received By:" + data.get(i).get("employeename").toString().toUpperCase() + ""); sb.append(""); sb.append(""); for (int j = 0; j < (40); j++) { sb.append(""); } sb.append("Subject to realistation of Cheque"); sb.append("Subject to Ahmedabad JurisdictionReceiver's Signature"); sb.append(""); sb.append(""); sb.append("Nirma University"); sb.append("Sarkhej-Gandhinagar Highway ,Ahmedabad - 382481"); sb.append(""); sb.append(""); sb.append(""); sb.append(""); sb.append(""); sb.append(""); sb.append("");// sb.append("" + ims.getInstitutename() + ""); sb.append("FEE RECEIPT"); sb.append(""); sb.append(""); sb.append("ROLL NO:" + data.get(i).get("enrollmentno").toString().toUpperCase() + ""); sb.append("STUD NAME:" + data.get(i).get("name").toString().toUpperCase() + ""); sb.append(""); sb.append(""); sb.append("SEMESTER:" + data.get(i).get("semester").toString() + "/" + df.format(new Date()).substring(8, 10) + "RECEIPT NO.:" + data.get(i).get("prno").toString().toUpperCase() + ""); sb.append("CATEGORY:" + data.get(i).get("categorycode").toString().toUpperCase() + " DATE:" +(collectiondate==null?df.format(data.get(i).get("prdate")):collectiondate) + ""); sb.append("PROGRAME:" + data.get(i).get("program").toString().toUpperCase() + ""); sb.append(""); sb.append(""); sb.append("Received Fees as Per Following"); sb.append(""); List feeDetailsAndAmtList1 = (List) daoFactory.getFeeTransactionDAO().getFeeReceiptReportFeeDetailsAndAmtData(instituteid, registrationid, data.get(i).get("studentid").toString(), data.get(i).get("enrollmentno").toString(), data.get(i).get("prid").toString(), prnofrom, prnoto, reportby); sb.append(""); sb.append("PARTICULARS AMOUNT"); if (feeDetailsAndAmtList1 != null && feeDetailsAndAmtList1.size() > 0 && !feeDetailsAndAmtList1.isEmpty()) { for (int x = 0; x < feeDetailsAndAmtList1.size(); x++) { Object[] obj = (Object[]) feeDetailsAndAmtList1.get(x); if (feeDetailsAndAmtList1.size() > 14) { if (obj[1].toString().length() > 50) { sb.append("" + (obj[1].toString()).substring(0, 50) + "\n" + (obj[1].toString()).substring(51) + "" + ((BigDecimal) obj[0]).setScale(2, BigDecimal.ROUND_HALF_UP).toString() + ""); } else { sb.append("" + obj[1].toString() + "" + ((BigDecimal) obj[0]).setScale(2, BigDecimal.ROUND_HALF_UP).toString() + ""); } total1 += Integer.parseInt(obj[0].toString()); totalf1 = totalf1.add(((BigDecimal) obj[0]).setScale(2, BigDecimal.ROUND_HALF_UP)); if (feeDetailsAndAmtList.size() == 14) { for (int j = 0; j < (25); j++) { sb.append(""); } } } else { if (obj[1].toString().length() > 50) { sb.append("" + (obj[1].toString()).substring(0, 50) + "\n" + (obj[1].toString()).substring(51) + "" + ((BigDecimal) obj[0]).setScale(2, BigDecimal.ROUND_HALF_UP).toString() + ""); } else { sb.append("" + obj[1].toString() + "" + ((BigDecimal) obj[0]).setScale(2, BigDecimal.ROUND_HALF_UP).toString() + ""); } total1 += Integer.parseInt(obj[0].toString()); totalf1 = totalf1.add(((BigDecimal) obj[0]).setScale(2, BigDecimal.ROUND_HALF_UP)); } } sb.append("TOTAL" + String.valueOf(totalf1) + "");// sb.append(""); sb.append(""); amountinwords = uiserviceobject.amountToWord(Double.parseDouble(totalf1.toString()), null); } sb.append(""); if (feeDetailsAndAmtList1.size()< 14) { for (int j = 0; j < (30); j++) { sb.append(""); } } if (feeDetailsAndAmtList.size() < 14) { for (int n = 0; n < (14 - feeDetailsAndAmtList.size()); n++) { sb.append(""); } } else { for (int l = 0; l < 14 - (feeDetailsAndAmtList.size() - 14); l++) { sb.append(""); } } sb.append("Amount in Words:" + amountinwords.toUpperCase() + ""); sb.append("Drawn on:" + data.get(i).get("drawnon").toString().toUpperCase() + ""); sb.append(""); sb.append(""); if(data.get(i).get("particularsdate").equals("Cash")) { sb.append("Cheque No:" + data.get(i).get("particularsno").toString().toUpperCase() + "&nbspDate:" + (data.get(i).get("particularsdate").equals("Cash") ? (collectiondate==null?df.format(data.get(i).get("prdate")):collectiondate): df.format((data.get(i).get("particularsdate")))) + ""); }else { sb.append("Cheque No:" + data.get(i).get("particularsno").toString().toUpperCase() + "&nbspDate:" + (data.get(i).get("particularsdate")=="" ? "": df.format((data.get(i).get("particularsdate")))) + ""); } sb.append("Received By:" + data.get(i).get("employeename").toString().toUpperCase() + ""); sb.append(""); sb.append(""); for (int j = 0; j < (40); j++) { sb.append(""); } sb.append("Subject to realistation of Cheque"); sb.append("Subject to Ahmedabad JurisdictionReceiver's Signature"); sb.append(""); sb.append(""); sb.append("Nirma University"); sb.append("Sarkhej-Gandhinagar Highway ,Ahmedabad - 382481"); sb.append(""); sb.append(""); sb.append(""); } sb.append(""); sb.append("");// System.out.println(sb.toString()); outputStream.print(sb.toString()); } else { } } catch (Exception e) { e.printStackTrace(); } } /** * DESC:: Method for Individual Student Fee Receipt. * @return */ public List getAllEventCodeWithRegistrationCode() { String instId = JIRPSession.getLoginInfo().getUserProfile().getSelectedinstitutemaster().getInstituteid(); ASObject aso = null; List rtnList = new ArrayList(); List eventList = (List) daoFactory.getFeeCollectionEventsDAO().getAllFeeCollectionEventCodeWithRegistrationCode(instId); if (eventList != null && eventList.size() > 0 && !eventList.isEmpty()) { for (int i = 0; i < eventList.size(); i++) { aso = new ASObject(); aso.put("data", eventList.get(i)[0]); aso.put("label", eventList.get(i)[1]); aso.put("desc", eventList.get(i)[2]); aso.put("regid", eventList.get(i)[10]); rtnList.add(aso); } } return rtnList; } public List getAllSTYNoFromStudentRegistration(String studentid, String instituteid) { List retList = new ArrayList(); ASObject obj = null; try { List list = (List) daoFactory.getStudentRegistrationDAO().find("select distinct sr.stynumber from StudentRegistration sr where sr.id.instituteid = '" + instituteid + "' and sr.id.studentid = '" + studentid + "' order by sr.stynumber asc"); if (list.size() > 0) { for (int i = 0; i < list.size(); i++) { obj = new ASObject(); obj.put("label", list.get(i).toString()); obj.put("data", list.get(i).toString()); obj.put("prnoList", getPrNoOnPridWithDate(studentid, instituteid, obj.get("data").toString())); retList.add(obj); } } } catch (Exception e) { e.printStackTrace(); } return retList; } public List getPrNoOnPridWithDate(String studentid, String instituteid, String styno) { List retList = new ArrayList(); ASObject obj = null; try { List list = (List) daoFactory.getFeeTransactionDAO().getPrNoOnPridWithDate(studentid, instituteid, styno); if (list.size() > 0) { for (int i = 0; i < list.size(); i++) { obj = new ASObject(); obj.put("label", list.get(i)[1].toString().concat(" (").concat(list.get(i)[2].toString()).concat(")")); obj.put("data", list.get(i)[0].toString()); retList.add(obj); } } } catch (Exception e) { e.printStackTrace(); } return retList; }}