diff --git a/ConsoleApp3.sln b/CardMarketBotSolution.sln
similarity index 86%
rename from ConsoleApp3.sln
rename to CardMarketBotSolution.sln
index 8aec5c5..de83780 100644
--- a/ConsoleApp3.sln
+++ b/CardMarketBotSolution.sln
@@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.6.33815.320
MinimumVisualStudioVersion = 10.0.40219.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp3", "ConsoleApp3\ConsoleApp3.csproj", "{4CB462A0-22BB-4E70-9C0B-203560329AFE}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CardMarketBot", "ConsoleApp3\CardMarketBot.csproj", "{4CB462A0-22BB-4E70-9C0B-203560329AFE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
diff --git a/ConsoleApp3/ConsoleApp3.csproj b/ConsoleApp3/CardMarketBot.csproj
similarity index 62%
rename from ConsoleApp3/ConsoleApp3.csproj
rename to ConsoleApp3/CardMarketBot.csproj
index fad1b3f..8934ec7 100644
--- a/ConsoleApp3/ConsoleApp3.csproj
+++ b/ConsoleApp3/CardMarketBot.csproj
@@ -8,7 +8,14 @@
+
+
+
+ PreserveNewest
+
+
+
diff --git a/ConsoleApp3/CardMarketParser.cs b/ConsoleApp3/CardMarketParser.cs
index 22407ba..7f20bdc 100644
--- a/ConsoleApp3/CardMarketParser.cs
+++ b/ConsoleApp3/CardMarketParser.cs
@@ -3,16 +3,8 @@
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium;
using System.Net;
-
-/*
- *
- * referalPage: /de/OnePiece
-username: Skywalkerex
-userPassword: Magnatpower310!!
-/de/OnePiece/PostGetAction/User_Login
-
-curbpJUJmtup1t.Tq0awbHIhIRwhzMW7vrsWxLAJu.pI9X4r
-*/
+using System.Diagnostics;
+using ConsoleApp3.Contracts;
namespace CardmarketBot
{
@@ -20,6 +12,7 @@ namespace CardmarketBot
{
private readonly string username;
private readonly string password;
+ private readonly IUsedRepository _usedRepository;
Dictionary portoberechnung = new Dictionary()
{
@@ -31,10 +24,11 @@ namespace CardmarketBot
{"3,20 €", Helper.Porto.PRIO270 },
};
- public CardMarketParser(string username, string password)
+ public CardMarketParser(string username, string password, IUsedRepository repository)
{
this.username = username;
this.password = password;
+ _usedRepository = repository;
}
public List ParseCardMarket()
@@ -65,27 +59,39 @@ namespace CardmarketBot
cookieContainer.Add(new System.Net.Cookie(name, value, c.Path, c.Domain));
}
- //cd.Navigate().GoToUrl(@"https://www.cardmarket.com/de/OnePiece/Orders/Sales/Paid");
- cd.Navigate().GoToUrl(@"https://www.cardmarket.com/de/OnePiece/Orders/Sales/Sent");
-
- IWebElement element = cd.FindElement(By.XPath("/html/body/main/section/div[3]/div[3]/div[2]"));
- string content = element.Text;
-
- string[] datas = content.Split("\r\n");
+ cd.Navigate().GoToUrl(@"https://www.cardmarket.com/de/OnePiece/Orders/Sales/Paid");
+ //cd.Navigate().GoToUrl(@"https://www.cardmarket.com/de/OnePiece/Orders/Sales/Sent");
List ids = new List();
- for (int i = 0; i < datas.Length; i += 7)
- {
- ids.Add(datas[i]);
- }
-
List kunden = new List();
+ IWebElement element;
+ try
+ {
+ element = cd.FindElement(By.XPath("/html/body/main/section/div[3]/div[3]/div[2]"));
+ string content = element.Text;
- int maxCounter = 2;
- int counter = 0;
+ List bereitsbearbeitet = _usedRepository.Query;
+ string[] datas = content.Split("\r\n");
+
+
+ for (int i = 0; i < datas.Length; i += 7)
+ {
+ if (bereitsbearbeitet.Find(x => x.Equals(datas[i])) != null) continue;
+ ids.Add(datas[i]);
+ }
+
+
+
+ }
+ catch(OpenQA.Selenium.NotFoundException ex)
+ {
+ Console.WriteLine("Keine Verkäufe aktuell");
+ return kunden;
+ }
+
foreach (string id in ids)
{
- if (counter > maxCounter) break;
+
Console.WriteLine(id);
cd.Navigate().GoToUrl(string.Format(@"https://www.cardmarket.com/de/OnePiece/Orders/{0}", id));
element = cd.FindElement(By.XPath("/html/body/main/section/div/div[1]/div/div[3]/div[2]/div[2]/div/div"));
@@ -94,12 +100,22 @@ namespace CardmarketBot
// Bezahldatum
element = cd.FindElement(By.XPath("/html/body/main/section/div/div[1]/div/div[2]/div/div[2]/div[2]"));
- kunde.Bezahldatum = element.Text;
- //Debugger.Break();
+ kunde.Bezahldatum = Helper.ConvertBezahlDatum(element.Text);
+
// Versandkosten
element = cd.FindElement(By.XPath("/html/body/main/section/div/div[1]/div/div[3]/div[1]/div[2]/div/div[3]/span[2]"));
- kunde.Versandskosten = portoberechnung[element.Text];
+ Helper.Porto resul;
+ if(portoberechnung.TryGetValue(element.Text, out resul))
+ {
+ kunde.Versandskosten = resul;
+ }
+ else
+ {
+ kunde.OverrideVersandskosten = element.Text;
+ Console.WriteLine(@"Achtung bei ID {id} wurde kein Richtige Porto berechnet. Liegt es im Ausland?");
+ }
+ //kunde.Versandskosten = portoberechnung[element.Text];
kunde.BestellungID = id;
@@ -111,7 +127,6 @@ namespace CardmarketBot
kunden.Add(kunde);
- counter++;
Thread.Sleep(TimeSpan.FromSeconds(5));
}
return kunden;
diff --git a/ConsoleApp3/Contracts/IUsedRepository.cs b/ConsoleApp3/Contracts/IUsedRepository.cs
new file mode 100644
index 0000000..dc916cd
--- /dev/null
+++ b/ConsoleApp3/Contracts/IUsedRepository.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ConsoleApp3.Contracts
+{
+ internal interface IUsedRepository
+ {
+ List Query { get; }
+ //void Insert(string key);
+ void Insert(List kunden);
+ }
+}
diff --git a/ConsoleApp3/DataContracts/Employee.cs b/ConsoleApp3/DataContracts/Employee.cs
deleted file mode 100644
index bcec3ed..0000000
--- a/ConsoleApp3/DataContracts/Employee.cs
+++ /dev/null
@@ -1,4 +0,0 @@
-namespace ConsoleApp3.DataContracts
-{
- public record Employee(string Name, int Number);
-}
\ No newline at end of file
diff --git a/ConsoleApp3/DataContracts/Invoice.cs b/ConsoleApp3/DataContracts/Invoice.cs
index 84c99c6..f47efd3 100644
--- a/ConsoleApp3/DataContracts/Invoice.cs
+++ b/ConsoleApp3/DataContracts/Invoice.cs
@@ -2,44 +2,558 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
+using System.Xml.Linq;
namespace ConsoleApp3.DataContracts
{
internal class Invoice
{
- [JsonProperty("id")] public string Id { get; set; }
- //[JsonProperty("organizationId")] public string OrganizationId { get; set; }
- [JsonProperty("createdDate")] public string CreatedDate { get; set; }
- [JsonProperty("updatedDate")] public string UpdatedDate { get; set; }
- [JsonProperty("version")] public decimal Version { get; set; }
- [JsonProperty("language")] public string Language { get; set; }
- [JsonProperty("archived")] public bool Archived { get; set; }
- [JsonProperty("voucherStatus")] public string VoucherStatus { get; set; }
- [JsonProperty("voucherNumber")] public string VoucherNumber { get; set; }
- [JsonProperty("voucherDate")] public string VoucherDate { get; set; }
- [JsonProperty("dueDate")] public string DueDate { get; set; }
- [JsonProperty("address")] public InvoiceAddress Address { get; set; }
- [JsonProperty("lineItems")] public List LineItems { get; set; }
- [JsonProperty("totalPrice")] public TotalPrice TotalPrice { get; set; }
- [JsonProperty("taxConditions")] public TaxConditions TaxConditions { get; set; }
- [JsonProperty("shippingConditions")] public ShippingConditions ShippingConditions { get; set; }
+ [JsonProperty(PropertyName ="id")]
+ public int? Id { get; set; }
+
+ [JsonProperty(PropertyName = "objectName")]
+ public string ObjectName { get; set; }
+ ///
+ ///
+ ///
+ ///
+ [DataMember(Name = "invoiceNumber", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "invoiceNumber")]
+ public string InvoiceNumber { get; set; }
+
+ ///
+ /// the contact the invoice belongs to
+ ///
+ /// the contact the invoice belongs to
+ [DataMember(Name = "contact", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "contact")]
+ public ModelContact Contact { get; set; }
+
+ ///
+ /// the date the invoice was created
+ ///
+ /// the date the invoice was created
+ [DataMember(Name = "create", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "create")]
+ public DateTime? Create { get; set; }
+
+ ///
+ /// the date the invoice was last updated
+ ///
+ /// the date the invoice was last updated
+ [DataMember(Name = "update", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "update")]
+ public DateTime? Update { get; set; }
+
+ ///
+ /// the date of the invoice
+ ///
+ /// the date of the invoice
+ [DataMember(Name = "invoiceDate", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "invoiceDate")]
+ public DateTime? InvoiceDate { get; set; }
+
+ ///
+ /// header/subject of the invoice
+ ///
+ /// header/subject of the invoice
+ [DataMember(Name = "header", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "header")]
+ public string Header { get; set; }
+
+ ///
+ /// head text of the invoice
+ ///
+ /// head text of the invoice
+ [DataMember(Name = "headText", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "headText")]
+ public string HeadText { get; set; }
+
+ ///
+ /// foot text of the invoice
+ ///
+ /// foot text of the invoice
+ [DataMember(Name = "footText", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "footText")]
+ public string FootText { get; set; }
+
+ ///
+ /// time left for paying the invoice, use format dd.MM.yyyy or number for number of days left
+ ///
+ /// time left for paying the invoice, use format dd.MM.yyyy or number for number of days left
+ [DataMember(Name = "timeToPay", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "timeToPay")]
+ public DateTime? TimeToPay { get; set; }
+
+ ///
+ ///
+ ///
+ ///
+ /*[DataMember(Name = "discountTime", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "discountTime")]
+ public DateTime? DiscountTime { get; set; }
+ */
+ ///
+ /// the discount value in '%'
+ ///
+ /// the discount value in '%'
+ [DataMember(Name = "discount", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "discount")]
+ public float? Discount { get; set; }
+
+ ///
+ /// the name in the address, equals the contacts name
+ ///
+ /// the name in the address, equals the contacts name
+ [DataMember(Name = "addressName", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "addressName")]
+ public string AddressName { get; set; }
+
+ ///
+ /// the street in the address, equals the contacts street
+ ///
+ /// the street in the address, equals the contacts street
+ [DataMember(Name = "addressStreet", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "addressStreet")]
+ public string AddressStreet { get; set; }
+
+ ///
+ /// the zip-code in the address, equals the contacts zip
+ ///
+ /// the zip-code in the address, equals the contacts zip
+ [DataMember(Name = "addressZip", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "addressZip")]
+ public string AddressZip { get; set; }
+
+ ///
+ /// the city in the address, equals the contacts city
+ ///
+ /// the city in the address, equals the contacts city
+ [DataMember(Name = "addressCity", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "addressCity")]
+ public string AddressCity { get; set; }
+
+ ///
+ /// the country in the address, equals the contacts country
+ ///
+ /// the country in the address, equals the contacts country
+ [DataMember(Name = "addressCountry", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "addressCountry")]
+ public ModelStaticCountry AddressCountry { get; set; }
+
+ ///
+ /// time left for paying the invoice, use format DD.MM.YYYY or number for number of days left
+ ///
+ /// time left for paying the invoice, use format DD.MM.YYYY or number for number of days left
+ [DataMember(Name = "payDate", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "payDate")]
+ public DateTime? PayDate { get; set; }
+
+ ///
+ /// SevUser who created the invoice
+ ///
+ /// SevUser who created the invoice
+ [DataMember(Name = "createUser", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "createUser")]
+ public ModelSevUser CreateUser { get; set; }
+
+ ///
+ /// sevClient is the unique id every customer has and is used in nearly all operations
+ ///
+ /// sevClient is the unique id every customer has and is used in nearly all operations
+ [DataMember(Name = "sevClient", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "sevClient")]
+ public Object SevClient { get; set; }
+
+ ///
+ /// delivery date of the goods from the invoice, please use dd.MM.yyyy
+ ///
+ /// delivery date of the goods from the invoice, please use dd.MM.yyyy
+ [DataMember(Name = "deliveryDate", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "deliveryDate")]
+ public DateTime? DeliveryDate { get; set; }
+
+ ///
+ /// status of the invoice
+ ///
+ /// status of the invoice
+ [DataMember(Name = "status", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "status")]
+ public EInvoiceStatus Status { get; set; }
+
+ ///
+ ///
+ ///
+ ///
+ /*[DataMember(Name = "smallSettlement", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "smallSettlement")]
+ public bool? SmallSettlement { get; set; }
+ */
+ ///
+ /// SevUser who created the invoice and therefore is the contact person
+ ///
+ /// SevUser who created the invoice and therefore is the contact person
+ [DataMember(Name = "contactPerson", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "contactPerson")]
+ public ModelSevUser ContactPerson { get; set; } = new ModelSevUser()
+ {
+
+ };
+
+ ///
+ /// tax rate used when adding a value added tax regulation
+ ///
+ /// tax rate used when adding a value added tax regulation
+ [DataMember(Name = "taxRate", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "taxRate")]
+ public float? TaxRate { get; set; }
+
+ ///
+ /// additional text when adding a value added tax regulation
+ ///
+ /// additional text when adding a value added tax regulation
+ [DataMember(Name = "taxText", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "taxText")]
+ public string TaxText { get; set; }
+
+ ///
+ /// dunning level of the invoice
+ ///
+ /// dunning level of the invoice
+ [DataMember(Name = "dunningLevel", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "dunningLevel")]
+ public int? DunningLevel { get; set; }
+
+ ///
+ /// name of the contacts address
+ ///
+ /// name of the contacts address
+ [DataMember(Name = "addressParentName", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "addressParentName")]
+ public string AddressParentName { get; set; }
+
+ ///
+ /// a reference to the contacts address
+ ///
+ /// a reference to the contacts address
+ [DataMember(Name = "addressContactRef", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "addressContactRef")]
+ public ModelContactAddress AddressContactRef { get; set; }
+
+ ///
+ ///
+ ///
+ ///
+ [DataMember(Name = "taxType", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "taxType")]
+ public string TaxType { get; set; }
+
+ ///
+ ///
+ ///
+ ///
+ [DataMember(Name = "paymentMethod", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "paymentMethod")]
+ public ModelPaymentMethod PaymentMethod { get; set; }
+
+ ///
+ ///
+ ///
+ ///
+ [DataMember(Name = "costCentre", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "costCentre")]
+ public ModelCostCentre CostCentre { get; set; }
+
+ ///
+ ///
+ ///
+ ///
+ [DataMember(Name = "sendDate", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "sendDate")]
+ public DateTime? SendDate { get; set; }
+
+ ///
+ ///
+ ///
+ ///
+ [DataMember(Name = "origin", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "origin")]
+ public Object Origin { get; set; }
+
+ ///
+ /// type of the invoice
+ ///
+ /// type of the invoice
+ [DataMember(Name = "invoiceType", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "invoiceType")]
+ public string InvoiceType { get; set; }
+
+ ///
+ ///
+ ///
+ ///
+ [DataMember(Name = "accountIntervall", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "accountIntervall")]
+ public int? AccountIntervall { get; set; }
+
+ ///
+ ///
+ ///
+ ///
+ [DataMember(Name = "accountLastInvoice", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "accountLastInvoice")]
+ public DateTime? AccountLastInvoice { get; set; }
+
+ ///
+ ///
+ ///
+ ///
+ [DataMember(Name = "accountNextInvoice", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "accountNextInvoice")]
+ public DateTime? AccountNextInvoice { get; set; }
+
+ ///
+ ///
+ ///
+ ///
+ [DataMember(Name = "reminderTotal", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "reminderTotal")]
+ public float? ReminderTotal { get; set; }
+
+ ///
+ ///
+ ///
+ ///
+ [DataMember(Name = "reminderDebit", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "reminderDebit")]
+ public float? ReminderDebit { get; set; }
+
+ ///
+ ///
+ ///
+ ///
+ [DataMember(Name = "reminderDeadline", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "reminderDeadline")]
+ public DateTime? ReminderDeadline { get; set; }
+
+ ///
+ ///
+ ///
+ ///
+ [DataMember(Name = "reminderCharge", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "reminderCharge")]
+ public float? ReminderCharge { get; set; }
+
+ ///
+ ///
+ ///
+ ///
+ [DataMember(Name = "addressParentName2", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "addressParentName2")]
+ public string AddressParentName2 { get; set; }
+
+ ///
+ ///
+ ///
+ ///
+ [DataMember(Name = "addressName2", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "addressName2")]
+ public string AddressName2 { get; set; }
+
+ ///
+ ///
+ ///
+ ///
+ [DataMember(Name = "taxSet", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "taxSet")]
+ public ModelTaxSet TaxSet { get; set; }
+
+ ///
+ ///
+ ///
+ ///
+ [DataMember(Name = "addressGender", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "addressGender")]
+ public string AddressGender { get; set; }
+
+ ///
+ ///
+ ///
+ ///
+ [DataMember(Name = "accountEndDate", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "accountEndDate")]
+ public DateTime? AccountEndDate { get; set; }
+
+ ///
+ ///
+ ///
+ ///
+ [DataMember(Name = "address", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "address")]
+ public string Address { get; set; }
+
+ ///
+ ///
+ ///
+ ///
+ [DataMember(Name = "currency", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "currency")]
+ public string Currency { get; set; } = "EUR";
+
+ ///
+ ///
+ ///
+ ///
+ [DataMember(Name = "sumNet", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "sumNet")]
+ public float? SumNet { get; set; }
+
+ ///
+ ///
+ ///
+ ///
+ [DataMember(Name = "sumTax", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "sumTax")]
+ public float? SumTax { get; set; }
+
+ ///
+ ///
+ ///
+ ///
+ [DataMember(Name = "sumGross", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "sumGross")]
+ public float? SumGross { get; set; }
+
+ ///
+ ///
+ ///
+ ///
+ [DataMember(Name = "sumDiscounts", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "sumDiscounts")]
+ public float? SumDiscounts { get; set; }
+
+ ///
+ ///
+ ///
+ ///
+ [DataMember(Name = "sumNetForeignCurrency", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "sumNetForeignCurrency")]
+ public float? SumNetForeignCurrency { get; set; }
+
+ ///
+ ///
+ ///
+ ///
+ [DataMember(Name = "sumTaxForeignCurrency", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "sumTaxForeignCurrency")]
+ public float? SumTaxForeignCurrency { get; set; }
+
+ ///
+ ///
+ ///
+ ///
+ [DataMember(Name = "sumGrossForeignCurrency", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "sumGrossForeignCurrency")]
+ public float? SumGrossForeignCurrency { get; set; }
+
+ ///
+ ///
+ ///
+ ///
+ [DataMember(Name = "sumDiscountsForeignCurrency", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "sumDiscountsForeignCurrency")]
+ public float? SumDiscountsForeignCurrency { get; set; }
+
+ ///
+ ///
+ ///
+ ///
+ [DataMember(Name = "sumNetAccounting", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "sumNetAccounting")]
+ public float? SumNetAccounting { get; set; }
+
+ ///
+ ///
+ ///
+ ///
+ [DataMember(Name = "sumTaxAccounting", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "sumTaxAccounting")]
+ public float? SumTaxAccounting { get; set; }
+
+ ///
+ ///
+ ///
+ ///
+ [DataMember(Name = "sumGrossAccounting", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "sumGrossAccounting")]
+ public float? SumGrossAccounting { get; set; }
+
+ ///
+ ///
+ ///
+ ///
+ [DataMember(Name = "entryType", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "entryType")]
+ public ModelEntryType EntryType { get; set; }
+
+ ///
+ ///
+ ///
+ ///
+ [DataMember(Name = "costumerInternalNote", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "costumerInternalNote")]
+ public string CostumerInternalNote { get; set; }
+
+ ///
+ ///
+ ///
+ ///
+ [DataMember(Name = "showNet", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "showNet")]
+ public int ShowNet { get; set; } = 0;
+
+
+ ///
+ ///
+ ///
+ ///
+ [DataMember(Name = "enshrined", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "enshrined")]
+ public bool? Enshrined { get; set; }
+
+ ///
+ ///
+ ///
+ ///
+ [DataMember(Name = "sendType", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "sendType")]
+ public string SendType { get; set; }
+
+ ///
+ ///
+ ///
+ ///
+ [DataMember(Name = "deliveryDateUntil", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "deliveryDateUntil")]
+ public DateTime? DeliveryDateUntil { get; set; }
+
+ [DataMember(Name = "mapAll", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "mapAll")]
+ public bool MapAll { get; set; } = true;
+
}
- public class ShippingConditions
+ enum EInvoiceStatus
{
- [JsonProperty("shippingDate")] public string shippingDate { get; set; } = "2023-04-22T00:00:00.000+02:00";
- [JsonProperty("shippingType")] public string shippingType { get; set; } = "delivery";
+ DEACTIVE = 50,
+ DRAFT = 100,
+ OPEN = 200,
+ PAYED = 1000
}
- public class TaxConditions
- {
- [JsonProperty("taxType")] public string TaxType { get; set; } = "net";
- }
-
- public class TotalPrice
- {
- [JsonProperty("currency")] public string Currency { get; set; } = "EUR";
- }
}
+
+
diff --git a/ConsoleApp3/DataContracts/InvoiceAddress.cs b/ConsoleApp3/DataContracts/InvoiceAddress.cs
deleted file mode 100644
index a29a8f6..0000000
--- a/ConsoleApp3/DataContracts/InvoiceAddress.cs
+++ /dev/null
@@ -1,26 +0,0 @@
-using Newtonsoft.Json;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace ConsoleApp3.DataContracts
-{
- internal class InvoiceAddress
- {
- [JsonProperty("contactId")] public string ContactId { get; set; }
-
- [JsonProperty("name")] public string Name { get; set; }
-
- [JsonProperty("supplement")] public string Supplement { get; set; }
-
- [JsonProperty("street")] public string Street { get; set; }
-
- [JsonProperty("city")] public string City { get; set; }
-
- [JsonProperty("zip")] public string Zip { get; set; }
-
- [JsonProperty("countryCode")] public string CountryCode { get; set; }
- }
-}
diff --git a/ConsoleApp3/DataContracts/InvoiceItem.cs b/ConsoleApp3/DataContracts/InvoiceItem.cs
deleted file mode 100644
index 666a41b..0000000
--- a/ConsoleApp3/DataContracts/InvoiceItem.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace ConsoleApp3.DataContracts
-{
- public record InvoiceItem
- {
- internal InvoiceItem(string invoiceId, string customer, DateTime date, Employee employee, int account,
- string description, decimal amountHours, decimal price)
- {
- InvoiceId = invoiceId;
- Customer = customer;
- Date = date;
- Employee = employee;
- Account = account;
- Description = description;
- AmountHours = amountHours;
- Price = price;
- }
-
- public string InvoiceId { get; }
- public string Customer { get; }
- public DateTime Date { get; }
- public Employee Employee { get; }
- public int Account { get; }
- public string Description { get; }
- public decimal AmountHours { get; }
- public decimal Price { get; }
- }
-}
diff --git a/ConsoleApp3/DataContracts/InvoiceLineItem.cs b/ConsoleApp3/DataContracts/InvoiceLineItem.cs
deleted file mode 100644
index e764256..0000000
--- a/ConsoleApp3/DataContracts/InvoiceLineItem.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-using Newtonsoft.Json;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace ConsoleApp3.DataContracts
-{
- internal class InvoiceLineItem
- {
- [JsonProperty("type")] public string Type { get; set; }
- [JsonProperty("name")] public string Name { get; set; }
- [JsonProperty("description")] public string Description { get; set; }
- [JsonProperty("quantity")] public decimal Quantity { get; set; }
- [JsonProperty("unitName")] public string UnitName { get; set; }
- [JsonProperty("unitPrice")] public InvoiceLineUnitPrice UnitPrice { get; set; }
- [JsonProperty("discountPercentage")] public decimal DiscountPercentage { get; set; }
- [JsonProperty("lineItemAmount")] public decimal LineItemAmount { get; set; }
- }
-}
diff --git a/ConsoleApp3/DataContracts/InvoiceLineUnitPrice.cs b/ConsoleApp3/DataContracts/InvoiceLineUnitPrice.cs
deleted file mode 100644
index bd4b02f..0000000
--- a/ConsoleApp3/DataContracts/InvoiceLineUnitPrice.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using Newtonsoft.Json;
-
-namespace ConsoleApp3.DataContracts
-{
- public class InvoiceLineUnitPrice
- {
- [JsonProperty("currency")] public string Currency { get; set; }
-
- [JsonProperty("netAmount")] public decimal NetAmount { get; set; }
-
- [JsonProperty("grossAmount")] public decimal GrossAmount { get; set; }
-
- [JsonProperty("taxRatePercentage")] public decimal TaxRatePercentage { get; set; }
- }
-}
\ No newline at end of file
diff --git a/ConsoleApp3/DataContracts/InvoicePosSave.cs b/ConsoleApp3/DataContracts/InvoicePosSave.cs
new file mode 100644
index 0000000..229fcf8
--- /dev/null
+++ b/ConsoleApp3/DataContracts/InvoicePosSave.cs
@@ -0,0 +1,67 @@
+using Newtonsoft.Json;
+using OpenQA.Selenium.DevTools.V112.DOM;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ConsoleApp3.DataContracts
+{
+ [DataContract]
+ internal class InvoicePosSave
+ {
+ [DataMember(Name = "id", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "id")]
+ public int? Id { get; set; }
+
+ [DataMember(Name = "objectName", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "objectName")]
+ public string ObjectName { get; set; } = "InvoicePos";
+
+ [DataMember(Name = "mapAll", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "mapAll")]
+ public bool MapAll { get; set; } = true;
+
+ [DataMember(Name = "quantity", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "quantity")]
+ public uint Quantity { get; set; }
+
+ [DataMember(Name = "price", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "price")]
+ public decimal Price { get; set; }
+
+ [DataMember(Name = "name", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "name")]
+ public string Name { get; set; } = "";
+
+ [DataMember(Name = "unity", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "unity")]
+ public ModelUnity Unity { get; set; } = new ModelUnity();
+
+ [DataMember(Name = "positionNumber", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "positionNumber")]
+ public uint PositionNumber { get; set; }
+
+ [DataMember(Name = "text", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "text")]
+ public string? Text { get; set; }
+
+ [DataMember(Name = "discount", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "discount")]
+ public int Discount { get; set; } = 0;
+
+ [DataMember(Name = "taxRate", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "taxRate")]
+ public uint TaxRate { get; set; } = 19;
+
+ [DataMember(Name = "priceGross", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "priceGross")]
+ public decimal PriceGross { get; set; }
+
+ [DataMember(Name = "priceTax", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "priceTax")]
+ public int PriceTax { get; set; } = 19;
+ }
+}
diff --git a/ConsoleApp3/DataContracts/Invoices.cs b/ConsoleApp3/DataContracts/Invoices.cs
new file mode 100644
index 0000000..c8ab436
--- /dev/null
+++ b/ConsoleApp3/DataContracts/Invoices.cs
@@ -0,0 +1,12 @@
+// See https://aka.ms/new-console-template for more information
+
+using Newtonsoft.Json;
+
+namespace ConsoleApp3.DataContracts
+{
+ internal class Invoices
+ {
+ [JsonProperty("objects")] public Invoice[] Invoice { get; set; }
+
+ }
+}
\ No newline at end of file
diff --git a/ConsoleApp3/DataContracts/ModelCategory.cs b/ConsoleApp3/DataContracts/ModelCategory.cs
new file mode 100644
index 0000000..a0f49f9
--- /dev/null
+++ b/ConsoleApp3/DataContracts/ModelCategory.cs
@@ -0,0 +1,110 @@
+using Newtonsoft.Json;
+using System.Runtime.Serialization;
+
+namespace ConsoleApp3.DataContracts
+{
+ [DataContract]
+ public class ModelCategory
+ {
+ [DataMember(Name = "create", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "create")]
+ public DateTime? Create { get; set; }
+
+ ///
+ /// date the category was last updated
+ ///
+ /// date the category was last updated
+ [DataMember(Name = "update", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "update")]
+ public DateTime? Update { get; set; }
+
+ ///
+ ///
+ ///
+ ///
+ [DataMember(Name = "parent", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "parent")]
+ public ModelCategory Parent { get; set; }
+
+ ///
+ ///
+ ///
+ ///
+ [DataMember(Name = "name", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "name")]
+ public string Name { get; set; }
+
+ ///
+ ///
+ ///
+ ///
+ [DataMember(Name = "objectType", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "objectType")]
+ public string ObjectType { get; set; }
+
+ ///
+ ///
+ ///
+ ///
+ [DataMember(Name = "priority", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "priority")]
+ public int? Priority { get; set; }
+
+ ///
+ ///
+ ///
+ ///
+ [DataMember(Name = "code", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "code")]
+ public string Code { get; set; }
+
+ ///
+ ///
+ ///
+ ///
+ [DataMember(Name = "color", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "color")]
+ public string Color { get; set; }
+
+ ///
+ ///
+ ///
+ ///
+ [DataMember(Name = "sevClient", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "sevClient")]
+ public Object SevClient { get; set; }
+
+ ///
+ ///
+ ///
+ ///
+ [DataMember(Name = "postingAccount", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "postingAccount")]
+ public string PostingAccount { get; set; }
+
+ ///
+ ///
+ ///
+ ///
+ [DataMember(Name = "type", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "type")]
+ public string Type { get; set; }
+
+ ///
+ ///
+ ///
+ ///
+ [DataMember(Name = "translationCode", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "translationCode")]
+ public string TranslationCode { get; set; }
+
+ ///
+ ///
+ ///
+ ///
+ [DataMember(Name = "entryType", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "entryType")]
+ public ModelEntryType EntryType { get; set; }
+
+ }
+}
\ No newline at end of file
diff --git a/ConsoleApp3/DataContracts/ModelContact.cs b/ConsoleApp3/DataContracts/ModelContact.cs
new file mode 100644
index 0000000..8dbf856
--- /dev/null
+++ b/ConsoleApp3/DataContracts/ModelContact.cs
@@ -0,0 +1,232 @@
+using Newtonsoft.Json;
+using System.Runtime.Serialization;
+
+namespace ConsoleApp3.DataContracts
+{
+ [DataContract]
+ public class ModelContact
+ {
+ [DataMember(Name = "id", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "id")]
+ public int Id { get; set; }
+
+ [DataMember(Name = "objectName", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "objectName")]
+ public string ObjectName { get; set; } = "";
+ ///
+ /// the contact address
+ ///
+ /// the contact address
+ [DataMember(Name = "address", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "address")]
+ public ModelContactAddress Address { get; set; }
+
+ ///
+ /// the creation date of the contact
+ ///
+ /// the creation date of the contact
+ [DataMember(Name = "create", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "create")]
+ public DateTime? Create { get; set; }
+
+ ///
+ /// date, the contact was last updated
+ ///
+ /// date, the contact was last updated
+ [DataMember(Name = "update", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "update")]
+ public DateTime? Update { get; set; }
+
+ ///
+ /// name of the contact
+ ///
+ /// name of the contact
+ [DataMember(Name = "name", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "name")]
+ public string Name { get; set; }
+
+ ///
+ /// status of the contact
+ ///
+ /// status of the contact
+ [DataMember(Name = "status", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "status")]
+ public int? Status { get; set; }
+
+ ///
+ /// customer number of the contact
+ ///
+ /// customer number of the contact
+ [DataMember(Name = "customerNumber", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "customerNumber")]
+ public int? CustomerNumber { get; set; }
+
+ ///
+ ///
+ ///
+ ///
+ [DataMember(Name = "parent", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "parent")]
+ public ModelContact Parent { get; set; }
+
+ ///
+ /// surname of the contact
+ ///
+ /// surname of the contact
+ [DataMember(Name = "surename", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "surename")]
+ public string Surename { get; set; }
+
+ ///
+ /// family name of the contact
+ ///
+ /// family name of the contact
+ [DataMember(Name = "familyname", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "familyname")]
+ public string Familyname { get; set; }
+
+ ///
+ /// title of the contact
+ ///
+ /// title of the contact
+ [DataMember(Name = "titel", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "titel")]
+ public string Titel { get; set; }
+
+ ///
+ /// category of the contact
+ ///
+ /// category of the contact
+ [DataMember(Name = "category", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "category")]
+ public ModelCategory Category { get; set; }
+
+ ///
+ /// description of the contact
+ ///
+ /// description of the contact
+ [DataMember(Name = "description", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "description")]
+ public string Description { get; set; }
+
+ ///
+ /// any academic title of the contact
+ ///
+ /// any academic title of the contact
+ [DataMember(Name = "academicTitle", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "academicTitle")]
+ public string AcademicTitle { get; set; }
+
+ ///
+ /// gender of the contact
+ ///
+ /// gender of the contact
+ [DataMember(Name = "gender", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "gender")]
+ public string Gender { get; set; }
+
+ ///
+ /// sevClient is the unique id every customer has and is used in nearly all operations
+ ///
+ /// sevClient is the unique id every customer has and is used in nearly all operations
+ [DataMember(Name = "sevClient", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "sevClient")]
+ public Object SevClient { get; set; }
+
+ ///
+ /// second name of the contact
+ ///
+ /// second name of the contact
+ [DataMember(Name = "name2", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "name2")]
+ public string Name2 { get; set; }
+
+ ///
+ /// birthday of the contact
+ ///
+ /// birthday of the contact
+ [DataMember(Name = "birthday", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "birthday")]
+ public DateTime? Birthday { get; set; }
+
+ ///
+ /// vat number of the contact
+ ///
+ /// vat number of the contact
+ [DataMember(Name = "vatNumber", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "vatNumber")]
+ public string VatNumber { get; set; }
+
+ ///
+ /// bank account of the contact
+ ///
+ /// bank account of the contact
+ [DataMember(Name = "bankAccount", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "bankAccount")]
+ public string BankAccount { get; set; }
+
+ ///
+ /// bank number of the contact
+ ///
+ /// bank number of the contact
+ [DataMember(Name = "bankNumber", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "bankNumber")]
+ public string BankNumber { get; set; }
+
+ ///
+ /// desired payment method of the customer
+ ///
+ /// desired payment method of the customer
+ [DataMember(Name = "paymentMethod", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "paymentMethod")]
+ public ModelPaymentMethod PaymentMethod { get; set; }
+
+ ///
+ ///
+ ///
+ ///
+ [DataMember(Name = "entryType", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "entryType")]
+ public ModelEntryType EntryType { get; set; }
+
+ ///
+ /// default cashback time of the contact
+ ///
+ /// default cashback time of the contact
+ [DataMember(Name = "defaultCashbackTime", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "defaultCashbackTime")]
+ public int? DefaultCashbackTime { get; set; }
+
+ ///
+ /// default cashback percentage of the contact
+ ///
+ /// default cashback percentage of the contact
+ [DataMember(Name = "defaultCashbackPercent", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "defaultCashbackPercent")]
+ public int? DefaultCashbackPercent { get; set; }
+
+ ///
+ /// default time to pay of the contact
+ ///
+ /// default time to pay of the contact
+ [DataMember(Name = "defaultTimeToPay", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "defaultTimeToPay")]
+ public int? DefaultTimeToPay { get; set; }
+
+ ///
+ /// tax number of the contact
+ ///
+ /// tax number of the contact
+ [DataMember(Name = "taxNumber", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "taxNumber")]
+ public string TaxNumber { get; set; }
+
+ ///
+ /// tax office of the contact
+ ///
+ /// tax office of the contact
+ [DataMember(Name = "taxOffice", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "taxOffice")]
+ public string TaxOffice { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/ConsoleApp3/DataContracts/ModelContactAddress.cs b/ConsoleApp3/DataContracts/ModelContactAddress.cs
new file mode 100644
index 0000000..58ad3b7
--- /dev/null
+++ b/ConsoleApp3/DataContracts/ModelContactAddress.cs
@@ -0,0 +1,114 @@
+using Newtonsoft.Json;
+using System.Runtime.Serialization;
+
+namespace ConsoleApp3.DataContracts
+{
+ [DataContract]
+ public class ModelContactAddress
+ {
+ ///
+ /// the creation date of the contact
+ ///
+ /// the creation date of the contact
+ [DataMember(Name = "create", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "create")]
+ public DateTime? Create { get; set; }
+
+ ///
+ /// date, the contact was last updated
+ ///
+ /// date, the contact was last updated
+ [DataMember(Name = "update", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "update")]
+ public DateTime? Update { get; set; }
+
+ ///
+ /// the contact the address belongs to
+ ///
+ /// the contact the address belongs to
+ [DataMember(Name = "contact", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "contact")]
+ public ModelContact Contact { get; set; }
+
+ ///
+ ///
+ ///
+ ///
+ [DataMember(Name = "street", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "street")]
+ public string Street { get; set; }
+
+ ///
+ /// zip of the city/village
+ ///
+ /// zip of the city/village
+ [DataMember(Name = "zip", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "zip")]
+ public string Zip { get; set; }
+
+ ///
+ ///
+ ///
+ ///
+ [DataMember(Name = "city", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "city")]
+ public string City { get; set; }
+
+ ///
+ ///
+ ///
+ ///
+ [DataMember(Name = "country", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "country")]
+ public ModelStaticCountry Country { get; set; }
+
+ ///
+ /// category of the address
+ ///
+ /// category of the address
+ [DataMember(Name = "category", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "category")]
+ public ModelCategory Category { get; set; }
+
+ ///
+ ///
+ ///
+ ///
+ [DataMember(Name = "name", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "name")]
+ public string Name { get; set; }
+
+ ///
+ /// sevClient is the unique id every customer has and is used in nearly all operations
+ ///
+ /// sevClient is the unique id every customer has and is used in nearly all operations
+ [DataMember(Name = "sevClient", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "sevClient")]
+ public Object SevClient { get; set; }
+
+ ///
+ ///
+ ///
+ ///
+ [DataMember(Name = "name2", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "name2")]
+ public string Name2 { get; set; }
+
+ ///
+ ///
+ ///
+ ///
+ [DataMember(Name = "name3", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "name3")]
+ public string Name3 { get; set; }
+
+ ///
+ ///
+ ///
+ ///
+ [DataMember(Name = "name4", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "name4")]
+ public string Name4 { get; set; }
+
+ }
+}
\ No newline at end of file
diff --git a/ConsoleApp3/DataContracts/ModelCostCentre.cs b/ConsoleApp3/DataContracts/ModelCostCentre.cs
new file mode 100644
index 0000000..b5877ac
--- /dev/null
+++ b/ConsoleApp3/DataContracts/ModelCostCentre.cs
@@ -0,0 +1,62 @@
+using Newtonsoft.Json;
+using System.Runtime.Serialization;
+using System.Xml.Linq;
+
+namespace ConsoleApp3.DataContracts
+{
+ [DataContract]
+ public class ModelCostCentre
+ {
+ [DataMember(Name = "create", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "create")]
+ public DateTime? Create { get; set; }
+
+ ///
+ /// date the cost centre was last updated
+ ///
+ /// date the cost centre was last updated
+ [DataMember(Name = "update", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "update")]
+ public DateTime? Update { get; set; }
+
+ ///
+ /// sevClient is the unique id every customer has and is used in nearly all operations
+ ///
+ /// sevClient is the unique id every customer has and is used in nearly all operations
+ [DataMember(Name = "sevClient", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "sevClient")]
+ public Object SevClient { get; set; }
+
+ ///
+ ///
+ ///
+ ///
+ [DataMember(Name = "number", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "number")]
+ public string Number { get; set; }
+
+ ///
+ ///
+ ///
+ ///
+ [DataMember(Name = "name", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "name")]
+ public string Name { get; set; }
+
+ ///
+ ///
+ ///
+ ///
+ [DataMember(Name = "color", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "color")]
+ public string Color { get; set; }
+
+ ///
+ ///
+ ///
+ ///
+ [DataMember(Name = "postingAccount", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "postingAccount")]
+ public string PostingAccount { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/ConsoleApp3/DataContracts/ModelEntryType.cs b/ConsoleApp3/DataContracts/ModelEntryType.cs
new file mode 100644
index 0000000..544494d
--- /dev/null
+++ b/ConsoleApp3/DataContracts/ModelEntryType.cs
@@ -0,0 +1,37 @@
+using Newtonsoft.Json;
+using System.Runtime.Serialization;
+
+namespace ConsoleApp3.DataContracts
+{
+ [DataContract]
+ public class ModelEntryType
+ {
+ [DataMember(Name = "create", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "create")]
+ public DateTime? Create { get; set; }
+
+ ///
+ /// date the entry type was last updated
+ ///
+ /// date the entry type was last updated
+ [DataMember(Name = "update", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "update")]
+ public DateTime? Update { get; set; }
+
+ ///
+ /// sevClient is the unique id every customer has and is used in nearly all operations
+ ///
+ /// sevClient is the unique id every customer has and is used in nearly all operations
+ [DataMember(Name = "sevClient", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "sevClient")]
+ public Object SevClient { get; set; }
+
+ ///
+ ///
+ ///
+ ///
+ [DataMember(Name = "name", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "name")]
+ public string Name { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/ConsoleApp3/DataContracts/ModelPaymentMethod.cs b/ConsoleApp3/DataContracts/ModelPaymentMethod.cs
new file mode 100644
index 0000000..6d87dc0
--- /dev/null
+++ b/ConsoleApp3/DataContracts/ModelPaymentMethod.cs
@@ -0,0 +1,50 @@
+using Newtonsoft.Json;
+using System.Runtime.Serialization;
+
+namespace ConsoleApp3.DataContracts
+{
+ [DataContract]
+ public class ModelPaymentMethod
+ {
+ ///
+ /// date the payment method was created
+ ///
+ /// date the payment method was created
+ [DataMember(Name = "create", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "create")]
+ public DateTime? Create { get; set; }
+
+ ///
+ /// date the payment method was last updated
+ ///
+ /// date the payment method was last updated
+ [DataMember(Name = "update", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "update")]
+ public DateTime? Update { get; set; }
+
+ ///
+ /// sevClient is the unique id every customer has and is used in nearly all operations
+ ///
+ /// sevClient is the unique id every customer has and is used in nearly all operations
+ [DataMember(Name = "sevClient", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "sevClient")]
+ public Object SevClient { get; set; }
+
+ ///
+ ///
+ ///
+ ///
+ [DataMember(Name = "name", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "name")]
+ public string Name { get; set; }
+
+ ///
+ ///
+ ///
+ ///
+ [DataMember(Name = "text", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "text")]
+ public string Text { get; set; }
+
+ }
+}
\ No newline at end of file
diff --git a/ConsoleApp3/DataContracts/ModelRechnung.cs b/ConsoleApp3/DataContracts/ModelRechnung.cs
new file mode 100644
index 0000000..72d7d35
--- /dev/null
+++ b/ConsoleApp3/DataContracts/ModelRechnung.cs
@@ -0,0 +1,22 @@
+using Newtonsoft.Json;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ConsoleApp3.DataContracts
+{
+ [DataContract]
+ internal class ModelRechnung
+ {
+ [DataMember(Name = "invoice", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "invoice")]
+ public Invoice Invoice { get; set; }
+
+ [DataMember(Name = "invoicePosSave", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "invoicePosSave")]
+ public InvoicePosSave[] InvoicePosSaves { get; set; }
+ }
+}
diff --git a/ConsoleApp3/DataContracts/ModelSevUser.cs b/ConsoleApp3/DataContracts/ModelSevUser.cs
new file mode 100644
index 0000000..87c8bd1
--- /dev/null
+++ b/ConsoleApp3/DataContracts/ModelSevUser.cs
@@ -0,0 +1,26 @@
+using Newtonsoft.Json;
+using System.Runtime.Serialization;
+using System.Xml.Linq;
+
+namespace ConsoleApp3.DataContracts
+{
+ [DataContract]
+ public class ModelSevUser
+ {
+ [DataMember(Name = "id", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "id")]
+ public int Id { get; set; } = 995002;
+
+ [DataMember(Name = "objectName", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "objectName")]
+ public string objectName { get; set; } = "SevUser";
+
+ ///
+ /// This information is not visible for you
+ ///
+ /// This information is not visible for you
+ [DataMember(Name = "hidden", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "hidden")]
+ public string Hidden { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/ConsoleApp3/DataContracts/ModelStaticCountry.cs b/ConsoleApp3/DataContracts/ModelStaticCountry.cs
new file mode 100644
index 0000000..8cb127c
--- /dev/null
+++ b/ConsoleApp3/DataContracts/ModelStaticCountry.cs
@@ -0,0 +1,66 @@
+using Newtonsoft.Json;
+using System.Runtime.Serialization;
+
+namespace ConsoleApp3.DataContracts
+{
+ [DataContract]
+ public class ModelStaticCountry
+ {
+ [DataMember(Name = "id", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "id")]
+ public int Id { get; set; }
+
+ [DataMember(Name = "objectName", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "objectName")]
+ public string ObjectName { get; set; } = "StaticCountry";
+
+ ///
+ ///
+ ///
+ ///
+ [DataMember(Name = "code", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "code")]
+ public string Code { get; set; }
+
+ ///
+ ///
+ ///
+ ///
+ [DataMember(Name = "name", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "name")]
+ public string Name { get; set; }
+
+ ///
+ ///
+ ///
+ ///
+ [DataMember(Name = "nameEn", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "nameEn")]
+ public string NameEn { get; set; }
+
+ ///
+ ///
+ ///
+ ///
+ [DataMember(Name = "translationCode", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "translationCode")]
+ public string TranslationCode { get; set; }
+
+ ///
+ ///
+ ///
+ ///
+ [DataMember(Name = "locale", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "locale")]
+ public string Locale { get; set; }
+
+ ///
+ ///
+ ///
+ ///
+ [DataMember(Name = "priority", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "priority")]
+ public int? Priority { get; set; }
+
+ }
+}
\ No newline at end of file
diff --git a/ConsoleApp3/DataContracts/ModelTaxSet.cs b/ConsoleApp3/DataContracts/ModelTaxSet.cs
new file mode 100644
index 0000000..30ddfb1
--- /dev/null
+++ b/ConsoleApp3/DataContracts/ModelTaxSet.cs
@@ -0,0 +1,123 @@
+using Newtonsoft.Json;
+using System.Runtime.Serialization;
+using System.Xml.Linq;
+
+namespace ConsoleApp3.DataContracts
+{
+ [DataContract]
+ public class ModelTaxSet
+ {
+ ///
+ /// date the tax set was created
+ ///
+ /// date the tax set was created
+ [DataMember(Name = "create", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "create")]
+ public DateTime? Create { get; set; }
+
+ ///
+ /// date the tax set was last updated
+ ///
+ /// date the tax set was last updated
+ [DataMember(Name = "update", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "update")]
+ public DateTime? Update { get; set; }
+
+ ///
+ /// sevClient is the unique id every customer has and is used in nearly all operations
+ ///
+ /// sevClient is the unique id every customer has and is used in nearly all operations
+ [DataMember(Name = "sevClient", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "sevClient")]
+ public Object SevClient { get; set; }
+
+ ///
+ ///
+ ///
+ ///
+ [DataMember(Name = "text", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "text")]
+ public string Text { get; set; }
+
+ ///
+ ///
+ ///
+ ///
+ [DataMember(Name = "taxRate", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "taxRate")]
+ public float? TaxRate { get; set; }
+
+ ///
+ ///
+ ///
+ ///
+ [DataMember(Name = "code", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "code")]
+ public float? Code { get; set; }
+
+ ///
+ ///
+ ///
+ ///
+ [DataMember(Name = "displayText", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "displayText")]
+ public string DisplayText { get; set; }
+
+ ///
+ ///
+ ///
+ ///
+ [DataMember(Name = "vatReportFieldNet", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "vatReportFieldNet")]
+ public string VatReportFieldNet { get; set; }
+
+ ///
+ ///
+ ///
+ ///
+ [DataMember(Name = "vatReportFieldTax", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "vatReportFieldTax")]
+ public string VatReportFieldTax { get; set; }
+
+ ///
+ ///
+ ///
+ ///
+ [DataMember(Name = "accountingExportVatField", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "accountingExportVatField")]
+ public string AccountingExportVatField { get; set; }
+
+ ///
+ ///
+ ///
+ ///
+ [DataMember(Name = "showInvoice", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "showInvoice")]
+ public bool? ShowInvoice { get; set; }
+
+ ///
+ ///
+ ///
+ ///
+ [DataMember(Name = "showDebitVoucher", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "showDebitVoucher")]
+ public bool? ShowDebitVoucher { get; set; }
+
+ ///
+ ///
+ ///
+ ///
+ [DataMember(Name = "showCreditVoucher", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "showCreditVoucher")]
+ public bool? ShowCreditVoucher { get; set; }
+
+ ///
+ ///
+ ///
+ ///
+ [DataMember(Name = "onlyForVatDec", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "onlyForVatDec")]
+ public bool? OnlyForVatDec { get; set; }
+
+ }
+}
\ No newline at end of file
diff --git a/ConsoleApp3/DataContracts/ModelUnity.cs b/ConsoleApp3/DataContracts/ModelUnity.cs
new file mode 100644
index 0000000..dda3914
--- /dev/null
+++ b/ConsoleApp3/DataContracts/ModelUnity.cs
@@ -0,0 +1,17 @@
+using Newtonsoft.Json;
+using System.Runtime.Serialization;
+
+namespace ConsoleApp3.DataContracts
+{
+ [DataContract]
+ public class ModelUnity
+ {
+ [DataMember(Name = "id", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "id")]
+ public int Id { get; set; } = 1;
+
+ [DataMember(Name = "objectName", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "objectName")]
+ public string ObjectName { get; set; } = "Unity";
+ }
+}
diff --git a/ConsoleApp3/Helper.cs b/ConsoleApp3/Helper.cs
index 9c20e14..3d195d0 100644
--- a/ConsoleApp3/Helper.cs
+++ b/ConsoleApp3/Helper.cs
@@ -61,6 +61,16 @@ static class Helper
}
return result;
}
+
+ internal static DateTime ConvertBezahlDatum(string text)
+ {
+ //21.06.202308:39
+ int uhrzeitsignature = text.IndexOf(':');
+ string datum = text.Substring(0, uhrzeitsignature - 2);
+ string uhrzeit = text.Substring(uhrzeitsignature-2,text.Length - uhrzeitsignature + 2);
+
+ return DateTime.Parse(string.Format("{0} {1}", datum, uhrzeit));
+ }
}
diff --git a/ConsoleApp3/InvoiceParser.cs b/ConsoleApp3/InvoiceParser.cs
index 58e1228..b5523dc 100644
--- a/ConsoleApp3/InvoiceParser.cs
+++ b/ConsoleApp3/InvoiceParser.cs
@@ -43,64 +43,86 @@ namespace CardmarketBot
{
this.kunden = kunden;
}
-
- public List GetInvoices()
+
+ public List GetInvoices()
{
- List result = new List();
+ List result = new List();
+
foreach (Kunde kunde in kunden)
{
- Invoice invoice = new Invoice();
- invoice.Language = "de";
- invoice.VoucherDate = DateTimeConverter(kunde.Bezahldatum); // "2023-02-22T00:00:00.000+01:00"; //
- invoice.Address = new InvoiceAddress()
+ ModelRechnung temp = new ModelRechnung();
+ Invoice rechnung = new Invoice();
+ rechnung.Id = null;
+ rechnung.ObjectName = "Invoice";
+ //rechnung.InvoiceNumber = string.Format("RE-{0}", await GetNextInvoiceNumber()); => Should be done by services.
+ rechnung.InvoiceDate = kunde.Bezahldatum;
+ rechnung.Header = string.Format("Verkauf #{0}",kunde.BestellungID);
+ rechnung.HeadText = "Sehr geehrte Damen und Herren," +
+ "Wir stellen Ihnen für Ihre bestellung folgende Rechnung." +
+ "Bitte Beachte, dass der Lieferdatum die Bestelldatum entspricht.";
+ rechnung.FootText = "Ihre Rechnung ist bereits über Cardmarket beglichen worden.";
+ rechnung.TimeToPay = new DateTime(0);
+ rechnung.Discount = 0;
+ rechnung.Address = string.Format("{0}\n{1} {2}\n{3} {4}", kunde.Name, kunde.Strasse, kunde.Hausnummer, kunde.Plz, kunde.Ort); //"Damian Wessels\nDät Haartje 27A\n26683 Saterland";
+ rechnung.AddressCountry = new ModelStaticCountry()
{
- Name = kunde.Name,
- Street = kunde.Strasse + " " + kunde.Hausnummer,
- City = kunde.Ort,
- Zip = kunde.Plz,
- CountryCode = "DE"
+ Id = 1
};
- invoice.LineItems = new List();
- foreach (var artikel in kunde.Artikels)
- {
- invoice.LineItems.Add(new InvoiceLineItem()
- {
- Type = "custom",
- Name = artikel.ENGName + "(" + artikel.Source + ")",
- Quantity = artikel.Amount,
- UnitName = "Stück",
- UnitPrice = new InvoiceLineUnitPrice()
- {
- Currency = "EUR",
- GrossAmount = Convert.ToDecimal(artikel.Preis),
- TaxRatePercentage = 19
- }
- });
- }
- invoice.LineItems.Add(new InvoiceLineItem()
- {
- Type = "custom",
- Name = "Versandkosten",
- Quantity = 1,
- UnitName = "Stück",
- UnitPrice = new InvoiceLineUnitPrice()
- {
- Currency = "EUR",
- GrossAmount = PortoPreis[kunde.Versandskosten],
- TaxRatePercentage = 19
- }
- });
+ //rechnung.PayDate = new DateTime(2019, 08, 24, 14, 15, 22);
+ rechnung.DeliveryDate = kunde.Bezahldatum;
+ rechnung.Status = EInvoiceStatus.OPEN;
+ rechnung.TaxRate = 19;
+ rechnung.TaxText = "Umsatzsteuer 19%";
+ rechnung.TaxType = "default";
+ rechnung.SendDate = kunde.Bezahldatum;
+ rechnung.InvoiceType = "RE";
- invoice.TotalPrice = new TotalPrice() { Currency = "EUR" };
- invoice.TaxConditions = new TaxConditions() { TaxType = "gross" };
- invoice.ShippingConditions = new ShippingConditions()
+ rechnung.Contact = new ModelContact()
{
- shippingDate = "2023-04-22T00:00:00.000+02:00",
- shippingType = "delivery"
+ Id = 64055231,
+ ObjectName = "Contact"
};
- result.Add(invoice);
+
+ temp.Invoice = rechnung;
+
+ temp.InvoicePosSaves = new InvoicePosSave[kunde.Artikels.Count + 1];
+
+ for(int i = 0; i < kunde.Artikels.Count; i++)
+ {
+ temp.InvoicePosSaves[i] = new InvoicePosSave()
+ {
+ Id = null,
+ MapAll = true,
+ Quantity = (uint)kunde.Artikels[i].Amount,
+ Name = string.Format("{0} ({1})", kunde.Artikels[i].ENGName, kunde.Artikels[i].Source),
+ PositionNumber = 0,
+ TaxRate = 19,
+ Price = Convert.ToDecimal(kunde.Artikels[i].Preis),
+ Discount = 0,
+ PriceGross = Convert.ToDecimal(kunde.Artikels[i].Preis),
+ PriceTax = 19
+ };
+ }
+
+ // Versandskosten
+ temp.InvoicePosSaves[temp.InvoicePosSaves.Length - 1] = new InvoicePosSave()
+ {
+ Id = null,
+ MapAll = true,
+ Quantity = 1,
+ Price = PortoPreis[kunde.Versandskosten],
+ Name = "Versandskosten",
+ PositionNumber = 0,
+ Discount = 0,
+ TaxRate = 19,
+ PriceGross = PortoPreis[kunde.Versandskosten],
+ PriceTax = 19
+ };
+ result.Add(temp);
+
}
return result;
+
}
}
}
\ No newline at end of file
diff --git a/ConsoleApp3/InvoiceService.cs b/ConsoleApp3/InvoiceService.cs
deleted file mode 100644
index f67cdca..0000000
--- a/ConsoleApp3/InvoiceService.cs
+++ /dev/null
@@ -1,46 +0,0 @@
-// See https://aka.ms/new-console-template for more information
-
-using System.Net;
-using System.Text;
-using ConsoleApp3.DataContracts;
-using Newtonsoft.Json;
-
-/*
- *
- * referalPage: /de/OnePiece
-username: Skywalkerex
-userPassword: Magnatpower310!!
-/de/OnePiece/PostGetAction/User_Login
-
-curbpJUJmtup1t.Tq0awbHIhIRwhzMW7vrsWxLAJu.pI9X4r
-*/
-
-namespace CardmarketBot
-{
- class InvoiceService
- {
- private readonly WebRequest request;
-
-
- public InvoiceService(string apiKey)
- {
- request = WebRequest.Create("https://api.lexoffice.io/v1/invoices");
- request.Method = "POST";
- request.Headers.Add("Authorization", string.Format("Bearer {0}",apiKey));
- request.Headers.Add("Accept", "application/json");
-
- }
-
- public void InsertInvoice(Invoice invoice)
- {
- var json = JsonConvert.SerializeObject(invoice);
- byte[] bytearray = Encoding.UTF8.GetBytes(json);
- request.ContentType = "application/json";
- using var reqStream = request.GetRequestStream();
- reqStream.Write(bytearray, 0, bytearray.Length);
- using var response = request.GetResponse();
- Console.WriteLine(((HttpWebResponse)response).StatusDescription);
- reqStream.Close();
- }
- }
-}
\ No newline at end of file
diff --git a/ConsoleApp3/Kunde.cs b/ConsoleApp3/Kunde.cs
index 5cb31aa..b0d6fb7 100644
--- a/ConsoleApp3/Kunde.cs
+++ b/ConsoleApp3/Kunde.cs
@@ -4,6 +4,7 @@ class Kunde
{
string bestellungID = "";
Helper.Porto versandskosten;
+ string? overrideVersandskosten;
string name;
string strasse;
string hausnummer;
@@ -11,7 +12,7 @@ class Kunde
string ort;
string land;
List artikels = new List();
- public string Bezahldatum { get; set; } = "";
+ public DateTime Bezahldatum { get; set; }
public string Name { get => name; set => name = value; }
public string Strasse { get => strasse; set => strasse = value; }
@@ -20,8 +21,24 @@ class Kunde
public string Land { get => land; set => land = value; }
public string BestellungID { get => bestellungID; set => bestellungID = value; }
public Helper.Porto Versandskosten { get => versandskosten; set => versandskosten = value; }
+
public string Hausnummer { get => hausnummer; set => hausnummer = value; }
internal List Artikels { get => artikels; set => artikels = value; }
+ public string? OverrideVersandskosten {
+ get => overrideVersandskosten;
+ set
+ {
+ string[] parts = value.Split(' ');
+ if(parts.Length < 2)
+ {
+ overrideVersandskosten = value;
+ }
+ else
+ {
+ overrideVersandskosten = parts[0];
+ }
+ }
+ }
public Kunde(string Name, string Strasse, string Hausnummer, string PLZ, string Ort, string Land)
{
@@ -32,26 +49,4 @@ class Kunde
ort = Ort;
land = Land;
}
-}
-
-
-
-/*
-HttpWebRequest hwr = (HttpWebRequest)HttpWebRequest.Create(@"https://www.cardmarket.com/de/OnePiece/Orders/Sales/Paid");
-hwr.CookieContainer = cookieContainer;
-hwr.Method = "GET";
-hwr.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36";
-WebResponse wr = hwr.GetResponse();
-string s = new StreamReader(wr.GetResponseStream()).ReadToEnd();
-Console.WriteLine(s);
-
-string GetHashKey(string line)
-{
- var x = line.IndexOf("__cmtkn");
- var d = line.Substring(x + 16);
- var m = d.IndexOf("\"");
- var a = d.Substring(0, m);
- return a;
-}
-
-*/
\ No newline at end of file
+}
\ No newline at end of file
diff --git a/ConsoleApp3/LexofficeService.cs b/ConsoleApp3/LexofficeService.cs
deleted file mode 100644
index 962a2fe..0000000
--- a/ConsoleApp3/LexofficeService.cs
+++ /dev/null
@@ -1,84 +0,0 @@
-// See https://aka.ms/new-console-template for more information
-
-using System.Text;
-using ConsoleApp3.DataContracts;
-using Newtonsoft.Json;
-
-/*
- *
- * referalPage: /de/OnePiece
-username: Skywalkerex
-userPassword: Magnatpower310!!
-/de/OnePiece/PostGetAction/User_Login
-
-curbpJUJmtup1t.Tq0awbHIhIRwhzMW7vrsWxLAJu.pI9X4r
-*/
-
-namespace CardmarketBot
-{
- class LexofficeService
- {
- private readonly HttpClient _client;
- private readonly Random _random = new();
-
- public LexofficeService()
- {
- _client = new HttpClient
- {
- DefaultRequestHeaders =
- {
- { "Authorization", "Bearer curbpJUJmtup1t.Tq0awbHIhIRwhzMW7vrsWxLAJu.pI9X4r" },
- { "Accept", "application/json" }
- }
- };
- }
-
- public void test()
- {
- var d = GetInvoiceAsync("d47936c1-71c6-4e22-b394-3630d7354ebf");
- var m = d.Result;
- Console.WriteLine(m);
- }
-
- public void m(Invoice invoice)
- {
-
-
- }
-
- public async void WriteInvoice(Invoice invoice)
- {
-
-
-
- var jsonSerializerSettings = new JsonSerializerSettings
- {
- MissingMemberHandling = MissingMemberHandling.Ignore
- };
-
- var s = JsonConvert.SerializeObject(invoice, jsonSerializerSettings);
-
- var content = new StringContent(invoice.ToString(), Encoding.UTF8, "application/json");
-
- var uri = LexofficeApiAddressesBuilder.CreateInvoice();
- var result = await _client.PostAsync(uri, content);
- Console.WriteLine(result.Content);
- }
-
- private async Task GetInvoiceAsync(string id)
- {
- var uri = LexofficeApiAddressesBuilder.InvoiceUri(id);
- var response = await _client.GetAsync(uri).ConfigureAwait(false);
-
- response.EnsureSuccessStatusCode();
-
- var contents = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
-
- var jsonSerializerSettings = new JsonSerializerSettings
- {
- MissingMemberHandling = MissingMemberHandling.Ignore
- };
- return JsonConvert.DeserializeObject(contents, jsonSerializerSettings);
- }
- }
-}
\ No newline at end of file
diff --git a/ConsoleApp3/Program.cs b/ConsoleApp3/Program.cs
index 4cabc87..2924831 100644
--- a/ConsoleApp3/Program.cs
+++ b/ConsoleApp3/Program.cs
@@ -1,8 +1,6 @@
-// See https://aka.ms/new-console-template for more information
-
-using System.Diagnostics;
-using static System.Collections.Specialized.BitVector32;
-using ConsoleApp3.DataContracts;
+using ConsoleApp3.DataContracts;
+using ConsoleApp3;
+using ConsoleApp3.Contracts;
namespace CardmarketBot
{
@@ -10,26 +8,38 @@ namespace CardmarketBot
{
static void Main(string[] args)
{
+
+ IUsedRepository usedRepository = new UsedRepository();
+
+
// Kunden aus Cardmarket erstellen
List kunden = new List();
- CardMarketParser cardMarketParser = new CardMarketParser("Skywalkerex", "Magnatpower310!!");
+ CardMarketParser cardMarketParser = new CardMarketParser("More-Tcg", "Magnatpower310!!", usedRepository);
kunden = cardMarketParser.ParseCardMarket();
+
+
// Rechnungen generieren
- List rechnungen = new List();
+ List rechnungen = new List();
InvoiceParser invoiceParser = new InvoiceParser(kunden);
rechnungen = invoiceParser.GetInvoices();
+
+
foreach (var item in rechnungen)
{
- InvoiceService invoiceService = new InvoiceService("curbpJUJmtup1t.Tq0awbHIhIRwhzMW7vrsWxLAJu.pI9X4r");
- invoiceService.InsertInvoice(item);
+ SevdeskService sevdeskService = new SevdeskService("7251554968610b78ca865b2b774b4134");
+ sevdeskService.Create(item);
+
}
+
// Post CSV Erstellen
DeutschePost deutschePost = new DeutschePost(kunden);
deutschePost.GenerateCSV();
+ usedRepository.Insert(kunden);
+
Console.WriteLine("Fertig");
Console.ReadLine();
}
diff --git a/ConsoleApp3/SevdeskService.cs b/ConsoleApp3/SevdeskService.cs
new file mode 100644
index 0000000..86f16a5
--- /dev/null
+++ b/ConsoleApp3/SevdeskService.cs
@@ -0,0 +1,101 @@
+using System.Runtime.Serialization;
+using System.Text;
+using ConsoleApp3.DataContracts;
+using Newtonsoft.Json;
+
+
+namespace CardmarketBot
+{
+ class SevdeskService
+ {
+ private readonly HttpClient _client;
+ private readonly Random _random = new();
+
+ public SevdeskService(string key)
+ {
+ _client = new HttpClient
+ {
+ DefaultRequestHeaders =
+ {
+ { "Authorization", "7251554968610b78ca865b2b774b4134" },
+ { "Accept", "application/json" }
+ }
+ };
+ }
+
+
+ public async void Create(ModelRechnung rechnung)
+ {
+
+ rechnung.Invoice.InvoiceNumber = string.Format("RE-{0}", await GetNextInvoiceNumber());
+ await WriteInv(rechnung);
+ }
+
+
+ private async Task WriteInv(ModelRechnung invoice)
+ {
+ var uri = "https://my.sevdesk.de/api/v1/Invoice/Factory/saveInvoice";
+
+ var t = JsonConvert.SerializeObject(invoice);
+ var content = new StringContent(JsonConvert.SerializeObject(invoice),Encoding.UTF8, "application/json");
+
+ var resp = await _client.PostAsync(uri, content);
+ //Console.WriteLine(resp.EnsureSuccessStatusCode());
+ var contents = await resp.Content.ReadAsStringAsync();
+
+ return true;
+ }
+
+ private async Task GetInvoiceAsync(string id)
+ {
+ //var uri = LexofficeApiAddressesBuilder.InvoiceUri(id);
+ var uri = "https://my.sevdesk.de/api/v1/Invoice/56501411/getPositions";
+ var response = await _client.GetAsync(uri).ConfigureAwait(false);
+
+ response.EnsureSuccessStatusCode();
+
+ var contents = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
+
+ var jsonSerializerSettings = new JsonSerializerSettings
+ {
+ MissingMemberHandling = MissingMemberHandling.Ignore
+ };
+ return JsonConvert.DeserializeObject(contents, jsonSerializerSettings);
+ }
+
+ private async Task GetNextInvoiceNumber()
+ {
+ var uri = "https://my.sevdesk.de/api/v1/SevSequence/Factory/getByType?objectType=Invoice&type=RE";
+ var response = await _client.GetAsync(uri).ConfigureAwait(false);
+ response.EnsureSuccessStatusCode();
+ var contents = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
+
+ var jsonSerializerSettings = new JsonSerializerSettings
+ {
+ MissingMemberHandling = MissingMemberHandling.Ignore
+ };
+ var ob = JsonConvert.DeserializeObject(contents, jsonSerializerSettings);
+
+ return ob.ConfigRechnungsnummer.NextNumber;
+
+ }
+ }
+
+ [DataContract]
+ class RNumbers
+ {
+ [JsonProperty("objects")] public ConfigRechnungnummer ConfigRechnungsnummer { get; set; }
+ }
+
+ [DataContract]
+ class ConfigRechnungnummer
+ {
+ [DataMember(Name = "format", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "format")]
+ public string Format { get; set; } = "";
+
+ [DataMember(Name = "nextSequence", EmitDefaultValue = false)]
+ [JsonProperty(PropertyName = "nextSequence")]
+ public string NextNumber { get; set; } = "";
+ }
+}
\ No newline at end of file
diff --git a/ConsoleApp3/UsedRepository.cs b/ConsoleApp3/UsedRepository.cs
new file mode 100644
index 0000000..3f8cb76
--- /dev/null
+++ b/ConsoleApp3/UsedRepository.cs
@@ -0,0 +1,27 @@
+using ConsoleApp3.Contracts;
+
+namespace ConsoleApp3
+{
+ internal class UsedRepository : IUsedRepository
+ {
+ public List Query => File
+ .ReadLines("usedList.csv")
+ .Select(l => l.Split(','))
+ .Select(p => new String(p[0]))
+ .ToList();
+
+ public void insert(string key)
+ {
+ key += Environment.NewLine;
+ File.AppendAllText("usedList.csv", key);
+ }
+
+ public void Insert(List list)
+ {
+ foreach(var kunde in list)
+ {
+ insert(kunde.BestellungID);
+ }
+ }
+ }
+}
diff --git a/ConsoleApp3/usedList.csv b/ConsoleApp3/usedList.csv
new file mode 100644
index 0000000..5f28270
--- /dev/null
+++ b/ConsoleApp3/usedList.csv
@@ -0,0 +1 @@
+
\ No newline at end of file