CBAM, VERAG CustomsDec

This commit is contained in:
2026-01-01 11:12:58 +01:00
parent ddb99e931d
commit 2187035214
6 changed files with 1051 additions and 892 deletions

View File

@@ -68,6 +68,8 @@ Partial Class usrCntlCBAM
Me.Button3 = New System.Windows.Forms.Button()
Me.lblKafkaCnt = New System.Windows.Forms.Label()
Me.Panel1 = New System.Windows.Forms.Panel()
Me.txtBenchmark = New VERAG_PROG_ALLGEMEIN.MyTextBox()
Me.Label12 = New System.Windows.Forms.Label()
Me.txtCalcLand = New VERAG_PROG_ALLGEMEIN.MyTextBox()
Me.txtCalcErg = New VERAG_PROG_ALLGEMEIN.MyTextBox()
Me.Button4 = New System.Windows.Forms.Button()
@@ -89,8 +91,7 @@ Partial Class usrCntlCBAM
Me.txtVon = New VERAG_PROG_ALLGEMEIN.MyTextBox()
Me.txtBis = New VERAG_PROG_ALLGEMEIN.MyTextBox()
Me.txtEori = New VERAG_PROG_ALLGEMEIN.MyTextBox()
Me.txtBenchmark = New VERAG_PROG_ALLGEMEIN.MyTextBox()
Me.Label12 = New System.Windows.Forms.Label()
Me.Button5 = New System.Windows.Forms.Button()
Me.cntxtAddSdl.SuspendLayout()
Me.Panel1.SuspendLayout()
Me.MyPanel1.SuspendLayout()
@@ -631,6 +632,39 @@ Partial Class usrCntlCBAM
Me.Panel1.Size = New System.Drawing.Size(223, 331)
Me.Panel1.TabIndex = 52
'
'txtBenchmark
'
Me.txtBenchmark._DateTimeOnly = False
Me.txtBenchmark._numbersOnly = True
Me.txtBenchmark._numbersOnlyKommastellen = ""
Me.txtBenchmark._numbersOnlyTrennzeichen = True
Me.txtBenchmark._Prozent = False
Me.txtBenchmark._ShortDateNew = False
Me.txtBenchmark._ShortDateOnly = False
Me.txtBenchmark._TimeOnly = False
Me.txtBenchmark._TimeOnly_Seconds = False
Me.txtBenchmark._value = ""
Me.txtBenchmark._Waehrung = False
Me.txtBenchmark._WaehrungZeichen = True
Me.txtBenchmark.ForeColor = System.Drawing.Color.Black
Me.txtBenchmark.Location = New System.Drawing.Point(73, 82)
Me.txtBenchmark.MaxLength = 10
Me.txtBenchmark.MaxLineLength = -1
Me.txtBenchmark.MaxLines_Warning = ""
Me.txtBenchmark.MaxLines_Warning_Label = Nothing
Me.txtBenchmark.Name = "txtBenchmark"
Me.txtBenchmark.Size = New System.Drawing.Size(147, 20)
Me.txtBenchmark.TabIndex = 66
'
'Label12
'
Me.Label12.AutoSize = True
Me.Label12.Location = New System.Drawing.Point(3, 85)
Me.Label12.Name = "Label12"
Me.Label12.Size = New System.Drawing.Size(67, 13)
Me.Label12.TabIndex = 67
Me.Label12.Text = "(Benchmark)"
'
'txtCalcLand
'
Me.txtCalcLand._DateTimeOnly = False
@@ -982,44 +1016,22 @@ Partial Class usrCntlCBAM
Me.txtEori.Size = New System.Drawing.Size(341, 20)
Me.txtEori.TabIndex = 1
'
'txtBenchmark
'Button5
'
Me.txtBenchmark._DateTimeOnly = False
Me.txtBenchmark._numbersOnly = True
Me.txtBenchmark._numbersOnlyKommastellen = ""
Me.txtBenchmark._numbersOnlyTrennzeichen = True
Me.txtBenchmark._Prozent = False
Me.txtBenchmark._ShortDateNew = False
Me.txtBenchmark._ShortDateOnly = False
Me.txtBenchmark._TimeOnly = False
Me.txtBenchmark._TimeOnly_Seconds = False
Me.txtBenchmark._value = ""
Me.txtBenchmark._Waehrung = False
Me.txtBenchmark._WaehrungZeichen = True
Me.txtBenchmark.ForeColor = System.Drawing.Color.Black
Me.txtBenchmark.Location = New System.Drawing.Point(73, 82)
Me.txtBenchmark.MaxLength = 10
Me.txtBenchmark.MaxLineLength = -1
Me.txtBenchmark.MaxLines_Warning = ""
Me.txtBenchmark.MaxLines_Warning_Label = Nothing
Me.txtBenchmark.Name = "txtBenchmark"
Me.txtBenchmark.Size = New System.Drawing.Size(147, 20)
Me.txtBenchmark.TabIndex = 66
'
'Label12
'
Me.Label12.AutoSize = True
Me.Label12.Location = New System.Drawing.Point(3, 85)
Me.Label12.Name = "Label12"
Me.Label12.Size = New System.Drawing.Size(67, 13)
Me.Label12.TabIndex = 67
Me.Label12.Text = "(Benchmark)"
Me.Button5.FlatStyle = System.Windows.Forms.FlatStyle.Flat
Me.Button5.Location = New System.Drawing.Point(32, 90)
Me.Button5.Name = "Button5"
Me.Button5.Size = New System.Drawing.Size(68, 37)
Me.Button5.TabIndex = 53
Me.Button5.Text = "test"
Me.Button5.UseVisualStyleBackColor = True
'
'usrCntlCBAM
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.BackColor = System.Drawing.Color.White
Me.Controls.Add(Me.Button5)
Me.Controls.Add(Me.Panel1)
Me.Controls.Add(Me.lblKafkaCnt)
Me.Controls.Add(Me.Button3)
@@ -1149,4 +1161,5 @@ Partial Class usrCntlCBAM
Friend WithEvents txtCalcLand As VERAG_PROG_ALLGEMEIN.MyTextBox
Friend WithEvents txtBenchmark As VERAG_PROG_ALLGEMEIN.MyTextBox
Friend WithEvents Label12 As Label
Friend WithEvents Button5 As Button
End Class

