This commit is contained in:
2026-01-05 15:19:26 +01:00
parent 2187035214
commit 3a30253c2d
14 changed files with 3160 additions and 225 deletions

View File

@@ -1,4 +1,5 @@
Imports System.Data.SqlClient
Imports javax.xml.bind.annotation
Public Class cSendungen
Implements ICloneable
@@ -132,7 +133,7 @@ Public Class cSendungen
Public Function CLEAR_ABRECHNUNG_NotLeistungen() As Boolean
ABRECHNUNG.RemoveAll(Function(x) x.sndabr_abrArt = "ZOLL")
ABRECHNUNG.RemoveAll(Function(x) x.sndabr_abrArt = "EUST")
ABRECHNUNG.RemoveAll(Function(x) x.sndabr_abrArt = "CLEARING")
@@ -295,6 +296,24 @@ Public Class cSendungen
Return Nothing
End If
End Function
Public Shared Function getAvisoIdSendungsIdByFilialenNrAbfertigungsNr(FilialenNr As Integer, AbfertigungsNr As Integer, ByRef AvisoID As Integer, ByRef SendungID As Integer) As Boolean
Dim sql As New VERAG_PROG_ALLGEMEIN.SQL
Dim dt = sql.loadDgvBySql("SELECT TOP 1 tblSnd_AvisoID, tblSnd_SendungID FROM tblSendungen WHERE FilialenNr='" & FilialenNr & "' AND AbfertigungsNr='" & AbfertigungsNr & "'", "AVISO")
If dt IsNot Nothing AndAlso dt.Rows.Count > 0 Then
Dim AvisopIdTmp = dt.Rows(0)("tblSnd_AvisoID")
Dim SendungIDTmp = dt.Rows(0)("tblSnd_SendungID")
If AvisopIdTmp IsNot DBNull.Value AndAlso IsNumeric(AvisopIdTmp) Then
AvisoID = CInt(AvisopIdTmp)
End If
If SendungIDTmp IsNot DBNull.Value AndAlso IsNumeric(SendungIDTmp) Then
SendungID = CInt(SendungIDTmp)
End If
Return True
Else
Return False
End If
End Function
Public Function getKdAtrNr(art As String) As String
Try

View File

