ENS HMRC
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
Imports System.Data.SqlClient
|
||||
Imports System.Reflection
|
||||
Imports VERAG_PROG_ALLGEMEIN
|
||||
|
||||
Public Class cDakosyNCTSOut004
|
||||
|
||||
@@ -784,7 +785,7 @@ Public Class cDakosyNCTSOut004
|
||||
|
||||
Next
|
||||
If loadALL Then
|
||||
LOAD_GUARANTEE()
|
||||
LOAD_Guarantee()
|
||||
LOAD_HouseConsignment()
|
||||
LOAD_TransportEquipment()
|
||||
End If
|
||||
@@ -1433,6 +1434,18 @@ Public Class cDakosyNCTSOut004
|
||||
SPEDITIONSBUCH.DokumentId_Steuerbeleg = ANM.dy_Steuerbescheid_dsId
|
||||
SPEDITIONSBUCH.DokumentId_VBD = ANM.dy_VBD_dsId
|
||||
|
||||
If SPEDITIONSBUCH.DokumentId_VBD Is Nothing OrElse SPEDITIONSBUCH.DokumentId_VBD <= 0 Then
|
||||
'Versuch einen ncoh nciht zugeordneten Versandschein zuzuordnen...
|
||||
Dim DS = New VERAG_PROG_ALLGEMEIN.cDATENSERVER("ZOLLDATEN", "VBD", "", "", "", SPEDITIONSBUCH.AtlasBezNrNCTS.Replace("/", "-").Trim, 0, False)
|
||||
If DS IsNot Nothing AndAlso DS.hasITEMS Then
|
||||
ANM.dy_VBD_dsId = DS.da_id
|
||||
ANM.SAVE()
|
||||
SPEDITIONSBUCH.DokumentId_VBD = ANM.dy_VBD_dsId
|
||||
|
||||
End If
|
||||
End If
|
||||
|
||||
|
||||
Catch ex As Exception
|
||||
MsgBox("ERR: " & ex.Message & ex.StackTrace)
|
||||
|
||||
@@ -2734,6 +2747,188 @@ Public Class cDakosyNCTSOut004
|
||||
End Function
|
||||
|
||||
|
||||
Shared Function fillNCTS_WithEXG(ByRef NCTS_OUT As cDakosyNCTSOut004, exg As cDakosyEXG, Optional ObjectName As String = "") As cDakosyNCTSOut004
|
||||
|
||||
|
||||
If NCTS_OUT Is Nothing Then
|
||||
NCTS_OUT = New DAKOSY_Worker.cDakosyNCTSOut004
|
||||
NCTS_OUT.ncts_ObjectName = ObjectName
|
||||
End If
|
||||
|
||||
|
||||
If NCTS_OUT IsNot Nothing Then
|
||||
If NCTS_OUT.ncts_ObjectName = "" Then NCTS_OUT.ncts_ObjectName = ObjectName
|
||||
|
||||
Dim HC As New cDakosy_NCTSOut004_HouseConsignment
|
||||
HC.nctsHC_Consignee_Name = exg.exg_Consignee_Name
|
||||
HC.nctsHC_Consignee_IdentificationNumber = exg.exg_Consignee_IdentificationNumber
|
||||
HC.nctsHC_Consignee_SubsidiaryNumber = exg.exg_Consignee_SubsidiaryNumber
|
||||
HC.nctsHC_Consignee_StreetNumber = exg.exg_Consignee_StreetNumber
|
||||
HC.nctsHC_Consignee_City = exg.exg_Consignee_City
|
||||
HC.nctsHC_Consignee_Postcode = exg.exg_Consignee_Postcode
|
||||
HC.nctsHC_Consignee_Country = exg.exg_Consignee_Country
|
||||
HC.nctsHC_Consignee_ContactPerson_Name = exg.exg_Consignee_ContactPerson_Name
|
||||
HC.nctsHC_Consignee_ContactPerson_PhoneNumber = exg.exg_Consignee_ContactPerson_PhoneNumber
|
||||
HC.nctsHC_Consignee_ContactPerson_EMailAddress = exg.exg_Consignee_ContactPerson_EMailAddress
|
||||
HC.nctsHC_Consignee_AdressCode = exg.exg_Consignee_AdressCode
|
||||
|
||||
HC.nctsHC_Consignor_Name = exg.exg_Consignor_Name
|
||||
HC.nctsHC_Consignor_IdentificationNumber = exg.exg_Consignor_IdentificationNumber
|
||||
HC.nctsHC_Consignor_SubsidiaryNumber = exg.exg_Consignor_SubsidiaryNumber
|
||||
HC.nctsHC_Consignor_StreetNumber = exg.exg_Consignor_StreetNumber
|
||||
HC.nctsHC_Consignor_City = exg.exg_Consignor_City
|
||||
HC.nctsHC_Consignor_Postcode = exg.exg_Consignor_Postcode
|
||||
HC.nctsHC_Consignor_Country = exg.exg_Consignor_Country
|
||||
HC.nctsHC_Consignor_ContactPerson_Name = exg.exg_Consignor_ContactPerson_Name
|
||||
HC.nctsHC_Consignor_ContactPerson_PhoneNumber = exg.exg_Consignor_ContactPerson_PhoneNumber
|
||||
HC.nctsHC_Consignor_ContactPerson_EMailAddress = exg.exg_Consignor_ContactPerson_EMailAddress
|
||||
HC.nctsHC_Consignor_AdressCode = exg.exg_Consignor_AdressCode
|
||||
|
||||
|
||||
HC.nctsHC_GrossMass = exg.exg_GrossMass
|
||||
HC.nctsHC_ReferenceNumberUCR = exg.exg_ReferenceNumberUCR
|
||||
|
||||
HC.nctsHC_CountryOfDestination = exg.exg_CountryOfDestination
|
||||
HC.nctsHC_CountryOfDispatch = exg.exg_CountryOfDispatch
|
||||
|
||||
HC.nctsHC_PreviousDocument_1_Type = "N830"
|
||||
HC.nctsHC_PreviousDocument_1_ReferenceNumber = exg.exg_MRN
|
||||
'HC.nctsHC_PreviousDocument_1_ComplementOfInformation =
|
||||
|
||||
|
||||
For Each EXG_POS In exg.exg_POSITION
|
||||
Dim HC_ITEM As New cDakosy_NCTSOut004_HouseConsignment_ConsignmentItem
|
||||
|
||||
HC_ITEM.nctsHCCI_CommodityCode = EXG_POS.exgPos_CommodityCode
|
||||
HC_ITEM.nctsHCCI_DescriptionOfGoods = EXG_POS.exgPos_DescriptionOfGoods
|
||||
|
||||
HC_ITEM.nctsHCCI_GrossMass = EXG_POS.exgPos_GrossMass
|
||||
HC_ITEM.nctsHCCI_NetMass = EXG_POS.exgPos_NetMass
|
||||
|
||||
If EXG_POS.exgPos_PreviousProcedure IsNot Nothing And EXG_POS.exgPos_RequestedProcedure IsNot Nothing Then
|
||||
HC_ITEM.nctsHCCI_DeclarationType = DetermineTransitProcedure(EXG_POS.exgPos_RequestedProcedure, EXG_POS.exgPos_PreviousProcedure)
|
||||
End If
|
||||
|
||||
If exg.exg_AutoTranslate Then
|
||||
If exg.exg_ForceTranslate Then
|
||||
cDeeplAPI.deepl_Translate(EXG_POS.exgPos_DescriptionOfGoods, HC_ITEM.nctsHCCI_DescriptionOfGoods, "DE")
|
||||
Else
|
||||
HC_ITEM.nctsHCCI_DescriptionOfGoods = cTariffKN8_Interface.getKN8FromTNR(EXG_POS.exgPos_CommodityCode)
|
||||
End If
|
||||
End If
|
||||
|
||||
For Each EXG_PK In EXG_POS.exgPos_PACKAGING
|
||||
Dim HC_PK = New cDakosy_NCTSOut004_HouseConsignment_ConsignmentItem_Packaging
|
||||
|
||||
HC_PK.nctsHCCIPK_NumberOfPackages = EXG_PK.exgPosPk_NumberOfPackages
|
||||
HC_PK.nctsHCCIPK_TypeOfPackages = EXG_PK.exgPosPk_TypeOfPackages
|
||||
HC_PK.nctsHCCIPK_ShippingMarks = EXG_PK.exgPosPk_ShippingMarks
|
||||
|
||||
HC_ITEM.nctsHCCI_PACKAGING.Add(HC_PK)
|
||||
|
||||
Next
|
||||
|
||||
HC.nctsWP_CONSIGNMENT_ITEM.Add(HC_ITEM)
|
||||
Next
|
||||
NCTS_OUT.ncts_HOUSE_CONSIGNMENT.Add(HC)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
' NCTS_OUT.INSERT_HouseConsignment()
|
||||
|
||||
|
||||
'--------Declarationtype-----------------------------------------------
|
||||
Dim declType = GetDeclarationType(NCTS_OUT.ncts_HOUSE_CONSIGNMENT)
|
||||
If declType <> "" Then
|
||||
emptyAllDeclarationItems(NCTS_OUT.ncts_HOUSE_CONSIGNMENT) ' Leert alle DeclType in den Pos
|
||||
NCTS_OUT.ncts_Declarationtype = declType ' Sezt es im Kopf
|
||||
Else
|
||||
NCTS_OUT.ncts_Declarationtype = "T-" ' Sezt es im Kopf
|
||||
End If
|
||||
'----------------------------------------------------------------------
|
||||
End If
|
||||
|
||||
Return NCTS_OUT
|
||||
End Function
|
||||
' Funktion zur Bestimmung des Declaration Type
|
||||
Shared Function GetDeclarationType(HC_LIST As List(Of cDakosy_NCTSOut004_HouseConsignment)) As String
|
||||
Dim declType As String = Nothing
|
||||
Dim isConsistent As Boolean = True ' Flag zur Überprüfung der Konsistenz
|
||||
|
||||
' Iteration über alle Positionen
|
||||
For Each HC In HC_LIST
|
||||
|
||||
For Each HC_ITEM In HC.nctsWP_CONSIGNMENT_ITEM
|
||||
Dim currentType = HC_ITEM.nctsHCCI_DeclarationType
|
||||
|
||||
' Abbruch, wenn ein Wert leer oder Nothing ist
|
||||
If String.IsNullOrWhiteSpace(currentType) Then
|
||||
isConsistent = False
|
||||
Exit For
|
||||
End If
|
||||
|
||||
' Setze declType, wenn noch nicht gesetzt
|
||||
If declType Is Nothing Then
|
||||
declType = currentType
|
||||
ElseIf declType <> currentType Then
|
||||
' Unterschiedlicher Wert gefunden → Abbruch
|
||||
isConsistent = False
|
||||
Exit For
|
||||
End If
|
||||
Next
|
||||
Next
|
||||
|
||||
' Rückgabe des einheitlichen declType oder leer, wenn inkonsistent
|
||||
If isConsistent AndAlso Not String.IsNullOrWhiteSpace(declType) Then
|
||||
Return declType
|
||||
Else
|
||||
Return ""
|
||||
End If
|
||||
End Function
|
||||
|
||||
|
||||
Shared Sub emptyAllDeclarationItems(ByRef HC_LIST As List(Of cDakosy_NCTSOut004_HouseConsignment))
|
||||
Dim declType As String = Nothing
|
||||
Dim isConsistent As Boolean = True ' Flag zur Überprüfung der Konsistenz
|
||||
|
||||
' Iteration über alle Positionen
|
||||
For Each HC In HC_LIST
|
||||
For Each HC_ITEM In HC.nctsWP_CONSIGNMENT_ITEM
|
||||
HC_ITEM.nctsHCCI_DeclarationType = ""
|
||||
Next
|
||||
Next
|
||||
|
||||
End Sub
|
||||
|
||||
Shared Function DetermineTransitProcedure(requestedProcedure As String, previousProcedure As String) As String
|
||||
' Entscheidungslogik für Transitverfahren (immer in der EU eröffnet)
|
||||
Select Case requestedProcedure
|
||||
Case "10" ' Ausfuhrverfahren
|
||||
If previousProcedure = "00" Then
|
||||
Return "T2" ' Ware ist weiterhin Unionsware, obwohl Ausfuhr vorgesehen ist
|
||||
ElseIf previousProcedure = "40" Then
|
||||
Return "T2" ' Ware im freien Verkehr (Unionsware)
|
||||
ElseIf previousProcedure = "61" Then
|
||||
Return "T1" ' Ware verlässt ein Zolllager (Nicht-Unionsware)
|
||||
Else
|
||||
Return "T2" ' Standardfall: Unionsware im Ausfuhrverfahren
|
||||
End If
|
||||
|
||||
Case "40" ' Überlassung zum freien Verkehr
|
||||
Return "T2" ' Ware wird Unionsware nach Import
|
||||
|
||||
Case "31" ' Versandverfahren
|
||||
Return "T-" ' Beibehaltung des ursprünglichen Status
|
||||
|
||||
Case "51" ' Passive Veredelung
|
||||
Return "T1" ' Rückkehr von Nicht-Unionsware nach Verarbeitung
|
||||
|
||||
Case Else
|
||||
Return "Unbekannt" ' Unbekannter Verfahrenscode
|
||||
End Select
|
||||
End Function
|
||||
|
||||
|
||||
End Class
|
||||
|
||||
Reference in New Issue
Block a user