From 18bc241c5d91373f7b09fd0cd909059e2aefc57c Mon Sep 17 00:00:00 2001 From: JesusPerez Date: Fri, 1 Oct 2021 20:29:55 +0100 Subject: [PATCH] chore: Last century javascript client/server --- albaran.js | 137 +++++ ctasapagar.js | 958 ++++++++++++++++++++++++++++++++ factura.js | 652 ++++++++++++++++++++++ global.js | 1448 ++++++++++++++++++++++++++++++++++++++++++++++++ l_albaran.js | 335 +++++++++++ l_docpago.js | 945 +++++++++++++++++++++++++++++++ l_factura.js | 477 ++++++++++++++++ l_prevision.js | 159 ++++++ l_trasp_old.js | 386 +++++++++++++ l_traspaso.js | 512 +++++++++++++++++ nroletra.js | 335 +++++++++++ 11 files changed, 6344 insertions(+) create mode 100644 albaran.js create mode 100644 ctasapagar.js create mode 100644 factura.js create mode 100644 global.js create mode 100644 l_albaran.js create mode 100644 l_docpago.js create mode 100644 l_factura.js create mode 100644 l_prevision.js create mode 100644 l_trasp_old.js create mode 100644 l_traspaso.js create mode 100644 nroletra.js diff --git a/albaran.js b/albaran.js new file mode 100644 index 0000000..97b93fe --- /dev/null +++ b/albaran.js @@ -0,0 +1,137 @@ +// // +// JavaScript Functions // +// // +////////////////////////////////////// +// Algunas variables Globales + +function InsAlbLins() { + if ( !request.ab_nro_reg ) { + status=-1 + return; + } + var i=1; + var nrolineas=0; + var nroctas=0, nro=0; + nro=parseInt(request.nrolineas); + if ( nro+1 > 1 ) { + for (nl=1;nl<=nro;nl++) { + eval('if ( request.al_'+i+'_cantidad+0 != 0 && request.al_'+i+'_precio_und+0 != 0 ) {'+ + 'status=database.execute("INSERT INTO albalineas(" +'+ + '" nro_lin," +'+ + '" nro_reg," +'+ + '" cantidad," +'+ + '" referencia," +'+ + '" descripcion," +'+ + '" precio_und ) VALUES (\'" + StringClip(true,request.al_'+i+'_nro_lin) + "\',\'" +'+ + 'StringClip(true,request.ab_nro_reg) + "\',\'"+'+ + 'NroUnformat(request.al_'+i+'_cantidad) + "\',\'"+'+ + 'StringClip(true,request.al_'+i+'_referencia) + "\',\'"+'+ + 'StringClip(true,request.al_'+i+'_descripcion) + "\',\'"+'+ + 'NroUnformat(request.al_'+i+'_precio_und ) + "\')");}'); + if ( status != 0 ) { + client.is_trans=false; + database.rollbackTransaction(); + redirect('error.html?alert=11') + } + DbsError(true,status); + } + } + nroctas=parseInt(request.nroctas); + if ( nroctas+1 > 1 ) { + for (nl=1;nl<=nroctas;nl++) { + eval(' if ( request.ac_'+nl+'_importe+0 != 0 && request.ac_'+nl+'_cod_cta.length > 2 ) {'+ + ' status=database.execute("INSERT INTO aptecuentas(" + '+ + '" nro_lin," + '+ + '" nro_reg," +'+ + '" tipolin," +'+ + '" cod_cta," +'+ + '" clave," +'+ + '" concepto," +'+ + '" importe," +'+ + '" tipo_apte," +'+ + '" fecha ) VALUES (\'" + StringClip(true,request.ac_'+nl+'_nro_lin) + "\',\'" + '+ + 'StringClip(true,request.ab_nro_reg) + "\',\'"+'+ + 'StringClip(true,request.ac_'+nl+'_tipolin) + "\',\'"+'+ + 'StringClip(true,request.ac_'+nl+'_cod_cta) + "\',\'"+'+ + 'StringClip(true,request.ac_'+nl+'_clave) + "\',\'"+'+ + 'StringClip(true,request.ac_'+nl+'_concepto) + "\',\'"+'+ + 'NroUnformat(request.ac_'+nl+'_importe) + "\',\'"+'+ + 'StringClip(true,request.ac_'+nl+'_tipo_apte) + "\',\'"+'+ + 'StringClip(true,datetoString(HOY)) + "\')");}'); + if ( status != 0 ) { + client.is_trans=false; + database.rollbackTransaction(); + redirect('error.html?alert=12') + } + DbsError(true,status); + } + } +} + +function DelAlbLins() { + status=database.execute("DELETE FROM albalineas WHERE nro_reg = \'" + request.ab_nro_reg + "\'"); + if ( status != 0 ) { + client.is_trans=false; + database.rollbackTransaction(); + redirect('error.html') + } + DbsError(true,status); + status=database.execute("DELETE FROM aptecuentas WHERE nro_reg = \'" + request.ab_nro_reg + "\'"); + if ( status != 0 ) { + client.is_trans=false; + database.rollbackTransaction(); + redirect('error.html') + } + DbsError(true,status); +} +function scanClaveCta(icta) { + var f=document.f_albaran; +// eval("var clave=f.ac_"+icta+"_clave.value;"); +// alert("Clave:"+clave+" linea "+icta); + var importe=0; + var cta="", tipoAte="", tipoLin=""; + eval("importe=parseInt(NroUnformat(f.ac_"+icta+"_importe.value));"); + eval("cta=f.ac_"+icta+"_cod_cta.value;"); + eval("tipoApte=get_value(\'select\',f.ac_"+icta+"_tipo_apte);"); + eval("tipoLin=f.ac_"+icta+"_tipolin.value;"); + if ( tipoLin == "G" && importe == 0 ) { eval("f.ac_"+icta+"_clave.value=pa_clave_siniva;"); } + if ( tipoLin == "G" && importe > 0 ) { eval("f.ac_"+icta+"_clave.value=pa_clave_coniva;"); } + if ( tipoLin == "G" && importe < 0 ) { eval("f.ac_"+icta+"_clave.value=pa_clave_coniva;"); } +// if ( tipoApte == "D" ) { } +// if ( tipoApte == "H" ) { } +// if ( TipoFra=="2") { // Dev. Retención +// if ( tipoLin == "G" || tipoLin == "R" ) { eval("f.acf_"+icta+"_clave.value=pa_clave_dev;"); }; +// } +// if ( TipoRet=="1") { // IRPF +// if ( tipoLin == "G" || tipoLin == "R" ) { eval("f.acf_"+icta+"_clave.value=pa_clave_reten_1;"); } +// } +// if ( TipoRet=="2") { // Por Garantía +// if ( tipoLin == "G" || tipoLin == "R" ) { eval("f.acf_"+icta+"_clave.value=pa_clave_reten_2;"); } +// } +// eval("var clave=f.ac_"+icta+"_clave.value;"); +// alert("Clave:"+clave); +} +function AlbDocuHtml(nro_reg) { + var s_seq=getSeqPrt(nprinter); + textoReqs=textoReqs+" "+s_seq; + var nomFile=spoolpath+nprinter+"/req_"+s_seq+".html" + fileRpt=new File(nomFile); + fileRpt.open("w"); + fileRpt.writeln(''); + nrolin=1; +// CursorTabla("fa","nro_reg","=\'"+nro_reg+"\'",true,""); + // Asignamos a request todas las columnas necesarias para el form. + if (request.f_formato=="documento") { + fileRpt.writeln(''); + fileRpt.writeln(''); + fileRpt.writeln(''); + fileRpt.close(); + return nrolin; + } + fileRpt.writeln(''); + fileRpt.writeln(''); + fileRpt.writeln(''); + fileRpt.close(); + return nrolin; +} + diff --git a/ctasapagar.js b/ctasapagar.js new file mode 100644 index 0000000..53f3dba --- /dev/null +++ b/ctasapagar.js @@ -0,0 +1,958 @@ +// // +// JavaScript Functions // +// // +////////////////////////////////////// +// Algunas variables Globales + var entorno = new entObj(0); + + +function entObj(appreg) { + this.DirBase="http://ctasapagar.malaga.sando.es/Ctas_a_Pagar"; + this.w_parambase="toolbar=yes,location=no,directories=no,menubar=no,status=yes,scrollbars=yes,resizable=yes"; + this.w_paramApp="toolbar=yes,location=no,directories=no,menubar=no,status=yes,scrollbars=yes,resizable=yes"; + this.appreg=appreg; + this.es_inicio=0; +} + + +function dbConnect() { +// if (client.es_inicio == 0 ) { +// entorno.es_inicio=client.es_inicio; +// redirect("go_close.html"); +// initial.html?ipw=1"); +// parent.window.close(); +//} +//else +// client.es_inicio=0 ; + if (!database.connected()) { + // arguments: + // database type INFORMIX + // database server + // database login + // database pw + // database name tock + // make sure you use a database login that has connect, select, update, + // insert, and delete privileges on the tock database + // database.connect("INFORMIX","appalanche_db", "informix", "informix", "tock"); + + client.type = "INFORMIX"; + client.db_id = "ctpagar"; + client.database = "sando_adm"; + client.server = "sandodbs"; + client.password = "15-admisys"; + + status=database.connect(client.type, + client.server, + client.db_id, + client.password, + client.database); + DbsError(status,-1); + } +} + +function dbAcl() +{ + chkBrowser(); // control del Browser +// if (request.FrameType) +// client.FrameType=request.FrameType; +// else +// request.FrameType=client.FrameType; +// Aquí va el control de acceso +// Reasignamos algunas variables globales para el Server +// Algunos formatos para fechas. + NLDF="D/M/YY"; // para columnas en las queries INFORMIX + IFDF="D/M/YY"; // para columnas en SQL según DBDATE + nprinter="hp4mp"; + spoolpath="c:/tmprpts/spool/"; +// Algunos formatos para nros. + NF2="##" + NF3="###" + NF4="#.###" + NF5="##.###" + NF6="###.###" + NF7="#.###.###" + NF8="##.###.###" + NF9="###.###.###" + NF09="***.***.***" + NFY9="&&&.&&&.&&&" + NF10="#.###.###.###" + NF11="##.###.###.###" + NF12="###.###.###.###" +// client.acl=2; + if (!request.uid || request.uid == null) + redirect("alertpage.html?alert=90"); +// request.uid=client.id; +// if (!client.acl) { // Ha perdido el acl !!!! + login = database.cursor("select acl from user where id='"+request.uid+"'"); + if (login.next()) { + client.acl = login.acl; + } + login.close(); +// } + if (client.acl == 0 || client.acl == null ) + redirect("alertpage.html?alert=0"); +// if ( request.ViewFkey == "S" || request.ViewFkey == "N" ) +// client.ViewFkey = request.ViewFkey; +// client.FrameType= request.FrameType; +// request.FrameType="L"; + if (client.acl == 1 ) { + request.waux="1"; + baseHtml="FrameType="+request.FrameType+"&ViewFkey="+request.ViewFkey+"&uid="+request.uid+"&waux=1" + }else + baseHtml="FrameType="+request.FrameType+"&ViewFkey="+request.ViewFkey+"&uid="+request.uid +} +function setUrl(docpath,reqObj) { + baseReq="FrameType="+request.FrameType+"&ViewFkey="+request.ViewFkey+"&uid="+request.uid + if (!reqObj || reqObj == "") + var HtmlRef=docpath+"?"+baseReq; + else + var HtmlRef=docpath+"?"+reqObj+"&"+baseReq; +// load_url("main",HtmlRef); + debug(HtmlRef); + return HtmlRef; +} +function getHtmlRef() { + return "FrameType="+request.FrameType+"&ViewFkey="+request.ViewFkey+"&uid="+request.uid +} +// +function Go_BaseFrame(FrameType,ViewFkey,MsgScroll,username) { + parent.document.location.href=entorno.DirBase+"/reinitial.html?FrameType="+FrameType+ + "&ViewFkey="+ViewFkey+ + "&MsgScroll="+MsgScroll+ + "&username="+username + +// var mainFrame=find_frame(top,"contents"); +// mainFrame.document.f_contents.action=entorno.DirBase+"/ctasapagar.html?FrameType="+FrameType +// mainFrame.document.f_contents.submit(); +} +function IniciaRequest(objeto) { + if (objeto == "us_" || objeto == "all" ) { + // user -> +// request.id +// request.login +// request.password +// request.firstname +// request.lastname +// request.fullname +// request.title +// request.phone +// request.email +// request.active +// request.status +// request.admin +// request.def_project +// request.def_category + } + if (objeto == "ac_" || objeto == "all" ) { + // aptecuentas -> + request.ac_nro_reg=0 + request.ac_nro_lin=0 + request.ac_cod_cta="" + request.acf_clave=""; + request.acf_concepto=""; + request.ac_importe=0 + request.ac_tipo_apte=""; + request.ac_fecha=""; + } + if (objeto == "tc_" || objeto == "all" ) { + // traspaso_ctas -> + request.tc_cta_contable=""; + request.tc_importe=0; + request.tc_es_nueva="N"; + } + if (objeto == "pr_" || objeto == "all" ) { + // proveedores -> + request.pr_nif=""; + request.pr_razon_social=""; + request.pr_cta_contable=""; + request.pr_cond_pago=""; + request.pr_domicilio=""; + request.pr_localidad=""; + request.pr_cod_postal=""; + request.pr_attn_envio=""; + request.pr_direccion_envio=""; + request.pr_localidad_envio=""; + request.pr_cod_postal_envio=""; + request.pr_telefono_1=""; + request.pr_telefono_2=""; + request.pr_fax=""; + request.pr_e_mail=""; + request.pr_observaciones=""; + request.pr_expediente=""; + request.pr_t_condpago=""; + request.pr_t_localidad=""; + request.pr_t_loc_envio=""; + } + if (objeto == "ce_" || objeto == "all" ) { + // centros -> + request.ce_cod_centro=""; + request.ce_cod_departamento=""; + request.ce_descripcion=""; + } + if (objeto == "cp_" || objeto == "all" ) { + // cond_pago -> + request.cp_cond_pago=""; + request.cp_descripcion=""; + request.cp_vencimiento=0 + } + if (objeto == "pe_" || objeto == "all" ) { + // pedidos -> + request.pe_nro_pedido=""; + request.pe_descripcion=""; + request.pe_nif_proveedor=""; + request.pe_cod_centro=""; + request.pe_cond_pago=""; + request.pe_fecha_pedido=""; + request.pe_fecha_entrega=""; + request.pe_importe=0; + request.pe_observaciones=""; + request.pe_expediente=""; + } + if (objeto == "ct_" || objeto == "all" ) { + // ctas_contables -> + request.ct_cta_contable=""; + request.ct_descripcion=""; + request.ct_es_nueva=""; + } + if (objeto == "cv_" || objeto == "all" ) { + // ctas_contables -> + request.cv_cod_clave=""; + request.cv_descripcion=""; + } + if (objeto == "al_" || objeto == "all" ) { + // albalineas -> + request.al_nro_lin=0; + request.al_nro_reg=""; + request.al_cantidad=0; + request.al_referencia=""; + request.al_descripcion=""; + request.al_precio_und=0; + } + if (objeto == "lo_" || objeto == "all" ) { + // localidades -> + request.lo_cod_localidad=""; + request.lo_descripcion=""; + } + if (objeto == "re_" || objeto == "all" ) { + // registros -> + request.rg_tipo_reg=""; + request.rg_nro_reg=0; + } + if (objeto == "ab_" || objeto == "all" ) { + // albaranes -> + request.ab_nro_reg=""; + request.ab_is_locked="N"; + request.ab_fra_reg=""; + request.ab_fecha_emision=""; + request.ab_cod_centro=""; + request.ab_nif=" "; + request.ab_por_reten=client.pa_reten_1; + request.ab_importe_reten=0; + request.ab_nro_pedido=""; + request.ab_vto_jefe_obra=""; + request.ab_vto_jefe_grupo=""; + request.ab_vto_proveedor=""; + request.ab_observaciones=""; + request.ab_expediente=""; + } + if (objeto == "af_" || objeto == "all" ) { + // albafras -> + request.af_nroreg_albafact=""; + request.af_nroreg_factura=""; + request.af_nroreg_albaran=""; + request.af_observaciones=""; + } + if (objeto == "ba_" || objeto == "all" ) { + // bancos -> + request.ba_cod_banco=""; + request.ba_nombre=""; + request.ba_domicilio=""; + request.ba_localidad=""; + request.ba_cod_postal=""; + request.ba_entidad=""; + request.ba_sucursal=""; + request.ba_cod_control=""; + request.ba_nro_cc=""; + request.ba_nro_lins=""; + request.ba_l_importe=""; + request.ba_c_importe=""; + request.ba_l_paguese=""; + request.ba_c_paguese=""; + request.ba_l1_nroletra=""; + request.ba_c1_nroletra=""; + request.ba_l2_nroletra=""; + request.ba_c2_nroletra=""; + request.ba_l_fecha=""; + request.ba_c_fecha=""; + request.ba_l_mes=""; + request.ba_c_mes=""; + request.ba_l_anno=""; + request.ba_c_anno=""; + request.ba_l1_firmado=""; + request.ba_c1_firmado=""; + request.ba_l2_firmado=""; + request.ba_c2_firmado=""; + request.ba_t1_firmado=""; + request.ba_t2_firmado=""; + } + if (objeto == "fa_" || objeto == "all" ) { + // facturas -> + request.fa_nro_reg=""; + request.fa_nro_regn=""; + request.fa_nro_regy=""; + request.fa_is_locked="N"; + request.fa_mes=NroFormat(HOY.getMonth()+1,"00"); + request.fa_nro_fra=""; + request.fa_f_emision=""; + request.fa_f_recepcion=""; + request.fa_f_pago=""; + request.fa_tipo_fra=1; + request.fa_tipo_calc_iva=1; + request.fa_importe_total=0; + request.fa_nif=""; + request.fa_cod_centro=""; + request.fa_nro_pedido=""; + request.fa_cond_pago=""; + request.fa_tipo_doc_pago=1; + request.fa_nro_doc_pago=""; + request.fa_f_emision_pago=""; + request.fa_cod_localidad=""; + request.fa_cod_banco=""; + request.fa_base_1=0; + request.fa_por_ret1=0; + request.fa_ret_1=0; + request.fa_por_iva1=client.pa_iva_1; + request.fa_iva_1=0; + request.fa_base_2=0; + request.fa_por_ret2=0; + request.fa_ret_2=0; + request.fa_por_iva2=client.pa_iva_2; + request.fa_iva_2=0; + request.fa_base_3=0; + request.fa_por_ret3=0; + request.fa_ret_3=0; + request.fa_por_iva3=client.pa_iva_3; + request.fa_iva_3=0; + request.fa_canexen=0; + request.fa_base_imponible=0; + request.fa_tipo_retencion=1; + request.fa_tipo_deduccion=""; + request.fa_deducciones=0; + request.fa_sin_pedido=""; + request.fa_traspaso_gasto="N"; + request.fa_traspaso_vto="N"; + request.fa_traspaso_pago="N"; + request.fa_nro_reg_vto=""; + request.fa_vto_pago=""; + request.fa_observaciones=""; + request.fa_expediente=""; + } + if (objeto == "acf_" || objeto == "all" ) { + // aptectasfra -> + request.acf_nro_reg=""; + request.acf_nro_lin=0; + request.acf_tipolin=""; + request.acf_cod_cta=""; + request.acf_clave=""; + request.acf_concepto=""; + request.acf_importe=0; + request.acf_tipo_apte=""; + request.acf_fecha=""; + } + if (objeto == "pa_" || objeto == "all" ) { + request.pa_id = 1; + request.pa_nro_reg = ""; + request.pa_longcta = 0; + request.pa_dia_pago_1 = 0; + request.pa_dia_pago_2 = 0; + request.pa_ex_dia_pago = ""; + request.pa_iva_1 = 0; + request.pa_iva_2 = 0; + request.pa_reten_1 = 0; + request.pa_ctas_reten_1 = ""; + request.pa_clave_reten_1 = ""; + request.pa_reten_2 = 0; + request.pa_ctas_reten_2 = ""; + request.pa_clave_reten_2 = ""; + request.pa_ctas_iva = ""; + request.pa_clave_iva = ""; + request.pa_ctas_cont = ""; + request.pa_clave_cont = ""; + request.pa_ctas_comp = ""; + request.pa_clave_comp = ""; + request.pa_ctas_coniva = ""; + request.pa_clave_coniva = ""; + request.pa_ctas_siniva = ""; + request.pa_clave_siniva = ""; + request.pa_ctas_dev = ""; + request.pa_clave_dev = ""; + } +} +// ---------------------- Select Tablas ---------------------------------- + +function CursorTabla(CodTabla,clave,criterio,chk,forupdate) +{ + if ( CodTabla == "pa" ) { + //Si se busca la fila ... usando la clave primaria de la relación + c_parametros=database.cursor("SELECT * FROM parametros WHERE "+ clave +criterio , forupdate ); + status=c_parametros.next(); + if ( chk == true ) + DbsError(true,status); + } + if ( CodTabla == "acf" ) { + //Si se busca la fila ... usando la clave primaria de la relación + c_aptectasfra=database.cursor("SELECT * FROM aptectasfra WHERE "+ clave +criterio , forupdate ); +// status=c_aptectasfra.next(); +// if ( chk == true ) +// DbsError(true,status); + } + if ( CodTabla == "ac" ) { + //Si se busca la fila ... usando la clave primaria de la relación + c_aptecuentas=database.cursor("SELECT * FROM aptecuentas WHERE "+ clave +criterio , forupdate ); + if ( chk == true ) + status=c_aptecuentas.next(); + if ( chk == true ) + DbsError(true,status); + } + if ( CodTabla == "tc" ) { + //Si se busca la fila ... usando la clave primaria de la relación + c_traspaso_ctas=database.cursor("SELECT * FROM traspaso_ctas WHERE "+ clave +criterio , forupdate ); + status=c_traspaso_ctas.next(); + if ( chk == true ) + DbsError(true,status); + } + if ( CodTabla == "pr" ) { + //Si se busca la fila ... usando la clave primaria de la relación + c_proveedores=database.cursor("SELECT * FROM proveedores WHERE "+ clave +criterio , forupdate ); + status=c_proveedores.next(); + if ( chk == true ) + DbsError(true,status); + } + if ( CodTabla == "ce" ) { + //Si se busca la fila ... usando la clave primaria de la relación + c_centros=database.cursor("SELECT * FROM centros WHERE "+ clave +criterio , forupdate ); + status=c_centros.next(); + if ( chk == true ) + DbsError(true,status); + } + if ( CodTabla == "pl" ) { + //Si se busca la fila ... usando la clave primaria de la relación + c_plan_contable=database.cursor("SELECT * FROM plan_contable WHERE "+ clave +criterio , forupdate ); + status=c_plan_contable.next(); + if ( chk == true ) + DbsError(true,status); + } + + if ( CodTabla == "cp" ) { + //Si se busca la fila ... usando la clave primaria de la relación + c_cond_pago=database.cursor("SELECT * FROM cond_pago WHERE "+ clave +criterio , forupdate ); + status=c_cond_pago.next(); + if ( chk == true ) + DbsError(true,status); + } + if ( CodTabla == "pe" ) { + //Si se busca la fila ... usando la clave primaria de la relación + c_pedidos=database.cursor("SELECT * FROM pedidos WHERE "+ clave +criterio , forupdate ); + status=c_pedidos.next(); + if ( chk == true ) + DbsError(true,status); + } + if ( CodTabla == "lo" ) { + //Si se busca la fila ... usando la clave primaria de la relación + c_localidades=database.cursor("SELECT * FROM localidades WHERE "+ clave +criterio , forupdate ); + status=c_localidades.next(); + if ( chk == true ) + DbsError(true,status); + } + if ( CodTabla == "fa" ) { + //Si se busca la fila ... usando la clave primaria de la relación + c_facturas=database.cursor("SELECT * FROM facturas WHERE "+ clave +criterio , forupdate ); + status=c_facturas.next(); + if ( chk == true ) + DbsError(true,status); + } + if ( CodTabla == "ct" ) { + //Si se busca la fila ... usando la clave primaria de la relación + c_ctas_contables=database.cursor("SELECT * FROM ctas_contables WHERE "+ clave +criterio , forupdate ); + status=c_ctas_contables.next(); + if ( chk == true ) + DbsError(true,status); + } + if ( CodTabla == "ba" ) { + //Si se busca la fila ... usando la clave primaria de la relación + c_bancos=database.cursor("SELECT * FROM bancos WHERE "+ clave +criterio , forupdate ); + status=c_bancos.next(); + if ( chk == true ) + DbsError(true,status); + } + if ( CodTabla == "al" ) { + //Si se busca la fila ... usando la clave primaria de la relación + c_albalineas=database.cursor("SELECT * FROM albalineas WHERE "+ clave +criterio , forupdate ); + if ( chk == true ) + status=c_albalineas.next(); + if ( chk == true ) + DbsError(true,status); + } + if ( CodTabla == "cv" ) { + //Si se busca la fila ... usando la clave primaria de la relación + c_claves=database.cursor("SELECT * FROM claves WHERE "+ clave +criterio , forupdate ); + status=c_claves.next(); + if ( chk == true ) + DbsError(true,status); + } + if ( CodTabla == "re" ) { + //Si se busca la fila ... usando la clave primaria de la relación + c_registro=database.cursor("SELECT * FROM registro WHERE "+ clave +criterio , forupdate ); + status=c_registro.next(); + if ( chk == true ) + DbsError(true,status); + } + if ( CodTabla == "ab" ) { + //Si se busca la fila ... usando la clave primaria de la relación + c_albaranes=database.cursor("SELECT * FROM albaranes WHERE "+ clave +criterio , forupdate ); + status=c_albaranes.next(); + if ( chk == true ) + DbsError(true,status); + } + if ( CodTabla == "af" ) { + //Si se busca la fila ... usando la clave primaria de la relación + c_albafras=database.cursor("SELECT * FROM albafras WHERE "+ clave +criterio , forupdate ); + if ( chk == true ) + status=c_albafras.next(); + if ( chk == true ) + DbsError(true,status); + } + if ( CodTabla == "pa" ) { + //Si se busca la fila ... usando la clave primaria de la relación + c_parametros=database.cursor("SELECT * FROM parametros WHERE "+ clave +criterio , forupdate ); + status=c_parametros.next(); + if ( chk == true ) + DbsError(true,status); + } +} + +function LoadHidden(htmlBaseRef) { + writeln(''); + writeln(''); + writeln(''); + writeln(''); +} +function ObjHeadBar(valor,texto,obj) { + writeln('
'); + writeln(''); + writeln(' '); + writeln(' '); + writeln(' '); + writeln(' '); + writeln('
'); + writeln(' Logout'); + if ( obj != "rpt" ) { + if (!valor) + writeln("
"); + if (valor && request.nvo) + writeln("
"); + if (valor && !request.nvo && request.lock) + writeln("
"); + if (valor && !request.nvo && !request.lock) + writeln("
"); + if ( request.ViewFkey == "S" && request.lock ) + writeln(""); + if ( request.ViewFkey == "N" && request.lock ) + writeln(""); + } + if ( obj == "ab_" && request.lock) { + writeln(""); + writeln(""); + } + if ( obj == "fa_" && request.lock) { + writeln(""); + writeln(""); + } + writeln(' '); + writeln(' Volver

'); + writeln(' '+texto+''); + writeln('

'); + if ( obj != "rpt" ) { + if (request.lock) + writeln('
'); + if (valor && !request.nvo ) + writeln(""); + } + writeln('
'); + writeln(' Ayuda
'); + writeln('
'); +} +function QueryHeadBar(texto,criterio,obj) { + writeln('
'); + writeln(''); + writeln(' '); + writeln(' '); + writeln(' '); + writeln(' '); + writeln(' '); + writeln('
'); + writeln(' '); + writeln(' Logout
'); + if ( obj != "rpt" ) { + if (client.acl != 1 && !request.waux) + writeln(' '); + } + writeln(' '); + writeln(' Volver

'); + writeln(' '+texto+'
'); + writeln(''); + writeln(' '+criterio+'

