📘 GeneralLedger.cs Documentation
🔖 Table of Contents
- Overview & Purpose
- File Header & Metadata
- Dependencies & Technologies
- Data Models
- Entity Framework Configuration
- Relationships & UML Diagram
- Usage Examples
- Conclusion
1. Overview & Purpose
The GeneralLedger.cs file defines two core Domain Classes used within the IrbyImaging.DomainClasses assembly:
- GeneralLedger: Represents a top‑level general ledger account.
- GLTypeDetail: Represents detailed sub‑accounts or types under a general ledger.
These classes are designed for use with Entity Framework Core to map to a relational database (schema: irby). They carry metadata via Data Annotations and enable easy CRUD operations on ledger data.
2. File Header & Metadata
// ***********************************************************************
// Assembly : IrbyImaging.DomainClasses
// Author : kvamshi
// Created : 03-31-2022
// Last Modified By : kvamshi
// Last Modified On : 03-31-2022
// <copyright file="GeneralLedger.cs" company="IrbyImaging.DomainClasses">
// Copyright (c) . All rights reserved.
// </copyright>
// ***********************************************************************
| Field | Value |
|---|---|
| Assembly | IrbyImaging.DomainClasses |
| Author | kvamshi |
| Created On | March 31, 2022 |
| Last Modified By/On | kvamshi – March 31, 2022 |
| Namespace | IrbyImaging.DomainClasses |
3. Dependencies & Technologies
- .NET Core / .NET Standard
- Entity Framework Core (for ORM mappings)
- System.ComponentModel.DataAnnotations
- System.ComponentModel.DataAnnotations.Schema
- System.Collections.Generic
No external third‑party integrations are directly referenced in this file.
4. Data Models
GeneralLedger Class
GeneralLedger maps to the table irby.GeneralLedger and serves as the primary entity.
[Table("GeneralLedger", Schema = "irby")]
public class GeneralLedger
{
[Key]
public Guid Id { get; set; }
public string Code { get; set; }
public string Description { get; set; }
public bool IsInactive { get; set; }
[Display(Name = "Added By")]
public string AddedBy { get; set; }
[Display(Name = "Added Date")]
public DateTime AddedDate { get; set; }
[Display(Name = "Modified By")]
public string ModifiedBy { get; set; }
[Display(Name = "Modified Date")]
public DateTime ModifiedDate { get; set; }
// Navigation property to detail types
public List<GLTypeDetail> GLTypeDetail { get; set; }
}
🔑 Key Properties
| Property | Type | Description |
|---|---|---|
| Id | Guid |
Primary key, uniquely identifies the ledger account. |
| Code | string |
Short code of the ledger (e.g., “1000”). |
| Description | string |
Human‑readable description (e.g., “Cash Account”). |
| IsInactive | bool |
Indicates if the ledger is inactive. |
| AddedBy | string |
Username or ID who created the record. |
| AddedDate | DateTime |
Timestamp of creation. |
| ModifiedBy | string |
Username or ID who last modified the record. |
| ModifiedDate | DateTime |
Timestamp of last modification. |
| GLTypeDetail | List<GLTypeDetail> |
Child items/ sub-accounts. |
GLTypeDetail Class
Defines sub‑accounts or granular types linked to a GeneralLedger.
public class GLTypeDetail
{
public Guid Id { get; set; }
public string Code { get; set; }
public string Description { get; set; }
public bool IsInactive { get; set; }
public string AddedBy { get; set; }
public DateTime AddedDate { get; set; }
public string ModifiedBy { get; set; }
public DateTime ModifiedDate { get; set; }
}
| Property | Type | Description |
|---|---|---|
| Id | Guid |
Primary key of the type detail. |
| Code | string |
Sub‑account code (e.g., “1000‑01”). |
| Description | string |
Sub‑account description. |
| IsInactive | bool |
Marks the sub‑account as inactive. |
| AddedBy | string |
Creator of this detail. |
| AddedDate | DateTime |
Creation timestamp. |
| ModifiedBy | string |
Last modifier of this detail. |
| ModifiedDate | DateTime |
Last modification timestamp. |
5. Entity Framework Configuration
While Data Annotations provide the basic mapping, a typical EF Core DbContext setup might look like:
public class AccountingContext : DbContext
{
public DbSet<GeneralLedger> GeneralLedgers { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
// Map to irby.GeneralLedger table
modelBuilder.Entity<GeneralLedger>()
.ToTable("GeneralLedger", "irby")
.HasKey(gl => gl.Id);
// One-to-many: GeneralLedger -> GLTypeDetail
modelBuilder.Entity<GeneralLedger>()
.HasMany(gl => gl.GLTypeDetail)
.WithOne() // No navigation back-reference
.HasForeignKey("GeneralLedgerId"); // Shadow FK column
}
}
Note: The
GLTypeDetailclass does not explicitly declare a foreign‑key property. You can either:
- Add a
public Guid GeneralLedgerId { get; set; }toGLTypeDetail- Or use shadow properties as shown above (
HasForeignKey("GeneralLedgerId")).
6. Relationships & UML Diagram
classDiagram
IrbyImaging.DomainClasses.GeneralLedger "1" o-- "*" IrbyImaging.DomainClasses.GLTypeDetail : contains
class GeneralLedger {
+Guid Id
+string Code
+string Description
+bool IsInactive
+string AddedBy
+DateTime AddedDate
+string ModifiedBy
+DateTime ModifiedDate
+List<GLTypeDetail> GLTypeDetail
}
class GLTypeDetail {
+Guid Id
+string Code
+string Description
+bool IsInactive
+string AddedBy
+DateTime AddedDate
+string ModifiedBy
+DateTime ModifiedDate
}
7. Usage Examples
Creating a General Ledger Entry
using (var context = new AccountingContext())
{
var ledger = new GeneralLedger
{
Id = Guid.NewGuid(),
Code = "1000",
Description = "Cash Account",
IsInactive = false,
AddedBy = "system",
AddedDate = DateTime.UtcNow,
ModifiedBy = "system",
ModifiedDate = DateTime.UtcNow,
GLTypeDetail = new List<GLTypeDetail>
{
new GLTypeDetail
{
Id = Guid.NewGuid(),
Code = "1000-01",
Description = "Main Checking",
IsInactive = false,
AddedBy = "system",
AddedDate = DateTime.UtcNow,
ModifiedBy = "system",
ModifiedDate = DateTime.UtcNow
}
}
};
context.GeneralLedgers.Add(ledger);
context.SaveChanges();
}
Querying with Includes
using (var context = new AccountingContext())
{
var activeLedgers = context.GeneralLedgers
.Include(gl => gl.GLTypeDetail)
.Where(gl => !gl.IsInactive)
.ToList();
foreach (var gl in activeLedgers)
{
Console.WriteLine($"{gl.Code} - {gl.Description}");
foreach (var detail in gl.GLTypeDetail)
{
Console.WriteLine($" ↳ {detail.Code}: {detail.Description}");
}
}
}
8. Conclusion
🎯 GeneralLedger.cs defines a clean, annotation‑driven domain model for managing general ledger accounts and their details.
- Scalable: Easily extendable with additional properties or relationships.
- EF Core‑ready: Data Annotations plus optional Fluent API snippets enable smooth database mapping.
- Auditable: Tracks creation/modification metadata via standardized fields.
Use these classes to represent your financial chart of accounts, build CRUD services, and integrate with your accounting or reporting modules.
Happy coding! 🚀