From ded36a27cf80832777a9468012e427a6d10f781f Mon Sep 17 00:00:00 2001 From: Peter Date: Thu, 16 Apr 2026 12:31:31 +0100 Subject: [PATCH] feat: show live estimated eBay Final Value Fee (12.8%) below price field --- EbayListingTool/Views/NewListingView.xaml | 11 +++++-- EbayListingTool/Views/NewListingView.xaml.cs | 33 ++++++++++++++++++++ 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/EbayListingTool/Views/NewListingView.xaml b/EbayListingTool/Views/NewListingView.xaml index a221973..e12f2a5 100644 --- a/EbayListingTool/Views/NewListingView.xaml +++ b/EbayListingTool/Views/NewListingView.xaml @@ -435,16 +435,21 @@ - + @@ -457,7 +462,7 @@ - diff --git a/EbayListingTool/Views/NewListingView.xaml.cs b/EbayListingTool/Views/NewListingView.xaml.cs index 7e88e4e..1cb985f 100644 --- a/EbayListingTool/Views/NewListingView.xaml.cs +++ b/EbayListingTool/Views/NewListingView.xaml.cs @@ -428,6 +428,39 @@ public partial class NewListingView : UserControl finally { SetPriceBusy(false); } } + private void PriceBox_ValueChanged(object sender, RoutedPropertyChangedEventArgs e) + => UpdateFeeEstimate(); + + private void PostageBox_SelectionChanged(object sender, SelectionChangedEventArgs e) + => UpdateFeeEstimate(); + + private static readonly Dictionary PostageEstimates = new() + { + ["RoyalMailFirstClass"] = 3.70m, + ["RoyalMailSecondClass"] = 2.85m, + ["RoyalMailTracked24"] = 4.35m, + ["RoyalMailTracked48"] = 3.60m, + ["CollectionOnly"] = 0m, + ["FreePostage"] = 0m, + }; + + private void UpdateFeeEstimate() + { + if (BFeeLabel == null) return; + var price = (decimal)(BPriceBox?.Value ?? 0); + if (price <= 0) { BFeeLabel.Visibility = Visibility.Collapsed; return; } + + var postageTag = (BPostageBox?.SelectedItem as ComboBoxItem)?.Tag?.ToString() ?? ""; + PostageEstimates.TryGetValue(postageTag, out var postageEst); + + const decimal fvfRate = 0.128m; + const decimal minFee = 0.30m; + var fee = Math.Max(Math.Round((price + postageEst) * fvfRate, 2), minFee); + + var postageNote = postageEst > 0 ? $" + est. \u00A3{postageEst:F2} postage" : ""; + BFeeLabel.Text = $"Est. eBay fee: \u00A3{fee:F2} (12.8% of \u00A3{price:F2}{postageNote})"; + BFeeLabel.Visibility = Visibility.Visible; + } private void SetPriceBusy(bool busy) { AiPriceBtn.IsEnabled = !busy;