Renaming
start.bat added
This commit is contained in:
171
CardMarketBot/InvoiceParser.cs
Normal file
171
CardMarketBot/InvoiceParser.cs
Normal file
@@ -0,0 +1,171 @@
|
||||
// See https://aka.ms/new-console-template for more information
|
||||
|
||||
using ConsoleApp3.DataContracts;
|
||||
using System.Diagnostics;
|
||||
|
||||
/*
|
||||
*
|
||||
* referalPage: /de/OnePiece
|
||||
username: Skywalkerex
|
||||
userPassword: Magnatpower310!!
|
||||
/de/OnePiece/PostGetAction/User_Login
|
||||
|
||||
curbpJUJmtup1t.Tq0awbHIhIRwhzMW7vrsWxLAJu.pI9X4r
|
||||
*/
|
||||
|
||||
namespace CardmarketBot
|
||||
{
|
||||
class InvoiceParser
|
||||
{
|
||||
Dictionary<Helper.Porto, decimal> PortoPreis = new Dictionary<Helper.Porto, decimal>()
|
||||
{
|
||||
{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<Kunde> kunden;
|
||||
public InvoiceParser(List<Kunde> kunden)
|
||||
{
|
||||
this.kunden = kunden;
|
||||
}
|
||||
|
||||
public List<ModelRechnung> GetInvoices()
|
||||
{
|
||||
List<ModelRechnung> result = new List<ModelRechnung>();
|
||||
|
||||
// 1 => Deutschland
|
||||
// 2 => Schweiz
|
||||
// 3 => Österreich
|
||||
// 6 => Belgien
|
||||
// 11 => Frankreich
|
||||
// 13 => Irland
|
||||
// 14 => Italien
|
||||
// 17 => Luxemburg
|
||||
|
||||
Dictionary<string, int> LaenderCodes = new Dictionary<string, int>()
|
||||
{
|
||||
{ "Deutschland", 1 },
|
||||
{ "Schweiz", 2 },
|
||||
{ "Österreich", 3 },
|
||||
{ "Belgien",6 },
|
||||
{ "Dänemark", 8 },
|
||||
{ "Frankreich", 11 },
|
||||
{ "Irland", 13 },
|
||||
{ "Italien", 14 },
|
||||
{ "Luxemburg", 17 }
|
||||
};
|
||||
|
||||
|
||||
|
||||
foreach (Kunde kunde in kunden)
|
||||
{
|
||||
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 das Lieferdatum dem Bestelldatum entspricht.";
|
||||
rechnung.FootText = "Ihre Rechnung ist bereits über Cardmarket beglichen worden.";
|
||||
rechnung.TimeToPay = 14;
|
||||
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();
|
||||
|
||||
if(LaenderCodes.ContainsKey(kunde.Land))
|
||||
{
|
||||
rechnung.AddressCountry.Id = LaenderCodes[kunde.Land];
|
||||
}
|
||||
else
|
||||
{
|
||||
rechnung.AddressCountry.Id = 1;
|
||||
Console.WriteLine($"Fehler Land wurde nicht richtig gefunden {kunde.Land} Bitte in Sevdesk kontrollieren und Damian die\n" +
|
||||
$"Fehlercode #LC01#{kunde.BestellungID} melden");
|
||||
}
|
||||
|
||||
|
||||
//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";
|
||||
|
||||
rechnung.Contact = new ModelContact()
|
||||
{
|
||||
Id = 64055231,
|
||||
ObjectName = "Contact"
|
||||
};
|
||||
|
||||
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,
|
||||
Name = "Versandskosten",
|
||||
PositionNumber = 0,
|
||||
Discount = 0,
|
||||
TaxRate = 19,
|
||||
PriceTax = 19
|
||||
};
|
||||
if(kunde.OverrideVersandskosten != null)
|
||||
{
|
||||
temp.InvoicePosSaves[temp.InvoicePosSaves.Length - 1].Price = Convert.ToDecimal(kunde.OverrideVersandskosten);
|
||||
temp.InvoicePosSaves[temp.InvoicePosSaves.Length - 1].Price = Convert.ToDecimal(kunde.OverrideVersandskosten);
|
||||
}
|
||||
else
|
||||
{
|
||||
temp.InvoicePosSaves[temp.InvoicePosSaves.Length - 1].Price = PortoPreis[kunde.Versandskosten];
|
||||
temp.InvoicePosSaves[temp.InvoicePosSaves.Length - 1].PriceGross = PortoPreis[kunde.Versandskosten];
|
||||
}
|
||||
result.Add(temp);
|
||||
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user