diff --git a/Data/Models/XRechnung/XRInvoicePayment.cs b/Data/Models/XRechnung/XRInvoicePayment.cs index 94055a797..616ca3291 100644 --- a/Data/Models/XRechnung/XRInvoicePayment.cs +++ b/Data/Models/XRechnung/XRInvoicePayment.cs @@ -8,7 +8,7 @@ namespace BeWo.Data.Models.XRechnung { public class XRInvoicePayment { - public string Type { get; set; } + public int Type { get; set; } public string Term { get; set; } public string DueDate { get; set; } } diff --git a/Data/Models/XRechnung/XRPosition.cs b/Data/Models/XRechnung/XRPosition.cs index c076b298c..cac17d858 100644 --- a/Data/Models/XRechnung/XRPosition.cs +++ b/Data/Models/XRechnung/XRPosition.cs @@ -8,13 +8,13 @@ namespace BeWo.Data.Models.XRechnung { public class XRPosition { - public string Quantity { get; set; } + public int Quantity { get; set; } public string QuantityType { get; set; } public string Text { get; set; } - public string Net { get; set; } - public string NetTotal { get; set; } - public string Tax { get; set; } - public string TaxSum { get; set; } + public int Net { get; set; } + public int NetTotal { get; set; } + public decimal Tax { get; set; } + public decimal TaxSum { get; set; } public string TaxType { get; set; } } } diff --git a/Data/Models/XRechnung/XRechnungRequest.cs b/Data/Models/XRechnung/XRechnungRequest.cs new file mode 100644 index 000000000..94e4df7c7 --- /dev/null +++ b/Data/Models/XRechnung/XRechnungRequest.cs @@ -0,0 +1,18 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BeWo.Data.Models.XRechnung +{ + public class XRechnungRequest + { + [JsonProperty("json")] + public XRechnung Json { get; set; } + + [JsonProperty("pdf")] + public string Url { get; set; } + } +} diff --git a/Shared/AppSender/OwnSoftSender.cs b/Shared/AppSender/OwnSoftSender.cs index ad058b504..f642ce9af 100644 --- a/Shared/AppSender/OwnSoftSender.cs +++ b/Shared/AppSender/OwnSoftSender.cs @@ -17,7 +17,7 @@ namespace BS.Shared.AppSender { client.Encoding = Encoding.UTF8; - client.Headers.Add(HttpRequestHeader.ContentType, "application/xml"); + client.Headers.Add(HttpRequestHeader.ContentType, "application/x-www-form-urlencoded"); response = client.UploadString(url, "POST", dataString); } diff --git a/XRechnungUnitTest/UnitTest1.cs b/XRechnungUnitTest/UnitTest1.cs index 7a7324f55..1065b5761 100644 --- a/XRechnungUnitTest/UnitTest1.cs +++ b/XRechnungUnitTest/UnitTest1.cs @@ -4,6 +4,7 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using Newtonsoft.Json; using System; using System.IO; +using System.Text.RegularExpressions; namespace XRechnungUnitTest { @@ -24,9 +25,22 @@ namespace XRechnungUnitTest public void SendTest() { var url = "https://test2.evplaner.de/xrg/create"; - var json = File.ReadAllText("invoicetest.json"); - var response = OwnSoftSender.Send(url, json); + var json = File.ReadAllText("invoicetest.json", System.Text.Encoding.UTF8); + + var xr = JsonConvert.DeserializeObject(json); + + var xrr = JsonConvert.SerializeObject(xr); + + //var req = new XRechnungRequest(); + + //req.Json = xr; + + //var txt = JsonConvert.SerializeObject(req); + + var txt = $"json={xrr}"; + + var response = OwnSoftSender.Send(url, txt); Assert.IsTrue(!string.IsNullOrWhiteSpace(response) && !response.ToLower().Contains("error")); }