Function AusgabeKFZRechnung(_self)
// -----------------------------------------
// 'Rechnung'
// -----------------------------------------
local cSparte
local cVersicherer
local cBuchungshinweis
local cZusatztext
local nWaehrung
local cWaehrung
local cKW
local nSBTK
local nSBVK
local cFahrzeugdaten
local nTabGround
local nKaskoID

local nVal

// cSparte ermitteln
cSparte := _Self:_dbfieldget("DBInk87","ART_WAS")
// cVersicherer ermitteln
cVersicherer := _Self:_dbfieldget("DBInk87","VU_NAME")
// Buchungshinweis ermitteln
cBuchungshinweis := AllTrim(_Self:_dbfieldget("DBInk87","NTEXT"))
// Zusatztext ermitteln
cZusatztext := AllTrim(_Self:_dbfieldget("DBInk87","ZUSATZTEXT"))
// Währung
nWaehrung := _Self:_dbfieldget("DBInk87","WAEHRUNG")
cWaehrung := _SELF:pdfGetWaehrungBezeich(nWaehrung)
nKaskoID := _self:pdf_Art2KaskoID(_SELF:_dbfieldget("DBInk87","ART"))

// nKW ermitteln
cKW := _Self:_dbfieldget("DBInk87","KW")
nSBTK := _Self:_dbfieldget("DBInk87","SBTK")
nSBVK := _Self:_dbfieldget("DBInk87","SBVK")
// Fahrzeugdaten
cFahrzeugdaten := AllTrim(_Self:_dbfieldget("DBInk87","WKZ"))
IF ! Empty(DBInk87->HSNR)
 cFahrzeugdaten := cFahrzeugdaten + " " + Trim(_Self:_dbfieldget("DBInk87","HSNR") )
ENDIF
IF ! Empty(_Self:_dbfieldget("DBInk87","TSNR"))
 cFahrzeugdaten := cFahrzeugdaten + " / " + Trim(_Self:_dbfieldget("DBInk87","TSNR"))
ENDIF
IF ! Empty (_Self:_dbfieldget("DBInk87","HSNAME"))
 cFahrzeugdaten := cFahrzeugdaten + " / " + Trim(_Self:_dbfieldget("DBInk87","HSNAME"))
ENDIF

// Start Ausdruck
	
// Zeile 1
_SELF:waehle_stift( _self:_stift_durchgezogen(), 1 )
_SELF:waehle_farbe( _self:_farbe_schwarz() )
_SELF:waehle_schrift( "ARIAL", 30, _self:_schrift_roman(), _self:_attr_normal() )
_SELF:txt_absolut(10,_self:wYTemp+5,"Policennummer")
_SELF:txt_absolut(770,_self:wYTemp+5,"Versicherer")
_SELF:waehle_schrift( "ARIAL", 35, _self:_schrift_roman(), _self:_attr_fett() )
_SELF:txt_absolut(360,_self:wYTemp,_Self:_dbfieldget("DBInk87","VSNR"))
_SELF:txt_absolut(960,_self:wYTemp,cVersicherer)
_SELF:wYTemp := _SELF:wYTemp + 40


// Zeile 2
_SELF:waehle_schrift( "ARIAL", 30, _self:_schrift_roman(), _self:_attr_normal() )
_SELF:txt_absolut(10,_self:wYTemp+5,"Sparte")
_SELF:waehle_schrift( "ARIAL", 35, _self:_schrift_roman(), _self:_attr_fett() )
_SELF:txt_absolut(360,_self:wYTemp,cSparte)
_SELF:txt_absolut(960,_self:wYTemp,_Self:_dbfieldget("DBInk87","KENN"))
_SELF:wYTemp := _SELF:wYTemp + 40


// Zeile 3	
IF ! empty(cBuchungshinweis)
 _SELF:waehle_schrift( "ARIAL", 30, _self:_schrift_roman(), _self:_attr_normal() )
 _SELF:txt_absolut(10,_self:wYTemp+5,"Buchungshinweis")
 _SELF:waehle_schrift( "ARIAL", 35, _self:_schrift_roman(), _self:_attr_fett() )
 _SELF:txt_absolut(360,_self:wYTemp,cBuchungshinweis)
 _SELF:wYTemp := _self:wYTemp +40
