From 2d8827ad5c14aa00c1897950595f36b766cb1028 Mon Sep 17 00:00:00 2001 From: Scott Pouliot Date: Wed, 6 May 2026 15:35:38 -0400 Subject: [PATCH] =?UTF-8?q?Fix=20'Oven=20(1=20batch=20=C3=97=200=20min)'?= =?UTF-8?q?=20display=20when=20OvenCycleMinutes=20is=20null?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Quote.OvenCycleMinutes is nullable — null means 'use company default'. The Details and DownloadPdf actions were converting null → 0 before passing it to the view, so the pricing summary showed '× 0 min' even though the oven cost was correctly calculated from DefaultOvenCycleMinutes. Fix: resolve null against operatingCosts.DefaultOvenCycleMinutes in both controller actions (DownloadPdf now loads operating costs for this). Added a defensive > 0 guard in the view so the minutes clause is omitted entirely if it still comes through as 0. Co-Authored-By: Claude Sonnet 4.6 --- src/PowderCoating.Web/Controllers/QuotesController.cs | 9 +++++++-- src/PowderCoating.Web/Views/Quotes/Details.cshtml | 5 ++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/PowderCoating.Web/Controllers/QuotesController.cs b/src/PowderCoating.Web/Controllers/QuotesController.cs index f4d3f12..2f71d8b 100644 --- a/src/PowderCoating.Web/Controllers/QuotesController.cs +++ b/src/PowderCoating.Web/Controllers/QuotesController.cs @@ -365,6 +365,8 @@ public class QuotesController : Controller } // Build pricing breakdown from stored snapshot values — never recalculate on load + // OvenCycleMinutes null means "use company default"; resolve it here so the view + // never displays "× 0 min" when the oven was priced against DefaultOvenCycleMinutes. quoteDto.PricingBreakdown = new QuotePricingBreakdownDto { MaterialCosts = quote.MaterialCosts, @@ -373,7 +375,7 @@ public class QuotesController : Controller ItemsSubtotal = quote.ItemsSubtotal, OvenBatchCost = quote.OvenBatchCost, OvenBatches = quote.OvenBatches, - OvenCycleMinutes = quote.OvenCycleMinutes ?? 0, + OvenCycleMinutes = quote.OvenCycleMinutes ?? operatingCosts?.DefaultOvenCycleMinutes ?? 0, ShopSuppliesAmount = quote.ShopSuppliesAmount, ShopSuppliesPercent = quote.ShopSuppliesPercent, OverheadCosts = quote.OverheadAmount, @@ -539,6 +541,9 @@ public class QuotesController : Controller // Get company info and logo var currentUser = await _userManager.GetUserAsync(User); + var pdfOperatingCosts = currentUser != null + ? await _pricingService.GetOperatingCostsAsync(currentUser.CompanyId) + : null; // Populate pricing breakdown from stored snapshot values — never recalculate on load quoteDto.PricingBreakdown = new QuotePricingBreakdownDto @@ -549,7 +554,7 @@ public class QuotesController : Controller ItemsSubtotal = quote.ItemsSubtotal, OvenBatchCost = quote.OvenBatchCost, OvenBatches = quote.OvenBatches, - OvenCycleMinutes = quote.OvenCycleMinutes ?? 0, + OvenCycleMinutes = quote.OvenCycleMinutes ?? pdfOperatingCosts?.DefaultOvenCycleMinutes ?? 0, ShopSuppliesAmount = quote.ShopSuppliesAmount, ShopSuppliesPercent = quote.ShopSuppliesPercent, OverheadCosts = quote.OverheadAmount, diff --git a/src/PowderCoating.Web/Views/Quotes/Details.cshtml b/src/PowderCoating.Web/Views/Quotes/Details.cshtml index addeace..d4ff49b 100644 --- a/src/PowderCoating.Web/Views/Quotes/Details.cshtml +++ b/src/PowderCoating.Web/Views/Quotes/Details.cshtml @@ -984,8 +984,7 @@
Oven - (@Model.PricingBreakdown.OvenBatches batch@(Model.PricingBreakdown.OvenBatches != 1 ? "es" : "") - × @Model.PricingBreakdown.OvenCycleMinutes min): + (@Model.PricingBreakdown.OvenBatches batch@(Model.PricingBreakdown.OvenBatches != 1 ? "es" : "")@(Model.PricingBreakdown.OvenCycleMinutes > 0 ? $" × {Model.PricingBreakdown.OvenCycleMinutes} min" : "")): @Model.PricingBreakdown.OvenBatchCost.ToString("C")
@@ -1148,7 +1147,7 @@ @if (pb.OvenBatchCost > 0) {
- Oven batch (@pb.OvenBatches batch@(pb.OvenBatches != 1 ? "es" : ""), @pb.OvenCycleMinutes min/cycle) + Oven batch (@pb.OvenBatches batch@(pb.OvenBatches != 1 ? "es" : "")@(pb.OvenCycleMinutes > 0 ? $", {pb.OvenCycleMinutes} min/cycle" : "")) @pb.OvenBatchCost.ToString("C")
}