From 3adbd25d76cfde62eff486a0accd6646f8aa64b4 Mon Sep 17 00:00:00 2001 From: DJh2o2 Date: Thu, 10 Feb 2022 09:43:45 +0100 Subject: [PATCH] added freight --- Gremlin/MVVM/Operations/TexHandler.cs | 14 ++++++++++---- Gremlin/MVVM/QuoteUI.xaml.cs | 2 +- Gremlin/MVVM/ViewModels/QuoteViewModel.cs | 14 ++++++++++---- Gremlin/MVVM/Views/QuoteView.xaml | 12 ++++++++---- 4 files changed, 29 insertions(+), 13 deletions(-) diff --git a/Gremlin/MVVM/Operations/TexHandler.cs b/Gremlin/MVVM/Operations/TexHandler.cs index e328d68..2a9e129 100644 --- a/Gremlin/MVVM/Operations/TexHandler.cs +++ b/Gremlin/MVVM/Operations/TexHandler.cs @@ -176,14 +176,20 @@ namespace Gremlin.MVVM + "\\begin{tabular}{|rr|}\n" + "\\hline"); - //Gesamtsumme - _ = texFile.AppendLine($"\\textbf{{Gesamtsumme netto}} & \\SI{{{quoteVM.TotalNet}}}{{\\sieuro}}\\\\"); + //Summe netto + _ = texFile.AppendLine($"\\textbf{{Summe netto}} & \\SI{{{quoteVM.TotalNet}}}{{\\sieuro}}\\\\"); + + //Frachtkosten + _ = texFile.AppendLine($"\\textbf{{Frachtkosten ({quoteVM.Freight}\\%)}} & \\SI{{{quoteVM.TotalFreightOnly}}}{{\\sieuro}}\\\\"); + + //Gesamtsumme netto + _ = texFile.AppendLine($"\\textbf{{Gesamtsumme netto}} & \\SI{{{quoteVM.TotalFreight}}}{{\\sieuro}}\\\\"); //mit Mehrwertsteuer if (quoteVM.ShowBrutto == true) { - _ = texFile.AppendLine($"\\textbf{{Mehrwertsteuer {quoteVM.VAT}\\%}} & \\SI{{{(float)quoteVM.TotalNet * quoteVM.VAT / 100}}}{{\\sieuro}}\\\\"); - _ = texFile.AppendLine($"\\textbf{{Gesamtsumme brutto}} & \\SI{{{(float)quoteVM.TotalNet * (1 + (quoteVM.VAT / 100))}}}{{\\sieuro}}\\\\"); + _ = texFile.AppendLine($"\\textbf{{Mehrwertsteuer ({quoteVM.VAT}\\%)}} & \\SI{{{quoteVM.TotalVAT}}}{{\\sieuro}}\\\\"); + _ = texFile.AppendLine($"\\textbf{{Gesamtsumme brutto}} & \\SI{{{quoteVM.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"); diff --git a/Gremlin/MVVM/QuoteUI.xaml.cs b/Gremlin/MVVM/QuoteUI.xaml.cs index 11c8673..60cc1db 100644 --- a/Gremlin/MVVM/QuoteUI.xaml.cs +++ b/Gremlin/MVVM/QuoteUI.xaml.cs @@ -43,7 +43,7 @@ namespace Gremlin.MVVM private void BtnPasteQuote_Click(object sender, RoutedEventArgs e) { - float vat = 19f; + decimal vat = 19; int warranty = int.TryParse(tbWarranty.Text, out int defaultWarranty) ? defaultWarranty : 12; int validity = int.TryParse(tbValidity.Text, out int defaultValidity) ? defaultValidity : 60; diff --git a/Gremlin/MVVM/ViewModels/QuoteViewModel.cs b/Gremlin/MVVM/ViewModels/QuoteViewModel.cs index ac130d4..2735fb9 100644 --- a/Gremlin/MVVM/ViewModels/QuoteViewModel.cs +++ b/Gremlin/MVVM/ViewModels/QuoteViewModel.cs @@ -18,7 +18,8 @@ namespace Gremlin.MVVM private string _quoteNumber; private int _warranty = 12; private int _validity = 60; - private float _vAT = 19f; + private decimal _vAT = 19; + private decimal _freight = 1; private bool? _showBrutto = true; private bool? _singlePrices = true; private bool? _attachBrochures; @@ -39,9 +40,10 @@ namespace Gremlin.MVVM public bool? AttachDataSheets { get => _attachDataSheets; set { _attachDataSheets = value; NotifyOfPropertyChange(() => AttachDataSheets); } } public bool? UseMailTemplate { get => _useMailTemplate; set { _useMailTemplate = value; NotifyOfPropertyChange(() => UseMailTemplate); } } public bool? ShowDiscounts { get => _showDiscounts; set { _showDiscounts = value; NotifyOfPropertyChange(() => ShowDiscounts); } } - public float VAT { get => _vAT; set { _vAT = value; NotifyOfPropertyChange(() => VAT); } } + public decimal VAT { get => _vAT; set { _vAT = value; NotifyOfPropertyChange(() => VAT); } } public int OppID { get => _oppID; set { _oppID = value; NotifyOfPropertyChange(() => OppID); } } public bool Preisinformation { get => _preisinformation; set { _preisinformation = value; NotifyOfPropertyChange(() => Preisinformation); } } + public decimal Freight { get => _freight; set { _freight = value; NotifyOfPropertyChange(() => Freight); } } public ObservableCollection LineItemsViewModel { get => _lineItemsVM; set { _lineItemsVM = value; NotifyOfPropertyChange(() => LineItemsViewModel); } } public ContactViewModel Recipient { get => _recipient; set { _recipient = value; NotifyOfPropertyChange(() => Recipient); } } @@ -50,6 +52,10 @@ namespace Gremlin.MVVM public decimal TotalListprice => GetTotal("TotalListprice"); public decimal AverageDiscount => GetTotal("AverageDiscount"); public decimal TotalNet => GetTotal("TotalNet"); + public decimal TotalFreightOnly => TotalNet * Freight / 100; + public decimal TotalFreight => TotalNet * (1 + VAT) / 100; + public decimal TotalVAT => TotalFreight * VAT / 100; + public decimal TotalGross => TotalNet * (1 + VAT) / 100; public bool QuoteContains3PP => DoesContains("3PP"); public bool QuoteContainsRB => DoesContains("RB"); @@ -78,7 +84,7 @@ namespace Gremlin.MVVM OppID = random.Next(111111111, 999999999); } - private QuoteViewModel(string quoteNumber, string quoteType, ContactViewModel recipient, ContactViewModel salesRep, bool? brutto, float vAT, int warranty, int validity, string quotePath, bool? singlePrices, bool? brochures, bool? dataSheets, bool? mailTemplate, bool? showDiscounts) + private QuoteViewModel(string quoteNumber, string quoteType, ContactViewModel recipient, ContactViewModel salesRep, bool? brutto, decimal vAT, int warranty, int validity, string quotePath, bool? singlePrices, bool? brochures, bool? dataSheets, bool? mailTemplate, bool? showDiscounts) { QuoteNumber = quoteNumber; QuoteType = quoteType; @@ -96,7 +102,7 @@ namespace Gremlin.MVVM ShowDiscounts = showDiscounts; } - internal static QuoteViewModel CreateQuote(string quoteNumber, ContactViewModel recipient, ContactViewModel salesRep, float vAT = 19f, string quoteType = "ein Analysegerät", bool? brutto = true, int warranty = 12, bool? singlePrices = true, bool? brochures = true, bool? dataSheets = true, bool? mailTemplate = true, string quotePath = "", int validity = 60, bool? showDiscounts = true) + internal static QuoteViewModel CreateQuote(string quoteNumber, ContactViewModel recipient, ContactViewModel salesRep, decimal vAT = 19, string quoteType = "ein Analysegerät", bool? brutto = true, int warranty = 12, bool? singlePrices = true, bool? brochures = true, bool? dataSheets = true, bool? mailTemplate = true, string quotePath = "", int validity = 60, bool? showDiscounts = true) { QuoteViewModel quoteVM = new(quoteNumber, quoteType, recipient, salesRep, brutto, vAT, warranty, validity, quotePath, singlePrices, brochures, dataSheets, mailTemplate, showDiscounts); quoteVM.LineItemsViewModel = new(); diff --git a/Gremlin/MVVM/Views/QuoteView.xaml b/Gremlin/MVVM/Views/QuoteView.xaml index 9d45802..29c459a 100644 --- a/Gremlin/MVVM/Views/QuoteView.xaml +++ b/Gremlin/MVVM/Views/QuoteView.xaml @@ -28,8 +28,10 @@ - - + + + + @@ -41,8 +43,10 @@ - - + + + +