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:
@@ -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,
|
||||
|
||||
@@ -984,8 +984,7 @@
|
||||
<div class="d-flex justify-content-between mb-2">
|
||||
<span>
|
||||
<i class="bi bi-fire me-1"></i>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" : "")):
|
||||
</span>
|
||||
<strong>@Model.PricingBreakdown.OvenBatchCost.ToString("C")</strong>
|
||||
</div>
|
||||
@@ -1148,7 +1147,7 @@
|
||||
@if (pb.OvenBatchCost > 0)
|
||||
{
|
||||
<div class="d-flex justify-content-between small mb-1">
|
||||
<span class="text-muted">Oven batch (@pb.OvenBatches batch@(pb.OvenBatches != 1 ? "es" : ""), @pb.OvenCycleMinutes min/cycle)</span>
|
||||
<span class="text-muted">Oven batch (@pb.OvenBatches batch@(pb.OvenBatches != 1 ? "es" : "")@(pb.OvenCycleMinutes > 0 ? $", {pb.OvenCycleMinutes} min/cycle" : ""))</span>
|
||||
<span>@pb.OvenBatchCost.ToString("C")</span>
|
||||
</div>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user