ENDIF

// Zeile 4
_SELF:waehle_schrift( "ARIAL", 30, _self:_schrift_roman(), _self:_attr_normal() )
_SELF:txt_absolut(10,_self:wYTemp+5,"Zahlungsgrund")
_SELF:waehle_schrift( "ARIAL", 35, _self:_schrift_roman(), _self:_attr_fett() )
_SELF:txt_absolut(360,_self:wYTemp,_Self:_dbfieldget("DBInk87","RTEXT"))
_SELF:wYTemp := _self:wYTemp +40

// Zeile 5
_SELF:waehle_schrift( "ARIAL", 30, _self:_schrift_roman(), _self:_attr_normal() )
_SELF:txt_absolut(10,_self:wYTemp+5,"Fälligkeitszeitraum")
_SELF:waehle_schrift( "ARIAL", 35, _self:_schrift_roman(), _self:_attr_fett() )
_SELF:txt_absolut(360,_self:wYTemp,DToC(_Self:_dbfieldget("DBInk87","FAELLIG"))+" - "+DToC(_Self:_dbfieldget("DBInk87","BIS")))
_SELF:wYTemp := _self:wYTemp +40

// Zeile 6
IF ! empty(cZusatzText)
 _SELF:waehle_schrift( "ARIAL", 35, _self:_schrift_roman(), _self:_attr_fett() )
 _SELF:txt_bereich(360,_self:wYTemp,_SELF:seite_x_ausdehnung(),_self:wYTemp+40,_self:_txt_links(),cZusatzText)
 _SELF:wYTemp := _self:wYTemp +40
ENDIF
_SELF:wYTemp := _self:wYTemp +20


