Refactor: centralize accounting helpers, status constants, and query deduplication
- AccountingDropdownHelper: wired into BillsController and ExpensesController, replacing 35-40 lines of duplicated DB queries per controller - AppConstants.StatusCodes: added Job.* and Quote.* constants to replace all magic status strings across Jobs, Quotes, Appointments, OvenScheduler, AiQuickQuote, QuoteApproval, and AccountingDropdownHelper - AccountingRules: extracted IsNormalDebitBalance into shared Infrastructure helper; removed duplicate private method from AccountBalanceService and LedgerService (~50 lines deleted) - AccountDataExportController: extracted 9 Fetch*Async methods (superset of includes) so Add*Sheet and Build*Csv no longer duplicate DB queries; each entity is queried once regardless of whether XLSX or CSV format is requested - BillsController.Create and ExpensesController.Create wrapped in ExecuteInTransactionAsync; blob uploads moved after commit to keep financial data atomic and prevent orphaned blobs from rolling back - Number generators (Appointments, CreditMemo, OvenBatch) fixed from full-table GetAllAsync to prefix-filtered FindAsync Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -134,4 +134,42 @@ public static class AppConstants
|
||||
public const int Layer3MinJobs = 150; // Minimum jobs with actual powder data before Layer 3 predictive features unlock
|
||||
public const int Layer2MinJobs = 10; // Minimum for efficiency trending to be meaningful
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// String codes stored in the JobStatusLookup and QuoteStatusLookup tables.
|
||||
/// Using constants here means a DB code rename only requires one code change,
|
||||
/// not a grep-and-replace across every controller.
|
||||
/// </summary>
|
||||
public static class StatusCodes
|
||||
{
|
||||
public static class Job
|
||||
{
|
||||
public const string Pending = "PENDING";
|
||||
public const string Quoted = "QUOTED";
|
||||
public const string Approved = "APPROVED";
|
||||
public const string InPreparation = "IN_PREPARATION";
|
||||
public const string Sandblasting = "SANDBLASTING";
|
||||
public const string MaskingTaping = "MASKING_TAPING";
|
||||
public const string Cleaning = "CLEANING";
|
||||
public const string InOven = "IN_OVEN";
|
||||
public const string Coating = "COATING";
|
||||
public const string Curing = "CURING";
|
||||
public const string QualityCheck = "QUALITY_CHECK";
|
||||
public const string Completed = "COMPLETED";
|
||||
public const string ReadyForPickup = "READY_FOR_PICKUP";
|
||||
public const string Delivered = "DELIVERED";
|
||||
public const string OnHold = "ON_HOLD";
|
||||
public const string Cancelled = "CANCELLED";
|
||||
}
|
||||
|
||||
public static class Quote
|
||||
{
|
||||
public const string Draft = "DRAFT";
|
||||
public const string Sent = "SENT";
|
||||
public const string Approved = "APPROVED";
|
||||
public const string Rejected = "REJECTED";
|
||||
public const string Converted = "CONVERTED";
|
||||
public const string Expired = "EXPIRED";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user