diff --git a/queue/src/fiskaltrust.Middleware.Localization.QueuePT/Exports/SAFTPT/SAFTSchemaPT10401/SAFTMapping.cs b/queue/src/fiskaltrust.Middleware.Localization.QueuePT/Exports/SAFTPT/SAFTSchemaPT10401/SAFTMapping.cs index f1bfdae59..cad0a2910 100644 --- a/queue/src/fiskaltrust.Middleware.Localization.QueuePT/Exports/SAFTPT/SAFTSchemaPT10401/SAFTMapping.cs +++ b/queue/src/fiskaltrust.Middleware.Localization.QueuePT/Exports/SAFTPT/SAFTSchemaPT10401/SAFTMapping.cs @@ -11,12 +11,16 @@ namespace fiskaltrust.SAFT.CLI.SAFTSchemaPT10401; public static class SAFTMapping { - public static AuditFile CreateAuditFile(AccountMasterData accountMasterData, List queueItems) + public static AuditFile CreateAuditFile(AccountMasterData accountMasterData, List queueItems, int to) { var receiptRequests = queueItems.Select(x => (receiptRequest: JsonSerializer.Deserialize(x.request)!, receiptResponse: JsonSerializer.Deserialize(x.response))).ToList(); var actualReceiptRequests = receiptRequests.Where(x => x.receiptResponse != null && ((long) x.receiptResponse.ftState & 0xFF) == 0x00).Cast<(ReceiptRequest receiptRequest, ReceiptResponse receiptResponse)>().ToList(); var invoices = actualReceiptRequests.Select(x => SAFTMapping.GetInvoiceForReceiptRequest(accountMasterData, x)).Where(x => x != null).ToList(); + if(to > 0) + { + invoices = invoices.Take(to).ToList(); + } return new AuditFile { Header = GetHeader(accountMasterData), diff --git a/queue/src/fiskaltrust.Middleware.Localization.QueuePT/Processors/JournalProcessorPT.cs b/queue/src/fiskaltrust.Middleware.Localization.QueuePT/Processors/JournalProcessorPT.cs index 2725d1392..675ed7ff5 100644 --- a/queue/src/fiskaltrust.Middleware.Localization.QueuePT/Processors/JournalProcessorPT.cs +++ b/queue/src/fiskaltrust.Middleware.Localization.QueuePT/Processors/JournalProcessorPT.cs @@ -40,7 +40,7 @@ public async IAsyncEnumerable ProcessAsync(JournalRequest reque { queueItems = (await _storageProvider.GetMiddlewareQueueItemRepository().GetAsync()).ToList(); } - var data = SAFTMapping.CreateAuditFile(masterData, queueItems); + var data = SAFTMapping.CreateAuditFile(masterData, queueItems, (int) request.To); using var memoryStream = new MemoryStream(); var serializer = new XmlSerializer(typeof(AuditFile)); serializer.Serialize(memoryStream, data);