Add GL account configuration and role mapping entities
- Introduced GlAccountConfig entity for mapping accounting roles to GL account codes. - Added GlAccountConfigConfiguration for database configuration of the singleton GL account mapping. - Created GlAccountRole enum to define accounting roles used in GL postings. - Enhanced error handling with new error codes for unconfigured and invalid GL accounts. - Updated existing DbContext to include GlAccountConfig DbSet.
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
namespace ERPCore.Domain.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// Role → GL account code mapping — a singleton row, same shape as <see cref="GrnConfig"/>.
|
||||
/// <para>
|
||||
/// This is master data, not deployment config. It used to live in <c>appsettings.json</c> as
|
||||
/// per-module <c>Gl*Code</c> keys, which meant (a) only a redeploy could correct a mapping, and
|
||||
/// (b) nothing checked the codes existed in GL until something tried to post. Held here it is
|
||||
/// validated against GL's live chart of accounts on every save, so an unknown or non-postable
|
||||
/// account cannot be stored in the first place — see <c>GlAccountConfigService.UpdateAsync</c>.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// Codes are nullable: a fresh install has nothing mapped, and a posting flow that needs an
|
||||
/// unmapped role fails with <c>GL_ACCOUNT_NOT_CONFIGURED</c> naming that role. Width matches
|
||||
/// GL's own <c>accounts.account_code varchar(20)</c>.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public class GlAccountConfig
|
||||
{
|
||||
/// <summary>Always 1 - the singleton row's id.</summary>
|
||||
public const int SingletonId = 1;
|
||||
|
||||
/// <summary>Matches GL's <c>accounts.account_code</c> column width.</summary>
|
||||
public const int CodeMaxLength = 20;
|
||||
|
||||
public int ConfigId { get; set; }
|
||||
|
||||
/// <summary>Stock on hand (was <c>Grn|Adjustment|SalesDayEnd|Fifo:GlInventoryAccountCode</c>).</summary>
|
||||
public string? InventoryAccountCode { get; set; }
|
||||
|
||||
/// <summary>Recoverable input VAT (was <c>Grn:GlVatRecoverableAccountCode</c>).</summary>
|
||||
public string? VatRecoverableAccountCode { get; set; }
|
||||
|
||||
/// <summary>Trade debtors (was <c>SalesDayEnd|SalesInvoice:GlAccountsReceivableCode</c>).</summary>
|
||||
public string? AccountsReceivableCode { get; set; }
|
||||
|
||||
/// <summary>Goods received not invoiced (was <c>Grn|PurchaseInvoice|Fifo:GlClearingAccountCode</c>).</summary>
|
||||
public string? ClearingAccountCode { get; set; }
|
||||
|
||||
/// <summary>Output tax payable (was <c>SalesDayEnd:GlTaxPayableAccountCode</c>).</summary>
|
||||
public string? TaxPayableAccountCode { get; set; }
|
||||
|
||||
/// <summary>Trade creditors (was <c>PurchaseInvoice:GlAccountsPayableCode</c>).</summary>
|
||||
public string? AccountsPayableCode { get; set; }
|
||||
|
||||
/// <summary>Sales revenue (was <c>SalesDayEnd:GlSalesRevenueAccountCode</c>).</summary>
|
||||
public string? SalesRevenueAccountCode { get; set; }
|
||||
|
||||
/// <summary>Sales discount given (was <c>SalesDayEnd:GlSalesDiscountAccountCode</c>).</summary>
|
||||
public string? SalesDiscountAccountCode { get; set; }
|
||||
|
||||
/// <summary>Inventory gain on adjustment/count (was <c>Adjustment:GlGainAccountCode</c>).</summary>
|
||||
public string? InventoryGainAccountCode { get; set; }
|
||||
|
||||
/// <summary>Cost of goods sold (was <c>SalesDayEnd:GlCogsAccountCode</c>).</summary>
|
||||
public string? CogsAccountCode { get; set; }
|
||||
|
||||
/// <summary>Inventory loss on adjustment/count (was <c>Adjustment:GlLossAccountCode</c>).</summary>
|
||||
public string? InventoryLossAccountCode { get; set; }
|
||||
|
||||
/// <summary>Cash takings at day-end (was <c>SalesDayEnd:GlCashAccountCode</c>).</summary>
|
||||
public string? CashAccountCode { get; set; }
|
||||
|
||||
public DateTime? UpdatedAt { get; set; }
|
||||
|
||||
public int? UpdatedBy { get; set; }
|
||||
public User? UpdatedByUser { get; set; }
|
||||
|
||||
/// <summary>Optimistic concurrency token (ETag source); bumped by ErpDbContext.BumpRowVersions.</summary>
|
||||
public uint RowVersion { get; set; }
|
||||
}
|
||||
Reference in New Issue
Block a user