Zugferd, etc.

This commit is contained in:
2026-04-28 17:11:48 +02:00
parent 77370be55d
commit 674532460a
5 changed files with 709 additions and 321 deletions

View File

@@ -720,15 +720,15 @@ Public Class cFakturierung
'End Function
Public Shared Function doRechnungsDruck_SRorER(RK_ID As Integer, Optional RechnungsDatum As Object = Nothing, Optional vorschau As Boolean = False, Optional Rechnugnsdruck As Integer = -1, Optional ByRef Path As String = "", Optional ByRef PrinterName As String = "", Optional printStbVdb As Boolean = False, Optional AnlageEinzelRg As Boolean = False, Optional sammelrechnungKopie As Boolean = False, Optional onlyAsfinagAttach As Boolean = False) As Boolean
Public Shared Function doRechnungsDruck_SRorER(RK_ID As Integer, Optional RechnungsDatum As Object = Nothing, Optional vorschau As Boolean = False, Optional Rechnugnsdruck As Integer = -1, Optional ByRef Path As String = "", Optional ByRef PrinterName As String = "", Optional printStbVdb As Boolean = False, Optional AnlageEinzelRg As Boolean = False, Optional sammelrechnungKopie As Boolean = False, Optional onlyAsfinagAttach As Boolean = False, Optional sammelrechnungsbericht As Boolean = True) As Boolean
If RK_ID <= 0 Then Return False
Dim RG_TMP As New VERAG_PROG_ALLGEMEIN.cRechnungsausgang(RK_ID)
If RG_TMP.Sammelrechnung = 0 Then
Return doRechnungsDruck(New VERAG_PROG_ALLGEMEIN.cRechnungsausgang(RK_ID), RechnungsDatum, vorschau, Rechnugnsdruck, Path, PrinterName, , printStbVdb)
ElseIf RG_TMP.Sammelrechnung = 6 Then
Return cFakturierung.doSAMMELRechnungsDruck_Abschnitt(RG_TMP.RechnungsNr, -1, -1, RG_TMP.DruckDatumZeit, "", AnlageEinzelRg, True, Rechnugnsdruck, Path, False,,,,,,,, True, True, sammelrechnungKopie,,, onlyAsfinagAttach, True)
Return cFakturierung.doSAMMELRechnungsDruck_Abschnitt(RG_TMP.RechnungsNr, -1, -1, RG_TMP.DruckDatumZeit, "", AnlageEinzelRg, sammelrechnungsbericht, Rechnugnsdruck, Path, False,,,,,,,, True, True, sammelrechnungKopie,,, onlyAsfinagAttach, True)
Else
Return cFakturierung.doSAMMELRechnungsDruck_Abschnitt(RG_TMP.RechnungsNr, -1, -1, RG_TMP.DruckDatumZeit, "", AnlageEinzelRg, , Rechnugnsdruck, Path, True)
Return cFakturierung.doSAMMELRechnungsDruck_Abschnitt(RG_TMP.RechnungsNr, -1, -1, RG_TMP.DruckDatumZeit, "", AnlageEinzelRg, sammelrechnungsbericht, Rechnugnsdruck, Path, True)
End If
End Function
@@ -4456,9 +4456,12 @@ Public Class cFakturierung
Dim xls_Transferry360 = ""
Dim pathPDF_Anlage As New List(Of String)
Dim zugferd As String = ""
'-------------- ENDE --------------
doSAMMELRechnungsDruck_Abschnitt = doSAMMELRechnungDruck_Rechnungsdruck(dt, RechnungsNr, DruckdatumUhrzeit, 3, RechnungsdruckArt, pathPDF_SammelRg, PrinterName, SRDruckWiederholen, VorschauID) 'Sammelrechnung drucken
Dim rpt As rptSammelRechnungDruck
doSAMMELRechnungsDruck_Abschnitt = doSAMMELRechnungDruck_Rechnungsdruck(dt, RechnungsNr, DruckdatumUhrzeit, 3, RechnungsdruckArt, pathPDF_SammelRg, PrinterName, SRDruckWiederholen, VorschauID,, zugferd) 'Sammelrechnung drucken
If Sammelrechnungsbericht Then If Not doSAMMELRechnungDruck_Rechnungsdruck_Sammelrechnungsbericht(RechnungsNr, DruckdatumUhrzeit, RechnungsdruckArt, pathPDF_SammelBericht, PrinterName, VorschauID, dt, RechnugnskopieMDMSammelrechnung) Then doSAMMELRechnungsDruck_Abschnitt = False 'Sammelrechnungsbericht drucken
If AnlageEinzelRg Then If Not doSAMMELRechnungDruck_Rechnungsdruck_Anlagen(RechnungsNr, DruckdatumUhrzeit, PrinterName, pathPDF_Anlage, RechnungsdruckArt, VorschauID) Then doSAMMELRechnungsDruck_Abschnitt = False 'Anlagen drucken
If RechnungsanhangPDF Then getRechnungsanshang(dt, pathPDF_Anlage, "pdf", onlyAsfinagAnhang)
@@ -4516,6 +4519,28 @@ Public Class cFakturierung
' Process.Start(pathPDF)
End If
'Hier ZUGFERD!!!
If pathPDF_Anlage.Count = 0 AndAlso zugferd <> "" Then ' nur wenn keine sonst. A,hänge!
Dim Paramslist As New cParameterList(VERAG_PROG_ALLGEMEIN.cAllgemein.PROGID)
Dim enableZugpferd = Paramslist.GET_PARAMETER_VALUE_BOOL("ZUGFeRD")
If enableZugpferd Then
'tmpPath = VERAG_PROG_ALLGEMEIN.DATENVERVER_OPTIONS.addAttachementToPDF(tmpPath, createZUGFeRD(False, Nothing, dt, rpt), "ZUGFeRD-invoice.xml")
Dim pdfA = VERAG_PROG_ALLGEMEIN.DATENVERVER_OPTIONS.ConvertToPdfA3(pathPDF)
pathPDF = VERAG_PROG_ALLGEMEIN.DATENVERVER_OPTIONS.addZugferdXML(pdfA, zugferd)
Else
Dim Zugferdpath = zugferd
If Zugferdpath IsNot Nothing AndAlso Zugferdpath <> "" Then
Dim fileInfo_ZP As New FileInfo(Zugferdpath)
Dim ZUGF_DS As New VERAG_PROG_ALLGEMEIN.cDATENSERVER("DOKUMENTE", "ZUGFERD", Now().Year & "_SR", "", "", fileInfo_ZP.Name, -1, False)
ZUGF_DS.uploadDataToDATENSERVER(Zugferdpath, fileInfo_ZP.Name, fileInfo_ZP.Extension,,,, True)
End If
End If
End If
'THEREFORE IMPORT:
'-------------------------------------------------------------------------------
Try
@@ -5347,24 +5372,25 @@ Public Class cFakturierung
pEx.Export(rpt.Document, tmpPath)
'MDM hat eigene Funktion!!
'If isMDMRechnungsdruck AndAlso SammelrechnungsDT IsNot Nothing AndAlso SammelrechnungsDT.Rows.Count > 0 AndAlso Firma.Firma_ID = 19 Then
' Dim Paramslist As New cParameterList(VERAG_PROG_ALLGEMEIN.cAllgemein.PROGID)
' Dim enableZugpferd = Paramslist.GET_PARAMETER_VALUE_BOOL("ZUGFeRD")
' If enableZugpferd Then
' 'tmpPath = VERAG_PROG_ALLGEMEIN.DATENVERVER_OPTIONS.addAttachementToPDF(tmpPath, createZUGFeRD(False, Nothing, SammelrechnungsDT, , rpt), "ZUGFeRD-invoice.xml")
' Dim pdfA = VERAG_PROG_ALLGEMEIN.DATENVERVER_OPTIONS.ConvertToPdfA3(tmpPath)
' tmpPath = VERAG_PROG_ALLGEMEIN.DATENVERVER_OPTIONS.addZugferdXML(pdfA, createZUGFeRD(False, Nothing, SammelrechnungsDT, , rpt))
' Else
' Dim Zugferdpath = createZUGFeRD(False, Nothing, SammelrechnungsDT,, rpt)
' If Zugferdpath IsNot Nothing AndAlso Zugferdpath <> "" Then
' Dim fileInfo_ZP As New FileInfo(Zugferdpath)
' Dim ZUGF_DS As New VERAG_PROG_ALLGEMEIN.cDATENSERVER("DOKUMENTE", "ZUGFERD", Now().Year & "_SR", "", "", fileInfo_ZP.Name, -1, False)
' ZUGF_DS.uploadDataToDATENSERVER(Zugferdpath, fileInfo_ZP.Name, fileInfo_ZP.Extension,,,, True)
' End If
' End If
If isMDMRechnungsdruck AndAlso SammelrechnungsDT IsNot Nothing AndAlso SammelrechnungsDT.Rows.Count > 0 Then
Dim Paramslist As New cParameterList(VERAG_PROG_ALLGEMEIN.cAllgemein.PROGID)
Dim enableZugpferd = Paramslist.GET_PARAMETER_VALUE_BOOL("ZUGFeRD")
If enableZugpferd Then
'tmpPath = VERAG_PROG_ALLGEMEIN.DATENVERVER_OPTIONS.addAttachementToPDF(tmpPath, createZUGFeRD(False, Nothing, SammelrechnungsDT, , rpt), "ZUGFeRD-invoice.xml")
tmpPath = VERAG_PROG_ALLGEMEIN.DATENVERVER_OPTIONS.AddZugferdXml(tmpPath, createZUGFeRD(False, Nothing, SammelrechnungsDT, , rpt))
Else
Dim Zugferdpath = createZUGFeRD(False, Nothing, SammelrechnungsDT,, rpt)
If Zugferdpath IsNot Nothing AndAlso Zugferdpath <> "" Then
Dim fileInfo_ZP As New FileInfo(Zugferdpath)
Dim ZUGF_DS As New VERAG_PROG_ALLGEMEIN.cDATENSERVER("DOKUMENTE", "ZUGFERD", Now().Year & "_SR", "", "", fileInfo_ZP.Name, -1, False)
ZUGF_DS.uploadDataToDATENSERVER(Zugferdpath, fileInfo_ZP.Name, fileInfo_ZP.Extension,,,, True)
End If
End If
End If
'End If
Return rpt
@@ -5733,7 +5759,7 @@ Public Class cFakturierung
Return ""
End Function
Shared Function doSAMMELRechnungDruck_Rechnungsdruck(dt As DataTable, RechnungsNr As Integer, DruckdatumUhrzeit As Date, Rgstatus As Integer, Optional Rechnugnsdruck As Integer = -1, Optional ByRef Path As String = "", Optional PrinterName As String = "", Optional SRDruckWiederholen As Boolean = False, Optional VorschauID As String = "", Optional mergePDF As Boolean = False) As Boolean 'RECHNUNG As VERAG_PROG_ALLGEMEIN.cRechnungsausgang, Optional vorschau As Boolean = False, Optional Rechnugnsdruck As Integer = -1, Optional ByRef Path As String = "") As Boolean
Shared Function doSAMMELRechnungDruck_Rechnungsdruck(dt As DataTable, RechnungsNr As Integer, DruckdatumUhrzeit As Date, Rgstatus As Integer, Optional Rechnugnsdruck As Integer = -1, Optional ByRef Path As String = "", Optional PrinterName As String = "", Optional SRDruckWiederholen As Boolean = False, Optional VorschauID As String = "", Optional mergePDF As Boolean = False, Optional ByRef Zugferd As String = "") As Boolean 'RECHNUNG As VERAG_PROG_ALLGEMEIN.cRechnungsausgang, Optional vorschau As Boolean = False, Optional Rechnugnsdruck As Integer = -1, Optional ByRef Path As String = "") As Boolean
Try
@@ -6026,11 +6052,6 @@ Public Class cFakturierung
' RECHNUNG.SET_DruckdatumUhrzeit()
'End If
If False Then
Else
'ORIGINAL
Dim AD As New VERAG_PROG_ALLGEMEIN.cAdressen(ROW("RechnungsKundenNr"))
Dim RG_Bezeichnung = "Rechnung_" & RechnungsNr & ".pdf"
@@ -6044,24 +6065,8 @@ Public Class cFakturierung
p.NeverEmbedFonts = ""
p.Export(rpt.Document, tmpPath)
If Not isMDMRechnungsdruck Then
If Not isMDMRechnungsdruck Then Zugferd = createZUGFeRD(False, Nothing, dt, rpt)
Dim Paramslist As New cParameterList(VERAG_PROG_ALLGEMEIN.cAllgemein.PROGID)
Dim enableZugpferd = Paramslist.GET_PARAMETER_VALUE_BOOL("ZUGFeRD")
If enableZugpferd Then
'tmpPath = VERAG_PROG_ALLGEMEIN.DATENVERVER_OPTIONS.addAttachementToPDF(tmpPath, createZUGFeRD(False, Nothing, dt, rpt), "ZUGFeRD-invoice.xml")
tmpPath = VERAG_PROG_ALLGEMEIN.DATENVERVER_OPTIONS.AddZugferdXml(tmpPath, createZUGFeRD(False, Nothing, dt, rpt))
Else
Dim Zugferdpath = createZUGFeRD(False, Nothing, dt, rpt)
If Zugferdpath IsNot Nothing AndAlso Zugferdpath <> "" Then
Dim fileInfo_ZP As New FileInfo(Zugferdpath)
Dim ZUGF_DS As New VERAG_PROG_ALLGEMEIN.cDATENSERVER("DOKUMENTE", "ZUGFERD", Now().Year & "_SR", "", "", fileInfo_ZP.Name, -1, False)
ZUGF_DS.uploadDataToDATENSERVER(Zugferdpath, fileInfo_ZP.Name, fileInfo_ZP.Extension,,,, True)
End If
End If
End If
Select Case If(Rechnugnsdruck > 0, Rechnugnsdruck, If(AD.Rechnungsdruck, 0))'If(AD.Rechnungsdruck, 0)
@@ -6148,7 +6153,6 @@ Public Class cFakturierung
End Select
End If

