š PayrollFringe.cs Documentation
Location: IrbyImaging.DomainClasses/PayrollFringe.cs
Namespace:IrbyImaging.DomainClasses
š Table of Contents
- Overview & Purpose
- Dependencies & Technologies
- Key Functional Areas
- Data Models & Properties
- Entity Framework Configuration
- UML Class Diagram
- Sample Code Blocks & Usage Examples
- Error Handling & Validation
- API Endpoints & Integration
- Conclusion
š§ Overview & Purpose
The PayrollFringe domain class models weekly fringeābenefit data for a given employee in the Irby Imaging system.
It captures:
- Employee identification & basic info
- Hourly pay rate and actual hours worked
- Detailed breakdown of benefit values (health, dental, life, etc.)
- Fringeābenefit credits
- Total gross pay and perājob (āDBA codeā) gross pay
- Audit information (who/when created or modified)
This structure allows the application to compute, store, and report on fringeābenefit obligations and reimbursements for each pay period.
š Dependencies & Technologies
| Dependency | Purpose |
|---|---|
System |
Core .NET types (e.g., Guid, DateTime) |
System.Collections.Generic |
Collection support (List<T>) |
System.ComponentModel.DataAnnotations |
Validation & EF mapping attributes |
System.ComponentModel.DataAnnotations.Schema |
DB schema and table mapping |
| Entity Framework | ORM for persistence (Code-First) |
šÆ Key Functional Areas
-
Data Modeling
- Defines the shape of the
PayrollFringeand relatedDBACodeGrossPayentities.
- Defines the shape of the
-
ORM Mapping
- EF CodeāFirst annotations (
[Table],[Key],[ForeignKey]) to control database schema.
- EF CodeāFirst annotations (
-
Benefit & Credit Calculations
- Holds fields for annual values, perāpayāperiod values, and credits (e.g.,
HealthAnnualValue,HealthCredit).
- Holds fields for annual values, perāpayāperiod values, and credits (e.g.,
-
Audit Trail
- Tracks creation and modification metadata to support accountability.
š Data Models & Properties
PayrollFringe Class
| Property | Type | Description |
|---|---|---|
Id |
Guid |
Primary key. |
EmployeeId |
Guid |
FK to an Employee. |
PayrollEmployee |
Employee |
Navigation property to the employee. |
| FormāLevel Data | ||
JobId |
Guid |
Identifier for job/site. |
SelectedDate |
DateTime |
Week ending or selection date. |
| Basic Employee Info | ||
EmployeeName |
string |
Full name. |
LaborClassification |
string |
Classification code or description. |
PayRateHr |
decimal |
Hourly pay rate. |
ActualHrsWorkedForWeek |
decimal |
Actual hours worked in the week. |
| Fringe Requirement | ||
FringeRequirement |
decimal |
Percentage or factor for fringe. |
AnnualizedFringe |
decimal |
Calculated annual fringe cost. |
CashInLieuOfFringeRequired |
decimal |
Required cashāinālieu amount. |
CashDue |
decimal |
Cash due amount. |
| Benefits Data | Annual vs. perāperiod values | |
HealthAnnualValue |
decimal |
Annual health benefit cost. |
HealthPayPeriodValue |
decimal |
Health cost per pay period. |
DentalAnnualValue |
decimal |
Annual dental benefit cost. |
DentalPayPeriodValue |
decimal |
Dental cost per pay period. |
| ⦠| ⦠| ⦠|
| Fringe Credit Values | Amount credited against benefits cost. | |
HealthCredit |
decimal |
Credit for health. |
DentalCredit |
decimal |
Credit for dental. |
LifeCredit |
decimal |
Credit for life insurance. |
| ⦠| ⦠| ⦠|
| Total & PerāDBA Code Gross Pay | ||
TotalGrossPay |
decimal |
Sum of gross pay for the period. |
DBACodeGrossPays |
List<DBACodeGrossPay> |
Detailed gross pay by day/code. |
| Audit Fields | ||
AddedBy |
string |
User who created. |
AddedDate |
DateTime |
Creation timestamp. |
ModifiedBy |
string |
Last user to modify. |
ModifiedDate |
DateTime |
Last modification timestamp. |
DBACodeGrossPay Class
| Property | Type | Description |
|---|---|---|
Id |
int |
Primary key. |
FringeBenefitEntryId |
int |
FK linking back to PayrollFringe. |
Day |
string |
Day of week (e.g., āMondayā). |
DBACode |
string |
DBA/job code for cost allocation. |
GrossPayAmount |
decimal |
Gross pay for that day & code. |
šļø Entity Framework Configuration
[Table("PayrollFringe", Schema = "irby")]
public class PayrollFringe {
[Key]
public Guid Id { get; set; }
public Guid EmployeeId { get; set; }
[ForeignKey("EmployeeId")]
public Employee PayrollEmployee { get; set; }
// ⦠other properties ā¦
}
- Table Mapping:
- Table name =
PayrollFringe - Schema =
irby
- Table name =
- Primary Key:
- Decorated with
[Key]
- Decorated with
- Foreign Key:
EmployeeIdāEmployeeentity
š ļø UML Class Diagram
classDiagram
direction LR
class PayrollFringe {
+Guid Id
+Guid EmployeeId
+Employee PayrollEmployee
+Guid JobId
+DateTime SelectedDate
+string EmployeeName
+string LaborClassification
+decimal PayRateHr
+decimal FringeRequirement
+decimal AnnualizedFringe
+decimal ActualHrsWorkedForWeek
+decimal CashInLieuOfFringeRequired
+decimal CashDue
+decimal HealthAnnualValue
+decimal HealthPayPeriodValue
+decimal DentalAnnualValue
+decimal DentalPayPeriodValue
+decimal LifeAnnualValue
+decimal LifePayPeriodValue
+decimal DisabilityAnnualValue
+decimal DisabilityPayPeriodValue
+decimal OtherEAPAnnualValue
+decimal OtherEAPPayPeriodValue
+decimal Annual401KValue
+decimal PayPeriod401KValue
+decimal HolidayAnnualValue
+decimal HolidayPayPeriodValue
+decimal OtherPTOBenefitAnnualValue
+decimal OtherPTOBenefitPayPeriodValue
+decimal ApprenticeshipValue
+decimal OtherBenefitTrainingValue
+decimal HealthCredit
+decimal DentalCredit
+decimal LifeCredit
+decimal DisabilityCredit
+decimal EAPCredit
+decimal _401kCredit
+decimal HolidayCredit
+decimal PTOCredit
+decimal ApprenticeshipCredit
+decimal OtherBenefitTrainingCredit
+decimal TotalGrossPay
+List~DBACodeGrossPay~ DBACodeGrossPays
+string AddedBy
+DateTime AddedDate
+string ModifiedBy
+DateTime ModifiedDate
}
class DBACodeGrossPay {
+int Id
+int FringeBenefitEntryId
+string Day
+string DBACode
+decimal GrossPayAmount
}
PayrollFringe "1" o-- "*" DBACodeGrossPay : has >
PayrollFringe --> Employee : PayrollEmployee >
š” Sample Code Blocks & Usage Examples
1. Creating & Saving a PayrollFringe Record
using (var context = new IrbyDbContext())
{
var fringe = new PayrollFringe
{
Id = Guid.NewGuid(),
EmployeeId = someEmployeeId,
JobId = someJobId,
SelectedDate = new DateTime(2024, 06, 30),
EmployeeName = "Jane Doe",
LaborClassification = "Technician",
PayRateHr = 30.00m,
FringeRequirement = 0.40m,
ActualHrsWorkedForWeek = 40.0m,
CashInLieuOfFringeRequired = 0.00m,
CashDue = 120.00m,
HealthAnnualValue = 3600.00m,
HealthPayPeriodValue = 138.46m,
// ⦠fill other benefit and credit fields ā¦
TotalGrossPay = 1200.00m,
DBACodeGrossPays = new List<DBACodeGrossPay>
{
new DBACodeGrossPay {
Day = "Monday",
DBACode = "DBA01",
GrossPayAmount = 200.00m
},
// ⦠additional days ā¦
},
AddedBy = "admin",
AddedDate = DateTime.UtcNow,
};
context.PayrollFringes.Add(fringe);
context.SaveChanges();
}
2. Querying Fringe Data for Reporting
var records = context.PayrollFringes
.Where(p => p.SelectedDate >= startDate && p.SelectedDate <= endDate)
.Include(p => p.DBACodeGrossPays)
.Include(p => p.PayrollEmployee)
.ToList();
foreach (var record in records)
{
Console.WriteLine($"{record.EmployeeName} | Week of {record.SelectedDate:d} | Total: {record.TotalGrossPay:C}");
}
šØ Error Handling & Validation
Note: This class itself does not implement methods or built-in validation logic beyond DataAnnotations.
Validation and error handling should be implemented at the service or API layer.
- Use DataAnnotations (e.g.,
[Required],[Range]) if stricter model validation is needed. - Handle exceptions when calling
.SaveChanges()to catch DB constraint violations.
š API Endpoints & Integration
This domain class is typically consumed by repository/service layers or Web APIs.
No direct API controllers are defined here. However, sample endpoints could include:
| Endpoint | Method | Description |
|---|---|---|
| GETĀ /payroll/fringes | GET | Retrieve list of all fringe entries |
| GETĀ /payroll/fringes/{id} | GET | Retrieve a single fringe record by Id |
| POSTĀ /payroll/fringes | POST | Create a new fringe record |
| PUTĀ /payroll/fringes/{id} | PUT | Update an existing fringe record |
| DELETEĀ /payroll/fringes/{id} | DELETE | Remove a fringe record (soft/hard) |
š Conclusion
The PayrollFringe and DBACodeGrossPay domain classes form the backbone of the fringeābenefit tracking subsystem in the Irby Imaging application.
They enable:
- Structured storage of detailed benefit & payroll data
- EF CodeāFirst mapping for seamless persistence
- Extensibility for new benefit types or job codes
- Auditability via āAdded/Modifiedā fields
By leveraging these classes, developers can build robust services and APIs for managing payroll fringes, generating reports, and integrating with external accounting or HR systems. š
Happy coding! š