📑 PncData Class Documentation

File: IrbyImaging/UI/Models/PncData.cs
Namespace: IrbyImaging.UI.Models
Purpose: Serves as an ASP.NET MVC ViewModel for collecting, displaying, and posting Purchase Card (PNC) data within the UI layer.


🧭 Table of Contents

  1. ✨ Overview & Purpose
  2. 🔑 Key Functional Areas
  3. 🧰 Dependencies & Technologies
  4. 🗂 Data Model: PncData Class
    1. Properties Overview
    2. Mermaid UML Diagram
  5. 🖼 ViewModel Usage in MVC
    1. Controller Example
    2. Razor View Example
  6. 🔧 Sample Code Blocks & Usage Examples
  7. ⚙️ Helper Methods / Utilities
  8. ❗ Error Handling & Return Types
  9. 🌐 API Endpoints Overview
  10. 🔗 Third-Party Integrations
  11. 📝 Conclusion

✨ Overview & Purpose

The PncData class is designed as a ViewModel in the ASP.NET MVC UI layer for the Purchase Card (PNC) reporting feature. It aggregates:

  • Search criteria (dates, IDs, department numbers, etc.)
  • Dropdown data (employees, jobs)
  • Search results (list of Pnc domain entities)

This structure simplifies data binding between the Controller and the Razor View, providing a strongly‑typed model for creation, display, and editing of PNC records.


🔑 Key Functional Areas

  • Search Filters
    Users can filter PNC transactions by date, department/job, employee, card number, merchant, etc.
  • Dropdown Data
    Populates UI dropdowns (SelectListItem) for Employee and Job selectors.
  • Result Set
    Holds a list of domain objects (List<Pnc>) returned from the search.

🧰 Dependencies & Technologies

Technology / Library Purpose
C# / .NET Framework Language & runtime
System.Web.Mvc SelectListItem for dropdowns
IrbyImaging.DomainClasses Pnc domain entity
System.ComponentModel.DataAnnotations (opt.) Could add validation if extended

🗂 Data Model: PncData Class

namespace IrbyImaging.UI.Models
{
    public class PncData
    {
        public Guid PncId { get; set; }
        public DateTime? PostingDate { get; set; }
        public string TransactionId { get; set; }
        public string DepartmentOrJobNumber { get; set; }
        public string Subsidiary { get; set; }
        public string SubLedger { get; set; }
        public string SubLedgerType { get; set; }
        public string CustomerWorkOrderNumber { get; set; }
        public string UnitNumber { get; set; }
        public string EmployeeJdeAB { get; set; }
        public string LastName { get; set; }
        public string FirstName { get; set; }
        public string CardNumber { get; set; }
        public DateTime? TransactionDate { get; set; }
        public decimal SplitAmount { get; set; }
        public string MerchantName { get; set; }
        public string MCC { get; set; }

        // Results & dropdown data
        public List<Pnc> SearchResults { get; set; }
        public List<SelectListItem> EmployeeData { get; set; }
        public List<SelectListItem> JobData { get; set; }
    }
}

Properties Overview

Property Type Description
PncId Guid Unique identifier for the PNC record.
PostingDate DateTime? Date the transaction was posted.
TransactionId string Unique transaction reference.
DepartmentOrJobNumber string Dept. or Job number.
Subsidiary string Subsidiary in Object.Subsidiary format (e.g., 1234.123).
SubLedger string Sub-ledger code.
SubLedgerType string Type of sub-ledger.
CustomerWorkOrderNumber string Customer’s work order number.
UnitNumber string Equipment or unit number.
EmployeeJdeAB string Employee’s JDE AB #.
LastName string Employee’s last name.
FirstName string Employee’s first name.
CardNumber string Masked card number (XXXX-XXXX-XXXX-1234).
TransactionDate DateTime? Date of the actual transaction.
SplitAmount decimal Amount split for this entry.
MerchantName string Merchant or vendor name.
MCC string Merchant Category Code.
SearchResults List<Pnc> List of domain PNC records returned by a search.
EmployeeData List<SelectListItem> Dropdown items for Employee selector.
JobData List<SelectListItem> Dropdown items for Job selector.

Mermaid UML Diagram

