ZukunftLeben/Export/DatevExporter.cs - Umstellung auf volles DatevFormat
SupportOID=168700
This commit is contained in:
@@ -29,42 +29,76 @@ namespace ZukunftLeben.Export
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
sb.AppendLine("Kontobezeichnung;Sollkonto;Belegdatum;Rechnungsbetrag;Habenkonto");
|
||||
sb.AppendLine(GetDatevKopfzeile(date));
|
||||
sb.Append(GetDatevSpaltenUeberschrift());
|
||||
|
||||
var s = GetMonatlicheBetraegeString(date);
|
||||
if (!String.IsNullOrWhiteSpace(s))
|
||||
{
|
||||
sb.AppendLine();
|
||||
sb.Append(s);
|
||||
}
|
||||
|
||||
s = GetMonatlicheRechnungenString(date);
|
||||
if (!String.IsNullOrWhiteSpace(s))
|
||||
{
|
||||
if (sb.Length > 0)
|
||||
sb.AppendLine();
|
||||
|
||||
sb.AppendLine();
|
||||
sb.Append(s);
|
||||
}
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
private const int DatevSpaltenAnzahl = 125;
|
||||
|
||||
private static String GetDatevKopfzeile(DateTime date)
|
||||
{
|
||||
DateTime monatStart = new DateTime(date.Year, date.Month, 1);
|
||||
DateTime monatEnde = monatStart.AddMonths(1).AddDays(-1);
|
||||
DateTime jahrStart = new DateTime(date.Year, 1, 1);
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.Append("\"DTVF\";700;21;\"Buchungsstapel\";13;");
|
||||
sb.Append(String.Format("{0:yyyyMMddHHmmssfff}", DateTime.Now)); // Erzeugt am
|
||||
sb.Append(";;\"SV\";\"mh\";\"\";38880;11925;");
|
||||
sb.Append(String.Format("{0:yyyyMMdd}", jahrStart)); // WJ-Beginn
|
||||
sb.Append(";4;"); // Sachkontennummernlänge
|
||||
sb.Append(String.Format("{0:yyyyMMdd}", monatStart)); // Datum von
|
||||
sb.Append(";");
|
||||
sb.Append(String.Format("{0:yyyyMMdd}", monatEnde)); // Datum bis
|
||||
sb.Append(";");
|
||||
sb.Append(String.Format("\"Debitorenbuchungen {0:MM}\"", monatStart)); // Bezeichnung
|
||||
sb.Append(";\"mh\";1;0;0;\"EUR\";;\"KP\";;212040;\"03\";;;\"\";\"\"");
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
private static String GetDatevSpaltenUeberschrift()
|
||||
{
|
||||
return "Umsatz (ohne Soll/Haben-Kz);Soll/Haben-Kennzeichen;WKZ Umsatz;Kurs;Basis-Umsatz;WKZ Basis-Umsatz;Konto;Gegenkonto (ohne BU-Schlüssel);"
|
||||
+ "BU-Schlüssel;Belegdatum;Belegfeld 1;Belegfeld 2;Skonto;Buchungstext;Postensperre;Diverse Adressnummer;Geschäftspartnerbank;Sachverhalt;Zinssperre;"
|
||||
+ "Beleglink;Beleginfo - Art 1;Beleginfo - Inhalt 1;Beleginfo - Art 2;Beleginfo - Inhalt 2;Beleginfo - Art 3;Beleginfo - Inhalt 3;Beleginfo - Art 4;"
|
||||
+ "Beleginfo - Inhalt 4;Beleginfo - Art 5;Beleginfo - Inhalt 5;Beleginfo - Art 6;Beleginfo - Inhalt 6;Beleginfo - Art 7;Beleginfo - Inhalt 7;"
|
||||
+ "Beleginfo - Art 8;Beleginfo - Inhalt 8;KOST1 - Kostenstelle;KOST2 - Kostenstelle;Kost-Menge;EU-Land u. UStID (Bestimmung);EU-Steuersatz (Bestimmung);"
|
||||
+ "Abw. Versteuerungsart;Sachverhalt L+L;Funktionsergänzung L+L;BU 49 Hauptfunktionstyp;BU 49 Hauptfunktionsnummer;BU 49 Funktionsergänzung;"
|
||||
+ "Zusatzinformation - Art 1;Zusatzinformation- Inhalt 1;Zusatzinformation - Art 2;Zusatzinformation- Inhalt 2;Zusatzinformation - Art 3;"
|
||||
+ "Zusatzinformation- Inhalt 3;Zusatzinformation - Art 4;Zusatzinformation- Inhalt 4;Zusatzinformation - Art 5;Zusatzinformation- Inhalt 5;"
|
||||
+ "Zusatzinformation - Art 6;Zusatzinformation- Inhalt 6;Zusatzinformation - Art 7;Zusatzinformation- Inhalt 7;Zusatzinformation - Art 8;"
|
||||
+ "Zusatzinformation- Inhalt 8;Zusatzinformation - Art 9;Zusatzinformation- Inhalt 9;Zusatzinformation - Art 10;Zusatzinformation- Inhalt 10;"
|
||||
+ "Zusatzinformation - Art 11;Zusatzinformation- Inhalt 11;Zusatzinformation - Art 12;Zusatzinformation- Inhalt 12;Zusatzinformation - Art 13;"
|
||||
+ "Zusatzinformation- Inhalt 13;Zusatzinformation - Art 14;Zusatzinformation- Inhalt 14;Zusatzinformation - Art 15;Zusatzinformation- Inhalt 15;"
|
||||
+ "Zusatzinformation - Art 16;Zusatzinformation- Inhalt 16;Zusatzinformation - Art 17;Zusatzinformation- Inhalt 17;Zusatzinformation - Art 18;"
|
||||
+ "Zusatzinformation- Inhalt 18;Zusatzinformation - Art 19;Zusatzinformation- Inhalt 19;Zusatzinformation - Art 20;Zusatzinformation- Inhalt 20;"
|
||||
+ "Stück;Gewicht;Zahlweise;Forderungsart;Veranlagungsjahr;Zugeordnete Fälligkeit;Skontotyp;Auftragsnummer;Buchungstyp (Anzahlungen);"
|
||||
+ "USt-Schlüssel (Anzahlungen);EU-Land (Anzahlungen);Sachverhalt L+L (Anzahlungen);EU-Steuersatz (Anzahlungen);Erlöskonto (Anzahlungen);Herkunft-Kz;"
|
||||
+ "Buchungs GUID;KOST-Datum;SEPA-Mandatsreferenz;Skontosperre;Gesellschaftername;Beteiligtennummer;Identifikationsnummer;Zeichnernummer;"
|
||||
+ "Postensperre bis;Bezeichnung SoBil-Sachverhalt;Kennzeichen SoBil-Buchung;Festschreibung;Leistungsdatum;Datum Zuord. Steuerperiode;Fälligkeit;"
|
||||
+ "Generalumkehr (GU);Steuersatz;Land;Abrechnungsreferenz;BVV-Position;EU-Land u. UStID (Ursprung);EU-Steuersatz (Ursprung);Abw. Skontokonto";
|
||||
}
|
||||
|
||||
|
||||
public static String GetMonatlicheRechnungenString(DateTime date)
|
||||
{
|
||||
var sql = GetMonatlicheRechnungenSql(date);
|
||||
|
||||
/*
|
||||
sip.Claim,
|
||||
c.DebitorNumber,
|
||||
ib.InvoiceDate,
|
||||
ib.invoicenumber,
|
||||
c.CostCenter,
|
||||
c2s.Oid,
|
||||
ib.InvoiceId,
|
||||
c2s.Notice AS 'Kostenstelle',
|
||||
ib.`AccountingPeriodEnd`, ib.`AccountingPeriodStart`
|
||||
*/
|
||||
|
||||
// sb.AppendLine("Kontobezeichnung;Sollkonto;Belegdatum,Rechnungsbetrag,Habenkonto");
|
||||
var dt = ExecuteQuery(sql, date);
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
@@ -80,30 +114,38 @@ ib.`AccountingPeriodEnd`, ib.`AccountingPeriodStart`
|
||||
{
|
||||
var c2s = DAOFactory.GenericDAO.LoadByID<CostBearer2SupportConcept>(c2sOid.Value);
|
||||
var c = c2s.SupportConcept.Customer;
|
||||
buchungstext = String.Format("{0}, {1} {2:MM}/{2:yy}-{3:MM}/{3:yy}", c.Person.LastName, c.Person.FirstName, row[9], row[8]);
|
||||
buchungstext = String.Format("{0}, {1} {2:MM}/{2:yy}", c.Person.LastName, c.Person.FirstName, row[8]);
|
||||
}
|
||||
sb.Append(buchungstext);
|
||||
sb.Append(";");
|
||||
string costcenter;
|
||||
costcenter = String.Format("{0}", row[7]); // CB2SC Notice
|
||||
costcenter.Trim();
|
||||
sb.Append(costcenter);
|
||||
sb.Append(";");
|
||||
sb.Append(String.Format("{0:dd.MM.yyyy}", row[2])); // Belegdatum
|
||||
sb.Append(";");
|
||||
sb.Append(String.Format("{0:0.00}", row[0]));
|
||||
sb.Append(";");
|
||||
sb.Append("8100"); // Erlöskonto
|
||||
sb.Append(";");
|
||||
//sb.Append(String.Format("{0}", row[3])); //Belegnummer
|
||||
//sb.Append(";");
|
||||
//sb.Append(String.Format("{0}", row[1])); //Debitor
|
||||
//sb.Append(";");
|
||||
|
||||
string konto = String.Format("{0}", row[1]).Trim(); // customer.DebitorNumber
|
||||
string belegfeld1 = String.Format("{0}", row[3]).Trim(); // ib.invoicenumber
|
||||
sb.Append(BuildBuchungszeile(row[0], konto, "8100", row[2], belegfeld1, buchungstext)); // Betrag, Konto (Debitor), Gegenkonto (Erlöskonto), Belegdatum, Belegfeld 1 (Rechnungsnummer), Buchungstext
|
||||
}
|
||||
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
private static String BuildBuchungszeile(object betrag, string konto, string gegenkonto, object belegdatum, string belegfeld1, string buchungstext)
|
||||
{
|
||||
var felder = new string[DatevSpaltenAnzahl];
|
||||
for (int i = 0; i < felder.Length; i++)
|
||||
{
|
||||
felder[i] = "";
|
||||
}
|
||||
felder[0] = String.Format("{0:0.00}", betrag); // Umsatz (ohne Soll/Haben-Kz)
|
||||
felder[1] = "S"; // Soll/Haben-Kennzeichen
|
||||
//felder[2] = "EUR"; // WKZ Umsatz
|
||||
//felder[3] = "1"; // Kurs
|
||||
//felder[4] = String.Format("{0:0.00}", betrag); // Basis-Umsatz
|
||||
//felder[5] = "EUR"; // WKZ Basis-Umsatz
|
||||
felder[6] = konto; // Konto
|
||||
felder[7] = gegenkonto; // Gegenkonto (ohne BU-Schlüssel)
|
||||
felder[9] = String.Format("{0:ddMM}", belegdatum); // Belegdatum
|
||||
felder[10] = belegfeld1; // Belegfeld 1
|
||||
felder[13] = buchungstext; // Buchungstext
|
||||
return String.Join(";", felder);
|
||||
}
|
||||
|
||||
public static String GetMonatlicheBetraegeString(DateTime date)
|
||||
{
|
||||
var sql = GetMonatlicheBetraegeLvrSql(date);
|
||||
@@ -139,19 +181,9 @@ cb2sc.Notice AS 'Kostenstelle',
|
||||
var c = c2s.SupportConcept.Customer;
|
||||
buchungstext = String.Format("{0}, {1} {2:MM}/{2:yy}", c.Person.LastName, c.Person.FirstName, lastDate);
|
||||
}
|
||||
sb.Append(buchungstext);
|
||||
sb.Append(";");
|
||||
string costcenter;
|
||||
costcenter = String.Format("{0}", row[5]); // CB2SC Notice
|
||||
costcenter.Trim();
|
||||
sb.Append(costcenter);
|
||||
sb.Append(";");
|
||||
sb.Append(String.Format("{0:dd.MM.yyyy}", lastDate)); // Belegdatum
|
||||
sb.Append(";");
|
||||
sb.Append(String.Format("{0:0.00}", row[0]));
|
||||
sb.Append(";");
|
||||
sb.Append("8100"); // Erlöskonto
|
||||
sb.Append(";");
|
||||
|
||||
string konto = String.Format("{0}", row[1]).Trim(); // customer.DebitorNumber
|
||||
sb.Append(BuildBuchungszeile(row[0], konto, "8100", lastDate, "", buchungstext)); // Betrag, Konto (Debitor), Gegenkonto (Erlöskonto), Belegdatum, Belegfeld 1, Buchungstext
|
||||
}
|
||||
|
||||
return sb.ToString();
|
||||
|
||||
Reference in New Issue
Block a user