Phase F: Customer/Vendor Statements, Payment Terms Parser, Tax Rates

F1: GetCustomerStatementAsync/GetVendorStatementAsync on IFinancialReportService;
    StatementLineDto; CustomerStatementDto/VendorStatementDto; Statement action on
    CustomersController + VendorsController; Statement views + PDF download via
    StatementPdfHelper (QuestPDF); Statement button on Customer/Vendor Details pages.

F2: PaymentTermsParser static helper (CalculateDueDate, ParseEarlyPaymentDiscount);
    EarlyPaymentDiscountPercent/Days on Invoice entity; GetCustomerPaymentTerms AJAX
    endpoint on InvoicesController auto-populates Terms + due date on customer select;
    early payment discount notice on Invoice Create.

F3: TaxRate entity (Name/Rate/State/IsDefault/IsActive, tenant-filtered);
    IUnitOfWork.TaxRates + UnitOfWork + ApplicationDbContext; TaxRatesController
    (Index/Create/Edit/Delete/ToggleActive, CompanyAdminOnly); GetTaxRateForCustomer
    AJAX endpoint; Tax Rates in Settings gear menu.

Also fixes AddVendorCredits migration: VendorCreditApplications FKs changed from
CASCADE to NoAction to resolve SQL Server error 1785 (multiple cascade paths).
Migration: AddPaymentTermsAndTaxRates applied locally; 200/200 unit tests pass.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-10 10:55:22 -04:00
parent 1229081436
commit d3a5d827f9
27 changed files with 11492 additions and 12 deletions
@@ -285,3 +285,20 @@ public class VendorCreditApplication : BaseEntity
public virtual VendorCredit VendorCredit { get; set; } = null!;
public virtual Bill Bill { get; set; } = null!;
}
/// <summary>
/// A named tax rate (e.g., "CA Sales Tax 8.25%") used to pre-fill the TaxPercent field on
/// invoices when a taxable customer is selected. Companies can define multiple rates for
/// different jurisdictions and mark one as default.
/// </summary>
public class TaxRate : BaseEntity
{
public string Name { get; set; } = string.Empty;
/// <summary>Rate as a percentage, e.g., 8.25 means 8.25%.</summary>
public decimal Rate { get; set; }
public string? State { get; set; }
public string? Description { get; set; }
/// <summary>When true, this rate is auto-applied to new invoices for taxable customers.</summary>
public bool IsDefault { get; set; }
public bool IsActive { get; set; } = true;
}
@@ -42,6 +42,19 @@ public class Invoice : BaseEntity
public string? Terms { get; set; }
public string? CustomerPO { get; set; }
/// <summary>
/// Early payment discount percentage (e.g., 2 means 2% discount).
/// Parsed from the customer's payment terms when the invoice is created (e.g., "2/10 Net 30").
/// Informational only — does not automatically reduce the amount due.
/// </summary>
public decimal EarlyPaymentDiscountPercent { get; set; }
/// <summary>
/// Number of days after invoice date within which the early payment discount applies.
/// Parsed from the customer's payment terms (e.g., "2/10 Net 30" → 10 days).
/// </summary>
public int EarlyPaymentDiscountDays { get; set; }
/// <summary>
/// Original invoice number from an external system (e.g. QuickBooks invoice # "3048").
/// Stored for searchability and traceability after import. Searchable from the invoice list.