Generate and store a Scorechain screening report PDF#4098
Merged
Conversation
…liance document For every newly-performed Scorechain screening (not cache hits) tied to a customer, render a one-page PDF report (score, severity, address, proof-of-authenticity, counterparty breakdown) and store it as a KycFile (UserNotes / BlockchainAddressAnalysis) on the userData — mirroring the NameCheck document flow. Wired into the buy-crypto/sell-crypto AML gates and the manual re-trigger. Failures to render/store never break the AML flow (logged, swallowed). No DB migration.
The generate() promise only rejected on synchronous throws; an async pdfkit stream 'error' event
would have left it pending forever and stalled the awaiting AML flow. Wire pdf.on('error', reject)
so a render failure always surfaces (and is then swallowed by the document service as intended).
Collaborator
Author
|
Design note for reviewers: a report is emitted per actually performed screening, keyed off the transient |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Every time a Scorechain screening is newly performed (not served from cache) for a transaction tied to a customer, render a one-page PDF report and store it as a compliance document on the user's
userData.Why
The Scorechain scoring response is currently only persisted as raw data on
scorechain_screening. Compliance needs a human-readable, self-contained document per check, filed alongside the customer's other KYC/AML documents — the same way name-check results are stored.How
ScorechainPdfService(integration/scorechain) — renders the stored screening (score, severity, address, blockchain, proof-of-authenticity, per-section counterparty breakdown) into a PDF withpdfkit+ the sharedPdfUtil, mirroringCustodyPdfService.ScorechainDocumentService(kycsubdomain) — generates the PDF and stores it viaKycDocumentService.uploadFileasFileType.UserNotes/FileSubType.BlockchainAddressAnalysis(an existing, previously unused subtype), mirroring the name-check document flow.isNewlyScreenedflag on the entity is set only on the provider path (performScreening), so cache hits never re-emit a document.No DB migration (reuses
kyc_fileand an existing subtype).Verification
format:check,lint,type-check, fulljest(1925 passed),build, and a DI-boot of the compiled app all pass locally — the last confirms the newforwardRefwiring between the KYC and buy/sell-crypto modules resolves cleanly.