Skip to content

PolicyDocumentExtensions

Provides extension methods that convert the internal PolicyDocument data model into the PolicyDocumentModel view/contract shape consumed by PolicyDocumentsApiService, deriving derived flags (invoice/payroll-report detection, packet ID) from the document's description and type fields.

Purpose

  • Converts a single PolicyDocument into a PolicyDocumentModel, including a nested DocumentCategory and derived IsInvoice/IsPayrollReport flags based on the document's description text.
  • Converts a collection of PolicyDocument instances into their PolicyDocumentModel equivalents in bulk.

Context

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

Public members

Member Signature Purpose
ToDocumentModels public static IEnumerable<PolicyDocumentModel> ToDocumentModels(this IEnumerable<PolicyDocument> documents) Maps each document in the sequence to a PolicyDocumentModel via ToDocumentModel and returns the resulting collection.
ToDocumentModel public static PolicyDocumentModel ToDocumentModel(this PolicyDocument document) Builds a PolicyDocumentModel from the document's ID, packet flag, description, document date, policy-period effective date, and a DocumentCategory built from the document type; sets PacketId only for packet documents, and flags IsInvoice/IsPayrollReport by case-insensitive comparison of the description against "INVOICE"/"PAYROLL REPORT".

Behavioral notes

  • ToDocumentModel throws ArgumentNullException if document is null.
  • IsInvoice and IsPayrollReport are determined purely by exact (uppercased) string match on document.Description, not by a document-type code.*

Constraints and usage notes

  • PacketId is populated only when document.IsPacket is true; non-packet documents get an empty string.

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/Policies/PolicyDocumentsApi/PolicyDocumentsApiService.cs