Te pongo una parte de mi codigo para la impresión de Facturas por Computador, cada cliente tiene su propio diseño, logo, etc., y lo imprimo con esta rutina. Tienes que enlazar el VRD.PRG a tu programa y colocar el #include vrd.ch en el prg que vayas a imprimir.
Code: Select all
EASYREPORT oVRD NAME Pub:DIRLOCAL+Pub:CODEMP+"\REP\factura.vrd" PREVIEW (.T.) OF ventana
IF oVRD:lDialogCancel = .T.
RETURN( .F. )
ENDIF
PRINTAREA 1 OF oVRD ;
ITEMIDS { 101, 102, 103, 104, 170, 171, 172, 150, 181, 180, 173, 174, 175, 182, 183, 184, 185, 186, 187, 190} ;
ITEMVALUES {V101,V102,V103,V104,V170,V171,V172,V150,V181,V180,V173,V174,V175,V182,V183,V184,V185,V186,V187,V190}
PRINTAREA 2 OF oVRD
SELE (SELTEMP)
DBGOTOP()
SELE (SELTEMP)
DBGOTOP()
DO WHILE .NOT. EOF()
V330:=TRANSFORM(RECNO(),"9,999")
V320:=(SELTEMP)->HTARTICU
IF NITEMP="860534227"
V302:=ALLTRIM(SUBS((SELTEMP)->HTDETALL,1,28))+"-"+ALLTRIM((SELTEMP)->HTOBSER2)
ELSEIF NITEMP="900186800"
V302:=(SELTEMP)->HTDETALL+" "+(SELTEMP)->HTOBSER2
ELSE
V302:=ALLTRIM(SUBS((SELTEMP)->HTDETALL,1,28))
ENDIF
V303:=TRANSFORM((SELTEMP)->HTCANTID,"99999.99")
IF DOLAR=.F.
VRporiva:=(SELTEMP)->HTPORIVA
VRtotale:=(SELTEMP)->HTVRUNIT
VRpordes:=(SELTEMP)->HTPORDES
IF ((SELTEMP)->HTFORIVA=1) //*******IVA INCLUIDO*********
Divide:=((VRporiva/100)+1)
VRtota:=ROUND(VRtotale,Decimales)
VRprde:=(VRpordes/100)
Etotal:=ROUND((VRtota*VRprde),Decimales) //Valor Descuento
Vrunit:=VRtota-Etotal
VRfinal:=ROUND((Vrunit/Divide),Decimales)
V304:=TRANSFORM(VRfinal,"999,999,999")
ELSE
V304:=TRANSFORM((SELTEMP)->HTVRUNIT,"999,999,999")
ENDIF
* V304:=TRANSFORM((SELTEMP)->HTVRUNIT,"999,999,999")
V305:=TRANSFORM((SELTEMP)->HTSUBTOT,"999,999,999")
V306:=TRANSFORM((SELTEMP)->HTDESCUE,"999,999,999")
V307:=TRANSFORM((SELTEMP)->HTVRIVAS,"999,999,999")
V308:=TRANSFORM((SELTEMP)->HTVRTOTA,"999,999,999")
V309:=TRANSFORM((SELTEMP)->HTPORIVA,"999,999,999")
V310:=TRANSFORM((SELTEMP)->HTPORDES,"999,999,999")
V311:=V451:=(SELTEMP)->HTOBSER2
V312:=TRANSFORM(ROUND(((SELTEMP)->HTVRUNIT)/(((SELTEMP)->HTPORIVA/100)+1),0),"999,999,999")
V313:=TRANSFORM(((SELTEMP)->HTVRTOTA-(SELTEMP)->HTVRIVAS),"999,999,999")
ELSE
V307:=" " //No Genera IVA
V309:=" " //No Genera IVA
* V305:=" " //Subtotal no lo muestra en la factura
V306:=" " //Valor $ de Descuento no lo muestra en la factura
V311:=V451:=" " //No genera
V312:=" " //No genera
V304:=TRANSFORM((SELTEMP)->HTDOLARE,"999,999,999.99")
V310:=TRANSFORM((SELTEMP)->HTPORDES,"999,999,999.99")
SUB:=(HTCANTID*HTDOLARE)
V305:=TRANSFORM(SUB,"999,999,999.99")
DES:=ROUND( (((HTCANTID*HTDOLARE)*HTPORDES)/100),2)
TOT:=(SUB-DES)
V308:=TRANSFORM(TOT,"999,999,999.99")
V313:=TRANSFORM(TOT,"999,999,999.99")
ENDIF
IF Pub:CODEMP="LU" //PARA ILUMINATTY
V305:=TRANSFORM(((SELTEMP)->HTSUBTOT-(SELTEMP)->HTDESCUE),"999,999,999")
ENDIF
IF Pub:CODEMP="20" //PARA METALES
PRINTAREA 3 OF oVRD ITEMIDS { 330, 320, 302, 303, 304, 305, 306, 307, 308, 311};
ITEMVALUES {V330,V320,V302,V303,V304,V305,V306,V307,V308,V311}
ELSE
PRINTAREA 3 OF oVRD ITEMIDS { 330, 320, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313};
ITEMVALUES {V330,V320,V302,V303,V304,V305,V306,V307,V308,V309,V310,V311,V312,V313}
ENDIF
FACDOL:=(SELTEMP)->HTFACDOL
//TOTALES//
IF DOLAR=.F.
CANT:=CANT+HTCANTID
SUBT:=SUBT+HTSUBTOT
DEST:=DEST+HTDESCUE
IVAT:=IVAT+HTVRIVAS
VRTT:=VRTT+HTVRTOTA
ELSE
CANT:=CANT+HTCANTID
SUBT:=SUBT+SUB
DEST:=DEST+DES
IVAT:=" "
VRTT:=VRTT+TOT
ENDIF
(SELTEMP)->(DBSKIP())
IF oVRD:nNextRow > oVRD:nPageBreak
PAGEBREAK oVRD
PRINTAREA 1 OF oVRD ;
ITEMIDS { 101, 102, 103, 104, 170, 171, 172, 150, 181, 180, 173, 174, 175, 182, 183, 184, 185, 186, 187} ;
ITEMVALUES {V101,V102,V103,V104,V170,V171,V172,V150,V181,V180,V173,V174,V175,V182,V183,V184,V185,V186,V187}
PRINTAREA 2 OF oVRD
ENDIF
ENDDO
IF DOLAR=.F.
V403:=TRAN(CANT,"999,999,999")
V405:=V505:=TRAN(SUBT,"999,999,999")
V406:=TRAN(DEST,"999,999,999")
V407:=V507:=TRAN(IVAT,"999,999,999")
V408:=TRAN(VRTT,"999,999,999")
V410:=V520:=ALLTRIM(GVobs)
V411:=TRAN(GVfle,"999,999,999")
V412:=V512:=TRAN(((VRTT)-(GVret+GViva+GVica)),"999,999,999")
V413:=TRAN(GVret,"999,999,999")
V414:=TRAN(GViva,"999,999,999")
V415:=TRAN(GVica,"999,999,999")
ELSE
V403:=TRANSFORM(CANT,"999,999,999.99")
V405:=V505:=TRANSFORM(SUBT,"999,999,999.99")
V406:=TRANSFORM(DEST,"999,999,999.99")
V407:=V507:=TRANSFORM(IVAT,"999,999,999.99")
V408:=TRANSFORM(VRTT,"999,999,999.99")
V410:=V520:=ALLTRIM(GVobs)
V411:=TRAN(GVfle,"999,999,999.99")
V412:=V512:=TRAN(((VRTT)-(GVret+GViva+GVica)),"999,999,999.99")
V413:=TRAN(GVret,"999,999,999.99")
V414:=TRAN(GViva,"999,999,999.99")
V415:=TRAN(GVica,"999,999,999.99")
ENDIF
IF Pub:CODEMP="LU" //PARA ILUMINATTY
V405:=TRAN((SUBT-DEST),"999,999,999")
ENDIF
SDOTOT:=((VRTT)-(GVret+GViva+GVica))
VALORES()
V521:=V409:=CAMT
PRINTAREA 4 OF oVRD ITEMIDS { 403, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 451} ;
ITEMVALUES {V403,V405,V406,V407,V408,V409,V410,V411,V412,V413,V414,V415,V451}
PRINTAREA 5 OF oVRD ITEMIDS { 520, 521, 505, 507, 512} ;
ITEMVALUES {V520,V521,V505,V507,V512}
END EASYREPORT oVRD