private async Task EnqueueBulkPostingProcessorMessage(IEnumerable <long> docIds, string company, bool postOpClosedPolicy)
        {
            List <ProcessMessage> postingProcessMessage = new List <ProcessMessage>();

            foreach (long docId in docIds)
            {
                var content = new JObject();
                content.Add(new JProperty("docId", docId));
                content.Add(new JProperty("postOpClosedPolicy", postOpClosedPolicy));

                postingProcessMessage.Add(new ProcessMessage
                {
                    ProcessTypeId = (long)ProcessType.AtlasPostingProcessor,
                    CompanyId     = company,
                    Content       = content.ToString()
                });
            }

            await _processMessageService.SendBulkMessage(postingProcessMessage);
        }
        public async Task <MonthEndTAResponse> Handle(MonthEndTemporaryAdjustmentListCommand request, CancellationToken cancellationToken)
        {
            _unitOfWork.BeginTransaction();

            try
            {
                List <MonthEndTemporaryAdjustmentReport> monthEndTemporaryAdjustmentData = new List <MonthEndTemporaryAdjustmentReport>();
                if (request.ReportType == 3)
                {
                    monthEndTemporaryAdjustmentData = await GetFxDealMonthEndTemporaryAdjustment(request.Company, request.DataVersionId);
                }
                else
                {
                    monthEndTemporaryAdjustmentData = await GetMonthEndTemporaryAdjustment(request.Company, (int)MonthEndType.Postings, request.ReportType, request.DataVersionId, request.AccountingPeriod, request.DocumentDate);
                }

                var accountingSetUp = await _accountingSetUpQueries.GetAccountingSetup(request.Company);

                if (accountingSetUp != null)
                {
                    request.AccountingPeriod = CalculateAccountPeriod(accountingSetUp, request.DocumentDate);
                }
                else
                {
                    throw new Exception("Unable to create document header and lines");
                }

                var response = await _monthEndTemporaryAdjustmentRepository.SaveMonthEndReport(monthEndTemporaryAdjustmentData, request.Company, request.DataVersionId, request.ReportType, request.DocumentDate, request.AccountingPeriod);

                List <Atlas.Application.Core.Entities.ProcessMessage> postingProcessMessage = new List <Atlas.Application.Core.Entities.ProcessMessage>();

                var authorizationResult = await _authorizationService.AuthorizeAsync(_identityService.GetUser(), Policies.PostOpClosedPolicy);

                foreach (var documentId in response.TransactionDocumentId)
                {
                    var content = new JObject();
                    content.Add(new JProperty("docId", documentId));
                    content.Add(new JProperty("postOpClosedPolicy", authorizationResult.Succeeded));

                    Atlas.Application.Core.Entities.ProcessMessage message = new Atlas.Application.Core.Entities.ProcessMessage​
                    {
                        ProcessTypeId = (int)Atlas.Application.Core.Entities.ProcessType.AtlasAccountingDocumentProcessor,
                        CompanyId     = request.Company,
                        Content       = content.ToString(),
                    };
                    postingProcessMessage.Add(message);
                }

                await _processMessageService.SendBulkMessage(postingProcessMessage);

                _unitOfWork.Commit();

                _logger.LogInformation("autoreversal have been created:", response);

                return(response);
            }
            catch
            {
                _unitOfWork.Rollback();
                throw;
            }
        }