diff --git a/SDL/My Project/AssemblyInfo.vb b/SDL/My Project/AssemblyInfo.vb index 64e75b4a..4eb74f7e 100644 --- a/SDL/My Project/AssemblyInfo.vb +++ b/SDL/My Project/AssemblyInfo.vb @@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices ' übernehmen, indem Sie "*" eingeben: ' - - + + diff --git a/VERAG_PROG_ALLGEMEIN/Schnittstellen/Modaltrans/cModalTransBase.vb b/VERAG_PROG_ALLGEMEIN/Schnittstellen/Modaltrans/cModalTransBase.vb new file mode 100644 index 00000000..b1ed1cbf --- /dev/null +++ b/VERAG_PROG_ALLGEMEIN/Schnittstellen/Modaltrans/cModalTransBase.vb @@ -0,0 +1,49 @@ +Imports Newtonsoft.Json +Imports Newtonsoft.Json.Linq + +Public Class cModalTransBase + Public Shared baseUrl As String = "https://app.modaltrans.com" + Shared http As New Chilkat.Http() + + + Private Shared API_Mail = "mdlapi@verag.ag" + Private Shared API_PWD = "Verag2023" + + + Public Sub New() + VERAG_PROG_ALLGEMEIN.cChilkat_Helper.UnlockCilkat() + + http.SetRequestHeader("Content-Type", "application/json") + End Sub + + ' Methode zur Authentifizierung und Abruf des Tokens + Public Shared Function Authenticate(ByRef authToken As String) As Boolean + Dim http As New Chilkat.Http() + Dim req As New Chilkat.HttpRequest() + req.AddParam("email", API_Mail) + req.AddParam("password", API_PWD) + + ' Wichtig: Kein JSON, sondern x-www-form-urlencoded! + req.ContentType = "application/x-www-form-urlencoded" + + + Dim resp As Chilkat.HttpResponse = http.PostUrlEncoded(baseUrl & "/api/v1/login", req) + + If resp IsNot Nothing Then + Try + Dim json = JsonConvert.DeserializeObject(Of JObject)(resp.BodyStr) + authToken = json.SelectToken("auth_token")?.ToString() + Console.WriteLine("Token: " & authToken) + If Not String.IsNullOrEmpty(authToken) Then + Return True + End If + Catch ex As Exception + Console.WriteLine("Fehler beim Parsen des Tokens: " & ex.Message) + End Try + Else + Console.WriteLine("Authentifizierungsfehler: " & http.LastErrorText) + End If + + Return False + End Function +End Class \ No newline at end of file diff --git a/VERAG_PROG_ALLGEMEIN/Schnittstellen/Modaltrans/cModalTransIMPORT.vb b/VERAG_PROG_ALLGEMEIN/Schnittstellen/Modaltrans/cModalTransIMPORT.vb new file mode 100644 index 00000000..cc19c725 --- /dev/null +++ b/VERAG_PROG_ALLGEMEIN/Schnittstellen/Modaltrans/cModalTransIMPORT.vb @@ -0,0 +1,525 @@ +Imports Chilkat +Imports Newtonsoft.Json +Imports Newtonsoft.Json.Linq +Public Class cModalTransIMPORT + ' VB.NET Klasse zur vollständigen Abbildung der Declaration Data laut Modaltrans API + Public Class cMT_IMP_CustomsDeclarationRequest + Public Property auto_send As Boolean? + Public Property badge_code As String + Public Property service_code As String + Public Property doc_type As String + Public Property declaration_type As String + Public Property commercial_ref As String + Public Property ducr As String + Public Property mucr As String + Public Property ducr_part As String + Public Property declarant_eori As String + Public Property declarant_name As String + Public Property declarant_address As String + Public Property declarant_city_name As String + Public Property declarant_country_id As String + Public Property declarant_postcode As String + Public Property declarant_rep As String + Public Property export_country_id As String + Public Property consignor_eori As String + Public Property consignor_name As String + Public Property consignor_address As String + Public Property consignor_city_name As String + Public Property consignor_country_id As String + Public Property consignor_postcode As String + Public Property multiple_consignor As Boolean? + Public Property import_country_id As String + Public Property consignee_eori As String + Public Property consignee_name As String + Public Property consignee_address As String + Public Property consignee_city_name As String + Public Property consignee_country_id As String + Public Property consignee_postcode As String + Public Property multiple_consignee As Boolean? + Public Property invoice_amount As Decimal? + Public Property invoice_curr As String + Public Property goods_location As String + Public Property border_transport_type As String + Public Property border_vehicle_coun As String + Public Property border_vehicle_code As String + Public Property inland_transport_type As String + Public Property container_no As String + Public Property gvms_interested As Boolean? + Public Property freight_amount As Decimal? + Public Property freight_curr As String + Public Property payment_method As String + Public Property carrier_eori As String + Public Property carrier_name As String + Public Property carrier_address As String + Public Property carrier_city_name As String + Public Property carrier_country_id As String + Public Property carrier_postcode As String + Public Property total_packages As Integer + Public Property nature_of_transaction As String + Public Property premises_code As String + Public Property first_dan_no As String + Public Property second_dan_no As String + Public Property insurance_amount As Decimal? + Public Property other_amounts As Decimal? + Public Property airport_code As String + Public Property apportment_indicator As String + Public Property total_gross_weight As Decimal? + Public Property total_net_weight As Decimal? + Public Property airfreight_cost As Decimal? + Public Property insurance_curr As String + Public Property other_amounts_curr As String + Public Property vat_adjustment As Decimal? + Public Property vat_adjustment_curr As String + Public Property discount_amount As Decimal? + Public Property discount_curr As String + Public Property discount_rate As Decimal? + Public Property warehouse_type As String + Public Property incoterm As String + Public Property incoterm_location As String + Public Property trader_ref As String + Public Property arrival_transport_type As String + Public Property guarantee_code As String + Public Property guarantee_reference As String + Public Property evrim_xml As String + Public Property goods_attributes As List(Of cMT_IMP_GoodsItem) + Public Property parties_attributes As List(Of cMT_IMP_PartyAttribute) + Public Property trader_additions_attributes As List(Of cMT_IMP_TraderAddition) + End Class + + Public Class cMT_IMP_GoodsItem + Public Property commodity As String + Public Property consignee_name As String + Public Property sender_name As String + Public Property packs_attributes As List(Of cMT_IMP_PackAttribute) + End Class + + Public Class cMT_IMP_PackAttribute + Public Property pack_type As String + Public Property notes As String + End Class + + Public Class cMT_IMP_PartyAttribute + Public Property name As String + Public Property eori As String + Public Property role As String + End Class + + Public Class cMT_IMP_TraderAddition + Public Property field As String + Public Property value As String + Public Property type As String + Public Property description As String + End Class + + + Public Class cMT_IMP_CustomsDeclarationResponse + Public Property status As String + Public Property declarationId As String + Public Property message As String + + ' Optional: wenn die API weitere Felder liefert + Public Property referenceNumber As String + Public Property createdAt As DateTime? + Public Property updatedAt As DateTime? + Public Property declaration_data As cMT_IMP_CustomsDeclarationRequest + End Class + + + Public Class cModaltransApiClient_IMPORT + + + Private baseUrl As String = "https://app.modaltrans.com" + Private http As New Chilkat.Http() + Private authToken As String + + + + + Public Sub New() + VERAG_PROG_ALLGEMEIN.cChilkat_Helper.UnlockCilkat() + + http.SetRequestHeader("Content-Type", "application/json") + End Sub + + + + ' 📤 Senden der Zollanmeldung + Public Function SendDeclaration(request As cMT_IMP_CustomsDeclarationRequest) As cMT_IMP_CustomsDeclarationResponse + Dim result As New cMT_IMP_CustomsDeclarationResponse() + + If Not cModalTransBase.Authenticate(authToken) Then + result.status = "Error" + result.message = "❌ Authentifizierung fehlgeschlagen." + Console.WriteLine(result.message) + Return result + End If + http.SetRequestHeader("Authorization", "Bearer " & authToken) + + Dim jsonPayload As String = JsonConvert.SerializeObject(New With {.declaration_data = request}) + Dim url As String = baseUrl & "/api/v1/customs_declarations" + + Dim resp As Chilkat.HttpResponse = http.PostJson(url, jsonPayload) + + If resp Is Nothing Then + result.status = "Error" + result.message = "❌ Fehler beim Senden: " & http.LastErrorText + Console.WriteLine(result.message) + Return result + End If + + Select Case resp.StatusCode + Case 201 ' Created + Try + result = JsonConvert.DeserializeObject(Of cMT_IMP_CustomsDeclarationResponse)(resp.BodyStr) + result.status = "Success" + Console.WriteLine("✅ Zollanmeldung erfolgreich erstellt.") + Catch ex As Exception + result.status = "Error" + result.message = "❌ Fehler beim Parsen der Erfolgsantwort: " & ex.Message + Console.WriteLine(result.message) + End Try + + Case 400 + result.status = "Bad Request" + result.message = resp.BodyStr + Console.WriteLine("⚠️ Ungültige Anfrage (400): " & result.message) + + Case 401 + result.status = "Unauthorized" + result.message = "❌ Nicht autorisiert (401)" + Console.WriteLine(result.message) + + Case 422 + result.status = "Validation Error" + result.message = resp.BodyStr + Console.WriteLine("⚠️ Validierungsfehler (422): " & result.message) + + Case Else + result.status = "Error" + result.message = $"❌ Unerwarteter Fehler: {resp.StatusCode}" & vbCrLf & resp.BodyStr + Console.WriteLine(result.message) + End Select + + Return result + End Function + + ' 📥 Zollanmeldung abrufen + Public Function GetDeclaration(declarationId As String) As cMT_IMP_CustomsDeclarationRequest + If Not cModalTransBase.Authenticate(authToken) Then + Console.WriteLine("❌ Authentifizierung fehlgeschlagen.") + Return Nothing + End If + http.SetRequestHeader("Authorization", "Bearer " & authToken) + + Dim url As String = $"{baseUrl}/api/v1/customs_declarations/{declarationId}" + Dim responseStr As String = http.QuickGetStr(url) + + If Not http.LastMethodSuccess Then + Console.WriteLine("❌ Fehler beim Abrufen: " & http.LastErrorText) + Return Nothing + End If + + Dim statusCode As Integer = http.LastStatus + Select Case statusCode + Case 200 + Try + Dim json = JsonConvert.DeserializeObject(Of JObject)(responseStr) + Dim data = json.SelectToken("declaration_data") + Dim result = data.ToObject(Of cMT_IMP_CustomsDeclarationRequest)() + Console.WriteLine("✅ Zollanmeldung erfolgreich abgerufen.") + Return result + Catch ex As Exception + Console.WriteLine("❌ Fehler beim Parsen: " & ex.Message) + End Try + Case 404 + Console.WriteLine("⚠️ Zollanmeldung nicht gefunden (404).") + Case 401 + Console.WriteLine("❌ Nicht autorisiert (401).") + Case Else + Console.WriteLine($"❌ Unerwarteter Fehler: {statusCode}") + Console.WriteLine(responseStr) + End Select + + Return Nothing + End Function + + Public Function ListDeclarationsFromDate(fromDate As DateTime, Optional page As Integer = 1) As List(Of cMT_IMP_CustomsDeclarationResponse) + Dim declarations As New List(Of cMT_IMP_CustomsDeclarationResponse)() + + If Not cModalTransBase.Authenticate(authToken) Then + Throw New Exception("Authentifizierung fehlgeschlagen") + End If + http.SetRequestHeader("Authorization", "Bearer " & authToken) + + + Dim url As String = $"{baseUrl}/api/v1/customs_declarations?from_date={fromDate:yyyy-MM-dd}&page={page}" + + Dim responseStr As String = http.QuickGetStr(url) + + If http.LastMethodSuccess Then + Try + ' Optional: falls die Antwort als { data: [ ... ] } zurückkommt + Dim json = JsonConvert.DeserializeObject(Of JObject)(responseStr) + Dim dataArray = json.SelectToken("data") + If dataArray IsNot Nothing Then + declarations = dataArray.ToObject(Of List(Of cMT_IMP_CustomsDeclarationResponse))() + Else + ' Falls direkt eine Liste zurückkommt + declarations = JsonConvert.DeserializeObject(Of List(Of cMT_IMP_CustomsDeclarationResponse))(responseStr) + End If + Catch ex As Exception + Throw New Exception("Fehler beim Parsen der Antwort: " & ex.Message) + End Try + Else + Throw New Exception("Fehler beim Abruf: " & http.LastErrorText) + End If + + + Return declarations + End Function + + End Class + + + + + + '-------------------------------------------------------------------------------------------------- + + + Public Shared Sub CreateAndSendMinimalImportDeclaration(LRN) + ' Objekt mit allen notwendigen Pflichtfeldern befüllen + Dim importRequest As New cMT_IMP_CustomsDeclarationRequest With { + .doc_type = "import", + .declaration_type = "IMA", + .declarant_eori = "GB123456789000", + .declarant_name = "Demo Importer Ltd.", + .export_country_id = "TR", + .consignor_name = "Nimbo Teknoloji Ltd.", + .consignor_address = "Techno Street 12", + .consignor_city_name = "Istanbul", + .consignor_country_id = "TR", + .consignor_postcode = "34000", + .import_country_id = "GB", + .consignee_name = "Demo Importer Ltd.", + .consignee_address = "Import Road 34", + .consignee_city_name = "London", + .consignee_country_id = "GB", + .consignee_postcode = "W1A 1AA", + .goods_location = "GBFXT", + .border_transport_type = "3", ' z. B. Straße + .total_packages = 5, + .trader_ref = LRN, + .ducr = LRN + } + + ' API-Client erstellen (mit Benutzer & Passwort in der Klasse eingebaut) + Dim client As New cModaltransApiClient_IMPORT() + + ' Senden und Ergebnis anzeigen + Dim response As cMT_IMP_CustomsDeclarationResponse = client.SendDeclaration(importRequest) + + If response IsNot Nothing Then + Console.WriteLine("Status: " & response.status) + Console.WriteLine("Message: " & response.message) + Console.WriteLine("Declaration ID: " & response.declarationId) + Else + Console.WriteLine("Keine Antwort erhalten.") + End If + End Sub + + + Public Shared Function ceateAndSend_IMP_FromSENDUNG(LRN As String, SND As cSendungen) As Boolean + If SND.tblSnd_AvisoID <= 0 Then Return False + Dim AVISO As cAviso = (New cAvisoDAL).LesenAviso(SND.tblSnd_AvisoID, "") + Return ceateAndSend_IMP_FromSENDUNG(LRN, SND, AVISO) + End Function + + + Public Shared Function ceateAndSend_IMP_FromSENDUNG(LRN As String, SND As cSendungen, AVISO As cAviso) As Boolean + ' Objekt mit allen notwendigen Pflichtfeldern befüllen + Dim MT_IMP As New cMT_IMP_CustomsDeclarationRequest With { + .doc_type = "import", + .declaration_type = "IMD", ' IMA-_> Arrived + .declarant_eori = VERAG_PROG_ALLGEMEIN.cAllgemein.UK_EORI_LTD, + .declarant_name = "VERAG-UNISPED Ltd", + .declarant_rep = "2", + .goods_location = "GBAUDEUDEUDEU", + .import_country_id = "GB", + .total_packages = 5, + .nature_of_transaction = "11", ' Kaufgeschäft 11 Outright purchase/sale + .trader_ref = LRN, + .ducr = LRN + } + + Dim ioReference = LRN & Now.ToString("ddMMyyyy_HHmmss") + + + Select Case If(AVISO.Transportmittelart, "") + Case "CONTAINER" + MT_IMP.border_transport_type = "1" ' z. B. Ocean + MT_IMP.arrival_transport_type = "10" + Case Else + MT_IMP.border_transport_type = "6" ' z. B. 3 Straße '?6 RORO?? + MT_IMP.arrival_transport_type = "30" + + End Select + + MT_IMP.inland_transport_type = "3" ' z. B. Straße '?6 RORO?? + MT_IMP.border_vehicle_code = AVISO.LKW_Nr + MT_IMP.border_vehicle_coun = AVISO.LKW_Nationalitaet + + + + If SND.tblSnd_EmpfaengerKdNr > 0 Then + Dim AD As New cAdressen(SND.tblSnd_EmpfaengerKdNr) + Dim KD As New cKunde(SND.tblSnd_EmpfaengerKdNr) + Dim CN As New VERAG_PROG_ALLGEMEIN.cRelayHub.cRelayHubAddress + CN.addressType = "CN" + MT_IMP.consignee_eori = If(KD.EORITIN, "") + MT_IMP.consignee_name = AD.Name_1 + MT_IMP.consignee_address = AD.Straße + MT_IMP.consignee_postcode = AD.PLZ + MT_IMP.consignee_city_name = AD.Ort + MT_IMP.consignee_country_id = cProgramFunctions.getISO2Land(AD.LandKz) + + End If + + If SND.tblSnd_AbsenderKdNr > 0 Then + Dim AD As New cAdressen(SND.tblSnd_AbsenderKdNr) + Dim KD As New cKunde(SND.tblSnd_AbsenderKdNr) + Dim CZ As New VERAG_PROG_ALLGEMEIN.cRelayHub.cRelayHubAddress + + MT_IMP.consignor_eori = If(KD.EORITIN, "") + MT_IMP.consignor_name = AD.Name_1 + MT_IMP.consignor_address = AD.Straße + MT_IMP.consignor_postcode = AD.PLZ + MT_IMP.consignor_city_name = AD.Ort + MT_IMP.consignor_country_id = cProgramFunctions.getISO2Land(AD.LandKz) + MT_IMP.export_country_id = MT_IMP.consignor_country_id + End If + + + + ' API-Client erstellen (mit Benutzer & Passwort in der Klasse eingebaut) + Dim client As New cModaltransApiClient_IMPORT() + + ' Senden und Ergebnis anzeigen + Dim response As cMT_IMP_CustomsDeclarationResponse = client.SendDeclaration(MT_IMP) + + If response IsNot Nothing Then + Console.WriteLine("Status: " & response.status) + Console.WriteLine("Message: " & response.message) + Console.WriteLine("Declaration ID: " & response.declarationId) + ' Console.WriteLine("Declaration DUCR: " & response.declaration_data.ducr) + + If response.status = "Success" Then + MsgBox(response.message) + Else + MsgBox(response.message) + Return False + End If + + Return True + Else + MsgBox("Keine Antwort erhalten.") + Console.WriteLine("Keine Antwort erhalten.") + End If + Return False + + End Function + + + + + + + Public Shared Function ceateAndSend_EXP_FromSENDUNG(LRN As String, SND As cSendungen) As Boolean + If SND.tblSnd_AvisoID <= 0 Then Return False + Dim AVISO As cAviso = (New cAvisoDAL).LesenAviso(SND.tblSnd_AvisoID, "") + Return ceateAndSend_EXP_FromSENDUNG(LRN, SND, AVISO) + End Function + + + Public Shared Function ceateAndSend_EXP_FromSENDUNG(LRN As String, SND As cSendungen, AVISO As cAviso) As Boolean + ' Objekt mit allen notwendigen Pflichtfeldern befüllen + Dim MT_IMP As New cMT_IMP_CustomsDeclarationRequest With { + .doc_type = "export", + .declaration_type = "EXA", ' IMA-_> Arrived + .declarant_eori = VERAG_PROG_ALLGEMEIN.cAllgemein.UK_EORI_LTD, + .declarant_name = "VERAG-UNISPED Ltd", + .declarant_rep = "2", + .goods_location = "GBAUDEUDEUDEU", + .total_packages = 5, + .nature_of_transaction = "11", ' Kaufgeschäft 11 Outright purchase/sale + .trader_ref = LRN, + .ducr = LRN + } + + Dim ioReference = LRN & Now.ToString("ddMMyyyy_HHmmss") + + + Select Case If(AVISO.Transportmittelart, "") + Case "CONTAINER" + MT_IMP.border_transport_type = "1" ' z. B. Ocean + MT_IMP.arrival_transport_type = "10" + Case Else + MT_IMP.border_transport_type = "6" ' z. B. 3 Straße '?6 RORO?? + MT_IMP.arrival_transport_type = "30" + + End Select + + MT_IMP.inland_transport_type = "3" ' z. B. Straße '?6 RORO?? + MT_IMP.border_vehicle_code = AVISO.LKW_Nr + MT_IMP.border_vehicle_coun = AVISO.LKW_Nationalitaet + + + + If SND.tblSnd_EmpfaengerKdNr > 0 Then + Dim AD As New cAdressen(SND.tblSnd_EmpfaengerKdNr) + Dim KD As New cKunde(SND.tblSnd_EmpfaengerKdNr) + Dim CN As New VERAG_PROG_ALLGEMEIN.cRelayHub.cRelayHubAddress + CN.addressType = "CN" + MT_IMP.consignee_eori = If(KD.EORITIN, "") + MT_IMP.consignee_name = AD.Name_1 + MT_IMP.consignee_address = AD.Straße + MT_IMP.consignee_postcode = AD.PLZ + MT_IMP.consignee_city_name = AD.Ort + MT_IMP.consignee_country_id = cProgramFunctions.getISO2Land(AD.LandKz) + + End If + + If SND.tblSnd_AbsenderKdNr > 0 Then + Dim AD As New cAdressen(SND.tblSnd_AbsenderKdNr) + Dim KD As New cKunde(SND.tblSnd_AbsenderKdNr) + Dim CZ As New VERAG_PROG_ALLGEMEIN.cRelayHub.cRelayHubAddress + + MT_IMP.consignor_eori = If(KD.EORITIN, "") + MT_IMP.consignor_name = AD.Name_1 + MT_IMP.consignor_address = AD.Straße + MT_IMP.consignor_postcode = AD.PLZ + MT_IMP.consignor_city_name = AD.Ort + MT_IMP.consignor_country_id = cProgramFunctions.getISO2Land(AD.LandKz) + MT_IMP.export_country_id = MT_IMP.consignor_country_id + MT_IMP.import_country_id = MT_IMP.consignor_country_id 'muss lt. API mitgegeben werden + End If + + + + ' API-Client erstellen (mit Benutzer & Passwort in der Klasse eingebaut) + Dim client As New cModaltransApiClient_IMPORT() + + ' Senden und Ergebnis anzeigen + Dim response As cMT_IMP_CustomsDeclarationResponse = client.SendDeclaration(MT_IMP) + + If response IsNot Nothing Then + Console.WriteLine("Status: " & response.status) + Console.WriteLine("Message: " & response.message) + Console.WriteLine("Declaration ID: " & response.declarationId) + Return True + Else + Console.WriteLine("Keine Antwort erhalten.") + End If + Return False + End Function +End Class \ No newline at end of file diff --git a/VERAG_PROG_ALLGEMEIN/Schnittstellen/Modaltrans/cModalTransNCTS.vb b/VERAG_PROG_ALLGEMEIN/Schnittstellen/Modaltrans/cModalTransNCTS.vb new file mode 100644 index 00000000..a4f5d47c --- /dev/null +++ b/VERAG_PROG_ALLGEMEIN/Schnittstellen/Modaltrans/cModalTransNCTS.vb @@ -0,0 +1,689 @@ +Imports Newtonsoft.Json +Imports Newtonsoft.Json.Linq + +Public Class cModalTransNCTS + ' Haupt-Requestklasse für NCTS-Versandverfahren + Public Class cMT_NCTS_DeclarationRequest + ' Nachricht + Public Property message_sender As String = "AVISO.APP" + Public Property message_sender_code As String = "" '"ITTR0000000000153" + Public Property message_recipient As String = "" '"NTA.BG" + Public Property message_recipient_code As String '= "BG005804" + Public Property message_identification As String = "BG015C" + Public Property message_type As String = "BG015C" + + ' Zusätzliche Pflichtfelder lt. Fehlermeldung + Public Property destination_country_id As String + Public Property trans_method As String + Public Property vehicle_id As String + Public Property trailer_id As String + + ' TransitOperation + Public Property lrn As String = "LRN-DEMO-12345" + Public Property declaration_type As String = "T1" + Public Property additional_declaration_type As String = "A" + Public Property security_level As String = "3" + Public Property reduced_dataset_indicator As String = "0" + Public Property binding_itinerary As String = "0" + + ' Zollstellen + Public Property departure_office As String + Public Property destination_office As String + Public Property transit_office_ref As String + Public Property transit_arrival_est As String + + ' Inhaber des Verfahrens + Public Property holder_eori As String + Public Property holder_name As String + Public Property holder_address As String + Public Property holder_postcode As String + Public Property holder_city As String + Public Property holder_country As String + Public Property holder_contact_name As String + Public Property holder_contact_phone As String + Public Property holder_contact_email As String + + ' Guarantee + Public Property guarantee_type As String + Public Property guarantee_sequence As String + Public Property guarantee_reference_sequence As String + Public Property guarantee_grn As String + Public Property guarantee_access_code As String + Public Property guarantee_amount As String + Public Property guarantee_currency As String + + ' Consignment + Public Property consignment_country_of_destination As String + Public Property consignment_container_indicator As String + Public Property consignment_inland_mode As String + Public Property consignment_border_mode As String + Public Property consignment_gross_mass As String + + ' Carrier + Public Property carrier_identification_number As String + + ' Consignor + Public Property consignor_name As String + Public Property consignor_street As String + Public Property consignor_postcode As String + Public Property consignor_city As String + Public Property consignor_country As String + + ' Consignee + Public Property consignee_name As String + Public Property consignee_street As String + Public Property consignee_postcode As String + Public Property consignee_city As String + Public Property consignee_country As String + + ' Transportmittel Abgangsort + Public Property departure_transport_sequence As String + Public Property departure_transport_type_id As String + Public Property departure_transport_number As String + Public Property departure_transport_nationality As String + + ' Routenländer + Public Property routing_countries As List(Of String) + + ' Grenzüberschreitendes Transportmittel + Public Property border_transport_customs_office As String + Public Property border_transport_type_id As String + Public Property border_transport_number As String + Public Property border_transport_nationality As String + + ' Beladungs- / Entladeort + Public Property loading_country As String + Public Property loading_location As String + Public Property unloading_country As String + Public Property unloading_location As String + + ' Steuer + Public Property tax_total_sum As String + Public Property tax_entries As List(Of cMT_NCTS_Tax) + + ' Hausversand / Warenpositionen + Public Property house_consignments As List(Of cMT_NCTS_HouseConsignment) + End Class + + Public Class cMT_NCTS_Tax + Public Property sequence_number As String + Public Property tax_type As String + Public Property tax_sum As String + End Class + + Public Class cMT_NCTS_HouseConsignment + Public Property sequence_number As String + Public Property gross_mass As String + Public Property items As List(Of cMT_NCTS_Item) + End Class + + Public Class cMT_NCTS_Item + Public Property goods_item_number As String + Public Property declaration_goods_item_number As String + Public Property description As String + Public Property hs_code As String + Public Property gross_mass As String + Public Property net_mass As String + Public Property packages As List(Of cMT_NCTS_Package) + Public Property supporting_documents As List(Of cMT_NCTS_Document) + Public Property transport_documents As List(Of cMT_NCTS_Document) + End Class + + Public Class cMT_NCTS_Package + Public Property sequence_number As String + Public Property package_type As String + Public Property number_of_packages As String + Public Property marks As String + End Class + + Public Class cMT_NCTS_Document + Public Property sequence_number As String + Public Property doc_type As String + Public Property reference As String + End Class + + + ' Response-Klasse für NCTS-Antworten + Public Class cMT_NCTS_DeclarationResponse + Public Property status As String + Public Property message As String + Public Property declaration_id As String + Public Property mrn As String + Public Property lrn As String + Public Property created_at As String + End Class + + + Public Class cMT_NCTS_ApiClient + Private http As New Chilkat.Http() + Private authToken As String + + Public Sub New() + VERAG_PROG_ALLGEMEIN.cChilkat_Helper.UnlockCilkat() + + http.SetRequestHeader("Content-Type", "application/json") + End Sub + + + + ' SEND NCTS Declaration using object and convert to wrapped XML JSON + Public Function SendNCTSDeclaration(declaration As cMT_NCTS_DeclarationRequest) As cMT_NCTS_DeclarationResponse + Dim result As New cMT_NCTS_DeclarationResponse() + + If Not cModalTransBase.Authenticate(authToken) Then + result.status = "Error" + result.message = "❌ Authentifizierung fehlgeschlagen." + Return result + End If + + ' XML manuell generieren aus dem Objekt + + Dim xml As New Chilkat.Xml() + xml.Tag = "ie:BG015C" + xml.AddAttribute("xmlns:ie", "http://ncts.dgtaxud.ec") + + xml.UpdateChildContent("messageSender", declaration.message_sender) + xml.UpdateChildContent("messageSenderCode", declaration.message_sender_code) + xml.UpdateChildContent("messageRecipient", declaration.message_recipient) + xml.UpdateChildContent("messageRecipientCode", declaration.message_recipient_code) + xml.UpdateChildContent("preparationDateAndTime", DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss")) + xml.UpdateChildContent("messageIdentification", declaration.message_identification) + xml.UpdateChildContent("messageType", declaration.message_type) + + Dim transitOp = xml.NewChild("TransitOperation", "") + transitOp.UpdateChildContent("LRN", declaration.lrn) + transitOp.UpdateChildContent("declarationType", declaration.declaration_type) + transitOp.UpdateChildContent("additionalDeclarationType", declaration.additional_declaration_type) + transitOp.UpdateChildContent("security", declaration.security_level) + transitOp.UpdateChildContent("reducedDatasetIndicator", declaration.reduced_dataset_indicator) + transitOp.UpdateChildContent("bindingItinerary", declaration.binding_itinerary) + MsgBox(declaration.vehicle_id) + xml.UpdateChildContent("vehicleId", declaration.vehicle_id) + xml.UpdateChildContent("trailerId", declaration.trailer_id) + xml.UpdateChildContent("CustomsOfficeOfDeparture/referenceNumber", declaration.departure_office) + xml.UpdateChildContent("CustomsOfficeOfDestinationDeclared/referenceNumber", declaration.destination_office) + + If Not String.IsNullOrWhiteSpace(declaration.transit_office_ref) Then + Dim transitOffice = xml.NewChild("CustomsOfficeOfTransitDeclared", "") + transitOffice.UpdateChildContent("sequenceNumber", "1") + transitOffice.UpdateChildContent("referenceNumber", declaration.transit_office_ref) + transitOffice.UpdateChildContent("arrivalDateAndTimeEstimated", declaration.transit_arrival_est) + End If + + Dim holder = xml.NewChild("HolderOfTheTransitProcedure", "") + holder.UpdateChildContent("identificationNumber", declaration.holder_eori) + holder.UpdateChildContent("name", declaration.holder_name) + Dim holderAddr = holder.NewChild("Address", "") + holderAddr.UpdateChildContent("streetAndNumber", declaration.holder_address) + holderAddr.UpdateChildContent("postcode", declaration.holder_postcode) + holderAddr.UpdateChildContent("city", declaration.holder_city) + holderAddr.UpdateChildContent("country", declaration.holder_country) + + If Not String.IsNullOrWhiteSpace(declaration.holder_contact_name) Then + Dim contact = holder.NewChild("ContactPerson", "") + contact.UpdateChildContent("name", declaration.holder_contact_name) + contact.UpdateChildContent("phoneNumber", declaration.holder_contact_phone) + contact.UpdateChildContent("eMailAddress", declaration.holder_contact_email) + End If + + Dim guarantee = xml.NewChild("Guarantee", "") + guarantee.UpdateChildContent("sequenceNumber", declaration.guarantee_sequence) + guarantee.UpdateChildContent("guaranteeType", declaration.guarantee_type) + Dim gr = guarantee.NewChild("GuaranteeReference", "") + gr.UpdateChildContent("sequenceNumber", declaration.guarantee_reference_sequence) + gr.UpdateChildContent("GRN", declaration.guarantee_grn) + gr.UpdateChildContent("accessCode", declaration.guarantee_access_code) + gr.UpdateChildContent("amountToBeCovered", declaration.guarantee_amount) + gr.UpdateChildContent("currency", declaration.guarantee_currency) + + Dim cons = xml.NewChild("Consignment", "") + cons.UpdateChildContent("countryOfDestination", declaration.consignment_country_of_destination) + cons.UpdateChildContent("containerIndicator", declaration.consignment_container_indicator) + cons.UpdateChildContent("inlandModeOfTransport", declaration.consignment_inland_mode) + cons.UpdateChildContent("modeOfTransportAtTheBorder", declaration.consignment_border_mode) + cons.UpdateChildContent("grossMass", declaration.consignment_gross_mass) + + Dim carrier = cons.NewChild("Carrier", "") + carrier.UpdateChildContent("identificationNumber", declaration.carrier_identification_number) + + Dim consignor = cons.NewChild("Consignor", "") + consignor.UpdateChildContent("name", declaration.consignor_name) + Dim consignorAddr = consignor.NewChild("Address", "") + consignorAddr.UpdateChildContent("streetAndNumber", declaration.consignor_street) + consignorAddr.UpdateChildContent("postcode", declaration.consignor_postcode) + consignorAddr.UpdateChildContent("city", declaration.consignor_city) + consignorAddr.UpdateChildContent("country", declaration.consignor_country) + + Dim consignee = cons.NewChild("Consignee", "") + consignee.UpdateChildContent("name", declaration.consignee_name) + Dim consigneeAddr = consignee.NewChild("Address", "") + consigneeAddr.UpdateChildContent("streetAndNumber", declaration.consignee_street) + consigneeAddr.UpdateChildContent("postcode", declaration.consignee_postcode) + consigneeAddr.UpdateChildContent("city", declaration.consignee_city) + consigneeAddr.UpdateChildContent("country", declaration.consignee_country) + + Dim dtm = cons.NewChild("DepartureTransportMeans", "") + dtm.UpdateChildContent("sequenceNumber", declaration.departure_transport_sequence) + dtm.UpdateChildContent("typeOfIdentification", declaration.departure_transport_type_id) + dtm.UpdateChildContent("identificationNumber", declaration.departure_transport_number) + dtm.UpdateChildContent("nationality", declaration.departure_transport_nationality) + + If declaration.routing_countries IsNot Nothing Then + For i = 0 To declaration.routing_countries.Count - 1 + Dim rc = cons.NewChild("CountryOfRoutingOfConsignment", "") + rc.UpdateChildContent("sequenceNumber", (i + 1).ToString()) + rc.UpdateChildContent("country", declaration.routing_countries(i)) + Next + End If + + Dim activeBorder = cons.NewChild("ActiveBorderTransportMeans", "") + activeBorder.UpdateChildContent("sequenceNumber", "1") + activeBorder.UpdateChildContent("customsOfficeAtBorderReferenceNumber", declaration.border_transport_customs_office) + activeBorder.UpdateChildContent("typeOfIdentification", declaration.border_transport_type_id) + activeBorder.UpdateChildContent("identificationNumber", declaration.border_transport_number) + activeBorder.UpdateChildContent("nationality", declaration.border_transport_nationality) + + Dim placeLoading = cons.NewChild("PlaceOfLoading", "") + placeLoading.UpdateChildContent("country", declaration.loading_country) + placeLoading.UpdateChildContent("location", declaration.loading_location) + + Dim placeUnloading = cons.NewChild("PlaceOfUnloading", "") + placeUnloading.UpdateChildContent("country", declaration.unloading_country) + placeUnloading.UpdateChildContent("location", declaration.unloading_location) + + Dim taxCalc = cons.NewChild("TaxCalculation", "") + taxCalc.UpdateChildContent("totalSum", declaration.tax_total_sum) + If declaration.tax_entries IsNot Nothing Then + For Each tax In declaration.tax_entries + Dim taxNode = taxCalc.NewChild("Tax", "") + taxNode.UpdateChildContent("sequenceNumber", tax.sequence_number) + taxNode.UpdateChildContent("taxType", tax.tax_type) + taxNode.UpdateChildContent("taxSum", tax.tax_sum) + Next + End If + + If declaration.house_consignments IsNot Nothing Then + For Each house In declaration.house_consignments + Dim hc = cons.NewChild("HouseConsignment", "") + hc.UpdateChildContent("sequenceNumber", house.sequence_number) + hc.UpdateChildContent("grossMass", house.gross_mass) + For Each item In house.items + Dim ci = hc.NewChild("ConsignmentItem", "") + ci.UpdateChildContent("goodsItemNumber", item.goods_item_number) + ci.UpdateChildContent("declarationGoodsItemNumber", item.declaration_goods_item_number) + Dim com = ci.NewChild("Commodity", "") + com.UpdateChildContent("descriptionOfGoods", item.description) + Dim cc = com.NewChild("CommodityCode", "") + cc.UpdateChildContent("harmonizedSystemSubHeadingCode", item.hs_code) + Dim gm = com.NewChild("GoodsMeasure", "") + gm.UpdateChildContent("grossMass", item.gross_mass) + gm.UpdateChildContent("netMass", item.net_mass) + For Each pkg In item.packages + Dim pk = ci.NewChild("Packaging", "") + pk.UpdateChildContent("sequenceNumber", pkg.sequence_number) + pk.UpdateChildContent("typeOfPackages", pkg.package_type) + pk.UpdateChildContent("numberOfPackages", pkg.number_of_packages) + pk.UpdateChildContent("shippingMarks", pkg.marks) + Next + For Each doc In item.supporting_documents + Dim d = ci.NewChild("SupportingDocument", "") + d.UpdateChildContent("sequenceNumber", doc.sequence_number) + d.UpdateChildContent("type", doc.doc_type) + d.UpdateChildContent("referenceNumber", doc.reference) + Next + For Each doc In item.transport_documents + Dim d = ci.NewChild("TransportDocument", "") + d.UpdateChildContent("sequenceNumber", doc.sequence_number) + d.UpdateChildContent("type", doc.doc_type) + d.UpdateChildContent("referenceNumber", doc.reference) + Next + Next + Next + End If + + Dim xmlContent As String = xml.GetXml() + Dim jsonPayload As String = JsonConvert.SerializeObject(New With { + .manifesto = New With { + .ncts_data = xmlContent + } + }) + + + + Dim url As String = cModalTransBase.baseUrl & "/api/v1/ncts_declarations" + http.SetRequestHeader("Authorization", "Bearer " & authToken) + http.SetRequestHeader("Content-Type", "application/json") + + Dim resp As Chilkat.HttpResponse = http.PostJson(url, jsonPayload) + + If resp Is Nothing Then + result.status = "Error" + result.message = "❌ Keine Verbindung: " & http.LastErrorText + Return result + End If + + Select Case resp.StatusCode + Case 201, 200 + result.status = "Success" + result.message = "✅ NCTS-Anmeldung erfolgreich übermittelt." + Dim json = JsonConvert.DeserializeObject(Of JObject)(resp.BodyStr) + result.lrn = json.SelectToken("lrn")?.ToString() + result.mrn = json.SelectToken("mrn")?.ToString() + result.declaration_id = json.SelectToken("declaration_id")?.ToString() + + Case 400, 422 + result.status = "Validation Error" + result.message = $"⚠️ Fehlerhafte Eingabe ({resp.StatusCode}): {resp.BodyStr}" + + Case 401 + result.status = "Unauthorized" + result.message = "❌ Zugriff verweigert – bitte Authentifizierung prüfen." + + Case Else + result.status = "Error" + result.message = $"❌ Unerwarteter Fehler ({resp.StatusCode}): {resp.BodyStr}" + End Select + + Console.WriteLine("Status: " & result.status) + Console.WriteLine("Nachricht: " & result.message) + Return result + End Function + + ' GET Declaration by ID / MRN / LRN / Ref + Public Function GetNCTSDeclaration(identifier As String) As cMT_NCTS_DeclarationRequest + If Not cModalTransBase.Authenticate(authToken) Then + Console.WriteLine("❌ Authentifizierung fehlgeschlagen.") + Return Nothing + End If + http.SetRequestHeader("Authorization", "Bearer " & authToken) + + Dim url = $"{cModalTransBase.baseUrl}/api/v1/ncts_declarations/{identifier}" + Dim resp = http.QuickGetObj(url) + + If resp Is Nothing Then + Console.WriteLine("❌ Keine Verbindung: " & http.LastErrorText) + Return Nothing + End If + + Select Case resp.StatusCode + Case 200 + Try + Dim json = JsonConvert.DeserializeObject(Of JObject)(resp.BodyStr) + Dim data = json.SelectToken("declaration_data") + Console.WriteLine("✅ NCTS-Anmeldung erfolgreich abgerufen.") + Return data.ToObject(Of cMT_NCTS_DeclarationRequest)() + Catch ex As Exception + Console.WriteLine("❌ Fehler beim Parsen: " & ex.Message) + End Try + Case 401 + Console.WriteLine("❌ Zugriff verweigert (401)") + Case 404 + Console.WriteLine("⚠️ Anmeldung nicht gefunden (404)") + Case Else + Console.WriteLine($"❌ Fehler ({resp.StatusCode}): {resp.BodyStr}") + End Select + + Return Nothing + End Function + + ' LIST all declarations + Public Function GetNCTSDeclarations(Optional page As Integer = 1) As List(Of cMT_NCTS_DeclarationResponse) + Dim list As New List(Of cMT_NCTS_DeclarationResponse)() + + If Not cModalTransBase.Authenticate(authToken) Then + Console.WriteLine("❌ Authentifizierung fehlgeschlagen.") + Return list + End If + http.SetRequestHeader("Authorization", "Bearer " & authToken) + + Dim url = $"{cModalTransBase.baseUrl}/api/v1/ncts_declarations?page={page}" + Dim resp = http.QuickGetObj(url) + + If resp Is Nothing Then + Console.WriteLine("❌ Keine Verbindung: " & http.LastErrorText) + Return list + End If + + Select Case resp.StatusCode + Case 200 + Try + Dim json = JsonConvert.DeserializeObject(Of JObject)(resp.BodyStr) + Dim data = json.SelectToken("data") + If data IsNot Nothing Then + list = data.ToObject(Of List(Of cMT_NCTS_DeclarationResponse))() + Console.WriteLine("✅ Liste der NCTS-Anmeldungen erfolgreich abgerufen.") + End If + Catch ex As Exception + Console.WriteLine("❌ Fehler beim Parsen der Liste: " & ex.Message) + End Try + Case 401 + Console.WriteLine("❌ Zugriff verweigert (401)") + Case Else + Console.WriteLine($"❌ Fehler ({resp.StatusCode}): {resp.BodyStr}") + End Select + + Return list + End Function + End Class + + + + Public Shared Function ceateAndSend_NCTS_FromSENDUNG(LRN As String, SND As cSendungen) As Boolean + If SND.tblSnd_AvisoID <= 0 Then Return False + Dim AVISO As cAviso = (New cAvisoDAL).LesenAviso(SND.tblSnd_AvisoID, "") + Return ceateAndSend_NCTS_FromSENDUNG(LRN, SND, AVISO) + End Function + + + Public Shared Function ceateAndSend_NCTS_FromSENDUNG(LRN As String, SND As cSendungen, AVISO As cAviso) As Boolean + ' Objekt mit allen notwendigen Pflichtfeldern befüllen + Dim MT_NCTS As New cMT_NCTS_DeclarationRequest With { + .lrn = LRN, + .departure_office = "GB000060", + .destination_office = "", + .transit_office_ref = "", + .trans_method = "3", + .transit_arrival_est = "2024-06-14T00:00:00", + .holder_eori = "DE828088257899835", + .holder_name = "VERAG SPEDITION GMBH", + .holder_address = "Hartham 6", + .holder_postcode = "94152", + .holder_city = "NEUHAUS AM INN", + .holder_country = "DE", + .holder_contact_name = VERAG_PROG_ALLGEMEIN.cAllgemein.USRNAME, + .holder_contact_phone = "0043771127770", + .holder_contact_email = "customs@verag-unisped.uk", + .departure_transport_sequence = "1", + .departure_transport_nationality = AVISO.LKW_Nationalitaet, + .border_transport_number = AVISO.LKW_Nr, + .border_transport_nationality = AVISO.LKW_Nationalitaet + } + + + + Select Case If(AVISO.Transportmittelart, "") + Case "CONTAINER" + ' MT_NCTS.border_transport_type = "1" ' z. B. Ocean + ' MT_NCTS.arrival_transport_type = "10" + ' MT_NCTS.border_transport_type_id = "1" ' z. B. Straße '?6 RORO?? + ' MT_NCTS.departure_transport_type_id = "3" ' z. B. Straße '?6 RORO?? + MT_NCTS.consignment_inland_mode = "3" + MT_NCTS.consignment_border_mode = "3" + MT_NCTS.consignment_container_indicator = "1" + + Case Else + MT_NCTS.consignment_container_indicator = "0" + MT_NCTS.border_transport_type_id = "30" + MT_NCTS.departure_transport_type_id = "30" + MT_NCTS.consignment_inland_mode = "3" + MT_NCTS.consignment_border_mode = "3" + ' MT_NCTS.border_transport_type = "6" ' z. B. 3 Straße '?6 RORO?? + ' MT_NCTS.arrival_transport_type = "30" + + End Select + + MT_NCTS.departure_transport_number = AVISO.LKW_Nr + MT_NCTS.vehicle_id = AVISO.LKW_Nr + MT_NCTS.trailer_id = AVISO.LKW_Nr ' AVISO.LKW_Nationalitaet + + + + If SND.tblSnd_EmpfaengerKdNr > 0 Then + Dim AD As New cAdressen(SND.tblSnd_EmpfaengerKdNr) + Dim KD As New cKunde(SND.tblSnd_EmpfaengerKdNr) + Dim CN As New VERAG_PROG_ALLGEMEIN.cRelayHub.cRelayHubAddress + ' MT_NCTS.consignee_eori = If(KD.EORITIN, "") + MT_NCTS.consignee_name = AD.Name_1 + MT_NCTS.consignee_street = AD.Straße + MT_NCTS.consignee_postcode = AD.PLZ + MT_NCTS.consignee_city = AD.Ort + MT_NCTS.consignee_country = cProgramFunctions.getISO2Land(AD.LandKz) + MT_NCTS.destination_country_id = MT_NCTS.consignee_country + MT_NCTS.consignment_country_of_destination = MT_NCTS.consignee_country + MT_NCTS.unloading_country = MT_NCTS.consignee_country + MT_NCTS.unloading_location = MT_NCTS.consignee_country + End If + + If SND.tblSnd_AbsenderKdNr > 0 Then + Dim AD As New cAdressen(SND.tblSnd_AbsenderKdNr) + Dim KD As New cKunde(SND.tblSnd_AbsenderKdNr) + Dim CZ As New VERAG_PROG_ALLGEMEIN.cRelayHub.cRelayHubAddress + + ' MT_NCTS.consignor_city= If(KD.EORITIN, "") + MT_NCTS.consignor_name = AD.Name_1 + MT_NCTS.consignor_street = AD.Straße + MT_NCTS.consignor_postcode = AD.PLZ + MT_NCTS.consignor_city = AD.Ort + MT_NCTS.consignor_country = cProgramFunctions.getISO2Land(AD.LandKz) + ' MT_NCTS.export_country = MT_NCTS.consignor_country_id + MT_NCTS.loading_country = MT_NCTS.consignor_country + MT_NCTS.loading_location = MT_NCTS.consignor_country + End If + + + + ' API-Client erstellen (mit Benutzer & Passwort in der Klasse eingebaut) + Dim client As New cMT_NCTS_ApiClient() + + ' Senden und Ergebnis anzeigen + Dim response As cMT_NCTS_DeclarationResponse = client.SendNCTSDeclaration(MT_NCTS) + + If response IsNot Nothing Then + Console.WriteLine("Status: " & response.status) + Console.WriteLine("Message: " & response.message) + Console.WriteLine("Declaration ID: " & response.declaration_id) + Console.WriteLine("LRN: " & response.lrn) + Console.WriteLine("MRN: " & response.mrn) + Else + Console.WriteLine("❌ Keine Antwort erhalten.") + End If + + Return False + End Function + + + Public Shared Sub TestNCTSSend() + Dim client As New cMT_NCTS_ApiClient() + Dim declaration As New cMT_NCTS_DeclarationRequest With { + .lrn = "LRN-DEMO-" & DateTime.Now.ToString("yyyyMMddHHmmss"), + .departure_office = "BG005804", + .destination_office = "TR343100", + .transit_office_ref = "TR220200", + .destination_country_id = "GB", + .trans_method = "3", + .transit_arrival_est = "2024-06-14T00:00:00", + .holder_eori = "DE828088257899835", + .holder_name = "VERAG SPEDITION AGMBH", + .holder_address = "Hartham 6", + .holder_postcode = "94152", + .holder_city = "NEUHAUS AM INN", + .holder_country = "DE", + .holder_contact_name = "Luxbauer", + .holder_contact_phone = "0771127770", + .holder_contact_email = "customs@verag-unisped.uk", + .guarantee_type = "0", + .guarantee_sequence = "1", + .guarantee_reference_sequence = "1", + .guarantee_grn = "DE123456789", + .guarantee_access_code = "XXXX", + .guarantee_amount = "1", + .guarantee_currency = "EUR", + .consignment_country_of_destination = "TR", + .consignment_container_indicator = "0", + .consignment_inland_mode = "3", + .consignment_border_mode = "3", + .consignment_gross_mass = "10.000", + .carrier_identification_number = "ateos13456", + .consignor_name = "test", + .consignor_street = "test", + .consignor_postcode = "01111", + .consignor_city = "test", + .consignor_country = "at", + .consignee_name = "test", + .consignee_street = "test", + .consignee_postcode = "34850", + .consignee_city = "ISTANBUL", + .consignee_country = "TR", + .departure_transport_sequence = "1", + .departure_transport_type_id = "30", + .departure_transport_number = "123456789", + .departure_transport_nationality = "TR", + .routing_countries = New List(Of String) From {"RS", "BG", "TR"}, + .border_transport_customs_office = "tr132456", + .border_transport_type_id = "30", + .border_transport_number = "139786546", + .border_transport_nationality = "TR", + .loading_country = "BG", + .loading_location = "BG", + .unloading_country = "TR", + .unloading_location = "TR", + .vehicle_id = "16BCB723", + .trailer_id = "16APM317", + .tax_total_sum = "3", + .tax_entries = New List(Of cMT_NCTS_Tax) From { + New cMT_NCTS_Tax With {.sequence_number = "1", .tax_type = "A00", .tax_sum = "1"}, + New cMT_NCTS_Tax With {.sequence_number = "2", .tax_type = "B00", .tax_sum = "2"} + }, + .house_consignments = New List(Of cMT_NCTS_HouseConsignment) From { + New cMT_NCTS_HouseConsignment With { + .sequence_number = "1", + .gross_mass = "11777.000", + .items = New List(Of cMT_NCTS_Item) From { + New cMT_NCTS_Item With { + .goods_item_number = "1", + .declaration_goods_item_number = "1", + .description = "Textilprodukte", + .hs_code = "380991", + .gross_mass = "1.000", + .net_mass = "1.000", + .packages = New List(Of cMT_NCTS_Package) From { + New cMT_NCTS_Package With { + .sequence_number = "1", + .package_type = "PK", + .number_of_packages = "1", + .marks = "NO MARKS" + } + }, + .supporting_documents = New List(Of cMT_NCTS_Document) From { + New cMT_NCTS_Document With {.sequence_number = "1", .doc_type = "N380", .reference = "A1111"} + }, + .transport_documents = New List(Of cMT_NCTS_Document) From { + New cMT_NCTS_Document With {.sequence_number = "1", .doc_type = "N730", .reference = "CMR"} + } + } + } + } + } + } + Dim response = client.SendNCTSDeclaration(declaration) + If response IsNot Nothing Then + Console.WriteLine("Status: " & response.status) + Console.WriteLine("Message: " & response.message) + Console.WriteLine("Declaration ID: " & response.declaration_id) + Console.WriteLine("LRN: " & response.lrn) + Console.WriteLine("MRN: " & response.mrn) + Else + Console.WriteLine("❌ Keine Antwort erhalten.") + End If + End Sub +End Class \ No newline at end of file diff --git a/VERAG_PROG_ALLGEMEIN/VERAG_PROG_ALLGEMEIN.vbproj b/VERAG_PROG_ALLGEMEIN/VERAG_PROG_ALLGEMEIN.vbproj index a5fce252..935ecac6 100644 --- a/VERAG_PROG_ALLGEMEIN/VERAG_PROG_ALLGEMEIN.vbproj +++ b/VERAG_PROG_ALLGEMEIN/VERAG_PROG_ALLGEMEIN.vbproj @@ -442,6 +442,9 @@ + + + diff --git a/VERAG_PROG_ALLGEMEIN/cAllgemein.vb b/VERAG_PROG_ALLGEMEIN/cAllgemein.vb index 9ea54704..818c4733 100644 --- a/VERAG_PROG_ALLGEMEIN/cAllgemein.vb +++ b/VERAG_PROG_ALLGEMEIN/cAllgemein.vb @@ -26,6 +26,8 @@ Public Class cAllgemein 'Public Shared FMZOLL_ATLAS_Datensicherung As String = "\\192.168.0.91\f\FMZoll\Datensicherung\atlas\atlas\fssouzb" Public Shared FMZOLL_ATLAS_Datensicherung_OLD As String = "\\share01\F\FMZoll\Datensicherung\atlas\atlas\fssouzb" + Public Shared UK_EORI_LTD = "GB078068385000" + Public Shared BÜRO As String Public Shared PRINTER_BON As String