Invoice
- Robert Frank
- Posts: 95
- Joined: Fri Nov 23, 2007 4:43 am
- Location: Gdynia-Poland
- Contact:
Re: Invoice
// WYDRUK
Static Procedure DRUKUJ(cPRINTER,cOPIS)
Local cTYTWYDRUKU:=Ptxt("FAKTURA VAT nr ")+AllTrim(FVAT1->NR_M)+cOPIS
Local lPREV:=.F.
oPRN:=PrintBegin(cTYTWYDRUKU,.F.,lPREV,IIF(cPRINTER<>NIL,cPRINTER,PrnGetName()))
Page
FV_CIENIE(@oPRN)
FV_NAGLOWEK(@oPRN,cOPIS)
//FV_KRESKI(@oPRN)
FV_ZAWARTOSC(@oPRN)
EndPage
EndPrint
Return
Function FV_NAGLOWEK(oPRN,cOPIS)
Local oFARIAL12B
Local oFARIAL6N
Local oFARIAL6B
Local aSPR:={} // sprzedawca
Local aNAB:={} // nabywca
Local XXX
Local nINT:=0.5
Local nLP :=2
AADD(aSPR,OemToAnsi(AllTrim(FIRMY->NAZWA1)))
AADD(aSPR,OemToAnsi(AllTrim(FIRMY->NAZWA2)))
AADD(aSPR,OemToAnsi(AllTrim(FIRMY->NAZWA3)))
AADD(aSPR,OemToAnsi(AllTrim(FIRMY->ADR2)+" "+AllTrim(FIRMY->ADR1)))
AADD(aSPR,OemToAnsi(AllTrim(FIRMY->ADR3)+" "+AllTrim(FIRMY->ADR4)))
AADD(aSPR,"NIP : "+AllTrim(FIRMY->NIP))
AADD(aSPR,"numer konta bankowego")
AADD(aSPR,AllTrim(FIRMY->BANK1))
AADD(aSPR,AllTrim(FIRMY->BANK2))
AADD(aNAB,OemToAnsi(AllTrim(FVAT1->NAZWA1)))
AADD(aNAB,OemToAnsi(AllTrim(FVAT1->NAZWA2)))
AADD(aNAB,OemToAnsi(AllTrim(FVAT1->NAZWA3)))
AADD(aNAB,OemToAnsi(AllTrim(FVAT1->MIASTO)))
AADD(aNAB,OemToAnsi(AllTrim(FVAT1->ADRES)))
AADD(aNAB,"NIP : "+AllTrim(FVAT1->NRID))
DEFINE FONT oFARIAL12B NAME "ARIAL CE" SIZE 0,-12 BOLD OF oPrn
DEFINE FONT oFARIAL6N NAME "ARIAL CE" SIZE 0, -8 OF oPrn
DEFINE FONT oFARIAL6B NAME "ARIAL CE" SIZE 0, -8 BOLD OF oPrn
oPRN:CmSay(0.5,19,AllTrim(OemToAnsi(FIRMY->ADR7))+" dnia "+DToC(FVAT1->DATA),oFARIAL6B,,,,1)
oPRN:CmSay(1 ,2,Ptxt("FAKTURA VAT nr ")+AllTrim(FVAT1->NR_M),oFARIAL12B,,,,0)
Do Case
Case cOPIS="O"
oPRN:CmSay(1 ,19,Ptxt("ORYGINA~L"),oFARIAL12B,,,,1)
Case cOPIS="K"
oPRN:CmSay(1 ,19,Ptxt("KOPIA"),oFARIAL12B,,,,1)
Otherwise
oPRN:CmSay(1 ,19,Ptxt("ORYGINA~L - KOPIA"),oFARIAL12B,,,,1)
EndCase
oPRN:CmSay(nLP,2.5,Ptxt("Dane sprzedawcy"),oFARIAL6N)
nLP:=2
For XXX:=1 To Len(aSPR)
If .NOT. Empty(aSPR[XXX])
oPRN:CmSay(1.5+(nLP++)*nINT,2.5,aSPR[XXX],oFARIAL6B)
EndIf
Next
oPRN:CmSay(2.0,10.5,Ptxt("Dane nabywcy"),oFARIAL6N)
nLP:=2
For XXX:=1 To Len(aNAB)
If .NOT. Empty(aNAB[XXX])
oPRN:CmSay(1.5+(nLP++)*nINT,10.5,aNAB[XXX],oFARIAL6B)
ENdIf
Next
Return .T.
Function FV_ZAWARTOSC(oPRN)
Local oFARIAL6N
Local oFARIAL6B
Local oFARIAL8B
Local oPEN1
Local oPEN3
Local aSRODEK:={}
Local XXX:=1
Local nLP:=1
Local nINT:=0.5
Local nNETTO:=0
Local nVAT :=0
Local nBRUTTO:=0
Local nTOTALN:=0
Local nTOTALV:=0
Local nTOTALB:=0
Local xWERT:=0 // pozycja lini w pionie
Local xSTART // wsporzedne punktu poczatkowego lini
Local xSTOP // wsporzedne punktu koncowego lini
Local aSUMA:={}
AADD(aSUMA,{"ZW" ,0,0,0})
AADD(aSUMA,{"3%" ,0,0,0})
AADD(aSUMA,{"5%" ,0,0,0})
AADD(aSUMA,{"8%" ,0,0,0})
AADD(aSUMA,{"23%",0,0,0})
// wczytaj do tablicy
If FVAT2->(DbSeek(FVAT1->NR))
Do While FVAT1->NR=FVAT2->NR_DOK .AND. .NOT. FVAT2->(Eof())
nNETTO := Round(FVAT2->ilosc * FVAT2->CENAJ,2)
nVAT := Round(nNETTO * Val(FVAT2->ST_VAT) / 100,2)
nBRUTTO:= Round(nNETTO + nVAT,2)
nTOTALN +=nNETTO
nTOTALV +=nVAT
nTOTALB +=nBRUTTO
AADD(aSRODEK,{;
OemToAnsi(FVAT2->TOWAR),; //1
OemToAnsi(FVAT2->J_M),; //2
AllTrim(Str(FVAT2->ILOSC)),; //3
AllTrim(Str(FVAT2->CENAJ,10,2)),; //4
AllTrim(FVAT2->ST_VAT),; //5
AllTrim(Str(nNETTO ,10,2)),; //6
AllTrim(Str(nVAT ,10,2)),; //7
AllTrim(Str(nBRUTTO,10,2)),; //8
""})
Do Case
Case AllTrim(FVAT2->ST_VAT)=="ZW"
aSUMA[1,2]+=nNETTO
aSUMA[1,3]+=nVAT
aSUMA[1,4]+=nBRUTTO
Case AllTrim(FVAT2->ST_VAT)=="3"
aSUMA[2,2]+=nNETTO
aSUMA[2,3]+=nVAT
aSUMA[2,4]+=nBRUTTO
Case AllTrim(FVAT2->ST_VAT)=="5"
aSUMA[3,2]+=nNETTO
aSUMA[3,3]+=nVAT
aSUMA[3,4]+=nBRUTTO
Case AllTrim(FVAT2->ST_VAT)=="8"
aSUMA[4,2]+=nNETTO
aSUMA[4,3]+=nVAT
aSUMA[4,4]+=nBRUTTO
Case AllTrim(FVAT2->ST_VAT)=="23"
aSUMA[5,2]+=nNETTO
aSUMA[5,3]+=nVAT
aSUMA[5,4]+=nBRUTTO
EndCase
FVAT2->(DbSkip(1))
EndDo
EndIf
DEFINE PEN oPen1 WIDTH 3
DEFINE PEN oPen3 WIDTH 0 STYLE PS_NULL
DEFINE FONT oFARIAL6N NAME "ARIAL CE" SIZE 0, -6 OF oPrn
DEFINE FONT oFARIAL6B NAME "ARIAL CE" SIZE 0, -6 BOLD OF oPrn
DEFINE FONT oFARIAL8B NAME "ARIAL CE" SIZE 0, -8 BOLD OF oPrn
xWERT :=6.2
xSTART:=oPRN:Cmtr2Pix(xWERT,sLEFT)
xSTOP :=oPRN:Cmtr2Pix(xWERT,sRIGHT)
oPRN:Line(xSTART[1],xSTART[2],xSTOP[1],xSTOP[2],oPEN1)
// naglowki
oPRN:CmSay(6.0+(nLP)*nINT,aKOLUMNY[1],"L.p." ,oFARIAL6N,,,,1)
oPRN:CmSay(6.0+(nLP)*nINT,aKOLUMNY[2],"Nazwa" ,oFARIAL6N)
oPRN:CmSay(6.0+(nLP)*nINT,aKOLUMNY[3],"j.m." ,oFARIAL6N,,,,1)
oPRN:CmSay(6.0+(nLP)*nINT,aKOLUMNY[4],Ptxt("ilo~s~c") ,oFARIAL6N,,,,1)
oPRN:CmSay(6.0+(nLP)*nINT,aKOLUMNY[5],"cena jedn." ,oFARIAL6N,,,,1)
oPRN:CmSay(6.0+(nLP)*nINT,aKOLUMNY[6],"stawka VAT" ,oFARIAL6N,,,,1)
oPRN:CmSay(6.0+(nLP)*nINT,aKOLUMNY[7],Ptxt("warto~s~c netto") ,oFARIAL6N,,,,1)
oPRN:CmSay(6.0+(nLP)*nINT,aKOLUMNY[8],Ptxt("warto~s~c VAT" ) ,oFARIAL6N,,,,1)
oPRN:CmSay(6.0+(nLP)*nINT,aKOLUMNY[9],Ptxt("warto~s~c brutto"),oFARIAL6N,,,,1)
xWERT :=7
xSTART:=oPRN:Cmtr2Pix(xWERT,sLEFT)
xSTOP :=oPRN:Cmtr2Pix(xWERT,sRIGHT)
oPRN:Line(xSTART[1],xSTART[2],xSTOP[1],xSTOP[2],oPEN1)
For XXX:=1 To Len(aSRODEK)
oPRN:CmSay(7.0+(nLP)*nINT,aKOLUMNY[1],Str(nLP) ,oFARIAL6N,,,,1)
oPRN:CmSay(7.0+(nLP)*nINT,aKOLUMNY[2],aSRODEK[XXX,1],oFARIAL6B)
oPRN:CmSay(7.0+(nLP)*nINT,aKOLUMNY[3],aSRODEK[XXX,2],oFARIAL6N,,,,1)
oPRN:CmSay(7.0+(nLP)*nINT,aKOLUMNY[4],aSRODEK[XXX,3],oFARIAL6N,,,,1)
oPRN:CmSay(7.0+(nLP)*nINT,aKOLUMNY[5],aSRODEK[XXX,4],oFARIAL6N,,,,1)
oPRN:CmSay(7.0+(nLP)*nINT,aKOLUMNY[6],aSRODEK[XXX,5],oFARIAL6N,,,,1)
oPRN:CmSay(7.0+(nLP)*nINT,aKOLUMNY[7],aSRODEK[XXX,6],oFARIAL6N,,,,1)
oPRN:CmSay(7.0+(nLP)*nINT,aKOLUMNY[8],aSRODEK[XXX,7],oFARIAL6N,,,,1)
oPRN:CmSay(7.0+(nLP)*nINT,aKOLUMNY[9],aSRODEK[XXX,8],oFARIAL6N,,,,1)
nLP++
Next
// zrob kreske
xWERT :=7.0+(nLP)*nINT-0.1
xSTART:=oPRN:Cmtr2Pix(xWERT,sLEFT)
xSTOP :=oPRN:Cmtr2Pix(xWERT,sRIGHT)
oPRN:Line(xSTART[1],xSTART[2],xSTOP[1],xSTOP[2],oPEN1)
For XXX:=1 To Len(aSUMA)
If aSUMA[XXX,2]<>0 // nie puste netto
oPRN:CmSay(7.0+(nLP)*nINT,aKOLUMNY[6],"Razem "+aSUMA[XXX,1] ,oFARIAL6N,,,,1)
oPRN:CmSay(7.0+(nLP)*nINT,aKOLUMNY[7],AllTrim(Str(aSUMA[XXX,2],10,2)),oFARIAL6N,,,,1)
oPRN:CmSay(7.0+(nLP)*nINT,aKOLUMNY[8],AllTrim(Str(aSUMA[XXX,3],10,2)),oFARIAL6N,,,,1)
oPRN:CmSay(7.0+(nLP)*nINT,aKOLUMNY[9],AllTrim(Str(aSUMA[XXX,4],10,2)),oFARIAL6N,,,,1)
nLP++
EndIf
Next
// zrob kreske
xWERT :=7.0+(nLP)*nINT-0.1
xSTART:=oPRN:Cmtr2Pix(xWERT,sLEFT)
xSTOP :=oPRN:Cmtr2Pix(xWERT,sRIGHT)
oPRN:Line(xSTART[1],xSTART[2],xSTOP[1],xSTOP[2],oPEN1)
// podsumowanie
oPRN:CmSay(7.0+(nLP)*nINT,aKOLUMNY[6],Ptxt("Do zap~laty") ,oFARIAL6B,,,,1)
oPRN:CmSay(7.0+(nLP)*nINT,aKOLUMNY[7],AllTrim(Str(nTOTALN,10,2)),oFARIAL6N,,,,1)
oPRN:CmSay(7.0+(nLP)*nINT,aKOLUMNY[8],AllTrim(Str(nTOTALV,10,2)),oFARIAL6N,,,,1)
oPRN:CmSay(7.0+(nLP)*nINT,aKOLUMNY[9],AllTrim(Str(nTOTALB,10,2)),oFARIAL6B,,,,1)
nLP++
// wybiel dol
WRITE_ROUNDBOX(@oPRN,sLEFT,7.0+(nLP)*nINT,sRIGHT+0.5,28.0,oPEN3,nRGB(255,255,255))
// zrob kreske
xWERT :=7.0+(nLP)*nINT
xSTART:=oPRN:Cmtr2Pix(xWERT,sLEFT)
xSTOP :=oPRN:Cmtr2Pix(xWERT,sRIGHT)
oPRN:Line(xSTART[1],xSTART[2],xSTOP[1],xSTOP[2],oPEN1)
nLP++
// teraz pierdoly
oPRN:CmSay(7.0+(nLP++)*nINT,aKOLUMNY[2],Ptxt("Razem do zap~laty : ")+Str(nTOTALB,10,2)+Ptxt(" z~l."),oFARIAL8B,,,,0)
oPRN:CmSay(7.0+(nLP++)*nINT,aKOLUMNY[2],Ptxt("S~lownie : ")+Slownie(Int(nTOTALB))+"_"+Str((nTOTALB-Int(nTOTALB))*100,2,0)+"/100",oFARIAL6N,,,,0)
oPRN:CmSay(7.0+(nLP++)*nINT,aKOLUMNY[2],Ptxt("Data sprzeda~zy : ")+DToC(FVAT1->DATAS),oFARIAL6N,,,,0)
oPRN:CmSay(7.0+(nLP++)*nINT,aKOLUMNY[2],Ptxt("Spos~ob zap~laty : ")+OemToAnsi(FVAT1->S_ZAP),oFARIAL8B,,,,0)
oPRN:CmSay(7.0+(nLP++)*nINT,aKOLUMNY[2],Ptxt("~Srodek transportu : ")+OemToAnsi(FVAT1->TRANS),oFARIAL6N,,,,0)
nLP++
nLP++
nLP++
// zrob kreske
xWERT :=7.0+(nLP)*nINT
xSTART:=oPRN:Cmtr2Pix(xWERT,10)
xSTOP :=oPRN:Cmtr2Pix(xWERT,sRIGHT)
oPRN:Line(xSTART[1],xSTART[2],xSTOP[1],xSTOP[2],oPEN1)
oPRN:CmSay(7.0+(nLP++)*nINT,15,Ptxt("Podpis osoby wystawiaj~acej dokument"),oFARIAL6B,,,,2)
// numer strony
oPRN:CmSay(27.5,19,Ptxt("strona 1 z 1"),,,,1)
Return .T.
Function FV_KRESKI(oPRN)
Local xWERT:=0 // pozycja lini w pionie
Local xSTART // wsporzedne punktu poczatkowego lini
Local xSTOP // wsporzedne punktu koncowego lini
Local xLEFT1:=0.5 // lewy margines wydruku
Local xRIGHT1:=20 // prawy margines wydruku
Local xLEFT2:=0.5 // lewy - wewnetrzna ramka na wynik
Local xRIGHT2:=20 // prawy - wewnetrzna ramka na wynik
Local oPEN // grubosc kreski
Local oBRUSH // tlo cienia
// cienie
//DEFINE BRUSH oBrush COLOR GET_LAB_KOL(60)
//FillRect( oPrn:hDcOut, { 100,100,200,200 }, oBrush:hBrush )
DEFINE PEN oPen WIDTH 3
// kreski poziome
xWERT :=6
xSTART:=oPRN:Cmtr2Pix(xWERT,xLEFT2)
xSTOP :=oPRN:Cmtr2Pix(xWERT,xRIGHT2)
oPRN:Line(xSTART[1],xSTART[2],xSTOP[1],xSTOP[2],oPEN)
// pozoma kreska przed sumami
xWERT :=20.0
xSTART:=oPRN:Cmtr2Pix(xWERT,xLEFT2)
xSTOP :=oPRN:Cmtr2Pix(xWERT,xRIGHT2)
oPRN:Line(xSTART[1],xSTART[2],xSTOP[1],xSTOP[2],oPEN)
/*
// kreski pionowe
// pionowa kreska po lewej stronie wyniku
xSTART:=oPRN:Cmtr2Pix(6,xLEFT2) // az do komentarzy
xSTOP :=oPRN:Cmtr2Pix(25.0,xLEFT2)
oPRN:Line(xSTART[1],xSTART[2],xSTOP[1],xSTOP[2],oPEN)
// pionowa kreska po prawej stronie wyniku
xSTART:=oPRN:Cmtr2Pix(6,xRIGHT2) // az do komentarzy
xSTOP :=oPRN:Cmtr2Pix(25.0,xRIGHT2)
oPRN:Line(xSTART[1],xSTART[2],xSTOP[1],xSTOP[2],oPEN)
*/
oPEN:End()
Return .T.
Static Function FV_CIENIE(oPRN)
Local oPEN3
DEFINE PEN oPen3 WIDTH 0 STYLE PS_NULL
// kontrahent
WRITE_ROUNDBOX(@oPRN,10,2,sRIGHT,6.0,oPEN3,nRGB(230,230,230))
// kolumny
WRITE_ROUNDBOX(@oPRN,aKOLUMNY[1]-0.5,7,aKOLUMNY[1]+0.2,25,oPEN3,nRGB(220,220,220)) //LP
WRITE_ROUNDBOX(@oPRN,aKOLUMNY[3]-0.5,7,aKOLUMNY[3]+0.2,25,oPEN3,nRGB(220,220,220)) //jm
WRITE_ROUNDBOX(@oPRN,aKOLUMNY[5]-1.3,7,aKOLUMNY[5]+0.1,25,oPEN3,nRGB(220,220,220)) // cenaj
WRITE_ROUNDBOX(@oPRN,aKOLUMNY[7]-1.3,7,aKOLUMNY[7]+0.1,25,oPEN3,nRGB(220,220,220)) // netto
WRITE_ROUNDBOX(@oPRN,aKOLUMNY[9]-1.5,7,aKOLUMNY[9]+0.2,25,oPEN3,nRGB(220,220,220))
Return .T.
Static Function WRITE_ROUNDBOX(oPRN,xODX,xODY,xDOX,xDOY,xPEN,xKOLOR)
Default xODX := 5.90 // os x odleglosc startu od lewej
Default xODY := 0.90 // os Y gdzie zaczac od gory
Default xDOX := 10.6 // os x - gdzie ma skonczyc od lewej
Default xDOY := 20.0 // os Y gdzie skonczyc od gory
oPrn:Cmtr2Pix(@xODX, @xODY)
oPrn:cmtr2Pix(@xDOX, @xDOY)
oPrn:RoundBox(xODX, xODY, xDOX, xDOY, 0,0, xPen , xKOLOR )
Return .T.
Static Procedure DRUKUJ(cPRINTER,cOPIS)
Local cTYTWYDRUKU:=Ptxt("FAKTURA VAT nr ")+AllTrim(FVAT1->NR_M)+cOPIS
Local lPREV:=.F.
oPRN:=PrintBegin(cTYTWYDRUKU,.F.,lPREV,IIF(cPRINTER<>NIL,cPRINTER,PrnGetName()))
Page
FV_CIENIE(@oPRN)
FV_NAGLOWEK(@oPRN,cOPIS)
//FV_KRESKI(@oPRN)
FV_ZAWARTOSC(@oPRN)
EndPage
EndPrint
Return
Function FV_NAGLOWEK(oPRN,cOPIS)
Local oFARIAL12B
Local oFARIAL6N
Local oFARIAL6B
Local aSPR:={} // sprzedawca
Local aNAB:={} // nabywca
Local XXX
Local nINT:=0.5
Local nLP :=2
AADD(aSPR,OemToAnsi(AllTrim(FIRMY->NAZWA1)))
AADD(aSPR,OemToAnsi(AllTrim(FIRMY->NAZWA2)))
AADD(aSPR,OemToAnsi(AllTrim(FIRMY->NAZWA3)))
AADD(aSPR,OemToAnsi(AllTrim(FIRMY->ADR2)+" "+AllTrim(FIRMY->ADR1)))
AADD(aSPR,OemToAnsi(AllTrim(FIRMY->ADR3)+" "+AllTrim(FIRMY->ADR4)))
AADD(aSPR,"NIP : "+AllTrim(FIRMY->NIP))
AADD(aSPR,"numer konta bankowego")
AADD(aSPR,AllTrim(FIRMY->BANK1))
AADD(aSPR,AllTrim(FIRMY->BANK2))
AADD(aNAB,OemToAnsi(AllTrim(FVAT1->NAZWA1)))
AADD(aNAB,OemToAnsi(AllTrim(FVAT1->NAZWA2)))
AADD(aNAB,OemToAnsi(AllTrim(FVAT1->NAZWA3)))
AADD(aNAB,OemToAnsi(AllTrim(FVAT1->MIASTO)))
AADD(aNAB,OemToAnsi(AllTrim(FVAT1->ADRES)))
AADD(aNAB,"NIP : "+AllTrim(FVAT1->NRID))
DEFINE FONT oFARIAL12B NAME "ARIAL CE" SIZE 0,-12 BOLD OF oPrn
DEFINE FONT oFARIAL6N NAME "ARIAL CE" SIZE 0, -8 OF oPrn
DEFINE FONT oFARIAL6B NAME "ARIAL CE" SIZE 0, -8 BOLD OF oPrn
oPRN:CmSay(0.5,19,AllTrim(OemToAnsi(FIRMY->ADR7))+" dnia "+DToC(FVAT1->DATA),oFARIAL6B,,,,1)
oPRN:CmSay(1 ,2,Ptxt("FAKTURA VAT nr ")+AllTrim(FVAT1->NR_M),oFARIAL12B,,,,0)
Do Case
Case cOPIS="O"
oPRN:CmSay(1 ,19,Ptxt("ORYGINA~L"),oFARIAL12B,,,,1)
Case cOPIS="K"
oPRN:CmSay(1 ,19,Ptxt("KOPIA"),oFARIAL12B,,,,1)
Otherwise
oPRN:CmSay(1 ,19,Ptxt("ORYGINA~L - KOPIA"),oFARIAL12B,,,,1)
EndCase
oPRN:CmSay(nLP,2.5,Ptxt("Dane sprzedawcy"),oFARIAL6N)
nLP:=2
For XXX:=1 To Len(aSPR)
If .NOT. Empty(aSPR[XXX])
oPRN:CmSay(1.5+(nLP++)*nINT,2.5,aSPR[XXX],oFARIAL6B)
EndIf
Next
oPRN:CmSay(2.0,10.5,Ptxt("Dane nabywcy"),oFARIAL6N)
nLP:=2
For XXX:=1 To Len(aNAB)
If .NOT. Empty(aNAB[XXX])
oPRN:CmSay(1.5+(nLP++)*nINT,10.5,aNAB[XXX],oFARIAL6B)
ENdIf
Next
Return .T.
Function FV_ZAWARTOSC(oPRN)
Local oFARIAL6N
Local oFARIAL6B
Local oFARIAL8B
Local oPEN1
Local oPEN3
Local aSRODEK:={}
Local XXX:=1
Local nLP:=1
Local nINT:=0.5
Local nNETTO:=0
Local nVAT :=0
Local nBRUTTO:=0
Local nTOTALN:=0
Local nTOTALV:=0
Local nTOTALB:=0
Local xWERT:=0 // pozycja lini w pionie
Local xSTART // wsporzedne punktu poczatkowego lini
Local xSTOP // wsporzedne punktu koncowego lini
Local aSUMA:={}
AADD(aSUMA,{"ZW" ,0,0,0})
AADD(aSUMA,{"3%" ,0,0,0})
AADD(aSUMA,{"5%" ,0,0,0})
AADD(aSUMA,{"8%" ,0,0,0})
AADD(aSUMA,{"23%",0,0,0})
// wczytaj do tablicy
If FVAT2->(DbSeek(FVAT1->NR))
Do While FVAT1->NR=FVAT2->NR_DOK .AND. .NOT. FVAT2->(Eof())
nNETTO := Round(FVAT2->ilosc * FVAT2->CENAJ,2)
nVAT := Round(nNETTO * Val(FVAT2->ST_VAT) / 100,2)
nBRUTTO:= Round(nNETTO + nVAT,2)
nTOTALN +=nNETTO
nTOTALV +=nVAT
nTOTALB +=nBRUTTO
AADD(aSRODEK,{;
OemToAnsi(FVAT2->TOWAR),; //1
OemToAnsi(FVAT2->J_M),; //2
AllTrim(Str(FVAT2->ILOSC)),; //3
AllTrim(Str(FVAT2->CENAJ,10,2)),; //4
AllTrim(FVAT2->ST_VAT),; //5
AllTrim(Str(nNETTO ,10,2)),; //6
AllTrim(Str(nVAT ,10,2)),; //7
AllTrim(Str(nBRUTTO,10,2)),; //8
""})
Do Case
Case AllTrim(FVAT2->ST_VAT)=="ZW"
aSUMA[1,2]+=nNETTO
aSUMA[1,3]+=nVAT
aSUMA[1,4]+=nBRUTTO
Case AllTrim(FVAT2->ST_VAT)=="3"
aSUMA[2,2]+=nNETTO
aSUMA[2,3]+=nVAT
aSUMA[2,4]+=nBRUTTO
Case AllTrim(FVAT2->ST_VAT)=="5"
aSUMA[3,2]+=nNETTO
aSUMA[3,3]+=nVAT
aSUMA[3,4]+=nBRUTTO
Case AllTrim(FVAT2->ST_VAT)=="8"
aSUMA[4,2]+=nNETTO
aSUMA[4,3]+=nVAT
aSUMA[4,4]+=nBRUTTO
Case AllTrim(FVAT2->ST_VAT)=="23"
aSUMA[5,2]+=nNETTO
aSUMA[5,3]+=nVAT
aSUMA[5,4]+=nBRUTTO
EndCase
FVAT2->(DbSkip(1))
EndDo
EndIf
DEFINE PEN oPen1 WIDTH 3
DEFINE PEN oPen3 WIDTH 0 STYLE PS_NULL
DEFINE FONT oFARIAL6N NAME "ARIAL CE" SIZE 0, -6 OF oPrn
DEFINE FONT oFARIAL6B NAME "ARIAL CE" SIZE 0, -6 BOLD OF oPrn
DEFINE FONT oFARIAL8B NAME "ARIAL CE" SIZE 0, -8 BOLD OF oPrn
xWERT :=6.2
xSTART:=oPRN:Cmtr2Pix(xWERT,sLEFT)
xSTOP :=oPRN:Cmtr2Pix(xWERT,sRIGHT)
oPRN:Line(xSTART[1],xSTART[2],xSTOP[1],xSTOP[2],oPEN1)
// naglowki
oPRN:CmSay(6.0+(nLP)*nINT,aKOLUMNY[1],"L.p." ,oFARIAL6N,,,,1)
oPRN:CmSay(6.0+(nLP)*nINT,aKOLUMNY[2],"Nazwa" ,oFARIAL6N)
oPRN:CmSay(6.0+(nLP)*nINT,aKOLUMNY[3],"j.m." ,oFARIAL6N,,,,1)
oPRN:CmSay(6.0+(nLP)*nINT,aKOLUMNY[4],Ptxt("ilo~s~c") ,oFARIAL6N,,,,1)
oPRN:CmSay(6.0+(nLP)*nINT,aKOLUMNY[5],"cena jedn." ,oFARIAL6N,,,,1)
oPRN:CmSay(6.0+(nLP)*nINT,aKOLUMNY[6],"stawka VAT" ,oFARIAL6N,,,,1)
oPRN:CmSay(6.0+(nLP)*nINT,aKOLUMNY[7],Ptxt("warto~s~c netto") ,oFARIAL6N,,,,1)
oPRN:CmSay(6.0+(nLP)*nINT,aKOLUMNY[8],Ptxt("warto~s~c VAT" ) ,oFARIAL6N,,,,1)
oPRN:CmSay(6.0+(nLP)*nINT,aKOLUMNY[9],Ptxt("warto~s~c brutto"),oFARIAL6N,,,,1)
xWERT :=7
xSTART:=oPRN:Cmtr2Pix(xWERT,sLEFT)
xSTOP :=oPRN:Cmtr2Pix(xWERT,sRIGHT)
oPRN:Line(xSTART[1],xSTART[2],xSTOP[1],xSTOP[2],oPEN1)
For XXX:=1 To Len(aSRODEK)
oPRN:CmSay(7.0+(nLP)*nINT,aKOLUMNY[1],Str(nLP) ,oFARIAL6N,,,,1)
oPRN:CmSay(7.0+(nLP)*nINT,aKOLUMNY[2],aSRODEK[XXX,1],oFARIAL6B)
oPRN:CmSay(7.0+(nLP)*nINT,aKOLUMNY[3],aSRODEK[XXX,2],oFARIAL6N,,,,1)
oPRN:CmSay(7.0+(nLP)*nINT,aKOLUMNY[4],aSRODEK[XXX,3],oFARIAL6N,,,,1)
oPRN:CmSay(7.0+(nLP)*nINT,aKOLUMNY[5],aSRODEK[XXX,4],oFARIAL6N,,,,1)
oPRN:CmSay(7.0+(nLP)*nINT,aKOLUMNY[6],aSRODEK[XXX,5],oFARIAL6N,,,,1)
oPRN:CmSay(7.0+(nLP)*nINT,aKOLUMNY[7],aSRODEK[XXX,6],oFARIAL6N,,,,1)
oPRN:CmSay(7.0+(nLP)*nINT,aKOLUMNY[8],aSRODEK[XXX,7],oFARIAL6N,,,,1)
oPRN:CmSay(7.0+(nLP)*nINT,aKOLUMNY[9],aSRODEK[XXX,8],oFARIAL6N,,,,1)
nLP++
Next
// zrob kreske
xWERT :=7.0+(nLP)*nINT-0.1
xSTART:=oPRN:Cmtr2Pix(xWERT,sLEFT)
xSTOP :=oPRN:Cmtr2Pix(xWERT,sRIGHT)
oPRN:Line(xSTART[1],xSTART[2],xSTOP[1],xSTOP[2],oPEN1)
For XXX:=1 To Len(aSUMA)
If aSUMA[XXX,2]<>0 // nie puste netto
oPRN:CmSay(7.0+(nLP)*nINT,aKOLUMNY[6],"Razem "+aSUMA[XXX,1] ,oFARIAL6N,,,,1)
oPRN:CmSay(7.0+(nLP)*nINT,aKOLUMNY[7],AllTrim(Str(aSUMA[XXX,2],10,2)),oFARIAL6N,,,,1)
oPRN:CmSay(7.0+(nLP)*nINT,aKOLUMNY[8],AllTrim(Str(aSUMA[XXX,3],10,2)),oFARIAL6N,,,,1)
oPRN:CmSay(7.0+(nLP)*nINT,aKOLUMNY[9],AllTrim(Str(aSUMA[XXX,4],10,2)),oFARIAL6N,,,,1)
nLP++
EndIf
Next
// zrob kreske
xWERT :=7.0+(nLP)*nINT-0.1
xSTART:=oPRN:Cmtr2Pix(xWERT,sLEFT)
xSTOP :=oPRN:Cmtr2Pix(xWERT,sRIGHT)
oPRN:Line(xSTART[1],xSTART[2],xSTOP[1],xSTOP[2],oPEN1)
// podsumowanie
oPRN:CmSay(7.0+(nLP)*nINT,aKOLUMNY[6],Ptxt("Do zap~laty") ,oFARIAL6B,,,,1)
oPRN:CmSay(7.0+(nLP)*nINT,aKOLUMNY[7],AllTrim(Str(nTOTALN,10,2)),oFARIAL6N,,,,1)
oPRN:CmSay(7.0+(nLP)*nINT,aKOLUMNY[8],AllTrim(Str(nTOTALV,10,2)),oFARIAL6N,,,,1)
oPRN:CmSay(7.0+(nLP)*nINT,aKOLUMNY[9],AllTrim(Str(nTOTALB,10,2)),oFARIAL6B,,,,1)
nLP++
// wybiel dol
WRITE_ROUNDBOX(@oPRN,sLEFT,7.0+(nLP)*nINT,sRIGHT+0.5,28.0,oPEN3,nRGB(255,255,255))
// zrob kreske
xWERT :=7.0+(nLP)*nINT
xSTART:=oPRN:Cmtr2Pix(xWERT,sLEFT)
xSTOP :=oPRN:Cmtr2Pix(xWERT,sRIGHT)
oPRN:Line(xSTART[1],xSTART[2],xSTOP[1],xSTOP[2],oPEN1)
nLP++
// teraz pierdoly
oPRN:CmSay(7.0+(nLP++)*nINT,aKOLUMNY[2],Ptxt("Razem do zap~laty : ")+Str(nTOTALB,10,2)+Ptxt(" z~l."),oFARIAL8B,,,,0)
oPRN:CmSay(7.0+(nLP++)*nINT,aKOLUMNY[2],Ptxt("S~lownie : ")+Slownie(Int(nTOTALB))+"_"+Str((nTOTALB-Int(nTOTALB))*100,2,0)+"/100",oFARIAL6N,,,,0)
oPRN:CmSay(7.0+(nLP++)*nINT,aKOLUMNY[2],Ptxt("Data sprzeda~zy : ")+DToC(FVAT1->DATAS),oFARIAL6N,,,,0)
oPRN:CmSay(7.0+(nLP++)*nINT,aKOLUMNY[2],Ptxt("Spos~ob zap~laty : ")+OemToAnsi(FVAT1->S_ZAP),oFARIAL8B,,,,0)
oPRN:CmSay(7.0+(nLP++)*nINT,aKOLUMNY[2],Ptxt("~Srodek transportu : ")+OemToAnsi(FVAT1->TRANS),oFARIAL6N,,,,0)
nLP++
nLP++
nLP++
// zrob kreske
xWERT :=7.0+(nLP)*nINT
xSTART:=oPRN:Cmtr2Pix(xWERT,10)
xSTOP :=oPRN:Cmtr2Pix(xWERT,sRIGHT)
oPRN:Line(xSTART[1],xSTART[2],xSTOP[1],xSTOP[2],oPEN1)
oPRN:CmSay(7.0+(nLP++)*nINT,15,Ptxt("Podpis osoby wystawiaj~acej dokument"),oFARIAL6B,,,,2)
// numer strony
oPRN:CmSay(27.5,19,Ptxt("strona 1 z 1"),,,,1)
Return .T.
Function FV_KRESKI(oPRN)
Local xWERT:=0 // pozycja lini w pionie
Local xSTART // wsporzedne punktu poczatkowego lini
Local xSTOP // wsporzedne punktu koncowego lini
Local xLEFT1:=0.5 // lewy margines wydruku
Local xRIGHT1:=20 // prawy margines wydruku
Local xLEFT2:=0.5 // lewy - wewnetrzna ramka na wynik
Local xRIGHT2:=20 // prawy - wewnetrzna ramka na wynik
Local oPEN // grubosc kreski
Local oBRUSH // tlo cienia
// cienie
//DEFINE BRUSH oBrush COLOR GET_LAB_KOL(60)
//FillRect( oPrn:hDcOut, { 100,100,200,200 }, oBrush:hBrush )
DEFINE PEN oPen WIDTH 3
// kreski poziome
xWERT :=6
xSTART:=oPRN:Cmtr2Pix(xWERT,xLEFT2)
xSTOP :=oPRN:Cmtr2Pix(xWERT,xRIGHT2)
oPRN:Line(xSTART[1],xSTART[2],xSTOP[1],xSTOP[2],oPEN)
// pozoma kreska przed sumami
xWERT :=20.0
xSTART:=oPRN:Cmtr2Pix(xWERT,xLEFT2)
xSTOP :=oPRN:Cmtr2Pix(xWERT,xRIGHT2)
oPRN:Line(xSTART[1],xSTART[2],xSTOP[1],xSTOP[2],oPEN)
/*
// kreski pionowe
// pionowa kreska po lewej stronie wyniku
xSTART:=oPRN:Cmtr2Pix(6,xLEFT2) // az do komentarzy
xSTOP :=oPRN:Cmtr2Pix(25.0,xLEFT2)
oPRN:Line(xSTART[1],xSTART[2],xSTOP[1],xSTOP[2],oPEN)
// pionowa kreska po prawej stronie wyniku
xSTART:=oPRN:Cmtr2Pix(6,xRIGHT2) // az do komentarzy
xSTOP :=oPRN:Cmtr2Pix(25.0,xRIGHT2)
oPRN:Line(xSTART[1],xSTART[2],xSTOP[1],xSTOP[2],oPEN)
*/
oPEN:End()
Return .T.
Static Function FV_CIENIE(oPRN)
Local oPEN3
DEFINE PEN oPen3 WIDTH 0 STYLE PS_NULL
// kontrahent
WRITE_ROUNDBOX(@oPRN,10,2,sRIGHT,6.0,oPEN3,nRGB(230,230,230))
// kolumny
WRITE_ROUNDBOX(@oPRN,aKOLUMNY[1]-0.5,7,aKOLUMNY[1]+0.2,25,oPEN3,nRGB(220,220,220)) //LP
WRITE_ROUNDBOX(@oPRN,aKOLUMNY[3]-0.5,7,aKOLUMNY[3]+0.2,25,oPEN3,nRGB(220,220,220)) //jm
WRITE_ROUNDBOX(@oPRN,aKOLUMNY[5]-1.3,7,aKOLUMNY[5]+0.1,25,oPEN3,nRGB(220,220,220)) // cenaj
WRITE_ROUNDBOX(@oPRN,aKOLUMNY[7]-1.3,7,aKOLUMNY[7]+0.1,25,oPEN3,nRGB(220,220,220)) // netto
WRITE_ROUNDBOX(@oPRN,aKOLUMNY[9]-1.5,7,aKOLUMNY[9]+0.2,25,oPEN3,nRGB(220,220,220))
Return .T.
Static Function WRITE_ROUNDBOX(oPRN,xODX,xODY,xDOX,xDOY,xPEN,xKOLOR)
Default xODX := 5.90 // os x odleglosc startu od lewej
Default xODY := 0.90 // os Y gdzie zaczac od gory
Default xDOX := 10.6 // os x - gdzie ma skonczyc od lewej
Default xDOY := 20.0 // os Y gdzie skonczyc od gory
oPrn:Cmtr2Pix(@xODX, @xODY)
oPrn:cmtr2Pix(@xDOX, @xDOY)
oPrn:RoundBox(xODX, xODY, xDOX, xDOY, 0,0, xPen , xKOLOR )
Return .T.
Robert Frank
Re: Invoice
Panie Robercie czy może Pan podesłać mi testowe bazy do tego przykładu wydruku faktury.
best regards
kajot
kajot
- Robert Frank
- Posts: 95
- Joined: Fri Nov 23, 2007 4:43 am
- Location: Gdynia-Poland
- Contact:
Re: Invoice
thanks
Progetto: test, Ambiente: xFive_Pelles:
[1]:iLink32.Exe -Gn -aa -Tpe -s @test.bcl
Turbo Incremental Link 5.69 Copyright (c) 1997-2005 Borland
Error: Unresolved external '_HB_FUN_PTXT' referenced from C:\WORK\ERRORI\TEST_INVOICE\OBJ\TEST.OBJ
Error: Unresolved external '_HB_FUN_SLOWNIE' referenced from C:\WORK\ERRORI\TEST_INVOICE\OBJ\TEST.OBJ
can send me the sample test please?
silvio[dot]falconi[at]gmail[dot]com
thanks
Progetto: test, Ambiente: xFive_Pelles:
[1]:iLink32.Exe -Gn -aa -Tpe -s @test.bcl
Turbo Incremental Link 5.69 Copyright (c) 1997-2005 Borland
Error: Unresolved external '_HB_FUN_PTXT' referenced from C:\WORK\ERRORI\TEST_INVOICE\OBJ\TEST.OBJ
Error: Unresolved external '_HB_FUN_SLOWNIE' referenced from C:\WORK\ERRORI\TEST_INVOICE\OBJ\TEST.OBJ
can send me the sample test please?
silvio[dot]falconi[at]gmail[dot]com
thanks
Best Regards, Saludos
Falconi Silvio
Falconi Silvio
- Robert Frank
- Posts: 95
- Joined: Fri Nov 23, 2007 4:43 am
- Location: Gdynia-Poland
- Contact:
Re: Invoice
Silvio
I sent to you working sample.
Function Ptxt() and Slownie() are in my libraries.
R.
I sent to you working sample.
Function Ptxt() and Slownie() are in my libraries.
R.
Robert Frank
Re: Invoice
I'm searching a system to make something easy
perhaps a easy class to modify files txt where we can inserted commands easy to make an invoice report
then we could call it only with a line commands
It can be use also for all reports
perhaps a easy class to modify files txt where we can inserted commands easy to make an invoice report
then we could call it only with a line commands
It can be use also for all reports
Best Regards, Saludos
Falconi Silvio
Falconi Silvio