1 19 package org.openbravo.erpCommon.ad_actionButton; 20 21 import org.openbravo.erpCommon.ad_combos.*; 22 import org.openbravo.erpCommon.utility.Utility; 23 import org.openbravo.utils.Replace; 24 import org.openbravo.base.secureApp.HttpSecureAppServlet; 25 import org.openbravo.base.secureApp.VariablesSecureApp; 26 import org.openbravo.xmlEngine.XmlDocument; 27 import java.io.*; 28 import javax.servlet.*; 29 import javax.servlet.http.*; 30 31 32 public class CreateFile extends HttpSecureAppServlet { 33 34 public void init (ServletConfig config) { 35 super.init(config); 36 boolHist = false; 37 } 38 39 public void doPost (HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException { 40 VariablesSecureApp vars = new VariablesSecureApp(request); 41 42 if (vars.commandIn("DEFAULT")) { 43 String strProcessId = vars.getStringParameter("inpProcessId"); 44 String strWindow = vars.getStringParameter("inpwindowId"); 45 String strKey = vars.getStringParameter("inpcRemittanceId"); 46 String strMessage = ""; 47 printPage(response, vars, strKey, strWindow, strProcessId, strMessage); 48 } else if(vars.commandIn("GENERATE")){ 49 String strKey = vars.getStringParameter("inpcRemittanceId"); 50 getPrintPage(response, vars, strKey); 51 } 52 } 53 54 55 void printPage(HttpServletResponse response, VariablesSecureApp vars, String strKey, String windowId, String strProcessId, String strMessage) 56 throws IOException, ServletException { 57 if (log4j.isDebugEnabled()) log4j.debug("Output: Button create file msg:"+strMessage); 58 59 ActionButtonDefaultData[] data = null; 60 String strHelp="", strDescription=""; 61 if (vars.getLanguage().equals("en_US")) data = ActionButtonDefaultData.select(this, strProcessId); 62 else data = ActionButtonDefaultData.selectLanguage(this, vars.getLanguage(), strProcessId); 63 64 if (data!=null && data.length!=0) { 65 strDescription = data[0].description; 66 strHelp = data[0].help; 67 } 68 String [] discard = {""}; 69 if (strHelp.equals("")) discard[0] = new String ("helpDiscard"); 70 XmlDocument xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_actionButton/CreateFile", discard).createXmlDocument(); 71 xmlDocument.setParameter("key", strKey); 72 xmlDocument.setParameter("window", windowId); 73 xmlDocument.setParameter("language", "LNG_POR_DEFECTO=\"" + vars.getLanguage() + "\";"); 74 xmlDocument.setData("reportTyperemittance","liststructure", TyperemittanceComboData.select(this, Utility.getContext(this, vars, "#User_Client", "CreateFile"), Utility.getContext(this, vars, "#User_Org", "CreateFile"))); 75 xmlDocument.setParameter("direction", "var baseDirection = \"" + strReplaceWith + "/\";\r\n"); 76 xmlDocument.setParameter("description", strDescription); 77 xmlDocument.setParameter("help", strHelp); 78 xmlDocument.setParameter("message",strMessage.equals("")?"":"alert('" + strMessage + "');"); 79 80 response.setContentType("text/html; charset=UTF-8"); 81 PrintWriter out = response.getWriter(); 82 out.println(xmlDocument.print()); 83 out.close(); 84 } 85 86 void getPrintPage(HttpServletResponse response, VariablesSecureApp vars, String strKey) throws IOException, ServletException { 87 if (log4j.isDebugEnabled()) log4j.debug("generate "+strKey); 88 String strCuaderno = CreateFileData.selectParam(this,strKey,"CUADERNO"); 89 String strContract = CreateFileData.selectParam(this,strKey,"CONTRACT"); 90 91 if (strCuaderno.equals("58")) printPageFind58(response, vars, strKey, strContract); 92 else if (strCuaderno.equals("19")) printPageFind19(response, vars, strKey, strContract); 93 else if (strCuaderno.equals("34")) printPageFind34(response, vars, strKey); 94 } 95 96 void printPageFind58(HttpServletResponse response, VariablesSecureApp vars, String strKey, String strContract) throws IOException, ServletException { 97 if (log4j.isDebugEnabled()) log4j.debug("Output: pageFind"); 98 StringBuffer strBuf = new StringBuffer (); 99 String strMessage = ""; 100 CreateFileData[] Principio = CreateFileData.select(this, strKey); 101 CreateFileData[] Lineas = CreateFileData.selectLineas(this,strKey); 102 CreateFileData[] Total = CreateFileData.selectTotal(this,strKey); 103 int comprobacion1 = new Integer (CreateFileData.selectComprobacion1(this, strKey)).intValue(); 104 int comprobacion2 = new Integer (CreateFileData.selectComprobacion2(this, strKey)).intValue(); 105 int comprobacion3 = new Integer (CreateFileData.selectComprobacion3(this, strKey)).intValue(); 106 int comprobacion4 = new Integer (CreateFileData.selectComprobacion4(this, strKey)).intValue(); 107 if (log4j.isDebugEnabled()) log4j.debug(" c1:"+comprobacion1+" c2:"+comprobacion2+" c3:"+comprobacion3+" c4:"+comprobacion4); 108 109 if(comprobacion1 != 0 || comprobacion2 != 1 || comprobacion3 !=1 || comprobacion4 == 0){ 110 strMessage = Utility.messageBD(this, "CreateFileError", vars.getLanguage()); 111 printPage(response, vars, strKey, "", "", strMessage); 112 } 113 int contador = 2; 114 String strLinea = ""; 115 if (Principio == null || Principio.length == 0){ 117 strMessage = Utility.messageBD(this, "DefaultAccountError", vars.getLanguage()); 118 printPage(response, vars, strKey, "", "", strMessage); 119 return; 120 } 121 if (Lineas == null || Total == null)return; 122 if (Principio[0].nif == null || Principio[0].nif.equals("")){ 123 strMessage = Utility.messageBD(this, "NIFError", vars.getLanguage()); 124 } 125 if (Principio[0].codebank == null || Principio[0].codebank.equals("")){ 126 strMessage = Utility.messageBD(this, "CodeBankError", vars.getLanguage()); 127 } 128 if (Principio[0].codebranch == null || Principio[0].codebranch.equals("")){ 129 strMessage = Utility.messageBD(this, "CodeBranchError", vars.getLanguage()); 130 } 131 if (Principio[0].digitcontrol1 == null || Principio[0].digitcontrol1.equals("")){ 132 strMessage = Utility.messageBD(this, "DC1Error", vars.getLanguage()); 133 } 134 if (Principio[0].digitcontrol2 == null || Principio[0].digitcontrol2.equals("")){ 135 strMessage = Utility.messageBD(this, "DC2Error", vars.getLanguage()); 136 } 137 if (Principio[0].ine == null || Principio[0].ine.equals("")){ 138 strMessage = Utility.messageBD(this, "INEError", vars.getLanguage()); 139 } 140 strBuf = strBuf.append("5170").append(Principio[0].nif).append(strContract).append(Principio[0].dateplanned); 142 strBuf = strBuf.append(Principio[0].entidad); 143 strBuf = strBuf.append(Principio[0].entofi).append("\r\n"); 144 strBuf = strBuf.append("5370").append(Principio[0].nif).append(strContract).append(Principio[0].dateplanned); 146 strBuf = strBuf.append(Principio[0].entidad).append(Principio[0].nCuenta).append(" 06"); 147 strBuf = strBuf.append(Principio[0].ine).append(" \r\n"); 148 for (int i=0;i<Lineas.length;i++){ 150 if (Lineas[i].creditcardnumber == null || Lineas[i].creditcardnumber.equals("")){ 152 strMessage = Utility.messageBD(this, "CodeBankBPError", vars.getLanguage()) + Lineas[i].tercero; 153 } 154 if (Lineas[i].fechaVencimiento == null || Lineas[i].fechaVencimiento.equals("")){ 155 strMessage = Utility.messageBD(this, "DatePlannedError", vars.getLanguage()) + Lineas[i].tercero; 156 } 157 if (Lineas[i].direccion == null || Lineas[i].direccion.equals("")){ 158 strMessage = Utility.messageBD(this, "AddressError", vars.getLanguage()) + Lineas[i].tercero; 159 } 160 if (Lineas[i].plaza == null || Lineas[i].plaza.equals("")){ 161 strMessage = Utility.messageBD(this, "SquareError", vars.getLanguage()) + Lineas[i].tercero; 162 } 163 if (Lineas[i].postal == null || Lineas[i].postal.equals("")){ 164 strMessage = Utility.messageBD(this, "PostCodeError", vars.getLanguage()) + Lineas[i].tercero; 165 } 166 if (Lineas[i].localidad == null || Lineas[i].localidad.equals("")){ 167 strMessage = Utility.messageBD(this, "TownError", vars.getLanguage()) + Lineas[i].tercero; 168 } 169 if (Lineas[i].fechaFactura == null || Lineas[i].fechaFactura.equals("")){ 170 strMessage = Utility.messageBD(this, "InvoiceDateError", vars.getLanguage()) + Lineas[i].tercero;; 171 } 172 strBuf = strBuf.append("5670").append(Principio[0].nif).append(strContract).append(Lineas[i].nFactura).append(Lineas[i].tercero); 173 strBuf = strBuf.append(Lineas[i].creditcardnumber).append(Lineas[i].payamt).append(" "); 174 strBuf = strBuf.append(Replace.replace(Lineas[i].concepto,"\n", "")).append(Lineas[i].fechaVencimiento).append(" \r\n"); 175 contador++; 176 strBuf = strBuf.append("5676").append(Principio[0].nif).append(strContract).append(Lineas[i].nFactura).append(Lineas[i].direccion); 177 strBuf = strBuf.append(Lineas[i].plaza).append(Lineas[i].postal).append(Lineas[i].localidad); 178 strBuf = strBuf.append(Lineas[i].codigoProvincia).append(Lineas[i].fechaFactura).append("\r\n"); 179 contador++; 180 } 181 CreateFileData[] NLineas = CreateFileData.selectNLineas(this, String.valueOf(contador)); 182 strBuf = strBuf.append("5870").append(Principio[0].nif).append(strContract).append(NLineas[0].hueco); 184 strBuf = strBuf.append(Total[0].payamt).append(Total[0].nFactura).append(NLineas[0].lineas).append("\r\n"); 185 NLineas = CreateFileData.selectNLineas(this, String.valueOf(contador + 2)); 186 strBuf = strBuf.append("5970").append(Principio[0].nif).append(strContract); 188 strBuf = strBuf.append(NLineas[0].ordenantes).append(Total[0].payamt).append(Total[0].nFactura).append(NLineas[0].lineas); 189 if (!strMessage.equals("")){ 190 printPage(response, vars, strKey, "", "", strMessage); 191 }else{ 192 response.setContentType("application/rtf"); 193 response.setHeader("Content-Disposition","attachment; filename=BANK.DAT"); 194 PrintWriter out = response.getWriter(); 195 out.println(strBuf.toString()); 196 out.close(); 197 } 198 } 199 200 void printPageFind19(HttpServletResponse response, VariablesSecureApp vars, String strKey, String strContract) throws IOException, ServletException { 201 if (log4j.isDebugEnabled()) log4j.debug("Output: pageFind"); 202 StringBuffer strBuf = new StringBuffer (); 203 String strMessage = ""; 204 CreateFileData[] Principio = CreateFileData.select(this, strKey); 205 CreateFileData[] Lineas = CreateFileData.selectLineas(this,strKey); 206 CreateFileData[] Total = CreateFileData.selectTotal(this,strKey); 207 208 int comprobacion1 = new Integer (CreateFileData.selectComprobacion1(this, strKey)).intValue(); 209 int comprobacion2 = new Integer (CreateFileData.selectComprobacion2(this, strKey)).intValue(); 210 int comprobacion3 = new Integer (CreateFileData.selectComprobacion3(this, strKey)).intValue(); 211 int comprobacion4 = new Integer (CreateFileData.selectComprobacion4(this, strKey)).intValue(); 212 213 if(comprobacion1 != 0 || comprobacion2 != 1 || comprobacion3 !=1 || comprobacion4 == 0){ 214 if (log4j.isDebugEnabled()) log4j.debug("Error: c1:"+comprobacion1+" c2:"+comprobacion2+" c3:"+comprobacion3+" c4:"+comprobacion4); 215 strMessage = Utility.messageBD(this, "CreateFileError", vars.getLanguage()); 216 printPage(response, vars, strKey, "", "", strMessage); 217 } 218 if (log4j.isDebugEnabled()) log4j.debug("check1 ok"); 219 int contador = 2; 220 String strLinea = ""; 221 if (Principio == null || Principio.length == 0){ 223 strMessage = Utility.messageBD(this, "DefaultAccountError", vars.getLanguage()); 224 printPage(response, vars, strKey, "", "", strMessage); 225 return; 226 } 227 if (Lineas == null || Total == null)return; 228 if (Principio[0].nif == null || Principio[0].nif.equals("")){ 229 strMessage = Utility.messageBD(this, "NIFError", vars.getLanguage()); 230 if (log4j.isDebugEnabled()) log4j.debug("NIF"); 231 } 232 if (Principio[0].codebank == null || Principio[0].codebank.equals("")){ 233 strMessage = Utility.messageBD(this, "CodeBankError", vars.getLanguage()); 234 if (log4j.isDebugEnabled()) log4j.debug("codebank"); 235 } 236 if (Principio[0].codebranch == null || Principio[0].codebranch.equals("")){ 237 strMessage = Utility.messageBD(this, "CodeBranchError", vars.getLanguage()); 238 if (log4j.isDebugEnabled()) log4j.debug("CodeBranchError"); 239 } 240 if (Principio[0].digitcontrol1 == null || Principio[0].digitcontrol1.equals("")){ 241 strMessage = Utility.messageBD(this, "DC1Error", vars.getLanguage()); 242 if (log4j.isDebugEnabled()) log4j.debug("DC1Error"); 243 } 244 if (Principio[0].digitcontrol2 == null || Principio[0].digitcontrol2.equals("")){ 245 strMessage = Utility.messageBD(this, "DC2Error", vars.getLanguage()); 246 if (log4j.isDebugEnabled()) log4j.debug("DC2Error"); 247 } 248 if (log4j.isDebugEnabled()) log4j.debug("check2 ok"); 249 strBuf = strBuf.append("5180").append(Principio[0].nif).append(strContract).append(Principio[0].hoy).append(Principio[0].dateplanned); 251 strBuf = strBuf.append(Principio[0].entidad19); 252 strBuf = strBuf.append(Principio[0].entofi).append("\r\n"); 253 strBuf = strBuf.append("5380").append(Principio[0].nif).append(strContract).append(Principio[0].hoy).append(Principio[0].dateplanned); 255 strBuf = strBuf.append(Principio[0].entidad19).append(Principio[0].nCuenta).append(" 01 "); 256 strBuf = strBuf.append(" \r\n"); 257 for (int i=0;i<Lineas.length;i++){ 259 if (Lineas[i].creditcardnumber == null || Lineas[i].creditcardnumber.equals("")){ 261 if (log4j.isDebugEnabled()) log4j.debug("CodeBankBPError"); 262 strMessage = Utility.messageBD(this, "CodeBankBPError", vars.getLanguage()) + Lineas[i].tercero; 263 } 264 if (Lineas[i].fechaVencimiento == null || Lineas[i].fechaVencimiento.equals("")){ 265 if (log4j.isDebugEnabled()) log4j.debug("DatePlannedError"); 266 strMessage = Utility.messageBD(this, "DatePlannedError", vars.getLanguage()) + Lineas[i].tercero; 267 } 268 if (Lineas[i].direccion == null || Lineas[i].direccion.equals("")){ 269 if (log4j.isDebugEnabled()) log4j.debug("AddressError"); 270 strMessage = Utility.messageBD(this, "AddressError", vars.getLanguage()) + Lineas[i].tercero; 271 } 272 if (Lineas[i].plaza == null || Lineas[i].plaza.equals("")){ 273 if (log4j.isDebugEnabled()) log4j.debug("SquareError"); 274 strMessage = Utility.messageBD(this, "SquareError", vars.getLanguage()) + Lineas[i].tercero; 275 } 276 if (Lineas[i].postal == null || Lineas[i].postal.equals("")){ 277 if (log4j.isDebugEnabled()) log4j.debug("PostCodeError"); 278 strMessage = Utility.messageBD(this, "PostCodeError", vars.getLanguage()) + Lineas[i].tercero; 279 } 280 if (Lineas[i].localidad == null || Lineas[i].localidad.equals("")){ 281 if (log4j.isDebugEnabled()) log4j.debug("TownError"); 282 strMessage = Utility.messageBD(this, "TownError", vars.getLanguage()) + Lineas[i].tercero; 283 } 284 if (Lineas[i].fechaFactura == null || Lineas[i].fechaFactura.equals("")){ 285 if (log4j.isDebugEnabled()) log4j.debug("InvoiceDateError"); 286 strMessage = Utility.messageBD(this, "InvoiceDateError", vars.getLanguage()) + Lineas[i].tercero;; 287 } 288 strBuf = strBuf.append("5680").append(Principio[0].nif).append(strContract).append(Lineas[i].nFactura19).append(Lineas[i].tercero); 289 strBuf = strBuf.append(Lineas[i].creditcardnumber).append(Lineas[i].payamt).append("0000000000000000"); 290 strBuf = strBuf.append(Replace.replace(Lineas[i].concepto,"\n", "")).append(Lineas[i].fechaVencimiento).append(" \r\n"); 291 contador++; 292 296 } 297 if (log4j.isDebugEnabled()) log4j.debug("check3 ok"); 298 CreateFileData[] NLineas = CreateFileData.selectNLineas(this, String.valueOf(contador)); 299 strBuf = strBuf.append("5880").append(Principio[0].nif).append(strContract).append(NLineas[0].hueco); 301 strBuf = strBuf.append(Total[0].payamt).append(Total[0].nFactura).append(NLineas[0].lineas).append("\r\n"); 302 NLineas = CreateFileData.selectNLineas(this, String.valueOf(contador + 2)); 303 strBuf = strBuf.append("5980").append(Principio[0].nif).append(strContract); 305 strBuf = strBuf.append(NLineas[0].ordenantes).append(Total[0].payamt).append(Total[0].nFactura).append(NLineas[0].lineas); 306 if (!strMessage.equals("")){ 307 printPage(response, vars, strKey, "", "", strMessage); 308 }else{ 309 response.setContentType("application/rtf"); 310 response.setHeader("Content-Disposition","attachment; filename=BANK.DAT"); 311 PrintWriter out = response.getWriter(); 312 out.println(strBuf.toString()); 313 out.close(); 314 } 315 } 316 317 318 319 void printPageFind34(HttpServletResponse response, VariablesSecureApp vars, String strKey) throws IOException, ServletException { 320 if (log4j.isDebugEnabled()) log4j.debug("Output: pageFind34"); 321 StringBuffer strBuf = new StringBuffer (); 322 String strMessage = ""; 323 324 325 String strConcepto = CreateFileData.selectParam(this,strKey,"CONCEPTO"); 326 if (log4j.isDebugEnabled()) log4j.debug("Item"+strConcepto); 327 if (strConcepto == null||strConcepto.equals("")) strConcepto="N"; 328 if (log4j.isDebugEnabled()) log4j.debug("Item"+strConcepto); 329 char cConcepto=strConcepto.charAt(0); 330 331 String strCodigo; 332 333 switch (cConcepto) 334 { 335 case 'C': strCodigo = "57"; 337 break; 338 case 'R': strCodigo = "58"; 340 break; 341 case 'P': strCodigo = "59"; 343 break; 344 default: strCodigo = "56"; 346 } 347 if (log4j.isDebugEnabled()) log4j.debug("code"+strCodigo); 348 352 String strGastos = CreateFileData.selectParam(this,strKey,"GASTOS"); 353 if (strGastos==null||!strGastos.equals("2")) strGastos="1"; 354 if (log4j.isDebugEnabled()) log4j.debug("strGastos"+strGastos); 355 356 360 String strDetalle = CreateFileData.selectParam(this,strKey,"DETALLE"); 361 if (strDetalle==null||!strDetalle.equals("1")) strDetalle="0"; 362 if (log4j.isDebugEnabled()) log4j.debug("code"+strDetalle); 363 364 365 CreateFile34Data[] Principio = CreateFile34Data.select(this, strKey); 366 CreateFile34Data[] Lineas = CreateFile34Data.selectLineas(this,strKey); 367 CreateFile34Data[] Total = CreateFile34Data.selectTotal(this,strKey); 368 int comprobacion1 = new Integer (CreateFileData.selectComprobacion1(this, strKey)).intValue(); 369 int comprobacion2 = new Integer (CreateFileData.selectComprobacion2(this, strKey)).intValue(); 370 int comprobacion3 = new Integer (CreateFileData.selectComprobacion3(this, strKey)).intValue(); 371 int comprobacion4 = new Integer (CreateFileData.selectComprobacion4(this, strKey)).intValue(); 372 373 int comprobacion341 = new Integer (CreateFile34Data.selectComprobacion341(this, Principio[0].hoy, Principio[0].duedate)).intValue(); 374 375 if(comprobacion1 != 0 || comprobacion2 != 1 || comprobacion3 !=1 || comprobacion4 == 0){ 376 if (log4j.isDebugEnabled()) log4j.debug("Error: c1:"+comprobacion1+" c2:"+comprobacion2+" c3:"+comprobacion3+" c4:"+comprobacion4); 377 strMessage = Utility.messageBD(this, "CreateFileError", vars.getLanguage()); 378 printPage(response, vars, strKey, "", "", strMessage); 379 } 380 381 if (log4j.isDebugEnabled()) log4j.debug("Principio[0].taxid = " + Principio[0].taxid); 382 if (log4j.isDebugEnabled()) log4j.debug("Principio[0].acct = " + Principio[0].acct); 383 if (log4j.isDebugEnabled()) log4j.debug("check1 ok"); 384 385 386 if (Principio == null || Principio.length == 0){ 388 strMessage = Utility.messageBD(this, "DefaultAccountError", vars.getLanguage()); 389 printPage(response, vars, strKey, "", "", strMessage); 390 return; 391 } 392 if (Lineas == null || Total == null) return; 393 if (Principio[0].taxid == null || Principio[0].taxid.length()!=9){ 394 strMessage = Utility.messageBD(this, "NIFError", vars.getLanguage()); 395 if (log4j.isDebugEnabled()) log4j.debug("VAT number"); 396 printPage(response, vars, strKey, "", "", strMessage); 397 return; 398 } 399 if (Principio[0].acct == null || Principio[0].acct.length()!=18){ 400 strMessage = Utility.messageBD(this, "BankAccountError", vars.getLanguage()); 401 if (log4j.isDebugEnabled()) log4j.debug("bankaccount"); 402 printPage(response, vars, strKey, "", "", strMessage); 403 return; 404 } 405 406 413 414 if (log4j.isDebugEnabled()) log4j.debug("check2 ok"); 415 strBuf = strBuf.append("03").append(strCodigo).append(Principio[0].nif).append(" "); strBuf = strBuf.append("001").append(Principio[0].hoy).append(Principio[0].duedate); strBuf = strBuf.append(Principio[0].nCuenta).append(strDetalle).append(" ").append(Principio[0].dc).append(Principio[0].hueco).append("\r\n"); 421 strBuf = strBuf.append("03").append(strCodigo).append(Principio[0].nif).append(" "); strBuf = strBuf.append("002").append(Principio[0].nombre).append(Principio[0].hueco).append("\r\n"); 425 strBuf = strBuf.append("03").append(strCodigo).append(Principio[0].nif).append(" "); strBuf = strBuf.append("003").append(Principio[0].domicilio).append(Principio[0].hueco).append("\r\n"); 429 strBuf = strBuf.append("03").append(strCodigo).append(Principio[0].nif).append(" "); strBuf = strBuf.append("004").append(Principio[0].plaza).append(Principio[0].hueco).append("\r\n"); 433 int contador = 4; 434 for (int i=0;i<Lineas.length;i++){ 436 if (log4j.isDebugEnabled()) log4j.debug("Lineas[i].taxid=" + Lineas[i].taxid); 438 if (log4j.isDebugEnabled()) log4j.debug("Lineas[i].acct=" + Lineas[i].acct); 439 if (log4j.isDebugEnabled()) log4j.debug("Lineas[i].nom=" + Lineas[i].nom); 440 if (log4j.isDebugEnabled()) log4j.debug("Lineas[i].dom=" + Lineas[i].dom); 441 if (log4j.isDebugEnabled()) log4j.debug("Lineas[i].pla=" + Lineas[i].pla); 442 if (log4j.isDebugEnabled()) log4j.debug("Lineas[i].prov=" + Lineas[i].prov); 443 444 445 if (Lineas[i].nom == null || Lineas[i].nom.length()<1){ 446 if (log4j.isDebugEnabled()) log4j.debug("NameError"); 447 strMessage = Utility.messageBD(this, "NameError", vars.getLanguage()) + Lineas[i].nif; 448 printPage(response, vars, strKey, "", "", strMessage); 449 return; 450 } 451 if (Lineas[i].taxid == null || Lineas[i].taxid.length()!=9){ 452 if (log4j.isDebugEnabled()) log4j.debug("NIFError"); 453 strMessage = Utility.messageBD(this, "NIFBPartnerError", vars.getLanguage()) + Lineas[i].nombre; 454 printPage(response, vars, strKey, "", "", strMessage); 455 return; 456 } 457 if (Lineas[i].acct == null || Lineas[i].acct.length()!=20){ 458 if (log4j.isDebugEnabled()) log4j.debug("CodeBankBPError"); 459 strMessage = Utility.messageBD(this, "CodeBankBPError", vars.getLanguage()) + Lineas[i].nombre; 460 printPage(response, vars, strKey, "", "", strMessage); 461 return; 462 } 463 if (Lineas[i].dom == null || Lineas[i].dom.length()<1){ 464 if (log4j.isDebugEnabled()) log4j.debug("AddressError"); 465 strMessage = Utility.messageBD(this, "AddressError", vars.getLanguage()) + Lineas[i].nombre; 466 printPage(response, vars, strKey, "", "", strMessage); 467 return; 468 } 469 if (Lineas[i].pla == null || Lineas[i].pla.length()<1){ 470 if (log4j.isDebugEnabled()) log4j.debug("SquareError"); 471 strMessage = Utility.messageBD(this, "SquareError", vars.getLanguage()) + Lineas[i].nombre; 472 printPage(response, vars, strKey, "", "", strMessage); 473 return; 474 } 475 if (Lineas[i].prov == null || Lineas[i].prov.length()<1){ 476 if (log4j.isDebugEnabled()) log4j.debug("AddressError"); 477 strMessage = Utility.messageBD(this, "AddressError", vars.getLanguage()) + Lineas[i].nombre; 478 printPage(response, vars, strKey, "", "", strMessage); 479 return; 480 } 481 strBuf = strBuf.append("06").append(strCodigo).append(Principio[0].nif).append(Lineas[i].nif); strBuf = strBuf.append("010").append(Lineas[i].payamt).append(Lineas[i].nCuenta); strBuf = strBuf.append(strGastos); 485 strBuf = strBuf.append(cConcepto=='N'?"1":cConcepto=='P'?"8":"9").append(" "); 486 strBuf = strBuf.append(Lineas[i].dc).append(Principio[0].hueco).append("\r\n"); 487 488 strBuf = strBuf.append("06").append(strCodigo).append(Principio[0].nif).append(Lineas[i].nif); strBuf = strBuf.append("011").append(Lineas[i].nombre).append(Principio[0].hueco).append("\r\n"); 491 strBuf = strBuf.append("06").append(strCodigo).append(Principio[0].nif).append(Lineas[i].nif); strBuf = strBuf.append("012").append(Lineas[i].domicilio).append(Principio[0].hueco).append("\r\n"); 494 495 strBuf = strBuf.append("06").append(strCodigo).append(Principio[0].nif).append(Lineas[i].nif); strBuf = strBuf.append("014").append(Lineas[i].plaza).append(Principio[0].hueco).append("\r\n"); 498 499 strBuf = strBuf.append("06").append(strCodigo).append(Principio[0].nif).append(Lineas[i].nif); strBuf = strBuf.append("015").append(Lineas[i].provincia).append(Principio[0].hueco).append("\r\n"); 502 503 strBuf = strBuf.append("06").append(strCodigo).append(Principio[0].nif).append(Lineas[i].nif); strBuf = strBuf.append("016").append(Lineas[i].concepto).append(Principio[0].hueco).append("\r\n"); 506 507 contador+=6; 508 } 509 CreateFile34Data[] NLineas = CreateFile34Data.selectNLineas(this, String.valueOf(contador+1)); 511 strBuf = strBuf.append("08").append(strCodigo).append(Principio[0].nif).append(Total[0].payamt); strBuf = strBuf.append(NLineas[0].ordenantes).append(NLineas[0].lineas).append(NLineas[0].hueco).append("\r\n"); 513 514 if (!strMessage.equals("")){ 515 printPage(response, vars, strKey, "", "", strMessage); 516 }else{ 517 response.setContentType("application/rtf"); 518 response.setHeader("Content-Disposition","attachment; filename=BANK.DAT"); 519 PrintWriter out = response.getWriter(); 520 out.println(strBuf.toString()); 521 out.close(); 522 } 523 } 524 525 public String getServletInfo() { 526 return "Servlet for the generation of files for banks"; 527 } } 529 | Popular Tags |