Skip to content

Commit

Permalink
Merge pull request #333 from fiskaltrust/#497-Add-migration-receipt-t…
Browse files Browse the repository at this point in the history
…o-German-Middleware

#497 Fix Migration-Receipt on mw with no migration impl
  • Loading branch information
forsthug authored Aug 26, 2024
2 parents 3c8d7cb + d857d32 commit 5e3686a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using fiskaltrust.ifPOS.v1;
using fiskaltrust.Middleware.Contracts.Repositories;
Expand Down Expand Up @@ -44,7 +45,7 @@ public static async Task FinishMigrationAync(ftQueue queue, ftQueueItem queueIte
await actionJournalRepository.InsertAsync(actionJournal).ConfigureAwait(false);
}

public static bool IsMigrationInProgress(IMiddlewareQueueItemRepository queueItemRepository)
public static bool IsMigrationInProgress(IMiddlewareQueueItemRepository queueItemRepository, IMiddlewareActionJournalRepository actionJournalRepository)
{
var queueItem = queueItemRepository.GetLastQueueItemAsync().Result;
if(queueItem == null)
Expand All @@ -54,6 +55,12 @@ public static bool IsMigrationInProgress(IMiddlewareQueueItemRepository queueIte
var request = JsonConvert.DeserializeObject<ReceiptRequest>(queueItem.request);
if ((request.ftReceiptCase & 0xFFFF) == 0x0019)
{
var actionJournal = actionJournalRepository.GetByQueueItemId(queueItem.ftQueueItemId).FirstOrDefaultAsync().Result;

if(actionJournal == null)
{
return false;
}
return true;
}
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public SignProcessorDE(
IConfigurationRepository configurationRepository,
IMiddlewareJournalDERepository journalDERepository,
IMiddlewareQueueItemRepository queueItemRepository,
IMiddlewareActionJournalRepository actionJournalRepository,
ITransactionPayloadFactory transactionPayloadFactory,
IRequestCommandFactory requestCommandFactory,
ILogger<SignProcessorDE> logger)
Expand All @@ -37,7 +38,7 @@ public SignProcessorDE(
_transactionPayloadFactory = transactionPayloadFactory;
_requestCommandFactory = requestCommandFactory;
_logger = logger;
_migrationDone = MigrationHelper.IsMigrationInProgress(queueItemRepository);
_migrationDone = MigrationHelper.IsMigrationInProgress(queueItemRepository, actionJournalRepository);
}

public async Task<(ReceiptResponse receiptResponse, List<ftActionJournal> actionJournals)> ProcessAsync(ReceiptRequest request, ftQueue queue, ftQueueItem queueItem)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public static SignProcessorDE ConstructSignProcessor(
configurationRepository,
journalDERepository,
queueItemRepository,
actionJournalRepository,
transactionPayloadFactory,
new RequestCommandFactory(services.BuildServiceProvider()),
logger
Expand Down

0 comments on commit 5e3686a

Please sign in to comment.