Exemplo n.º 1
0
        private async Task EnqueueMessageForAccountingDocumentCreation(long transactionDocumentId, string company)
        {
            var authorizationResult = await _authorizationService.AuthorizeAsync(_identityService.GetUser(), Policies.PostOpClosedPolicy);

            var content = new JObject();

            content.Add(new JProperty("docId", transactionDocumentId));
            content.Add(new JProperty("postOpClosedPolicy", authorizationResult.Succeeded));
            ProcessMessage message = new ProcessMessage​
            {
                ProcessTypeId = (int)ProcessType.AtlasAccountingDocumentProcessor,
                CompanyId     = company,
                Content       = content.ToString(),
            };

            await _processMessageService.SendMessage(message);
        }
Exemplo n.º 2
0
        private async Task EnqueueMessage(string contextInfo, string company)
        {
            ProcessMessage message = new ProcessMessage​
            {
                ProcessTypeId = (int)ProcessType.AtlasAccountingDocumentProcessor,
                CompanyId     = company,
                Content       = new JObject(new JProperty("docId", contextInfo)).ToString(),
            };

            await _processMessageService.SendMessage(message);
        }
Exemplo n.º 3
0
        private async Task EnqueuePostingProcessorMessage(long docId, string company, bool postOpClosedPolicy)
        {
            var content = new JObject();

            content.Add(new JProperty("docId", docId));
            content.Add(new JProperty("postOpClosedPolicy", postOpClosedPolicy));

            await _processMessageService.SendMessage(new ProcessMessage
            {
                ProcessTypeId = (long)ProcessType.AtlasPostingProcessor,
                CompanyId     = company,
                Content       = content.ToString()
            });
        }
Exemplo n.º 4
0
        /// <summary>
        /// This method will insert record into Process message to call the recalc
        /// </summary>
        /// <param name="sectionId"> section command object</param>
        /// <param name="dataVersionId">dataversion being edited</param>
        /// <param name="companyId">company on which there is edition</param>
        private async Task InsertFreezeRecalcProcessQueue(long sectionId, long?dataVersionId, string companyId)
        {
            dynamic message = new JObject(
                new JProperty("userId", _identityService.GetUserName()),
                new JProperty("sectionId", sectionId),
                new JProperty("dataVersionId", dataVersionId));

            await _processMessageService.SendMessage(new ProcessMessage
            {
                ProcessTypeId = (int)ProcessType.AtlasRecalculationProcessor,
                CompanyId     = companyId,
                Content       = message.ToString()
            });
        }
Exemplo n.º 5
0
        public async Task EnqueueMessage(string contextInfo, string company)
        {
            var content = new JObject();

            content.Add(new JProperty("docId", contextInfo));
            content.Add(new JProperty("postOpClosedPolicy", true));
            ProcessMessage message = new ProcessMessage​
            {
                ProcessTypeId = (int)ProcessType.AtlasAccountingDocumentProcessor,
                CompanyId     = company,
                Content       = content.ToString(),
            };

            await _processMessageService.SendMessage(message);
        }
Exemplo n.º 6
0
        public async Task <ManualJournalResponse> Handle(CreateManualJournalDocumentCommand request, CancellationToken cancellationToken)
        {
            _unitOfWork.BeginTransaction();
            AccountingSetupDto accountingSetup = null;
            Company            company         = null;

            try
            {
                string documentLabel              = string.Empty;
                string year                       = string.Empty;
                int    documentReferenceYear      = 0;
                string documentReferenceYearValue = string.Empty;

                ManualJournalDocument manualJournalDocument = request.ManualJournal;
                company = await _masterDataService.GetCompanyByIdAsync(request.Company);

                CommonRules commonRules = new CommonRules(_accountingQueries, _authorizationService, _identityService);

                if (manualJournalDocument.AccountingPeriod.Year < manualJournalDocument.DocumentDate.Year ||
                    (manualJournalDocument.AccountingPeriod.Year <= manualJournalDocument.DocumentDate.Year &&
                     manualJournalDocument.AccountingPeriod.Month < manualJournalDocument.DocumentDate.Month))
                {
                    throw new AtlasBusinessException("A/c period should not be before doc. Date");
                }

                accountingSetup = await _accountingQueries.GetAccountingSetup(request.Company);

                if (accountingSetup != null)
                {
                    if (await CheckIfDocumentDateAccountingPeriodValid(manualJournalDocument, accountingSetup))
                    {
                        if (company.IsProvinceEnable)
                        {
                            foreach (var item in manualJournalDocument.ManualJournalLines)
                            {
                                item.ProvinceId = company.DefaultProvinceId;
                                item.BranchId   = company.DefaultBranchId;
                            }
                        }
                        else
                        {
                            foreach (var item in manualJournalDocument.ManualJournalLines)
                            {
                                item.ProvinceId = item.BranchId = null;
                            }
                        }
                        if (manualJournalDocument.TransactionDocumentTypeId == (int)MasterDocumentType.TA ||
                            manualJournalDocument.TransactionDocumentTypeId == (int)MasterDocumentType.JL)
                        {
                            documentLabel         = Enum.GetName(typeof(MasterDocumentType), manualJournalDocument.TransactionDocumentTypeId);
                            year                  = manualJournalDocument.DocumentDate.Year.ToString(CultureInfo.InvariantCulture).Substring(2, 2);
                            documentReferenceYear = await commonRules.GetDocumentReferenceYear(manualJournalDocument.DocumentDate, request.Company);

                            documentReferenceYearValue = documentReferenceYear.ToString(System.Globalization.CultureInfo.InvariantCulture).Substring(2, 2);
                        }

                        if (manualJournalDocument.TransactionDocumentTypeId == (int)MasterDocumentType.JL)
                        {
                            manualJournalDocument.JLTypeId = (int)JLType.ManualRegularJournal;
                        }
                        else if (manualJournalDocument.TransactionDocumentTypeId == (int)MasterDocumentType.TA)
                        {
                            if (manualJournalDocument.TATypeId != null)
                            {
                                manualJournalDocument.TATypeId = (int)TAType.ManualMarkToMarket;
                            }
                            else
                            {
                                manualJournalDocument.TATypeId = (int)TAType.ManualTemporaryAdjustment;
                            }
                        }


                        int referencenumber = await _manualJournalQueries.GetManualDocumentReferenceValues(request.Company, (int)manualJournalDocument.TransactionDocumentTypeId, documentReferenceYear);

                        manualJournalDocument.YearNumber = referencenumber;

                        manualJournalDocument.Year = documentReferenceYear;

                        manualJournalDocument.DocumentReference = string.Concat(documentLabel, documentReferenceYearValue, string.Format(CultureInfo.InvariantCulture, "{0:D5}", referencenumber));

                        var objResponse = await _manualJournalRepository.CreateManualJournal(manualJournalDocument, request.Company);

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

                        var content = new JObject();
                        content.Add(new JProperty("docId", objResponse.TransactionDocumentId));
                        content.Add(new JProperty("postOpClosedPolicy", authorizationResult.Succeeded));

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

                        await _processMessageService.SendMessage(message);

                        _unitOfWork.Commit();

                        return(objResponse);
                    }
                    else
                    {
                        throw new AtlasSecurityException($"Please check the document date and accounting period");
                    }
                }
                else
                {
                    throw new AtlasSecurityException($"No Accounting Setup found");
                }
            }
            catch
            {
                _unitOfWork.Rollback();

                throw;
            }
        }