---
title: BillOverrideService
summary: API reference for BillOverrideService.
status: draft
owner: SAIF Doc Gen
last_reviewed: 2026-09-24
library: SAIF.Services
reference_type: package
---

# BillOverrideService

Implements `IBillOverrideService`, providing CRUD access to EDI bill-level audit bypass overrides via `IUnitOfWork`, stamping each write with the current user's ID from `IUserProfileService`. It also depends on `IValidationService`, though validation is not invoked in the methods shown.

## Purpose
- Retrieves a single bill override by ID, or all bill overrides.
- Adds, edits, and deletes bill overrides, each within its own transaction with rollback on failure.
- Stamps every write with the current user, current time, and an incremented update-number.
- Normalizes a default (`DateTime.MinValue`) statement-thru date to null before persisting.

## Context
- Namespace: `SAIF.Services.Edi`
- Assembly/package: `SAIF.Services` (packaged inside the `SAIF.SAIFCode.Core` NuGet package)

## Public members
| Member | Signature | Purpose |
| --- | --- | --- |
| BillOverrideService(...) | `public BillOverrideService(IUnitOfWork uow, IValidationService validationService, IUserProfileService userProfileService)` | Stores the unit of work, validation service, and user-profile collaborators (all required non-null) and captures the current user's ID for stamping subsequent writes. |
| Get(billId) | `public BillOverride Get(long billId)` | Returns the single bill override matching `billId`, mapped to the contract type; throws if no matching row exists. |
| Get() | `public IEnumerable<Core.Contracts.Edi.BillOverride> Get()` | Returns every bill override in the repository, mapped to contracts. |
| Edit | `public void Edit(long id, Contract.BillOverride billOverrideEdit)` | Stamps `billOverrideEdit`, normalizes a default statement-thru date to null, copies its fields onto the stored entity matching `id`, and commits; rolls back and rethrows on any exception. |
| Add | `public void Add(Contract.BillOverride billOverride)` | Stamps `billOverride`, normalizes a default statement-thru date to null, creates a new override entity from its fields, adds it to the repository, and commits; rolls back and rethrows on any exception. |
| Delete | `public void Delete(long id)` | Loads the override matching `id` and deletes it, committing the transaction; rolls back and rethrows on any exception. |

## Behavioral notes
- Every write operation (`Edit`, `Add`, `Delete`) is wrapped in `unitOfWork.Begin()`/`Commit()`, with an explicit `Rollback()` and rethrow in the `catch` block.
- `Edit` and `Add` both convert a `StatementThruDate` equal to `DateTime.MinValue` into `null` before saving, avoiding an out-of-range date being persisted as a "real" value.
- The injected `IValidationService` is stored but not called from any of the members shown, so no FluentValidation rules currently run before writes in this type*.

> **Note:** Statements marked with * were inferred from code structure, naming conventions, or
> contextual evidence where direct confirmation was not available in source artifacts. Statements
> marked with ** could not be confirmed; treat as unknown until verified.

## Sources
- Services/SAIF.Services/Edi/BillOverrideService.cs
