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
@@ -59,6 +59,8 @@
<input type="hidden" asp-for="PreparedById" />
<input type="hidden" asp-for="JobId" />
<input type="hidden" asp-for="CustomerId" id="hiddenCustomerId" />
<input type="hidden" asp-for="EarlyPaymentDiscountPercent" id="EarlyPaymentDiscountPercent" />
<input type="hidden" asp-for="EarlyPaymentDiscountDays" id="EarlyPaymentDiscountDays" />
<div class="row g-4">
<!-- LEFT: Main form -->
@@ -473,8 +475,10 @@
// Trigger due date recalculation (invoice-due-date.js listens to 'change')
termsSelect.dispatchEvent(new Event('change'));
}
// Show/hide early payment discount notice
// Show/hide early payment discount notice and persist values
const discountEl = document.getElementById('earlyPaymentDiscountNotice');
const discountPctField = document.getElementById('EarlyPaymentDiscountPercent');
const discountDaysField = document.getElementById('EarlyPaymentDiscountDays');
if (discountEl) {
if (data.earlyPaymentDiscountPercent > 0) {
discountEl.textContent = `${data.earlyPaymentDiscountPercent}% discount if paid within ${data.earlyPaymentDiscountDays} days`;
@@ -483,6 +487,8 @@
discountEl.classList.add('d-none');
}
}
if (discountPctField) discountPctField.value = data.earlyPaymentDiscountPercent ?? 0;
if (discountDaysField) discountDaysField.value = data.earlyPaymentDiscountDays ?? 0;
}).catch(() => {});
// Fetch tax rate for the selected customer