1 19 package org.openbravo.erpCommon.ad_reports; 20 21 import org.openbravo.erpCommon.utility.*; 22 import org.openbravo.erpCommon.businessUtility.WindowTabs; 23 import org.openbravo.erpCommon.utility.ComboTableData; 24 import org.openbravo.erpCommon.businessUtility.Tree; 25 import org.openbravo.base.secureApp.HttpSecureAppServlet; 26 import org.openbravo.base.secureApp.VariablesSecureApp; 27 import org.openbravo.xmlEngine.XmlDocument; 28 import java.io.*; 29 import java.util.*; 30 import javax.servlet.*; 31 import javax.servlet.http.*; 32 33 import org.openbravo.erpCommon.ad_combos.OrganizationComboData; 34 import java.util.Vector ; 35 36 import org.openbravo.erpCommon.utility.DateTimeData; 37 38 39 import org.openbravo.erpCommon.utility.ToolBar; 40 41 public class ReportTrialBalance extends HttpSecureAppServlet { 42 43 44 public void doPost (HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException { 45 VariablesSecureApp vars = new VariablesSecureApp(request); 46 47 if (!Utility.hasProcessAccess(this, vars, "", "ReportTrialBalance")) { 48 bdError(response, "AccessTableNoView", vars.getLanguage()); 49 return; 50 } 51 52 if (vars.commandIn("DEFAULT")) { 53 String strDateFrom = vars.getGlobalVariable("inpDateFrom", "ReportTrialBalance|DateFrom", ""); 54 String strDateTo = vars.getGlobalVariable("inpDateTo", "ReportTrialBalance|DateTo", ""); 55 String strOnly = vars.getGlobalVariable("inpOnly", "ReportTrialBalance|Only", "-1"); 56 String strOrg = vars.getGlobalVariable("inpOrg", "ReportTrialBalance|Org", ""); 57 String strLevel = vars.getGlobalVariable("inpLevel", "ReportTrialBalance|Level", ""); 58 String strAccountFrom = vars.getGlobalVariable("inpAccountFrom", "ReportTrialBalance|AccountFrom", ""); 59 String strAccountTo = vars.getGlobalVariable("inpAccountTo", "ReportTrialBalance|AccountTo", ReportTrialBalanceData.selectLastAccount(this, Utility.getContext(this, vars, "#User_Org", "Account"), Utility.getContext(this, vars, "#User_Client", "Account"))); 60 61 String strcBpartnerId = vars.getRequestInGlobalVariable("inpcBPartnerId_IN", "ReportTrialBalance|cBpartnerId"); 62 String strAll = vars.getStringParameter("inpAll"); 63 64 printPageDataSheet(response, vars, strDateFrom, strDateTo, strOrg, strLevel, strOnly, strAccountFrom, strAccountTo, strAll, strcBpartnerId); 65 } else if (vars.commandIn("FIND")) { 66 String strDateFrom = vars.getRequestGlobalVariable("inpDateFrom", "ReportTrialBalance|DateFrom"); 67 String strDateTo = vars.getRequestGlobalVariable("inpDateTo", "ReportTrialBalance|DateTo"); 68 String strOnly = vars.getRequestGlobalVariable("inpOnly", "ReportTrialBalance|Only"); 69 String strOrg = vars.getRequestGlobalVariable("inpOrg", "ReportTrialBalance|Org"); 70 String strLevel = vars.getRequestGlobalVariable("inpLevel", "ReportTrialBalance|Level"); 71 String strAccountFrom = vars.getRequestGlobalVariable("inpAccountFrom", "ReportTrialBalance|AccountFrom"); 72 String strAccountTo = vars.getRequestGlobalVariable("inpAccountTo", "ReportTrialBalance|AccountTo"); 73 74 String strcBpartnerId = vars.getRequestInGlobalVariable("inpcBPartnerId_IN", "ReportTrialBalance|cBpartnerId"); 75 String strAll = vars.getStringParameter("inpAll"); 76 printPageDataSheet(response, vars, strDateFrom, strDateTo, strOrg, strLevel, strOnly, strAccountFrom, strAccountTo, strAll, strcBpartnerId); 77 } else if (vars.commandIn("PDF")){ 78 String strDateFrom = vars.getRequestGlobalVariable("inpDateFrom", "ReportTrialBalance|DateFrom"); 79 String strDateTo = vars.getRequestGlobalVariable("inpDateTo", "ReportTrialBalance|DateTo"); 80 String strOnly = vars.getRequestGlobalVariable("inpOnly", "ReportTrialBalance|Only"); 81 String strOrg = vars.getRequestGlobalVariable("inpOrg", "ReportTrialBalance|Org"); 82 String strLevel = vars.getRequestGlobalVariable("inpLevel", "ReportTrialBalance|Level"); 83 String strAccountFrom = vars.getRequestGlobalVariable("inpAccountFrom", "ReportTrialBalance|AccountFrom"); 84 String strAccountTo = vars.getRequestGlobalVariable("inpAccountTo", "ReportTrialBalance|AccountTo"); 85 86 String strcBpartnerId = vars.getRequestInGlobalVariable("inpcBPartnerId_IN", "ReportTrialBalance|cBpartnerId"); 87 String strAll = vars.getStringParameter("inpAll"); 88 printPageDataPDF(response, vars, strDateFrom, strDateTo, strOrg, strLevel, strOnly, strAccountFrom, strAccountTo, strAll, strcBpartnerId); 89 }else pageError(response); 90 } 91 92 void printPageDataSheet(HttpServletResponse response, VariablesSecureApp vars, String strDateFrom, String strDateTo, String strOrg, String strLevel, String strOnly, String strAccountFrom, String strAccountTo, String strAll, String strcBpartnerId) 93 throws IOException, ServletException { 94 String strMessage=""; 95 if (log4j.isDebugEnabled()) log4j.debug("Output: dataSheet"); 96 if (log4j.isDebugEnabled()) log4j.debug("strAll:"+strAll+" - strLevel:"+strLevel+" - strOnly:"+strOnly); 97 response.setContentType("text/html; charset=UTF-8"); 98 PrintWriter out = response.getWriter(); 99 String discard[]={"sectionDiscard","sectionBP"}; 100 XmlDocument xmlDocument=null; 101 String strTreeOrg = ReportTrialBalanceData.treeOrg(this, vars.getClient()); 102 String strOrgFamily = getFamily(strTreeOrg, strOrg); 103 String strTreeAccount = ReportTrialBalanceData.treeAccount(this, vars.getClient()); 104 String strcBpartnerIdAux = strcBpartnerId; 105 106 ReportTrialBalanceData [] data = null; 107 108 if (strDateFrom.equals("") && strDateTo.equals("")) { 109 xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportTrialBalance", discard).createXmlDocument(); 110 data = ReportTrialBalanceData.set(); 111 if (vars.commandIn("FIND")) { 112 strMessage=Utility.messageBD(this, "BothDatesCannotBeBlank", vars.getLanguage()); 113 log4j.warn("Both dates are blank"); 114 } 115 } else { 116 if (!strLevel.equals("S")) discard[0] = "selEliminarField"; 117 else discard[0] = "discard"; 118 119 if (log4j.isDebugEnabled()) log4j.debug("printPageDataSheet - strOrgFamily = " + strOrgFamily); 120 121 if(strLevel.equals("S") && strOnly.equals("-1") ){ 122 123 if (log4j.isDebugEnabled()) log4j.debug("strcBpartnerId:"+strcBpartnerId+" - strAll:"+strAll); 124 if (!(strAll.equals("")&&(strcBpartnerId.equals("")))) { 125 if (log4j.isDebugEnabled()) log4j.debug("Select BP, strcBpartnerId:"+strcBpartnerId+" - strAll:"+strAll); 126 if (!strAll.equals("")) strcBpartnerId=""; 127 discard[1] = "sectionNoBP"; 128 data = ReportTrialBalanceData.selectBP(this, strDateFrom, strDateTo, strOrg, strOrgFamily, Utility.getContext(this, vars, "#User_Client", "ReportTrialBalance"), Utility.getContext(this, vars, "#User_Org", "ReportTrialBalance"), strDateFrom, DateTimeData.nDaysAfter(this, strDateTo,"1"), strAccountFrom, strAccountTo,strcBpartnerId); 129 } else { 130 data = ReportTrialBalanceData.select(this, strDateFrom, strDateTo, strOrg, strTreeAccount, strOrgFamily, Utility.getContext(this, vars, "#User_Client", "ReportTrialBalance"), Utility.getContext(this, vars, "#User_Org", "ReportTrialBalance"), strDateFrom, DateTimeData.nDaysAfter(this, strDateTo,"1"), strAccountFrom, strAccountTo); 131 } 132 }else{ 133 data = ReportTrialBalanceData.select(this, strDateFrom, strDateTo, strOrg, strTreeAccount, strOrgFamily, Utility.getContext(this, vars, "#User_Client", "ReportTrialBalance"), Utility.getContext(this, vars, "#User_Org", "ReportTrialBalance"), strDateFrom, DateTimeData.nDaysAfter(this, strDateTo,"1"),"",""); 134 } 135 136 if (log4j.isDebugEnabled()) log4j.debug("Calculating tree..."); 137 data = calculateTree(data, null, new Vector <Object >()); 138 data = levelFilter(data, null, false, strLevel); 139 data = dataFilter(data); 140 if (log4j.isDebugEnabled()) log4j.debug("Tree calculated"); 141 } 142 ReportTrialBalanceData [] new_data = null; 143 if (strOnly.equals("-1") && data!=null && data.length>0)new_data = filterTree(data, strLevel); 144 else new_data = data; 145 if (log4j.isDebugEnabled()) log4j.debug("Creating xmlengine"); 146 xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportTrialBalance", discard).createXmlDocument(); 147 try { 148 ComboTableData comboTableData = new ComboTableData(vars, this, "LIST", "", "C_ElementValue level", "", Utility.getContext(this, vars, "#User_Org", "ReportTrialBalance"), Utility.getContext(this, vars, "#User_Client", "ReportTrialBalance"), 0); 149 Utility.fillSQLParameters(this, vars, null, comboTableData, "ReportTrialBalance", ""); 150 xmlDocument.setData("reportLevel","liststructure", comboTableData.select(false)); 151 comboTableData = null; 152 } catch (Exception ex) { 153 throw new ServletException(ex); 154 } 155 156 ToolBar toolbar = new ToolBar(this, vars.getLanguage(), "ReportTrialBalance", false, "", "", "imprimir();return false;",false, "ad_reports", strReplaceWith, false, true); 157 toolbar.prepareSimpleToolBarTemplate(); 158 159 xmlDocument.setParameter("toolbar", toolbar.toString()); 160 161 try { 162 KeyMap key = new KeyMap(this, vars, "ReportTrialBalance.html"); 163 xmlDocument.setParameter("keyMap", key.getReportKeyMaps()); 164 } catch (Exception ex) { 165 throw new ServletException(ex); 166 } 167 try { 168 WindowTabs tabs = new WindowTabs(this, vars, "org.openbravo.erpCommon.ad_reports.ReportTrialBalance"); 169 xmlDocument.setParameter("parentTabContainer", tabs.parentTabs()); 170 xmlDocument.setParameter("mainTabContainer", tabs.mainTabs()); 171 xmlDocument.setParameter("childTabContainer", tabs.childTabs()); 172 xmlDocument.setParameter("theme", vars.getTheme()); 173 NavigationBar nav = new NavigationBar(this, vars.getLanguage(), "ReportTrialBalance.html", classInfo.id, classInfo.type, strReplaceWith, tabs.breadcrumb()); 174 xmlDocument.setParameter("navigationBar", nav.toString()); 175 LeftTabsBar lBar = new LeftTabsBar(this, vars.getLanguage(), "ReportTrialBalance.html", strReplaceWith); 176 xmlDocument.setParameter("leftTabs", lBar.manualTemplate()); 177 } catch (Exception ex) { 178 throw new ServletException(ex); 179 } 180 { 181 OBError myMessage = vars.getMessage("ReportTrialBalance"); 182 vars.removeMessage("ReportTrialBalance"); 183 if (myMessage!=null) { 184 xmlDocument.setParameter("messageType", myMessage.getType()); 185 xmlDocument.setParameter("messageTitle", myMessage.getTitle()); 186 xmlDocument.setParameter("messageMessage", myMessage.getMessage()); 187 } 188 } 189 190 xmlDocument.setData("reportAccountFrom_ID","liststructure", ReportTrialBalanceData.selectAccount(this, Utility.getContext(this, vars, "#User_Org", "Account"), Utility.getContext(this, vars, "#User_Client", "Account"), "")); 191 xmlDocument.setData("reportAccountTo_ID","liststructure", ReportTrialBalanceData.selectAccount(this, Utility.getContext(this, vars, "#User_Org", "Account"), Utility.getContext(this, vars, "#User_Client", "Account"), "")); 192 xmlDocument.setData("reportAD_ORGID", "liststructure", OrganizationComboData.selectCombo(this, vars.getRole())); 193 xmlDocument.setParameter("calendar", vars.getLanguage().substring(0,2)); 194 xmlDocument.setParameter("direction", "var baseDirection = \"" + strReplaceWith + "/\";\n"); 195 xmlDocument.setParameter("paramLanguage", "LNG_POR_DEFECTO=\"" + vars.getLanguage() + "\";"); 196 xmlDocument.setParameter("dateFrom", strDateFrom); 197 xmlDocument.setParameter("dateFromdisplayFormat", vars.getSessionValue("#AD_SqlDateFormat")); 198 xmlDocument.setParameter("dateFromsaveFormat", vars.getSessionValue("#AD_SqlDateFormat")); 199 xmlDocument.setParameter("dateTo", strDateTo); 200 xmlDocument.setParameter("dateTodisplayFormat", vars.getSessionValue("#AD_SqlDateFormat")); 201 xmlDocument.setParameter("dateTosaveFormat", vars.getSessionValue("#AD_SqlDateFormat")); 202 xmlDocument.setParameter("Only", strOnly); 203 xmlDocument.setParameter("adOrgId", strOrg); 204 xmlDocument.setParameter("Level", strLevel); 205 xmlDocument.setParameter("accountFrom", strAccountFrom); 206 xmlDocument.setParameter("accountTo", strAccountTo); 207 xmlDocument.setParameter("paramMessage", (strMessage.equals("")?"":"alert('" + strMessage + "');")); 208 xmlDocument.setParameter("paramAll0", strAll.equals("")?"0":"1"); 209 xmlDocument.setData("reportCBPartnerId_IN", "liststructure", ReportRefundInvoiceCustomerDimensionalAnalysesData.selectBpartner(this, Utility.getContext(this, vars, "#User_Org", ""), Utility.getContext(this, vars, "#User_Client", ""), strcBpartnerIdAux)); 210 211 if (log4j.isDebugEnabled()) log4j.debug("filling structure, data.length:"+new_data.length); 212 if (discard[1].equals("sectionNoBP")) { 213 if (log4j.isDebugEnabled()) log4j.debug("without BPs"); 214 xmlDocument.setData("structure2", new_data); 215 } else { 216 if (log4j.isDebugEnabled()) log4j.debug("with BPs"); 217 if(strOnly.equals("-1")) Arrays.sort(new_data, new ReportTrialBalanceDataComparator()); 218 xmlDocument.setData("structure1", new_data); 219 220 } 221 out.println(xmlDocument.print()); 222 out.close(); 223 } 224 225 void printPageDataPDF(HttpServletResponse response, VariablesSecureApp vars, String strDateFrom, String strDateTo, String strOrg, String strLevel, String strOnly, String strAccountFrom, String strAccountTo, String strAll, String strcBpartnerId) 226 throws IOException, ServletException { 227 if (log4j.isDebugEnabled()) log4j.debug("Output: dataSheet"); 228 230 String discard[]={"selEliminar","sectionBP"}; 231 232 XmlDocument xmlDocument=null; 233 String strTreeOrg = ReportTrialBalanceData.treeOrg(this, vars.getClient()); 234 String strOrgFamily = getFamily(strTreeOrg, strOrg); 235 String strTreeAccount = ReportTrialBalanceData.treeAccount(this, vars.getClient()); 236 ReportTrialBalanceData [] data = null; 237 if (strDateFrom.equals("") && strDateTo.equals("")) { 238 xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportTrialBalancePDF", discard).createXmlDocument(); 239 data = ReportTrialBalanceData.set(); 240 } else { 241 if (!strLevel.equals("S")) discard[0] = "selEliminarField"; 242 else discard[0] = "discard"; 243 244 245 if(strLevel.equals("S") && strOnly.equals("-1") ){ 246 247 if (!(strAll.equals("")&&(strcBpartnerId.equals("")))) { 248 if (log4j.isDebugEnabled()) log4j.debug("Select BP, strcBpartnerId:"+strcBpartnerId+" - strAll:"+strAll); 249 if (!strAll.equals("")) strcBpartnerId=""; 250 discard[1] = "sectionNoBP"; 251 data = ReportTrialBalanceData.selectBP(this, strDateFrom, strDateTo, strOrg, strOrgFamily, Utility.getContext(this, vars, "#User_Client", "ReportTrialBalance"), Utility.getContext(this, vars, "#User_Org", "ReportTrialBalance"), strDateFrom, DateTimeData.nDaysAfter(this, strDateTo,"1"), strAccountFrom, strAccountTo,strcBpartnerId); 252 } else { 253 data = ReportTrialBalanceData.select(this, strDateFrom, strDateTo, strOrg, strTreeAccount, strOrgFamily, Utility.getContext(this, vars, "#User_Client", "ReportTrialBalance"), Utility.getContext(this, vars, "#User_Org", "ReportTrialBalance"), strDateFrom, DateTimeData.nDaysAfter(this, strDateTo,"1"), strAccountFrom, strAccountTo); 254 } 255 }else{ 256 data = ReportTrialBalanceData.select(this, strDateFrom, strDateTo, strOrg, strTreeAccount, strOrgFamily, Utility.getContext(this, vars, "#User_Client", "ReportTrialBalance"), Utility.getContext(this, vars, "#User_Org", "ReportTrialBalance"), strDateFrom, DateTimeData.nDaysAfter(this, strDateTo,"1"),"",""); 257 } 258 259 260 data = calculateTree(data, null, new Vector <Object >()); 261 data = levelFilter(data, null, false, strLevel); 262 data = dataFilter(data); 263 } 264 ReportTrialBalanceData [] new_data = null; 265 if (strOnly.equals("-1") && data!=null && data.length>0)new_data = filterTree(data, strLevel); 266 else new_data = data; 267 268 269 270 xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportTrialBalancePDF", discard).createXmlDocument(); 271 xmlDocument.setParameter("companyName", ReportTrialBalanceData.selectCompany(this, vars.getClient())); 272 xmlDocument.setParameter("date", DateTimeData.today(this)); 273 xmlDocument.setParameter("period", strDateFrom + " - " + strDateTo); 274 if (strLevel.equals("S")) xmlDocument.setParameter("accounting", "Cuenta inicio: "+ReportTrialBalanceData.selectAccountingName(this, strAccountFrom)+" - Cuenta fin: "+ReportTrialBalanceData.selectAccountingName(this, strAccountTo)); 275 else xmlDocument.setParameter("accounting", ""); 276 277 if (log4j.isDebugEnabled()) log4j.debug("filling structure, data.length:"+new_data.length); 278 if (log4j.isDebugEnabled()) log4j.debug("discard:"+discard[0]+","+discard[1]); 279 280 if (discard[1].equals("sectionNoBP")) 281 xmlDocument.setData("structure2", new_data); 282 else { 283 if(strOnly.equals("-1")) Arrays.sort(new_data, new ReportTrialBalanceDataComparator()); 284 xmlDocument.setData("structure1", new_data); 285 } 286 287 288 String strResult = xmlDocument.print(); 289 renderFO(strResult, response); 290 292 } 293 294 private ReportTrialBalanceData [] filterTree(ReportTrialBalanceData [] data, String strLevel){ 295 ArrayList<Object > arrayList = new ArrayList<Object >(); 296 for (int i=0;data!=null && i<data.length;i++){ 297 if (data[i].elementlevel.equals(strLevel)) arrayList.add(data[i]); 298 } 299 ReportTrialBalanceData[] new_data = new ReportTrialBalanceData [arrayList.size()]; 300 arrayList.toArray(new_data); 301 return new_data; 302 } 303 304 private ReportTrialBalanceData[] calculateTree(ReportTrialBalanceData[] data, String indice, Vector <Object > vecTotal) { 305 if (data==null || data.length==0) return data; 306 if (indice == null) indice="0"; 307 ReportTrialBalanceData[] result = null; 308 Vector <Object > vec = new Vector <Object >(); 309 if (vecTotal==null) vecTotal = new Vector <Object >(); 311 if (vecTotal.size()==0) { 312 vecTotal.addElement("0"); 313 vecTotal.addElement("0"); 314 vecTotal.addElement("0"); 315 vecTotal.addElement("0"); 316 } 317 double totalDR = Double.valueOf((String ) vecTotal.elementAt(0)).doubleValue(); 318 double totalCR = Double.valueOf((String ) vecTotal.elementAt(1)).doubleValue(); 319 double totalInicial = Double.valueOf((String ) vecTotal.elementAt(2)).doubleValue(); 320 double totalFinal = Double.valueOf((String ) vecTotal.elementAt(3)).doubleValue(); 321 boolean encontrado = false; 322 for (int i=0;i<data.length;i++) { 323 if (data[i].parentId.equals(indice)) { 324 encontrado = true; 325 Vector <Object > vecParcial = new Vector <Object >(); 326 vecParcial.addElement("0"); 327 vecParcial.addElement("0"); 328 vecParcial.addElement("0"); 329 vecParcial.addElement("0"); 330 ReportTrialBalanceData[] dataChilds = calculateTree(data, data[i].id, vecParcial); 331 double parcialDR = Double.valueOf((String ) vecParcial.elementAt(0)).doubleValue(); 332 double parcialCR = Double.valueOf((String ) vecParcial.elementAt(1)).doubleValue(); 333 double parcialInicial = Double.valueOf((String ) vecParcial.elementAt(2)).doubleValue(); 334 double parcialFinal = Double.valueOf((String ) vecParcial.elementAt(3)).doubleValue(); 335 data[i].amtacctdr = Double.toString(Double.valueOf(data[i].amtacctdr).doubleValue() + parcialDR); 336 data[i].amtacctcr = Double.toString(Double.valueOf(data[i].amtacctcr).doubleValue() + parcialCR); 337 data[i].saldoInicial = Double.toString(Double.valueOf(data[i].saldoInicial).doubleValue() + parcialInicial); 338 data[i].saldoFinal = Double.toString(Double.valueOf(data[i].saldoFinal).doubleValue() + parcialFinal); 339 340 totalDR += Double.valueOf(data[i].amtacctdr).doubleValue(); 341 totalCR += Double.valueOf(data[i].amtacctcr).doubleValue(); 342 totalInicial += Double.valueOf(data[i].saldoInicial).doubleValue(); 343 totalFinal += Double.valueOf(data[i].saldoFinal).doubleValue(); 344 345 vec.addElement(data[i]); 346 if (dataChilds!=null && dataChilds.length>0) { 347 for (int j=0;j<dataChilds.length;j++) vec.addElement(dataChilds[j]); 348 } 349 }else if(encontrado)break; 350 } 351 vecTotal.set(0, Double.toString(totalDR)); 352 vecTotal.set(1, Double.toString(totalCR)); 353 vecTotal.set(2, Double.toString(totalInicial)); 354 vecTotal.set(3, Double.toString(totalFinal)); 355 result = new ReportTrialBalanceData[vec.size()]; 356 vec.copyInto(result); 357 return result; 358 } 359 360 private ReportTrialBalanceData[] dataFilter(ReportTrialBalanceData[] data){ 361 if(data==null || data.length==0) return data; 362 Vector <Object > dataFiltered = new Vector <Object >(); 363 for (int i=0;i<data.length;i++){ 364 if (Double.valueOf(data[i].amtacctdr).doubleValue()!=0.0 || Double.valueOf(data[i].amtacctcr).doubleValue()!=0.0 || Double.valueOf(data[i].saldoInicial).doubleValue()!=0.0 || Double.valueOf(data[i].saldoFinal).doubleValue()!=0.0) { 365 dataFiltered.addElement(data[i]); 366 } 367 } 368 ReportTrialBalanceData[] result = new ReportTrialBalanceData[dataFiltered.size()]; 369 dataFiltered.copyInto(result); 370 return result; 371 } 372 373 private ReportTrialBalanceData[] levelFilter(ReportTrialBalanceData[] data, String indice, boolean found, String strLevel) { 374 if (data==null || data.length==0 || strLevel==null || strLevel.equals("")) return data; 375 ReportTrialBalanceData[] result = null; 376 Vector <Object > vec = new Vector <Object >(); 377 379 if (indice == null) indice="0"; 380 for (int i=0;i<data.length;i++) { 381 if (data[i].parentId.equals(indice) && (!found || data[i].elementlevel.equalsIgnoreCase(strLevel))) { 382 ReportTrialBalanceData[] dataChilds = levelFilter(data, data[i].id, (found || data[i].elementlevel.equals(strLevel)), strLevel); 383 vec.addElement(data[i]); 384 if (dataChilds!=null && dataChilds.length>0) for (int j=0;j<dataChilds.length;j++) vec.addElement(dataChilds[j]); 385 } 386 } 387 result = new ReportTrialBalanceData[vec.size()]; 388 vec.copyInto(result); 389 vec.clear(); 390 return result; 391 } 392 393 public String getFamily(String strTree, String strChild) throws IOException, ServletException { 394 return Tree.getMembers(this, strTree, strChild); 395 404 } 405 406 public String getServletInfo() { 407 return "Servlet ReportTrialBalance. This Servlet was made by Eduardo Argal"; 408 } } 410 411 | Popular Tags |