@@ -146,14 +146,7 @@ Public Class cATEZ_Greenpulse_CBAM_CostCalculation
' ------------------------------------------------------------------------
' calcCBAM mit automatischem Fallback auf CN-Code Defaults
' ------------------------------------------------------------------------
Public Shared Function calcCBAM(
cn_code As String,
weight As Object,
country_code As String,
Optional see_total As Object = Nothing,
Optional year As Object = Nothing,
Optional benchmark_value As Object = Nothing
) As String
Public Shared Function calcCBAM(cn_code As String, weight As Object, country_code As String, Optional ByRef see_total As Object = Nothing, Optional year As Object = Nothing, Optional ByRef benchmark_value As Object = Nothing, Optional ByRef CBAM_COST As Decimal = -1, Optional ByRef CBAM_EMISSION As Decimal = -1) As String
' ------------------------------------------------------------
' Basis-Validierung
@@ -207,6 +200,9 @@ Public Class cATEZ_Greenpulse_CBAM_CostCalculation
If defResp.success Then
defaultEmission = defResp.data.default_emission
defaultBenchmark = defResp.data.benchmark
benchmark_value = defaultBenchmark
see_total = defaultEmission
Else
Return $"FEHLER DEFAULTS {defResp.error.code}: {defResp.error.message}"
End If
@@ -272,7 +268,7 @@ Public Class cATEZ_Greenpulse_CBAM_CostCalculation
s &= $"Gewicht: {req.weight:N2} t" & vbCrLf
s &= vbCrLf
s &= $"Kosten: {d.cost:N2} {d.currency}" & vbCrLf
's &= $"Kosten: {d.cost:N2} {d.currency}" & vbCrLf
s &= $"CBAM Emission: {d.cbam_emission:N5}" & vbCrLf
s &= $"Benchmark: {d.benchmark:N5}" & vbCrLf
s &= $"Phase-Faktor: {d.phase_factor:P2}" & vbCrLf
@@ -281,12 +277,96 @@ Public Class cATEZ_Greenpulse_CBAM_CostCalculation
If Not String.IsNullOrWhiteSpace(d.info_message) Then
s &= vbCrLf & "Info: " & d.info_message & vbCrLf
End If
s &= vbCrLf
s &= $"CBAM Kosten: {d.cost:N2} {d.currency}" & vbCrLf
CBAM_COST = d.cost
CBAM_EMISSION = see_total
Return s
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
' ------------------------------------------------------------
' Validierung
' ------------------------------------------------------------
If cn_code Is Nothing OrElse Not IsNumeric(cn_code) _
OrElse Not {4, 6, 8}.Contains(cn_code.Length) Then
Return "Fehler: CN-Code muss 4-, 6- oder 8-stellig numerisch sein"
End If
If weight Is Nothing OrElse Not IsNumeric(weight) OrElse CDbl(weight) <= 0 Then
Return "Fehler: Gewicht muss > 0 sein"
End If
If country_code Is Nothing OrElse country_code.Length <> 2 Then
Return "Fehler: country_code muss ISO-2 sein"
End If
If certificate_price Is Nothing OrElse Not IsNumeric(certificate_price) OrElse CDbl(certificate_price) <= 0 Then
Return "Fehler: Zertifikatspreis muss > 0 sein"
End If
If year Is Nothing Or Not IsNumeric(year) Then
Return "Fehler: ungültiges Jahr"
End If
' ------------------------------------------------------------
' SEE total (Default-Emission) laden
' ------------------------------------------------------------
Dim api As New cATEZ_Greenpulse_CBAM_CostCalculation()
Dim see_total As Decimal
Try
Dim defResp = api.GetCnCodeDefaults(
cn_code,
country_code.ToUpperInvariant(),
CInt(year)
)
If Not defResp.success Then
Return $"FEHLER DEFAULTS {defResp.error.code}: {defResp.error.message}"
End If
If defResp.data.default_emission < 0 Then
Return "Fehler: Keine Default-Emission (see_total) verfügbar"
End If
see_total = defResp.data.default_emission
Catch ex As Exception
Return "Technischer Fehler beim Laden der CN-Code Defaults: " & ex.Message
End Try
' ------------------------------------------------------------
' Berechnung (ohne Phase-Faktor!)
' ------------------------------------------------------------
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
' ------------------------------------------------------------
Dim s As String = ""
s &= "CBAM Kostenberechnung (ohne Benchmark)" & vbCrLf
s &= "-----------------------------------------------------------" & vbCrLf
s &= $"CN-Code: {cn_code}" & vbCrLf
s &= $"Ursprungsland: {country_code.ToUpperInvariant()}" & 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
CBAM_COST = cbamCost
CBAM_EMISSION = see_total
Return s
End Function
' ------------------------------------------------------------------------
' Helpers
' ------------------------------------------------------------------------

View File

@@ -46,6 +46,13 @@ Public Class cATEZ_Greenpulse_KafkaDecs
Dim m = (mrn).ToUpperInvariant()
Return String.Join(SEP_PIPE, New String() {KEY_VERSION, c, s, m})
End Function
Public Shared Function GetUniqueKey_Pipe_FromVERAG_CustomsDec(CD As VERAG_PROG_ALLGEMEIN.cVERAG_CustomsDeclarations, Optional mrn As String = "") As String
Dim c = (If(CD.za_CountryImport, CD.za_CustomsSystemCountry)).ToUpperInvariant()
Dim s = (If(CD.za_System, CD.za_CustomsSystem)).ToUpperInvariant()
Dim m = (If(mrn = "", CD.za_MRN, mrn)).ToUpperInvariant()
Return String.Join(SEP_PIPE, New String() {KEY_VERSION, c, s, m})
End Function
'========================
'== Datenobjekte lt. UDM-Schema

View File

