Ad-hoc quote email, accounting improvements, AI lookup fix, and misc service updates

- Quotes: ad-hoc email modal on Quote Details lets staff send to an address not on file;
  QuotesController passes overrideEmail through to NotificationService
- Quotes/Details view: SMS consent display, email/SMS send button state based on consent
- Accounting module: AccountingDisplayHelpers for consistent ledger formatting;
  AccountsController + Accounts views improvements; AccountingEnums additions
- Bills/Expenses: AI account categorization fixes in BillsController and ExpensesController
- InventoryAiLookupService: TDS cure fallback no longer fires on AiAugmentFromUrl path
  (LookupByUrlAsync already has it built in — was double-fetching)
- PdfService: quote/invoice PDF updates
- PricingCalculationService: minor pricing logic fix
- QuoteProfile: mapping updates for new quote fields
- ApplicationDbContextModelSnapshot: catches up to all 4 migrations in this branch

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-08 20:48:00 -04:00
parent 0d980e651a
commit 9a52e7fae5
19 changed files with 480 additions and 63 deletions
@@ -2431,6 +2431,9 @@ namespace PowderCoating.Infrastructure.Migrations
b.Property<string>("Address")
.HasColumnType("nvarchar(max)");
b.Property<string>("BillingEmail")
.HasColumnType("nvarchar(max)");
b.Property<string>("City")
.HasColumnType("nvarchar(max)");
@@ -3279,6 +3282,9 @@ namespace PowderCoating.Infrastructure.Migrations
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<bool>("IsIncoming")
.HasColumnType("bit");
b.Property<DateTime?>("LastPurchaseDate")
.HasColumnType("datetime2");
@@ -3844,6 +3850,12 @@ namespace PowderCoating.Infrastructure.Migrations
.HasColumnType("uniqueidentifier")
.HasDefaultValueSql("NEWID()");
b.Property<decimal>("ShopSuppliesAmount")
.HasColumnType("decimal(18,2)");
b.Property<decimal>("ShopSuppliesPercent")
.HasColumnType("decimal(18,2)");
b.Property<int?>("ShopWorkerId")
.HasColumnType("int");
@@ -6059,7 +6071,7 @@ namespace PowderCoating.Infrastructure.Migrations
{
Id = 1,
CompanyId = 0,
CreatedAt = new DateTime(2026, 5, 6, 19, 59, 56, 264, DateTimeKind.Utc).AddTicks(846),
CreatedAt = new DateTime(2026, 5, 8, 14, 21, 51, 589, DateTimeKind.Utc).AddTicks(4358),
Description = "Standard pricing for regular customers",
DiscountPercent = 0m,
IsActive = true,
@@ -6070,7 +6082,7 @@ namespace PowderCoating.Infrastructure.Migrations
{
Id = 2,
CompanyId = 0,
CreatedAt = new DateTime(2026, 5, 6, 19, 59, 56, 264, DateTimeKind.Utc).AddTicks(852),
CreatedAt = new DateTime(2026, 5, 8, 14, 21, 51, 589, DateTimeKind.Utc).AddTicks(4424),
Description = "5% discount for preferred customers",
DiscountPercent = 5m,
IsActive = true,
@@ -6081,7 +6093,7 @@ namespace PowderCoating.Infrastructure.Migrations
{
Id = 3,
CompanyId = 0,
CreatedAt = new DateTime(2026, 5, 6, 19, 59, 56, 264, DateTimeKind.Utc).AddTicks(853),
CreatedAt = new DateTime(2026, 5, 8, 14, 21, 51, 589, DateTimeKind.Utc).AddTicks(4426),
Description = "10% discount for premium customers",
DiscountPercent = 10m,
IsActive = true,
@@ -6397,6 +6409,12 @@ namespace PowderCoating.Infrastructure.Migrations
b.Property<string>("ProspectPhone")
.HasColumnType("nvarchar(max)");
b.Property<bool>("ProspectSmsConsent")
.HasColumnType("bit");
b.Property<DateTime?>("ProspectSmsConsentedAt")
.HasColumnType("datetime2");
b.Property<string>("ProspectState")
.HasColumnType("nvarchar(max)");
@@ -407,7 +407,7 @@ Rules:
/// known product page URL without running a Serper search. Used after a catalog hit
/// to augment the catalog record with fields the catalog table doesn't store.
/// </summary>
public async Task<InventoryAiLookupResult> LookupByUrlAsync(string url, string? colorName)
public async Task<InventoryAiLookupResult> LookupByUrlAsync(string url, string? colorName, string? tdsFallbackUrl = null)
{
var apiKey = _config["AI:Anthropic:ApiKey"];
if (string.IsNullOrWhiteSpace(apiKey) || apiKey.StartsWith("your-"))
@@ -484,6 +484,28 @@ Rules:
};
ApplyPowderFallbacks(result);
// TDS fallback: use the TDS URL discovered from the product page, or the one the
// caller passed in (e.g. known from catalog). Try it when cure specs are still missing.
var effectiveTdsUrl = result.TdsUrl ?? tdsFallbackUrl;
if (!string.IsNullOrWhiteSpace(effectiveTdsUrl) &&
(result.CureTemperatureF == null || result.CureTimeMinutes == null))
{
try
{
var tds = await FetchTdsCureSpecsAsync(effectiveTdsUrl!, colorName);
if (tds.Success)
{
if (result.CureTemperatureF == null) result.CureTemperatureF = tds.CureTemperatureF;
if (result.CureTimeMinutes == null) result.CureTimeMinutes = tds.CureTimeMinutes;
}
}
catch (Exception ex)
{
_logger.LogWarning(ex, "TDS fallback failed for {Url}", tdsFallbackUrl);
}
}
return result;
}
catch (Exception ex)