Fix Company Settings save, invoice PAID stamp, and purge script
- Company Settings: switch save button from type=submit to type=button to bypass HTML5 form validation blocking the submit event; replace AutoMapper Map() with explicit property assignment so EF change tracking reliably detects mutations; fix showButtonSuccess() never re-enabling the button after a successful save - Invoice PDF: move PAID stamp into the header row as a centered middle column so it sits between the company and invoice blocks without adding height to the document - Purge script: use business-date fields instead of CreatedAt so imported records (which all share today's CreatedAt) are correctly filtered by actual transaction dates Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -230,11 +230,19 @@ public class CompanySettingsController : Controller
|
||||
return Json(new { success = false, message = "Company not found." });
|
||||
}
|
||||
|
||||
// Update company properties
|
||||
_mapper.Map(dto, company);
|
||||
company.UpdatedAt = DateTime.UtcNow;
|
||||
// Explicit assignment avoids AutoMapper quirks with tracked EF entities
|
||||
company.CompanyName = dto.CompanyName.Trim();
|
||||
company.CompanyCode = string.IsNullOrWhiteSpace(dto.CompanyCode) ? null : dto.CompanyCode.Trim();
|
||||
company.PrimaryContactName = dto.PrimaryContactName.Trim();
|
||||
company.PrimaryContactEmail = dto.PrimaryContactEmail.Trim();
|
||||
company.Phone = string.IsNullOrWhiteSpace(dto.Phone) ? null : dto.Phone.Trim();
|
||||
company.Address = string.IsNullOrWhiteSpace(dto.Address) ? null : dto.Address.Trim();
|
||||
company.City = string.IsNullOrWhiteSpace(dto.City) ? null : dto.City.Trim();
|
||||
company.State = string.IsNullOrWhiteSpace(dto.State) ? null : dto.State.Trim();
|
||||
company.ZipCode = string.IsNullOrWhiteSpace(dto.ZipCode) ? null : dto.ZipCode.Trim();
|
||||
company.TimeZone = string.IsNullOrWhiteSpace(dto.TimeZone) ? null : dto.TimeZone.Trim();
|
||||
company.AccountingMethod = dto.AccountingMethod;
|
||||
|
||||
await _unitOfWork.Companies.UpdateAsync(company);
|
||||
await _unitOfWork.CompleteAsync();
|
||||
|
||||
_logger.LogInformation("Company {CompanyId} settings updated by user", companyId);
|
||||
|
||||
Reference in New Issue
Block a user