Mit dem Aloaha ZUGFeRD SDK ist es ganz einfach, ein ZUGFeRD-PDF bzw. eine X-Rechnungs-XML einzulesen. Zuerst müssen Sie natürlich das Aloaha-Objekt erstellen:
In VB.NET
Dim alo As New Aloaha_ZUGFeRD.XML
In VB6 (Early Binding)
Dim alo As Aloaha_ZUGFeRD.XML
Set alo = CreateObject("Aloaha_ZUGFeRD.XML")
In VBA/VB6 (Late Binding)
Dim alo As Object
Set alo = CreateObject("Aloaha_ZUGFeRD.XML")
Als nächstes müssen Sie die Rechnung einlesen. Sie können direkt Ihr PDF oder die XML-Datei einlesen.
In VB.NET
Dim inputfile as string="c:\rechnungen\rechnung1.xml" 'pdf geht auch
Dim LicenseKey as string="xxxxxxxxxxx" 'contact info@aloaha.com for an eval key
If alo.Licensed(LicenseKey) = True Then
alo = Nothing
alo = New Aloaha_ZUGFeRD.XML
alo.FillZUGFeRD_Structure(inputfile )
Dim Posten() As iXML.TradeItem = alo.Trade_Items
If Posten.Length > 0 Then
'usw
End If
End If
Sie können auch die gesamte interne ZUGFeRD-Struktur auslesen. Das geht jedoch nur in .NET und nicht in VB6 (COM): Laden einer existierenden ZUGFeRD Rechnung in das Toolkit
In VB6 (Early Binding)
Der Code sieht in VB6 etwas anders aus, da Trade_Items in COM nicht verfügbar ist.
Dim inputfile As String
Dim LicenseKey As String
Dim IBAN As String
Dim BIC As String
Dim BankName As String
Dim AnzahlKonten As Integer
Dim KaeuferVAT As String
Dim VerkaeuferVAT As String
Dim KaeuferBestellnummer As String
Dim VerkaeuferBestellnummer As String
inputfile = "o:\temp\test1.xml" 'pdf possible as well
LicenseKey = "xxxxx" 'contact info@aloaha.com for eval key
Dim alo As Aloaha_ZUGFeRD.XML
Set alo = CreateObject("Aloaha_ZUGFeRD.XML")
If alo.Licensed(LicenseKey) = True Then
alo.FillZUGFeRD_Structure (inputfile)
KaeuferVAT = alo.VATNumber(True)
VerkaeuferVAT = alo.VATNumber(False)
KaeuferBestellnummer = alo.OrderNumber(True)
VerkaeuferBestellnummer = alo.OrderNumber(False)
Dim Lieferdatum As String
'aus Struktur
Lieferdatum = alo.SupplyChain_Structure.ActualDeliveryDate.Document_Date
'oder als Funktion
Lieferdatum = alo.ActualDeliveryDate_102
'Summen auslesen
Dim DuePayableAmount As String
Dim AllowanceTotalAmount As String
Dim ChargeTotalAmount As String
Dim GrandTotalAmount As String
Dim LineTotalAmount As String
Dim TaxBasisTotalAmount As String
Dim TaxTotalAmount As String
Dim TotalPrepaidAmount As String
Dim RoundingAmount As String
DuePayableAmount = alo.GetMonetarySummation(SummationType_DuePayableAmount)
AllowanceTotalAmount = alo.GetMonetarySummation(SummationType_AllowanceTotalAmount)
'usw
'get aber besser mit einem Call
Call alo.getTotals(LineTotalAmount, GrandTotalAmount, DuePayableAmount, TaxBasisTotalAmount, TaxTotalAmount, AllowanceTotalAmount, TotalPrepaidAmount, RoundingAmount, ChargeTotalAmount)
Dim TradeAllowanceCharges As Integer
TradeAllowanceCharges = alo.TradeAllowanceCharges
If TradeAllowanceCharges > 0 Then
For i = 0 To TradeAllowanceCharges - 1
Dim ChargeIndicator As Boolean
Dim CalculationPercent As String
Dim ChargeBasisAmount As String
Dim BasisQuantity As String
Dim BasisQuantityUnitCode As String
Dim ActualAmount As String
Dim Reason As String
Dim ReasonCode As String
Dim CurrencyID As String
Dim SequenceNumeric As String
Dim Taxes As Variant
Dim TaxCount As Long
Call alo.GetTradeAllowanceCharge(i, ChargeIndicator, CalculationPercent, ChargeBasisAmount, BasisQuantity, BasisQuantityUnitCode, ActualAmount, Reason, ReasonCode, SequenceNumeric, CurrencyID, TaxCount)
If TaxCount > 0 Then
For x = 0 To TaxCount - 1
Dim TaxRate As String
Dim CategoryCode As String
Dim TypeCode As String
Dim TaxReason As String
Dim TAXCalculatedAmount As String
Call alo.GetTradeAllowanceChargeTax(i, x, TaxRate, CategoryCode, TypeCode, TaxReason, TAXCalculatedAmount)
Next x
End If
Next i
End If
'Zahlungsbedingungen auslesen
If alo.TradePaymentTermsCount > 0 Then
For i = 0 To alo.TradePaymentTermsCount - 1
Dim index As Long
Dim Description As String
Dim ActualDiscountAmount As String
Dim tCalculationPercent As String
Dim DirectDebitMandateID As String
Dim DueDate As String
Dim BasisPeriod As String
Dim BasisDateTime As String
Call alo.TradePaymentTerm(index, Description, ActualDiscountAmount, tCalculationPercent, DirectDebitMandateID, BasisDateTime, BasisPeriod, DueDate)
Next i
End If
'Zahlungsbedingungen auslesen
If alo.TradePaymentTermsCount > 0 Then
For i = 0 To alo.TradePaymentTermsCount - 1
Dim index As Long
Dim Description As String
Dim ActualDiscountAmount As String
Dim tCalculationPercent As String
Dim DirectDebitMandateID As String
Dim DueDate As String
Dim BasisPeriod As String
Dim BasisDateTime As String
Call alo.TradePaymentTerm(index, Description, ActualDiscountAmount, tCalculationPercent, DirectDebitMandateID, BasisDateTime, BasisPeriod, DueDate)
Next i
End If
Dim AnzahlSteuerSaetze As Integer
AnzahlSteuerSaetze = alo.TradeTaxes
If AnzahlSteuerSaetze > 0 Then
For i = 0 To AnzahlSteuerSaetze - 1
Dim Steuersatz As TradeTax
Steuersatz = alo.TradeTaxItem(i)
Dim Prozent As String
Dim Steuerart As String
Dim Steuerkategorie As String
Dim BasisAmount As String
Dim CalculatedAmount As String
Dim ExemptionReason As String
Prozent = Steuersatz.RateApplicablePercent
Steuerkategorie = Steuersatz.CategoryCode
Steuerart = Steuersatz.TypeCode
BasisAmount = Steuersatz.BasisAmount.Amount
CalculatedAmount = Steuersatz.CalculatedAmount.Amount
ExemptionReason = Steuersatz.ExemptionReason
Next i
End If
AnzahlKonten = alo.InvoicePaymentMeansCount
If AnzahlKonten > 0 Then
For i = 0 To AnzahlKonten - 1
'In der Demo schalte ich ich zwischen true/false um
'da ich credit und debit accounts abteste
BankName = alo.InvoicePaymentMeansBankName(0, True)
If BankName = "" Then
BankName = alo.InvoicePaymentMeansBankName(0, False)
End If
IBAN = alo.InvoicePaymentMeansIBAN(0, True)
If IBAN = "" Then
IBAN = alo.InvoicePaymentMeansIBAN(0, False)
End If
BIC = alo.InvoicePaymentMeansBIC(0, True)
If BIC = "" Then
BIC = alo.InvoicePaymentMeansBIC(0, False)
End If
Next i
End If
Dim AnzahlPosten As Integer
AnzahlPosten = alo.TradeItemsCount
If AnzahlPosten > 0 Then
For i = 0 To AnzahlPosten - 1
Dim Posten As TradeItem
Dim PostenBeschreibung As String
Posten = alo.Trade_Item(i)
PostenBeschreibung = Posten.TradeProduct.Description.Value
If PostenBeschreibung <> "" Then
'usw
End If
Next i
End If
End If
Für “Late Binding” in VB6 bzw. VBA ändert sich nur die Objekterstellung:
Dim inputfile As String
Dim LicenseKey As String
Dim IBAN As String
Dim BIC As String
Dim BankName As String
Dim AnzahlKonten As Integer
Dim KaeuferVAT As String
Dim VerkaeuferVAT As String
Dim KaeuferBestellnummer As String
Dim VerkaeuferBestellnummer As String
inputfile = "o:\temp\test1.xml"
LicenseKey = "xxxxxx"
Dim alo As Object
Set alo = CreateObject("Aloaha_ZUGFeRD.XML")
If alo.Licensed(LicenseKey) = True Then
alo.FillZUGFeRD_Structure (inputfile)
KaeuferVAT = alo.VATNumber(True)
VerkaeuferVAT = alo.VATNumber(False)
KaeuferBestellnummer = alo.OrderNumber(True)
VerkaeuferBestellnummer = alo.OrderNumber(False)
Dim Lieferdatum As String
'aus Struktur
Lieferdatum = alo.SupplyChain_Structure.ActualDeliveryDate.Document_Date
'oder als Funktion
Lieferdatum = alo.ActualDeliveryDate_102
'Summen auslesen
Dim DuePayableAmount As String
Dim AllowanceTotalAmount As String
Dim ChargeTotalAmount As String
Dim GrandTotalAmount As String
Dim LineTotalAmount As String
Dim TaxBasisTotalAmount As String
Dim TaxTotalAmount As String
Dim TotalPrepaidAmount As String
Dim RoundingAmount As String
Call alo.getTotals(LineTotalAmount, GrandTotalAmount, DuePayableAmount, TaxBasisTotalAmount, TaxTotalAmount, AllowanceTotalAmount, TotalPrepaidAmount, RoundingAmount, ChargeTotalAmount)
Dim TradeAllowanceCharges As Integer
TradeAllowanceCharges = alo.TradeAllowanceCharges
If TradeAllowanceCharges > 0 Then
For i = 0 To TradeAllowanceCharges - 1
Dim ChargeIndicator As Boolean
Dim CalculationPercent As String
Dim ChargeBasisAmount As String
Dim BasisQuantity As String
Dim BasisQuantityUnitCode As String
Dim ActualAmount As String
Dim Reason As String
Dim ReasonCode As String
Dim CurrencyID As String
Dim SequenceNumeric As String
Dim Taxes As Variant
Dim TaxCount As Long
Call alo.GetTradeAllowanceCharge(i, ChargeIndicator, CalculationPercent, ChargeBasisAmount, BasisQuantity, BasisQuantityUnitCode, ActualAmount, Reason, ReasonCode, SequenceNumeric, CurrencyID, TaxCount)
If TaxCount > 0 Then
For x = 0 To TaxCount - 1
Dim TaxRate As String
Dim CategoryCode As String
Dim TypeCode As String
Dim TaxReason As String
Dim TAXCalculatedAmount As String
Call alo.GetTradeAllowanceChargeTax(i, x, TaxRate, CategoryCode, TypeCode, TaxReason, TAXCalculatedAmount)
Next x
End If
Next i
End If
Dim AnzahlSteuerSaetze As Integer
AnzahlSteuerSaetze = alo.TradeTaxes
If AnzahlSteuerSaetze > 0 Then
For i = 0 To AnzahlSteuerSaetze - 1
Dim Steuersatz As Variant
Steuersatz = alo.TradeTaxItem(i)
Dim Prozent As String
Dim Steuerart As String
Dim Steuerkategorie As String
Dim BasisAmount As String
Dim CalculatedAmount As String
Dim ExemptionReason As String
Prozent = Steuersatz.RateApplicablePercent
Steuerkategorie = Steuersatz.CategoryCode
Steuerart = Steuersatz.TypeCode
BasisAmount = Steuersatz.BasisAmount.Amount
CalculatedAmount = Steuersatz.CalculatedAmount.Amount
ExemptionReason = Steuersatz.ExemptionReason
Next i
End If
AnzahlKonten = alo.InvoicePaymentMeansCount
If AnzahlKonten > 0 Then
For i = 0 To AnzahlKonten - 1
'In der Demo schalte ich ich zwischen true/false um
'da ich credit und debit accounts abteste
BankName = alo.InvoicePaymentMeansBankName(0, True)
If BankName = "" Then
BankName = alo.InvoicePaymentMeansBankName(0, False)
End If
IBAN = alo.InvoicePaymentMeansIBAN(0, True)
If IBAN = "" Then
IBAN = alo.InvoicePaymentMeansIBAN(0, False)
End If
BIC = alo.InvoicePaymentMeansBIC(0, True)
If BIC = "" Then
BIC = alo.InvoicePaymentMeansBIC(0, False)
End If
Next i
End If
Dim AnzahlPosten As Integer
AnzahlPosten = alo.TradeItemsCount
If AnzahlPosten > 0 Then
For i = 0 To AnzahlPosten - 1
Dim Posten As Variant
Dim PostenBeschreibung As String
Posten = alo.Trade_Item(i)
PostenBeschreibung = Posten.TradeProduct.Description.Value
If PostenBeschreibung <> "" Then
'usw
End If
Next i
End If
End If