This commit is contained in:
2026-01-13 15:29:00 +01:00
parent 84e9e86a4d
commit 283ba40d9c
5 changed files with 94 additions and 39 deletions

View File

@@ -285,7 +285,9 @@ Public Class cATEZ_Greenpulse_CBAM_CostCalculation
End Function
Public Shared Function calcCBAM_ByCertificatePrice(cn_code As String, weight As Object, country_code As String, certificate_price As Object, year As Object, Optional ByRef CBAM_COST As Decimal = -1, Optional ByRef CBAM_EMISSION As Decimal = -1) As String
Public Shared Function calcCBAM_ByCertificatePrice(cn_code As String, weight As Object, country_code As String, certificate_price As Object, year As Object, Optional ByRef CBAM_COST As Decimal = -1, Optional ByRef CBAM_EMISSION As Decimal = -1, Optional ByRef CBAM_BENCHMARK As Decimal = -1, Optional ByRef CBAM_Faktor As Decimal = -1) As String
VERAG_PROG_ALLGEMEIN.cChilkat_Helper.UnlockCilkat()
' ------------------------------------------------------------
' Validierung
@@ -316,6 +318,7 @@ Public Class cATEZ_Greenpulse_CBAM_CostCalculation
' ------------------------------------------------------------
Dim api As New cATEZ_Greenpulse_CBAM_CostCalculation()
Dim see_total As Decimal
Dim benchmark As Decimal
Try
Dim defResp = api.GetCnCodeDefaults(
@@ -333,6 +336,7 @@ Public Class cATEZ_Greenpulse_CBAM_CostCalculation
End If
see_total = defResp.data.default_emission
benchmark = defResp.data.benchmark
Catch ex As Exception
Return "Technischer Fehler beim Laden der CN-Code Defaults: " & ex.Message
@@ -344,25 +348,52 @@ Public Class cATEZ_Greenpulse_CBAM_CostCalculation
Dim w As Decimal = CDec(weight)
Dim price As Decimal = CDec(certificate_price)
Dim cbamEmission As Decimal = w * see_total
Dim cbamCost As Decimal = cbamEmission * price
' ------------------------------------------------------------
' Ausgabe
' ------------------------------------------------------------
' --- Faktoren als echte Faktoren (nicht Prozent) ---
Dim cbamf As Decimal = 0D
Select Case CInt(year)
Case 2026 : cbamf = 0.975D
Case 2027 : cbamf = 0.95D
Case 2028 : cbamf = 0.9D
Case 2029 : cbamf = 0.775D
Case 2030 : cbamf = 0.515D
Case 2031 : cbamf = 0.39D
Case 2032 : cbamf = 0.265D
Case 2033 : cbamf = 0.14D
Case Else : cbamf = 0D
End Select
' SEFA = Benchmark * CBAMF * CSCF
Dim sefa As Decimal = benchmark * cbamf
' Zertifikatspflicht je Tonne Ware
Dim certPerTon As Decimal = see_total - sefa
If certPerTon < 0D Then certPerTon = 0D
' Gesamte Zertifikatspflicht (t CO2e)
Dim certTotal As Decimal = certPerTon * w
' Kosten
Dim cbamCost As Decimal = certTotal * price
' --- Ausgabe ---
Dim s As String = ""
s &= "CBAM Kostenberechnung (ohne Benchmark)" & vbCrLf
s &= "CBAM Kostenberechnung (Default EE mit SEFA-Abzug)" & vbCrLf
s &= "-----------------------------------------------------------" & vbCrLf
s &= $"CN-Code: {cn_code}" & vbCrLf
s &= $"Ursprungsland: {country_code.ToUpperInvariant()}" & vbCrLf
s &= $"Jahr: {year}" & vbCrLf
s &= $"Gewicht: {w:N2} t" & vbCrLf
s &= $"SEE total (Default): {see_total:N5}" & vbCrLf
s &= $"CBAM Emission: {cbamEmission:N5} t CO₂" & vbCrLf
s &= $"Zertifikatspreis: {price:N2} EUR/t" & vbCrLf
s &= vbCrLf
s &= $"CBAM Kosten: {cbamCost:N2} EUR" & vbCrLf
s &= $"EE / SEE total (Default): {see_total:N6} t CO₂e/t" & vbCrLf
s &= $"Benchmark BMg: {benchmark:N6} t CO₂e/t" & vbCrLf
s &= $"CBAMF: {cbamf:N3}"
Console.WriteLine(s)
CBAM_COST = cbamCost
CBAM_EMISSION = see_total
CBAM_BENCHMARK = benchmark
CBAM_Faktor = cbamf
Return s

View File

@@ -369,6 +369,7 @@ Public Class cVERAG_CustomsDeclarations
If hasCBAM(CBAM_ITEMS) Then
Dim importerEORI As String = Me.Parties.Where(Function(p) {"CN", "IM", "IMP", "IMPORTER"}.Contains(p.zaParty_Role)).Select(Function(p) p.zaParty_EORI).FirstOrDefault()
Dim ImporterString As String = Me.Parties.Where(Function(p) {"CZ", "EX", "EXP", "EXPORTER"}.Contains(p.zaParty_Role)).Select(Function(p) p.zaParty_Name).FirstOrDefault()
Dim ExporterEORI As String = Me.Parties.Where(Function(p) {"CZ", "EX", "EXP", "EXPORTER"}.Contains(p.zaParty_Role)).Select(Function(p) p.zaParty_EORI).FirstOrDefault()
Dim ExporterString As String = Me.Parties.Where(Function(p) {"CZ", "EX", "EXP", "EXPORTER"}.Contains(p.zaParty_Role)).Select(Function(p) p.zaParty_Name).FirstOrDefault()
@@ -380,14 +381,27 @@ Public Class cVERAG_CustomsDeclarations
AD = New cAdressen(KD.KundenNr)
End If
If AD IsNot Nothing Then
ImporterString = AD.Name_1 & " " & If(AD.Name_2, "") & "<br/>" & If(AD.LandKz, "") & " " & If(AD.PLZ, "") & " " & If(AD.Ort, "")
End If
Dim KD_EX As cKunde = Nothing
Dim AD_EX As cAdressen = Nothing
If If(ExporterEORI, "") <> "" Then
KD_EX = cKunde.LOAD_ByEORI(ExporterEORI, If(za_Firma, ""))
If KD_EX Is Nothing Then KD_EX = cKunde.LOAD_ByEORI(ExporterEORI) 'Wenn kein Kunde mit Firma gefunden wurde, nur nach EORI suchen (default VERAG)
AD_EX = New cAdressen(KD_EX.KundenNr)
End If
If AD_EX IsNot Nothing Then
ExporterString = AD_EX.Name_1 & " " & If(AD_EX.Name_2, "") & "<br/>" & If(AD_EX.LandKz, "") & " " & If(AD_EX.PLZ, "") & " " & If(AD_EX.Ort, "")
End If
If isIndirect() Then
Dim KD_EX As cKunde = Nothing
Dim AD_EX As cAdressen = Nothing
If If(ExporterEORI, "") <> "" Then
KD_EX = cKunde.LOAD_ByEORI(ExporterEORI, If(za_Firma, ""))
If KD_EX Is Nothing Then KD_EX = cKunde.LOAD_ByEORI(ExporterEORI) 'Wenn kein Kunde mit Firma gefunden wurde, nur nach EORI suchen (default VERAG)
AD_EX = New cAdressen(KD_EX.KundenNr)
End If
'==================>> INDIRECT <<=========================
Dim itemsHtml As String =
@@ -416,9 +430,7 @@ Public Class cVERAG_CustomsDeclarations
"</table>" &
"<p>" &
"<b>Importeur:</b><br/>" &
importerEORI & " " & vbNewLine &
If(AD Is Nothing, ExporterString, AD.Name_1 & " " & If(AD.Name_2, "") & "<br/>" &
If(AD.LandKz, "") & " " & If(AD.PLZ, "") & " " & If(AD.Ort, "")) &
If(importerEORI, "") & "<br>" & If(ImporterString, "") &
"</p>" &
"<p>" &
"<b>Exporteur:</b><br/>" &
@@ -480,29 +492,28 @@ Public Class cVERAG_CustomsDeclarations
Schwellenwert = Warn1
End If
'===========>>>> WARNUNG <<<<<<<=================================
If WarnLevel <> "" Then
'===========>>>> WARNUNG <<<<<<<=================================
If WarnLevel <> "" Then
Dim bodyHtml As String =
"<html><body style='font-family:Segoe UI, Arial, sans-serif; font-size:12pt; color:#222'>" &
"<h2 style='color:#b00020'>CBAM-Warnmeldung zu Ihrer Zollanmeldung " & Me.za_MRN & "</h2>" &
"<p>" &
"<p>" &
"Laut unserem System wurden in der Zollanmeldung mit der MRN <b>" & Me.za_MRN & "</b> " &
"CBAM-pflichtige Warenpositionen erkannt.<br/>" &
"Für Ihr Unternehmen liegen uns derzeit keine Informationen über eine gültige CBAM-Registrierung vor." &
"</p>" &
"<table cellpadding='6' cellspacing='0' border='1' style='border-collapse:collapse'>" &
"<tr><td><b>Warnstufe</b></td><td>" & WarnLevel & If(WarnLevel = 3, " - <b style='color:#b00020'>ÜBERSCHREITUNG!</b>", "") & "</td></tr>" &
"<table cellpadding='6' cellspacing='0' border='1' style='border-collapse:collapse'>" &
"<tr><td><b>Warnstufe</b></td><td>" & WarnLevel & If(WarnLevel = 3, " - <span style='color:#b00020'><b>ÜBERSCHREITUNG!</b></span>", "") & "</td></tr>" &
"<tr><td><b>Schwellenwert</b></td><td>" & Schwellenwert.ToString("N0") & " Tonnen</td></tr>" &
"</table><br/>" &
"<p>" &
"<b>Importeur:</b><br/>" &
importerEORI & " " & vbNewLine &
If(AD Is Nothing, ExporterString, AD.Name_1 & " " & If(AD.Name_2, "") & "<br/>" &
If(AD.LandKz, "") & " " & If(AD.PLZ, "") & " " & If(AD.Ort, "")) &
"</p>" &
If(importerEORI, "") & "<br>" & If(ImporterString, "") &
"</p>" &
"<p>" &
"<b>Exporteur:</b><br/>" &
If(ExporterEORI, "") & " " & vbNewLine & If(ExporterString, "") &
If(ExporterEORI, "") & "<br>" & If(ExporterString, "") &
"</p>" &
"<p style='color:#b00020'><b>WICHTIG</b></p>" &
"<p>" &
@@ -518,9 +529,10 @@ Public Class cVERAG_CustomsDeclarations
"<p><b>VERAG DCS CBAM Compliance Services</b></p>" &
"<p>VERAG Spedition AG<br>A-4975 Suben, Suben 100</p>" &
"</body></html>"
Console.WriteLine(bodyHtml)
VERAG_PROG_ALLGEMEIN.cProgramFunctions.sendMail(If(AD.E_Mail, ""), "CBAM-WARNUNG " & If(WarnLevel = 3, " - ACHTUNG: Überschreitung 50to! ", "Überschreitung der Meldeschwelle"), bodyHtml, "cbam@verag.ag", (WarnLevel = 3), "cbam@verag.ag",, "al@verag.ag")
' VERAG_PROG_ALLGEMEIN.cProgramFunctions.sendMail(If(AD.E_Mail, ""), "CBAM-WARNUNG " & If(WarnLevel = 3, " ACHTUNG: Überschreitung 50to! ", "Überschreitung der Meldeschwelle"), bodyHtml, "cbam@verag.ag", (WarnLevel = 3), "cbam@verag.ag",, "al@verag.ag")
VERAG_PROG_ALLGEMEIN.cProgramFunctions.sendMail(If(AD.E_Mail, ""), "CBAM-WARNUNG " & If(WarnLevel = 3, " ACHTUNG: Überschreitung 50to! ", "Überschreitung der Meldeschwelle"), bodyHtml, "cbam@verag.ag", (WarnLevel = 3), False, "cbam@verag.ag", "al@verag.ag")
'VERAG_PROG_ALLGEMEIN.cProgramFunctions.sendMail(
' "al@verag.ag",
@@ -539,8 +551,8 @@ Public Class cVERAG_CustomsDeclarations
' "VERAG CBAM Compliance Services"
' )
End If
'================================================================
End Select
'================================================================
End Select
End If
'=========================================================
Catch ex As Exception