// See https://aka.ms/new-console-template for more information using ConsoleApp3.DataContracts; /* * * referalPage: /de/OnePiece username: Skywalkerex userPassword: Magnatpower310!! /de/OnePiece/PostGetAction/User_Login curbpJUJmtup1t.Tq0awbHIhIRwhzMW7vrsWxLAJu.pI9X4r */ namespace CardmarketBot { class InvoiceParser { Dictionary PortoPreis = new Dictionary() { {Helper.Porto.BRIEF085, 1.15m }, {Helper.Porto.BRIEF100, 1.30m }, {Helper.Porto.BRIEF160, 2.10m }, {Helper.Porto.BRIEF275, 3.25m }, {Helper.Porto.PRIO210, 2.60m }, {Helper.Porto.PRIO270, 3.20m } }; private static string DateTimeConverter(string input) { //2023-06-20T11:30:00" //2023-02-22T00:00:00.000+01:0 string datum = input.Substring(0, 10); string uhrzeit = input.Substring(10, input.Length - 10); input = string.Format("{0} {1}", datum, uhrzeit); DateTime converted = Convert.ToDateTime(input); var format = "yyyy-MM-ddTHH:mm:ssK"; string res = converted.ToString(format); return string.Format("{0}.000+01:00", res); } List kunden; public InvoiceParser(List kunden) { this.kunden = kunden; } public List GetInvoices() { 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() { Name = kunde.Name, Street = kunde.Strasse + " " + kunde.Hausnummer, City = kunde.Ort, Zip = kunde.Plz, CountryCode = "DE" }; 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 } }); invoice.TotalPrice = new TotalPrice() { Currency = "EUR" }; invoice.TaxConditions = new TaxConditions() { TaxType = "gross" }; invoice.ShippingConditions = new ShippingConditions() { shippingDate = "2023-04-22T00:00:00.000+02:00", shippingType = "delivery" }; result.Add(invoice); } return result; } } }