'); + writeln(' '); + writeln(' Volver
'); + writeln(' '); + writeln(' Ayuda
'); + writeln('
'); +} +function execMainFrm(obj) { + var accion=obj.name; + var mainFrame=find_frame(top,"main"); + var f_form=mainFrame.document.forms[0]; + if ( accion == "add" ) { + if (mainFrame.Chek_fields(f_form) == true) { + f_form.action=f_form.htmlBaseRef.value+"&add=1"; + f_form.submit(); + } + } + if ( accion == "Actualizar" ) { + if (mainFrame.Chek_fields(f_form) == true) { + f_form.action=f_form.htmlBaseRef.value+"&upd=1"; + f_form.submit(); + } + } + if ( accion == "Modificar" ) { + f_form.action=f_form.htmlBaseRef.value+"&lock=true"; + f_form.submit(); + } + if ( accion == "Ir a" ) + mainFrame.Enfoca("Ir a"); + if ( accion == "Refrescar" ) { + f_form.action=f_form.htmlBaseRef.value+"&cookie=1&lock=true"; + f_form.submit(); + } + if ( accion == "Deshacer" ) + f_form.reset(); + if ( accion == "Borrar" ) { + f_form.action=f_form.htmlBaseRef.value+"&del=1"; + f_form.submit(); + } + if ( accion == "Cta." ) + mainFrame.Enfoca("linCta"); + if ( accion == "Alb." ) + mainFrame.Enfoca("linAlb"); +}; + +function ObjButtons(valor,texto,obj) { + writeln(' ndoc.close();'); + writeln(' ndoc.open();'); + writeln(' ndoc.clear();'); + writeln(' ndoc.writeln(\'\');'); +// writeln(' ndoc.writeln(\'\');'); + writeln(' ndoc.writeln(\'\');'); + writeln(' ndoc.writeln(\'
\');'); + writeln(' ndoc.writeln(\'
\');'); + writeln(' ndoc.writeln(\'\');'); + writeln(' ndoc.writeln(\' \');'); + writeln(' ndoc.writeln(\' \');'); + writeln(' ndoc.writeln(\' \');'); + writeln(' ndoc.writeln(\' \');'); + writeln(' ndoc.writeln(\'
\');'); + writeln(' ndoc.writeln(\' Logout\');'); + if ( obj != "rpt" ) { + if (!valor) + writeln(' ndoc.writeln(\'
\');'); + if (valor && request.nvo) + writeln(' ndoc.writeln(\'
\');'); + if (valor && !request.nvo && request.lock) + writeln(' ndoc.writeln(\'
\');'); + if (valor && !request.nvo && !request.lock) + writeln(' ndoc.writeln(\'
\');'); + if ( request.ViewFkey == "S" && request.lock ) + writeln(' ndoc.writeln(\'\');'); + if ( request.ViewFkey == "N" && request.lock ) + writeln(' ndoc.writeln(\'
\');'); + } + if ( obj == "ab_") { + writeln(' ndoc.writeln(\'\');'); + writeln(' ndoc.writeln(\'\');'); + } + if ( obj == "fa_") { + writeln(' ndoc.writeln(\'\');'); + writeln(' ndoc.writeln(\'\');'); + } +// writeln(' ndoc.writeln(\' \');'); +// writeln(' ndoc.writeln(\' Volver

