Skip to content

Commit

Permalink
Merge branch 'new-markets' of https://github.com/fiskaltrust/middleware
Browse files Browse the repository at this point in the history
… into new-markets
  • Loading branch information
StefanKert committed Dec 6, 2024
2 parents d3b29ad + 0d89336 commit 923e330
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,16 @@ namespace fiskaltrust.SAFT.CLI.SAFTSchemaPT10401;

public static class SAFTMapping
{
public static AuditFile CreateAuditFile(AccountMasterData accountMasterData, List<ftQueueItem> queueItems)
public static AuditFile CreateAuditFile(AccountMasterData accountMasterData, List<ftQueueItem> queueItems, int to)
{
var receiptRequests = queueItems.Select(x => (receiptRequest: JsonSerializer.Deserialize<ReceiptRequest>(x.request)!, receiptResponse: JsonSerializer.Deserialize<ReceiptResponse>(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),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public async IAsyncEnumerable<JournalResponse> 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);
Expand Down

0 comments on commit 923e330

Please sign in to comment.