// Fällt weg bei KFZ-Flottenrechnung
// -------------------------------------------------------
IF _self:pdf_Art2KaskoID(_SELF:_dbfieldget("DBInk87","ART")) != _self:pdf_nKFZFlotteID()

 // Zeile 7
 _SELF:waehle_schrift( "ARIAL", 30, _self:_schrift_roman(), _self:_attr_normal() )
 _SELF:txt_absolut(10,_self:wYTemp+5,"Fahrzeugdaten")
 _SELF:waehle_schrift( "ARIAL", 35, _self:_schrift_roman(), _self:_attr_fett() )
 _SELF:txt_absolut(360,_self:wYTemp,cFahrzeugdaten)
 _SELF:wYTemp := _self:wYTemp +40

 // Zeile 8
 _SELF:waehle_schrift( "ARIAL", 35, _self:_schrift_roman(), _self:_attr_fett() )
 _SELF:txt_absolut(360,_self:wYTemp,AllTrim(cKW)+" KW/To")
 _SELF:wYTemp := _self:wYTemp +60
 // Tabelle
 IF nKaskoID == _self:pdf_nKFZHVID()
  nTabGround := _SELF:wYTemp + 70		
 ELSE			
  nTabGround := _SELF:wYTemp + 110
 ENDIF
 IF _Self:_dbfieldget("DBInk87","IUVPPA") != 0
  nTabGround := nTabGround + 40
 ENDIF
 IF _Self:_dbfieldget("DBInk87","SCHUTZPA") != 0
  nTabGround := nTabGround + 40
 ENDIF

 _SELF:waehle_farbe( _self:_farbe_weiss() )
 _SELF:waehle_farb_pinsel()
 _SELF:waehle_farbe( _self:_farbe_grau() )
 _SELF:waehle_stift( _self:_stift_durchgezogen(), 4 )
 _SELF:gdi_rect(10, _self:wYTemp, 1310, nTabGround )
 _SELF:gdi_line(210,_SELF:wYTemp,210,nTabGround)
 _SELF:gdi_line(1110,_SELF:wYTemp,1110,nTabGround)
 _SELF:waehle_stift( _self:_stift_durchgezogen(), 1 )
 _SELF:gdi_line(210,_SELF:wYTemp+30,1310,_SELF:wYTemp+30)
 _SELF:waehle_farbe( _self:_farbe_schwarz() )
 _SELF:waehle_schrift( "ARIAL", 20, _self:_schrift_roman(), _self:_attr_normal() )
 _SELF:txt_absolut(230,_SELF:wYTemp+5,"Tarif")
 _SELF:txt_absolut(310,_SELF:wYTemp+5,"SF-Klasse")
 _SELF:txt_absolut(470,_SELF:wYTemp+5,"SFR")
 _SELF:txt_absolut(580,_SELF:wYTemp+5,"Typklasse")
 _SELF:txt_absolut(760,_SELF:wYTemp+5,"erhoben")
 _SELF:txt_absolut(960,_SELF:wYTemp+5,"erstattet")
 _SELF:txt_absolut(1160,_SELF:wYTemp+5,"Gesamt")

 // HV
 _SELF:wYTemp := _self:wYTemp +30
 _SELF:waehle_schrift( "ARIAL", 30, _self:_schrift_roman(), _self:_attr_normal() )
 _SELF:txt_absolut(20, _SELF:wYTemp,"Haftpflicht")
 _SELF:txt_absolut(230, _SELF:wYTemp,AllTrim(_Self:_dbfieldget("DBInk87","TH")))
 _SELF:txt_absolut(350, _SELF:wYTemp,AllTrim(_Self:_dbfieldget("DBInk87","SFKH")))
 _SELF:txt_absolut(450, _SELF:wYTemp,AllTrim(_Self:_dbfieldget("DBInk87","SFH"))+"%")
 _SELF:txt_absolut(610, _SELF:wYTemp,AllTrim(_Self:_dbfieldget("DBInk87","TYPKL_H")))
 _SELF:txt_bereich(700, _SELF:wYTemp, 850, _SELF:wYTemp+30,_self:_txt_rechts(),AllTrim(Str(_Self:_dbfieldget("DBInk87","PRHPAE"),10,2)))
 _SELF:txt_bereich(850, _SELF:wYTemp, 1050, _SELF:wYTemp+30,_self:_txt_rechts(),AllTrim(Str(_Self:_dbfieldget("DBInk87","PRHPAR"),10,2)))
 _SELF:txt_bereich(1120, _SELF:wYTemp, 1260, _SELF:wYTemp+30,_self:_txt_rechts(),AllTrim(Str(_Self:_dbfieldget("DBInk87","PRHPA"),10,2)))


 // TK
 IF nKaskoID == _self:pdf_nKFZTKID()
  _SELF:wYTemp := _self:wYTemp +40
  _SELF:txt_absolut(20, _SELF:wYTemp,"Teilkasko")
  _SELF:txt_absolut(230, _SELF:wYTemp,AllTrim(_Self:_dbfieldget("DBInk87","TK")))
  _SELF:txt_absolut(350, _SELF:wYTemp,AllTrim(_Self:_dbfieldget("DBInk87","SFKK")))
  _SELF:txt_absolut(450, _SELF:wYTemp,AllTrim(_Self:_dbfieldget("DBInk87","SFK"))+"%")
  _SELF:txt_absolut(610, _SELF:wYTemp,AllTrim(_Self:_dbfieldget("DBInk87","TYPKL")))
  _SELF:txt_bereich(700, _SELF:wYTemp, 850, _SELF:wYTemp+30,_self:_txt_rechts(),AllTrim(Str(_Self:_dbfieldget("DBInk87","PRKPAE"),10,2)))
  _SELF:txt_bereich(850, _SELF:wYTemp, 1050, _SELF:wYTemp+30,_self:_txt_rechts(),AllTrim(Str(_Self:_dbfieldget("DBInk87","PRKPAR"),10,2)))
  _SELF:txt_bereich(1120, _SELF:wYTemp, 1260, _SELF:wYTemp+30,_self:_txt_rechts(),AllTrim(Str(_Self:_dbfieldget("DBInk87","PRKPA"),10,2)))
 // VK
 ELSEIF nKaskoID == _self:pdf_nKFZVKID()
  _SELF:wYTemp := _self:wYTemp +40
  _SELF:txt_absolut(20, _SELF:wYTemp,"Vollkasko")
  _SELF:txt_absolut(230, _SELF:wYTemp,AllTrim(_Self:_dbfieldget("DBInk87","TK")))
  _SELF:txt_absolut(350, _SELF:wYTemp,AllTrim(_Self:_dbfieldget("DBInk87","SFKK")))
  _SELF:txt_absolut(450, _SELF:wYTemp,AllTrim(_Self:_dbfieldget("DBInk87","SFK"))+"%")
  _SELF:txt_absolut(610, _SELF:wYTemp,AllTrim(_Self:_dbfieldget("DBInk87","TYPKL")))
  _SELF:txt_bereich(700, _SELF:wYTemp, 850, _SELF:wYTemp+30,_self:_txt_rechts(),AllTrim(Str(_Self:_dbfieldget("DBInk87","PRKPAE"),10,2)))
  _SELF:txt_bereich(850, _SELF:wYTemp, 1050, _SELF:wYTemp+30,_self:_txt_rechts(),AllTrim(Str(_Self:_dbfieldget("DBInk87","PRKPAR"),10,2)))
  _SELF:txt_bereich(1120, _SELF:wYTemp, 1260, _SELF:wYTemp+30,_self:_txt_rechts(),AllTrim(Str(_Self:_dbfieldget("DBInk87","PRKPA"),10,2)))
 ENDIF
 // IUVP
 IF (nVal := _Self:_dbfieldget("DBInk87","IUVPPA")) != 0
  _SELF:wYTemp := _self:wYTemp +40
  _SELF:txt_absolut(20, _SELF:wYTemp,"Unfall")
  _SELF:txt_bereich(700, _SELF:wYTemp, 850, _SELF:wYTemp+30,_self:_txt_rechts(),AllTrim(Str(_Self:_dbfieldget("DBInk87","IUVPPAE"),10,2)))
  _SELF:txt_bereich(850, _SELF:wYTemp, 1050, _SELF:wYTemp+30,_self:_txt_rechts(),AllTrim(Str(_Self:_dbfieldget("DBInk87","IUVPPAR"),10,2)))
  _SELF:txt_bereich(1120, _SELF:wYTemp, 1260, _SELF:wYTemp+30,_self:_txt_rechts(),AllTrim(Str(nVal,10,2)))
 ENDIF
 // SCHUZUPA
 IF ( nVal := _Self:_dbfieldget("DBInk87","SCHUTZPA")) != 0
  _SELF:wYTemp := _self:wYTemp +40
  _SELF:txt_absolut(20, _SELF:wYTemp,"Schutzbrief")
  _SELF:txt_bereich(700, _SELF:wYTemp, 850, _SELF:wYTemp+30,_self:_txt_rechts(),AllTrim(Str(_Self:_dbfieldget("DBInk87","SCHUTZPAE"),10,2)))
  _SELF:txt_bereich(850, _SELF:wYTemp, 1050, _SELF:wYTemp+30,_self:_txt_rechts(),AllTrim(Str(_Self:_dbfieldget("DBInk87","SCHUTZPAR"),10,2)))
  _SELF:txt_bereich(1120, _SELF:wYTemp, 1260, _SELF:wYTemp+30,_self:_txt_rechts(),AllTrim(Str(nVal,10,2)))
 ENDIF
 // SB's
 IF nKaskoID == _self:pdf_nKFZTKID()
  _SELF:wYTemp := _self:wYTemp +70
  _SELF:txt_absolut(10,_SELF:wYTemp, "Selbstbehalt in Teilkasko")
  _SELF:txt_absolut(500,_SELF:wYTemp,AllTrim(Str(nSBTK))+" "+cWaehrung)
 ELSEIF nKaskoID == _self:pdf_nKFZVKID()
  _SELF:wYTemp := _self:wYTemp +70
  _SELF:txt_absolut(10,_SELF:wYTemp, "Selbstbehalt in Teilkasko:")
  _SELF:txt_absolut(400,_SELF:wYTemp,AllTrim(Str(nSBTK))+" "+cWaehrung)
  _SELF:wYTemp := _self:wYTemp +40
  _SELF:txt_absolut(10,_SELF:wYTemp, "Selbstbehalt in Vollkasko:")
  _SELF:txt_absolut(400,_SELF:wYTemp,AllTrim(Str(nSBVK))+" "+cWaehrung)
 ENDIF
