---
title: SAIF.Services.Printing.Remote business rules
summary: Enumerated business rules with per-rule trigger, enforcement, and outcomes.
status: draft
owner: <owner>
last_reviewed: 2026-07-24
library: SAIF.Services.Printing.Remote
reference_type: package
---

# SAIF.Services.Printing.Remote business rules

This page captures business rules enforced by this library.

## BR-001: Row-count contention check

| Field | Value |
| --- | --- |
| **Statement** | Every insert, update, and delete operation checks that exactly one row was affected; if `RowsAffected <> 1`, an error message is added to signal a contention or unexpected state. |
| **Trigger** | Completion of any `AfterInsert`, `AfterUpdate`, or `AfterDelete` lifecycle method across all six business objects. |
| **Enforcement** | Each `After*` method inspects `RowsAffected` and calls `AddErrorMessage(...)` when the count is not exactly 1. Implemented in `clsXDeferredPrint.vb`, `clsXDeferredPrintCollection.vb`, `clsXDocument.vb`, `clsXPrintControl.vb`, `clsXPrintControlCollection.vb`. Note: `clsXDeferredPrint.AfterDelete` has its contention check commented out — no live post-delete validation applies for single-item deferred print deletes.* |
| **Outcome** | The calling layer receives an error condition when a write does not affect exactly one row, enabling the consumer to handle concurrency conflicts or data-integrity violations. |
| **Tables** | [XDEFERRED_PRINT](database-tables.md#xdeferred_print), [XPRINT_CONTROL](database-tables.md#xprint_control), [XDOCUMENT](database-tables.md#xdocument) |
| **SQL** | [SQL-004](sql/SQL-004-saif-services-printing-remote.md), [SQL-006](sql/SQL-006-saif-services-printing-remote.md), [SQL-007](sql/SQL-007-saif-services-printing-remote.md), [SQL-015](sql/SQL-015-saif-services-printing-remote.md), [SQL-017](sql/SQL-017-saif-services-printing-remote.md), [SQL-019](sql/SQL-019-saif-services-printing-remote.md), [SQL-021](sql/SQL-021-saif-services-printing-remote.md), [SQL-022](sql/SQL-022-saif-services-printing-remote.md), [SQL-023](sql/SQL-023-saif-services-printing-remote.md) |
| **Source** | `Services\SAIF.Services.Printing.Remote\clsXDeferredPrint.vb`, `Services\SAIF.Services.Printing.Remote\clsXDocument.vb`, `Services\SAIF.Services.Printing.Remote\clsXPrintControl.vb`, `Services\SAIF.Services.Printing.Remote\clsXPrintControlCollection.vb` |

---

## BR-002: Deferred print retention/eligibility rule

| Field | Value |
| --- | --- |
| **Statement** | A deferred print item is eligible for retrieval when its `PrintedDate` is before a supplied cutoff date, or when its `CreateDate` is more than 30 days old — regardless of print status. |
| **Trigger** | Retrieval of `clsXDeferredPrintCollection` using `RetrieveType = byDate`. |
| **Enforcement** | `clsXDeferredPrintCollection.Criteria.New(inDataportal, inPrintedDate)` computes `ThirtyDaysAgoDate = Today.AddDays(-30)`. `BeforeRetrieve` appends `WHERE PRINTED_DATE < :PrintedDate OR CREATE_DATE < :ThirtyDaysAgoDate` to the base `RetrieveSQL` text (SQL-010, Variant A). |
| **Outcome** | Stale or previously processed items become selectable for cleanup or reprocessing regardless of their current print status. |
| **Tables** | [XDEFERRED_PRINT](database-tables.md#xdeferred_print) |
| **SQL** | [SQL-010](sql/SQL-010-saif-services-printing-remote.md) |
| **Source** | `Services\SAIF.Services.Printing.Remote\clsXDeferredPrintCollection.vb` |

---

## BR-003: Print-control batch staleness rule

| Field | Value |
| --- | --- |
| **Statement** | A print-control batch is selected for the pending-processing collection when `PROCESSED_DATE < :ProcessedDate` or `CREATE_DATE < :ThirtyDaysAgoDate` (30-day-old default). |
| **Trigger** | Retrieval of `clsXPrintControlCollection` via `GetXprintControlCollection(inProcessedDate)`. |
| **Enforcement** | `clsXPrintControlCollection.Criteria.New` sets `ThirtyDaysAgoDate = Today.AddDays(-30)`. `BeforeRetrieve` binds both date parameters to [SQL-014](sql/SQL-014-saif-services-printing-remote.md) (`WHERE PROCESSED_DATE < :ProcessedDate OR CREATE_DATE < :ThirtyDaysAgoDate`). |
| **Outcome** | Both explicitly unprocessed batches (by processed date) and stale batches (by create date, regardless of processed status) are included in the pending collection, enabling cleanup of abandoned batches. |
| **Tables** | [XPRINT_CONTROL](database-tables.md#xprint_control) |
| **SQL** | [SQL-014](sql/SQL-014-saif-services-printing-remote.md) |
| **Source** | `Services\SAIF.Services.Printing.Remote\clsXPrintControlCollection.vb` |

---

## BR-004: Duplex mode controlled vocabulary

| Field | Value |
| --- | --- |
| **Statement** | `clsXPrintControl.DuplexMode` translates between the `DuplexModes` enum (`DEFLT`, `HORIZONTAL`, `VERTICAL`, `SIMPLEX`) and fixed 5-character database codes (`DEFLT`, `HORIZ`, `VERTL`, `SIMPL`). Any stored code not matching these four values has no explicit getter return.** |
| **Trigger** | Reading or writing `clsXPrintControl.DuplexMode` property; inserting or updating `XPRINT_CONTROL.DUPLEX_CODE`. |
| **Enforcement** | The `DuplexMode` property getter maps stored codes to enum values via `Select Case`; an unrecognized code falls through with no `Return`, yielding an implicit VB default.** The setter translates the enum to a fixed code string for `DuplexCode` storage. Controlled vocabulary also appears on `clsXDocument.DuplexCode` and `clsXDeferredPrint.DuplexCode` (stored as the same 5-character codes but without explicit translation logic in those classes).* |
| **Outcome** | Only the four defined duplex modes are reliably persisted and retrieved. An unrecognized stored code may result in an implicit default enum value (`SIMPLEX`, ordinal 0) rather than an explicit error.** |
| **Tables** | [XPRINT_CONTROL](database-tables.md#xprint_control), [XDOCUMENT](database-tables.md#xdocument), [XDEFERRED_PRINT](database-tables.md#xdeferred_print) |
| **SQL** | [SQL-007](sql/SQL-007-saif-services-printing-remote.md), [SQL-011](sql/SQL-011-saif-services-printing-remote.md), [SQL-012](sql/SQL-012-saif-services-printing-remote.md) |
| **Source** | `Services\SAIF.Services.Printing.Remote\clsXPrintControl.vb`, `Services\SAIF.Services.Printing.Remote\Enums.vb` |

---

## BR-005: Default bin type on document creation

| Field | Value |
| --- | --- |
| **Statement** | New `clsXDocument` instances default `XBinTypeCode` to `"AUTO"` and `CopiesCount` to `1`, routing to an auto-selected print bin and printing a single copy unless explicitly overridden. |
| **Trigger** | Invocation of `clsXDocument.Create()` lifecycle method. |
| **Enforcement** | The `Create()` method sets `XBinTypeCode = "AUTO"` and `CopiesCount = 1` before any caller-supplied values are applied. These defaults flow into [SQL-006](sql/SQL-006-saif-services-printing-remote.md) via the `:XBinTypeCode` and `:CopiesCount` parameters in `BeforeInsert`. |
| **Outcome** | Documents that do not explicitly set a bin type or copy count are routed to the auto-selected bin with a single copy, preventing null or zero values from reaching the database. |
| **Tables** | [XDOCUMENT](database-tables.md#xdocument) |
| **SQL** | [SQL-006](sql/SQL-006-saif-services-printing-remote.md) |
| **Source** | `Services\SAIF.Services.Printing.Remote\clsXDocument.vb` |

---

## BR-006: IDM path default

| Field | Value |
| --- | --- |
| **Statement** | `clsXPrintControl.IDMPathName` defaults to `"PROMPT"`, indicating that a document imaging (IDM) destination path is not pre-set and must be resolved or prompted by a downstream consumer.** |
| **Trigger** | Construction or creation of a `clsXPrintControl` instance without an explicit `IDMPathName` value. |
| **Enforcement** | The `IDMPathName` property (or its backing field) is initialized to `"PROMPT"` in the object's create/initialization path.* The `"PROMPT"` value flows into [SQL-007](sql/SQL-007-saif-services-printing-remote.md) via `:IDMPathName` when `BeforeInsert` runs. |
| **Outcome** | Downstream consumers that read `IDMPathName = "PROMPT"` are expected to substitute a real IDM path; an unresolved `"PROMPT"` value in the database indicates an incomplete or pending imaging setup.** |
| **Tables** | [XPRINT_CONTROL](database-tables.md#xprint_control) |
| **SQL** | [SQL-007](sql/SQL-007-saif-services-printing-remote.md) |
| **Source** | `Services\SAIF.Services.Printing.Remote\clsXPrintControl.vb` |

---

> **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.

## Related documentation
- [Index](index.md)
- [Overview](overview.md)
- [Architecture](architecture.md)
- [Dependencies](dependencies.md)
- [Operations and processes](operations-processes.md)
- [Database tables](database-tables.md)
- [SQL catalog](sql/index.md)
- [API reference](api/index.md)

## Sources
- `Services\SAIF.Services.Printing.Remote\clsXDeferredPrint.vb`
- `Services\SAIF.Services.Printing.Remote\clsXDeferredPrintCollection.vb`
- `Services\SAIF.Services.Printing.Remote\clsXDocument.vb`
- `Services\SAIF.Services.Printing.Remote\clsXPrintControl.vb`
- `Services\SAIF.Services.Printing.Remote\clsXPrintControlCollection.vb`
- `Services\SAIF.Services.Printing.Remote\Enums.vb`
