Fix 'Oven (1 batch × 0 min)' display when OvenCycleMinutes is null

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 <noreply@anthropic.com>
This commit is contained in:
2026-05-06 15:35:38 -04:00
parent 4d10175ce3
commit 2d8827ad5c
2 changed files with 9 additions and 5 deletions
@@ -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,