View File

@@ -18,6 +18,57 @@ Public Class usrCntlCBAM
Me.kdnr = kdNr
End Sub
Public Function CountCBAMTariffNumbersBySystemAndEORI(systemName As String, eori As String, dateFrom As Date, dateTo As Date) As Integer
' ------------------------------------------------------------
' CBAM-Pattern WHERE-Clause (HSCode)
' ------------------------------------------------------------
Dim cbamWhere As String =
VERAG_PROG_ALLGEMEIN.cGreendeal_CBAM_Trn.BuildCBAMPatternWhereClause("i.zaItem_HSCode")
' ------------------------------------------------------------
' SQL
' ------------------------------------------------------------
Dim sql As String =
"SELECT COUNT(distinct(z.Za_MRN)) AS Cnt " &
"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_System = @sys " &
" AND 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
' ------------------------------------------------------------
' Parameter
' ------------------------------------------------------------
Dim p As New List(Of VERAG_PROG_ALLGEMEIN.SQLVariable) From {
New VERAG_PROG_ALLGEMEIN.SQLVariable("sys", systemName),
New VERAG_PROG_ALLGEMEIN.SQLVariable("eori", eori),
New VERAG_PROG_ALLGEMEIN.SQLVariable("dateFrom", dateFrom),
New VERAG_PROG_ALLGEMEIN.SQLVariable("dateTo", dateTo)
}
' ------------------------------------------------------------
' Execute
' ------------------------------------------------------------
Dim dt As DataTable =
New VERAG_PROG_ALLGEMEIN.SQL().
loadDgvBySql_Param(sql, "VERAG", , p)
If dt Is Nothing OrElse dt.Rows.Count = 0 OrElse IsDBNull(dt.Rows(0)("Cnt")) Then
Return 0
End If
Return Convert.ToInt32(dt.Rows(0)("Cnt"))
End Function
Private Sub btnCBAMPruef_DAKOSY_Click(sender As Object, e As EventArgs) Handles btnCBAMPruef_DAKOSY.Click
txtCBAMPruef_DAKOSY.Text = "-"
@@ -36,8 +87,8 @@ Public Class usrCntlCBAM
Dim SQLSTR = "
SELECT COUNT(distinct(Registriernummer_MRN)) FROM [tbl_DY_Zollmeldungen_Import]
where Überlassungsdatum between '" & txtVon._value & "' and '" & txtBis._value & "'
and
(
and " & VERAG_PROG_ALLGEMEIN.cGreendeal_CBAM_Trn.BuildCBAMPatternWhereClause("Warentarifnummer") & "
/* (
left(Warentarifnummer,4) IN (2523,2716,2808,2814,3102,3105,7201,7203,7318,7326,7601,7616)
OR left(Warentarifnummer,4) between 7301 and 7311
OR left(Warentarifnummer,4) between 7205 and 7229
@@ -52,7 +103,7 @@ Public Class usrCntlCBAM
OR Warentarifnummer like '720260%'
OR Warentarifnummer like '280410%'
)
and Warentarifnummer not like '310560%'
and Warentarifnummer not like '310560%'*/
"
@@ -181,8 +232,8 @@ Public Class usrCntlCBAM
inner join zsAnmDeclarant on zsAnmHea.LizenzNr=zsAnmDeclarant.LizenzNr and zsAnmHea.AnmID=zsAnmDeclarant.AnmID and zsAnmHea.VorgangID=zsAnmDeclarant.VorgangID and zsAnmHea.OperatorID=zsAnmDeclarant.OperatorID
inner join zsAnmTransp on zsAnmHea.LizenzNr=zsAnmTransp.LizenzNr and zsAnmHea.AnmID=zsAnmTransp.AnmID and zsAnmHea.VorgangID=zsAnmTransp.VorgangID and zsAnmHea.OperatorID=zsAnmTransp.OperatorID
where DecDT between '" & txtVon._value & "' and '" & txtBis._value & "'
and
(
and " & VERAG_PROG_ALLGEMEIN.cGreendeal_CBAM_Trn.BuildCBAMPatternWhereClause("ComCd") & "
/* (
left(ComCd,4) IN (2523,2716,2808,2814,3102,3105,7201,7203,7318,7326,7601,7616)
OR left(ComCd,4) between 7301 and 7311
OR left(ComCd,4) between 7205 and 7229
@@ -197,7 +248,7 @@ Public Class usrCntlCBAM
OR ComCd like '720260%'
OR ComCd like '280410%'
)
and ComCd not like '310560%'
and ComCd not like '310560%' */
and crn is not null
and zsAnmDHFRefs.ErledigungsTypID like 'F%'
"
@@ -246,8 +297,8 @@ Public Class usrCntlCBAM
inner join zsAnmDeclarant on zsAnmHea.LizenzNr=zsAnmDeclarant.LizenzNr and zsAnmHea.AnmID=zsAnmDeclarant.AnmID and zsAnmHea.VorgangID=zsAnmDeclarant.VorgangID and zsAnmHea.OperatorID=zsAnmDeclarant.OperatorID
inner join zsAnmTransp on zsAnmHea.LizenzNr=zsAnmTransp.LizenzNr and zsAnmHea.AnmID=zsAnmTransp.AnmID and zsAnmHea.VorgangID=zsAnmTransp.VorgangID and zsAnmHea.OperatorID=zsAnmTransp.OperatorID
where DecDT between '" & txtVon._value & "' and '" & txtBis._value & "'
and
(
and " & VERAG_PROG_ALLGEMEIN.cGreendeal_CBAM_Trn.BuildCBAMPatternWhereClause("ComCd") & "
/*(
left(ComCd,4) IN (2523,2716,2808,2814,3102,3105,7201,7203,7318,7326,7601,7616)
OR left(ComCd,4) between 7301 and 7311
OR left(ComCd,4) between 7205 and 7229
@@ -262,7 +313,7 @@ Public Class usrCntlCBAM
OR ComCd like '720260%'
OR ComCd like '280410%'
)
and ComCd not like '310560%'
and ComCd not like '310560%' */
and crn is not null
and zsAnmDHFRefs.ErledigungsTypID like 'F%'
"
@@ -316,8 +367,8 @@ Public Class usrCntlCBAM
where 1=1
and
(
and " & VERAG_PROG_ALLGEMEIN.cGreendeal_CBAM_Trn.BuildCBAMPatternWhereClause("Item_ComCd") & "
/* (
left(Item_ComCd,4) IN (2523,2716,2808,2814,3102,3105,7201,7203,7318,7326,7601,7616)
OR left(Item_ComCd,4) between 7301 and 7311
OR left(Item_ComCd,4) between 7205 and 7229
@@ -332,7 +383,7 @@ Public Class usrCntlCBAM
OR Item_ComCd like '720260%'
OR Item_ComCd like '280410%'
)
and Item_ComCd not like '310560%'
and Item_ComCd not like '310560%' */
and telnam_aktuellsteNachricht=1
@@ -587,8 +638,8 @@ Public Class usrCntlCBAM
FROM [tbl_DY_Zollmeldungen_Import]
where
Überlassungsdatum between '" & txtVon._value & "' and '" & txtBis._value & "'
and
(
and " & VERAG_PROG_ALLGEMEIN.cGreendeal_CBAM_Trn.BuildCBAMPatternWhereClause("Warentarifnummer") & "
/* (
left(Warentarifnummer,4) IN (2523,2716,2808,2814,3102,3105,7201,7203,7318,7326,7601,7616)
OR left(Warentarifnummer,4) between 7301 and 7311
OR left(Warentarifnummer,4) between 7205 and 7229
@@ -603,7 +654,7 @@ Public Class usrCntlCBAM
OR Warentarifnummer like '720260%'
OR Warentarifnummer like '280410%'
)
and Warentarifnummer not like '310560%'
and Warentarifnummer not like '310560%' */
"
@@ -733,7 +784,8 @@ Public Class usrCntlCBAM
Dim SQLSTR = " FROM [tbl_DY_Zollmeldungen_Import]
where
Überlassungsdatum between '" & txtVon._value & "' and '" & txtBis._value & "'
AND (
and " & VERAG_PROG_ALLGEMEIN.cGreendeal_CBAM_Trn.BuildCBAMPatternWhereClause("Warentarifnummer") & "
/* AND (
LEFT(Warentarifnummer,4) IN (2523,2716,2808,2814,2803,2818,3102,3103,3104,3105,
7201,7202,7203,7204,7325,7318,7326,7601,7602)
OR LEFT(Warentarifnummer,4) BETWEEN 7205 AND 7229
@@ -751,7 +803,7 @@ Public Class usrCntlCBAM
OR Warentarifnummer LIKE '720260%'
OR Warentarifnummer LIKE '280410%'
)
AND Warentarifnummer NOT LIKE '310560%'
AND Warentarifnummer NOT LIKE '310560%'*/
"
@@ -841,8 +893,8 @@ Public Class usrCntlCBAM
inner join zsAnmDeclarant on zsAnmHea.LizenzNr=zsAnmDeclarant.LizenzNr and zsAnmHea.AnmID=zsAnmDeclarant.AnmID and zsAnmHea.VorgangID=zsAnmDeclarant.VorgangID and zsAnmHea.OperatorID=zsAnmDeclarant.OperatorID
inner join zsAnmTransp on zsAnmHea.LizenzNr=zsAnmTransp.LizenzNr and zsAnmHea.AnmID=zsAnmTransp.AnmID and zsAnmHea.VorgangID=zsAnmTransp.VorgangID and zsAnmHea.OperatorID=zsAnmTransp.OperatorID
where DecDT between '" & txtVon._value & "' and '" & txtBis._value & "'
and
(
and " & VERAG_PROG_ALLGEMEIN.cGreendeal_CBAM_Trn.BuildCBAMPatternWhereClause("ComCd") & "
/* (
left(ComCd,4) IN (2523,2716,2808,2814,3102,3105,7201,7203,7318,7326,7601,7616)
OR left(ComCd,4) between 7301 and 7311
OR left(ComCd,4) between 7205 and 7229
@@ -857,7 +909,7 @@ Public Class usrCntlCBAM
OR ComCd like '720260%'
OR ComCd like '280410%'
)
and ComCd not like '310560%'
and ComCd not like '310560%' */
and crn is not null
and zsAnmDHFRefs.ErledigungsTypID like 'F%'"
@@ -946,7 +998,8 @@ Public Class usrCntlCBAM
where 1=1
and
and " & VERAG_PROG_ALLGEMEIN.cGreendeal_CBAM_Trn.BuildCBAMPatternWhereClause("Item_ComCd") & "
/*
(
left(Item_ComCd,4) IN (2523,2716,2808,2814,3102,3105,7201,7203,7318,7326,7601,7616)
OR left(Item_ComCd,4) between 7301 and 7311
@@ -962,7 +1015,7 @@ Public Class usrCntlCBAM
OR Item_ComCd like '720260%'
OR Item_ComCd like '280410%'
)
and Item_ComCd not like '310560%'
and Item_ComCd not like '310560%' */
and telnam_aktuellsteNachricht=1
@@ -1231,8 +1284,8 @@ Public Class usrCntlCBAM
inner join tblDakosy_EZA_Adressen on ezaAd_EZAId=eza_Id and [ezaAd_AdressTyp]='CN'
where
eza_anmeldedatum between '" & txtVon._value & "' and '" & txtBis._value & "'
and
(
and " & VERAG_PROG_ALLGEMEIN.cGreendeal_CBAM_Trn.BuildCBAMPatternWhereClause("ezaWP_WarennummerEZT") & "
/* (
left(ezaWP_WarennummerEZT,4) IN (2523,2716,2808,2814,3102,3105,7201,7203,7318,7326,7601,7616)
OR left(ezaWP_WarennummerEZT,4) between 7301 and 7311
OR left(ezaWP_WarennummerEZT,4) between 7205 and 7229
@@ -1248,7 +1301,7 @@ Public Class usrCntlCBAM
OR ezaWP_WarennummerEZT like '280410%'
)
and ezaWP_WarennummerEZT not like '310560%'
and ezaWP_WarennummerEZT not like '310560%'*/
and (eza_status between 50 and 60 or [eza_ANR] LIKE 'ATC%')
"
@@ -1678,8 +1731,8 @@ Public Class usrCntlCBAM
inner join zsAnmDeclarant on zsAnmHea.LizenzNr=zsAnmDeclarant.LizenzNr and zsAnmHea.AnmID=zsAnmDeclarant.AnmID and zsAnmHea.VorgangID=zsAnmDeclarant.VorgangID and zsAnmHea.OperatorID=zsAnmDeclarant.OperatorID
inner join zsAnmTransp on zsAnmHea.LizenzNr=zsAnmTransp.LizenzNr and zsAnmHea.AnmID=zsAnmTransp.AnmID and zsAnmHea.VorgangID=zsAnmTransp.VorgangID and zsAnmHea.OperatorID=zsAnmTransp.OperatorID
where DecDT between '" & txtVon._value & "' and '" & txtBis._value & "'
and
(
and " & VERAG_PROG_ALLGEMEIN.cGreendeal_CBAM_Trn.BuildCBAMPatternWhereClause("ComCd") & "
/* (
left(ComCd,4) IN (2523,2716,2808,2814,3102,3105,7201,7203,7318,7326,7601,7616)
OR left(ComCd,4) between 7301 and 7311
OR left(ComCd,4) between 7205 and 7229
@@ -1694,7 +1747,7 @@ Public Class usrCntlCBAM
OR ComCd like '720260%'
OR ComCd like '280410%'
)
and ComCd not like '310560%'
and ComCd not like '310560%' */
and crn is not null
and zsAnmDHFRefs.ErledigungsTypID like 'F%'
"
@@ -2032,4 +2085,9 @@ Public Class usrCntlCBAM
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
txtCalcErg.Text = cATEZ_Greenpulse_CBAM_CostCalculation.calcCBAM(txtCalcKN8._value, txtCalcGewicht._value, txtCalcLand._value, txtCalcEmission._value, txtCalcJahr._value, txtBenchmark._value)
End Sub
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
MsgBox(CountCBAMTariffNumbersBySystemAndEORI("DAKOSY", txtEori.Text, txtVon._value, txtBis._value))
MsgBox(CountCBAMTariffNumbersBySystemAndEORI("DHF", txtEori.Text, txtVon._value, txtBis._value))
End Sub
End Class