ctasapagar/l_albaran.js

336 lines
15 KiB
JavaScript
Raw Permalink Blame History

//////////////////////////////////////
// //
// JavaScript Functions //
// //
//////////////////////////////////////
function report_alb() {
var npag=0;
var nrolin=0;
while (c_albareg.next()) {
// if ( nrolin <= request.maxLins && npag >0 ) {
// skipTopPage(nrolin,request.maxLins);
// nrolin=0;
// }
// npag++;;
if (request.f_formato=="proveedor")
AlbProveedorHtml();
if (request.f_formato=="centro")
AlbCentroHtml();
if (request.f_formato=="pendientes")
AlbCentroHtml();
if (request.f_formato=="emitidos")
AlbEmitidosHtml();
if (request.f_formato=="provBloq")
AlbRetenidosHtml();
if (request.f_formato=="documento")
nrolin=AlbDocHtml(c_albareg.nro_reg);
}
}
function sumalbctas() {
CursorTabla("ac","nro_reg","=\'"+request.ab_nro_reg+"\'",false,"");
request.ac_totaldebe=0;
request.ac_totalhaber=0;
request.ac_total=0;
request.nroctas=0;
while (c_aptecuentas.next()) {
request.nroctas++;
if ( c_aptecuentas.tipo_apte == "D" )
request.ac_totaldebe=request.ac_totaldebe+c_aptecuentas.importe;
if ( c_aptecuentas.tipo_apte == "H" )
request.ac_totalhaber=request.ac_totalhaber+c_aptecuentas.importe;
}
request.ac_total=request.ac_totaldebe-request.ac_totalhaber;
c_aptecuentas.close()
}
function AlbProveedorHtml() {
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('<BR><BR><BR>');
nrolin=0;
is_newpag=true;
};
if ( keyLastRow != c_albareg.nif && keyLastRow !="-") {
fileRpt.writeln('</TABLE>');
fileRpt.writeln('<HR><TABLE BORDER='+request.borde+' ALIGN=CENTER><TR>');
fileRpt.writeln("<TR><TD ALIGN=RIGHT>TOTAL .... </TD>"+
"<TD ALIGN=RIGHT>"+NroFormat(suma_prov,NF11)+"</TD>");
fileRpt.writeln('</TABLE><HR>');
suma_prov=0;
nrolin=nrolin+3
set_head=true;
}
if ( is_newpag == true ) {
if ( keyLastRow !="-" ) { fileRpt.writeln('</TABLE>')};
fileRpt.writeln('<B><I>Dpto. Cuentas a Pagar</B></I><BR><HR>');
fileRpt.writeln('<ALIGN=LEFT><H3><B>LISTADO DE ALBARANES POR PROVEEDOR</B></H3>');
fileRpt.writeln('<HR>');
is_newpag=false;
nrolin=nrolin+4;
set_head=true;
}
if ( set_head == true ) {
fileRpt.writeln('<CENTER><TABLE BORDER=0 ALIGN=CENTER>');
fileRpt.writeln("<TR><TD ALIGN=RIGHT><B>"+c_albareg.nif +"</TD></B>"+
"<TD ALIGN=RIGHT><B>"+c_albareg.razon_social+"</TD></B>");
fileRpt.writeln('</TABLE>');
fileRpt.writeln('<HR><CENTER><TABLE BORDER='+request.borde+' ALIGN=CENTER>');
fileRpt.writeln(" <TR><TD ALIGN=CENTER>Nro. Reg." +
"<TD ALIGN=CENTER>F.Emisi<73>n </TD>"+
"<TD ALIGN=CENTER>Nro. Fra.</TD>"+
"<TD ALIGN=CENTER>Centro </TD>"+
"<TD ALIGN=CENTER>Importe</TD></TR>");
nrolin=nrolin+3; set_head=false;
}
request.ab_nro_reg=c_albareg.nro_reg;
sumalbctas();
fileRpt.writeln("<TR><TD ALIGN=RIGHT>"+c_albareg.nro_reg+"</TD>"+
"<TD ALIGN=RIGHT>"+datetoString(c_albareg.fecha_emision) +"</TD>"+
"<TD ALIGN=RIGHT>"+c_albareg.nro_fra +"</TD>"+
"<TD ALIGN=RIGHT>"+c_albareg.cod_centro +"</TD>"+
"<TD ALIGN=RIGHT>"+NroFormat(request.ac_total,NF11)+"</TD></TR>");
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("<TR><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD ALIGN=RIGHT></TD><TD ALIGN=RIGHT>----------------</TD>");
// writeln("<TR><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD ALIGN=RIGHT>Suma Total:</TD><TD ALIGN=RIGHT>"+NroFormat(suma_total,NF10) +"</TD>");
fileRpt.writeln('</TABLE>');
fileRpt.writeln('<TABLE BORDER=0 ALIGN=CENTER><TR>');
fileRpt.writeln("<TR><TD ALIGN=RIGHT>TOTAL .... </TD>"+
"<TD ALIGN=RIGHT>"+NroFormat(suma_prov,NF11)+"</TD>");
fileRpt.writeln('</TABLE>');
fileRpt.writeln('<HR><TABLE BORDER=0 ALIGN=CENTER><TR>');
fileRpt.writeln("<TR><TD ALIGN=RIGHT>TOTAL Acumulado....... </TD>"+
"<TD ALIGN=RIGHT>"+NroFormat(suma_total,NF11)+"</TD>");
fileRpt.writeln('</TABLE>');
}
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('<HTML><HEAD></HEAD>');
fileRpt.writeln('<BASEFONT SIZE=2>');
status=database.execute("DELETE FROM sumactasalb where uid=\'" + request.uid+ "\'");
while (true) {
if ( nrolin+3 == request.maxLins ) {
fileRpt.writeln('<BR><BR><BR>');
nrolin=0;
set_head=true;
};
if ( keyLastPrv == "-" )
keyLastPrv=c_albareg.nif;
if ( keyLastPrv != c_albareg.nif ) {
keyLastPrv=c_albareg.nif;
fileRpt.writeln("<TR><TD ALIGN=RIGHT NOWRAP VALIGN=TOP ><B><FONT SIZE=-1>TOTAL .... </FONT></B></TD>"+
"<TD></TD>"+
"<TD ALIGN=LEFT NOWRAP VALIGN=TOP ><B><FONT SIZE=-1>..............</FONT></B></TD>"+
"<TD ALIGN=LEFT NOWRAP VALIGN=TOP ><B><FONT SIZE=-1>..............</FONT></B></TD>"+
"<TD></TD>"+
"<TD ALIGN=RIGHT NOWRAP VALIGN=TOP ><B><FONT SIZE=-1>"+NroFormat(request.s_prov,NF9)+"</FONT></B></TD>"+
"<TD></TD>"+
"</TR>")
request.s_prov=0;
}
if ( keyLastRow != c_albareg.cod_centro && keyLastRow !="-" ) {
nrolin++;
fileRpt.writeln("<TR><TD ALIGN=RIGHT NOWRAP VALIGN=TOP ><B><FONT SIZE=-1>TOTAL .... </FONT></B></TD>"+
"<TD></TD>"+
"<TD ALIGN=LEFT NOWRAP VALIGN=TOP ><B><FONT SIZE=-1>..............</FONT></B></TD>"+
"<TD ALIGN=LEFT NOWRAP VALIGN=TOP ><B><FONT SIZE=-1>..............</FONT></B></TD>"+
"<TD></TD>"+
"<TD ALIGN=RIGHT NOWRAP VALIGN=TOP ><B><FONT SIZE=-1>"+NroFormat(request.s_ctas,NF9)+"</FONT></B></TD>"+
"<TD></TD>"+
"</TR>")
fileRpt.writeln('</TABLE><BR><BR>');
AlbResCentrosHtml(keyLastRow,desLastRow);
fileRpt.writeln('</BODY>');
fileRpt.writeln('</HTML>');
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('<HTML><HEAD></HEAD>');
fileRpt.writeln('<BASEFONT SIZE=2>');
// 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("</TABLE>");
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("</TABLE>");
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("<TR><TD ALIGN=LEFT NOWRAP VALIGN=TOP ><FONT SIZE=-1>"+c_albareg.nro_reg+"</FONT></TD>"+
"<TD ALIGN=LEFT NOWRAP VALIGN=TOP ><FONT SIZE=-1>"+datetoString(c_albareg.fecha_emision) +"</FONT></TD>"+
"<TD ALIGN=LEFT NOWRAP VALIGN=TOP ><FONT SIZE=-1>"+c_albareg.nif+"</FONT></TD>"+
"<TD ALIGN=LEFT NOWRAP VALIGN=TOP ><FONT SIZE=-1>"+c_albareg.razon_social+"</FONT></TD>"+
"<TD ALIGN=LEFT NOWRAP VALIGN=TOP ><FONT SIZE=-1>"+c_aptesalb.cod_cta+"</FONT></TD>"+
"<TD ALIGN=RIGHT NOWRAP VALIGN=TOP ><FONT SIZE=-1>"+NroFormat(importe,NF9)+"</FONT></TD>"+
"<TD ALIGN=RIGHT NOWRAP VALIGN=TOP ><FONT SIZE=-1>"+c_albareg.fra_reg+"</FONT></TD>"+
"</TR>")
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("</TABLE>");
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("<TR><TD ALIGN=RIGHT NOWRAP VALIGN=TOP ></TD>"+
"<TD></TD>"+
"<TD></TD>"+
"<TD></TD>"+
"<TD ALIGN=LEFT NOWRAP VALIGN=TOP ><FONT SIZE=-1>"+c_aptesalb.cod_cta+"</FONT></TD>"+
"<TD ALIGN=RIGHT NOWRAP VALIGN=TOP ><FONT SIZE=-1>"+NroFormat(importe,NF9)+"</FONT></TD>"+
"<TD></TD>"+
"</TR>")
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("<TR><TD ALIGN=RIGHT NOWRAP VALIGN=TOP ><B><FONT SIZE=-1>TOTAL .... </FONT></B></TD>"+
"<TD></TD>"+
"<TD ALIGN=LEFT NOWRAP VALIGN=TOP ><B><FONT SIZE=-1>..............</FONT></B></TD>"+
"<TD ALIGN=LEFT NOWRAP VALIGN=TOP ><B><FONT SIZE=-1>..............</FONT></B></TD>"+
"<TD></TD>"+
"<TD ALIGN=RIGHT NOWRAP VALIGN=TOP ><B><FONT SIZE=-1>"+NroFormat(request.s_ctas,NF9)+"</FONT></B></TD>"+
"<TD></TD>"+
"</TR>")
fileRpt.writeln('</TABLE>');
AlbResCentrosHtml(keyLastRow,desLastRow);
fileRpt.writeln('</BODY>');
fileRpt.writeln('</HTML>');
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('<HR>');
if (request.f_formato=="pendientes")
fileRpt.writeln('<H4><B>RESUMEN CUENTAS DE ALBARANES PENDIENTES DE FACTURA</B></H4>');
else
fileRpt.writeln('<H4><B>RESUMEN DE CUENTAS POR CENTRO</B></H4>');
fileRpt.writeln('<HR>');
// fileRpt.writeln('<TABLE BORDER='+request.borde+' ALIGN=CENTER><TR>');
// fileRpt.writeln("<TD ALIGN=LEFT><B>"+clave +"</B>"+
// "<B>"+desclave+"</B>");
// fileRpt.writeln('</TD></TR></TABLE><BR><BR><LEFT>');
fileRpt.writeln("<FONT SIZE=+1>"+clave +desclave+"</FONT>");
fileRpt.writeln('<TABLE BORDER='+request.borde+' ALIGN=CENTER CELLSPACING=0 CELLPADDING=4 VALIGN="TOP"><TR>');
fileRpt.writeln("<TR><TH ALIGN=LEFT NOWRAP VALIGN=TOP ><FONT SIZE=-1><I>Cod. Cta.</FONT></I></TH>" +
"<TH ALIGN=RIGHT NOWRAP VALIGN=TOP ><FONT SIZE=-1><I>Importe</FONT></I></TH>"+
"</TR>");
request.s_total=0;
while ( c_ctascentro.next()) {
fileRpt.writeln("<TR>"+
"<TD ALIGN=RIGHT NOWRAP VALIGN=TOP ><FONT SIZE=-1>"+c_ctascentro.cod_cta+"</FONT></TD>"+
"<TD ALIGN=RIGHT NOWRAP VALIGN=TOP ><FONT SIZE=-1>"+NroFormat(c_ctascentro[1],NF11)+"</FONT></TD>"+
"</TR>");
request.s_total=parseFloat(request.s_total)+parseFloat(c_ctascentro[1]);
}
c_ctascentro.close();
fileRpt.writeln("<TR><TH ALIGN=RIGHT NOWRAP VALIGN=TOP ><FONT SIZE=-1><I>TOTAL</FONT></I></TH>"+
"<TH ALIGN=RIGHT NOWRAP VALIGN=TOP ><FONT SIZE=-1>"+NroFormat(request.s_total,NF11)+"</FONT></TH></TR>");
fileRpt.writeln('</TABLE>');
fileRpt.writeln('<BR><BR>');
}
function AlbCentrosCab() {
fileRpt.writeln('<H6><I>Dpto. Cuentas a Pagar</FONT></I>');
fileRpt.writeln('<HR>');
if (request.f_formato=="pendientes")
fileRpt.writeln('<ALIGN=CENTER><H4><B>LISTADO DE ALBARANES PENDIENTES DE FACTURA</B></H4>');
else
fileRpt.writeln('<ALIGN=CENTER><H4><B>LISTADO DE ALBARANES POR CENTRO</B></H4>');
fileRpt.writeln('<HR>');
fileRpt.writeln('</TABLE><ALIGN=LEFT>');
fileRpt.writeln("<ALIGN=LEFT NOWRAP VALIGN=TOP ><FONT SIZE=+1>"+c_albareg.cod_centro +c_albareg.descripcion+"</FONT>");
fileRpt.writeln('<TABLE BORDER='+request.borde+' ALIGN=CENTER CELLSPACING=0 CELLPADDING=4 VALIGN="TOP">');
fileRpt.writeln("<TR><TH ALIGN=CENTER NOWRAP VALIGN=TOP ><FONT SIZE=-1><I>Nro.Alb.</FONT></I></TH>" +
"<TH ALIGN=CENTER NOWRAP VALIGN=TOP ><FONT SIZE=-1><I>Fecha Al.</FONT></I></TH>"+
"<TH ALIGN=CENTER NOWRAP VALIGN=TOP ><FONT SIZE=-1><I>N.I.F.</FONT></I></TH>"+
"<TH ALIGN=CENTER NOWRAP VALIGN=TOP ><FONT SIZE=-1><I>Raz<61>n Social</FONT></I></TH>"+
"<TH ALIGN=CENTER NOWRAP VALIGN=TOP ><FONT SIZE=-1><I>Cuenta</FONT></I></TH>"+
"<TH ALIGN=CENTER NOWRAP VALIGN=TOP ><FONT SIZE=-1><I>Imp.Cta.</FONT></I></TH>"+
"<TH ALIGN=CENTER NOWRAP VALIGN=TOP ><FONT SIZE=-1><I>Reg.Fra.</TH>"+
"</TR>");
}
function AlbPendientesHtml() {
}
function AlbEmitidosHtml() {
}
function AlbRetenidosHtml() {
}