\');'); + writeln(' ndoc.writeln(\' '+texto+'\');'); + writeln(' ndoc.writeln(\'

\');'); + if ( obj != "rpt" ) { + if (request.lock) + writeln(' ndoc.writeln(\'
\');'); + if (valor && !request.nvo ) + writeln(' ndoc.writeln(\'\');'); + } + writeln(' ndoc.writeln(\'
\');'); +// writeln(" ndoc.writeln(' ');"); + writeln(' ndoc.writeln(\' Ayuda
\');'); + writeln(' ndoc.writeln(\'
\');'); + writeln(' ndoc.close();'); +} +function QueryButtons(texto,criterio,obj) { + writeln(' ndoc.close();'); + writeln(' ndoc.open();'); + writeln(' ndoc.clear();'); + writeln(' ndoc.writeln(\'\');'); + writeln(' ndoc.writeln(\'\');'); + writeln(' ndoc.writeln(\'
\');'); + writeln(' ndoc.writeln(\'
\');'); + writeln(' ndoc.writeln(\'\');'); + writeln(' ndoc.writeln(\' \');'); + writeln(' ndoc.writeln(\' \');'); + writeln(' ndoc.writeln(\' \');'); + writeln(' ndoc.writeln(\' \');'); + writeln(' ndoc.writeln(\'
\');'); + writeln(' ndoc.writeln(\' Logout\');'); + if ( obj != "rpt" ) { + if (client.acl != 1 && !request.waux) + writeln(' ndoc.writeln(\' \');'); + } +// writeln(' ndoc.writeln(\' \');'); +// writeln(' ndoc.writeln(\' Volver

\');'); + writeln(' ndoc.writeln(\' '+texto+'
\');'); + writeln(' ndoc.writeln(\'\');'); + writeln(' ndoc.writeln(\' '+criterio+'

\');'); + writeln(' ndoc.writeln(\' \');'); +// writeln(" ndoc.writeln(' ');"); + writeln(' ndoc.writeln(\' Ayuda
\');'); + writeln(' ndoc.writeln(\'
\');'); + writeln(' ndoc.close();'); +} + +function writeSignature(showfull) { + if (showfull == true) { + writeln('

'); + writeln(''); + writeln(' '); + writeln(' '); + writeln(' '); + writeln(' '); + writeln(' '); + writeln('
'); + writeln(' '); + writeln(' '); + writeln(' '); + writeln(' '); + writeln(' '); + writeln(' '); + writeln(' Dpto. Cuentas a Pagar'); + writeln(' '); + writeln('
'); + writeln('
'); + } + writeln('
'); + writeln(''); + writeln('Contactar con: '); + writeln(''); + writeln(' Departamento de Cuentas a Pagar
'); + writeln('
'); + writeln('
Copyright © 1997 '); + writeln(''); + writeln(' Construcciones SANDO SA'); + writeln(''); + writeln('& '); + writeln(''); + writeln(' AdmiSys SL'); + writeln(''); + writeln(''); + writeln('
Rev. 1.0
'); + writeln(''); + writeln(' webteam@admisys.com'); + writeln(''); + writeln('
'); +} + +function LoadParametros() { + UnLoadParametros(); + c_param = database.cursor("select * from parametros where id=1"); + if (c_param.next()) { + client.pa_id = c_param.id; + client.pa_nro_reg = StringClip(false,c_param.nro_reg); + client.pa_longcta = c_param.longcta; + client.pa_dia_pago_1 = c_param.dia_pago_1; + client.pa_dia_pago_2 = c_param.dia_pago_2; + client.pa_ex_dia_pago = StringClip(false,c_param.ex_dia_pago); + client.pa_iva_1 = c_param.iva_1; + client.pa_iva_2 = c_param.iva_2; + client.pa_iva_3 = c_param.iva_3; + client.pa_reten_1 = c_param.reten_1; + client.pa_cta_reten_1 = StringClip(false,c_param.cta_reten_1); + client.pa_clave_reten_1 = StringClip(false,c_param.clave_reten_1); + client.pa_reten_2 = c_param.reten_2; + client.pa_cta_reten_2 = StringClip(false,c_param.cta_reten_2); + client.pa_clave_reten_2 = StringClip(false,c_param.clave_reten_2); + client.pa_cta_iva = StringClip(false,c_param.cta_iva); + client.pa_clave_iva = StringClip(false,c_param.clave_iva); + client.pa_cta_cont = StringClip(false,c_param.cta_cont); + client.pa_clave_cont = StringClip(false,c_param.clave_cont); + client.pa_cta_comp = StringClip(false,c_param.cta_comp); + client.pa_clave_comp = StringClip(false,c_param.clave_comp); + client.pa_cta_coniva = StringClip(false,c_param.cta_coniva); + client.pa_clave_coniva = StringClip(false,c_param.clave_coniva); + client.pa_cta_siniva = StringClip(false,c_param.cta_siniva); + client.pa_clave_siniva = StringClip(false,c_param.clave_siniva); + client.pa_cta_dev = StringClip(false,c_param.cta_dev); + client.pa_clave_dev = StringClip(false,c_param.clave_dev); + client.pa_cp_lock = StringClip(false,c_param.cp_lock); + } + c_param.close(); +} +function SetParametros() { + writeln('// Variables de Entorno '); + writeln(' pa_id='+ client.pa_id + ' ;'); + writeln(' pa_nro_reg='+ client.pa_nro_reg + ' ;'); + writeln(' pa_nro_remesa='+ client.pa_nro_remesa + ' ;'); + writeln(' pa_longcta='+ client.pa_longcta + ' ;'); + writeln(' pa_dia_pago_1='+ client.pa_dia_pago_1 + ' ;'); + writeln(' pa_dia_pago_2='+ client.pa_dia_pago_2 + ' ;'); + writeln(' pa_ex_dia_pago='+ client.pa_ex_dia_pago + ' ;'); + writeln(' pa_iva_1='+ client.pa_iva_1 + ' ;'); + writeln(' pa_iva_2='+ client.pa_iva_2 + ' ;'); + writeln(' pa_iva_3='+ client.pa_iva_3 + ' ;'); + writeln(' pa_reten_1='+ client.pa_reten_1 + ' ;'); + writeln(' pa_cta_reten_1="'+ client.pa_cta_reten_1 + '" ;'); + writeln(' pa_clave_reten_1="'+ client.pa_clave_reten_1 + '" ;'); + writeln(' pa_reten_2='+ client.pa_reten_2 + ' ;'); + writeln(' pa_cta_reten_2="'+ client.pa_cta_reten_2 + '" ;'); + writeln(' pa_clave_reten_2="'+ client.pa_clave_reten_2 + '" ;'); + writeln(' pa_cta_iva="'+ client.pa_cta_iva + '" ;'); + writeln(' pa_clave_iva="'+ client.pa_clave_iva + '" ;'); + writeln(' pa_cta_cont="'+ client.pa_cta_cont + '" ;'); + writeln(' pa_clave_cont="'+ client.pa_clave_cont + '" ;'); + writeln(' pa_cta_comp="'+ client.pa_cta_comp + '" ;'); + writeln(' pa_clave_comp="'+ client.pa_clave_comp + '" ;'); + writeln(' pa_cta_coniva="'+ client.pa_cta_coniva + '" ;'); + writeln(' pa_clave_coniva="'+ client.pa_clave_coniva + '" ;'); + writeln(' pa_cta_siniva="'+ client.pa_cta_siniva + '" ;'); + writeln(' pa_clave_siniva="'+ client.pa_clave_siniva + '" ;'); + writeln(' pa_cta_dev="'+ client.pa_cta_dev + '" ;'); + writeln(' pa_clave_dev="'+ client.pa_clave_dev + '" ;'); + writeln(' pa_cp_lock="'+ client.pa_cp_lock + '" ;'); + writeln(' baseHtml="'+ baseHtml + '" ;'); + writeln('//'); + } +function UnLoadParametros() { + client.pa_id = null; + client.pa_nro_reg = null; + client.pa_nro_remesa = null; + client.pa_longcta = null; + client.pa_dia_pago_1 = null; + client.pa_dia_pago_2 = null; + client.pa_ex_dia_pago = null; + client.pa_iva_1 = null; + client.pa_iva_2 = null; + client.pa_iva_3 = null; + client.pa_reten_1 = null; + client.pa_cta_reten_1 = null; + client.pa_calve_reten_1 = null; + client.pa_reten_2 = null; + client.pa_cta_reten_1 = null; + client.pa_calve_reten_1 = null; + client.pa_cta_iva = null; + client.pa_clave_iva = null; + client.pa_cta_cont = null; + client.pa_clave_cont = null; + client.pa_cta_comp = null; + client.pa_clave_comp = null; + client.pa_cta_siniva = null; + client.pa_clave_siniva = null; + client.pa_cta_coniva = null; + client.pa_clave_coniva = null; + client.pa_cta_dev = null; + client.pa_clave_dev = null; + client.pa_cp_lock = null; +} + +function CtaNroPad(obj) { + if ( obj.value.length == 0 ) + return; + var nro=parseInt(obj.value); + if ( nro+1 > 0 ) + var c_nro=nro+""; + else { + alert("El dato: '"+obj.value+"' Contiene caracteres no válidos"); + obj.focus(); + return; + } + for (var j=c_nro.length ; j pa_longcta ) { + alert("La cuenta: '"+obj.value+"' contiene más caracteres !!! "); + obj.focus(); + } +} + +function substCta(stringCta,formato) { + if (!formato) + return stringCta+" "; + var nro=""; + nro=NroUnformat(stringCta+" "); + if ( nro.length > 0 ) + c_nro=nro+" "; + else + return "0" ; + var cadena=""; + var nrolon=c_nro.length; + var f_size=formato.length; + var f_char=""; + for (var i=0; i < f_size ; i++) { + f_char=formato.substring(i,i+1); +// alert(cadena+"--"+i+"-"+c_nro.substring(i,i+1)+"--"+formato.substring(i,i+1)) + if ( f_char == "?" ) + cadena=cadena+c_nro.substring(i,i+1); + if ( f_char == "*" ) { + cadena=cadena+c_nro.substring(i,nrolon); + break; + } + if ( f_char != "*" && f_char != "?" ) + cadena=cadena+f_char; + } + return cadena; +} + +function getSeqPrt(nprinter) { + var nomFile=spoolpath+nprinter+"/seq"; + var seqprtfile=new File(nomFile); + project.lock(); + seqprtfile.open("r"); + s_seq=seqprtfile.readln(); + seqprtfile.close(); + var n_seq=parseInt(s_seq); + if ( n_seq > 0 ) + n_seq++; + else + n_seq=1; + seqprtfile.open("w"); + seqprtfile.write(n_seq); + seqprtfile.close(); + project.unlock(); + return n_seq; +} + +function skipTopPage(nrolinea,PaperLines){ + for (nl=nrolinea ; nl <= PaperLines ; nl++) + fileRpt.writeln("
"); +} \ No newline at end of file diff --git a/factura.js b/factura.js new file mode 100644 index 0000000..8c3d08f --- /dev/null +++ b/factura.js @@ -0,0 +1,652 @@ +// // +// JavaScript Functions // +// // +////////////////////////////////////// + +function wfra(text){ + writeln("w_outfra.document.write('"+text+"\\n');"); +} + +function InsFraLins() { + if ( !request.fa_nro_reg ) { + status=-1 + return; + } + var nl=0; + var nrolineas=0; + var nroctas=0; + nrolineas=parseInt(request.nrolineas); + if ( nrolineas+1 > 1 ) { + for (nl=1;nl<=nrolineas;nl++) { + eval('if ( request.af_'+nl+'_nroreg_albaran && request.af_'+nl+'_nroreg_albaran.length > 0 && NroUnformat(request.af_'+nl+'_sumaCtas)!= 0) { '+ + 'status=database.execute("INSERT INTO albafras(" +'+ + '" nroreg_albafact," +'+ + '" nroreg_factura," +'+ + '" nroreg_albaran," +'+ + '" sumactas," +'+ + '" observaciones ) VALUES (\'" + StringClip(true,request.af_'+nl+'_nroreg_albafact) + "\',\'" +'+ + 'StringClip(true,request.fa_nro_reg) + "\',\'"+'+ + 'StringClip(true,request.af_'+nl+'_nroreg_albaran) + "\',\'"+ '+ + 'NroUnformat(request.af_'+nl+'_sumaCtas) + "\',\'"+ '+ + 'StringClip(true,request.af_'+nl+'_observaciones) + "\')");}'); + if ( status != 0 ) { + client.is_trans=false; + database.rollbackTransaction(); + redirect('error.html?alert=11') + } + DbsError(true,status); + eval('if ( request.af_'+nl+'_nroreg_albaran.length > 0 ) { '+ + 'status=database.execute("UPDATE albaranes SET" +'+ + '" is_locked=\'S\',"+'+ + '" fra_reg=\'"+'+ + 'StringClip(true,request.fa_nro_reg)+"\'"+'+ + '" WHERE nro_reg = \'"+'+ + 'StringClip(true,request.af_'+nl+'_nroreg_albaran)+"\'")}') +// eval('if ( request.af_'+nl+'_nroreg_albaran && request.af_'+nl+'_nroreg_albaran.length > 0 ) { '+ + if ( status != 0 ) { + client.is_trans=false; + database.rollbackTransaction(); + eval("redirect('error.html?alert=14?key='+request.af_"+nl+"_nroreg_albaran)"); + } + } + } + nroctas=parseInt(request.nroctas); + if ( nroctas+1 > 1 ) { + for (nl=1;nl<=nroctas;nl++) { +// ' request.acf_'+nl+'_concepto=StringClip(true,request.acf_'+nl+'_concepto)+request.fa_nro_reg.substring(4,10)+" "+request.fa_nro_fra+" "+request.fa_t_razon_social;}'); + eval(' if ( request.acf_'+nl+'_concepto.substring(0,4) == " " ) {'+ + ' request.acf_'+nl+'_concepto=request.fa_nro_fra+" "+request.fa_nro_reg.substring(4,10)+" "+request.fa_t_razon_social;}'); + eval(' if ( request.acf_'+nl+'_concepto.substring(0,1) == "-" ) {'+ + ' request.acf_'+nl+'_concepto="-"+request.fa_nro_fra+" "+request.fa_nro_reg.substring(4,10)+" "+request.fa_t_razon_social;}'); + eval(' if ( request.acf_'+nl+'_concepto.substring(0,2) == "--" ) {'+ + ' request.acf_'+nl+'_concepto="--"+request.fa_nro_fra+" "+request.fa_nro_reg.substring(4,10)+" "+request.fa_t_razon_social;}'); + eval(' if ( request.acf_'+nl+'_concepto.length < 4 ) {'+ + ' request.acf_'+nl+'_concepto=request.acf_'+nl+'_concepto.substring(0,2)+" "+request.fa_nro_fra+" "+request.fa_nro_reg.substring(4,10)+" "+request.fa_t_razon_social;}'); + eval(' if ( request.acf_'+nl+'_importe+0 != 0 && request.acf_'+nl+'_cod_cta.length > 2 ) {'+ + ' status=database.execute("INSERT INTO aptectasfra(" + '+ + '" nro_lin," + '+ + '" nro_reg," +'+ + '" tipolin," +'+ + '" albareg," +'+ + '" cod_cta," +'+ + '" clave," +'+ + '" concepto," +'+ + '" importe," +'+ + '" tipo_apte," +'+ + '" fecha ) VALUES (\'" + StringClip(true,request.acf_'+nl+'_nro_lin) + "\',\'" + '+ + 'StringClip(true,request.fa_nro_reg) + "\',\'"+'+ + 'StringClip(true,request.acf_'+nl+'_tipolin) + "\',\'"+'+ + 'StringClip(true,request.acf_'+nl+'_albareg) + "\',\'"+'+ + 'StringClip(true,request.acf_'+nl+'_cod_cta) + "\',\'"+'+ + 'StringClip(true,request.acf_'+nl+'_clave) + "\',\'"+'+ + 'StringClip(true,request.acf_'+nl+'_concepto) + "\',\'"+'+ + 'NroUnformat(request.acf_'+nl+'_importe) + "\',\'"+'+ + 'StringClip(true,request.acf_'+nl+'_tipo_apte) + "\',\'"+'+ + 'StringClip(true,datetoString(HOY)) + "\')");}'); + if ( status != 0 ) { + client.is_trans=false; + database.rollbackTransaction(); + redirect('error.html?alert=12') + } + DbsError(true,status); + } + } +} +function DelFraLins() { + status=database.execute("DELETE FROM albafras WHERE nroreg_factura = \'" + request.fa_nro_reg + "\'"); +// if ( status != 0 ) { +// client.is_trans=false; +// database.rollbackTransaction(); +// redirect('error.html') +// } +// DbsError(true,status); + status=database.execute("DELETE FROM aptectasfra WHERE nro_reg = \'" + request.fa_nro_reg + "\'"); +// if ( status != 0 ) { +// client.is_trans=false; +// database.rollbackTransaction(); +// redirect('error.html') +// } +// DbsError(true,status); +// Liberamos albaranes + status=database.execute("UPDATE albaranes SET" + + " is_locked='N',"+ + " fra_reg=''"+ + " WHERE fra_reg = '"+ + StringClip(true,request.fa_nro_reg)+"'"); + if ( status != 0 ) { + client.is_trans=false; + database.rollbackTransaction(); + eval("redirect('error.html?alert=14?key='+request.af_"+nl+"_nroreg_albaran)"); + } +} + +function ctasAlbtoFra(ialb,icta) { + eval('CursorTabla("ab","nro_reg","=\'"+request.af_'+ialb+'_nroreg_albaran+"\'",true,"");'); + // Asignamos a request todas las columnas necesarias para el form. + if ( c_albaranes.is_locked == "S" ) { + eval('request.af_'+ialb+'_nroreg_albaran="";'); + eval('request.af_'+nl+'_observaciones="ALBARAN BLOQUEADO";'); + eval('request.af_'+ialb+'_toblink="on";'); + c_albaranes.close(); + return; + } + var ab_nif="", ab_cod_centro="", ab_nro_pedido=""; + ab_nif=StringClip(false,c_albaranes.nif); + ab_cod_centro=StringClip(false,c_albaranes.cod_centro); + ab_nro_pedido=StringClip(false,c_albaranes.nro_pedido); + if ( ab_nif != null && ab_nif != request.fa_nif ) + eval('request.af_'+ialb+'_toblink="on";'); + if ( ab_cod_centro != null && ab_cod_centro != request.fa_cod_centro ) + eval('request.af_'+ialb+'_toblink="on";'); +// if ( ab_nro_pedido != null && ab_nro_pedido != request.fa_nro_pedido ) +// eval('request.af_'+ialb+'_toblink="on";'); + eval('request.af_'+ialb+'_nif=ab_nif'); + eval('request.af_'+ialb+'_nro_pedido=ab_nro_pedido'); + eval('request.af_'+ialb+'_cod_centro=ab_cod_centro'); + eval('CursorTabla("ac","nro_reg","=\'"+request.af_'+ialb+'_nroreg_albaran+"\'",false,"");'); + var sumaCtas=0; lin=0; + eval ('if ( parseInt(request.acf_'+(icta+1)+'importe) == 0 ) { lin=1 } '); + icta=icta-lin; + var acumula=false; + while (c_aptecuentas.next()) { + // Si la Cuenta ya existe hay que acumular + acumula=false; + for (var i=1; i <= icta ; i++ ) { + eval(' if (request.acf_'+i+'_cod_cta==StringClip(true,c_aptecuentas.cod_cta) '+ + ' && request.acf_'+i+'_clave==StringClip(true,c_aptecuentas.clave) '+ + ' && request.acf_'+i+'_concepto==StringClip(true,c_aptecuentas.concepto) '+ + ' && request.acf_'+i+'_tipo_apte==StringClip(true,c_aptecuentas.tipo_apte) )'+ + ' { acumula=true }'); + if ( acumula == true ) { + eval(' request.acf_'+i+'_importe=NroFormat('+ + ' parseFloat(NroUnformat(request.acf_'+i+'_importe))+c_aptecuentas.importe'+ + ',NF9);'); + break; + } + } + if ( acumula == false ) { // No ha acumulado la cuenta del albarán !!! + icta++; + eval(' request.acf_'+icta+'_esnva="0";'); + eval(' request.acf_'+icta+'_nro_lin='+icta+';'); + eval(' request.acf_'+icta+'_albareg=request.af_'+ialb+'_nroreg_albaran;'); + eval(' request.acf_'+icta+'_cod_cta=StringClip(true,c_aptecuentas.cod_cta);'); + eval(' request.acf_'+icta+'_clave=StringClip(true,c_aptecuentas.clave);'); + eval(' request.acf_'+icta+'_concepto=StringClip(true,c_aptecuentas.concepto);'); + eval(' request.acf_'+icta+'_tipo_apte=StringClip(true,c_aptecuentas.tipo_apte);'); + eval(' request.acf_'+icta+'_importe=NroFormat(c_aptecuentas.importe,NF9);'); + if ( c_aptecuentas.concepto.length < 3 || StringClip(false,c_aptecuentas.concepto)==" " ) { + if ( c_aptecuentas.importe < 0 ) + eval('request.acf_'+icta+'_concepto="A"'); + if ( c_aptecuentas.importe >= 0 ) + eval('request.acf_'+icta+'_concepto=""'); + } + eval(' if (request.acf_'+icta+'_concepto == " ") {request.acf_'+icta+'_concepto=""}'); + eval(' request.acf_'+icta+'_tipolin="A";'); + } + if (c_aptecuentas.tipo_apte == "D" ) + sumaCtas=sumaCtas+c_aptecuentas.importe; + if (c_aptecuentas.tipo_apte == "H" ) + sumaCtas=sumaCtas-c_aptecuentas.importe; + } + c_aptecuentas.close() + if ( sumaCtas == 0 ) { + eval(' request.af_'+ialb+'_observaciones="¡¡ No existe o con Importe 0 !!";'); + } else { + eval(' request.af_'+ialb+'_esnva="0";'); + eval(' request.af_'+ialb+'_sumaCtas=NroFormat(sumaCtas,NF9);'); + eval(' request.af_'+ialb+'_observaciones=StringClip(false,c_albaranes.observaciones);'); + } + c_albaranes.close(); + request.nroctas=icta+lin; +} +function scanClaveCta(icta) { + var f=document.f_factura; +// eval("var clave=f.acf_"+icta+"_clave.value;"); +// alert("Clave:"+clave+" linea "+icta); +// eval("var importe=parseInt(NroUnforma(f.acf_"+icta+"_importe.value);"); + var SumaIVA=0; + var cta="", tipoApte="", tipoLin="", TipoRet="", TipoFra=""; + eval("SumaIVA=parseFloat(NroUnformat(f.fa_SumaIva.value));"); + eval("cta=f.acf_"+icta+"_cod_cta.value;"); + eval("tipoApte=get_value(\'select\',f.acf_"+icta+"_tipo_apte);"); + eval("tipoLin=f.acf_"+icta+"_tipolin.value;"); + TipoRet=get_value("select",f.fa_tipo_retencion); + TipoFra=get_value("select",f.fa_tipo_fra); + if ( tipoLin == "G" && SumaIVA == 0 ) { eval("f.acf_"+icta+"_clave.value=pa_clave_siniva;"); } + if ( tipoLin == "G" && SumaIVA > 0 ) { eval("f.acf_"+icta+"_clave.value=pa_clave_coniva;"); } + if ( tipoLin == "G" && SumaIVA < 0 ) { eval("f.acf_"+icta+"_clave.value=pa_clave_coniva;"); } +// if ( tipoApte == "D" ) { } +// if ( tipoApte == "H" ) { } + if ( TipoFra=="1") { // Albarán Interno + } + if ( TipoFra=="2") { // Dev. Retención + if ( tipoLin == "G" || tipoLin == "R" ) { eval("f.acf_"+icta+"_clave.value=pa_clave_dev;"); }; + } + if ( TipoFra=="4") { // Sin Albaranes + } + if ( TipoRet=="0") { // Sin Retención + } + if ( TipoRet=="1") { // IRPF + if ( tipoLin == "G" || tipoLin == "R" ) { eval("f.acf_"+icta+"_clave.value=pa_clave_reten_1;"); } + } + if ( TipoRet=="2") { // Por Garantía + if ( tipoLin == "G" || tipoLin == "R" ) { eval("f.acf_"+icta+"_clave.value=pa_clave_reten_2;"); } + } + if ( TipoCalculo=="1") { // Sobre Base + } else { // Sobre Base - Retención + } +// eval("var clave=f.acf_"+icta+"_clave.value;"); +// alert("Clave:"+clave); +} + +function FraDocHtml(nro_reg) { + var s_seq=getSeqPrt(nprinter); + textoReqs=textoReqs+" "+s_seq; + var nomFile=spoolpath+nprinter+"/req_"+s_seq+".html" + fileRpt=new File(nomFile); + fileRpt.open("w"); + fileRpt.writeln(''); + nrolin=1; + CursorTabla("fa","nro_reg","=\'"+nro_reg+"\'",true,""); + // Asignamos a request todas las columnas necesarias para el form. + request.fa_nro_reg=StringClip(false,c_facturas.nro_reg); + var lon=request.fa_nro_reg.length; + request.fa_nro_regn=request.fa_nro_reg.substring(4,lon); + request.fa_nro_regy=request.fa_nro_reg.substring(0,4); + request.fa_f_emision=datetoString(c_facturas.f_emision); + request.fa_f_recepcion=datetoString(c_facturas.f_recepcion); + request.fa_f_pago=datetoString(c_facturas.f_pago); + request.fa_f_emision_pago=datetoString(c_facturas.f_emision_pago); + request.fa_mes=StringClip(false,c_facturas.mes); + request.fa_nro_fra=StringClip(false,c_facturas.nro_fra); + request.fa_nif=StringClip(false,c_facturas.nif); + request.fa_cod_centro=StringClip(false,c_facturas.cod_centro); + request.fa_cond_pago=StringClip(false,c_facturas.cond_pago); + request.fa_tipo_calc_iva=StringClip(false,c_facturas.tipo_calc_iva); + request.fa_tipo_fra=StringClip(false,c_facturas.tipo_fra); + request.fa_tipo_doc_pago=StringClip(false,c_facturas.tipo_doc_pago); + request.fa_nro_doc_pago=StringClip(true,c_facturas.nro_doc_pago); + request.fa_cod_localidad=StringClip(false,c_facturas.cod_localidad); + request.fa_cod_banco=StringClip(true,c_facturas.cod_banco); + request.fa_base_1=NroFormat(c_facturas.base_1,NF11); + request.fa_por_ret1=NroFormat(c_facturas.por_ret1,NF2); + request.fa_ret_1=NroFormat(c_facturas.ret_1,NF9); + request.fa_por_iva1=NroFormat(c_facturas.por_iva1,NF2); + request.fa_iva_1=NroFormat(c_facturas.iva_1,NF9); + request.fa_base_2=NroFormat(c_facturas.base_2,NF11); + request.fa_por_ret2=NroFormat(c_facturas.por_ret2,NF2); + request.fa_ret_2=NroFormat(c_facturas.ret_2,NF9); + request.fa_por_iva2=NroFormat(c_facturas.por_iva2,NF2); + request.fa_iva_2=NroFormat(c_facturas.iva_2,NF9); + request.fa_base_3=NroFormat(c_facturas.base_3,NF11); + request.fa_por_ret3=NroFormat(c_facturas.por_ret3,NF2); + request.fa_ret_3=NroFormat(c_facturas.ret_3,NF9); + request.fa_por_iva3=NroFormat(c_facturas.por_iva3,NF2); + request.fa_iva_3=NroFormat(c_facturas.iva_3,NF9); + request.fa_canexen=NroFormat(c_facturas.canexen,NF11); + request.fa_SumaBase=NroFormat(c_facturas.base_1+c_facturas.base_2+c_facturas.base_3+c_facturas.canexen,NF11); + request.fa_SumaIva=NroFormat(c_facturas.iva_1+c_facturas.iva_2+c_facturas.iva_3,NF11); + request.fa_SumaRet=NroFormat(c_facturas.ret_1+c_facturas.ret_2+c_facturas.ret_3,NF11); +// if ( c_facturas.tipo_calc_iva == 2 ) + fa_Totaf_1=c_facturas.base_1+c_facturas.iva_1-c_facturas.ret_1; +// else +// fa_Totaf_1=c_facturas.base_1+c_facturas.iva_1+c_facturas.ret_1; +// if ( c_facturas.tipo_calc_iva == 2 ) + fa_Totaf_2=c_facturas.base_2+c_facturas.iva_2-c_facturas.ret_2; +// else +// fa_Totaf_2=c_facturas.base_2+c_facturas.iva_2+c_facturas.ret_2; +// if ( c_facturas.tipo_calc_iva == 2 ) + fa_Totaf_3=c_facturas.base_3+c_facturas.iva_3-c_facturas.ret_3; +// else +// fa_Totaf_3=c_facturas.base_3+c_facturas.iva_3+c_facturas.ret_3; + var fa_Totex=c_facturas.canexen; + request.fa_Totaf_1=NroFormat(fa_Totaf_1,NF11); + request.fa_Totaf_2=NroFormat(fa_Totaf_2,NF11); + request.fa_Totaf_3=NroFormat(fa_Totaf_3,NF11); + request.fa_Totex=NroFormat(c_facturas.canexen,NF11); + request.fa_deducciones=NroFormat(c_facturas.deducciones,NF9); + request.fa_SumaImporte=NroFormat(fa_Totaf_1+fa_Totaf_2+fa_Totaf_3+fa_Totex,NF11); + request.fa_importe_total=NroFormat(fa_Totaf_1+fa_Totaf_2+fa_Totaf_3+fa_Totex-c_facturas.deducciones,NF11); + request.fa_tipo_retencion=StringClip(true,c_facturas.tipo_retencion); + request.fa_tipo_deduccion=StringClip(true,c_facturas.tipo_deduccion); + request.fa_nro_pedido=StringClip(false,c_facturas.nro_pedido); + request.fa_traspaso_gasto=StringClip(false,c_facturas.traspaso_gasto); + request.fa_traspaso_vto=StringClip(false,c_facturas.traspaso_vto); + request.fa_traspaso_pago=StringClip(false,c_facturas.traspaso_pago); + request.fa_nro_reg_pago=StringClip(false,c_facturas.nro_reg_pago); + request.fa_vto_pago=datetoString(c_facturas.vto_pago); + request.fa_observaciones=StringClip(false,c_facturas.observaciones); + request.fa_is_locked=StringClip(false,c_facturas.is_locked); + if (request.lock) + c_facturas.close(); + if (request.fa_is_locked == "S" ) + request.waux=8; + if (request.fa_cod_centro && request.fa_cod_centro != null) { + CursorTabla("ce","cod_centro","=\'"+StringClip(true,request.fa_cod_centro)+"\'",false,false); + request.fa_t_des_centro=c_centros.descripcion; + c_centros.close(); + } + else + request.fa_t_des_centro=""; + if (request.fa_nro_pedido && request.fa_nro_pedido != null) { + CursorTabla("pe","nro_pedido","=\'"+StringClip(true,request.fa_nro_pedido)+"\'",false,false); + request.fa_t_des_pedido=c_pedidos.descripcion; + if (request.fa_cond_pago.length==0) + request.fa_cond_pago=c_pedidos.cond_pago; + c_pedidos.close(); + } + else + request.fa_t_des_pedido=""; + if (request.fa_nif && request.fa_nif != null ) { + CursorTabla("pr","nif","=\'"+StringClip(true,request.fa_nif)+"\'",false,false); + request.fa_t_razon_social=StringClip(false,c_proveedores.razon_social); + if ( request.fa_t_razon_social == " " ) { + request.fa_t_razon_social="NO EXISTE"; + request.fa_cta_contable=""; + } + else { + request.fa_cta_contable=StringClip(false,c_proveedores.cta_contable); + if (request.fa_cond_pago.length==0 || request.fa_cond_pago==client.pa_cp_lock) + request.fa_cond_pago=c_proveedores.cond_pago; + } + c_proveedores.close(); + } + else { + request.fa_t_razon_social=""; + request.fa_cta_contable=""; + } + if (request.fa_cond_pago && request.fa_cond_pago != null) { + CursorTabla("cp","cond_pago","=\'"+StringClip(true,request.fa_cond_pago)+"\'",false,false); + request.fa_t_condpago=c_cond_pago.descripcion; + request.fa_cp_vto=c_cond_pago.vencimiento; + c_cond_pago.close(); + } + else { + request.fa_cp_vto=0 + request.fa_t_condpago=""; + } + if (request.fa_cod_banco && request.fa_cod_banco != null) { + CursorTabla("ba","cod_banco","=\'"+StringClip(true,request.fa_cod_banco)+"\'",false,false); + request.fa_t_nombre_banco=c_bancos.nombre; + c_bancos.close(); + } + else + request.fa_t_nombre_banco=""; + fileRpt.writeln('
'); + fileRpt.writeln(''); + if ( request.fa_is_locked == "S" ) + fileRpt.writeln('Bloqueada:'+request.fa_is_locked+''); + fileRpt.writeln(''); + nrolin++; + fileRpt.writeln(''); + nrolin++; + fileRpt.writeln(''); + fileRpt.writeln(''); + fileRpt.writeln(''); + nrolin++; + fileRpt.writeln(''); + fileRpt.writeln(''); + nrolin++; + fileRpt.writeln(''); + fileRpt.writeln(''); + nrolin++; + fileRpt.writeln(''); + nrolin++; + fileRpt.writeln(''); + fileRpt.writeln(''); + nrolin++; + fileRpt.writeln(''); + nrolin++; + fileRpt.writeln(''); + nrolin++; + fileRpt.writeln('
Nro.Reg.: '); + fileRpt.writeln(''+request.fa_nro_regn+'/'+request.fa_nro_regy+'
Contabilizado:'); + fileRpt.writeln(''+request.fa_mes+'
Nro. Fra.:'); + fileRpt.writeln(''+request.fa_nro_fra+'
N.I.F. '); + fileRpt.writeln(''+request.fa_nif+''+request.fa_t_razon_social+''); + nrolin++; + fileRpt.writeln('
Centro'); + fileRpt.writeln(''+request.fa_cod_centro+''+request.fa_t_des_centro+'
Pedido'); + fileRpt.writeln(''+request.fa_nro_pedido+''+request.fa_t_des_pedido+'
C.Pago'); + fileRpt.writeln(''+request.fa_cond_pago+''+request.fa_t_condpago+'
Fecha Emisión:'); + fileRpt.writeln(''+request.fa_f_emision+'
Fecha Recepción:'); + fileRpt.writeln(''+request.fa_f_recepcion+'Fecha Pago:'); + fileRpt.writeln(''+request.fa_f_pago+'
Tipo de Factura:'); + if (request.fa_tipo_fra=="1") + fileRpt.writeln(' De Albarán Interno '); + if (request.fa_tipo_fra=="2") + fileRpt.writeln(' Devolución Retención '); + if (request.fa_tipo_fra=="4") + fileRpt.writeln(' Sin Albaranes '); + nrolin++; + fileRpt.writeln('
Retenciones:'); + if (request.fa_tipo_retencion=="0") + fileRpt.writeln(' Sin Retencion '); + if (request.fa_tipo_retencion=="1") + fileRpt.writeln(' I.R.P.F. '); + if (request.fa_tipo_retencion=="2") + fileRpt.writeln(' Por Garantía '); + fileRpt.writeln('
Cálculo IVA:'); + if (request.fa_tipo_calc_iva=="1") + fileRpt.writeln(' Sobre Base '); + else + fileRpt.writeln(' Sobre Base - Retención '); + fileRpt.writeln('
'); + fileRpt.writeln('
'); + fileRpt.writeln(''); + fileRpt.writeln(''); + fileRpt.writeln(''); + fileRpt.writeln(''); + fileRpt.writeln(''); + fileRpt.writeln(''); + fileRpt.writeln(''); + fileRpt.writeln(''); + fileRpt.writeln(''); + fileRpt.writeln(''); + nrolin++; + fileRpt.writeln(''); + fileRpt.writeln(''); + fileRpt.writeln(''); + fileRpt.writeln(''); + fileRpt.writeln(''); + fileRpt.writeln(''); + fileRpt.writeln(''); + fileRpt.writeln(''); + nrolin++; + fileRpt.writeln(''); + fileRpt.writeln(''); + fileRpt.writeln(''); + fileRpt.writeln(''); + fileRpt.writeln(''); + fileRpt.writeln(''); + fileRpt.writeln(''); + fileRpt.writeln(''); + nrolin++; + fileRpt.writeln(''); + fileRpt.writeln(''); + fileRpt.writeln(''); + fileRpt.writeln(''); + fileRpt.writeln(''); + fileRpt.writeln(''); + fileRpt.writeln(''); + fileRpt.writeln(''); + nrolin++; + fileRpt.writeln(''); + fileRpt.writeln(''); + fileRpt.writeln(''); + fileRpt.writeln(''); + fileRpt.writeln(''); + nrolin++; + fileRpt.writeln(''); + fileRpt.writeln(''); + fileRpt.writeln(''); + fileRpt.writeln(''); + fileRpt.writeln(''); + fileRpt.writeln(''); + fileRpt.writeln(''); + nrolin++; + fileRpt.writeln(''); + fileRpt.writeln(''); + fileRpt.writeln(''); + fileRpt.writeln(''); + fileRpt.writeln(''); + nrolin++; + fileRpt.writeln(''); + fileRpt.writeln(''); + fileRpt.writeln(''); + fileRpt.writeln(''); + fileRpt.writeln('
Lin Base Imponible %Ret Imp. Ret %IVA Imp. IVA T O T A L
1.-'+request.fa_base_1+''+request.fa_por_ret1+''+request.fa_ret_1+''+request.fa_por_iva1+''+request.fa_iva_1+''+request.fa_Totaf_1+'
2.-'+request.fa_base_2+''+request.fa_por_ret2+''+request.fa_ret_2+''+request.fa_por_iva2+''+request.fa_iva_2+''+request.fa_Totaf_2+'
3.-'+request.fa_base_3+''+request.fa_por_ret3+''+request.fa_ret_3+''+request.fa_por_iva3+''+request.fa_iva_3+''+request.fa_Totaf_3+'
Ex.'+request.fa_canexen+'------------------------'+request.fa_Totex+'
Tot.'+request.fa_SumaBase+'---'+request.fa_SumaRet+'---'+request.fa_SumaIva+''+request.fa_SumaImporte+'
Ded:'+request.fa_tipo_deduccion+'------------------------'+request.fa_deducciones+'
Totales------------------------'+request.fa_importe_total+'
'); + nrolin++; + fileRpt.writeln('

Apuntes Contables

'); + fileRpt.writeln(''); + nrolin++; + fileRpt.writeln(''); + fileRpt.writeln(''); + fileRpt.writeln(''); + fileRpt.writeln(''); + fileRpt.writeln(''); + fileRpt.writeln(''); + fileRpt.writeln(''); + var lin=0; + CursorTabla("acf","nro_reg","=\'"+c_facturas.nro_reg+"\' order by nro_lin ",false,""); + var SumaDebe=0; + var SumaHaber=0; + request.nroctas=0; + nl=0; + while (c_aptectasfra.next()) { + request.nroctas=c_aptectasfra.nro_lin; + nro=c_aptectasfra.importe; + nl=request.nroctas +// if ( nro == 0 && nl < 10 ) { + //fileRpt.writeln(""); +// continue; +// } + lin++; + if ( nrolin+1 > request.maxLins ) { + skipTopPage(nrolin,request.maxLins); + nrolin=0; + } + nrolin++; + fileRpt.writeln(''); + valor=c_aptectasfra.cod_cta; + if (valor != " " && valor != "" && valor != "null" ) { + CursorTabla("ct","cta_contable","=\'"+StringClip(true,valor)+"\'",false,false); + texto=StringClip(true,c_ctas_contables.descripcion); + c_ctas_contables.close(); + } + else { + texto=" " + } + fileRpt.writeln(''); + if (c_aptectasfra.tipo_apte == "H") {SumaHaber=SumaHaber+nro} else {SumaDebe=SumaDebe+nro}; + if (c_aptectasfra.tipo_apte == "H") {fileRpt.writeln('')}; + fileRpt.writeln(''); + if (c_aptectasfra.tipo_apte == "D") {fileRpt.writeln('')}; + fileRpt.writeln(''); + fileRpt.writeln(''); + fileRpt.writeln(""); + } +// var acf_totalsaldo=NroFormat(SumaDebe-SumaHaber+" ",NF11); + c_aptectasfra.close(); + nrolin++; + fileRpt.writeln(''); + fileRpt.writeln(''); + fileRpt.writeln(''); + fileRpt.writeln(''); + fileRpt.writeln(''); + fileRpt.writeln('
N. CuentaTítulo CuentaDebe Haber ClaveConcepto
'+c_aptectasfra.nro_lin+'') +// var albareg=c_aptectasfra.albareg; + fileRpt.writeln(''+c_aptectasfra.cod_cta+''+texto+'-'+NroFormat(c_aptectasfra.importe,NF9)+'-'+c_aptectasfra.clave+''+c_aptectasfra.concepto+'
--Totales ... '+NroFormat(SumaDebe+" ",NF11)+''+NroFormat(SumaHaber+" ",NF11)+'--
'); + fileRpt.writeln(''); + nrolin++; + fileRpt.writeln('

Albaranes

'); + nrolin++; + fileRpt.writeln(''); + fileRpt.writeln(''); + fileRpt.writeln(' '); + fileRpt.writeln(''); + fileRpt.writeln(''); + fileRpt.writeln(''); + CursorTabla("af","nroreg_factura","=\'"+c_facturas.nro_reg+"\'",false,""); + var sumalbs=0; + request.nrolineas=0; + while (c_albafras.next()) { + request.nrolineas++; + sumalbs=sumalbs+parseFloat(c_albafras.sumactas); + nrolin++; + fileRpt.writeln(''); + fileRpt.writeln(''); + fileRpt.writeln(''); + fileRpt.writeln(''); + fileRpt.writeln(''); + } + c_albafras.close() + nrolin++; + fileRpt.writeln(''); + fileRpt.writeln(''); + fileRpt.writeln(''); + fileRpt.writeln(''); + fileRpt.writeln('
N. Nro.Reg Suma Ctas.O b s e r v a c i o n e s
'); + fileRpt.writeln(''+c_albafras.nroreg_albafact+''); + fileRpt.writeln(''+c_albafras.nroreg_albaran+''+NroFormat(c_albafras.sumactas,NF9)+''+c_albafras.observaciones+'
Total:'+NroFormat(sumalbs,NF9)+'
'); +// if (request.f_formato=="documento") { + fileRpt.writeln('
'); + fileRpt.writeln(''); + fileRpt.writeln(''); + fileRpt.close(); + return nrolin; +// } + nrolin++; + fileRpt.writeln('

Datos de Pago

'); + fileRpt.writeln(''); + nrolin++; + fileRpt.writeln(''); + fileRpt.writeln(''); + nrolin++; + fileRpt.writeln(''); + nrolin++; + fileRpt.writeln(''); + nrolin++; + fileRpt.writeln(''); + fileRpt.writeln(''); + nrolin++; + fileRpt.writeln(''); + fileRpt.writeln('
Banco: '); + fileRpt.writeln(''+request.fa_cod_banco+''+request.fa_t_nombre_banco+'
Localidad:'); + fileRpt.writeln(''+request.fa_cod_localidad+'
Fecha Emisión:'); + fileRpt.writeln(''+request.fa_f_emision_pago+'
Tipo Doc. Pago:'); + if (request.fa_tipo_doc_pago=="1") + fileRpt.writeln(' Pagaré '); + if (request.fa_tipo_doc_pago=="2") + fileRpt.writeln(' Talón '); + if (request.fa_tipo_doc_pago=="3") + fileRpt.writeln(' Compensación '); + if (request.fa_tipo_doc_pago=="4") + fileRpt.writeln(' Domiciliación '); + fileRpt.writeln(''+request.fa_nro_doc_pago+'
Vencimiento:'); + fileRpt.writeln(''+request.fa_vto_pago+'
'); + fileRpt.writeln('

Notas

'); + fileRpt.writeln(''); + nrolin++; + fileRpt.writeln(''); + fileRpt.writeln(''); + fileRpt.writeln(''); + fileRpt.writeln(''); + nrolin++; + fileRpt.writeln(''); + nrolin++; + fileRpt.writeln(''); + fileRpt.writeln(''); + nrolin++; + fileRpt.writeln(''); + fileRpt.writeln(''); + fileRpt.writeln('
Observaciones:
Traspaso Contable:'+request.fa_traspaso_ctable+'
Traspaso de Pago:'); + fileRpt.writeln(''+request.fa_traspaso_pago+'
Aptes.Pago'+request.fa_nro_reg_pago+'
Expediente:'+request.fa_expediente+'
'); + fileRpt.writeln(''); + fileRpt.writeln(''); + fileRpt.close(); + return nrolin; +} + + \ No newline at end of file diff --git a/global.js b/global.js new file mode 100644 index 0000000..a771132 --- /dev/null +++ b/global.js @@ -0,0 +1,1448 @@ +// // +// JavaScript Functions // +// // +////////////////////////////////////// +// Algunas variables Globales + + var HOY=new Date(); +// Algunos formatos para fechas. + var NLDF="D/M/YY"; // para columnas en las queries INFORMIX + var IFDF="D/M/YY"; // para columnas en SQL según DBDATE +// Algunos formatos para nros. + var NF2="##" + var NF3="###" + var NF4="#.###" + var NF5="##.###" + var NF6="###.###" + var NF7="#.###.###" + var NF8="##.###.###" + var NF9="###.###.###" + var NF09="***.***.***" + var NFY9="&&&.&&&.&&&&" + var NF10="#.###.###.###" + var NF11="##.###.###.###" + var NF12="###.###.###.###" + var baseHtml=""; +// Inline Character Constants + var BACKSPACE = "\b" + var TAB = "\t" + var CR = "\r" + var LF = "\n" + var CRLF = "\r\n" + var FF = "\f" + var DQUOTE = '\"' + var SQUOTE = "\'" + var BACKSLASH = "\\" + +// +// Date Object Enhanced Methods +// +Date.prototype.getFullYear = getFullYear; +Date.prototype.getActualMonth = getActualMonth; +Date.prototype.getActualDay = getActualDay; +Date.prototype.getCalendarDay= getCalendarDay; +Date.prototype.getCalendarMonth= getCalendarMonth; +Date.prototype.getYearDay= getYearDay; +function DateFromN(ndia) { +// Esta función devuelve una fecha en formato "DD/MM/YY" +// a partir de un nro de día entre 1 y 366 del año actual +// + if ( ndia < 0 ) + return "" + var yea=HOY.getYear(); + if ( ndia >365 ) { + yea=yea+1; + ndia=ndia-365 + } + var nmes = new Array(12); + nmes[0] = 31; + nmes[1] = 28; + nmes[2] = 31; + nmes[3] = 30; + nmes[4] = 31; + nmes[5] = 30; + nmes[6] = 31; + nmes[7] = 31; + nmes[8] = 30; + nmes[9] = 31; + nmes[10] = 30 + nmes[11] = 31; + var sumadias=0; + for ( var i=0 ; i <= 11 ; i++) { + suma=nmes[i]+sumadias; + if (suma >= ndia ) + break; + sumadias=suma; + } + var dia=ndia-sumadias; +// alert("Datos :"+dia+" Nro Dia: "+ndia+" Mes: "+mes+" SumaDias: "+sumadias+" Suma:"+suma+" Mes:"+i); + var mes=i+1; +// alert("Es Día :"+dia+" del mes "+mes); + return dia+"/"+mes+"/"+yea; +} +function AsignaFecha(stringDate,fecha) { +// Esta función asigna el día, mes y año de la cadena stringDate +// a la variable de tipo date pasada como argumento "fecha" + + if ( stringDate == "" ) + return "" ; + var s_fecha=DateUnformat(stringDate+""); + if ( s_fecha == "" ) + return "" ; + if ( s_fecha.substring(0,1) == "-" ) { + alert("-> ¡ Fecha no Válida! ¡ Debe ser una fecha en formato dd/mm/aa!"); + return "-1"; + } + var day=HOY.getDate(); + var yea=HOY.getYear(); + var mon=HOY.getMonth()+1; + var pos=s_fecha.indexOf("/"); + if (pos == -1) { + if ( s_fecha.length == 1 || s_fecha.length == 2 ) + day=parseInt(s_fecha); + if ( s_fecha.length == 3 || s_fecha.length == 4 ) { + day=parseInt(s_fecha.substring(0,2)); + mon=s_fecha.substring(2,s_fecha.length); + } + if ( s_fecha.length == 5 ) { + day=parseInt(s_fecha.substring(0,2)); + mon=s_fecha.substring(2,3); + yea=parseInt(s_fecha.substring(3,s_fecha.length)); + } + if ( s_fecha.length == 6 ) { + day=parseInt(s_fecha.substring(0,2)); + mon=s_fecha.substring(2,4); + yea=parseInt(s_fecha.substring(4,s_fecha.length)); + } + } + else { + var lastPos=s_fecha.substring(pos+1,s_fecha.length).indexOf("/"); + if ( lastPos == -1 ) { + day = parseInt(s_fecha.substring(0,pos)); + mon = s_fecha.substring(pos+1,s_fecha.length); + } + else { + lastPos=pos+lastPos+1; + day = parseInt(s_fecha.substring(0,pos)); + mon = s_fecha.substring(pos+1,lastPos); + yea = parseInt(s_fecha.substring(lastPos+1,s_fecha.length)); + } + } + fecha.setDate(day); + fecha.setMonth(mon-1); + fecha.setYear(yea); + return 0; +} + +function getYearDay() { + var nday = this.getDate(); + var nmon = this.getMonth(); + var nyea = this.getYear(); + var nmes = new Array(12); + nmes[0] = 31; + nmes[1] = daysInFebruary (nyea) + nmes[2] = 31; + nmes[3] = 30; + nmes[4] = 31; + nmes[5] = 30; + nmes[6] = 31; + nmes[7] = 31; + nmes[8] = 30; + nmes[9] = 31; + nmes[10] = 30 + nmes[11] = 31; + var sumadias=0; + for ( var i=0 ; i < nmon; i++ ) + sumadias=nmes[i]+sumadias; + var dia=sumadias+nday; +// alert("El Día es:"+dia+" del año"); + return dia; +} + +function getFullYear() { + var n = this.getYear(); + if ( n >= 0 && n <= 70 ) + n += 2000; + else + n += 1900; + return n; +} +function getActualMonth() { + var n = this.getMonth(); + n += 1; + return n; +} +function getActualDay() { + var n = this.getDay(); + n += 1; + return n; +} +function getCalendarDay() { + var n = this.getDay(); + var ndia = new Array(7); + ndia[0] = "Domingo"; + ndia[1] = "Lunes"; + ndia[2] = "Martes"; + ndia[3] = "Miércoles"; + ndia[4] = "Jueves"; + ndia[5] = "Viernes"; + ndia[6] = "Sábado"; + return ndia[n]; +} +function getCalendarMonth() { + var n = this.getMonth(); + var nmes = new Array(12); + nmes[0] = "Enero"; + nmes[1] = "Febrero"; + nmes[2] = "Marzo"; + nmes[3] = "Abril"; + nmes[4] = "Mayo"; + nmes[5] = "Junio"; + nmes[6] = "Julio"; + nmes[7] = "Agosto"; + nmes[8] = "Septiembre"; + nmes[9] = "Octubre"; + nmes[10] = "Noviembre"; + nmes[11] = "Diciembre"; + return nmes[n]; +} +function stringMonth(n) { + var nmes = new Array(12); + nmes[0] = "Enero"; + nmes[1] = "Febrero"; + nmes[2] = "Marzo"; + nmes[3] = "Abril"; + nmes[4] = "Mayo"; + nmes[5] = "Junio"; + nmes[6] = "Julio"; + nmes[7] = "Agosto"; + nmes[8] = "Septiembre"; + nmes[9] = "Octubre"; + nmes[10] = "Noviembre"; + nmes[11] = "Diciembre"; + return nmes[n]; +} + +// End Date Objects +/* + Varialbles para el Scroll: + MESSAGE = "Your message" -- The text you want to scroll. + [Put into scroll.msg] + DELAY = 50 -- The delay (in milliseconds) + between each shift left. + [Put into scroll.delay] + POSITION = 100 -- How many spaces should lead the + message when it starts? + [Put into scroll.pos] + status_scroll -- true o false si scroll activado +*/ +var status_scroll = false +// No scroll activado +var POSITION = 100 +var DELAY = 50 +var MESSAGE = " Cuentas a Pagar " +var scroll = new statusMessageObject() + +function decode(str) { + return unescape(str); +} +function encode(str) { + return escape(str); +} + +function getCookie(Name) { + var search = "NETSCAPE_LIVEWIRE." + Name + "="; + var RetStr = ""; + var Offset = 0; + var end = 0; + if (document.cookie.length > 0) { + offset = document.cookie.indexOf(search); + if (offset != -1) { + offset += search.length; + end = document.cookie.indexOf(";",offset); + if (end == -1) { + end = document.cookie.length + } + RetStr = decode(document.cookie.substring(offset,end)); + } + } + return(RetStr); +} +function setCookie(Name,Value,Expire) { + document.cokie = "NETSCAPE_LIVEWIRE." + Name + "=" + + encode(Value) + + ((Expire == null) ? "" : ("; expires=" + Expire.toGMTString())); +} +function chk_login() { + if (client.es_inicio == 1 ) { + top.close(); + redirect("initial.html?ipw=1"); + return false; + } + else + return true; +} +function abreVentana(ulrPath,winName) { +// if (ulrPath != null) { + now=new Date(); + var n = now.getSeconds(); + stringArgs=" "; + numArgs=abreVentana.arguments.length; + if (numArgs >2) { + for (var i=1; i < numArgs; i++) { + stringArgs=stringArgs+","+abreVentana.arguments[i]; + }; + }; + stringArgs="\""+stringArgs+"\""; + NvaVentana=window.open(ulrPath,winName+n,stringArgs); + return NvaVentana; +// }; +} + +function cierraVentana(Ventana) { + if (Ventana != null) { + Ventana.close(); + return; + }; +} + +function NetHelp(topic) { + window.open("help.html#" + topic , "HelpWin", +"toolbar=no,directories=no,menubar=no,status=no,scrollbars=no,resizable=yes,width=400,height=500") +} + +function loadHelp() { + if (parent.main.document.URL.indexOf("multi_entry.html") >= 0) + NetHelp("entry"); + else if (parent.main.document.URL.indexOf("report") >= 0) + NetHelp("reports"); + else if (parent.main.document.URL.indexOf("user_info.html") >= 0 || + parent.main.document.URL.indexOf("_pw.html") >= 0) + NetHelp("prefs"); + else if (parent.main.document.URL.indexOf("edit_entry") >= 0) + NetHelp("edit_entry"); + else if (parent.main.document.URL.indexOf("admin.html") >= 0 || + parent.main.document.URL.indexOf("add_") >= 0 || + parent.main.document.URL.indexOf("edit_") >= 0) + NetHelp("admin"); + else + NetHelp("intro"); +} + +function DbsError(status,dbstatus) +{ +// Hay un problemilla: status es true en las operaciones de +// connect pero es un numérico en el resto. +// por eso siempre será true en las peticiones SQL +// + client.status=status; + client.dbstatus=dbstatus; + client.majorErrorCode=database.majorErrorCode(); + client.majorErrorMessage= database.majorErrorMessage(); + client.minorErrorCode =database.minorErrorCode(); + client.minorErrorMessage=database.minorErrorMessage(); + if ( status == true ) + return; + if ( dbstatus == 0 ) + return; + + if (client.is_trans == true) + database.rollbackTransaction(); + redirect('error.html') + +} +function chkBrowser() { + browser = request.agent; + if (browser.indexOf("Mozilla/") != -1) { + ver = browser.substring(8,9) + verNum = parseInt(ver) + if (verNum > 2 ) { + return; + } + redirect("wrongbrw.html") + } +} + + + +function writeln(text) +{ + write(text + '\n'); +} +function wbuttons(text) +{ + write(' ndoc=\''+text+'\');'+'\n'); +} + + + + +function escQuote (query_string) { + var new_string = ""; + var query_len = query_string.length; + var c; + + if (query_string == "" || query_string.indexOf("'") < 0) + return query_string; + + for (var i = 0; i < query_len; i++) { + c = query_string.charAt(i); + if (c != '\'') new_string += c; + else new_string += "''"; + } + return new_string; +} + + + + +function backslashQuote (s) { + var new_string = ""; + var len = s.length; + var c; + + if (s == "" || s.indexOf("'") < 0) + return s; + + for (var i = 0; i < len; i++) { + c = s.charAt(i); + if (c != '\'') new_string += c; + else new_string += "\\'"; + } + return new_string; +} + + + + + + + +function createIdNameString(queryString) { + var query; + var temp; + + temp = ""; + query = database.cursor(queryString); + while (query.next()) + temp += query[0]+" | "+query[1]+" || "; + query.close(); + return temp; +} + + + + + + + +function createIdNameGroupString(query_string) { + var query; + var temp; + + temp = ""; + query = database.cursor(query_string); + while (query.next()) { + if ((query[2]+"").indexOf("No Group") >= 0) + temp += query[0]+" | "+query.fullname+" || "; + else + temp += query[0]+" | "+query.fullname+" ("+query[2]+") || "; + } + query.close(); + return temp; +} + + + + + +function loggedIn() { + var today = new Date; + + if (client.id == "null" || client.id == null) + return false; + if (! client["login"+((today.getYear()+today.getMonth())*client.id)]) + return false; + if (client["login"+((today.getYear()+today.getMonth())*client.id)] != "yes") + return false; + return true; +} + + + + +function setLoggedIn() { + var today = new Date(); + + client["login"+((today.getYear()+today.getMonth())*client.id)] = "yes"; +} + + + + +function setLoggedOut() { + var today = new Date(); + + if (client.id != null && client.id != "null") + client["login"+((today.getYear()+today.getMonth())*client.id)] = null; +} + + + + +function IdNameObj() { + this.id = ""; + this.name = ""; + this.currPos = 0; +} + + + + +function getNextItem(s,item) { + var nextPos; + + nextPos = s.indexOf(" |",item.currPos); + item.id = s.substring(item.currPos,nextPos); + item.currPos = nextPos+3; + nextPos = s.indexOf(" ||", item.currPos); + item.name = s.substring(item.currPos,nextPos); + item.currPos = nextPos+4; +} + + + + + + + +function writeSelectMultiOptions(list,selectList) { + var item = new IdNameObj(); + var selectItem = new IdNameObj; + var allItemsFound = true; + + getNextItem(selectList,selectItem); + while (item.currPos < list.length) { + getNextItem(list,item); + // current item in select list not found in list + if (item.name > selectItem.name && + selectItem.currPos < selectList.length) { + getNextItem(selectList,selectItem); + allItemsFound = false; + } + if (item.id == selectItem.id) { + writeln("
'); + fileRpt.writeln(""+ + ""); + fileRpt.writeln('
"+c_albareg.nif +""+c_albareg.razon_social+"
'); + fileRpt.writeln('
'); + fileRpt.writeln(" "+ + ""+ + ""+ + ""); + nrolin=nrolin+3; set_head=false; + } + request.ab_nro_reg=c_albareg.nro_reg; + sumalbctas(); + fileRpt.writeln(""+ + ""+ + ""+ + ""+ + ""); + suma_total=suma_total+request.ac_total; + suma_prov=suma_prov+request.ac_total; + keyLastRow=c_albareg.nif; + nrolin++; + if (!c_albareg.next()) + break; + } +// writeln(""); +// writeln(""); + fileRpt.writeln('
Nro. Reg." + + "F.Emisión Nro. Fra.Centro Importe
"+c_albareg.nro_reg+""+datetoString(c_albareg.fecha_emision) +""+c_albareg.nro_fra +""+c_albareg.cod_centro +""+NroFormat(request.ac_total,NF11)+"
----------------
Suma Total:"+NroFormat(suma_total,NF10) +"
'); + fileRpt.writeln(''); + fileRpt.writeln(""+ + ""); + fileRpt.writeln('
TOTAL .... "+NroFormat(suma_prov,NF11)+"
'); + fileRpt.writeln('
'); + fileRpt.writeln(""+ + ""); + fileRpt.writeln('
TOTAL Acumulado....... "+NroFormat(suma_total,NF11)+"
'); +} +function AlbCentroHtml() { + request.s_ctas=0; + request.s_total=0; + request.s_prov=0; + var nrolin=0; + var keyLastRow="-"; + var desLastRow=""; + var keyLastPrv="-"; + var set_head=true; + var s_seq=getSeqPrt(nprinter); + textoReqs=textoReqs+" "+s_seq; + var nomFile=spoolpath+nprinter+"/req_"+s_seq+".html" + fileRpt=new File(nomFile); + fileRpt.open("w"); + fileRpt.writeln(''); + fileRpt.writeln(''); + status=database.execute("DELETE FROM sumactasalb where uid=\'" + request.uid+ "\'"); + while (true) { + if ( nrolin+3 == request.maxLins ) { + fileRpt.writeln('


'); + nrolin=0; + set_head=true; + }; + if ( keyLastPrv == "-" ) + keyLastPrv=c_albareg.nif; + if ( keyLastPrv != c_albareg.nif ) { + keyLastPrv=c_albareg.nif; + fileRpt.writeln("TOTAL .... "+ + ""+ + ".............."+ + ".............."+ + ""+ + ""+NroFormat(request.s_prov,NF9)+""+ + ""+ + "") + request.s_prov=0; + } + if ( keyLastRow != c_albareg.cod_centro && keyLastRow !="-" ) { + nrolin++; + fileRpt.writeln("TOTAL .... "+ + ""+ + ".............."+ + ".............."+ + ""+ + ""+NroFormat(request.s_ctas,NF9)+""+ + ""+ + "") + fileRpt.writeln('

'); + AlbResCentrosHtml(keyLastRow,desLastRow); + fileRpt.writeln(''); + fileRpt.writeln(''); + fileRpt.close(); + s_seq=getSeqPrt(nprinter); + textoReqs=textoReqs+" "+s_seq; + nomFile=spoolpath+nprinter+"/req_"+s_seq+".html" + fileRpt=new File(nomFile); + fileRpt.open("w"); + fileRpt.writeln(''); + fileRpt.writeln(''); +// if ( nrolin <= request.maxLins ) { +// skipTopPage(nrolin,request.maxLins); +// nrolin=0; +// set_head=true; +// } + request.s_ctas=0; + request.s_total=0; + request.s_prov=0; + nrolin=nrolin+3 + set_head=true; + } + if ( set_head == true ) { + nrolin=nrolin+6; + if ( keyLastRow !="-" ) + fileRpt.writeln(""); + AlbCentrosCab(); + set_head=false; + } + c_aptesalb = database.cursor("SELECT * from aptecuentas where nro_reg='"+ + c_albareg.nro_reg+"' ") + if (c_aptesalb.next()) { + instCtaAlb(); + if ( nrolin+1 > request.maxLins ) { + skipTopPage(nrolin,request.maxLins); + nrolin=6; + fileRpt.writeln(""); + AlbCentrosCab(); + } + nrolin++; + importe=parseFloat(c_aptesalb.importe); + if ( c_aptesalb.tipo_apte == "H" ) + importe=parseFloat(c_aptesalb.importe)*-1; + request.s_prov=parseFloat(request.s_prov)+parseFloat(importe); + fileRpt.writeln(""+c_albareg.nro_reg+""+ + ""+datetoString(c_albareg.fecha_emision) +""+ + ""+c_albareg.nif+""+ + ""+c_albareg.razon_social+""+ + ""+c_aptesalb.cod_cta+""+ + ""+NroFormat(importe,NF9)+""+ + ""+c_albareg.fra_reg+""+ + "") + request.s_total=parseFloat(request.s_total)+parseFloat(importe); + request.s_ctas=parseFloat(request.s_ctas)+parseFloat(importe); + } + while (c_aptesalb.next()) { + instCtaAlb(); + if ( nrolin+1 > request.maxLins ) { + skipTopPage(nrolin,request.maxLins); + nrolin=6; + fileRpt.writeln(""); + AlbCentrosCab(); + } + nrolin++; + importe=parseFloat(c_aptesalb.importe); + if ( c_aptesalb.tipo_apte == "H" ) + importe=parseFloat(c_aptesalb.importe)*-1; + request.s_prov=parseFloat(request.s_prov)+parseFloat(importe); + fileRpt.writeln(""+ + ""+ + ""+ + ""+ + ""+c_aptesalb.cod_cta+""+ + ""+NroFormat(importe,NF9)+""+ + ""+ + "") + request.s_total=parseFloat(request.s_total)+parseFloat(importe); + request.s_ctas=parseFloat(request.s_ctas)+parseFloat(importe); + } + c_aptesalb.close(); + keyLastRow=c_albareg.cod_centro; + desLastRow=c_albareg.descripcion; + if (!c_albareg.next()) + break; + } + fileRpt.writeln("TOTAL .... "+ + ""+ + ".............."+ + ".............."+ + ""+ + ""+NroFormat(request.s_ctas,NF9)+""+ + ""+ + "") + fileRpt.writeln(''); + AlbResCentrosHtml(keyLastRow,desLastRow); + fileRpt.writeln(''); + fileRpt.writeln(''); + fileRpt.close(); +} +function instCtaAlb() { + importe=parseFloat(c_aptesalb.importe); + if ( c_aptesalb.tipo_apte == "H" ) + importe=parseFloat(c_aptesalb.importe)*-1; + status=database.execute("INSERT INTO sumactasalb(" + + " uid," + + " cod_centro," + + " cod_cta," + + " importe) VALUES ('" + + request.uid + "','" + + StringClip(true,c_albareg.cod_centro) + "','" + + StringClip(true,c_aptesalb.cod_cta) + "','" + + importe+ "')"); +} +function AlbResCentrosHtml(clave,desclave) { + c_ctascentro = database.cursor("SELECT cod_cta,sum(importe) from sumactasalb where cod_centro=\'" +clave+"\' and uid=\'" + request.uid+ + "\' group by cod_cta "); + fileRpt.writeln('
'); + if (request.f_formato=="pendientes") + fileRpt.writeln('

RESUMEN CUENTAS DE ALBARANES PENDIENTES DE FACTURA

'); + else + fileRpt.writeln('

RESUMEN DE CUENTAS POR CENTRO

'); + fileRpt.writeln('
'); +// fileRpt.writeln(''); +// fileRpt.writeln("
"+clave +""+ +// ""+desclave+""); +// fileRpt.writeln('


'); + fileRpt.writeln(""+clave +desclave+""); + fileRpt.writeln(''); + fileRpt.writeln("" + + ""+ + ""); + request.s_total=0; + while ( c_ctascentro.next()) { + fileRpt.writeln(""+ + ""+ + ""+ + ""); + request.s_total=parseFloat(request.s_total)+parseFloat(c_ctascentro[1]); + } + c_ctascentro.close(); + fileRpt.writeln(""+ + ""); + fileRpt.writeln('
Cod. Cta.Importe
"+c_ctascentro.cod_cta+""+NroFormat(c_ctascentro[1],NF11)+"
TOTAL"+NroFormat(request.s_total,NF11)+"
'); + fileRpt.writeln('

'); +} +function AlbCentrosCab() { + fileRpt.writeln('
Dpto. Cuentas a Pagar'); + fileRpt.writeln('
'); + if (request.f_formato=="pendientes") + fileRpt.writeln('

LISTADO DE ALBARANES PENDIENTES DE FACTURA

'); + else + fileRpt.writeln('

LISTADO DE ALBARANES POR CENTRO

'); + fileRpt.writeln('
'); + fileRpt.writeln(''); + fileRpt.writeln(""+c_albareg.cod_centro +c_albareg.descripcion+""); + fileRpt.writeln(''); + fileRpt.writeln("" + + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""); +} +function AlbPendientesHtml() { +} +function AlbEmitidosHtml() { +} +function AlbRetenidosHtml() { +} + diff --git a/l_docpago.js b/l_docpago.js new file mode 100644 index 0000000..1a10d59 --- /dev/null +++ b/l_docpago.js @@ -0,0 +1,945 @@ +////////////////////////////////////// +// // +// JavaScript Functions // +// // +////////////////////////////////////// + +function wrdocpago(text){ +// writeln("w_outdocpago.document.write('"+text+"\\n');"); + fileRpt.writeln(text); +} + +function chk_docspago() { + var query; + query = database.cursor("select count(*) FROM docspago WHERE uid=\'" + request.uid+ "\'"); + if (query.next()) { + if (query[0] > 0) { + tdoc = database.cursor("select unique tipo_doc_pago FROM docspago WHERE uid=\'" + request.uid+ "\'"); + tdoc.next(); + if ( tdoc.tipo_doc_pago=="1" ) { + request.f_tipo_doc_pago="1"; + Palabra="Pagarés"; + } + if ( tdoc.tipo_doc_pago=="2" ) { + request.f_tipo_doc_pago="2"; + Palabra="Talones"; + } + writeln(' alert("\\r Hay '+Palabra+' Pendientes de Confirmación !!!"); '); + tdoc.close(); + request.opt_docpago="true"; + } + } + query.close(); + if (request.opt_docpago) + return true + else + return false +} + +function updPagoFras() { + client.is_trans=true; + database.beginTransaction(); + c_docspago = database.cursor("SELECT * FROM docspago WHERE uid='"+request.uid+"' order by nro_reg "); + while (c_docspago.next()) { + // DesBloquear factura + status=database.execute("UPDATE facturas SET "+ + " is_locked='N',"+ + " tipo_doc_pago='" + c_docspago.tipo_doc_pago + "',"+ + " nro_doc_pago='" + c_docspago.nro_doc_pago + "',"+ + " f_emision_pago='" + DateFormat(datetoString(c_docspago.f_emision_pago),NLDF) + "',"+ + " vto_pago='" + DateFormat(datetoString(c_docspago.vto_pago),NLDF) + "',"+ + " cod_localidad='" + c_docspago.cod_localidad + "',"+ + " cod_banco='" + c_docspago.cod_banco + "'"+ + " WHERE nro_reg='"+c_docspago.nro_reg+"'"); + + if ( status != 0 ) { + c_docspago.close(); + client.is_trans=false; + database.rollbackTransaction(); + redirect(addClient('error.html?alert=9')); + } + } + database.commitTransaction(); + client.is_trans=false; + c_docspago.close(); + return true; +} + +function report_docpago() { + // Borramos en tabla de pagos datos del usuario + status=database.execute("DELETE FROM docspago WHERE uid=\'" + request.uid+ "\'"); + client.is_trans=true; + database.beginTransaction(); + var s_lon=request.sel_nro_reg.length; + if (s_lon == 0 ) + return; + var s_lon=request.sel_nro_reg.length; + var i=0; + pos=request.sel_nro_reg.substring(i,s_lon).indexOf("|") + var nregfra=""; + while (pos >0) { + insertaDocPago(i,pos); + i=pos+1; + if ( i >= s_lon ) + break; + pos=request.sel_nro_reg.substring(i,s_lon).indexOf("|") + if (pos <= 0 ) + break; + else + pos=pos+i; + } + if (i==0) + return; + // Hay que buscar si tiene ABONOS + chk_abonos(); + upd_docspago(); + database.commitTransaction(); + client.is_trans=false; + if (preparamat("spa", "f") == false ) // Aquí se prepara la trad. de dígitos + return; + if (request.f_tipo_doc_pago == "1" ) + out_docpago() + if (request.f_tipo_doc_pago == "2" ) + out_doctalon() + writeln('w_outdocpago=window.open("'+urlFile+'","w_outdocpago","toolbar=yes,directories=no,menubar=yes,status=no,scrollbars=yes,resizable=yes,width=600,height=500");'); +} +function rpt_doccarta() { + out_doccarta() + writeln('w_carta=window.open("'+urlCarta+'","w_carta","toolbar=yes,directories=no,menubar=yes,status=no,scrollbars=yes,resizable=yes,width=600,height=500");'); +} +function rpt_docfile() { + out_docfichero() + writeln('w_carta=window.open("'+urlFich+'","w_file","toolbar=yes,directories=no,menubar=yes,status=no,scrollbars=yes,resizable=yes,width=600,height=500");'); +} +function insertaDocPago(i,pos) { + var nro_reg=request.sel_nro_reg.substring(i,pos); +// debug(nro_reg); + if ( nro_reg.length < 1 ) + return; + c_facturas = database.cursor("SELECT nif, importe_total,cod_centro,f_pago,nro_fra,tipo_fra,tipo_doc_pago "+ + " FROM facturas WHERE nro_reg="+nro_reg); + if (c_facturas.next()) { + status=database.execute("INSERT INTO docspago(" + + " uid," + + " nro_reg," + + " cod_centro," + + " f_pago," + + " nro_fra," + + " tipo_fra," + + " nif," + + " tipo_doc_pago," + + " nro_doc_pago," + + " f_emision_pago," + + " cod_localidad," + + " vto_pago," + + " cod_banco," + + " importe_total ) VALUES ('" + request.uid+ "','" + + nro_reg + "','"+ + StringClip(true,c_facturas.cod_centro) + "','"+ + DateFormat(datetoString(c_facturas.f_pago),NLDF) + "','"+ + StringClip(true,c_facturas.nro_fra) + "','"+ + StringClip(true,c_facturas.tipo_fra) + "','"+ + StringClip(false,c_facturas.nif) + "','"+ + StringClip(false,c_facturas.tipo_doc_pago) + "','"+ + "0','"+ + DateFormat(request.f_f_emision_pago,NLDF) + "','"+ + StringClip(true,request.f_cod_localidad) + "','"+ + DateFormat(datetoString(c_facturas.f_pago),NLDF) + "','"+ + StringClip(true,request.f_cod_banco) + "','"+ + c_facturas.importe_total + "')"); + if ( status != 0 ) { + client.is_trans=false; + database.rollbackTransaction(); + redirect(addClient('error.html?alert=14&nro_reg='+nro_reg)); + } + } + c_facturas.close(); +} +function chk_abonos() { +// c_fraspago = database.cursor("SELECT sum(importe_total),nif FROM docspago WHERE uid='"+request.uid+"' group by nif "); +// while (c_fraspago.next()) { +// debug(c_fraspago[0]); +// if ( c_fraspago[0] < 0 ) { + // no se paga nada de nada ... nos Debe +// status=database.execute("DELETE from docspago WHERE uid='" + request.uid+"'"+ +// " and nif = '"+c_fraspago.nif+"'"); +// } +// } +// c_fraspago.close(); +// Leemos los abonos de cada proveedor y buscamos fras. que lo cubran si no no se paga. +// Para evitar problemas actualizamos centro y f_pago en el abono ... + c_docsnif = database.cursor("SELECT UNIQUE nif FROM docspago WHERE uid='"+request.uid+"' "); + while (c_docsnif.next()) { + c_frasabono= database.cursor("SELECT * FROM docspago WHERE uid='"+request.uid+"' and nif ='"+c_docsnif.nif+"' and importe_total < 0 "+ + " order by importe_total"); + to_paynif=true; + while (c_frasabono.next() && to_paynif == true ) { +//debug(c_frasabono.nro_reg) + to_payfra=false; + c_fraspago = database.cursor("SELECT sum(importe_total),cod_centro,f_pago FROM docspago WHERE uid='"+request.uid+"' and nif ='"+c_docsnif.nif+"' and importe_total > 0 "+ + "group by cod_centro,f_pago "); + while (c_fraspago.next() ) { +//linea=c_fraspago[0]+" "+c_frasabono.importe_total; +//debug(linea) + if ( c_fraspago[0] > c_frasabono.importe_total*-1 ) { + status=database.execute("UPDATE docspago SET cod_centro='"+c_fraspago.cod_centro+"',"+ + " f_pago='"+DateFormat(datetoString(c_fraspago.f_pago),NLDF)+"',"+ + " vto_pago='"+DateFormat(datetoString(c_fraspago.f_pago),NLDF)+ + "' WHERE nro_reg='"+c_frasabono.nro_reg+"'"); + + to_payfra=true + break; + } + } + c_fraspago.close(); + if ( to_payfra == false ) + to_paynif=false; + } + if ( to_paynif == false ) { + status=database.execute("DELETE FROM docspago WHERE uid='" + request.uid+"'"+ + " and nif = '"+c_docsnif.nif+"'"); + } + c_frasabono.close(); + } + c_docsnif.close(); +} + +function upd_docspago() { + var nro_docpago=parseFloat(NroUnformat(request.f_nro_doc)); + var inro_docpago=nro_docpago; + // Actualizar las Filas con su nro_doc_pago ... +// c_docspago = database.cursor("SELECT * FROM docspago WHERE uid='"+request.uid+"' and importe_total > 0 order by nif,importe_total "); + c_docspago = database.cursor("SELECT * FROM docspago WHERE uid='"+request.uid+"' order by nif,importe_total "); + while (c_docspago.next()) { + // if (request.f_tipo_doc_pago=="1") // Pagaré + // if (request.f_tipo_doc_pago=="2") // Talón + // if (request.f_tipo_doc_pago=="3") // Compensación + // if (request.f_tipo_doc_pago=="4") // Domiciliación + // Asignar el nro. de documento de pago, el mismo si nif, centro y f_pago coinciden. + c_haydocspago = database.cursor("SELECT nro_doc_pago FROM docspago WHERE uid='"+ request.uid+"' and nif = '"+StringClip(false,c_docspago.nif)+ + "' and nro_doc_pago !='0' and nro_reg != '"+c_docspago.nro_reg+ + "' and cod_centro ='"+c_docspago.cod_centro+ + "' and f_pago='"+DateFormat(datetoString(c_docspago.f_pago),NLDF)+"'"); + // "' and importe_total > 0 "+ +//debug(c_haydocspago.nro_doc_pago); + var nro_doc_pago=nro_docpago; + var hay_mas=false; + if ( c_haydocspago.next() ) { + nro_doc_pago=parseFloat(c_haydocspago.nro_doc_pago); + if ( nro_doc_pago == 0 ) + nro_doc_pago=nro_docpago; + else + hay_mas=true; + } + c_haydocspago.close(); + status=database.execute("UPDATE docspago SET nro_doc_pago='"+nro_doc_pago+"' WHERE nro_reg='"+c_docspago.nro_reg+"'"); + if (hay_mas == false) { nro_docpago++ }; + // Bloquear la factura durante el curso del pago ... Así sólo es de lectura. + status=database.execute("UPDATE facturas SET is_locked='S' WHERE nro_reg='"+c_docspago.nro_reg+"'"); + } + c_docspago.close(); +} +function no_sirve() { + // Devoluciones ... + c_docspago = database.cursor("SELECT * FROM docspago WHERE uid='"+request.uid+"' and importe_total < 0 order by nro_reg "); + while (c_docspago.next()) { + var nro=c_docspago.importe_total*-1; + // Asignar el nro. de documento de pago, el mismo si nif coincide. + c_haydocspago = database.cursor("SELECT nro_doc_pago FROM docspago WHERE uid='"+ request.uid+"' and nif = '"+StringClip(false,c_docspago.nif)+ + "' and nro_doc_pago !='0' and nro_reg != '"+c_docspago.nro_reg+ + "' and importe_total > '"+nro+"'"); + if ( c_haydocspago.next() ) { + status=database.execute("UPDATE docspago SET nro_doc_pago='"+c_haydocspago.nro_doc_pago+"' WHERE nro_reg='"+c_docspago.nro_reg+"'"); + // Bloquear la factura durante el curso del pago ... Así sólo es de lectura. + status=database.execute("UPDATE facturas SET is_locked='S' WHERE nro_reg='"+c_docspago.nro_reg+"'"); + } + c_haydocspago.close(); + } + c_docspago.close(); +} +function cleanup_docspago() { + c_docspago = database.cursor("SELECT nro_reg FROM docspago WHERE uid='"+request.uid+"' order by nro_reg "); + while (c_docspago.next()) { + // DesBloquear factura + status=database.execute("UPDATE facturas SET is_locked='' WHERE nro_reg='"+c_docspago.nro_reg+"'"); + } + // Borramos en tabla de pagos datos del usuario + status=database.execute("DELETE FROM docspago WHERE uid=\'" + request.uid+ "\'"); +} +function out_docpago() { + var fileRpt=new File(nomFile); + fileRpt.open("w"); + fileRpt.writeln(''); + fileRpt.writeln(''); + fileRpt.writeln(''); + fileRpt.writeln(''); + fileRpt.writeln('
 ');
+   c_nrodocspago = database.cursor("SELECT UNIQUE nro_doc_pago FROM docspago WHERE uid="+ request.uid+" ORDER BY nro_doc_pago ");
+   var PlusNroDoc=0;    // Acumula incrementos en Nro. Doc si salto página
+   var lnro="";
+   var nlin=1
+   while (c_nrodocspago.next()) {
+ 		  c_docspago = database.cursor("SELECT importe_total FROM docspago WHERE uid="+ request.uid+
+                " and nro_doc_pago='"+c_nrodocspago.nro_doc_pago+"' ");
+		  var importeTotal=0;
+        var NeedLins=0;
+        while (c_docspago.next()) {   // A Sumar ....
+		      importeTotal=importeTotal+parseFloat(c_docspago.importe_total);  
+		      NeedLins++;
+        } 
+        c_docspago.close();
+ 		  c_docspago = database.cursor("SELECT * FROM docspago WHERE uid="+ request.uid+
+                " and nro_doc_pago='"+c_nrodocspago.nro_doc_pago+"' ORDER BY importe_total ");
+		  c_docspago.next();
+		  CursorTabla("pr","nif","=\'"+StringClip(false,c_docspago.nif)+"\'",false,false);
+		  CursorTabla("ba","cod_banco","=\'"+StringClip(false,c_docspago.cod_banco)+"\'",false,false);
+        if (request.t_nl == "1") { lnro=nlin; }
+		  for (n=nlin; n<14 ; n++) {
+		      fileRpt.writeln(lnro+" ");
+            nlin++; 
+            if (request.t_nl == "1") { lnro=nlin; }
+		  }    
+        fileRpt.writeln(lnro+"           Málaga,"+datetoString(c_docspago.f_emision_pago));
+        nlin++;
+//         123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 23456789 123       
+//		  direccion=StringClip(false,c_proveedores.direccion_envio);
+//        localidad=StringClip(false,c_proveedores.cod_postal_envio)+" "+StringClip(false,c_proveedores.localidad_envio);
+//		  if ( direccion == "" || direccion == " " ) {
+  		      direccion=StringClip(false,c_proveedores.domicilio);
+   		   localidad=StringClip(false,c_proveedores.cod_postal)+" "+c_proveedores.localidad;
+//		  }
+//		  attn_envio=StringClip(false,c_proveedores.attn_envio);
+//		  fileRpt.writeln(lnro+"                                                 "+c_proveedores.attn_envio+" ");
+        if (request.t_nl == "1") { lnro=nlin };
+		  fileRpt.writeln(lnro+"                                                    "+StringClip(false,c_proveedores.razon_social)+" ");
+        nlin++;
+        if (request.t_nl == "1") { lnro=nlin };
+		  fileRpt.writeln(lnro+"                                                    "+direccion+" ");
+        nlin++;
+        if (request.t_nl == "1") { lnro=nlin };
+		  fileRpt.writeln(lnro+"                                                    "+localidad+" ");
+        nlin++;
+        if (request.t_nl == "1") { lnro=nlin };
+		  for (n=1; n<3 ; n++) {
+		    fileRpt.writeln(lnro+" ");
+		    nlin++;
+          if (request.t_nl == "1") { lnro=nlin };
+        }
+        if ( NeedLins > BodyLines) {
+             PlusNroDoc++;
+	     }
+        var nro_doc_pago=parseFloat(c_docspago.nro_doc_pago)+PlusNroDoc;
+        if (PlusNroDoc > 0 ) {   
+          status=database.execute("UPDATE docspago SET nro_doc_pago='"+nro_doc_pago+"' WHERE nro_reg='"+c_docspago.nro_reg+"'");                
+   	  }
+		  fileRpt.writeln(lnro+" ");
+        nlin++;
+        if (request.t_nl == "1") { lnro=nlin; }
+		  fileRpt.writeln(lnro+" ");
+        nlin++;
+        if (request.t_nl == "1") { lnro=nlin; }
+        fileRpt.writeln(lnro+"           Muy Sres. nuestros:");  
+        nlin++;
+        if (request.t_nl == "1") { lnro=nlin; }
+		  fileRpt.writeln(lnro+" ");
+        nlin++;
+        if (request.t_nl == "1") { lnro=nlin; }
+		  fileRpt.writeln(lnro+"                     Adjunto les remitimos pagaré nro. 0"+nro_doc_pago+" a cargo del ");  
+        nlin++;   
+        if (request.t_nl == "1") { lnro=nlin; }
+		  fileRpt.writeln(lnro+"           "+StringClip(false,c_bancos.nombre)+" de pesetas "+NroFormat(importeTotal,NF9)+",");
+        nlin++;
+        if (request.t_nl == "1") { lnro=nlin; }
+		  fileRpt.writeln(lnro+"           con el cual cancelamos las facturas siguientes: ");
+        nlin++;  
+        if (request.t_nl == "1") { lnro=nlin; }
+		  fileRpt.writeln(lnro+" ");
+        nlin++;
+        if (request.t_nl == "1") { lnro=nlin; }
+		  fileRpt.writeln(lnro+"                    Centro   Registro      Importe            Nro.Fra ");
+        nlin++; 
+        if (request.t_nl == "1") { lnro=nlin; }
+		  fileRpt.writeln(lnro+"                    ------  ---------   ----------------    ----------------");
+        nlin++;
+        blin=0;
+        if (request.t_nl == "1") { lnro=nlin; }
+		  while (true) {
+            blin++;
+            codCentro=StringClip(false,c_docspago.cod_centro);
+            if ( c_docspago.importe_total < 0 ) 
+                 codCentro="     ";
+		      var nreg=c_docspago.nro_reg.substring(4,10)+"/"+c_docspago.nro_reg.substring(2,4);
+		      fileRpt.writeln(lnro+"                    "+codCentro+"   "+nreg+"    "+NroFormat(c_docspago.importe_total,NF9)+" Ptas."+"  "+StringClip(false,c_docspago.nro_fra));  
+ 		      if (blin+1 > BodyLines ) {
+ 		         blin=0;
+               nlin=FootPosLin;
+            }
+            nlin++;
+            if (request.t_nl == "1") { lnro=nlin; }
+            if ( nlin == FootPosLin ) {
+                for (var i=nlin ; i <= PaperLines ; i++) {
+                    if (request.t_nl == "1") { lnro=i; }
+               	  fileRpt.writeln(lnro+" ");  
+                }
+                for (var i=nlin ; i <= HeadPosLin ; i++) {
+                    if (request.t_nl == "1") { lnro=i; }
+	             	  fileRpt.writeln(lnro+" ");  
+                }
+	             nlin=HeadPosLin;	  
+            }
+		      if ( !c_docspago.next()) 
+            break;
+		  }
+		  while ( blin < BodyLines ) {
+                if (request.t_nl == "1") { lnro=nlin; }
+    	   	    fileRpt.writeln(lnro+" ");  
+                nlin++; 
+                blin++;
+                if (request.t_nl == "1") { lnro=nlin; }   
+        }
+		  fileRpt.writeln(lnro+"                     A la espera de que el mencionado importe sea de su entera ");
+        nlin++;  
+        if (request.t_nl == "1") { lnro=nlin; }
+  	     fileRpt.writeln(lnro+"           conformidad, reciban un cordial saludo.");
+        nlin++;   
+        if (request.t_nl == "1") { lnro=nlin; }
+		  fileRpt.writeln(lnro+" ");  
+        nlin++; 
+        if (request.t_nl == "1") { lnro=nlin; }
+		  fileRpt.writeln(lnro+" ");  
+        nlin++; 
+        if (request.t_nl == "1") { lnro=nlin; }
+		  fileRpt.writeln(lnro+"                        CONSTRUCCIONES SANCHEZ DOMINGUEZ-SANDO, S.A. ");  
+        nlin++;
+        if (request.t_nl == "1") { lnro=nlin; }
+        while (nlin < FootPosLin) {
+           // Salta hasta pie de Página
+      	  fileRpt.writeln(lnro+" ");  
+           nlin++;
+           if (request.t_nl == "1") { lnro=nlin; }
+        }
+		     fileRpt.writeln(lnro+" ");      
+           nlin++;
+           if (request.t_nl == "1") { lnro=nlin; }	
+		     fileRpt.writeln(lnro+" ");      
+           nlin++;
+           if (request.t_nl == "1") { lnro=nlin; }	
+		     fileRpt.writeln(lnro+" ");     
+           nlin++;
+           if (request.t_nl == "1") { lnro=nlin; }	
+           linea=NroFormat(importeTotal,NF9);
+		     fileRpt.writeln(lnro+"                 ");      
+           nlin++;
+           if (request.t_nl == "1") { lnro=nlin; }	
+		     fileRpt.writeln(lnro+"                 "+StringClip(false,c_proveedores.nif)+"                        "+StringClip(false,c_docspago.cod_localidad)+"                  #"+StringClip(true,linea)+"#");      
+           nlin++;
+           if (request.t_nl == "1") { lnro=nlin; }
+		     fileRpt.writeln(lnro+" ");  
+           nlin++;
+           if (request.t_nl == "1") { lnro=nlin; }
+		     fileRpt.writeln(lnro+"                       "+datetoString(c_docspago.f_emision_pago)+"                                     "+datetoString(c_docspago.f_pago)+" ");    
+           nlin++;
+           if (request.t_nl == "1") { lnro=nlin; }
+		     fileRpt.writeln(lnro+" ");  
+           nlin++;
+           if (request.t_nl == "1") { lnro=nlin; }
+		     fileRpt.writeln(lnro+"                                                                             ");    
+           nlin++;
+//		     fileRpt.writeln(lnro+"                                                                             "+CompLetOn+"orden"+CompLetOff);    
+           if (request.t_nl == "1") { lnro=nlin; }
+		     fileRpt.writeln(lnro+"                                                                                               no a la orden");    
+           nlin++;  
+           if (request.t_nl == "1") { lnro=nlin; }
+//         123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 23456789 123         
+		     fileRpt.writeln(lnro+" ");    
+           nlin++;
+           if (request.t_nl == "1") { lnro=nlin; }
+		     fileRpt.writeln(lnro+" ");    
+           nlin++;
+           if (request.t_nl == "1") { lnro=nlin; }
+		     fileRpt.writeln(lnro+"                       "+StringClip(false,c_proveedores.razon_social)+" ");
+           nlin++;  
+           if (request.t_nl == "1") { lnro=nlin; }
+           num_let="";
+           if (importeTotal > 0 ) 
+              nro_letra(importeTotal, "spa", "f", "PESETAS", CarPad,LongLine,LongLine);
+//debug(num_let)
+//debug(num_let2)
+           fileRpt.writeln(lnro+"                          "+num_let);    
+           nlin++;
+           if (request.t_nl == "1") { lnro=nlin; }
+           fileRpt.writeln(lnro+"                          "+num_let2);
+           nlin++;
+           if (request.t_nl == "1") { lnro=nlin; }
+		     fileRpt.writeln(lnro+" ");    
+           nlin++;
+           if (request.t_nl == "1") { lnro=nlin; }
+		     fileRpt.writeln(lnro+" ");    
+           nlin++;
+           if (request.t_nl == "1") { lnro=nlin; }
+		     fileRpt.writeln(lnro+" ");    
+           nlin++;
+           if (request.t_nl == "1") { lnro=nlin; }
+//		     fileRpt.writeln(lnro+" ");    
+//           nlin++;
+		     fileRpt.writeln(lnro+" ");    
+           nlin++;
+           if (request.t_nl == "1") { lnro=nlin; }
+		     fileRpt.writeln(lnro+"                           "+c_bancos.nombre+"              "+c_bancos.entidad+" ");        
+           nlin++;
+           if (request.t_nl == "1") { lnro=nlin; }
+		     fileRpt.writeln(lnro+"                           "+c_bancos.domicilio+"              "+c_bancos.sucursal+"  "+c_bancos.cod_control+"  ");        
+           nlin++;
+           if (request.t_nl == "1") { lnro=nlin; }
+		     fileRpt.writeln(lnro+"                           "+c_bancos.cod_postal+" "+c_bancos.localidad+"                     "+c_bancos.nro_cc+"  ");
+           nlin++;
+           if (request.t_nl == "1") { lnro=nlin; }
+        while ( nlin <= PaperLines ) {
+		    fileRpt.writeln(lnro+" ");
+		    nlin++;
+          if (request.t_nl == "1") { lnro=nlin; }
+        }
+		  // Cerrando cursores
+		  c_proveedores.close(); 
+		  c_bancos.close();
+		  c_docspago.close();
+        nlin=1;
+   }		  
+   c_nrodocspago.close();
+   fileRpt.writeln('
');
+   fileRpt.writeln('');
+   fileRpt.writeln('');
+   fileRpt.writeln('');
+   fileRpt.close();
+}
+function out_doctalon() {
+   var fileRpt=new File(nomFile);
+   fileRpt.open("w");
+   fileRpt.writeln('');
+   fileRpt.writeln('');
+   fileRpt.writeln('');
+   fileRpt.writeln('');
+   fileRpt.writeln('
 ');
+   c_nrodocspago = database.cursor("SELECT UNIQUE nro_doc_pago FROM docspago WHERE uid="+ request.uid+" ORDER BY nro_doc_pago ");
+   var f_pago = new Date(); 
+   var cadena="                                                                                "; 
+   var loncad=cadena.length;
+   var nlin=1;
+   var lnro="";
+   while (c_nrodocspago.next()) {
+ 		  c_docspago = database.cursor("SELECT importe_total FROM docspago WHERE uid="+ request.uid+
+                " and nro_doc_pago='"+c_nrodocspago.nro_doc_pago+"' ");
+		  var importeTotal=0;
+        while (c_docspago.next()) {   // A Sumar ....
+		      importeTotal=importeTotal+parseFloat(c_docspago.importe_total);  
+        } 
+        c_docspago.close();
+ 		  c_docspago = database.cursor("SELECT * FROM docspago WHERE uid="+ request.uid+
+                " and nro_doc_pago='"+c_nrodocspago.nro_doc_pago+"' ORDER BY nro_reg ");
+		  c_docspago.next();
+		  CursorTabla("pr","nif","=\'"+StringClip(false,c_docspago.nif)+"\'",false,false);
+		  CursorTabla("ba","cod_banco","=\'"+StringClip(false,c_docspago.cod_banco)+"\'",false,false);
+        ntal=1;
+        if (request.t_nl == "1") { lnro=nlin; }
+        if ( nlin > 1 ) {
+    		  for (n=1; n<1 ; n++) {
+	   	      fileRpt.writeln(nlin+" ");
+               nlin++;
+               if (request.t_nl == "1") { lnro=nlin; }
+           }
+		  }    
+        if ( nlin == 1 ) 
+             ntal=3
+//              123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 23456789 123       
+        if (request.t_nl == "1") { lnro=nlin; }
+        while (ntal < c_bancos.l_importe) {
+		    fileRpt.writeln(lnro+" ");
+		    nlin++; ntal++;
+          if (request.t_nl == "1") { lnro=nlin; }
+        }
+        linea=cadena;
+        nro=NroFormat(importeTotal,NF9);
+        linea=linea.substring(0,c_bancos.c_importe)+"#"+StringClip(true,nro)+"#";
+	     fileRpt.writeln(linea);  
+  	     nlin++; ntal++;
+        if (request.t_nl == "1") { lnro=nlin; } 
+        while (ntal < c_bancos.l_paguese) {
+		    fileRpt.writeln(lnro+" ");
+		    nlin++; ntal++;
+          if (request.t_nl == "1") { lnro=nlin; }
+        }
+        linea=cadena;
+        linea=linea.substring(0,c_bancos.c_paguese)+StringClip(false,c_proveedores.razon_social);
+	     fileRpt.writeln(linea);  
+  	     nlin++; ntal++;
+        if (request.t_nl == "1") { lnro=nlin; }
+        while (ntal < c_bancos.l1_nroletra) {
+		    fileRpt.writeln(lnro+" ");
+		    nlin++; ntal++;
+        }
+        if (request.t_nl == "1") { lnro=nlin; }
+        num_let="";
+        if (importeTotal > 0 ) 
+            nro_letra(importeTotal, "spa", "f", "PESETAS", CarPad,LongLine,LongLine);
+//debug(num_let)
+//debug(num_let2)
+        linea=cadena;
+        linea=linea.substring(0,c_bancos.c1_nroletra)+num_let;
+	     fileRpt.writeln(linea);  
+  	     nlin++; ntal++;
+        if (request.t_nl == "1") { lnro=nlin; }
+        while (ntal < c_bancos.l2_nroletra) {
+		    fileRpt.writeln(lnro+" ");
+		    nlin++; ntal++;
+        }
+        if (request.t_nl == "1") { lnro=nlin; }
+        linea=cadena;
+        linea=linea.substring(0,c_bancos.c2_nroletra)+num_let2;
+	     fileRpt.writeln(linea);  
+  	     nlin++; ntal++;
+        if (request.t_nl == "1") { lnro=nlin; }
+        num_let="";
+        AsignaFecha(datetoString(c_docspago.f_pago),f_pago);
+        importeTotal=f_pago.getDate();
+        if (importeTotal > 0 ) 
+            nro_letra(importeTotal, "spa", "m", "", "",LongLine,LongLine);
+        if (request.t_nl == "1") { lnro=nlin; } 
+        while (ntal < c_bancos.l_fecha) {
+		    fileRpt.writeln(lnro+" ");
+		    nlin++; ntal++;
+          if (request.t_nl == "1") { lnro=nlin; }
+        }
+        linea=cadena;
+        linea=linea.substring(0,c_bancos.c_fecha)+num_let;
+        lonlin=linea.length;
+        linea=linea+cadena.substring(lonlin,loncad);
+        linea=linea.substring(0,c_bancos.c_mes)+stringMonth(f_pago.getMonth()); //CalendarMonth();
+        linea=linea+cadena.substring(lonlin,loncad);
+        anno=""+f_pago.getYear();
+        linea=linea.substring(0,c_bancos.c_anno)+anno; //.substring(2,4)
+        if (request.t_nl == "1") { lnro=nlin; }
+	     fileRpt.writeln(linea);  
+  	     nlin++; ntal++;
+        if (request.t_nl == "1") { lnro=nlin; }
+        while (ntal < c_bancos.l1_firmado) {
+		    fileRpt.writeln(lnro+" ");
+		    nlin++; ntal++;
+          if (request.t_nl == "1") { lnro=nlin; }
+        }
+        linea=cadena;
+        linea=linea.substring(0,c_bancos.c1_firmado)+StringClip(false,c_bancos.t1_firmado);
+        if (request.t_nl == "1") { lnro=nlin; }
+	     fileRpt.writeln(linea);  
+  	     nlin++; ntal++;
+        if (request.t_nl == "1") { lnro=nlin; }
+        while (ntal < c_bancos.l2_firmado) {
+		    fileRpt.writeln(lnro+" ");
+		    nlin++; ntal++;
+          if (request.t_nl == "1") { lnro=nlin; }
+        }
+        linea=cadena;
+        linea=linea.substring(0,c_bancos.c2_firmado)+StringClip(false,c_bancos.t2_firmado);
+	     fileRpt.writeln(linea);  
+  	     nlin++; ntal++;
+        if (request.t_nl == "1") { lnro=nlin; }
+        while (ntal < c_bancos.nro_lins) {
+		    fileRpt.writeln(lnro+" ");
+		    nlin++; ntal++;
+          if (request.t_nl == "1") { lnro=nlin; }
+        }
+//         123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 23456789 123         
+        if (nlin == PaperTLines ) 
+          nlin=1;
+		  // Cerrando cursores
+		  c_proveedores.close(); 
+		  c_bancos.close();
+		  c_docspago.close();
+   }		  
+   c_nrodocspago.close();
+   fileRpt.writeln('
');
+   fileRpt.writeln('');
+   fileRpt.writeln('');
+   fileRpt.writeln('');
+   fileRpt.close();
+}
+function out_doccarta() {
+   var fileRpt=new File(nomCarta);
+   fileRpt.open("w");
+   fileRpt.writeln('');
+   fileRpt.writeln('');
+   fileRpt.writeln('');
+   fileRpt.writeln('');
+   fileRpt.writeln('
 ');
+   c_nrodocspago = database.cursor("SELECT UNIQUE nro_doc_pago FROM docspago WHERE uid="+ request.uid+" ORDER BY nro_doc_pago ");
+   var PlusNroDoc=0;    // Acumula incrementos en Nro. Doc si salto página
+   var lnro="";
+   while (c_nrodocspago.next()) {
+ 		  c_docspago = database.cursor("SELECT importe_total FROM docspago WHERE uid="+ request.uid+
+                " and nro_doc_pago='"+c_nrodocspago.nro_doc_pago+"' ");
+		  var importeTotal=0;
+        var NeedLins=0;
+        while (c_docspago.next()) {   // A Sumar ....
+		      importeTotal=importeTotal+parseFloat(c_docspago.importe_total);  
+		      NeedLins++;
+        } 
+        c_docspago.close();
+ 		  c_docspago = database.cursor("SELECT * FROM docspago WHERE uid="+ request.uid+
+                " and nro_doc_pago='"+c_nrodocspago.nro_doc_pago+"' ORDER BY nro_reg ");
+		  c_docspago.next();
+		  CursorTabla("pr","nif","=\'"+StringClip(false,c_docspago.nif)+"\'",false,false);
+		  CursorTabla("ba","cod_banco","=\'"+StringClip(false,c_docspago.cod_banco)+"\'",false,false);
+        nlin=1;
+        if (request.t_nl == "1") { lnro=nlin; }
+		  for (n=1; n<13 ; n++) {
+		      fileRpt.writeln(lnro+" ");
+            nlin++;
+            if (request.t_nl == "1") { lnro=nlin; }
+		  }    
+        fileRpt.writeln(lnro+"           Málaga,"+datetoString(c_docspago.f_emision_pago));
+        nlin++;
+        if (request.t_nl == "1") { lnro=nlin; }
+//         123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 23456789 123       
+//		  direccion=StringClip(false,c_proveedores.direccion_envio);
+//        localidad=StringClip(false,c_proveedores.cod_postal_envio)+" "+StringClip(false,c_proveedores.localidad_envio);
+//		  if ( direccion == "" || direccion == " " ) {
+  		      direccion=StringClip(false,c_proveedores.domicilio);
+   		   localidad=StringClip(false,c_proveedores.cod_postal)+" "+c_proveedores.localidad;
+//		  }
+//		  attn_envio=StringClip(false,c_proveedores.attn_envio);
+//		  fileRpt.writeln(lnro+"                                                 "+c_proveedores.attn_envio+" ");
+		  fileRpt.writeln(lnro+"                                                    "+StringClip(false,c_proveedores.razon_social)+" ");
+        nlin++;
+        if (request.t_nl == "1") { lnro=nlin; }
+		  fileRpt.writeln(lnro+"                                                    "+direccion+" ");
+        nlin++;
+        if (request.t_nl == "1") { lnro=nlin; }
+		  fileRpt.writeln(lnro+"                                                    "+localidad+" ");
+        nlin++;
+        if (request.t_nl == "1") { lnro=nlin; }
+		  for (n=1; n<3 ; n++) {
+		    fileRpt.writeln(lnro+" ");
+		    nlin++;
+          if (request.t_nl == "1") { lnro=nlin; }
+        }
+        if ( NeedLins > BodyLines) {
+             PlusNroDoc++;
+	     }
+        var nro_doc_pago=parseFloat(c_docspago.nro_doc_pago)+PlusNroDoc;
+        if (PlusNroDoc > 0 ) {   
+          status=database.execute("UPDATE docspago SET nro_doc_pago='"+nro_doc_pago+"' WHERE nro_reg='"+c_docspago.nro_reg+"'");                
+   	  }
+		  fileRpt.writeln(lnro+" ");
+        nlin++;
+        if (request.t_nl == "1") { lnro=nlin; }
+		  fileRpt.writeln(lnro+" ");
+        nlin++;
+        if (request.t_nl == "1") { lnro=nlin; }
+        fileRpt.writeln(lnro+"           Muy Sres. nuestros:");  
+        nlin++;
+        if (request.t_nl == "1") { lnro=nlin; }
+		  fileRpt.writeln(lnro+" ");
+        nlin++;
+        if (request.t_nl == "1") { lnro=nlin; }
+		  fileRpt.writeln(lnro+"                     Adjunto les remitimos talón nro. "+nro_doc_pago+" a cargo del ");  
+        nlin++;   
+        if (request.t_nl == "1") { lnro=nlin; }
+		  fileRpt.writeln(lnro+"           "+StringClip(false,c_bancos.nombre)+" de pesetas "+NroFormat(importeTotal,NF9)+",");
+        nlin++;
+        if (request.t_nl == "1") { lnro=nlin; }
+		  fileRpt.writeln(lnro+"           con el cual cancelamos las facturas siguientes: ");
+        nlin++;  
+        if (request.t_nl == "1") { lnro=nlin; }
+		  fileRpt.writeln(lnro+" ");
+        nlin++;
+        if (request.t_nl == "1") { lnro=nlin; }
+		  fileRpt.writeln(lnro+"                    Centro   Registro      Importe            Nro.Fra ");
+        nlin++; 
+        if (request.t_nl == "1") { lnro=nlin; }
+		  fileRpt.writeln(lnro+"                    ------  ---------   ----------------    ----------------");
+        nlin++;
+        if (request.t_nl == "1") { lnro=nlin; }
+        blin=0;
+		  while (true) {
+            blin++;
+            codCentro=StringClip(false,c_docspago.cod_centro);
+            if ( c_docspago.importe_total < 0 ) 
+                 codCentro="      ";
+		      var nreg=c_docspago.nro_reg.substring(4,10)+"/"+c_docspago.nro_reg.substring(2,4);
+		      fileRpt.writeln(lnro+"                    "+codCentro+"   "+nreg+"    "+NroFormat(c_docspago.importe_total,NF9)+" Ptas."+"  "+StringClip(false,c_docspago.nro_fra));  
+            nlin++;
+            if (request.t_nl == "1") { lnro=nlin; }
+            if ( nlin == FootPosLin ) {
+                for (var i=nlin ; i <= PaperLines ; i++) {
+	             	  fileRpt.writeln(lnro+" ");  
+                    if (request.t_nl == "1") { lnro=nlin; }
+                }
+                for (var i=nlin ; i <= HeadPosLin ; i++) {
+	             	  fileRpt.writeln(lnro+" ");  
+                    if (request.t_nl == "1") { lnro=nlin; }
+                }
+	             nlin=HeadPosLin;	  
+            }
+		      if ( !c_docspago.next()) 
+            break;
+		  }
+        if (request.t_nl == "1") { lnro=nlin; }
+		  while ( blin < BodyLines ) {
+    	   	    fileRpt.writeln(lnro+" ");  
+                nlin++; 
+                blin++;
+                if (request.t_nl == "1") { lnro=nlin; }
+        }
+		  fileRpt.writeln(lnro+"                     A la espera de que el mencionado importe sea de su entera ");
+        nlin++;  
+        if (request.t_nl == "1") { lnro=nlin; }
+		  fileRpt.writeln(lnro+"           conformidad, reciban un cordial saludo.");
+        nlin++;   
+        if (request.t_nl == "1") { lnro=nlin; }
+		  fileRpt.writeln(lnro+" ");  
+        nlin++; 
+        if (request.t_nl == "1") { lnro=nlin; }
+		  fileRpt.writeln(lnro+"                        CONSTRUCCIONES SANCHEZ DOMINGUEZ-SANDO, S.A. ");  
+        nlin++;
+        if (request.t_nl == "1") { lnro=nlin; }
+        while ( nlin <= PaperTray ) {
+		    fileRpt.writeln(lnro+" ");
+		    nlin++;
+          if (request.t_nl == "1") { lnro=nlin; }
+        }
+		  // Cerrando cursores
+		  c_proveedores.close(); 
+		  c_bancos.close();
+		  c_docspago.close();
+   }		  
+   c_nrodocspago.close();
+   fileRpt.writeln('
');
+   fileRpt.writeln('');
+   fileRpt.writeln('');
+   fileRpt.writeln('');
+   fileRpt.close();
+}
+function out_docfichero() {
+   var fileRpt=new File(nomFich);
+   fileRpt.open("w");
+   c_nrodocspago = database.cursor("SELECT UNIQUE nro_doc_pago FROM docspago WHERE uid="+ request.uid+" ORDER BY nro_doc_pago ");
+   var PlusNroDoc=0;    // Acumula incrementos en Nro. Doc si salto página
+   var lnro="";
+   while (c_nrodocspago.next()) {
+ 		  c_docspago = database.cursor("SELECT importe_total FROM docspago WHERE uid="+ request.uid+
+                " and nro_doc_pago='"+c_nrodocspago.nro_doc_pago+"' ");
+		  var importeTotal=0;
+        var NeedLins=0;
+        while (c_docspago.next()) {   // A Sumar ....
+		      importeTotal=importeTotal+parseFloat(c_docspago.importe_total);  
+		      NeedLins++;
+        } 
+        c_docspago.close();
+ 		  c_docspago = database.cursor("SELECT * FROM docspago WHERE uid="+ request.uid+
+                " and nro_doc_pago='"+c_nrodocspago.nro_doc_pago+"' ORDER BY nro_reg ");
+		  c_docspago.next();
+
+		  CursorTabla("pr","nif","=\'"+StringClip(false,c_docspago.nif)+"\'",false,false);
+        linea="                                       ";
+        linea=StringClip(false,c_proveedores.razon_social)+linea;
+		  fileRpt.writeln(linea.substring(0,40)+" "+importeTotal);
+		  // Cerrando cursores
+		  c_proveedores.close(); 
+		  c_docspago.close();
+   }		  
+   c_nrodocspago.close();
+   fileRpt.close();
+}
+
+function rpt_test() {
+   var fileRpt=new File(nomTest);
+   fileRpt.open("w");
+   fileRpt.writeln('');
+   fileRpt.writeln('');
+   fileRpt.writeln('');
+   fileRpt.writeln('');
+   fileRpt.writeln('
 ');
+   var cadena="";
+   for (n=1; n< 8 ; n++) {
+       cadena=cadena+"123456789 "
+   }
+   fileRpt.writeln(cadena);
+   for (n=1; n< PaperLines ; n++) {
+        fileRpt.writeln(n);
+   }         
+   fileRpt.writeln('
');
+   fileRpt.writeln('');
+   fileRpt.writeln('');
+   fileRpt.writeln('');
+   fileRpt.close();
+   writeln('w_outtest=window.open("'+urlTest+'","w_test","toolbar=yes,directories=no,menubar=yes,status=no,scrollbars=yes,resizable=yes,width=600,height=500");');
+}
+
+function rpt_docpago() {
+   c_docspago= database.cursor("SELECT * FROM docspago WHERE uid='"+request.uid+"' order by nro_doc_pago ");
+   var fileRpt=new File(nomList);
+   fileRpt.open("w");
+   fileRpt.writeln('');
+   fileRpt.writeln('');
+   var suma_total=0;
+   var nlins=0;
+   var npag=1;
+   var is_newpag=true;
+   request.maxLins=53;
+   while (c_docspago.next()) {
+	  CursorTabla("pr","nif","=\'"+StringClip(false,c_docspago.nif)+"\'",false,false);
+	  CursorTabla("fa","nro_reg","=\'"+StringClip(false,c_docspago.nro_reg)+"\'",false,false);
+//     if ( nlins+3 == request.maxLins ) { 
+//          fileRpt.writeln('


'); +// nlins=0; +// is_newpag=true; +// }; + if ( is_newpag == true ) { + if (npag > 1 ) { fileRpt.write('
Nro.Alb.Fecha Al.N.I.F.Razón SocialCuentaImp.Cta.Reg.Fra.
')}; + fileRpt.writeln('Dpto. Cuentas a Pagar

'); + fileRpt.writeln('

LISTADO DE PAGOS PENDIENTES DE CONFIRMAR

'); + fileRpt.writeln('
'); + is_newpag=false; + nlins=nlins+4; + set_head=true; + npag++; + } + if ( set_head == true ) { + fileRpt.writeln('
'); + fileRpt.writeln(" "+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""); + nlins=nlins+2; set_head=false; + } +// "/" + c_docspago.nro_reg.substring(0,4) +""+ + fileRpt.writeln("" + + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""); + suma_total=suma_total+c_docspago.importe_total; + nlins++; + c_proveedores.close(); + c_facturas.close(); + } +// writeln(""); +// writeln(""); + fileRpt.writeln('
N.Reg." + + "F.Vto.Pago Centro ProveedorTot.Fra.Nro.Doc.BancoImporte
"+c_docspago.nro_reg.substring(4,c_docspago.nro_reg.length) + ""+datetoString(c_docspago.vto_pago) +""+c_docspago.cod_centro +""+c_proveedores.razon_social +""+NroFormat(c_facturas.importe_total,NF9)+""+StringClip(false,c_docspago.nro_doc_pago) +""+StringClip(false,c_docspago.cod_banco) +""+NroFormat(c_docspago.importe_total,NF9)+"
----------------
Suma Total:"+NroFormat(suma_total,NF10) +"
'); + fileRpt.writeln('
'); + fileRpt.writeln(""+ + ""); + fileRpt.writeln('
TOTAL Acumulado....... "+NroFormat(suma_total,NF11)+"
'); + fileRpt.writeln('
'); + fileRpt.writeln(''); + fileRpt.writeln(''); + fileRpt.close(); + writeln('w_outtest=window.open("'+urlList+'","w_list","toolbar=yes,directories=no,menubar=yes,status=no,scrollbars=yes,resizable=yes,width=600,height=500");'); + +} diff --git a/l_factura.js b/l_factura.js new file mode 100644 index 0000000..3116d39 --- /dev/null +++ b/l_factura.js @@ -0,0 +1,477 @@ +////////////////////////////////////// +// // +// JavaScript Functions // +// // +////////////////////////////////////// +function report_fra() { + var npag=0; + var nrolin=0; + while (c_factreg.next()) { +// if ( nrolin <= request.maxLins && npag >0 ) { +// skipTopPage(nrolin,request.maxLins); +// nrolin=0; +// } +// npag++;; + if (request.f_formato=="proveedor") + FraProveedorHtml(); + if (request.f_formato=="centro") + FraCentroHtml(); + if (request.f_formato=="pendientes") + FraPendientesHtml(); + if (request.f_formato=="emitidas") + FraEmitidasHtml(); + if (request.f_formato=="provBloq") + FraRetenidasHtml(); + if (request.f_formato=="documento") + nrolin=FraDocHtml(c_factreg.nro_reg); + } +} +function FraProveedorHtml() { + var suma_total=0; + var suma_prov=0; + var nrolin=0; + var keyLastRow="-"; + var is_newpag=true; + while (true) { + if ( nrolin+3 == request.maxLins ) { + fileRpt.writeln('


'); + nrolin=0; + is_newpag=true; + }; + if ( keyLastRow != c_factreg.nif && keyLastRow !="-") { + fileRpt.writeln(''); + fileRpt.writeln('
'); + fileRpt.writeln(""+ + ""); + fileRpt.writeln('
TOTAL .... "+NroFormat(suma_prov,NF11)+"

'); + suma_prov=0; + nrolin=nrolin+3 + set_head=true; + } + if ( is_newpag == true ) { + if ( keyLastRow !="-" ) { fileRpt.writeln('')}; + fileRpt.writeln('Dpto. Cuentas a Pagar

'); + fileRpt.writeln('

LISTADO DE FACTURAS POR PROVEEDOR

'); + fileRpt.writeln('
'); + is_newpag=false; + nrolin=nrolin+4; + set_head=true; + } + if ( set_head == true ) { + fileRpt.writeln('
'); + fileRpt.writeln(""+ + ""); + fileRpt.writeln('
"+c_factreg.nif +""+c_factreg.razon_social+"
'); + fileRpt.writeln('
'); + fileRpt.writeln(" "+ + ""+ + ""+ + ""+ + ""); + nrolin=nrolin+3; set_head=false; + } + fileRpt.writeln(""+ + ""+ + ""+ + ""+ + ""+ + ""); + suma_total=suma_total+c_factreg.importe_total; + suma_prov=suma_prov+c_factreg.importe_total; + keyLastRow=c_factreg.nif; + nrolin++; + if (!c_factreg.next()) + break; + } +// writeln(""); +// writeln(""); + fileRpt.writeln('
Nro. Reg." + + "F.Emisión Nro. Fra.Centro Vto. PagoImporte
"+c_factreg.nro_reg.substring(4,c_factreg.nro_reg.length) + "/" + + c_factreg.nro_reg.substring(0,4) +""+datetoString(c_factreg.f_emision) +""+c_factreg.nro_fra +""+c_factreg.cod_centro +""+datetoString(c_factreg.vto_pago) +""+NroFormat(c_factreg.importe_total,NF9)+"
----------------
Suma Total:"+NroFormat(suma_total,NF10) +"
'); + fileRpt.writeln(''); + fileRpt.writeln(""+ + ""); + fileRpt.writeln('
TOTAL .... "+NroFormat(suma_prov,NF11)+"
'); + fileRpt.writeln('
'); + fileRpt.writeln(""+ + ""); + fileRpt.writeln('
TOTAL Acumulado....... "+NroFormat(suma_total,NF11)+"
'); +} +function FraCentroHtml() { + request.s_iva=0; + request.s_ctas=0; + request.s_ret=0; + request.s_total=0; + request.s_prov=0; + request.s_albs=0; + var nrolin=0; + var keyLastRow="-"; + var desLastRow=""; + var keyLastPrv=""; + var set_head=true; + var s_seq=getSeqPrt(nprinter); + textoReqs=textoReqs+" "+s_seq; + var nomFile=spoolpath+nprinter+"/req_"+s_seq+".html" + fileRpt=new File(nomFile); + fileRpt.open("w"); + fileRpt.writeln(''); + fileRpt.writeln(''); + status=database.execute("DELETE FROM sumactasfra where uid=\'" + request.uid+ "\'"); + while (true){ + if ( nrolin+3 == request.maxLins ) { + fileRpt.writeln('


'); + nrolin=0; + set_head=true; + }; + if ( keyLastPrv != c_factreg.nif ) { + keyLastPrv=c_factreg.nif; + s_prov=0; + } + if ( keyLastRow != c_factreg.cod_centro && keyLastRow !="-" ) { + nrolin++; + fileRpt.writeln("TOTAL .... "+ +// ""+NroFormat(suma_ctas,NF11)+""); + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+NroFormat(request.s_ctas,NF11)+""+ + ""+NroFormat(request.s_ret,NF11)+""+ + ""+NroFormat(request.s_iva,NF11)+""+ + ""+NroFormat(request.s_total,NF11)+""+ + ""+ + ""+NroFormat(request.s_albs,NF11)+""+ + ""+ + ""); + fileRpt.writeln('

'); + FraResCentrosHtml(keyLastRow,desLastRow); + fileRpt.writeln(''); + fileRpt.writeln(''); + fileRpt.close(); + s_seq=getSeqPrt(nprinter); + textoReqs=textoReqs+" "+s_seq; + nomFile=spoolpath+nprinter+"/req_"+s_seq+".html" + fileRpt=new File(nomFile); + fileRpt.open("w"); + fileRpt.writeln(''); + fileRpt.writeln(''); +// if ( nrolin <= request.maxLins ) { +// skipTopPage(nrolin,request.maxLins); +// nrolin=0; +// set_head=true; +// } + request.s_iva=0; + request.s_ctas=0; + request.s_ret=0; + request.s_total=0; + request.s_prov=0; + request.s_albs=0; + nrolin=nrolin+3 + set_head=true; + } + if ( set_head == true ) { + nrolin=nrolin+6; + if ( keyLastRow !="-" ) + fileRpt.writeln(""); + FraCentrosCab(); + set_head=false; + } + s_iva=c_factreg.iva_1+c_factreg.iva_2+c_factreg.iva_3; + s_ret=c_factreg.ret_1+c_factreg.ret_2+c_factreg.ret_3; +// request.s_prov=request.s_prov+c_factreg.importe_total; + c_aptesfra = database.cursor("SELECT * from aptectasfra where nro_reg='"+ + c_factreg.nro_reg+"' and nro_lin > 9 ") + c_albafra = database.cursor("SELECT * from albafras where nroreg_factura='"+ + c_factreg.nro_reg+"' order by nroreg_albafact ") + if (c_aptesfra.next()) { + insCtaFra(); + if (c_albafra.next()) { + a_nroreg=c_albafra.nroreg_albaran; + a_sumactas=NroFormat(c_albafra.sumactas,NF9) + request.s_albs=parseFloat(request.s_albs)+parseFloat(c_albafra.sumactas); + } + else { + a_nroreg=""; + a_sumactas=""; + } + importe=parseFloat(c_aptesfra.importe); + if ( c_aptesfra.tipo_apte == "H" ) + importe=parseFloat(c_aptesfra.importe)*-1; + if ( nrolin+1 > request.maxLins ) { + skipTopPage(nrolin,request.maxLins); + nrolin=6; + fileRpt.writeln(""); + FraCentrosCab(); + } + nrolin++; + fileRpt.writeln(""+c_factreg.nro_reg.substring(4,c_factreg.nro_reg.length) + +// "/" + c_factreg.nro_reg.substring(0,4) + + ""+ + ""+c_factreg.nro_fra +""+ + ""+datetoString(c_factreg.f_emision) +""+ + ""+datetoString(c_factreg.f_recepcion) +""+ + ""+datetoString(c_factreg.vto_pago) +""+ + ""+c_factreg.tipo_doc_pago+""+ + ""+datetoString(c_factreg.f_emision_pago) +""+ + ""+c_aptesfra.cod_cta+""+ + ""+NroFormat(importe,NF9)+""+ + ""+NroFormat(s_ret,NF9)+""+ + ""+NroFormat(s_iva,NF9)+""+ + ""+NroFormat(c_factreg.importe_total,NF9)+""+ + ""+a_nroreg+""+ + ""+a_sumactas+""+ + ""+c_factreg.razon_social+""+ +// ""+c_factreg.razon_social.substring(0,18)+""+ + "") + request.s_total=parseFloat(request.s_total)+parseFloat(c_factreg.importe_total); + request.s_ret=parseFloat(request.s_ret)+parseFloat(s_ret); + request.s_iva=parseFloat(request.s_iva)+parseFloat(s_iva); + request.s_ctas=parseFloat(request.s_ctas)+parseFloat(importe); + + } + while (c_aptesfra.next()) { + insCtaFra(); + if (c_albafra.next()) { + a_nroreg=c_albafra.nroreg_albaran; + a_sumactas=NroFormat(c_albafra.sumactas,NF9) + request.s_albs=parseFloat(request.s_albs)+parseFloat(c_albafra.sumactas); + } + else { + a_nroreg=""; + a_sumactas=""; + } + importe=parseFloat(c_aptesfra.importe); + if ( c_aptesfra.tipo_apte == "H" ) + importe=parseFloat(c_aptesfra.importe)*-1; + if ( nrolin+1 > request.maxLins ) { + skipTopPage(nrolin,request.maxLins); + nrolin=6; + fileRpt.writeln(""); + FraCentrosCab(); + } + nrolin++; + fileRpt.writeln(""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+c_aptesfra.cod_cta+""+ + ""+NroFormat(importe,NF9)+""+ + ""+ + ""+ + ""+ + ""+a_nroreg+""+ + ""+a_sumactas+""+ + ""+ + ""); + request.s_ctas=parseFloat(request.s_ctas)+parseFloat(importe); + } + c_aptesfra.close(); + while (c_albafra.next()) { + if ( nrolin+1 > request.maxLins ) { + skipTopPage(nrolin,request.maxLins); + nrolin=6; + fileRpt.writeln(""); + FraCentrosCab(); + } + nrolin++; + fileRpt.writeln(""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+c_albafra.nroreg_albaran+""+ + ""+NroFormat(c_albafra.sumactas,NF9)+""+ + ""+ + ""); + request.s_albs=parseFloat(request.s_albs)+parseFloat(c_albafra.sumactas); + } + keyLastRow=c_factreg.cod_centro; + desLastRow=c_factreg.descripcion; + c_albafra.close(); + if (!c_factreg.next()) + break; + } + fileRpt.writeln("TOTAL .... "+ +// ""+NroFormat(suma_ctas,NF11)+""); + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+NroFormat(request.s_ctas,NF11)+""+ + ""+NroFormat(request.s_ret,NF11)+""+ + ""+NroFormat(request.s_iva,NF11)+""+ + ""+NroFormat(request.s_total,NF11)+""+ + ""+ + ""+NroFormat(request.s_albs,NF11)+""+ + ""+ + ""); + fileRpt.writeln(''); + FraResCentrosHtml(keyLastRow,desLastRow); + fileRpt.writeln(''); + fileRpt.writeln(''); + fileRpt.close(); +} +function insCtaFra() { + importe=parseFloat(c_aptesfra.importe); + if ( c_aptesfra.tipo_apte == "H" ) + importe=parseFloat(c_aptesfra.importe)*-1; + status=database.execute("INSERT INTO sumactasfra(" + + " uid," + + " cod_centro," + + " cod_cta," + + " importe) VALUES ('" + + request.uid + "','" + + StringClip(true,c_factreg.cod_centro) + "','" + + StringClip(true,c_aptesfra.cod_cta) + "','" + + importe+ "')"); +} +function FraResCentrosHtml(clave,desclave) { + c_ctascentro = database.cursor("SELECT cod_cta,sum(importe) from sumactasfra where cod_centro=\'" +clave+"\' and uid=\'" + request.uid+ + "\' group by cod_cta "); + fileRpt.writeln('
'); + fileRpt.writeln('

RESUMEN DE CUENTAS POR CENTRO

'); + fileRpt.writeln('
'); +// fileRpt.writeln(''); +// fileRpt.writeln("
"+clave +""+ +// ""+desclave+""); +// fileRpt.writeln('


'); + fileRpt.writeln(""+clave +desclave+""); + fileRpt.writeln(''); + fileRpt.writeln("" + + ""+ + ""); + request.s_total=0; + while ( c_ctascentro.next()) { + fileRpt.writeln(""+ + ""+ + ""+ + ""); + request.s_total=parseFloat(request.s_total)+parseFloat(c_ctascentro[1]); + } + c_ctascentro.close(); + fileRpt.writeln(""+ + ""); + fileRpt.writeln('
Cod. Cta.Importe
"+c_ctascentro.cod_cta+""+NroFormat(c_ctascentro[1],NF11)+"
TOTAL"+NroFormat(request.s_total,NF11)+"
'); + fileRpt.writeln('

'); +} +function FraCentrosCab() { + fileRpt.writeln('
Dpto. Cuentas a Pagar'); + fileRpt.writeln('
'); + fileRpt.writeln('

LISTADO DE FACTURAS POR CENTRO

'); + fileRpt.writeln('
'); + fileRpt.writeln(''); + fileRpt.writeln(""+c_factreg.cod_centro +c_factreg.descripcion+""); + fileRpt.writeln(''); + fileRpt.writeln("" + + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ +// ""+ + ""); +} +function FraPendientesHtml() { +} +function FraEmitidasHtml() { + var suma_total=0; + var suma_banco=0; + var nrolin=0; + var npag=1; + var keyLastRow=""; + var is_newpag=true; + while (true) { + if ( nrolin+3 == request.maxLins ) { + fileRpt.writeln('


'); + nrolin=0; + is_newpag=true; + }; + if ( keyLastRow != c_factreg.nif && npag!=1 ) { + fileRpt.writeln('
Nro.Reg.Nro. Fra.F.Fra.F.Recep.F.PagoTDF.Emis.CuentaImp.Cta.RetenciónI.V.A.Total Fra.Alb.Int.Alb.Imp.Razón SocialImp.Prov.
'); + fileRpt.writeln('
'); + fileRpt.writeln(""+ + ""); + fileRpt.writeln('
TOTAL .... "+NroFormat(suma_banco,NF11)+"

'); + suma_banco=0; + nrolin=nrolin+3 + set_head=true; + } + if ( is_newpag == true ) { + if (npag > 1 ) { fileRpt.writeln('')}; + fileRpt.writeln('
Dpto. Cuentas a Pagar

'); + fileRpt.writeln('

LISTADO DE PAGARES EMITIDOS

'); +// 'Pág.:'+npag+' '); + fileRpt.writeln('
'); + is_newpag=false; + nrolin=nrolin+4; + set_head=true; + npag++; + } + if ( set_head == true ) { + fileRpt.writeln('
'); + fileRpt.writeln(""+ + ""); + fileRpt.writeln('
"+c_factreg.nif +""+c_factreg.razon_social+"
'); + fileRpt.writeln('
'); + fileRpt.writeln(" "+ + ""+ + ""+ + ""+ + ""); + nrolin=nrolin+3; set_head=false; + } + fileRpt.writeln(""+ + ""+ + ""+ + ""+ + ""+ + ""); + suma_total=suma_total+c_factreg.importe_total; + suma_banco=suma_banco+c_factreg.importe_total; + keyLastRow=c_factreg.nif; + nrolin++; + if (!c_factreg.next()) + break; + } +// writeln(""); +// writeln(""); + fileRpt.writeln('
Nro. Reg." + + "F.Emisión Nro. Fra.Centro Vto. PagoImporte
"+c_factreg.nro_reg.substring(4,c_factreg.nro_reg.length) + "/" + + c_factreg.nro_reg.substring(0,4) +""+datetoString(c_factreg.f_emision) +""+c_factreg.nro_fra +""+c_factreg.cod_centro +""+datetoString(c_factreg.vto_pago) +""+NroFormat(c_factreg.importe_total,NF9)+"
----------------
Suma Total:"+NroFormat(suma_total,NF10) +"
'); + fileRpt.writeln(''); + fileRpt.writeln(""+ + ""); + fileRpt.writeln('
TOTAL .... "+NroFormat(suma_prov,NF11)+"
'); + fileRpt.writeln('
'); + fileRpt.writeln(""+ + ""); + fileRpt.writeln('
TOTAL Acumulado....... "+NroFormat(suma_total,NF11)+"
'); +} +function FraRetenidasHtml() { +} + diff --git a/l_prevision.js b/l_prevision.js new file mode 100644 index 0000000..0f05d66 --- /dev/null +++ b/l_prevision.js @@ -0,0 +1,159 @@ +////////////////////////////////////// +// // +// JavaScript Functions // +// // +////////////////////////////////////// +function report_prev() { + var npag=0; + var nrolin=0; +// if (request.f_formato=="documento") + PrevisionHtml(); +} +function PrevisionHtml() { + request.sumaret=0; + request.sumapag=0; + request.sumatal=0; + request.linea=""; + request.suma_lin=0; + request.suma_tot=0; + var nrolin=0; + var set_head=true; +// var s_seq=getSeqPrt(nprinter); +// textoReqs=textoReqs+" "+s_seq; +// var nomFile=spoolpath+nprinter+"/req_"+s_seq+".html" + fileRpt=new File(nomFile); + fileRpt.open("w"); + fileRpt.writeln(''); + fileRpt.writeln(''); + fileRpt.writeln(''); + var keyLastRow="-"; + + c_vtosDate = database.cursor("SELECT unique vto_pago from facturas where tipo_doc_pago = '1' "+ + " and vto_pago >='"+ + request.f_entrada+"' order by vto_pago ") + c_bancos = database.cursor("SELECT cod_banco,nombre FROM bancos where is_locked != 'S' ORDER BY cod_banco "); + while (c_bancos.next()) { + eval ("request.sum_"+c_bancos.cod_banco+"=0"); + } + c_bancos.close(); + + while (c_vtosDate.next()){ + if ( nrolin+3 == request.maxLins ) { + fileRpt.writeln('


'); + nrolin=0; + set_head=true; + }; + if ( set_head == true ) { + nrolin=nrolin+2; + if ( keyLastRow !="-" ) + fileRpt.writeln(""); + PrevisionCab(); + set_head=false; + } + if ( nrolin+1 > request.maxLins ) { + skipTopPage(nrolin,request.maxLins); + nrolin=6; + fileRpt.writeln(""); + PrevisionCab(); + } + c_bancos = database.cursor("SELECT cod_banco,nombre FROM bancos where is_locked != 'S' ORDER BY cod_banco "); + request.linea=""+datetoString(c_vtosDate.vto_pago)+""; + request.suma_lin=0; + while (c_bancos.next()) { + c_vtos = database.cursor("SELECT sum(importe_total) from facturas where tipo_doc_pago = '1' "+ + " and cod_banco = '"+c_bancos.cod_banco+ + "' and vto_pago ='"+datetoString(c_vtosDate.vto_pago)+ + "'") + + c_vtos.next(); + numero=0; + if ( c_vtos[0] > 0 || c_vtos[0] < 0 ) + numero=c_vtos[0]; + request.linea=request.linea+""+NroFormat(numero,NF11)+"" + eval ("request.sum_"+c_bancos.cod_banco+"=parseFloat(request.sum_"+c_bancos.cod_banco+")+parseFloat("+numero+")"); + request.suma_lin=parseFloat(request.suma_lin)+parseFloat(numero); + c_vtos.close(); + } + c_bancos.close(); + c_pagemi = database.cursor("SELECT sum(importe_total),f_pago,tipo_doc_pago from facturas where tipo_doc_pago ='2' "+ + " and vto_pago is null and f_pago ='"+ + datetoString(c_vtosDate.vto_pago)+"' group by tipo_doc_pago, f_pago order by f_pago,tipo_doc_pago") + c_pagemi.next(); + // Suma de Pagos tipo 2 + numero=0; + if ( c_pagemi[0] > 0 || c_pagemi[0] < 0 ) + numero=c_pagemi[0]; + request.linea=request.linea+""+NroFormat(numero,NF11)+"" + request.sumtal=parseFloat(request.sumatal+numero); + request.suma_lin=parseFloat(request.suma_lin)+parseFloat(numero); + c_pagemi.close(); + c_pagemi = database.cursor("SELECT sum(importe_total),f_pago,tipo_doc_pago from facturas where tipo_doc_pago = '1' "+ + " and vto_pago is null and f_pago ='"+ + datetoString(c_vtosDate.vto_pago)+"' group by tipo_doc_pago, f_pago order by f_pago,tipo_doc_pago") + c_pagemi.next(); + // Suma de Pagos tipo 1 + numero=0; + if ( c_pagemi[0] > 0 || c_pagemi[0] < 0 ) + numero=c_pagemi[0]; + request.linea=request.linea+""+NroFormat(numero,NF11)+"" + request.sumpag=parseFloat(request.sumapag+numero); + request.suma_lin=parseFloat(request.suma_lin)+parseFloat(numero); + c_pagemi.close(); + c_reten = database.cursor("SELECT sum(importe_total),f_pago from facturas,proveedores where tipo_doc_pago between '1' and '2' "+ + " and f_emision_pago is null and f_pago ='"+ + datetoString(c_vtosDate.vto_pago)+"' "+ + " and facturas.nif=proveedores.nif "+ + " and ( proveedores.cond_pago = '99' or facturas.cond_pago = '99' )"+ + " group by cod_banco,f_pago order by f_pago") + c_reten.next(); + // Suma de Retenciones + numero=0; + if ( c_reten[0] > 0 || c_reten[0] < 0 ) + numero=c_reten[0]; + request.linea=request.linea+""+NroFormat(numero,NF11)+"" + request.sumret=parseFloat(request.sumaret+numero); + request.suma_lin=parseFloat(request.suma_lin)+parseFloat(numero); + c_reten.close(); + keyLastRow=c_vtosDate.vto_pago; + request.suma_tot=parseFloat(request.suma_tot)+parseFloat(request.suma_lin); + request.linea=request.linea+""+NroFormat(request.suma_lin,NF11)+"" + nrolin++; + fileRpt.writeln(""+request.linea+"") + } + // Acumulados totales + c_vtosDate.close(); + request.linea=""; + c_bancos = database.cursor("SELECT cod_banco,nombre FROM bancos where is_locked != 'S' ORDER BY cod_banco "); + while (c_bancos.next()) { + eval ("request.linea=request.linea+''+NroFormat(request.sum_"+c_bancos.cod_banco+",NF11)+''"); + } + c_bancos.close(); + request.linea=request.linea+""+NroFormat(request.sumatal,NF11)+"" + request.linea=request.linea+""+NroFormat(request.sumapag,NF11)+"" + request.linea=request.linea+""+NroFormat(request.sumaret,NF11)+"" + request.linea=request.linea+""+NroFormat(request.suma_tot,NF11)+"" + fileRpt.writeln("TOTALES"+request.linea+""); + fileRpt.writeln(''); + fileRpt.writeln(''); + fileRpt.writeln(''); + fileRpt.close(); +} +function PrevisionCab() { + request.linea=""; + fileRpt.writeln('
Dpto. Cuentas a Pagar'); + fileRpt.writeln('
'); + fileRpt.writeln('

PREVISIONES

'); + fileRpt.writeln('
'); + fileRpt.writeln(''); + fileRpt.writeln(''); + c_bancos = database.cursor("SELECT cod_banco,acronimo FROM bancos where is_locked != 'S' ORDER BY cod_banco "); + while (c_bancos.next()) { + request.linea=request.linea+" "; + } + c_bancos.close(); + request.linea=request.linea+" "; + request.linea=request.linea+" "; + request.linea=request.linea+" "; + request.linea=request.linea+" "; + fileRpt.writeln(" "+request.linea+""); +} diff --git a/l_trasp_old.js b/l_trasp_old.js new file mode 100644 index 0000000..91e07ad --- /dev/null +++ b/l_trasp_old.js @@ -0,0 +1,386 @@ +////////////////////////////////////// +// // +// JavaScript Functions // +// // +////////////////////////////////////// + +function wrtraspaso(text){ +// writeln("w_outtraspaso.document.write('"+text+"\\n');"); + fileRpt.writeln(text); +} +function chk_traspaso() { + var query; + c_query = database.cursor("select * FROM traspaso WHERE uid=\'" + request.uid+ "\'"); + if (c_query.next()) { + request.criterio=StringClip(false,c_query.criterio); + request.f_traspaso=StringClip(false,c_query.f_traspaso); + request.f_emision=StringClip(false,c_query.f_emision); + request.f_nro_doc=StringClip(false,c_query.f_nro_doc); + request.sel_order=StringClip(false,c_query.sel_order); + writeln(' alert("\\r Existe un Traspaso de '+request.f_traspaso+' Pendientes de Confirmación !!!"); '); + request.opt_traspaso="true"; + } + c_query.close(); + if (request.opt_traspaso) + return true + else + return false +} +function insertaTrasp() { + status=database.execute('INSERT INTO traspaso(' + + ' uid,' + + ' sel_order,'+ + ' criterio,'+ + ' f_traspaso,'+ + ' f_emision,'+ + ' f_nro_doc ) VALUES ("' + request.uid+ '","' + + request.sel_order + '","'+ + request.criterio + '","'+ + request.f_traspaso + '","'+ + request.f_emision + '","'+ + request.f_nro_doc + '")'); + if ( status != 0 ) { + client.is_trans=false; + database.rollbackTransaction(); + redirect(addClient('error.html?alert=14')); + } +} + +function report_traspaso() { + client.is_trans=true; + database.beginTransaction(); + insertaTrasp(); + out_traspaso(); + database.commitTransaction(); + client.is_trans=false; +} +function rpt_traspaso_Doc() { + writeln('w_carta=window.open("'+urlDoc+'","w_traspaso","toolbar=yes,directories=no,menubar=yes,status=no,scrollbars=yes,resizable=yes,width=600,height=500");'); +} +function rpt_traspaso_Data() { + writeln('w_carta=window.open("'+urlData+'","w_traspaso","toolbar=yes,directories=no,menubar=yes,status=no,scrollbars=yes,resizable=yes,width=600,height=500");'); +} + +function cleanup_traspaso() { + // Borramos en tabla de pagos datos del usuario + status=database.execute("DELETE FROM traspaso WHERE uid=\'" + request.uid+ "\'"); + return; +} + +function out_traspaso() { + var Clave="-"; + var SumaTotal=0; + var fileRpt=new File(nomDoc); + fileRpt.open("w"); + var fileData=new File(nomData); + fileData.open("w"); + fileRpt.writeln(''); + fileRpt.writeln(''); + fileRpt.writeln(''); + fileRpt.writeln('
Traspaso de Facturas - '+request.f_traspaso+' - '); + if (request.f_traspaso=="gasto") + fileRpt.writeln(''); + else + fileRpt.writeln(''); + fileRpt.writeln('
 ');
+   fileRpt.writeln('
'); + if (request.f_traspaso=="gasto") + fileRpt.writeln('N.Doc. Línea Fecha Centro Cuenta Cv. DEBE HABER C o n c e p t o F. Vto. Contrap.'); + else { + fileRpt.writeln('
"+c_bancos.acronimo+"CONTADOPAGARESRETENIDOTOTALES
VTOS.
'); + fileRpt.writeln('N.Doc. Línea Fecha Centro Cuenta Cv. DEBE HABER C o n c e p t o F. Vto. Contrap.'); + } + fileRpt.writeln('
'); + linea=" "; +// c_traspaso = database.cursor("SELECT * FROM traspaso WHERE uid="+ request.uid+" ORDER BY nro_reg "); + var nlin=1 + var nro_doc=NroUnformat(request.f_nro_doc); + while (c_traspdocs.next()) { + if (request.f_traspaso=="pago") + c_traspaso = database.cursor("SELECT * FROM facturas,proveedores WHERE facturas.nif=proveedores.nif "+ + " and nro_doc_pago='"+c_traspdocs.nro_doc_pago+"' "+ + " ORDER BY " + request.sel_order); + if (request.f_traspaso=="gasto") + c_traspaso = database.cursor("SELECT * FROM facturas,proveedores WHERE facturas.nif=proveedores.nif "+ + " and nro_reg='"+c_traspdocs.nro_reg+"' "+ + " ORDER BY " + request.sel_order); + if (request.f_traspaso=="vto") + c_traspaso = database.cursor("SELECT * FROM facturas,proveedores WHERE facturas.nif=proveedores.nif "+ + " and nro_reg_vto='"+c_traspdocs.nro_reg_vto+"' "+ + " ORDER BY " + request.sel_order); + while (c_traspaso.next()) { + request.razon_social=c_traspaso.razon_social; + if ( request.f_traspaso=="pago" && Clave == c_traspaso.nro_doc_pago ) + continue; + if ( request.f_traspaso=="vto" && Clave == c_traspaso.nro_reg_vto ) + continue ; + nrolin=1; + if (request.f_traspaso!="vto") + CursorTabla("acf","nro_reg","=\'"+c_traspaso.nro_reg+"\' order by nro_lin ",false,""); + if (request.f_traspaso=="gasto") { + fileRpt.writeln('
'); + while (c_aptectasfra.next()) { + make_apte(nro_doc,"",StringClip(false,c_traspaso.cta_contable),"",nrolin,0); +// if ( nrolin+1 > request.maxLins ) { +// skipTopPage(nrolin,request.maxLins); +// nrolin=0; +// } + fileData.writeln(request.linea); + fileRpt.writeln(request.lindoc); + nrolin++; + } + fileRpt.writeln('
'); + } else { + if (request.f_traspaso!="vto") + c_aptectasfra.next(); +// fileRpt.writeln(''); + if (request.f_traspaso=="pago") + CursorTabla("fa","nro_doc_pago","=\'"+c_traspaso.nro_doc_pago+"\'",true,""); + if (request.f_traspaso=="vto") + CursorTabla("fa","nro_reg_vto","=\'"+c_traspaso.nro_reg_vto+"\'",true,""); + SumaTotal=0; + request.cta_contable=c_traspaso.cta_contable; + request.f_emision_pago=datetoString(c_traspaso.f_emision_pago); + request.is_remesa ="N"; + while ( true ) { + request.nro_reg=c_facturas.nro_reg; + request.nro_fra=c_facturas.nro_fra; + request.nro_doc_pago=c_facturas.nro_doc_pago; + request.importe_total=c_facturas.importe_total; + if ( c_traspaso.nro_doc_pago != c_facturas.nro_doc_pago ) + request.is_remesa ="S"; + if (request.f_traspaso=="pago") { + traspaso_pago(nro_doc,nrolin,"D"); + if (c_facturas.tipo_doc_pago == "1" ) { + fileData.writeln(request.linea); + fileRpt.writeln(request.lindoc); + nrolin++; + traspaso_pago(nro_doc,nrolin,"H"); + Clave=c_traspaso.nro_doc_pago; + } + } + if (request.f_traspaso=="vto") + traspaso_vto(nro_doc,nrolin,"D"); + fileData.writeln(request.linea); + fileRpt.writeln(request.lindoc); + nrolin++; + SumaTotal=parseFloat(c_facturas.importe_total)+parseFloat(SumaTotal); + if (!c_facturas.next()) + break; + } + c_facturas.close(); + request.nro_reg=c_traspaso.nro_reg; + request.nro_fra=c_traspaso.nro_fra; + request.nro_doc_pago=c_traspaso.nro_doc_pago; + request.importe_total=SumaTotal; + if (request.f_traspaso=="pago" && c_traspaso.tipo_doc_pago == "2" ) { + traspaso_pago(nro_doc,nrolin,"H"); + Clave=c_traspaso.nro_doc_pago; + fileData.writeln(request.linea); + fileRpt.writeln(request.lindoc); + nrolin++; + } + if (request.f_traspaso=="vto") { + traspaso_vto(nro_doc,nrolin,"H"); + Clave=c_traspaso.nro_reg_vto; + fileData.writeln(request.linea); + fileRpt.writeln(request.lindoc); + nrolin++; + } +// fileRpt.writeln('
'); + } + if (request.f_traspaso!="vto") + c_aptectasfra.close(); + fileRpt.writeln('
'); + nro_doc++; + } + c_traspaso.close(); + } + c_traspdocs.close(); + fileRpt.writeln(''); + request.lindoc="TOTALES DEBE : "+NroFormat(SumaDebe,NF11); +// request.lindoc=request.lindoc.substring(0,46)+NroFormat(SumaDebe,NF11)+NroFormat(SumaHaber,NF11)+"" + fileRpt.writeln(request.lindoc); + request.lindoc="TOTALES HABER: "+NroFormat(SumaHaber,NF11); + fileRpt.writeln(request.lindoc); + fileRpt.writeln('
');
+ fileRpt.writeln('');
+ fileRpt.writeln('');
+ fileRpt.writeln('');
+ fileRpt.close();
+ fileData.close();
+}
+function traspaso_pago(nro_doc,nrolin,tipoApte) {
+        var DocNro="";
+        var s_cta="";
+        s_banco=parseInt(c_traspaso.cod_banco)+"";
+        lon=s_banco.length;
+        request.d_cod_cta=request.cta_contable;  
+        if (c_traspaso.tipo_doc_pago == "1" )
+              s_cta=request.pag_hpag;
+        if (c_traspaso.tipo_doc_pago == "2" )
+              s_cta=request.pag_htal;
+        s_lon=s_cta.length;
+        request.h_cod_cta=s_cta.substring(0,s_lon-lon)+s_banco;
+        s_lon=request.d_cod_cta.length;
+        if ( tipoApte == "H")  {
+             DocNro=StringClip(false,request.nro_doc_pago)+"";
+             make_apte(nro_doc,request.h_cod_cta,request.d_cod_cta,"H",nrolin,request.importe_total,DocNro);
+        }
+        if ( tipoApte == "D") {
+             DocNro=StringClip(false,request.nro_fra)+" "+request.nro_reg.substring(4,10);
+             make_apte(nro_doc,request.d_cod_cta,request.h_cod_cta,"D",nrolin,request.importe_total,DocNro);
+        }
+}
+
+function traspaso_vto(nro_doc,nrolin,tipoApte) {
+        var DocNro="";
+        var	s_cta="";
+        s_banco=parseInt(c_traspaso.cod_banco)+"";
+        lon=s_banco.length;
+        if (c_traspaso.tipo_doc_pago == "1" )
+              s_cta=request.vto_dpag;
+        if (c_traspaso.tipo_doc_pago == "2" ) 
+              s_cta=request.vto_dtal;
+        s_lon=s_cta.length;
+        request.d_cod_cta=s_cta.substring(0,s_lon-lon)+s_banco;
+        s_lon=request.vto_h.length;
+        request.h_cod_cta=request.vto_h.substring(0,s_lon-lon)+s_banco;
+        DocNro=StringClip(false,request.nro_doc_pago);
+        if ( tipoApte == "H")  {
+             DocNro=StringClip(false,request.nro_doc_pago);
+             if ( request.is_remesa == "S" ) {
+                  lon=c_traspaso.nro_reg_vto.length;
+                  request.razon_social="REMESA "+c_traspaso.nro_reg_vto.substring(5,lon);
+             }   
+             make_apte(nro_doc,request.h_cod_cta,request.d_cod_cta,"H",nrolin,request.importe_total,DocNro);
+        }
+        if ( tipoApte == "D") {
+             if ( request.is_remesa == "S" ) {
+        	         CursorTabla("pr","nif","=\'"+StringClip(true,c_facturas.nif)+"\'",false,false);
+                  request.razon_social=StringClip(false,c_proveedores.razon_social);  	     
+                  c_proveedores.close();
+             }   
+             make_apte(nro_doc,request.d_cod_cta,request.h_cod_cta,"D",nrolin,request.importe_total,DocNro);
+             DocNro=StringClip(false,request.nro_fra)+" "+request.nro_reg.substring(4,10);
+        }
+}
+
+function make_apte(nro_doc,cod_cta,c_cod_cta,tipo_apte,nl,Cantidad,DocNro) {
+             linea="                                                                                                                        ";   
+             request.linea=linea;
+             request.lindoc="";
+             cadena=parseInt(nro_doc)+"";
+             lon=cadena.length;
+             request.linea=request.linea.substring(0,p_nro_doc-lon)+cadena+linea;
+             cadena=parseInt(nl)+"";
+             lon=cadena.length;
+             request.linea=request.linea.substring(0,p_nro_lin-lon)+cadena+linea;
+             request.lindoc=StringClip(false,request.linea);
+             s_cadena=request.f_emision;
+             if (request.f_traspaso=="pago")
+                 s_cadena=request.f_emision_pago;
+             cadena=datetoNString(s_cadena);
+             lon=cadena.length;
+             request.linea=request.linea.substring(0,p_f_cont-lon)+cadena+linea;
+             request.linea=request.linea.substring(0,p_f_emis-lon)+cadena+linea;             
+             request.lindoc=request.lindoc+"  "+s_cadena;
+             cadena=StringClip(false,c_traspaso.cod_centro);
+             request.lindoc=request.lindoc+"  "+cadena;
+             lon=cadena.length;
+             request.linea=request.linea.substring(0,p_centro-lon)+cadena+linea;
+             if (request.f_traspaso=="gasto")
+                 cadena=StringClip(false,c_aptectasfra.cod_cta);
+             if (request.f_traspaso=="pago")
+                 cadena=StringClip(false,cod_cta)+"";
+             if (request.f_traspaso=="vto")
+                 cadena=StringClip(false,cod_cta)+"";
+             request.lindoc=request.lindoc+"  "+cadena;
+             lon=cadena.length;
+             request.linea=request.linea.substring(0,p_cta-lon)+cadena+linea;
+             if (request.f_traspaso=="gasto")
+                 cadena=c_aptectasfra.clave+"";
+             if (request.f_traspaso=="pago")
+                 cadena=request.f_clave+"";
+             if (request.f_traspaso=="vto")
+                 cadena=request.f_clave+"";
+             request.lindoc=request.lindoc+"  "+cadena;
+             clave=cadena;
+             if (request.f_traspaso=="gasto") {
+                  nro=c_aptectasfra.importe;
+                  tipo_apte=c_aptectasfra.tipo_apte;
+             } else {    
+                     nro=Cantidad;
+             }
+             if ( c_traspaso.tipo_doc_pago == "1" ) 
+                cadDoc="P/";
+             if ( c_traspaso.tipo_doc_pago == "2" )              
+                cadDoc="T/";
+             if ( nro < 0 ) {
+                nro=nro*-1;
+                if (request.f_traspaso=="pago" && tipo_apte == "D") 
+                    cadDoc="";
+                if ( tipo_apte == "D" ) 
+                     tipo_apte="H";
+                else
+                     tipo_apte="D";
+             }
+             if (tipo_apte == "H") {
+                    SumaHaber=SumaHaber+nro;
+                    request.lindoc=request.lindoc+"             "+NroFormat(nro,NF9)+"  ";                    
+             } else {
+                    SumaDebe=SumaDebe+nro;
+                    request.lindoc=request.lindoc+"  "+NroFormat(nro,NF9)+"             ";                    
+             };
+             cadena=tipo_apte;
+             lon=cadena.length;
+             request.linea=request.linea.substring(0,p_tipo_apte-lon)+cadena+linea;
+             cadena=NroUnformat(NroFormat(nro,NF9))+"";
+             lon=cadena.length;
+             request.linea=request.linea.substring(0,p_importe-lon)+cadena+linea;
+             lon=clave.length;
+             request.linea=request.linea.substring(0,p_clave-lon)+clave+linea;
+             if (request.f_traspaso=="gasto") {
+                 cadena=StringClip(false,c_aptectasfra.concepto);
+//                   cadena=StringClip(false,c_traspaso.nro_fra)+" "+c_traspaso.nro_reg.substring(4,10)+" "+StringClip(false,request.razon_social);
+             }
+             if (request.f_traspaso=="pago" && tipo_apte == "H") 
+                   cadena=cadDoc+DocNro+" "+StringClip(false,request.razon_social);
+             if (request.f_traspaso=="pago" && tipo_apte == "D") {
+//                 cadena=StringClip(false,c_aptectasfra.concepto);
+                   cadena=DocNro+StringClip(false,request.razon_social);
+             }
+             if (request.f_traspaso=="vto" && tipo_apte == "D")
+                 cadena=cadDoc+DocNro+" "+StringClip(false,request.razon_social);
+             if (request.f_traspaso=="vto" && tipo_apte == "H") {
+                 if ( request.is_remesa == "S" ) 
+                    cadena=StringClip(false,request.razon_social);
+                 else
+                    cadena=cadDoc+DocNro+" "+StringClip(false,request.razon_social);
+             }
+             lon=30; // lon=cadena.length;
+             s_cadena=cadena+linea;
+             request.lindoc=request.lindoc+"  "+s_cadena.substring(0,lon);
+             request.linea=request.linea.substring(0,p_concepto-lon)+cadena.substring(0,lon)+linea;
+             if (request.f_traspaso=="gasto") {
+                 s_cadena="      ";
+					  cadena=s_cadena;
+             }
+             else {
+                 s_cadena=datetoString(c_traspaso.vto_pago);
+                 cadena=datetoNString(s_cadena);
+             }
+             request.lindoc=request.lindoc+"  "+s_cadena;
+             lon=cadena.length;
+             request.linea=request.linea.substring(0,p_vto-lon)+cadena+linea;
+             cadena=StringClip(false,c_cod_cta);
+             lon=cadena.length;
+//texto="p_contracta="+p_contracta+" lon="+lon+" c_cod_cta="+c_cod_cta
+//debug(texto)
+//debug(request.linea)
+             request.lindoc=request.lindoc+"  "+cadena;
+//             if (request.f_traspaso=="pago" && tipo_apte == "H" && cod_cta.substring(0,2) != "41")      
+//                 lon=lon-4;
+             request.linea=request.linea.substring(0,p_contracta-lon)+cadena;
+//debug(request.linea)
+}
diff --git a/l_traspaso.js b/l_traspaso.js
new file mode 100644
index 0000000..4c73bbd
--- /dev/null
+++ b/l_traspaso.js
@@ -0,0 +1,512 @@
+//////////////////////////////////////
+//                                  //
+//     JavaScript Functions         // 
+//                                  //
+//////////////////////////////////////
+
+function wrtraspaso(text){
+//   writeln("w_outtraspaso.document.write('"+text+"\\n');");
+   fileRpt.writeln(text);    
+}
+function chk_traspaso() {
+ var query;
+ c_query = database.cursor("select * FROM traspaso WHERE uid=\'" + request.uid+ "\'");
+ if (c_query.next()) {
+         request.criterio=StringClip(false,c_query.criterio);
+         request.f_traspaso=StringClip(false,c_query.f_traspaso);
+         request.f_emision=StringClip(false,c_query.f_emision);
+         request.f_nro_doc=StringClip(false,c_query.f_nro_doc);
+         request.sel_order=StringClip(false,c_query.sel_order);
+         writeln('         alert("\\r Existe un Traspaso de '+request.f_traspaso+' Pendientes de Confirmación !!!"); ');
+         request.opt_traspaso="true";
+ }
+ c_query.close();
+ if (request.opt_traspaso)
+    return true
+ else 
+    return false
+}
+function insertaTrasp() {
+      status=database.execute('INSERT INTO traspaso(' +
+ 	          ' uid,' +
+ 	          ' sel_order,'+
+ 	          ' criterio,'+
+ 	          ' f_traspaso,'+
+             ' f_emision,'+
+ 	          ' f_nro_doc ) VALUES ("' + request.uid+ '","' + 
+                      request.sel_order + '","'+
+                      request.criterio + '","'+
+                      request.f_traspaso + '","'+
+                      request.f_emision + '","'+
+                      request.f_nro_doc + '")');
+      if ( status != 0 ) {
+         	client.is_trans=false;
+           	database.rollbackTransaction();
+         	redirect(addClient('error.html?alert=14'));
+      }
+}
+
+function report_traspaso() {
+   client.is_trans=true;
+   database.beginTransaction();
+   insertaTrasp();
+   out_traspaso();
+   database.commitTransaction();
+   client.is_trans=false;
+}
+function rpt_traspaso_Doc() {
+   writeln('w_carta=window.open("'+urlDoc+'","w_traspaso","toolbar=yes,directories=no,menubar=yes,status=no,scrollbars=yes,resizable=yes,width=600,height=500");');
+}
+function rpt_traspaso_Data() {
+   writeln('w_carta=window.open("'+urlData+'","w_traspaso","toolbar=yes,directories=no,menubar=yes,status=no,scrollbars=yes,resizable=yes,width=600,height=500");');
+}
+
+function cleanup_traspaso() {
+   // Borramos en tabla de pagos datos del usuario
+   status=database.execute("DELETE FROM traspaso WHERE uid=\'" + request.uid+ "\'");    
+   return;
+}
+
+function out_traspaso() {
+   var Clave="-";
+   var SumaTotal=0;
+   var fileRpt=new File(nomDoc);
+   fileRpt.open("w");
+   var fileData=new File(nomData);
+   fileData.open("w");
+   fileRpt.writeln('');
+   fileRpt.writeln('');
+   fileRpt.writeln('');
+   fileRpt.writeln('
Traspaso de Facturas - '+request.f_traspaso+' - '); + if (request.f_traspaso=="gasto") + fileRpt.writeln(''); + else + fileRpt.writeln(''); + fileRpt.writeln('
 ');
+   fileRpt.writeln('
'); + if (request.f_traspaso=="gasto") + fileRpt.writeln('N.Doc. Línea Fecha Centro Cuenta Cv. DEBE HABER C o n c e p t o F. Vto. Contrap.'); + else { + fileRpt.writeln(''); + fileRpt.writeln('N.Doc. Línea Fecha Centro Cuenta Cv. DEBE HABER C o n c e p t o F. Vto. Contrap.'); + } + fileRpt.writeln('
'); + linea=" "; +// c_traspaso = database.cursor("SELECT * FROM traspaso WHERE uid="+ request.uid+" ORDER BY nro_reg "); + var nlin=1 + var nro_doc=NroUnformat(request.f_nro_doc); + while (c_traspdocs.next()) { + if (request.f_traspaso=="pago") + c_traspaso = database.cursor("SELECT * FROM facturas,proveedores WHERE facturas.nif=proveedores.nif "+ + " and nro_doc_pago='"+c_traspdocs.nro_doc_pago+"' "+ + " ORDER BY " + request.sel_order); + if (request.f_traspaso=="gasto") + c_traspaso = database.cursor("SELECT * FROM facturas,proveedores WHERE facturas.nif=proveedores.nif "+ + " and nro_reg='"+c_traspdocs.nro_reg+"' "+ + " ORDER BY " + request.sel_order); + if (request.f_traspaso=="vto") + c_traspaso = database.cursor("SELECT * FROM facturas,proveedores WHERE facturas.nif=proveedores.nif "+ + " and nro_reg_vto='"+c_traspdocs.nro_reg_vto+"' "+ + " ORDER BY " + request.sel_order); + while (c_traspaso.next()) { + request.razon_social=c_traspaso.razon_social; + if ( request.f_traspaso=="pago" && Clave == c_traspaso.nro_doc_pago ) + continue; + if ( request.f_traspaso=="vto" && Clave == c_traspaso.nro_reg_vto ) + continue ; + jusnum=""; + nrolin=1; + if (request.f_traspaso!="vto") + CursorTabla("acf","nro_reg","=\'"+c_traspaso.nro_reg+"\' order by nro_lin ",false,""); + if (request.f_traspaso=="gasto") { + fileRpt.writeln('
'); + while (c_aptectasfra.next()) { + make_apte(nro_doc,"",StringClip(false,c_traspaso.cta_contable),"",nrolin,0,jusnum,c_aptectasfra.tipoapte); +// if ( nrolin+1 > request.maxLins ) { +// skipTopPage(nrolin,request.maxLins); +// nrolin=0; +// } + if (c_aptectasfra.tipoapte != "I1" || + c_aptectasfra.tipoapte != "I2" || + c_aptectasfra.tipoapte != "I3" ) + fileData.writeln(request.linea); + fileRpt.writeln(request.lindoc); + nrolin++; + if ( jusnum == "" ) + jusnum="0"; + } + fileRpt.writeln('
'); + } else { + if (request.f_traspaso!="vto") + c_aptectasfra.next(); +// fileRpt.writeln(''); + if (request.f_traspaso=="pago") + CursorTabla("fa","nro_doc_pago","=\'"+c_traspaso.nro_doc_pago+"\'",true,""); + if (request.f_traspaso=="vto") + CursorTabla("fa","nro_reg_vto","=\'"+c_traspaso.nro_reg_vto+"\'",true,""); + SumaTotal=0; + request.cta_contable=c_traspaso.cta_contable; + request.f_emision_pago=datetoString(c_traspaso.f_emision_pago); + request.is_remesa ="N"; + while ( true ) { + request.nro_reg=c_facturas.nro_reg; + request.nro_fra=c_facturas.nro_fra; + request.nro_doc_pago=c_facturas.nro_doc_pago; + request.importe_total=c_facturas.importe_total; + if ( c_traspaso.nro_doc_pago != c_facturas.nro_doc_pago ) + request.is_remesa ="S"; + if (request.f_traspaso=="pago") { + traspaso_pago(nro_doc,nrolin,"D"); + if (c_facturas.tipo_doc_pago == "1" ) { + fileData.writeln(request.linea); + fileRpt.writeln(request.lindoc); + nrolin++; + traspaso_pago(nro_doc,nrolin,"H"); + Clave=c_traspaso.nro_doc_pago; + } + } + if (request.f_traspaso=="vto") + traspaso_vto(nro_doc,nrolin,"D"); + fileData.writeln(request.linea); + fileRpt.writeln(request.lindoc); + nrolin++; + SumaTotal=parseFloat(c_facturas.importe_total)+parseFloat(SumaTotal); + if (!c_facturas.next()) + break; + } + c_facturas.close(); + request.nro_reg=c_traspaso.nro_reg; + request.nro_fra=c_traspaso.nro_fra; + request.nro_doc_pago=c_traspaso.nro_doc_pago; + request.importe_total=SumaTotal; + if (request.f_traspaso=="pago" && c_traspaso.tipo_doc_pago == "2" ) { + traspaso_pago(nro_doc,nrolin,"H"); + Clave=c_traspaso.nro_doc_pago; + fileData.writeln(request.linea); + fileRpt.writeln(request.lindoc); + nrolin++; + } + if (request.f_traspaso=="vto") { + traspaso_vto(nro_doc,nrolin,"H"); + Clave=c_traspaso.nro_reg_vto; + fileData.writeln(request.linea); + fileRpt.writeln(request.lindoc); + nrolin++; + } +// fileRpt.writeln('
'); + } + if (request.f_traspaso!="vto") + c_aptectasfra.close(); + fileRpt.writeln('
'); + nro_doc++; + } + c_traspaso.close(); + } + c_traspdocs.close(); + fileRpt.writeln(''); + request.lindoc="TOTALES DEBE : "+NroFormat(SumaDebe,NF11); +// request.lindoc=request.lindoc.substring(0,46)+NroFormat(SumaDebe,NF11)+NroFormat(SumaHaber,NF11)+"" + fileRpt.writeln(request.lindoc); + request.lindoc="TOTALES HABER: "+NroFormat(SumaHaber,NF11); + fileRpt.writeln(request.lindoc); + fileRpt.writeln('
');
+ fileRpt.writeln('');
+ fileRpt.writeln('');
+ fileRpt.writeln('');
+ fileRpt.close();
+ fileData.close();
+}
+function traspaso_pago(nro_doc,nrolin,tipoApte) {
+        var DocNro="";
+        var s_cta="";
+        s_banco=parseInt(c_traspaso.cod_banco)+"";
+        lon=s_banco.length;
+        request.d_cod_cta=request.cta_contable;  
+        if (c_traspaso.tipo_doc_pago == "1" )
+              s_cta=request.pag_hpag;
+        if (c_traspaso.tipo_doc_pago == "2" )
+              s_cta=request.pag_htal;
+        s_lon=s_cta.length;
+        request.h_cod_cta=s_cta.substring(0,s_lon-lon)+s_banco;
+        s_lon=request.d_cod_cta.length;
+        if ( tipoApte == "H")  {
+             DocNro=StringClip(false,request.nro_doc_pago)+"";
+             make_apte(nro_doc,request.h_cod_cta,request.d_cod_cta,"H",nrolin,request.importe_total,DocNro,jusnum,"");
+        }
+        if ( tipoApte == "D") {
+             DocNro=StringClip(false,request.nro_fra)+" "+request.nro_reg.substring(4,10);
+             make_apte(nro_doc,request.d_cod_cta,request.h_cod_cta,"D",nrolin,request.importe_total,DocNro,jusnum,"");
+        }
+}
+
+function traspaso_vto(nro_doc,nrolin,tipoApte) {
+        var DocNro="";
+        var	s_cta="";
+        s_banco=parseInt(c_traspaso.cod_banco)+"";
+        lon=s_banco.length;
+        if (c_traspaso.tipo_doc_pago == "1" )
+              s_cta=request.vto_dpag;
+        if (c_traspaso.tipo_doc_pago == "2" ) 
+              s_cta=request.vto_dtal;
+        s_lon=s_cta.length;
+        request.d_cod_cta=s_cta.substring(0,s_lon-lon)+s_banco;
+        s_lon=request.vto_h.length;
+        request.h_cod_cta=request.vto_h.substring(0,s_lon-lon)+s_banco;
+        DocNro=StringClip(false,request.nro_doc_pago);
+        if ( tipoApte == "H")  {
+             DocNro=StringClip(false,request.nro_doc_pago);
+             if ( request.is_remesa == "S" ) {
+                  lon=c_traspaso.nro_reg_vto.length;
+                  request.razon_social="REMESA "+c_traspaso.nro_reg_vto.substring(5,lon);
+             }   
+             make_apte(nro_doc,request.h_cod_cta,request.d_cod_cta,"H",nrolin,request.importe_total,DocNro,jusnum,"");
+        }
+        if ( tipoApte == "D") {
+             if ( request.is_remesa == "S" ) {
+        	         CursorTabla("pr","nif","=\'"+StringClip(true,c_facturas.nif)+"\'",false,false);
+                  request.razon_social=StringClip(false,c_proveedores.razon_social);  	     
+                  c_proveedores.close();
+             }   
+             make_apte(nro_doc,request.d_cod_cta,request.h_cod_cta,"D",nrolin,request.importe_total,DocNro,jusnum,"");
+             DocNro=StringClip(false,request.nro_fra)+" "+request.nro_reg.substring(4,10);
+        }
+}
+function make_apte(nro_doc,cod_cta,c_cod_cta,tipo_apte,nl,Cantidad,DocNro,jusnum,tipoapte) {
+ make_lindoc(nro_doc,cod_cta,c_cod_cta,tipo_apte,nl,Cantidad,DocNro,jusnum,tipoapte); 
+ if (tipoapte != "I1" || tipoapte != "I2" || tipoapte != "I3" )
+     make_linea(nro_doc,cod_cta,c_cod_cta,tipo_apte,nl,Cantidad,DocNro,jusnum,tipoapte); 
+}
+function make_lindoc(nro_doc,cod_cta,c_cod_cta,tipo_apte,nl,Cantidad,DocNro,jusnum,tipoapte) {
+             linea="                                                                                                                        ";   
+             request.lindoc="";
+//             cadena=parseInt(nro_doc)+"";
+             cadDoc="";
+             if ( c_traspaso.tipo_doc_pago == "1" ) 
+                cadDoc="P/";
+             if ( c_traspaso.tipo_doc_pago == "2" )              
+                cadDoc="T/";
+             if (request.f_traspaso=="gasto") {
+                 cadena=StringClip(false,c_aptectasfra.concepto);
+             }
+	          // Una "P" delante del nro_doc ahora DocNro
+             request.lindoc=cadDoc+DocNro+"   ";
+             cadena=parseInt(nl)+"";
+             request.lindoc=request.lindoc+cadena;
+             // Fecha de documento
+             s_fechadoc=request.f_emision;
+             if (request.f_traspaso=="pago")
+                 s_fechadoc=request.f_emision_pago;
+             cadena=datetoNString(s_fechadoc);
+             lon=cadena.length;
+             request.lindoc=request.lindoc+"  "+s_fechadoc;
+             s_fechadoc=cadena;
+             // Cod. Centro para el listado
+             cadena=StringClip(false,c_traspaso.cod_centro);
+             request.lindoc=request.lindoc+"  "+cadena;
+             // Cod. Cta.  
+             if (request.f_traspaso=="gasto")
+                 s_cta=StringClip(false,c_aptectasfra.cod_cta);
+             if (request.f_traspaso=="pago")
+                 s_cta=StringClip(false,cod_cta)+"";
+             if (request.f_traspaso=="vto")
+                 s_cta=StringClip(false,cod_cta)+"";
+             request.lindoc=request.lindoc+"  "+s_cta;
+             lon=s_cta.length;             
+             // Clave
+             if (request.f_traspaso=="gasto")
+                 cadena=c_aptectasfra.clave+"";
+             if (request.f_traspaso=="pago")
+                 cadena=request.f_clave+"";
+             if (request.f_traspaso=="vto")
+                 cadena=request.f_clave+"";
+             request.lindoc=request.lindoc+"  "+cadena;
+             clave=cadena;
+             // Importe
+             if (request.f_traspaso=="gasto") {
+                  nro=c_aptectasfra.importe;
+                  tipo_apte=c_aptectasfra.tipo_apte;
+             } else {    
+                     nro=Cantidad;
+             }
+             if ( nro < 0 ) {
+                nro=nro*-1;
+                if (request.f_traspaso=="pago" && tipo_apte == "D") 
+                   cadDoc="";
+                if ( tipo_apte == "D" ) 
+                     tipo_apte="H";
+                else
+                     tipo_apte="D";
+             }
+             if (tipo_apte == "H") {
+                    SumaHaber=SumaHaber+nro;
+                    request.lindoc=request.lindoc+"             "+NroFormat(nro,NF9)+"  ";                    
+             } else {
+                    SumaDebe=SumaDebe+nro;
+                    request.lindoc=request.lindoc+"  "+NroFormat(nro,NF9)+"             ";                    
+             };
+             cadena=NroUnformat(NroFormat(nro,NF9))+"";
+             // Concepto para el listado
+             if (request.f_traspaso=="gasto") {
+                 cadena=StringClip(false,c_aptectasfra.concepto);
+             }
+             if (request.f_traspaso=="pago" && tipo_apte == "H") 
+                   cadena=cadDoc+DocNro+" "+StringClip(false,request.razon_social);
+             if (request.f_traspaso=="pago" && tipo_apte == "D") {
+                   cadena=DocNro+StringClip(false,request.razon_social);
+             }
+             if (request.f_traspaso=="vto" && tipo_apte == "D")
+                 cadena=cadDoc+DocNro+" "+StringClip(false,request.razon_social);
+             if (request.f_traspaso=="vto" && tipo_apte == "H") {
+                 if ( request.is_remesa == "S" ) 
+                    cadena=StringClip(false,request.razon_social);
+                 else
+                    cadena=cadDoc+DocNro+" "+StringClip(false,request.razon_social);
+             }
+             lon=30; // lon=cadena.length;
+             s_cadena=cadena+linea;
+             request.lindoc=request.lindoc+"  "+s_cadena.substring(0,lon);
+             // Vto.
+             if (request.f_traspaso=="gasto") {
+                 s_cadena="      ";
+					  cadena=s_cadena;
+             }
+             else {
+                 s_cadena=datetoString(c_traspaso.vto_pago);
+                 cadena=datetoNString(s_cadena);
+             }
+             request.lindoc=request.lindoc+"  "+s_cadena;
+             lon=cadena.length;
+             // Contrapartida para el listado
+             cadena=StringClip(false,c_cod_cta);
+             lon=cadena.length;
+             request.lindoc=request.lindoc+"  "+cadena;
+}
+function make_linea(nro_doc,cod_cta,c_cod_cta,tipo_apte,nl,Cantidad,DocNro,jusnum,tipoapte) {
+             linea="                                                                                                                        ";   
+             carsep="|";
+             request.linea="";
+             // apteid, asient, diario, moneda, cambio
+             request.linea="0"+carsep+"DG"+carsep+"PTA"+carsep+"1.0"+carsep;
+             cadena=StringClip(false,c_traspaso.cod_centro);
+             // centro de coste, seccion, juser
+	       request.linea=request.linea+cadena+carsep+"A"+carsep+"A"+carsep+jusnum+carsep;
+             request.linea=request.linea+"P"+carsep;
+             cadDoc="";
+             if ( c_traspaso.tipo_doc_pago == "1" ) 
+                cadDoc="P/";
+             if ( c_traspaso.tipo_doc_pago == "2" )              
+                cadDoc="T/";
+             if (request.f_traspaso=="gasto") {
+                 cadena=StringClip(false,c_aptectasfra.concepto);
+             }
+             request.linea=request.linea+cadDoc+DocNro+carsep;
+             // Fecha de documento
+             s_fechadoc=request.f_emision;
+             if (request.f_traspaso=="pago")
+                 s_fechadoc=request.f_emision_pago;
+             cadena=datetoNString(s_fechadoc);
+             lon=cadena.length;
+             request.linea=request.linea+cadena+carsep;
+             s_fechadoc=cadena;
+             // Cod. Cta.  
+             if (request.f_traspaso=="gasto")
+                 s_cta=StringClip(false,c_aptectasfra.cod_cta);
+             if (request.f_traspaso=="pago")
+                 s_cta=StringClip(false,cod_cta)+"";
+             if (request.f_traspaso=="vto")
+                 s_cta=StringClip(false,cod_cta)+"";
+             lon=s_cta.length;             
+             request.linea=request.linea+s_cta.substring(0,3)+"."+s_cta.substring(4,lon)+carsep+carsep;
+             // Concepto
+             if ( c_traspaso.tipo_doc_pago == "1" ) 
+                 cadDoc="P/";
+             if ( c_traspaso.tipo_doc_pago == "2" )              
+                 cadDoc="T/";
+             if (request.f_traspaso=="gasto") {
+                 cadena=StringClip(false,c_aptectasfra.concepto);
+             }
+             if (request.f_traspaso=="pago" && tipo_apte == "H") 
+                   cadena=cadDoc+DocNro+" "+StringClip(false,request.razon_social);
+             if (request.f_traspaso=="pago" && tipo_apte == "D") {
+                   cadena=DocNro+StringClip(false,request.razon_social);
+             }
+             if (request.f_traspaso=="vto" && tipo_apte == "D")
+                 cadena=cadDoc+DocNro+" "+StringClip(false,request.razon_social);
+             if (request.f_traspaso=="vto" && tipo_apte == "H") {
+                 if ( request.is_remesa == "S" ) 
+                    cadena=StringClip(false,request.razon_social);
+                 else
+                    cadena=cadDoc+DocNro+" "+StringClip(false,request.razon_social);
+             }
+             request.linea=request.linea+cadena+carsep;
+             // Importe
+             if (request.f_traspaso=="gasto") {
+                  nro=c_aptectasfra.importe;
+                  tipo_apte=c_aptectasfra.tipo_apte;
+             } else {    
+                     nro=Cantidad;
+             }
+             cadena=NroUnformat(NroFormat(nro,NF9))+"";
+             if ( tipo_apte == "D" ) 
+                request.linea=request.linea+cadena+carsep+carsep;
+             if ( tipo_apte == "H" ) 
+                request.linea=request.linea+carsep+cadena+carsep;
+             // Contrapartida nula aptes. en tabla 
+                request.linea=request.linea+carsep;
+             // Fecha valor, sistem
+             request.linea=request.linea+s_fechadoc+carsep+"A"+carsep+"0"+carsep+"0"+carsep;
+             // Tipo documento
+             if ( s_cta.substring(0,1) == "2" ) 
+                 request.linea=request.linea+"I"+carsep;
+             else
+                 request.linea=request.linea+"R"+carsep+"N"+carsep;
+             // Código de Tercero cta_contable
+             request.linea=request.linea+c_traspaso.cta_contable+carsep;				        
+             tipIVA="";
+             if (tipoapte == "P1"){ 
+                if ( c_traspaso.iva_1 == "16")
+                     tipIVA="RE"
+                request.linea=request.linea+tipIVA+carsep+"1"+carsep;				        
+             }
+             if (tipoapte == "P2"){ 
+                if ( c_traspaso.iva_2 == "7" )
+                     tipIVA="OR"
+                request.linea=request.linea+tipIVA+carsep+"1"+carsep;				        
+             }
+             if (tipoapte == "P3"){ 
+                if ( c_traspaso.iva_3 == "4" )
+                     tipIVA="SR"
+                request.linea=request.linea+tipIVA+carsep+"1"+carsep;				        
+             }
+
+    
+
+
+ 
+             if (request.f_traspaso=="gasto")
+                 cadena=c_aptectasfra.clave+"";
+             if (request.f_traspaso=="pago")
+                 cadena=request.f_clave+"";
+             if (request.f_traspaso=="vto")
+                 cadena=request.f_clave+"";
+
+             // Vto.
+             if (request.f_traspaso=="gasto") {
+                 s_cadena="      ";
+					  cadena=s_cadena;
+             }
+             else {
+                 s_cadena=datetoString(c_traspaso.vto_pago);
+                 cadena=datetoNString(s_cadena);
+             }
+             lon=cadena.length;
+             request.linea=request.linea+cadena+linea;
+             // Contrapartida para el listado
+             cadena=StringClip(false,c_cod_cta);
+             lon=cadena.length;
+             request.linea=request.linea+cadena;
+//texto="p_contracta="+p_contracta+" lon="+lon+" c_cod_cta="+c_cod_cta
+//debug(texto)
+//debug(request.linea)
+//debug(request.linea)
+}
diff --git a/nroletra.js b/nroletra.js
new file mode 100644
index 0000000..14b1dba
--- /dev/null
+++ b/nroletra.js
@@ -0,0 +1,335 @@
+//                                  //
+//     JavaScript Functions         // 
+//                                  //
+//////////////////////////////////////
+// Función para convertir un nro. en letra
+//
+// La llamada a esta función es del modo siguiente:
+//
+//   nro_letra(nro, cod_len, cod_gen, cod_mon, car_pad, lon_l1, lon_l2)
+//       return num_let
+//
+//   (*)   nro       es el float que contiene el nro. a transcribir.
+//   (*)   cod_len   es el código de la lengua en la que se transcribe nro
+//                   (3 dígitos) ej: "spa" para nuestra lengua.
+//   (*)   cod_gen   es el género "m" masculino o "f" femenino.
+//         cod_mon   es el código de la moneda ( 4 dígitos). [ej: "pts"]
+//         car_pad   es el caracter que se usa para relleno ( caso de cheques)
+//         lon_l1    es la longitud de la primera cadena de caracteres que se
+//                   concatena con la segunda en una para el return 
+//         lon_l2    es la longitud de la segunda cadena que se prepara para
+//                   el programa que llama a este módulo
+//         num_let   es la cadena  que se manipula y devuelve con el texto del
+//                   nro transcrito y las manipulaciones solicitadas por el 
+//                   resto de los argumentos.
+//
+
+function nro_letra(nro_i, cod_len, cod_gen, cod_mon, car_pad, lon_l1, lon_l2) {
+        // var nro_i=0;     // Nro. a escribir
+        // var cod_len="";   // Código de lengua
+        // var cod_gen="";   // Código ( m / f) género para cientos 
+        // var cod_mon="";   // Código de moneda
+        // var car_pad="";   // Caracter para usar de relleno
+        // var lon_l1=0;     // Long de la línea uno
+        // var lon_l2=0;     // Long de la línea dos
+ 		  var nro_let="";
+        var nro=parseFloat(nro_i);
+//car_pad="*"
+//lon_l1=80
+//cod_len="spa"
+//cod_gen="m"
+    tx_cent="";
+    tx_dece="";
+    tx_und="";                 
+    tx_mll="";
+    txletmll="";
+    txletmil="";
+    if ( nro+0 == 0 ) {
+        return false; 
+    }
+    var s_nro=nro+"";
+    var lonNro=s_nro.length;
+    var pos=s_nro.indexOf(car_dec);   
+//    if (pos == -1)  {
+//       var s_entera=s_nro;
+//       var s_decimal="0";
+//    } else {
+//       var s_entera = s_nro.substring(0,pos);   
+//       var s_decimal = s_nro.substring(pos+1,longNro);
+//    }
+//debug(s_entera);
+//    if ( parseInt(s_entera) > 0 ) 
+         analiza_num(s_nro,cod_mon,car_pad, lon_l1, lon_l2); //  Análisis nro y trad.
+//    if ( parseInt(s_decimal) > 0 && pos > 0 ) { 
+//         nro_let=num_let;
+//         analiza_num(s_decimal); //  Análisis del nro y trad.
+//         num_let=nro_let+" con "+num_let; 
+//    }
+    if (num_let.length == 0 ) { return "" } 
+//    num_let=num_let+cod_mon;        // pone moneda y mayuscula
+   return true
+}
+
+function analiza_num(s_num,cod_mon,car_pad, lon_l1, lon_l2) {
+   var nro_let="";
+   var s_nro="";
+   var s_numero=s_num+"";
+   var lonNro=s_numero.length;
+   if ( lonNro < 3 ) {
+        parseCent(s_numero,1,1);
+        num_let=tx_cent+" "+tx_dece+tx_und+" ";
+        return;
+   }
+   var n_centenas=parseInt(lonNro/3);
+   var n_ope=n_centenas*3;
+   var n_ini=0;
+   if  (n_centenas == 0 )  
+       n_centenas=1;
+   if ( n_ope < lonNro  ) {
+       n_centenas++;
+       n_fin=lonNro-n_ope;    
+   } else
+          n_fin=n_ini+3;      
+   for ( var i=0; i < n_centenas ; i++ ) {
+        s_nro=s_numero.substring(n_ini,n_fin);
+        parseCent(s_nro,n_centenas,n_centenas-i);        
+        if ( n_centenas-i == 2 && s_nro != "000")
+            txletmil=" "+let_mil;
+        else
+            txletmil="";
+        nro_let=nro_let+" "+tx_cent+" "+tx_dece+tx_und+txletmil;
+        if (parseInt(s_nro) > 0 ) {
+           parseMil(n_centenas-i,s_nro)
+           if (s_nro == "1" )
+               nro_let=let_un+" "+txletmll;
+           else {
+               nro_let=nro_let+" "+txletmll;
+           }    
+        }
+		  n_ini=n_fin;
+        n_fin=n_ini+3;      
+   }
+   num_let=nro_let+" ";
+   num_let=num_let+" "+cod_mon;
+   nro_let=num_let;
+   num_let=num_let+linPad;
+  	num_let2=linPad;
+   lonNro=nro_let.length;
+   if ( lonNro  > LongLine) {
+       var pos=LongLine;
+       while (pos > 0) {
+           var s_char=nro_let.substring(pos-1,pos)
+           if ( s_char == " " )
+               break;
+           pos--;
+       }
+       if ( pos > 0 ) {
+          num_let=nro_let.substring(0,pos)+linPad;    
+    	    num_let2=nro_let.substring(pos,lonNro)+linPad;    
+       }       
+   }
+   num_let=num_let.substring(0,lon_l1);
+   num_let2=num_let2.substring(0,lon_l2);
+return;
+}
+
+function parseCent(s_nro,n_cents,p_cents) {
+   var nro_flt=parseFloat(s_nro); 
+   var cad_nro = nro_flt+"";
+   var lon = cad_nro.length;
+   var cadena="";
+   var n_c=0; 
+   tx_cent="";
+   tx_dece="";
+   tx_und="";                 
+   if (cad_nro == "000" ) return
+   if (cad_nro == "100" ) {
+       tx_cent = mat_ce_1;       
+       return
+   }
+   if ( lon == 3 ) {   //  Centenas 
+       var n_c=cad_nro.substring(0,1);
+       var n_d=cad_nro.substring(1,2);
+       var n_u=cad_nro.substring(2,3);
+   }
+   if ( lon == 2 ) {   //  Decenas 
+       var n_c="0";
+       var n_d=cad_nro.substring(0,1);
+       var n_u=cad_nro.substring(1,2);
+   }
+   if ( lon == 1 ) {   //  Unidades 
+	    var n_c="0";
+       var n_d="0";
+       var n_u=cad_nro.substring(0,1);
+   }
+   if ( n_c > 0 ) { 
+      eval("tx_cent = mat_ce_"+n_c);       
+      if ( n_c > 1 && n_c != 5 ) 
+          tx_cent= tx_cent+let_ciens
+   }    
+   if ( n_c == 1 ) { tx_cent = tx_cent+let_plus100; };
+   if ( n_d > 0 ) { 
+      if ( n_d == 1 && n_u > 0 ) 
+          eval("tx_dece=mat_ud_"+n_u);
+      if ( n_d == 1 && n_u == 0 ) 
+          eval("tx_dece=mat_de_"+1);
+      if ( n_d == 2 ) {
+          eval("tx_dece=mat_de_"+n_d);
+          if ( n_u > 0 )
+             tx_dece=tx_dece+"I";
+      }          
+	   if ( n_d > 2 ) {
+          eval("tx_dece=mat_de_"+n_d);
+          if ( n_u > 0 )
+             tx_dece=tx_dece+" Y ";
+      }    
+   }    
+   if ( n_d == 2 && n_u == 0 ) { tx_dece=tx_dece+"E" }
+   if ( s_nro.length == 1 && n_d == 0  ) 
+         eval("tx_und=mat_un_"+n_u);
+   if ( parseInt(s_nro) != 1 ) { 
+     if ( p_cents%2 != 0 && p_cents != 1 && n_d != 1 && n_u == 1 ) { tx_dece=tx_dece+"UN" }
+     if ( p_cents%2 == 0 && p_cents != 1 && n_d != 1  ) { eval("tx_und=mat_un_"+n_u)  }
+//     if ( p_cents == 1 ) { eval("tx_und=mat_un_"+n_u)  }
+     if ( s_nro.length > 1 && n_d != 1 ) 
+         eval("tx_und=mat_un_"+n_u)
+   } else {
+     if ( p_cents == 1 ) { eval("tx_und=mat_un_"+n_u)  }
+//     if ( p_cents > 1 && nd != 1 ) { tx_und=let_un  }
+   }
+//  nro_let=num_let+tx_cent+" "+tx_dece+tx_und+txletmil;
+//lin=" Ce: "+n_c+" De: "+n_d+" Un: "+n_u+" Nro: "+cad_nro 
+//debug(lin)
+//debug(nro_let)
+}
+function parseMil(cen,s_nro) {
+    tx_mll="";
+    txletmll=""
+    if ( cen < 2 ) {
+       return "";
+    }
+    if ( cen%2 == 0 ) {
+       if ( s_nro != "000" ) {
+            return ""; // let_mil;
+       }
+    }
+    // Los millones y más ... too much !!!
+    if ( cen == 3 ) 
+          tx_mll=mat_mll_1;
+    if ( cen == 5 ) 
+          tx_mll=mat_mll_2;
+    if ( cen == 7 ) 
+          tx_mll=mat_mll_3;
+    if ( cen == 9 ) 
+          tx_mll=mat_mll_4;
+    if ( cen == 11 ) 
+          tx_mll=mat_mll_5;
+    if ( cen == 13 ) 
+          tx_mll=mat_mll_6;
+    if ( cen == 15 ) 
+          tx_mll=mat_mll_7;
+    if ( cen == 17 ) 
+          tx_mll=mat_mll_8;
+    if ( cen == 19 ) 
+          tx_mll=mat_mll_9;
+    var lonNro=s_nro.length;
+    if ( parseInt(s_nro) == 1 ) {
+          txletmll=tx_mll+let_mill;
+//          return ""; // let_un; // +" "+tx_mll+let_mill;
+    } else {
+          txletmll=tx_mll+let_mills;
+//          return "";   //tx_mll+let_mills;
+    }
+    return "";   
+}
+function preparamat(cod_len,cod_gen) {
+  if ( cod_gen == "f" ) 
+           let_fin="as"
+  else if ( cod_gen == "m" )
+           let_fin="os"
+  else if (cod_gen != "f" || cod_gen != "m") {
+      alert (" Genero : "+cod_gen+" de la lengua : "+cod_len+" Desconocido");
+      return false;
+  } 
+  if ( cod_len == "spa" ) {
+              mat_un_0="";
+              if (cod_gen=="m")
+                  mat_un_1="UNO";
+              else
+                  mat_un_1="UNA";	 
+              mat_un_2="DOS";
+              mat_un_3="TRES";
+              mat_un_4="CUATRO";
+              mat_un_5="CINCO";
+              mat_un_6="SEIS";
+              mat_un_7="SIETE";
+              mat_un_8="OCHO";
+              mat_un_9="NUEVE";
+
+	           mat_ud_0="";
+	           mat_ud_1="ONCE";
+              mat_ud_2="DOCE";
+              mat_ud_3="TRECE";
+              mat_ud_4="CATORCE";
+              mat_ud_5="QUINCE";
+              mat_ud_6="DIECISEIS";
+              mat_ud_7="DIECISIETE";
+              mat_ud_8="DIECIOCHO";
+              mat_ud_9="DIECINUEVE";
+            
+              mat_de_1="DIEZ";
+              mat_de_2="VEINT";
+              mat_de_3="TREINTA";
+              mat_de_4="CUARENTA";
+              mat_de_5="CINCUENTA";
+              mat_de_6="SESENTA";
+              mat_de_7="SETENTA";
+              mat_de_8="OCHENTA";
+              mat_de_9="NOVENTA";
+
+              if (cod_gen=="m")
+   	            let_ciens="CENTOS";
+              else
+	               let_ciens="CIENTAS";
+
+              let_plus100="TO";
+              mat_ce_1="CIEN";
+              mat_ce_2="DOS";
+              mat_ce_3="TRES";
+              mat_ce_4="CUATRO";
+              if (cod_gen=="m")
+                 mat_ce_5="QUINIENTOS";
+              else
+                 mat_ce_5="QUINIENTAS";
+              mat_ce_6="SEIS";
+              mat_ce_7="SETE";
+              mat_ce_8="OCHO";
+              mat_ce_9="NOVE";
+
+              let_un="UN";
+              let_cien="CIEN";
+              let_cient="CIENTO";
+              let_mil ="MIL";
+	           let_mills="LLONES";
+	           let_mill="LLON";
+              let_con="CON";
+              car_dec=",";
+
+              mat_mll_1="MI";
+              mat_mll_2="BI";
+              mat_mll_3="TRI";
+              mat_mll_4="CUATRI";
+              mat_mll_5="QUINTI";
+              mat_mll_6="SESTI";
+              mat_mll_7="SEPTI";
+              mat_mll_8="OCTI";
+              mat_mll_9="NOVI";
+    for ( var i=1; i < LongLine; i++ ) 
+           linPad=linPad+CarPad;
+  } else {
+          alert(" Código de Lengua "+cod_len+" No definido !!");
+          return false;
+  }
+  return true
+ }
+