Fix 4 post-review issues found in accounting module audit

- Drop orphan VendorCreditId1 column from VendorCreditApplications (was
  scaffolded by EF because WithMany() lacked inverse navigation name;
  fixed WithMany() → WithMany(vc => vc.Applications) in ApplicationDbContext)
- Wire EarlyPaymentDiscount fields through full data path: added
  EarlyPaymentDiscountPercent/Days to CreateInvoiceDto, hidden inputs to
  Invoice Create view, and JS to populate from customer AJAX response
- Add missing [HttpGet] attribute to TaxRatesController.Index
- Document GenerateNow architecture exception with XML rationale

Migration DropOrphanVendorCreditId1 applied. Build: 0 errors, 168 warnings.
Unit tests: 200/200 passing.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-10 11:32:44 -04:00
parent 14026818e2
commit d94612cc9c
8 changed files with 10296 additions and 15 deletions
@@ -667,7 +667,7 @@ public class ApplicationDbContext : IdentityDbContext<ApplicationUser>, IDataPro
.OnDelete(DeleteBehavior.NoAction);
modelBuilder.Entity<VendorCreditApplication>()
.HasOne(vca => vca.VendorCredit)
.WithMany()
.WithMany(vc => vc.Applications)
.HasForeignKey(vca => vca.VendorCreditId)
.OnDelete(DeleteBehavior.NoAction);
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,91 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PowderCoating.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class DropOrphanVendorCreditId1 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_VendorCreditApplications_VendorCredits_VendorCreditId1",
table: "VendorCreditApplications");
migrationBuilder.DropIndex(
name: "IX_VendorCreditApplications_VendorCreditId1",
table: "VendorCreditApplications");
migrationBuilder.DropColumn(
name: "VendorCreditId1",
table: "VendorCreditApplications");
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 5, 10, 15, 25, 26, 831, DateTimeKind.Utc).AddTicks(199));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 5, 10, 15, 25, 26, 831, DateTimeKind.Utc).AddTicks(205));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 5, 10, 15, 25, 26, 831, DateTimeKind.Utc).AddTicks(206));
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<int>(
name: "VendorCreditId1",
table: "VendorCreditApplications",
type: "int",
nullable: true);
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 5, 10, 15, 1, 54, 769, DateTimeKind.Utc).AddTicks(6262));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 5, 10, 15, 1, 54, 769, DateTimeKind.Utc).AddTicks(6270));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 5, 10, 15, 1, 54, 769, DateTimeKind.Utc).AddTicks(6271));
migrationBuilder.CreateIndex(
name: "IX_VendorCreditApplications_VendorCreditId1",
table: "VendorCreditApplications",
column: "VendorCreditId1");
migrationBuilder.AddForeignKey(
name: "FK_VendorCreditApplications_VendorCredits_VendorCreditId1",
table: "VendorCreditApplications",
column: "VendorCreditId1",
principalTable: "VendorCredits",
principalColumn: "Id");
}
}
}
@@ -6293,7 +6293,7 @@ namespace PowderCoating.Infrastructure.Migrations
{
Id = 1,
CompanyId = 0,
CreatedAt = new DateTime(2026, 5, 10, 15, 1, 54, 769, DateTimeKind.Utc).AddTicks(6262),
CreatedAt = new DateTime(2026, 5, 10, 15, 25, 26, 831, DateTimeKind.Utc).AddTicks(199),
Description = "Standard pricing for regular customers",
DiscountPercent = 0m,
IsActive = true,
@@ -6304,7 +6304,7 @@ namespace PowderCoating.Infrastructure.Migrations
{
Id = 2,
CompanyId = 0,
CreatedAt = new DateTime(2026, 5, 10, 15, 1, 54, 769, DateTimeKind.Utc).AddTicks(6270),
CreatedAt = new DateTime(2026, 5, 10, 15, 25, 26, 831, DateTimeKind.Utc).AddTicks(205),
Description = "5% discount for preferred customers",
DiscountPercent = 5m,
IsActive = true,
@@ -6315,7 +6315,7 @@ namespace PowderCoating.Infrastructure.Migrations
{
Id = 3,
CompanyId = 0,
CreatedAt = new DateTime(2026, 5, 10, 15, 1, 54, 769, DateTimeKind.Utc).AddTicks(6271),
CreatedAt = new DateTime(2026, 5, 10, 15, 25, 26, 831, DateTimeKind.Utc).AddTicks(206),
Description = "10% discount for premium customers",
DiscountPercent = 10m,
IsActive = true,
@@ -8171,17 +8171,12 @@ namespace PowderCoating.Infrastructure.Migrations
b.Property<int>("VendorCreditId")
.HasColumnType("int");
b.Property<int?>("VendorCreditId1")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("BillId");
b.HasIndex("VendorCreditId");
b.HasIndex("VendorCreditId1");
b.ToTable("VendorCreditApplications");
});
@@ -9883,15 +9878,11 @@ namespace PowderCoating.Infrastructure.Migrations
.IsRequired();
b.HasOne("PowderCoating.Core.Entities.VendorCredit", "VendorCredit")
.WithMany()
.WithMany("Applications")
.HasForeignKey("VendorCreditId")
.OnDelete(DeleteBehavior.NoAction)
.IsRequired();
b.HasOne("PowderCoating.Core.Entities.VendorCredit", null)
.WithMany("Applications")
.HasForeignKey("VendorCreditId1");
b.Navigation("Bill");
b.Navigation("VendorCredit");