public static Result <WineMsGeneralLedgerJournalTransactionBatch> ProcessTransaction( WineMsGeneralLedgerJournalTransactionBatch wineMsGeneralLedgerJournalTransactionBatch) { wineMsGeneralLedgerJournalTransactionBatch .Transactions .Select(NewGeneralJournalTransactions) .ForEach( journalPair => { Post(journalPair.debit); Post(journalPair.credit); }); return(Result.Ok(wineMsGeneralLedgerJournalTransactionBatch)); void Post(GeneralLedgerTransaction generalLedgerTransaction) { generalLedgerTransaction.Transaction.Post(); wineMsGeneralLedgerJournalTransactionBatch .AddMapping(NewMapping(generalLedgerTransaction)); } GeneralLedgerJournalTransactionMapping NewMapping(GeneralLedgerTransaction generalLedgerTransaction) => new GeneralLedgerJournalTransactionMapping { Guid = generalLedgerTransaction.Guid, AuditNumber = generalLedgerTransaction.Transaction.Audit }; }
public static void CompletePosting( this WineMsGeneralLedgerJournalTransactionBatch generalLedgerJournalTransactionBatch, string integrationDocumentType) { WineMsDbContextFunctions .WrapInDbContext( context => { var transactionLines = generalLedgerJournalTransactionBatch.Transactions.ToWineMsBufferEntryArray(); context.SetAsPosted(transactionLines); context.AddIntegrationMappings( new IntegrationMappingDescriptor { IntegrationDocumentNumber = generalLedgerJournalTransactionBatch.DocumentNumber, IntegrationDocumentType = integrationDocumentType, TransactionLines = transactionLines }); context.SaveChanges(); }); }