@@ -70,6 +70,7 @@ Public Class cVERAG_CustomsDeclarations
Public Property za_Remarks As String
Public Property za_Sachbearbeiter As String
Public Property za_SachbearbeiterId As String
Public Property za_TotGrossMass As Decimal?
Public Property Parties As New List(Of cVERAG_CustomsDeclarations_Parties)
Public Property Items As New List(Of cVERAG_CustomsDeclarations_Item)
@@ -142,7 +143,8 @@ Public Class cVERAG_CustomsDeclarations
New SQLVariable("za_SendungsId", za_SendungsId),
New SQLVariable("za_Remarks", za_Remarks),
New SQLVariable("za_Sachbearbeiter", za_Sachbearbeiter),
New SQLVariable("za_SachbearbeiterId", za_SachbearbeiterId)
New SQLVariable("za_SachbearbeiterId", za_SachbearbeiterId),
New SQLVariable("za_TotGrossMass", za_TotGrossMass)
}
End Function
@@ -204,6 +206,107 @@ Public Class cVERAG_CustomsDeclarations
End Try
End Sub
Public Shared Function LOAD_List_CBAM(EORI As String, ImportCountry As String, datFrom As Date, datTo As Date, Optional CustomsSystem As String = "", Optional loadAll As Boolean = True) As List(Of cVERAG_CustomsDeclarations)
Dim LIST As New List(Of cVERAG_CustomsDeclarations)
Dim SQL As New VERAG_PROG_ALLGEMEIN.SQL
Try
' ------------------------------------------------------------
' CBAM Pattern (HSCode)
' ------------------------------------------------------------
Dim cbamWhere As String =
VERAG_PROG_ALLGEMEIN.cGreendeal_CBAM_Trn.BuildCBAMPatternWhereClause("i.zaItem_HSCode")
' ------------------------------------------------------------
' SQL: ZA-IDs ermitteln
' ------------------------------------------------------------
Dim sqlstr As String =
"SELECT DISTINCT z.* " &
"FROM VERAG.dbo.tblVERAG_CustomsDeclarations z " &
"INNER JOIN VERAG.dbo.tblVERAG_CustomsDeclarations_Items i " &
" ON z.za_Id = i.zaItem_zaId " &
"INNER JOIN VERAG.dbo.tblVERAG_CustomsDeclarations_Parties p " &
" ON z.za_Id = p.zaParty_zaId " &
"WHERE z.za_REGIME = 'IMPORT' " &
" AND z.za_IsFinalDeclaration = 1 " &
" AND z.za_DeclarationDate >= @dateFrom " &
" AND z.za_DeclarationDate <= @dateTo " &
" AND p.zaParty_EORI = @eori " &
" AND " & cbamWhere
If ImportCountry <> "" Then
sqlstr &= " AND z.za_CountryImport = @importCountry "
End If
If CustomsSystem <> "" Then
sqlstr &= " AND z.za_System = @sys "
End If
Using conn = sql.GetNewOpenConnectionFMZOLL()
Using cmd As New SqlCommand(sqlstr, conn)
cmd.Parameters.AddWithValue("@eori", EORI)
cmd.Parameters.AddWithValue("@dateFrom", datFrom)
cmd.Parameters.AddWithValue("@dateTo", datTo)
If ImportCountry <> "" Then
cmd.Parameters.AddWithValue("@importCountry", ImportCountry)
End If
If CustomsSystem <> "" Then
cmd.Parameters.AddWithValue("@sys", CustomsSystem)
End If
Using dr = cmd.ExecuteReader()
While dr.Read()
Dim CD As New cVERAG_CustomsDeclarations
CD.hasEntry = False
' ------------------------------------------------
' DIREKTE BEFÜLLUNG (wie gewünscht)
' ------------------------------------------------
For Each li In CD.getParameterList()
Dim pi = CD.GetType().GetProperty(li.Scalarvariable)
If pi Is Nothing Then Continue For
If dr.Item(li.Text) Is DBNull.Value Then
pi.SetValue(CD, Nothing)
Else
pi.SetValue(CD, dr.Item(li.Text))
End If
Next
CD.hasEntry = True
' ------------------------------------------------
' OPTIONALES NACHLADEN
' ------------------------------------------------
If loadAll Then
CD.Parties = cVERAG_CustomsDeclarations_Parties.LOAD_BY_ZAID(CD.za_Id)
CD.Items = cVERAG_CustomsDeclarations_Item.LOAD_BY_ZAID(CD.za_Id)
CD.Duties = cVERAG_CustomsDeclarations_Duty.LOAD_BY_ZAID(CD.za_Id)
CD.Documents = cVERAG_CustomsDeclarations_Document.LOAD_HEAD_BY_ZAID(CD.za_Id)
End If
LIST.Add(CD)
End While
End Using
End Using
End Using
Catch ex As Exception
cErrorHandler.ERR(ex.Message, ex.StackTrace, Reflection.MethodInfo.GetCurrentMethod.Name)
End Try
Return LIST
End Function
Public Shared Function loadByMRN(MRN As String, loadall As Boolean) As cVERAG_CustomsDeclarations
Dim ZA As New cVERAG_CustomsDeclarations
If If(MRN, "") = "" Then Return ZA
@@ -717,7 +820,7 @@ Public Class cVERAG_CustomsDeclarations_Document
New SQLVariable("zaDoc_DepreciationAmount", zaDoc_DepreciationAmount),
New SQLVariable("zaDoc_DepreciationUnitmeasurement", zaDoc_DepreciationUnitmeasurement),
New SQLVariable("zaDoc_DepreciationUnitmeasurementQualifier", zaDoc_DepreciationUnitmeasurementQualifier),
New SQLVariable("zaDoc_Description ", zaDoc_Description)
New SQLVariable("zaDoc_Description", zaDoc_Description)
}
End Function

