Implement receipt lottery handling on the Custom RT Server#698
Merged
danielscainifiskaltrust merged 1 commit intoJun 30, 2026
Conversation
✅ CLA SignedAll contributors have signed the CLA. Thank you! |
SCU.IT Test Results 8 files 8 suites 2s ⏱️ Results for commit 721bfb2. |
Queue Test Results 43 files 43 suites 3m 34s ⏱️ Results for commit 721bfb2. |
4 tasks
Contributor
Author
|
I have read the CLA Document and I hereby sign the CLA |
accodev
approved these changes
Jun 30, 2026
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.
Context
The
CustomRTServerSCU did not handle the receipt lottery code:RTCodiceLotteriawas hardcoded to an empty string inProcessFiscalDocumentAsync,so the code sent by the POS in
ftReceiptCaseDatawas silently dropped(unlike CustomRTPrinter and Epson, which already handle it).
Changes
scu-it
CustomRTServerMapping: when present, thecodicelotteriais read viaGetLotteryData()and embedded as
lottery_client_codeinsidefiscalData(usingDocumentDataLottery).QR/SHA is still computed over the serialized string → signature stays consistent.
CustomRTServerSCU: reads the code back from the document and populatesRTCodiceLotteria(→
<rt-lottery-id>signature); passes anisLotteryflag to the queue.CustomRTServerClient:InsertFiscalDocumentLotteryAsyncnow sends the sameCommercialDocumentas the normal flow to
/insertFiscalDocumentLottery.php(same payload → same SHA/HMAC).CustomRTServerCommunicationQueue: lottery receipts are routed to the dedicated endpointin both sync and async modes (disk cache uses a dedicated filename suffix);
send loops (background + daily closing) and counters updated accordingly.
SignatureFactory: the<rt-lottery-id>signature was moved to the end of the array,so it is always last even when customer-id/reference signatures are present.
queue
[www.fiskaltrust.it]footer already includedCodice Lotteria: <code>by reading theRTLotteryIDsignature. Now that CustomRTServeremits it, the footer is populated automatically. Added coverage tests only.
Signature output
For a receipt carrying a lottery code, the response contains:
<rt-lottery-id>→ftSignatureType 0x4954200000000015,ftSignatureFormat 0x1,Data = <code>[www.fiskaltrust.it]footer (ftSignatureType 0x4954200000000001) with aCodice Lotteria: <code>lineTesting
lottery_client_codeembedding infiscalData, signature on/off,routing of lottery documents to the dedicated endpoint.
Codice Lotteria.responseCode 0,fiscalDocIdassigned)on both
/insertFiscalDocument2.php(embed) and/insertFiscalDocumentLottery.php,paid by electronic payment (required for the lottery to be valid).
Notes
CustomRTMappingTests.GenerateTaxDataForReceiptRequest_Should_Map_Correctly,which already fails on
mainand is unrelated to this PR.InsertFiscalDocumentArrayLotteryAsyncand theFDocumentLotterymodel are now unused[removed in this PR / to be removed separately — pick one].
Issue
#697