View File

@@ -5618,10 +5618,10 @@ mwst:
End If
If VERAG_PROG_ALLGEMEIN.cAllgemein.TESTSYSTEM Then
Button8.Enabled = Not enableAUTOMAIL
Button9.Enabled = Not enableAUTOMAIL
Button4.Enabled = Not enableAUTOMAIL
Button16.Enabled = Not enableAUTOMAIL
'Button8.Enabled = Not enableAUTOMAIL
'Button9.Enabled = Not enableAUTOMAIL
'Button4.Enabled = Not enableAUTOMAIL
'Button16.Enabled = Not enableAUTOMAIL
End If

View File

@@ -25,11 +25,10 @@ Partial Class frmKundenUebersichtZollRgDetails
Me.components = New System.ComponentModel.Container()
Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(frmKundenUebersichtZollRgDetails))
Me.pnl = New System.Windows.Forms.Panel()
Me.Button2 = New System.Windows.Forms.Button()
Me.btnZugferd = New System.Windows.Forms.Button()
Me.Button1 = New System.Windows.Forms.Button()
Me.Label2 = New System.Windows.Forms.Label()
Me.Button15 = New System.Windows.Forms.Button()
Me.cbxLastschrift = New VERAG_PROG_ALLGEMEIN.MyCheckbox(Me.components)
Me.Label18 = New System.Windows.Forms.Label()
Me.lblWaerung = New System.Windows.Forms.Label()
Me.Label13 = New System.Windows.Forms.Label()
@@ -52,14 +51,22 @@ Partial Class frmKundenUebersichtZollRgDetails
Me.lblSteuerbetrag = New System.Windows.Forms.Label()
Me.lblSteuersatz = New System.Windows.Forms.Label()
Me.lblAbfNr = New System.Windows.Forms.Label()
Me.PictureBox5 = New System.Windows.Forms.PictureBox()
Me.Button2 = New System.Windows.Forms.Button()
Me.cbxLastschrift = New VERAG_PROG_ALLGEMEIN.MyCheckbox(Me.components)
Me.Label1 = New System.Windows.Forms.Label()
Me.pnl.SuspendLayout()
CType(Me.DataGridView, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.PictureBox5, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'pnl
'
Me.pnl.BackColor = System.Drawing.Color.White
Me.pnl.Controls.Add(Me.Label1)
Me.pnl.Controls.Add(Me.Button2)
Me.pnl.Controls.Add(Me.PictureBox5)
Me.pnl.Controls.Add(Me.btnZugferd)
Me.pnl.Controls.Add(Me.Button1)
Me.pnl.Controls.Add(Me.Label2)
Me.pnl.Controls.Add(Me.Button15)
@@ -92,17 +99,18 @@ Partial Class frmKundenUebersichtZollRgDetails
Me.pnl.Size = New System.Drawing.Size(560, 517)
Me.pnl.TabIndex = 0
'
'Button2
'btnZugferd
'
Me.Button2.FlatStyle = System.Windows.Forms.FlatStyle.Flat
Me.Button2.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Button2.Location = New System.Drawing.Point(117, 419)
Me.Button2.Margin = New System.Windows.Forms.Padding(10, 3, 3, 3)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(105, 25)
Me.Button2.TabIndex = 93
Me.Button2.Text = "ZUGFeRD"
Me.Button2.UseVisualStyleBackColor = True
Me.btnZugferd.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom
Me.btnZugferd.FlatStyle = System.Windows.Forms.FlatStyle.Flat
Me.btnZugferd.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.btnZugferd.Location = New System.Drawing.Point(446, 420)
Me.btnZugferd.Margin = New System.Windows.Forms.Padding(10, 3, 3, 3)
Me.btnZugferd.Name = "btnZugferd"
Me.btnZugferd.Size = New System.Drawing.Size(64, 25)
Me.btnZugferd.TabIndex = 93
Me.btnZugferd.Text = "Bericht"
Me.btnZugferd.UseVisualStyleBackColor = True
'
'Button1
'
@@ -142,20 +150,6 @@ Partial Class frmKundenUebersichtZollRgDetails
Me.Button15.TextAlign = System.Drawing.ContentAlignment.MiddleRight
Me.Button15.UseVisualStyleBackColor = True
'
'cbxLastschrift
'
Me.cbxLastschrift._value = ""
Me.cbxLastschrift.AutoSize = True
Me.cbxLastschrift.Checked_value = False
Me.cbxLastschrift.CheckedValue = False
Me.cbxLastschrift.Location = New System.Drawing.Point(12, 423)
Me.cbxLastschrift.Name = "cbxLastschrift"
Me.cbxLastschrift.Size = New System.Drawing.Size(74, 17)
Me.cbxLastschrift.TabIndex = 15
Me.cbxLastschrift.Text = "Lastschrift"
Me.cbxLastschrift.UseVisualStyleBackColor = True
Me.cbxLastschrift.Visible = False
'
'Label18
'
Me.Label18.AutoSize = True
@@ -377,6 +371,54 @@ Partial Class frmKundenUebersichtZollRgDetails
Me.lblAbfNr.Text = "-"
Me.lblAbfNr.TextAlign = System.Drawing.ContentAlignment.TopRight
'
'PictureBox5
'
Me.PictureBox5.BackgroundImage = Global.SDL.My.Resources.Resources.fragezeichen
Me.PictureBox5.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom
Me.PictureBox5.Location = New System.Drawing.Point(516, 421)
Me.PictureBox5.Name = "PictureBox5"
Me.PictureBox5.Size = New System.Drawing.Size(23, 22)
Me.PictureBox5.TabIndex = 134
Me.PictureBox5.TabStop = False
'
'Button2
'
Me.Button2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom
Me.Button2.FlatStyle = System.Windows.Forms.FlatStyle.Flat
Me.Button2.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Button2.Location = New System.Drawing.Point(294, 420)
Me.Button2.Margin = New System.Windows.Forms.Padding(10, 3, 3, 3)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(64, 25)
Me.Button2.TabIndex = 136
Me.Button2.Text = "check"
Me.Button2.UseVisualStyleBackColor = True
Me.Button2.Visible = False
'
'cbxLastschrift
'
Me.cbxLastschrift._value = ""
Me.cbxLastschrift.AutoSize = True
Me.cbxLastschrift.Checked_value = False
Me.cbxLastschrift.CheckedValue = False
Me.cbxLastschrift.Location = New System.Drawing.Point(12, 423)
Me.cbxLastschrift.Name = "cbxLastschrift"
Me.cbxLastschrift.Size = New System.Drawing.Size(74, 17)
Me.cbxLastschrift.TabIndex = 15
Me.cbxLastschrift.Text = "Lastschrift"
Me.cbxLastschrift.UseVisualStyleBackColor = True
Me.cbxLastschrift.Visible = False
'
'Label1
'
Me.Label1.AutoSize = True
Me.Label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label1.Location = New System.Drawing.Point(365, 424)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(76, 13)
Me.Label1.TabIndex = 137
Me.Label1.Text = "eRechnung:"
'
'frmKundenUebersichtZollRgDetails
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
@@ -390,6 +432,7 @@ Partial Class frmKundenUebersichtZollRgDetails
Me.pnl.ResumeLayout(False)
Me.pnl.PerformLayout()
CType(Me.DataGridView, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.PictureBox5, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
End Sub
@@ -420,5 +463,8 @@ Partial Class frmKundenUebersichtZollRgDetails
Friend WithEvents lblAbfNr As System.Windows.Forms.Label
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents Button1 As Button
Friend WithEvents btnZugferd As Button
Friend WithEvents PictureBox5 As PictureBox
Friend WithEvents Button2 As Button
Friend WithEvents Label1 As Label
End Class

View File

@@ -5,11 +5,13 @@ Imports VERAG_PROG_ALLGEMEIN
Public Class frmKundenUebersichtZollRgDetails
Dim RK_ID As Integer = -1
Dim Sammelrechnung As Integer = -1
Dim SQL As New SQL
Dim sammelrechnungskopie As Boolean
Dim filialeTmp As String
Dim abfertigungsNrTmp As String
Dim ZugferdDaId As Integer = -1
Sub New(RK_ID)
' Dieser Aufruf ist für den Designer erforderlich.
@@ -28,7 +30,9 @@ Public Class frmKundenUebersichtZollRgDetails
End Sub
Private Sub frmKundenUebersichtZollRg_Load(sender As Object, e As EventArgs) Handles Me.Load
Dim dt As DataRow = SQL.loadDgvBySql("SELECT *, /*[SteuerpflichtigerGesamtbetrag]*[Steuersatz %]*/ SteuerpflichtigerGesamtbetrag/(1+[Steuersatz %])*[Steuersatz %] as ErgSteuerbetrag , [SteuerpflichtigerGesamtbetrag]+[SteuerfreierGesamtbetrag] as RgBetrag FROM Rechnungsausgang WHERE RK_ID = " & RK_ID & "", "FMZOLL").Rows(0)
Dim dt As DataRow = SQL.loadDgvBySql("SELECT *, /*[SteuerpflichtigerGesamtbetrag]*[Steuersatz %]*/ SteuerpflichtigerGesamtbetrag/(1+[Steuersatz %])*[Steuersatz %] as ErgSteuerbetrag , [SteuerpflichtigerGesamtbetrag]+[SteuerfreierGesamtbetrag] as RgBetrag,cast(isnull(zugferdcheck,0) as Bit) as zugferdcheck, isnull(zugferdcheck_daid, -1) as zugferdcheck_daid FROM Rechnungsausgang WHERE RK_ID = " & RK_ID & "", "FMZOLL").Rows(0)
lblRgNr.Text = dt("RechnungsNr").ToString
lblRgBetrag.Text = CDbl(dt("RgBetrag")).ToString("N2", CultureInfo.CurrentCulture)
@@ -49,7 +53,31 @@ Public Class frmKundenUebersichtZollRgDetails
lblBelegartNr.Text = dt("BelegartenNr").ToString
lblWaerung.Text = dt("Währungscode").ToString
If Not IsDBNull(dt("zugferdcheck")) Then
If dt("zugferdcheck") Then
btnZugferd.BackColor = Color.LightGreen
If IsNumeric(dt("zugferdcheck_daid")) Then ZugferdDaId = dt("zugferdcheck_daid")
Else
If IsNumeric(dt("zugferdcheck_daid")) Then ZugferdDaId = dt("zugferdcheck_daid")
btnZugferd.BackColor = Color.IndianRed
End If
Else
btnZugferd.BackColor = Color.White
End If
Sammelrechnung = CInt(dt("Sammelrechnung").ToString)
If RK_ID > 0 Then initDGV()
If Environment.MachineName = "H6CCWP3" Then
Button2.Visible = True
Else
Button2.Visible = False
End If
End Sub
Sub initDGV()
@@ -109,7 +137,34 @@ Public Class frmKundenUebersichtZollRgDetails
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
cFakturierung.doRechnungsDruck_SRorER(RK_ID,, False, 3,,,,, sammelrechnungskopie)
If RK_ID > 0 Then
Dim RE As New cRechnungsausgang(RK_ID)
If RE.dsId > 0 Then
Dim RE_PDF As New cDATENSERVER(RE.dsId)
Dim tmpPath = RE_PDF.GET_TOP1_PATH
If tmpPath <> "" Then
Process.Start(tmpPath)
End If
Else
Dim SRAnhangen As Boolean = False
If Sammelrechnung <> 0 Then
If vbYes = MsgBox("Soll die Sammelrechnung mit Anlagen angezeigt werden?", vbYesNoCancel) Then SRAnhangen = True
End If
cFakturierung.doRechnungsDruck_SRorER(RK_ID,, False, 3,,,,, sammelrechnungskopie,, SRAnhangen)
End If
End If
End Sub
Public Shared Function ConvertToPdfA3_WithMustang(inputPdf As String) As String
@@ -141,16 +196,43 @@ Public Class frmKundenUebersichtZollRgDetails
End Function
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles btnZugferd.Click
If ZugferdDaId > 0 Then
Dim ZUG As New cDATENSERVER(ZugferdDaId)
Dim tmpPath_Report = ZUG.GET_TOP1_PATH
If tmpPath_Report <> "" Then
Process.Start(tmpPath_Report)
End If
Else
End If
End Sub
Private Sub PictureBox5_Click(sender As Object, e As EventArgs) Handles PictureBox5.Click
Dim webAddress As String = "https://wiki.verag.ag/de/software/aviso/howtos/E-Rechnung"
Process.Start(webAddress)
End Sub
Private Sub Button2_Click_1(sender As Object, e As EventArgs) Handles Button2.Click
Dim Path_temp As String = ""
cFakturierung.doRechnungsDruck_SRorER(RK_ID,, False, 3, Path_temp,,,, sammelrechnungskopie)
If Sammelrechnung = 0 Then
cFakturierung.doRechnungsDruck_SRorER(RK_ID,, False, 3, Path_temp,,,, sammelrechnungskopie,, False)
Else
cFakturierung.doRechnungsDruck_SRorER(RK_ID,, False, 3, Path_temp,,,, sammelrechnungskopie,, False)
End If
If Path_temp <> "" Then
Try
'ConvertToPdfA3_WithMustang(Path_temp)
Dim psi As New ProcessStartInfo()
@@ -173,136 +255,14 @@ Public Class frmKundenUebersichtZollRgDetails
If output <> "" Then
Dim tmpPath_Report = VERAG_PROG_ALLGEMEIN.DATENVERVER_OPTIONS.getTMPPath("MUSTANG-REPORT", ".pdf", , False)
CreateValidationPdf(output, Path_temp, RK_ID, tmpPath_Report)
VERAG_PROG_ALLGEMEIN.DATENVERVER_OPTIONS.CreateValidationPdf(output, Path_temp, RK_ID, tmpPath_Report)
If tmpPath_Report <> "" Then Process.Start(tmpPath_Report)
End If
End Using
Catch ex As Exception
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
End Try
End If
End Sub
Private Function ExtractMustangResult(xmlLog As String, invoiceFile As String, RK_ID As Integer) As String
Dim doc As New Xml.XmlDocument()
doc.LoadXml(xmlLog)
Dim fileInfo As New FileInfo(invoiceFile)
Dim invoice As New cRechnungsausgang(RK_ID)
' --- PDF Status ---
Dim pdfNode = doc.SelectSingleNode("//pdf/summary")
Dim pdfStatus As String = If(pdfNode?.Attributes("status")?.Value = "valid", "VALID", "INVALID")
' --- XML Status ---
Dim xmlNode = doc.SelectSingleNode("//xml/summary")
Dim xmlStatus As String = If(xmlNode?.Attributes("status")?.Value = "valid", "VALID", "INVALID")
' --- Profile ---
Dim profileNode = doc.SelectSingleNode("//xml/info/profile")
Dim profile As String = If(profileNode IsNot Nothing, profileNode.InnerText, "UNKNOWN")
' --- XML Version ---
Dim xmlVersionNode = doc.SelectSingleNode("//xml/info/version")
Dim xmlVersion As String = If(xmlVersionNode IsNot Nothing, xmlVersionNode.InnerText, "-")
' --- Validator Version ---
Dim validatorNode = doc.SelectSingleNode("//xml/info/validator")
Dim validatorVersion As String = validatorNode?.Attributes("version")?.Value
' --- Duration ---
Dim pdfDuration = doc.SelectSingleNode("//pdf/info/duration")?.InnerText
Dim xmlDuration = doc.SelectSingleNode("//xml/info/duration")?.InnerText
Dim duration As String = ""
If pdfDuration IsNot Nothing AndAlso xmlDuration IsNot Nothing Then
duration = $"{pdfDuration} ms (PDF) / {xmlDuration} ms (XML)"
End If
' --- Tests ---
Dim firedNode = doc.SelectSingleNode("//xml/info/rules/fired")
Dim failedNode = doc.SelectSingleNode("//xml/info/rules/failed")
Dim fired As Integer = If(firedNode IsNot Nothing, Integer.Parse(firedNode.InnerText), 0)
Dim failed As Integer = If(failedNode IsNot Nothing, Integer.Parse(failedNode.InnerText), 0)
Dim passed As Integer = fired - failed
' --- PDF Errors ---
Dim failedAssertions = doc.SelectNodes("//pdf//TestAssertion[@status='failed']")
Dim errorCount As Integer = If(failedAssertions IsNot Nothing, failedAssertions.Count, 0)
' --- Top Errors ---
Dim errorDetails As New List(Of String)
If failedAssertions IsNot Nothing Then
For i = 0 To Math.Min(2, failedAssertions.Count - 1)
Dim msg = failedAssertions(i).Attributes("message")?.Value
If msg IsNot Nothing Then errorDetails.Add("- " & msg)
Next
End If
' --- Output ---
Dim result As New Text.StringBuilder()
result.AppendLine("ZUGFeRD VALIDATION RESULT")
result.AppendLine("================================")
result.AppendLine($"PDF File : {fileInfo.Name}")
result.AppendLine($"Invoice No : {invoice.RechnungsNr}")
result.AppendLine("--------------------------------")
result.AppendLine($"PDF Status : {pdfStatus}")
result.AppendLine($"XML Status : {xmlStatus}")
result.AppendLine($"Profile : {profile}")
result.AppendLine($"XML Version : {xmlVersion}")
result.AppendLine($"Validator : {validatorVersion}")
result.AppendLine("--------------------------------")
result.AppendLine($"Tests Passed : {passed} / {fired}")
result.AppendLine($"XML Failed : {failed}")
result.AppendLine($"PDF Errors : {errorCount}")
result.AppendLine($"Duration : {duration}")
If errorDetails.Count > 0 Then
result.AppendLine("--------------------------------")
result.AppendLine("Top Errors:")
For Each err_ In errorDetails
result.AppendLine(err_)
Next
End If
result.AppendLine("================================")
Return result.ToString()
End Function
Public Sub CreateValidationPdf(log As String, Invoice_file As String, RK_ID As Integer, outputPath As String)
Dim resultText = ExtractMustangResult(log, Invoice_file, RK_ID)
Using fs As New FileStream(outputPath, FileMode.Create)
Using doc As New itextsharp.text.Document()
Dim writer = itextsharp.text.pdf.PdfWriter.GetInstance(doc, fs)
doc.Open()
Dim titleFont = itextsharp.text.FontFactory.GetFont("Arial", 14, itextsharp.text.Font.BOLD)
Dim bodyFont = itextsharp.text.FontFactory.GetFont("Arial", 10)
doc.Add(New itextsharp.text.Paragraph("ZUGFeRD VALIDATION REPORT", titleFont))
doc.Add(New itextsharp.text.Paragraph(" "))
Dim lines = resultText.Split(vbCrLf)
For Each line In lines
doc.Add(New itextsharp.text.Paragraph(line, bodyFont))
Next
doc.Close()
End Using
End Using
End Sub
End Class

View File

@@ -6,6 +6,7 @@ Imports System.Net
Imports System.Text
Imports System.Text.RegularExpressions
Imports System.Windows.Forms
Imports System.Xml
Imports DocumentFormat.OpenXml
Imports iText.Kernel.Pdf
Imports iText.Kernel.Pdf.Filespec
@@ -13,11 +14,13 @@ Imports iText.Kernel.XMP
Imports iText.Kernel.XMP.Options
Imports iText.Pdfa
Imports iText.Pdfa.Exceptions
Imports iTextSharp.text
Imports iTextSharp.text.pdf
Imports Spire.Pdf
Imports Spire.Pdf.Attachments
Imports Spire.Pdf.Graphics
Imports Spire.Pdf.Print
Imports Font = iTextSharp.text.Font
Imports PdfName = iTextSharp.text.pdf.PdfName
@@ -851,13 +854,13 @@ Public Class cFormularManager
Public Function fillPDF(vorlagenname As String, list As List(Of VERAG_PROG_ALLGEMEIN.MyListItem), listToWrite As List(Of cPDFWriteValues), Optional editierbar As Boolean = True, Optional autoDruck As Boolean = False, Optional printerName As String = "", Optional barcode As Image = Nothing, Optional barcodeLKW As Image = Nothing, Optional uo2 As String = "", Optional openfile As Boolean = True) As String
Public Function fillPDF(vorlagenname As String, list As List(Of VERAG_PROG_ALLGEMEIN.MyListItem), listToWrite As List(Of cPDFWriteValues), Optional editierbar As Boolean = True, Optional autoDruck As Boolean = False, Optional printerName As String = "", Optional barcode As System.Drawing.Image = Nothing, Optional barcodeLKW As System.Drawing.Image = Nothing, Optional uo2 As String = "", Optional openfile As Boolean = True) As String
Return fillPDF_Editierbar("DOKUMENTE", "VORLAGEN", "", uo2, "", vorlagenname, list, listToWrite, editierbar, autoDruck, printerName, barcode, barcodeLKW)
End Function
Public Function fillPDF_Editierbar(da_kategorie As String, da_ordner As String, da_uOrdner1 As String, da_uOrdner2 As String, da_uOrdner3 As String, da_name As String, list As List(Of VERAG_PROG_ALLGEMEIN.MyListItem), listToWrite As List(Of cPDFWriteValues), Optional editierbar As Boolean = True, Optional autoDruck As Boolean = False, Optional printerName As String = "", Optional barcode As Image = Nothing, Optional barcodeLKW As Image = Nothing, Optional openfile As Boolean = True) As String
Public Function fillPDF_Editierbar(da_kategorie As String, da_ordner As String, da_uOrdner1 As String, da_uOrdner2 As String, da_uOrdner3 As String, da_name As String, list As List(Of VERAG_PROG_ALLGEMEIN.MyListItem), listToWrite As List(Of cPDFWriteValues), Optional editierbar As Boolean = True, Optional autoDruck As Boolean = False, Optional printerName As String = "", Optional barcode As System.Drawing.Image = Nothing, Optional barcodeLKW As System.Drawing.Image = Nothing, Optional openfile As Boolean = True) As String
Try
Dim DS As New cDATENSERVER(da_kategorie, da_ordner, da_uOrdner1, da_uOrdner2, da_uOrdner3, da_name)
If Not DS.hasITEMS Then Return ""
@@ -1455,7 +1458,7 @@ Public Class cFormularManager
Dim printer As PrintDocument = New PrintDocument
AddHandler printer.PrintPage, Sub(snd As Object, ev As PrintPageEventArgs)
Dim img As Image = Image.FromFile(pdfPath)
Dim img As System.Drawing.Image = System.Drawing.Image.FromFile(pdfPath)
ev.Graphics.DrawImage(img, ev.PageBounds)
End Sub
' printer.PrinterSettings.DefaultPageSettings.PrintableArea.
@@ -1815,7 +1818,7 @@ Public Class cFormularManager
Dim rasterizer = New Ghostscript.NET.Rasterizer.GhostscriptRasterizer
rasterizer.Open(fileName)
'//Image page = rasterizer.GetPage(96,96); <-- this one prints ok
Dim page As Image = rasterizer.GetPage(600, 600, 1)
Dim page As System.Drawing.Image = rasterizer.GetPage(600, 600, 1)
' doc.DocumentName = fileName
Dim doc As New PrintDocument
@@ -2526,21 +2529,20 @@ Public Class DATENVERVER_OPTIONS
Private Shared Sub SetZugferdXmp_NEW(pdf As iText.Kernel.Pdf.PdfDocument, xmlFileName As String)
Dim xmp As XMPMeta = XMPMetaFactory.Create()
Dim xmp = iText.Kernel.XMP.XMPMetaFactory.Create()
' =========================
' PDF/A
' PDF/A Pflichtfelder
' =========================
Dim pdfaNs As String = "http://www.aiim.org/pdfa/ns/id/"
xmp.SetProperty(pdfaNs, "part", "3")
xmp.SetProperty(pdfaNs, "conformance", "B")
xmp.SetProperty("http://www.aiim.org/pdfa/ns/id/", "part", "3")
xmp.SetProperty("http://www.aiim.org/pdfa/ns/id/", "conformance", "B")
' =========================
' Factur-X Namespace
' =========================
Dim fxNs As String = "urn:factur-x:pdfa:CrossIndustryDocument:invoice:1p0#"
XMPMetaFactory.GetSchemaRegistry().RegisterNamespace(fxNs, "fx")
iText.Kernel.XMP.XMPMetaFactory.GetSchemaRegistry().RegisterNamespace(fxNs, "fx")
xmp.SetProperty(fxNs, "DocumentType", "INVOICE")
xmp.SetProperty(fxNs, "DocumentFileName", xmlFileName)
@@ -2548,12 +2550,76 @@ Public Class DATENVERVER_OPTIONS
xmp.SetProperty(fxNs, "ConformanceLevel", "EN 16931")
' =========================
' WICHTIG: KEIN XML-MANIPULATION
' PDF/A Extension Schema
' =========================
Dim pdfaExt = "http://www.aiim.org/pdfa/ns/extension/"
Dim pdfaSchema = "http://www.aiim.org/pdfa/ns/schema#"
Dim pdfaProp = "http://www.aiim.org/pdfa/ns/property#"
' schemas Array (rdf:Bag ist hier OK für schemas selbst)
xmp.SetProperty(pdfaExt, "schemas", Nothing,
New iText.Kernel.XMP.Options.PropertyOptions(iText.Kernel.XMP.Options.PropertyOptions.ARRAY))
' Schema-Struct hinzufügen
xmp.AppendArrayItem(
pdfaExt,
"schemas",
New iText.Kernel.XMP.Options.PropertyOptions(iText.Kernel.XMP.Options.PropertyOptions.ARRAY),
Nothing,
New iText.Kernel.XMP.Options.PropertyOptions(iText.Kernel.XMP.Options.PropertyOptions.STRUCT)
)
' Schema Beschreibung
xmp.SetStructField(pdfaExt, "schemas[1]", pdfaSchema, "schema", "Factur-X PDFA Extension Schema")
xmp.SetStructField(pdfaExt, "schemas[1]", pdfaSchema, "namespaceURI", fxNs)
xmp.SetStructField(pdfaExt, "schemas[1]", pdfaSchema, "prefix", "fx")
' 🔥 property MUSS rdf:Seq sein!
xmp.SetStructField(
pdfaExt,
"schemas[1]",
pdfaSchema,
"property",
Nothing,
New iText.Kernel.XMP.Options.PropertyOptions(
iText.Kernel.XMP.Options.PropertyOptions.ARRAY Or
iText.Kernel.XMP.Options.PropertyOptions.ARRAY_ORDERED)
)
Dim props = {"DocumentType", "DocumentFileName", "Version", "ConformanceLevel"}
For i = 0 To props.Length - 1
Dim arrayPath = "schemas[1]/pdfaSchema:property"
' 🔥 Item in rdf:Seq hinzufügen
xmp.AppendArrayItem(
pdfaExt,
arrayPath,
New iText.Kernel.XMP.Options.PropertyOptions(
iText.Kernel.XMP.Options.PropertyOptions.ARRAY Or
iText.Kernel.XMP.Options.PropertyOptions.ARRAY_ORDERED),
Nothing,
New iText.Kernel.XMP.Options.PropertyOptions(iText.Kernel.XMP.Options.PropertyOptions.STRUCT)
)
Dim idx = i + 1
Dim basePath = $"schemas[1]/pdfaSchema:property[{idx}]"
xmp.SetStructField(pdfaExt, basePath, pdfaProp, "name", props(i))
xmp.SetStructField(pdfaExt, basePath, pdfaProp, "valueType", "Text")
xmp.SetStructField(pdfaExt, basePath, pdfaProp, "category", "external")
xmp.SetStructField(pdfaExt, basePath, pdfaProp, "description", props(i))
Next
' =========================
' XMP ins PDF schreiben
' =========================
pdf.SetXmpMetadata(xmp)
End Sub
Public Shared Function addAttachementToPDF(File As String, attPath As String, Optional renameFile As String = "") As String
Try
@@ -2603,11 +2669,323 @@ Public Class DATENVERVER_OPTIONS
End Function
Shared Function ExtractMustangResult(xmlLog As String, invoiceFile As String, RK_ID As Integer) As MustangResult
Dim doc As New XmlDocument()
doc.LoadXml(xmlLog)
' =========================
' PDF STATUS
' =========================
Dim pdfNode = doc.SelectSingleNode("//pdf/summary")
Dim pdfStatus As String =
If(pdfNode?.Attributes("status")?.Value = "valid", "VALID", "INVALID")
' =========================
' XML STATUS
' =========================
Dim xmlNode = doc.SelectSingleNode("//xml/summary")
Dim xmlStatus As String =
If(xmlNode?.Attributes("status")?.Value = "valid", "VALID", "INVALID")
' =========================
' PROFILE
' =========================
Dim profileNode = doc.SelectSingleNode("//xml/info/profile")
Dim profile As String =
If(profileNode IsNot Nothing, profileNode.InnerText, "UNKNOWN")
' =========================
' VERSION
' =========================
Dim xmlVersionNode = doc.SelectSingleNode("//xml/info/version")
Dim xmlVersion As String =
If(xmlVersionNode IsNot Nothing, xmlVersionNode.InnerText, "-")
Dim validatorNode = doc.SelectSingleNode("//xml/info/validator")
Dim validatorVersion As String =
validatorNode?.Attributes("version")?.Value
' =========================
' DURATION (SAFE)
' =========================
Dim pdfDuration = doc.SelectSingleNode("//pdf/info/duration")?.InnerText
Dim xmlDuration = doc.SelectSingleNode("//xml/info/duration")?.InnerText
Dim duration As String =
$"{If(pdfDuration, "-")} ms (PDF)" & " / " &
$"{If(xmlDuration, "-")} ms (XML)"
' =========================
' RULES
' =========================
Dim firedNode = doc.SelectSingleNode("//xml/info/rules/fired")
Dim failedNode = doc.SelectSingleNode("//xml/info/rules/failed")
Dim fired As Integer = If(firedNode IsNot Nothing, Integer.Parse(firedNode.InnerText), 0)
Dim failed As Integer = If(failedNode IsNot Nothing, Integer.Parse(failedNode.InnerText), 0)
Dim passed As Integer = fired - failed
' =========================
' RESULT DTO
' =========================
Return New MustangResult With {
.PdfValid = (pdfStatus = "VALID"),
.XmlValid = (xmlStatus = "VALID"),
.PdfStatus = pdfStatus,
.XmlStatus = xmlStatus,
.Profile = profile,
.Fired = fired,
.Failed = failed,
.Passed = passed,
.ValidatorVersion = validatorVersion,
.XMLVersion = xmlVersion,
.Duration = duration
}
End Function
Shared Function CreateValidationPdf(log As String, Invoice_file As String, RK_ID As Integer, outputPath As String) As Boolean
Dim result = ExtractMustangResult(log, Invoice_file, RK_ID)
Dim docXml As New XmlDocument()
docXml.LoadXml(log)
Using fs As New FileStream(outputPath, FileMode.Create)
Using doc As New iTextSharp.text.Document(iTextSharp.text.PageSize.A4, 36, 36, 36, 36)
Dim writer = pdf.PdfWriter.GetInstance(doc, fs)
doc.Open()
' =========================
' FONTS
' =========================
Dim titleFont = setFont(18.0F, Font.BOLD)
Dim normal = setFont(9.0F, iTextSharp.text.Font.NORMAL)
Dim errorFont = setFont(11.0F, Font.BOLD, BaseColor.RED)
' =========================
' HEADER
' =========================
Dim title As New iTextSharp.text.Paragraph("MUSTANG VALIDATION DASHBOARD", titleFont)
title.Alignment = Element.ALIGN_CENTER
title.SpacingAfter = 15
doc.Add(title)
doc.Add(New iTextSharp.text.Paragraph(" ", normal))
' =========================
' KPI 1
' =========================
Dim kpiTable As New PdfPTable(3)
kpiTable.WidthPercentage = 100
kpiTable.SetWidths(New Single() {33, 33, 34})
kpiTable.AddCell(CreateKpiCell("PDF STATUS", result.PdfStatus, If(result.PdfValid, BaseColor.GREEN, BaseColor.RED)))
kpiTable.AddCell(CreateKpiCell("XML STATUS", result.XmlStatus, If(result.XmlValid, BaseColor.GREEN, BaseColor.RED)))
kpiTable.AddCell(CreateKpiCell("PROFILE", result.Profile, BaseColor.DARK_GRAY))
doc.Add(kpiTable)
' =========================
' KPI 2
' =========================
Dim kpi2 As New PdfPTable(3)
kpi2.WidthPercentage = 100
kpi2.SpacingAfter = 15
kpi2.SetWidths(New Single() {33, 33, 34})
kpi2.AddCell(CreateKpiCell("TESTS PASSED", result.Passed.ToString(), BaseColor.DARK_GRAY))
kpi2.AddCell(CreateKpiCell("FAILED", result.Failed.ToString(), If(result.Failed > 0, BaseColor.RED, BaseColor.GREEN)))
kpi2.AddCell(CreateKpiCell("TOTAL", result.Fired.ToString(), BaseColor.DARK_GRAY))
doc.Add(kpi2)
' =========================
' KPI 3
' =========================
'Dim kpi3 As New PdfPTable(3)
'kpi3.WidthPercentage = 100
'kpi3.SetWidths(New Single() {33, 33, 34})
'kpi3.AddCell(CreateKpiCell("VALIDATOR", result.ValidatorVersion, BaseColor.DARK_GRAY))
'kpi3.AddCell(CreateKpiCell("XML VERSION", result.XMLVersion, BaseColor.DARK_GRAY))
'kpi3.AddCell(CreateKpiCell("DURATION", result.Duration, BaseColor.DARK_GRAY))
'doc.Add(kpi3)
' =========================
' DETAILS
' =========================
Dim detailHeader As New iTextSharp.text.Paragraph("DETAILS", normal)
detailHeader.SpacingAfter = 8
doc.Add(New iTextSharp.text.Paragraph(ToFlatText(result, Invoice_file, RK_ID), normal))
' =========================
' ERROR SECTION
' =========================
Dim failedAssertions = docXml.SelectNodes("//pdf//TestAssertion[@status='failed']")
Dim MessagesXML = docXml.SelectNodes("//xml/messages/*")
Dim MessagesPDF = docXml.SelectNodes("//pdf/messages/*")
Dim errorHeader As New iTextSharp.text.Paragraph("VALIDATION DETAILS", normal)
errorHeader.SpacingAfter = 8
doc.Add(errorHeader)
Dim errorTable As New PdfPTable(1)
errorTable.WidthPercentage = 100
Dim hasErrors As Boolean = (failedAssertions IsNot Nothing AndAlso failedAssertions.Count > 0) OrElse (MessagesXML IsNot Nothing AndAlso MessagesXML.Count > 0) OrElse (MessagesPDF IsNot Nothing AndAlso MessagesPDF.Count > 0)
If hasErrors Then
If failedAssertions IsNot Nothing Then
For i = 0 To failedAssertions.Count - 1
Dim msg = failedAssertions(i).Attributes("message")?.Value
Dim rule = failedAssertions(i).Attributes("ruleId")?.Value
Dim text = If(rule IsNot Nothing, "[" & rule & "] ", "") &
If(msg IsNot Nothing, msg, "Unknown error")
Dim cell As New PdfPCell(New Phrase(text, normal))
cell.BackgroundColor = New BaseColor(245, 245, 245)
cell.Padding = 8
errorTable.AddCell(cell)
Next
End If
' XML Messages
If MessagesXML IsNot Nothing Then
For i = 0 To MessagesXML.Count - 1
Dim text = MessagesXML(i).InnerText
errorTable.AddCell(New PdfPCell(New Phrase(text, normal)) With {
.BackgroundColor = New BaseColor(245, 245, 245),
.Padding = 8
})
Next
End If
' PDF Messages
If MessagesPDF IsNot Nothing Then
For i = 0 To MessagesPDF.Count - 1
Dim text = MessagesPDF(i).InnerText
errorTable.AddCell(New PdfPCell(New Phrase(text, normal)) With {
.BackgroundColor = New BaseColor(245, 245, 245),
.Padding = 8
})
Next
End If
doc.Add(errorTable)
Else
Dim ok As New iTextSharp.text.Paragraph("No validation errors found.", normal)
ok.Font.Color = BaseColor.GREEN
doc.Add(ok)
End If
' =========================
' FOOTER
' =========================
doc.Add(New iTextSharp.text.Paragraph(" "))
Dim footer As New iTextSharp.text.Paragraph("Generated by Mustang Validator", normal)
footer.Alignment = Element.ALIGN_RIGHT
footer.Font.Color = BaseColor.BLACK
doc.Add(footer)
doc.Close()
Return result.PdfValid AndAlso result.XmlValid
End Using
End Using
End Function
Public Shared Function ToFlatText(r As MustangResult, fileName As String, RK_ID As String) As String
Dim sb As New StringBuilder()
Dim fileInfo As New FileInfo(fileName)
Dim invoice As New cRechnungsausgang(RK_ID)
sb.AppendLine("RESULT")
sb.AppendLine("================================")
sb.AppendLine($"PDF File : {fileInfo.Name}")
sb.AppendLine($"Invoice No : {invoice.RechnungsNr}")
sb.AppendLine($"Invoice Date : {CDate(invoice.RechnungsDatum).ToShortDateString}")
sb.AppendLine("--------------------------------")
sb.AppendLine($"XML Version : {r.XMLVersion}")
sb.AppendLine($"Validator : {r.ValidatorVersion}")
sb.AppendLine("--------------------------------")
sb.AppendLine($"Tests Passed : {r.Passed} / {r.Fired}")
sb.AppendLine($"XML Errors : {r.Failed}")
sb.AppendLine($"PDF Errors : {If(r.PdfValid AndAlso r.XmlValid, 0, 1)}")
sb.AppendLine($"Duration : {r.Duration}")
sb.AppendLine($"Created : {Now()}")
sb.AppendLine("================================")
Return sb.ToString()
End Function
Private Shared Function CreateKpiCell(title As String, value As String, color As iTextSharp.text.BaseColor) As iTextSharp.text.pdf.PdfPCell
Dim titleFont = iTextSharp.text.FontFactory.GetFont("Helvetica", 9, iTextSharp.text.Font.BOLD)
Dim valueFont As iTextSharp.text.Font = iTextSharp.text.FontFactory.GetFont(iTextSharp.text.FontFactory.HELVETICA, 11.0F, iTextSharp.text.Font.BOLD, color)
Dim p As New iTextSharp.text.Paragraph()
p.Add(New iTextSharp.text.Phrase(title & vbCrLf, titleFont))
p.Add(New iTextSharp.text.Phrase(value, valueFont))
Dim cell As New iTextSharp.text.pdf.PdfPCell(p)
cell.Padding = 10
cell.HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER
cell.VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE
Return cell
End Function
Private Shared Function setFont(size As Single, style As Integer, Optional color As BaseColor = Nothing) As Font
If color Is Nothing Then
Return FontFactory.GetFont(FontFactory.HELVETICA, size, style)
End If
Return FontFactory.GetFont(FontFactory.HELVETICA, size, style, color)
End Function
End Class
Public Class MustangResult
Public Property PdfValid As Boolean
Public Property XmlValid As Boolean
Public Property PdfStatus As String
Public Property XmlStatus As String
Public Property Profile As String
Public Property Fired As Integer
Public Property Failed As Integer
Public Property Passed As Integer
Public Property ValidatorVersion As String
Public Property XMLVersion As String
Public Property Duration As String
End Class
Public Class barcodeToPdf
Public image As Image = Nothing
Public image As System.Drawing.Image = Nothing
Public x As Integer
Public y As Integer
Public width As Integer
@@ -2615,7 +2993,7 @@ Public Class barcodeToPdf
Public onpage = 1
Public rotate As System.Drawing.RotateFlipType = RotateFlipType.RotateNoneFlipNone
Sub New(image As Image, x As Integer, y As Integer, width As Integer, height As Integer, onpage As Integer, rotate As System.Drawing.RotateFlipType)
Sub New(image As System.Drawing.Image, x As Integer, y As Integer, width As Integer, height As Integer, onpage As Integer, rotate As System.Drawing.RotateFlipType)
Me.image = image
Me.x = x
Me.y = y