šŸ“„ PayrollFringe.cs Documentation


Location: IrbyImaging.DomainClasses/PayrollFringe.cs
Namespace: IrbyImaging.DomainClasses


šŸ“‘ Table of Contents

  1. Overview & Purpose
  2. Dependencies & Technologies
  3. Key Functional Areas
  4. Data Models & Properties
  5. Entity Framework Configuration
  6. UML Class Diagram
  7. Sample Code Blocks & Usage Examples
  8. Error Handling & Validation
  9. API Endpoints & Integration
  10. 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

  1. Data Modeling

    • Defines the shape of the PayrollFringe and related DBACodeGrossPay entities.
  2. ORM Mapping

    • EF Code‑First annotations ([Table], [Key], [ForeignKey]) to control database schema.
  3. Benefit & Credit Calculations

    • Holds fields for annual values, per‑pay‐period values, and credits (e.g., HealthAnnualValue, HealthCredit).
  4. 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
  • Primary Key:
    • Decorated with [Key]
  • Foreign Key:
    • EmployeeId → Employee entity

šŸ› ļø 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! šŸŽ‰