Umgeschrieben auf Sevdesk

This commit is contained in:
2023-07-17 19:10:11 +02:00
parent 47e39bc11f
commit 8c640c426c
32 changed files with 1795 additions and 369 deletions

View File

@@ -43,64 +43,86 @@ namespace CardmarketBot
{
this.kunden = kunden;
}
public List<Invoice> GetInvoices()
public List<ModelRechnung> GetInvoices()
{
List<Invoice> result = new List<Invoice>();
List<ModelRechnung> result = new List<ModelRechnung>();
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<InvoiceLineItem>();
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;
}
}
}