@ -15,55 +15,72 @@ public static class TexService {
}
private static StringBuilder ? CreateBriefkopf ( Contact recipient , bool tex = false ) {
if ( recipient . Account .AccountName is null ) return null ;
if ( recipient . Account ? .AccountName is null ) return null ;
StringBuilder briefkopf = new ( ) ;
if ( recipient . Gender = = ( byte ) Gender . Male ) briefkopf . AppendLine ( $"Herr {recipient.FirstName} {recipient.LastName}" ) ;
else briefkopf . AppendLine ( $"Frau {recipient.FirstName} {recipient.LastName}" ) ;
if ( tex ) briefkopf . AppendLine ( "\\ \\") ;
if ( tex ) briefkopf . AppendLine ( @ "\\") ;
//AccountNamen mit "&" im Namen abfangen
string accountName = recipient . Account . AccountName . Replace ( "&" , "\\&" ) ;
briefkopf . AppendLine ( $"{accountName}" ) ;
if ( tex ) briefkopf . AppendLine ( "\\ \\") ;
if ( tex ) briefkopf . AppendLine ( @ "\\") ;
briefkopf . AppendLine ( $"{recipient.Account.Street}" ) ;
if ( tex ) briefkopf . AppendLine ( "\\ \\") ;
if ( tex ) briefkopf . AppendLine ( @ "\\") ;
briefkopf . AppendLine ( $"{recipient.Account.Zip} {recipient.Account.City}" ) ;
if ( tex ) briefkopf . AppendLine ( "\\ \\") ;
if ( tex ) briefkopf . AppendLine ( @ "\\") ;
return briefkopf ;
}
private static async Task < StringBuilder ? > CreateTexFile ( Quote quote ) {
if ( quote . LineItems is null ) return null ;
const string rand = "2" ; //RUSettingModel.GetSettingValue(Properties.Settings.Default.userSettingID, "texRand");
StringBuilder texFile = new ( "\\documentclass[a4paper,ngerman,parskip,10pt]{scrlttr2}\n" + "\\usepackage{lmodern}\n" + "\\usepackage[T1]{fontenc}\n" + "\\usepackage[utf8]{inputenc}\n" + "\\usepackage{babel}\n" + "\\usepackage[hidelinks]{hyperref}\n" ) ;
StringBuilder texFile = new ( "\\documentclass[a4paper,ngerman,parskip,10pt]{scrlttr2}\n" +
"\\usepackage{lmodern}\n" + "\\usepackage[T1]{fontenc}\n" +
"\\usepackage[utf8]{inputenc}\n" + "\\usepackage{babel}\n" +
"\\usepackage[hidelinks]{hyperref}\n" ) ;
texFile . AppendLine ( $"\\usepackage[left={rand}cm, right={rand}cm, top={rand}cm, bottom={rand}cm]{{geometry}}\n" ) ;
texFile . AppendLine ( "\\usepackage[table]{xcolor}\n" + "\\usepackage[right]{{eurosym}}\n" + "\\usepackage[locale=DE]{{siunitx}}\n" + "\\usepackage{{scrlayer-scrpage}}\n" + "\\usepackage{{lastpage}}\n" + "\\usepackage{{graphicx}}\n" + "\\usepackage{{multirow}}\n" + "\\usepackage{{longtable}}\n" + "\\usepackage{{enumitem}}\n" + "\\usepackage{{fp, xstring, spreadtab, numprint}}\n" + "\\DeclareSIUnit{{\\sieuro}}{{\\mbox{{\\euro}}}}" ) ;
texFile . AppendLine ( "\\usepackage[table]{xcolor}\n" + "\\usepackage[right]{{eurosym}}\n" +
"\\usepackage[locale=DE]{{siunitx}}\n" + "\\usepackage{{scrlayer-scrpage}}\n" +
"\\usepackage{{lastpage}}\n" + "\\usepackage{{graphicx}}\n" + "\\usepackage{{multirow}}\n" +
"\\usepackage{{longtable}}\n" + "\\usepackage{{enumitem}}\n" +
"\\usepackage{{fp, xstring, spreadtab, numprint}}\n" +
@"\DeclareSIUnit{{\sieuro}}{{\mbox{{\euro}}}}" ) ;
texFile . AppendLine ( $"\\rohead{{{quote.QuotationNumber}}}" ) ;
texFile . AppendLine ( "\\cfoot{Seite \\thepage/\\pageref{LastPage}}\n" + "\\sisetup{round-integer-to-decimal,round-precision=2,round-mode=places}" + "\n\\newcommand{\\produkttitel}[1]{\\textsc{#1}}" + "\n\\renewcommand{\\arraystretch}{1.2}\n\\definecolor{AgilentBlau}{HTML}{0085d5}" + "\n\\setlist{noitemsep}\n\\begin{document}" + "\n\\begin{tabular}{p{0.4\\hsize}p{0.5\\hsize}}" + "\n\\multirow{4}{*}{\\includegraphics[width=0.9\\hsize]{agilentLogo.png}}" + "\n&\\normalsize{Agilent Technologies Deutschland GmbH}\\\\" + "\n&\\normalsize{Life Sciences \\& Chemical Analysis}\\\\" + "\n&\\normalsize{Hewlett-Packard-Str. 8}\\\\" + "\n&\\normalsize{D-76337 Waldbronn}" + "\n\\end{tabular}" + "\n\\par\n\\begin{flushright}" ) ;
texFile . AppendLine ( "\\cfoot{Seite \\thepage/\\pageref{LastPage}}\n" +
"\\sisetup{round-integer-to-decimal,round-precision=2,round-mode=places}" +
"\n\\newcommand{\\produkttitel}[1]{\\textsc{#1}}" +
"\n\\renewcommand{\\arraystretch}{1.2}\n\\definecolor{AgilentBlau}{HTML}{0085d5}" +
"\n\\setlist{noitemsep}\n\\begin{document}" +
"\n\\begin{tabular}{p{0.4\\hsize}p{0.5\\hsize}}" +
"\n\\multirow{4}{*}{\\includegraphics[width=0.9\\hsize]{agilentLogo.png}}" +
"\n&\\normalsize{Agilent Technologies Deutschland GmbH}\\\\" +
"\n&\\normalsize{Life Sciences \\& Chemical Analysis}\\\\" +
"\n&\\normalsize{Hewlett-Packard-Str. 8}\\\\" + "\n&\\normalsize{D-76337 Waldbronn}" +
"\n\\end{tabular}" + "\n\\par\n\\begin{flushright}" ) ;
texFile . AppendLine ( quote . IsPriceInformation ? "\n\\colorbox{AgilentBlau}{\\textcolor{white}{\\textsc{\\Huge{Preisinformation}}}}\n\\end{flushright}\n\\begin{tabular}{p{0.4\\hsize}p{0.6\\hsize}}" : "\n\\colorbox{AgilentBlau}{\\textcolor{white}{\\textsc{\\Huge{Angebot}}}}\n\\end{flushright}\n\\begin{tabular}{p{0.4\\hsize}p{0.6\\hsize}}" ) ;
texFile . AppendLine ( "\n &\n\\multirow{4}{*}{" + "\n\\begin{tabular}{|ll|}" + "\n\\hline" ) ;
texFile . AppendLine ( $"\\textbf{{Angebotsnummer:}}&{quote.QuotationNumber}\\\\" ) ;
texFile . AppendLine ( $ @ "\textbf{{Angebotsnummer:}}&{quote.QuotationNumber}\\") ;
texFile . Append ( $"Angebotdatum:&\\today\\\\\nAngebotsgültigkeit:&{quote.ValidFor} Tage\\\\" ) ;
SalesRep ? salesRep = GenericController . Get < SalesRep > ( sR = > sR . SalesRepId . Equals ( quote . SalesRepId ) ) ;
if ( salesRep is not null ) {
texFile . AppendLine ( $ "\ \textbf{{Ansprechpartner:}}&{salesRep.FirstName} {salesRep.LastName}\\ \\") ;
texFile . AppendLine ( $ "Telefon: &{salesRep.PhoneNumber}\\ \\") ;
texFile . AppendLine ( $ "Mobil:&{salesRep.MobileNumber}\\ \\") ;
texFile . AppendLine ( $ "E-Mail:&\ \href{{mailto:{salesRep.EMail}}}{{{salesRep.EMail}}}\\ \\") ;
texFile . AppendLine ( $ @ "\textbf{{Ansprechpartner:}}&{salesRep.FirstName} {salesRep.LastName}\\") ;
texFile . AppendLine ( $ @ "Telefon: &{salesRep.PhoneNumber}\\") ;
texFile . AppendLine ( $ @ "Mobil:&{salesRep.MobileNumber}\\") ;
texFile . AppendLine ( $ @ "E-Mail:&\href{{mailto:{salesRep.EMail}}}{{{salesRep.EMail}}}\\") ;
}
else {
Debug . WriteLine ( "No SalesRep in Quote!" ) ;
@ -97,19 +114,19 @@ public static class TexService {
switch ( quote . ShowDiscounts ) {
case false :
//mit Einzelpreisen
texFile . AppendLine ( "{| cp{0.71\ \textwidth} cr |} \ \hline") ;
texFile . AppendLine ( @ "{| cp{0.71\textwidth} cr |} \hline") ;
texFile . AppendLine ( @"\textbf{\#} & \textbf{Produktbeschreibung} (Produktnummer) & \textbf{Menge} & \textbf{Preis}\\ \hline \endhead" ) ;
break ;
case true :
//mit Einzelpreisen und Discounts
texFile . AppendLine ( "{| cp{0.595\ \textwidth} crr |} \ \hline") ;
texFile . AppendLine ( @ "{| cp{0.595\textwidth} crr |} \hline") ;
texFile . AppendLine ( @"\textbf{\#} & \textbf{Produktbeschreibung} (Produktnummer) & \textbf{Menge} & \textbf{Discount} & \textbf{Preis}\\ \hline \endhead" ) ;
break ;
}
}
else {
//ohne Einzelpreise
texFile . AppendLine ( "{| cp{0.83\ \textwidth} c |} \ \hline") ;
texFile . AppendLine ( @ "{| cp{0.83\textwidth} c |} \hline") ;
texFile . AppendLine ( @"\textbf{\#} & \textbf{Produktbeschreibung} (Produktnummer) & \textbf{Menge}\\ \hline \endhead" ) ;
}
@ -128,18 +145,18 @@ public static class TexService {
switch ( quote . ShowSinglePrices ) {
case true when ! quote . ShowDiscounts :
//mit Einzelpreisen
lineItemTex = lineItem . OptionNumber ! = "" ? $ "{lineItem.Position} &\ \textbf{{{customDescription.Heading}}} ({lineItem.ProductNumber}\\ #{lineItem.OptionNumber})\ \newline {customDescription.DescriptionText}&{lineItem.Amount}&\\ SI{{{lineItem.Total}}}{{\\ sieuro}}\\ \\" : $ "{lineItem.Position} &\ \textbf{{{customDescription.Heading}}} ({lineItem.ProductNumber})\\ newline {customDescription.DescriptionText}&{lineItem.Amount}&\ \SI{{{lineItem.Total}}}{{\\ sieuro}}\\ \\";
lineItemTex = lineItem . OptionNumber ! = "" ? $ @ "{lineItem.Position} &\textbf{{{customDescription.Heading}}} ({lineItem.ProductNumber}\#{lineItem.OptionNumber})\newline {customDescription.DescriptionText}&{lineItem.Amount}&\SI{{{lineItem.Total}}}{{\sieuro}}\\" : $ @ "{lineItem.Position} &\textbf{{{customDescription.Heading}}} ({lineItem.ProductNumber})\newline {customDescription.DescriptionText}&{lineItem.Amount}&\SI{{{lineItem.Total}}}{{\sieuro}}\\";
break ;
case true : {
if ( quote . ShowDiscounts )
//mit Einzelpreisen und Discounts
lineItemTex = lineItem . OptionNumber ! = "" ? $ "{lineItem.Position} &\ \textbf{{{customDescription.Heading}}} ({lineItem.ProductNumber}\\ #{lineItem.OptionNumber})\ \newline {customDescription.DescriptionText}\\ newline Listenpreis: \ \SI{{{lineItem.ListPrice}}}{{\ \sieuro}}&{lineItem.Amount}&\\ SI{{{lineItem.TotalDiscount}}}{{\\ %}}&\ \SI{{{lineItem.Total}}}{{\\ sieuro}}\\ \\" : $ "{lineItem.Position} &\ \textbf{{{customDescription.Heading}}} ({lineItem.ProductNumber})\ \newline {customDescription.DescriptionText}\\ newline Listenpreis: \ \SI{{{lineItem.ListPrice}}}{{\ \sieuro}}&{lineItem.Amount}&\\ SI{{{lineItem.TotalDiscount}}}{{\\ %}}&\ \SI{{{lineItem.Total}}}{{\\ sieuro}}\\ \\";
lineItemTex = lineItem . OptionNumber ! = "" ? $ @ "{lineItem.Position} &\textbf{{{customDescription.Heading}}} ({lineItem.ProductNumber}\#{lineItem.OptionNumber})\newline {customDescription.DescriptionText}\newline Listenpreis: \SI{{{lineItem.ListPrice}}}{{\sieuro}}&{lineItem.Amount}&\SI{{{lineItem.TotalDiscount}}}{{\%}}&\SI{{{lineItem.Total}}}{{\sieuro}}\\" : $ @ "{lineItem.Position} &\textbf{{{customDescription.Heading}}} ({lineItem.ProductNumber})\newline {customDescription.DescriptionText}\newline Listenpreis: \SI{{{lineItem.ListPrice}}}{{\sieuro}}&{lineItem.Amount}&\SI{{{lineItem.TotalDiscount}}}{{\%}}&\SI{{{lineItem.Total}}}{{\sieuro}}\\";
break ;
}
case false :
//ohne Einzelpreise
lineItemTex = lineItem . OptionNumber ! = "" ? $ "{lineItem.Position} &\ \textbf{{{customDescription.Heading}}} ({lineItem.ProductNumber}\ \#{lineItem.OptionNumber})\\ newline {customDescription.DescriptionText}&{lineItem.Amount}\\ \\" : $ "{lineItem.Position} &\ \textbf{{{customDescription.Heading}}} ({lineItem.ProductNumber})\ \newline {customDescription.DescriptionText}&{lineItem.Amount}\\ \\";
lineItemTex = lineItem . OptionNumber ! = "" ? $ @ "{lineItem.Position} &\textbf{{{customDescription.Heading}}} ({lineItem.ProductNumber}\#{lineItem.OptionNumber})\newline {customDescription.DescriptionText}&{lineItem.Amount}\\" : $ @ "{lineItem.Position} &\textbf{{{customDescription.Heading}}} ({lineItem.ProductNumber})\newline {customDescription.DescriptionText}&{lineItem.Amount}\\";
break ;
}
@ -151,18 +168,18 @@ public static class TexService {
texFile . AppendLine ( "\\vspace{-2cm}\n" + "\\begin{flushright}\n\n" + "\\begin{tabular}{|rr|}\n" + "\\hline" ) ;
//Summe netto
texFile . AppendLine ( $ "\ \textbf{{Summe netto}} & \ \SI{{{quote.TotalNet}}}{{\\ sieuro}}\\ \\") ;
texFile . AppendLine ( $ @ "\textbf{{Summe netto}} & \SI{{{quote.TotalNet}}}{{\sieuro}}\\") ;
//Frachtkosten
texFile . AppendLine ( $ "\ \textbf{{Versand und Bereitstellungskosten ({quote.Freight}\\ %)}} & \ \SI{{{quote.TotalFreightOnly}}}{{\\ sieuro}}\\ \\") ;
texFile . AppendLine ( $ @ "\textbf{{Versand und Bereitstellungskosten ({quote.Freight}\%)}} & \SI{{{quote.TotalFreightOnly}}}{{\sieuro}}\\") ;
//Gesamtsumme netto
texFile . AppendLine ( $ "\ \textbf{{Gesamtsumme netto}} & \ \SI{{{quote.TotalFreight}}}{{\\ sieuro}}\\ \\") ;
texFile . AppendLine ( $ @ "\textbf{{Gesamtsumme netto}} & \SI{{{quote.TotalFreight}}}{{\sieuro}}\\") ;
//mit Mehrwertsteuer
if ( quote . ShowBrutto ) {
texFile . AppendLine ( $ "\ \textbf{{Umsatzsteuer ({quote.Vat}\\ %)}} & \ \SI{{{quote.TotalVat}}}{{\\ sieuro}}\\ \\") ;
texFile . AppendLine ( $ "\ \textbf{{Gesamtsumme brutto}} & \ \SI{{{quote.TotalGross}}}{{\\ sieuro}}\\ \\") ;
texFile . AppendLine ( $ @ "\textbf{{Umsatzsteuer ({quote.Vat}\%)}} & \SI{{{quote.TotalVat}}}{{\sieuro}}\\") ;
texFile . AppendLine ( $ @ "\textbf{{Gesamtsumme brutto}} & \SI{{{quote.TotalGross}}}{{\sieuro}}\\") ;
}
texFile . Append ( "\\hline\n\\end{tabular}\n\n\\end{flushright}\n\nDer Betrag versteht sich zzgl. der gesetzlichen Steuern.\\\\\nDiese werden im Rechnungszeitraum auf der Rechnung gesondert ausgewiesen.\\\\\nZahlungsbedingungen: 30 Tage netto ab Rechnungsdatum.\\\\\nIncoterm (2010) für Lieferungen innerhalb Deutschlands: DDP.\n\\begin{small}\n\n" ) ;