ENDIF	

_SELF:wYTemp := _self:wYTemp +90

IF ( nVal := _Self:_dbfieldget("DBInk87","GEB")) != 0
 _SELF:txt_absolut(10,_SELF:wYTemp,"Gebühr des Versicherers:")
 _SELF:waehle_schrift( "ARIAL", 30, _self:_schrift_roman(), _self:_attr_normal() )
 _SELF:txt_absolut(400,_SELF:wYTemp,AllTrim(Str(nVal))+" "+cWaehrung)
 _SELF:wYTemp := _self:wYTemp +40
ENDIF

_SELF:waehle_schrift( "ARIAL", 30, _self:_schrift_roman(), _self:_attr_normal() )
_SELF:txt_absolut(10,_SELF:wYTemp,"In der Gesamtprämie sind ";
			+AllTrim(Str(_Self:_dbfieldget("DBInk87","ST_SATZ")))+"% gesetzliche Versicherungssteuer mit ";
			+AllTrim(Str(Abs(_Self:_dbfieldget("DBInk87","VSST"))))+" "+cWaehrung+" enthalten")




nVal := _Self:_dbfieldget("DBInk87","BRUTTO") 
// - DEM -------------------------------------------------------------------------
IF nWaehrung == 0
 _SELF:wYTemp := _self:wYTemp +40
 _SELF:waehle_schrift( "ARIAL", 35, _self:_schrift_roman(), _self:_attr_fett() )

 // DEM-Betrag ----------
 IF nVal < 0
  _SELF:txt_absolut(10,_SELF:wYTemp,"Rückbeitrag in DEM")
 ELSE
  _SELF:txt_absolut(10,_SELF:wYTemp,"Beitrag in DEM")
 ENDIF
 _SELF:txt_bereich(1400,_SELF:wYTemp,1620,_SELF:wYTemp+40,_self:_txt_rechts(),AllTrim(Str(nVal)))
 _SELF:txt_gerichtet(_SELF:wYTemp,_self:_txt_rechts(),"DEM")


 _SELF:wYTemp := _self:wYTemp +40
 // EUR-Betrag ----------
 IF nVal < 0
  _SELF:txt_absolut(10,_SELF:wYTemp,"Rückbeitrag")
 ELSE
  _SELF:txt_absolut(10,_SELF:wYTemp,"Beitrag")
 ENDIF
 _SELF:txt_bereich(1400,_SELF:wYTemp,1620,_SELF:wYTemp+40,_self:_txt_rechts(),AllTrim(Str(_self:pdf_nDEM2EUR(nVal))))
 _SELF:txt_gerichtet(_SELF:wYTemp,_self:_txt_rechts(),"EUR")

// - EURO -------------------------------------------------------------------------
ELSE	// EUR
 _SELF:wYTemp := _self:wYTemp +40
 _SELF:waehle_schrift( "ARIAL", 35, _self:_schrift_roman(), _self:_attr_fett() )
	
 IF nVal < 0
  _SELF:txt_absolut(10,_SELF:wYTemp,"Rückbeitrag")
 ELSE
  _SELF:txt_absolut(10,_SELF:wYTemp,"Beitrag")
 ENDIF
 _SELF:txt_bereich(1400,_SELF:wYTemp,1620,_SELF:wYTemp+40,_self:_txt_rechts(),AllTrim(Str(nVal)))
 _SELF:txt_gerichtet(_SELF:wYTemp,_self:_txt_rechts(),"EUR")
ENDIF


// ---------------------------------------------------------------------------------
_SELF:wYTemp := _self:wYTemp +50
_SELF:waehle_stift( _self:_stift_durchgezogen(), 2 )
_SELF:gdi_line(0,_SELF:wYTemp,_SELF:seite_x_ausdehnung(),_SELF:wYTemp)
_SELF:waehle_stift( _self:_stift_durchgezogen(), 1 )

_SELF:wYTemp := _self:wYTemp +30


RETURN	
