Skip to content

OpposingCounselService

Generates the batch print package of opposing-counsel notice copies for provider-type subpoenas that have reached ready-to-pay status, and advances those subpoenas to paid status once the batch is committed. It collaborates with ISubpoenaDocumentService to assemble the per-subpoena document XML, ISubpoenaLabelService to produce the certified mailing label and determine the required envelope size, IEnvironmentService to resolve Xpressions file-path configuration, and IUnitOfWork to persist the generated XPrintControl/XDocument print-batch records and the subpoena status change as a single transaction.

Purpose

  • Builds the XPressions print-batch XML for opposing-counsel copies of approved, provider-type subpoenas, excluding "ZeroPay - Claim" subpoenas flagged do-not-mail.
  • Selects the correct certified-envelope size/description for each subpoena copy via the label service, escalating to a "Deliver to Legal" instruction when the label is too large for simple certified mail.
  • Advances all ready-to-pay subpoenas to paid status and commits the print batch only when every ready-to-pay subpoena was successfully updated; otherwise rolls back and reports zero processed.

Context

  • Namespace: SAIF.Services.Legal.Subpoenas
  • Assembly/package: SAIF.Services (packaged inside the SAIF.SAIFCode.Core NuGet package).

Public members

Member Signature Purpose
OpposingCounselService (constructor) public OpposingCounselService(IUnitOfWork unitOfWork, ISubpoenaDocumentService subpoenaDocumentService, ISubpoenaLabelService subpoenaLabelService, IEnvironmentService environmentService) Wires the unit of work, subpoena document service, subpoena label service, and environment configuration accessor, null-checking all four collaborators.
GenerateOpposingCounselDocuments public long GenerateOpposingCounselDocuments(XPrintBatchArguments batchArguments) Resolves the check/XML output paths from configuration, builds the opposing-counsel document XML for approved provider-type subpoenas (skipping do-not-mail ZeroPay-Claim subpoenas), writes the XPressions XML file and print-control record, advances subpoena statuses to paid, and returns the count of provider-type subpoenas processed only if every ready-to-pay subpoena was updated (otherwise rolls back and returns 0).

Behavioral notes

  • Wraps the print-batch record creation and the subpoena status update in a single IUnitOfWork.Begin()/Commit()/Rollback() transaction; the transaction only commits when the count of subpoenas moved to paid equals the count originally read as ready-to-pay.*
  • When no provider-type subpoenas are present, the method still begins the transaction (to allow the status update) but skips document/XML generation entirely.
  • Sanitizes generated XML by renaming internal DTO element names (SubpoenaDocumentsConfiguration, SubpoenaDocument, ArrayOfclsPaymentTransaction) to the external XPressions schema names and un-escaping doubly-encoded <br> tags before writing the file.
  • Chooses envelope size/description per subpoena from ISubpoenaLabelService.GenerateOpposingCounselLabel's returned LabelSizeOptions, mapping EnvelopeSize10, Large, and Small to distinct window-envelope flags and document descriptions, with an "Too large for simple certified! Deliver to Legal" fallback for unknown sizes.
  • Uses a different mail-room instruction string ("Deliver to Transformers Team") when IEnvironmentService.IsProduction is false, to redirect non-production batches away from the live mail room.*

Constraints and usage notes

  • GenerateOpposingCounselDocuments throws via Enforce.ArgumentNotNull if batchArguments is null.
  • Only provider-type subpoenas (per Subpoena.IsProviderType()) contribute to the returned processed count and the generated document package; witness-type subpoenas in the same ready-to-pay batch are still advanced to paid status but produce no opposing-counsel documents.*

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/Legal/Subpoenas/OpposingCounselService.cs