Fix invoice re-creation after void; add payment terms selector and shop supplies line

- Voided invoices no longer block creating a new invoice for the same job: voided invoice's
  JobId FK is cleared so the unique index slot is freed for the replacement
- Invoice Details view shows voided invoices as history rather than hiding them
- Payment terms: standardized SelectList (Due on Receipt, Net 15/30/45/60/90, 2% 10 Net 30,
  COD) with custom-term preservation; invoice-due-date.js auto-updates Due Date on term change
- Shop supplies on direct (no-quote) jobs: InvoicesController derives the shop supplies line
  from the company rate when the job has no source quote to read the pre-agreed amount from
- Job entity: ShopSuppliesAmount + ShopSuppliesPercent fields preserved through job lifecycle
- Migration: AddShopSuppliesAmountToJob

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-08 20:47:34 -04:00
parent fc35fd123c
commit 3278152d83
10 changed files with 9972 additions and 74 deletions
@@ -7,6 +7,7 @@
var invoiceId = (int)(ViewBag.InvoiceId ?? 0);
var jobNumber = ViewBag.JobNumber as string;
var customerName = ViewBag.CustomerName as string;
var canResend = ViewBag.CanResend == true;
}
<div class="d-flex justify-content-between align-items-center mb-4">
@@ -37,7 +38,7 @@
<a tabindex="0" class="help-icon" role="button"
data-bs-toggle="popover" data-bs-placement="right" data-bs-trigger="focus"
data-bs-title="Invoice Details"
data-bs-content="Invoice Date is the date of issue and the reference for payment terms. Due Date drives overdue status and A/R aging. Payment Terms prints on the invoice — changing it here only affects this invoice. Only Draft invoices can be edited; sending locks the invoice.">
data-bs-content="Invoice Date is the date of issue and the reference for payment terms. Due Date drives overdue status and A/R aging. Payment Terms prints on the invoice — changing it here only affects this invoice. Draft, Sent, and Overdue invoices can be edited; Paid and Partially Paid invoices are locked.">
<i class="bi bi-question-circle"></i>
</a>
</div>
@@ -64,7 +65,7 @@
<div class="row g-3 mt-1">
<div class="col-md-12">
<label asp-for="Terms" class="form-label fw-semibold">Payment Terms</label>
<input asp-for="Terms" class="form-control" placeholder="e.g. Net 30" />
<select asp-for="Terms" asp-items="ViewBag.PaymentTermsOptions" class="form-select"></select>
</div>
</div>
</div>
@@ -234,6 +235,15 @@
<!-- Actions -->
<div class="card border-0 shadow-sm">
<div class="card-body d-grid gap-2">
@if (canResend)
{
<div class="form-check mb-1">
<input class="form-check-input" type="checkbox" name="resendToCustomer" value="true" id="resendCheck" />
<label class="form-check-label small" for="resendCheck">
<i class="bi bi-send me-1"></i>Re-send updated invoice to customer
</label>
</div>
}
<button type="submit" class="btn btn-primary">
<i class="bi bi-check-circle me-2"></i>Save Changes
</button>
@@ -242,9 +252,10 @@
</a>
</div>
<div class="card-footer border-0 pt-0">
<div class="alert alert-warning mb-0 small py-2">
<i class="bi bi-exclamation-triangle me-1"></i>
Only <strong>Draft</strong> invoices can be edited. Send the invoice to lock it.
<div class="alert alert-info mb-0 small py-2">
<i class="bi bi-info-circle me-1"></i>
<strong>Draft, Sent,</strong> and <strong>Overdue</strong> invoices can be edited.
Paid invoices are locked.
</div>
</div>
</div>