CashReceiptsService¶
Implements ICashReceiptsService, the batch process that applies cash-receipt batches recorded for a run date to their Collections cases. It depends on IUnitOfWork for repository access and transactions, ICollectionsRepository for the ApplyPayments post-processing step, IUserProfileService for update attribution, and IDocumentService to generate and email a PDF payment-posting report split into fraud and third-party sections.
Purpose¶
- Locates unbalanced (
BatchBalancedFlag == "N") cash-receipt batches for a run date and processes each one, posting a transaction per receipt and updating the associated case's balance. - Rejects (rolls back) a batch whose receipt count or total does not match the batch-control record, logging the discrepancy.
- Calls
ICollectionsRepository.ApplyPaymentsfor each affected case after a batch is successfully posted. - Generates and emails a PDF report summarizing fraud-related and third-party cash receipts for the run date.
Context¶
- Namespace:
SAIF.Services.Collections - Assembly/package:
SAIF.Services(packaged inside theSAIF.SAIFCode.CoreNuGet package)
Public members¶
| Member | Signature | Purpose |
|---|---|---|
| UnitOfWork | protected readonly IUnitOfWork UnitOfWork |
Repository/transaction gateway used for all batch, cash-receipt, case, and transaction persistence in this service. |
| CollectionsRepo | protected readonly ICollectionsRepository CollectionsRepo |
Collections-specific repository used to reapply payments to a case after a batch is posted. |
| ProfileService | protected readonly IUserProfileService ProfileService |
Resolves the current user for attributing posted transactions. |
| DocumentService | protected readonly IDocumentService DocumentService |
Generates the PDF payment-posting report and sends it by email. |
| CashReceiptsService(...) | public CashReceiptsService(IUserProfileService profile, IUnitOfWork unitOfWork, ICollectionsRepository collectionsRepo, IDocumentService documentService) |
Wires in the profile, unit-of-work, collections repository, and document-service collaborators, enforcing that the repository and unit of work are non-null. |
| ApplyCashReceipts | public int ApplyCashReceipts(DateTime runDate, ILogWriter controlReport, ILogWriter controlLog, string emailList) |
Processes every unbalanced batch for runDate; returns 6 if no batches are found, 5 if any batch fails to balance (after emailing the report), or 0 after successfully posting all batches and emailing the report. |
Behavioral notes¶
- Each batch is processed inside
UnitOfWork.Begin()/Commit(); if the summed receipt count/amount does not match theBatchControlrecord, the transaction is rolled back and the batch is skipped, andApplyCashReceiptsreturns5without processing further batches. - After a batch balances and is marked
BatchBalancedFlag = "Y",CollectionsRepo.ApplyPaymentsis called for each distinct positive case ID in a secondBegin()/Commit()transaction, reapplying payment allocation logic per case. - Every posted receipt creates a matching
Transactionrow (via the privateAddTransactionhelper) using the receipt's own transaction type/reference/date and decreases the case's current balance by the transaction amount; the transaction'sUpdateUseris hardcoded to"LCB0009"while the case'sUpdateUseruses the current user. - The generated PDF report groups receipts into "fraud" (
WRKR/FPOL/FOTHcollection codes) and "third party" (THRD/CTHRD) sections and is emailed to every address inemailListwith@saif.comappended, from the hardcoded senderHelpdesk@saif.com.
Sources¶
- Services/SAIF.Services/Collections/CashReceiptsService.cs