AccountLedger.cs
# 📄 AccountLedger Class Documentation
---
## Table of Contents
1. [Overview & Purpose](#overview--purpose)
2. [Dependencies & Technologies](#dependencies--technologies)
3. [Data Model & Entity Mapping](#data-model--entity-mapping)
4. [Key Properties](#key-properties)
5. [Sample Code Blocks & Usage Examples](#sample-code-blocks--usage-examples)
6. [UML Class Diagram](#uml-class-diagram)
7. [Conclusion](#conclusion)
---
## 📝 Overview & Purpose
The **`AccountLedger`** class is a Plain Old CLR Object (POCO) that represents a single ledger entry in the `irby.AccountLedger` table of your relational database. It is intended for use with Entity Framework Core (or any ORM supporting Data Annotations) to perform CRUD operations, reporting, and financial analysis in the **IrbyImaging** domain.
- 🏷 **Namespace**: `IrbyImaging.DomainClasses`
- 📋 **Table**: `irby.AccountLedger`
- 🔑 **Primary Key**: `AccountLedgerId` (GUID)
This model captures **financial transactions**—invoices, batch postings, purchase orders, receipts, etc.—and enriches them with project, job, and user‐defined metadata.
---
## 🔗 Dependencies & Technologies
| Dependency | Purpose |
|-----------------------------------------|--------------------------------------------------------------|
| `Microsoft.Kiota.Abstractions` | (Imported but not directly used in this class) |
| `System` | Base types |
| `System.ComponentModel.DataAnnotations` | Entity‐framework field & key attributes |
| `System.ComponentModel.DataAnnotations.Schema` | Table & schema mapping attributes |
| `System.Collections.Generic` | Collections (not used here, but common in domain classes) |
| `System.Threading.Tasks` | Task‐based async (not used here) |
> **Note**: Although `Microsoft.Kiota.Abstractions` is imported, this file does not currently leverage Kiota-specific features. It can be safely removed if not used elsewhere.
---
## 📦 Data Model & Entity Mapping
```csharp
using Microsoft.Kiota.Abstractions;
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace IrbyImaging.DomainClasses
{
[Table("AccountLedger", Schema = "irby")]
public class AccountLedger
{
[Key]
public Guid AccountLedgerId { get; set; }
// ... other properties omitted for brevity
}
}
[Table("AccountLedger", Schema = "irby")]
Maps this class to theirby.AccountLedgertable.[Key]
MarksAccountLedgerIdas the primary key.
🧩 Key Properties
Below is a concise table of each property, its CLR type, and a short description:
| Property | Type | Description |
|---|---|---|
| AccountLedgerId | Guid |
🔑 Primary key |
| ReportingYear | int |
The fiscal/reporting year |
| ReportingMonth | int |
The fiscal/reporting month (1–12) |
| JobNumber | string |
Internal job/project identifier |
| JobName | string |
Descriptive name of the job/project |
| AccountId | string |
GL account code |
| Amount | decimal |
Transaction amount |
| Description | string |
Short description of the ledger entry |
| Remark | string |
Free‑form remarks or notes |
| ObjectAccount | string |
Secondary account classification |
| CostCode | string |
Project cost code |
| CostCodeDescription | string |
Human‑readable cost code description |
| ReverseOrVoid | string |
Indicator: reversal or void flag |
| Offset | string |
Offset account or reference |
| InvoiceDate | DateTime? |
Date of invoice (nullable) |
| InvoiceNumber | string |
Invoice reference number |
| PurchaseOrder | string |
PO number |
| ReceiptNumber | string |
Receipt reference |
| GLDate | DateTime |
General Ledger posting date |
| BatchDate | DateTime |
Date when batch was created |
| BatchNumber | string |
Batch identifier |
| DocumentNumber | string |
AP/AR document number |
| DocumentType | string |
Type (e.g., AP, AR, GL) |
| SerialNumber | string |
Equipment or asset serial |
| State | string |
Geographic or status code |
| Customer | string |
Customer or vendor name |
| TypeOfWork | string |
Category of work performed |
| FieldOffice | string |
Field office location |
| Lead, Manager, ProjectEstimator, Superintendent, ProjectManager | ||
string |
Personnel or role responsible | |
| JobType | string |
Classification of the job (e.g., Renovation, New Build) |
💡 Sample Code Blocks & Usage Examples
Below are snippets demonstrating how to integrate AccountLedger into your EF Core DbContext and query it:
using IrbyImaging.DomainClasses;
using Microsoft.EntityFrameworkCore;
public class ApplicationDbContext : DbContext
{
public DbSet<AccountLedger> AccountLedgers { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder options)
=> options.UseSqlServer("YourConnectionStringHere");
}
// In a service or repository:
public async Task<List<AccountLedger>> GetMonthlyLedgerAsync(int year, int month)
{
using var context = new ApplicationDbContext();
return await context.AccountLedgers
.Where(x => x.ReportingYear == year && x.ReportingMonth == month)
.OrderBy(x => x.GLDate)
.ToListAsync();
}
Inserting a new ledger entry:
var newEntry = new AccountLedger
{
AccountLedgerId = Guid.NewGuid(),
ReportingYear = 2023,
ReportingMonth = 4,
JobNumber = "JOB-1234",
JobName = "West Side Renovation",
AccountId = "4000-EXP",
Amount = 1250.75m,
Description = "Concrete delivery",
InvoiceDate = DateTime.UtcNow,
GLDate = DateTime.UtcNow,
BatchDate = DateTime.UtcNow,
BatchNumber = "BATCH-0423"
// ... set other required props
};
using var ctx = new ApplicationDbContext();
ctx.AccountLedgers.Add(newEntry);
await ctx.SaveChangesAsync();
🖼️ UML Class Diagram
Below is a simple PlantUML sketch of the AccountLedger entity:
@startuml
package "IrbyImaging.DomainClasses" {
class AccountLedger {
+ Guid AccountLedgerId
+ int ReportingYear
+ int ReportingMonth
+ string JobNumber
+ string JobName
+ string AccountId
+ decimal Amount
+ string Description
+ DateTime? InvoiceDate
+ DateTime GLDate
+ DateTime BatchDate
+ string BatchNumber
+ ... (other props)
}
}
@enduml
✅ Conclusion
The AccountLedger domain class is the cornerstone for tracking financial transactions in the IrbyImaging system.
By leveraging EF Core’s DataAnnotations, it provides:
- Clear table & schema mapping
- A strongly‐typed contract for ledger data
- Easy integration into LINQ queries and asynchronous workflows
Feel free to extend or decorate this class with navigation properties (e.g., to a Job or Account entity), validation attributes, or business‐logic helpers as your application grows. Enjoy building insightful financial reports! 🚀