View File

@@ -71,6 +71,120 @@ Public Class cProgramFunctions
End Function
Public Shared Sub tryGetFilialeAbf_ByLRN(ByVal LRN As String, ByRef FilialenNr As Object, ByRef AbfertigungsNr As Object)
If String.IsNullOrWhiteSpace(LRN) Then Exit Sub
Dim pattern As String = "^(?<Filiale>\d{4})[\/\-](?<Abfertigung>\d{8})"
Dim m As System.Text.RegularExpressions.Match =
System.Text.RegularExpressions.Regex.Match(LRN.Trim(), pattern)
If Not m.Success Then Exit Sub
Dim filialeStr As String = m.Groups("Filiale").Value
Dim abfertigungStr As String = m.Groups("Abfertigung").Value
Dim FilialenNrTmp As Integer
Dim AbfertigungsNrTmp As Integer
If Integer.TryParse(filialeStr, FilialenNrTmp) AndAlso
Integer.TryParse(abfertigungStr, AbfertigungsNrTmp) Then
FilialenNr = FilialenNrTmp
AbfertigungsNr = AbfertigungsNrTmp
End If
End Sub
Public Shared Sub tryGetAvisoId_SndId_ByLRN(ByVal LRN As String, ByRef AvisoId As Object, ByRef SendungId As Object)
Dim FilialenNrTmp As Integer = -1
Dim AbfertigungsNrTmp As Integer = -1
tryGetFilialeAbf_ByLRN(LRN, FilialenNrTmp, AbfertigungsNrTmp)
If FilialenNrTmp > 0 AndAlso AbfertigungsNrTmp > 0 Then
VERAG_PROG_ALLGEMEIN.cSendungen.getAvisoIdSendungsIdByFilialenNrAbfertigungsNr(FilialenNrTmp, AbfertigungsNrTmp, AvisoId, SendungId)
End If
End Sub
Public Shared Sub tryGetFirmaNiederlassung(ByRef firma As String, ByRef niederlassung As String, Mail As String, BezugsNr As String)
If Mail.Contains("@imex") Then
firma = "IMEX"
niederlassung = "IMEX"
ElseIf Mail.Contains("@ambar") Then
firma = "AMBAR"
niederlassung = "AMBAR"
ElseIf Mail.Contains("atilla@verag.ag") Or Mail.Contains("@atilla") Then
If BezugsNr <> "" Then ' VERIMEX --> wenn keine Bezugsnummer, dann bei anderem Satus..
'----------------------------------------------------------------------------
'VERIMEX!!!! --> Arbeitet bim T1 Vorschreiben mit ATILLA Benutzer
Dim verimex = False
If firma = "" Then
If BezugsNr <> "" And BezugsNr.Length > 4 Then
Select Case BezugsNr.Substring(0, 4)
Case "5501", "4803", "5003", "5103", "5303", "4805", "4811", "7001", "5601"
verimex = True
End Select
End If
End If
'----------------------------------------------------------------------------
If Not verimex Then
firma = "ATILLA"
niederlassung = "SUB"
End If
End If
ElseIf Mail.Contains("@durmaz") Then
firma = "DURMAZ"
niederlassung = "SBG"
ElseIf Mail.Contains("@verag") Then
firma = "VERAG"
ElseIf Mail.Contains("@unisped") Then
firma = "UNISPED"
niederlassung = "ATSP"
End If
If firma = "" Then
Select Case VERAG_PROG_ALLGEMEIN.cAllgemein.FIRMA 'Gehrt nur bei UNSPED
Case "UNISPED"
firma = "UNISPED"
niederlassung = "ATSP"
End Select
End If
If firma = "" Then
If BezugsNr <> "" And BezugsNr.Length > 4 Then
Select Case BezugsNr.Substring(0, 4)
Case "5501"
firma = "IMEX"
'niederlassung = "IMEX"
Case "5701"
firma = "AMBAR"
niederlassung = "AMBAR"
Case "4801", "4802"
firma = "ATILLA"
niederlassung = "SUB"
'Case "4801"
' firma = "DURMAZ"
' niederlassung = "SBG"
Case "4803", "5003", "5103", "5303", "4805", "4811", "7001"
firma = "VERAG"
Case "5601"
firma = "UNISPED"
niederlassung = "ATSP"
End Select
End If
End If
End Sub
Public Shared Function fktEuro(varBetrag As Object, varVonWährung As Object, varNachWährung As Object) As Object
'(FixeTaxe, "ATS", RECHNUNG.Währungscode)
'Dim varVonWährung As Object