MS Sichtbeleg
This commit is contained in:
parent
99f954d406
commit
70765af22b
@ -30,5 +30,5 @@ Imports System.Runtime.InteropServices
|
|||||||
' Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
|
' Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
|
||||||
' übernehmen, indem Sie "*" eingeben:
|
' übernehmen, indem Sie "*" eingeben:
|
||||||
|
|
||||||
<Assembly: AssemblyVersion("2.7.0.0")>
|
<Assembly: AssemblyVersion("2.8.0.0")>
|
||||||
<Assembly: AssemblyFileVersion("2.7.0.0")>
|
<Assembly: AssemblyFileVersion("2.8.0.0")>
|
||||||
|
|||||||
@ -14,6 +14,10 @@ Public Class XRechnungViewDocument
|
|||||||
Private ReadOnly _filesystem As FilesystemEx
|
Private ReadOnly _filesystem As FilesystemEx
|
||||||
Private ReadOnly _file As ZUGFeRD.FileFunctions
|
Private ReadOnly _file As ZUGFeRD.FileFunctions
|
||||||
Private ReadOnly _gdpictureLicenseKey As String
|
Private ReadOnly _gdpictureLicenseKey As String
|
||||||
|
Private fontResName As String
|
||||||
|
Private fontResNameBold As String
|
||||||
|
Private fontResNameItalic As String
|
||||||
|
Private MyGDPicturePDF As GdPicturePDF
|
||||||
|
|
||||||
Public Sub New(LogConfig As LogConfig, MSSQL As MSSQLServer, GDPictureLicenseKey As String)
|
Public Sub New(LogConfig As LogConfig, MSSQL As MSSQLServer, GDPictureLicenseKey As String)
|
||||||
_logConfig = LogConfig
|
_logConfig = LogConfig
|
||||||
@ -45,36 +49,28 @@ Public Class XRechnungViewDocument
|
|||||||
File.Delete(oOutputPath)
|
File.Delete(oOutputPath)
|
||||||
End If
|
End If
|
||||||
|
|
||||||
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
|
MyGDPicturePDF = New GdPicturePDF()
|
||||||
gdpicturePDF.NewPDF(PdfConformance.PDF_A_2a)
|
MyGDPicturePDF.NewPDF(PdfConformance.PDF_A_2a)
|
||||||
Dim ostatus As GdPictureStatus = gdpicturePDF.NewPDF()
|
Dim oPDFStatus As GdPictureStatus = MyGDPicturePDF.NewPDF()
|
||||||
If ostatus <> GdPictureStatus.OK Then
|
If oPDFStatus <> GdPictureStatus.OK Then
|
||||||
_logger.Warn($"Error initializing PDF: {ostatus}")
|
_logger.Warn($"Error initializing PDF: {oPDFStatus}")
|
||||||
Return Nothing
|
Return Nothing
|
||||||
End If
|
End If
|
||||||
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
|
MyGDPicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
|
||||||
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)
|
MyGDPicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)
|
||||||
gdpicturePDF.SetLineWidth(1)
|
MyGDPicturePDF.SetLineWidth(1)
|
||||||
Dim fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
|
fontResName = MyGDPicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
|
||||||
Dim fontResNameBold = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelveticaBold)
|
fontResNameBold = MyGDPicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelveticaBold)
|
||||||
Dim fontResNameItalic = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelveticaBoldOblique)
|
fontResNameItalic = MyGDPicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelveticaBoldOblique)
|
||||||
gdpicturePDF.SetTitle("xInvoice VisualReceipt")
|
MyGDPicturePDF.SetTitle("xInvoice VisualReceipt")
|
||||||
gdpicturePDF.SetAuthor("Digital Data GmbH, Heuchelheim")
|
MyGDPicturePDF.SetAuthor("Digital Data GmbH, Ludwig Rinn Str. 16, 35452 Heuchelheim")
|
||||||
'Create a New page
|
'Create a New page
|
||||||
gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4)
|
MyGDPicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4)
|
||||||
'Draw content on the PDF
|
' Dim oCurrent As Integer = MyGDPicturePDF.GetCurrentPage()
|
||||||
Dim yPosition As Integer = 15
|
|
||||||
gdpicturePDF.SetTextSize(18)
|
Dim yPosition As Integer = Create_PageHeader(False)
|
||||||
gdpicturePDF.DrawText(fontResName, 10, yPosition, "xRechnung Sichtbeleg - xInvoice Visual Receipt")
|
Create_PageFooter()
|
||||||
yPosition += 10
|
|
||||||
gdpicturePDF.SetTextSize(10)
|
|
||||||
gdpicturePDF.DrawText(fontResNameItalic, 10, yPosition, XRechnungStrings.CommentSichtbeleg_DE_Row1)
|
|
||||||
yPosition += 5
|
|
||||||
gdpicturePDF.DrawText(fontResNameItalic, 10, yPosition, XRechnungStrings.CommentSichtbeleg_DE_Row2)
|
|
||||||
yPosition += 5
|
|
||||||
gdpicturePDF.DrawText(fontResNameItalic, 10, yPosition, XRechnungStrings.CommentSichtbeleg_EN_Row1)
|
|
||||||
yPosition += 5
|
|
||||||
gdpicturePDF.DrawText(fontResNameItalic, 10, yPosition, XRechnungStrings.CommentSichtbeleg_EN_Row2)
|
|
||||||
Dim oArea As String = ""
|
Dim oArea As String = ""
|
||||||
Dim oIsPosition As Boolean = False
|
Dim oIsPosition As Boolean = False
|
||||||
Dim oPosCount = 0
|
Dim oPosCount = 0
|
||||||
@ -89,12 +85,35 @@ Public Class XRechnungViewDocument
|
|||||||
Dim oItemValue As String = oRow.Item("ITEM_VALUE")
|
Dim oItemValue As String = oRow.Item("ITEM_VALUE")
|
||||||
Dim oDisplay As Boolean = oRow.Item("Display")
|
Dim oDisplay As Boolean = oRow.Item("Display")
|
||||||
Dim oAreaSwitch As Boolean = False
|
Dim oAreaSwitch As Boolean = False
|
||||||
|
If oRow.Item("Area") = "INTERNAL" Then
|
||||||
|
If oItemSPECNAME = "STATIC_Y_SWITCH" Then
|
||||||
|
yPosition = oItemValue
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
If yPosition >= 270 Then
|
||||||
|
oPDFStatus = MyGDPicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4)
|
||||||
|
If oPDFStatus <> GdPictureStatus.OK Then
|
||||||
|
_logger.Warn($"Could not create a second page. The error was: {oPDFStatus}")
|
||||||
|
Exit For
|
||||||
|
Else
|
||||||
|
yPosition = Create_PageHeader(True)
|
||||||
|
Create_PageFooter()
|
||||||
|
End If
|
||||||
|
'oCurrent = MyGDPicturePDF.GetCurrentPage()
|
||||||
|
End If
|
||||||
|
|
||||||
|
|
||||||
|
If oRow.Item("Area") = "INTERNAL" Then
|
||||||
|
_logger.Debug($"Next Item as Area is internal")
|
||||||
|
Continue For
|
||||||
|
End If
|
||||||
_logger.Debug($"Working on SPEC_NAME: {oItemSPECNAME}")
|
_logger.Debug($"Working on SPEC_NAME: {oItemSPECNAME}")
|
||||||
|
|
||||||
If oArea <> oRow.Item("Area") Then
|
If oArea <> oRow.Item("Area") Then
|
||||||
'########## AREA WECHSEL ###########
|
'########## AREA WECHSEL ###########
|
||||||
oAreaSwitch = True
|
oAreaSwitch = True
|
||||||
oArea = oRow.Item("Area")
|
oArea = oRow.Item("Area")
|
||||||
|
_logger.Debug($"Area-Switch to: {oArea}")
|
||||||
Dim oAREACaption As String
|
Dim oAREACaption As String
|
||||||
If oArea = "TYPE" Then
|
If oArea = "TYPE" Then
|
||||||
oAREACaption = $"{Return_InvType(oItemValue)} [{oItemValue}]"
|
oAREACaption = $"{Return_InvType(oItemValue)} [{oItemValue}]"
|
||||||
@ -119,15 +138,15 @@ Public Class XRechnungViewDocument
|
|||||||
If Not oAREACaption = String.Empty Then
|
If Not oAREACaption = String.Empty Then
|
||||||
'erste Area-Linie
|
'erste Area-Linie
|
||||||
yPosition += 5
|
yPosition += 5
|
||||||
gdpicturePDF.DrawLine(10, yPosition, 125, yPosition)
|
MyGDPicturePDF.DrawLine(10, yPosition, 125, yPosition)
|
||||||
'gdpicturePDF.DrawText(fontResName, 10, yPosition, XRechnungStrings.Seperator_Line)
|
'gdpicturePDF.DrawText(fontResName, 10, yPosition, XRechnungStrings.Seperator_Line)
|
||||||
yPosition += 5
|
yPosition += 5
|
||||||
'Area caption
|
'Area caption
|
||||||
gdpicturePDF.DrawText(fontResNameBold, 10, yPosition, oAREACaption)
|
MyGDPicturePDF.DrawText(fontResNameBold, 10, yPosition, oAREACaption)
|
||||||
|
|
||||||
yPosition += 5
|
yPosition += 5
|
||||||
If oArea = "TYPE" Then
|
If oArea = "TYPE" Then
|
||||||
gdpicturePDF.DrawLine(10, yPosition, 125, yPosition)
|
MyGDPicturePDF.DrawLine(10, yPosition, 125, yPosition)
|
||||||
' gdpicturePDF.DrawText(fontResName, 10, yPosition, XRechnungStrings.Seperator_Line)
|
' gdpicturePDF.DrawText(fontResName, 10, yPosition, XRechnungStrings.Seperator_Line)
|
||||||
yPosition += 5
|
yPosition += 5
|
||||||
End If
|
End If
|
||||||
@ -159,6 +178,7 @@ Public Class XRechnungViewDocument
|
|||||||
End If
|
End If
|
||||||
Else
|
Else
|
||||||
'INDIVIDUELLES VERHALTEN BEI Folge-ITEMS
|
'INDIVIDUELLES VERHALTEN BEI Folge-ITEMS
|
||||||
|
_logger.Debug($"FollowItem: {oItemSPECNAME} - ItemValue: {oItemValue}")
|
||||||
If oArea = "POSITION" Then
|
If oArea = "POSITION" Then
|
||||||
If oItemSPECNAME = "INVOICE_POSITION_AMOUNT" Then
|
If oItemSPECNAME = "INVOICE_POSITION_AMOUNT" Then
|
||||||
oPosCount += 1
|
oPosCount += 1
|
||||||
@ -168,12 +188,12 @@ Public Class XRechnungViewDocument
|
|||||||
oPosTerm += $" {oItemValue}"
|
oPosTerm += $" {oItemValue}"
|
||||||
oDisplay = False
|
oDisplay = False
|
||||||
ElseIf oItemSPECNAME = "INVOICE_TAXPOS_TAX_RATE" Or oItemSPECNAME = "INVOICE_TAXPOS_RATE" Then
|
ElseIf oItemSPECNAME = "INVOICE_TAXPOS_TAX_RATE" Or oItemSPECNAME = "INVOICE_TAXPOS_RATE" Then
|
||||||
oPosTerm += $" - ({oItemValue} %)"
|
oPosTerm += $" - {oItemValue} %"
|
||||||
|
oDisplay = False
|
||||||
|
ElseIf oItemSPECNAME = "INVOICE_POSITION_TAX_AMOUNT" Then
|
||||||
|
oPosTerm += $" - {oItemValue} {oCurrencySymbol}"
|
||||||
End If
|
End If
|
||||||
oItemValue = oPosTerm
|
oItemValue = oPosTerm
|
||||||
If oPosCount >= 9 Then
|
|
||||||
oDisplay = False
|
|
||||||
End If
|
|
||||||
ElseIf oArea = "HEAD" Then
|
ElseIf oArea = "HEAD" Then
|
||||||
If oItemSPECNAME = "INVOICE_DATE" Or oItemSPECNAME = "INVOICE_SERVICE_DATE" Then
|
If oItemSPECNAME = "INVOICE_DATE" Or oItemSPECNAME = "INVOICE_SERVICE_DATE" Then
|
||||||
Dim oDateString As String = oItemValue
|
Dim oDateString As String = oItemValue
|
||||||
@ -194,6 +214,7 @@ Public Class XRechnungViewDocument
|
|||||||
oItemValue = oPosTerm
|
oItemValue = oPosTerm
|
||||||
End If
|
End If
|
||||||
End If
|
End If
|
||||||
|
|
||||||
If oDisplay = True Then
|
If oDisplay = True Then
|
||||||
If Y_eq_lastrow = False And oAreaSwitch = False Then
|
If Y_eq_lastrow = False And oAreaSwitch = False Then
|
||||||
yPosition += 5
|
yPosition += 5
|
||||||
@ -206,16 +227,11 @@ Public Class XRechnungViewDocument
|
|||||||
|
|
||||||
|
|
||||||
If oRowCaption <> String.Empty Then
|
If oRowCaption <> String.Empty Then
|
||||||
gdpicturePDF.DrawText(fontResName, 10, yPosition, oRowCaption)
|
MyGDPicturePDF.DrawText(fontResName, 10, yPosition, oRowCaption)
|
||||||
gdpicturePDF.DrawText(fontResName, 70, yPosition, oItemValue)
|
MyGDPicturePDF.DrawText(fontResName, 70, yPosition, oItemValue)
|
||||||
Else
|
Else
|
||||||
If Y_eq_lastrow = True Then
|
If Y_eq_lastrow = True Then
|
||||||
If oIsPosition = True And oPosCount = 9 Then
|
MyGDPicturePDF.DrawText(fontResName, oRow.Item("xPosition"), yPosition, oItemValue)
|
||||||
gdpicturePDF.DrawText(fontResName, 10, yPosition, "...es gibt noch mehr Positionen, diese werden aber aus Layoutgründen nicht dargestellt.")
|
|
||||||
gdpicturePDF.DrawText(fontResName, 10, yPosition, "...There are more positions, but these are not shown for layout reasons.")
|
|
||||||
Else
|
|
||||||
gdpicturePDF.DrawText(fontResName, oRow.Item("xPosition"), yPosition, oItemValue)
|
|
||||||
End If
|
|
||||||
Else
|
Else
|
||||||
If oItemValue.Length > 112 Then
|
If oItemValue.Length > 112 Then
|
||||||
' Liste zur Speicherung der Teilstrings
|
' Liste zur Speicherung der Teilstrings
|
||||||
@ -230,11 +246,11 @@ Public Class XRechnungViewDocument
|
|||||||
|
|
||||||
' Ausgabe der Teilstrings
|
' Ausgabe der Teilstrings
|
||||||
For Each teilString As String In teilStrings
|
For Each teilString As String In teilStrings
|
||||||
gdpicturePDF.DrawText(fontResName, 10, yPosition, teilString)
|
MyGDPicturePDF.DrawText(fontResName, 10, yPosition, teilString)
|
||||||
yPosition += 5
|
yPosition += 5
|
||||||
Next
|
Next
|
||||||
Else
|
Else
|
||||||
gdpicturePDF.DrawText(fontResName, 10, yPosition, oItemValue)
|
MyGDPicturePDF.DrawText(fontResName, 10, yPosition, oItemValue)
|
||||||
End If
|
End If
|
||||||
|
|
||||||
End If
|
End If
|
||||||
@ -242,24 +258,20 @@ Public Class XRechnungViewDocument
|
|||||||
End If
|
End If
|
||||||
oIndex += 1
|
oIndex += 1
|
||||||
Next
|
Next
|
||||||
Dim oCreated = Now.ToString
|
|
||||||
|
|
||||||
gdpicturePDF.DrawLine(10, 280, 200, 280)
|
|
||||||
Dim oCreatedString = $"Maschinell erstellt durch / Automatically created by Digital Data E-Rechnung Parser: {oCreated}"
|
|
||||||
gdpicturePDF.DrawText(fontResName, 10, 285, oCreatedString)
|
|
||||||
Dim oeinv_Format As PdfInvoiceDataFormat = PdfInvoiceDataFormat.ZUGFeRD_2_0
|
Dim oeinv_Format As PdfInvoiceDataFormat = PdfInvoiceDataFormat.ZUGFeRD_2_0
|
||||||
gdpicturePDF.EmbedFile(oTempFilePath, "Rechnungsdaten im ZUGFeRD-XML-Format")
|
MyGDPicturePDF.EmbedFile(oTempFilePath, "Rechnungsdaten im ZUGFeRD-XML-Format")
|
||||||
'Finalize And save the PDF
|
'Finalize And save the PDF
|
||||||
ostatus = gdpicturePDF.SaveToFile(oOutputPath)
|
oPDFStatus = MyGDPicturePDF.SaveToFile(oOutputPath)
|
||||||
If ostatus = GdPictureStatus.OK Then
|
If oPDFStatus = GdPictureStatus.OK Then
|
||||||
_logger.Info("PDF VisualReceipt generated successfully!")
|
_logger.Info("PDF VisualReceipt generated successfully!")
|
||||||
Else
|
Else
|
||||||
_logger.Warn($"Error generating PDF VisualReceipt: {ostatus}")
|
_logger.Warn($"Error generating PDF VisualReceipt: {oPDFStatus}")
|
||||||
End If
|
End If
|
||||||
|
|
||||||
'Release resources
|
'Release resources
|
||||||
gdpicturePDF.CloseDocument()
|
MyGDPicturePDF.CloseDocument()
|
||||||
If ostatus = GdPictureStatus.OK Then
|
If oPDFStatus = GdPictureStatus.OK Then
|
||||||
File.Delete(oXRechnungFile)
|
File.Delete(oXRechnungFile)
|
||||||
oNewFileinfo = New FileInfo(oOutputPath)
|
oNewFileinfo = New FileInfo(oOutputPath)
|
||||||
Return oNewFileinfo
|
Return oNewFileinfo
|
||||||
@ -272,6 +284,27 @@ Public Class XRechnungViewDocument
|
|||||||
Return Nothing
|
Return Nothing
|
||||||
End Try
|
End Try
|
||||||
End Function
|
End Function
|
||||||
|
Public Function Create_PageHeader(pFollowPage As Boolean) As Integer
|
||||||
|
'Draw content on the PDF
|
||||||
|
Dim yPosition As Integer = 15
|
||||||
|
MyGDPicturePDF.SetTextSize(18)
|
||||||
|
MyGDPicturePDF.DrawText(fontResName, 10, yPosition, "xRechnung Sichtbeleg - xInvoice Visual Receipt")
|
||||||
|
yPosition += 10
|
||||||
|
MyGDPicturePDF.SetTextSize(10)
|
||||||
|
MyGDPicturePDF.DrawText(fontResNameItalic, 10, yPosition, XRechnungStrings.CommentSichtbeleg_DE_Row1)
|
||||||
|
yPosition += 5
|
||||||
|
MyGDPicturePDF.DrawText(fontResNameItalic, 10, yPosition, XRechnungStrings.CommentSichtbeleg_DE_Row2)
|
||||||
|
yPosition += 5
|
||||||
|
MyGDPicturePDF.DrawText(fontResNameItalic, 10, yPosition, XRechnungStrings.CommentSichtbeleg_EN_Row1)
|
||||||
|
yPosition += 5
|
||||||
|
MyGDPicturePDF.DrawText(fontResNameItalic, 10, yPosition, XRechnungStrings.CommentSichtbeleg_EN_Row2)
|
||||||
|
Return yPosition
|
||||||
|
End Function
|
||||||
|
Public Function Create_PageFooter()
|
||||||
|
MyGDPicturePDF.DrawLine(10, 280, 200, 280)
|
||||||
|
Dim oCreatedString = $"Maschinell erstellt durch / Automatically created by Digital Data E-Rechnung Parser: {Now.ToString}"
|
||||||
|
MyGDPicturePDF.DrawText(fontResName, 10, 285, oCreatedString)
|
||||||
|
End Function
|
||||||
Private Function Return_InvType(pType As String) As String
|
Private Function Return_InvType(pType As String) As String
|
||||||
Dim oReturn As String = "Rechnung/invoice"
|
Dim oReturn As String = "Rechnung/invoice"
|
||||||
If pType = "380" Then
|
If pType = "380" Then
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user