classDiagram
    class PncData {
        +Guid PncId
        +DateTime? PostingDate
        +string TransactionId
        +string DepartmentOrJobNumber
        +string Subsidiary
        +string SubLedger
        +string SubLedgerType
        +string CustomerWorkOrderNumber
        +string UnitNumber
        +string EmployeeJdeAB
        +string LastName
        +string FirstName
        +string CardNumber
        +DateTime? TransactionDate
        +decimal SplitAmount
        +string MerchantName
        +string MCC
        +List~Pnc~ SearchResults
        +List~SelectListItem~ EmployeeData
        +List~SelectListItem~ JobData
    }

🖼 ViewModel Usage in MVC

Controller Example

public class PncController : Controller
{
    // GET: /Pnc/Search
    public ActionResult Search()
    {
        var model = new PncData
        {
            EmployeeData = GetEmployeesSelectList(),
            JobData      = GetJobsSelectList(),
            SearchResults = new List<Pnc>()
        };
        return View(model);
    }

    [HttpPost]
    public ActionResult Search(PncData criteria)
    {
        // Validate criteria, call service/repo
        criteria.SearchResults = _pncService.FindByCriteria(criteria);
        // Re-populate dropdowns
        criteria.EmployeeData = GetEmployeesSelectList();
        criteria.JobData      = GetJobsSelectList();
        return View(criteria);
    }

    private List<SelectListItem> GetEmployeesSelectList() { /* ... */ }
    private List<SelectListItem> GetJobsSelectList() { /* ... */ }
}

Razor View Example

@model IrbyImaging.UI.Models.PncData

<form asp-action="Search" method="post">
  <div>
    <label asp-for="PostingDate">Posting Date</label>
    <input asp-for="PostingDate" type="date" class="form-control" />
  </div>
  <div>
    <label asp-for="EmployeeJdeAB">Employee</label>
    @Html.DropDownListFor(m => m.EmployeeJdeAB, Model.EmployeeData, "Select Employee")
  </div>
  <button type="submit" class="btn btn-primary">Search</button>
</form>

<table class="table">
  <thead>
    <tr><th>Txn ID</th><th>Date</th><th>Amount</th>…</tr>
  </thead>
  <tbody>
  @foreach(var item in Model.SearchResults) {
    <tr>
      <td>@item.TransactionId</td>
      <td>@item.TransactionDate?.ToString("MM/dd/yyyy")</td>
      <td>@item.SplitAmount.ToString("C")</td>
      …
    </tr>
  }
  </tbody>
</table>

🔧 Sample Code Blocks & Usage Examples

Populating PncData in Service Layer:

var criteria = new PncData {
    PostingDate           = DateTime.Today.AddDays(-7),
    DepartmentOrJobNumber = "DPT123",
    EmployeeJdeAB         = "EAB456"
};
var results = _pncService.FindByCriteria(criteria);

Rendering Dropdown in JavaScript (optional):

function onDepartmentChange(dep) {
  // AJAX call to get job list
  $.getJSON('/api/jobs', { dept: dep }, function(data) {
    populateSelect('#jobSelect', data);
  });
}

⚙️ Helper Methods / Utilities

None defined within this class.
All data manipulation and helper functions (e.g., creating SelectListItem) reside in Controllers or dedicated service classes.


❗ Error Handling & Return Types

  • Validation should be enforced via DataAnnotations or manual ModelState checks in the Controller.
  • Null checks on SearchResults, EmployeeData, JobData to avoid NullReferenceException in Views.
  • No exceptions thrown directly by this POCO; it's passive.

🌐 API Endpoints Overview

Not directly applicable.
This ViewModel is consumed by MVC Controllers and Razor Views.
Underlying data access may expose Web API endpoints (e.g., /api/pnc/search), but they are outside the scope of PncData.


🔗 Third-Party Integrations

  • None at the ViewModel level.
  • Domain entity Pnc may be populated from a database via Entity Framework or Dapper.

📝 Conclusion

The PncData class is a central ViewModel for PNC (Purchase Card) transactional data in the Irby Imaging application. By bundling search filters, dropdown sources, and search results into one strongly‑typed model, it streamlines:

  • Maintainable code in Controllers and Views
  • Intuitive data binding in Razor markup
  • Separation of concerns between UI layer and domain logic

Use this documentation to quickly onboard new developers, extend search filters, or integrate additional UI elements into the PNC search experience. 🚀