public CreateAccountingDocumentCommandHandler(
     ILogger <CreateAccountingDocumentCommandHandler> logger,
     IUnitOfWork unitOfWork,
     IIdentityService identityService,
     IMapper mapper,
     IAuthorizationService authorizationService,
     IAccountingDocumentQueries accountingQueries,
     IMasterDataService masterDataService,
     ISystemDateTimeService systemDateTimeService,
     IProcessMessageService processMessageService,
     IAccountingDocumentRepository accountingDocumentRepository,
     IInvoicingRepository documentMatchingRepository,
     IForeignExchangeRateService foreignExchangeRateService)
 {
     _unitOfWork                   = unitOfWork;
     _logger                       = logger;
     _mapper                       = mapper;
     _identityService              = identityService ?? throw new ArgumentNullException(nameof(identityService));
     _authorizationService         = authorizationService ?? throw new ArgumentNullException(nameof(authorizationService));
     _systemDateTimeService        = systemDateTimeService ?? throw new ArgumentNullException(nameof(systemDateTimeService));
     _processMessageService        = processMessageService ?? throw new ArgumentNullException(nameof(processMessageService));
     _accountingQueries            = accountingQueries;
     _masterDataService            = masterDataService;
     _accountingDocumentRepository = accountingDocumentRepository;
     _invoicingRepository          = documentMatchingRepository;
     _foreignExchangeRateService   = foreignExchangeRateService;
 }
Exemplo n.º 2
0
 public AccountingCsvImporter(IMasterDataService masterDataService, IAccountingDocumentQueries accountingDocumentQueries, string company, IMapper mapper)
 {
     _masterDataService         = masterDataService;
     _accountingDocumentQueries = accountingDocumentQueries;
     _mapper      = mapper;
     this.company = company;
 }
Exemplo n.º 3
0
 public AccountingDocumentsController(IMediator mediator, IIdentityService identityService, IGridService gridQueries, IAccountingDocumentQueries accountingDocumentQueries, IMasterDataService masterDataService, IMapper mapper)
 {
     _mediator                  = mediator;
     _identityService           = identityService;
     _accountingDocumentQueries = accountingDocumentQueries;
     _mapper            = mapper;
     _masterDataService = masterDataService ?? throw new ArgumentNullException(nameof(masterDataService));
 }
Exemplo n.º 4
0
 public AuthorizeForPostingCommandHandler(
     ILogger <AuthorizeForPostingCommandHandler> logger,
     IUnitOfWork unitOfWork,
     IIdentityService identityService,
     IAuthorizationService authorizationService,
     IAccountingDocumentQueries accountingQueries,
     ISystemDateTimeService systemDateTimeService,
     IProcessMessageService processMessageService,
     IAccountingDocumentRepository accountingDocumentRepository,
     IForeignExchangeRateService foreignExchangeRateService)
 {
     _unitOfWork                   = unitOfWork;
     _logger                       = logger;
     _identityService              = identityService ?? throw new ArgumentNullException(nameof(identityService));
     _authorizationService         = authorizationService ?? throw new ArgumentNullException(nameof(authorizationService));
     _systemDateTimeService        = systemDateTimeService ?? throw new ArgumentNullException(nameof(systemDateTimeService));
     _processMessageService        = processMessageService ?? throw new ArgumentNullException(nameof(processMessageService));
     _accountingQueries            = accountingQueries;
     _accountingDocumentRepository = accountingDocumentRepository;
     _foreignExchangeRateService   = foreignExchangeRateService;
 }
Exemplo n.º 5
0
 // This is to be develop in coming sprint. Created Block with default return false
 internal static async Task <bool> CheckIfInterface(IAccountingDocumentQueries accountingQueries, long docId, string company)
 {
     return((await accountingQueries.GetTransactionDocumentTypeByDocId(docId, company)).ToInterface);
 }
Exemplo n.º 6
0
 // This is to be develop in coming sprint. Created Block with default return false
 internal static async Task <MappingErrorMessages> CheckMappingError(IAccountingDocumentQueries accountingQueries, IEnumerable <AccountingDocumentLine> accountingDocumentLine, string company, long transactionDocumentTypeId)
 {
     return(await accountingQueries.GetMapppingErrorAsync(accountingDocumentLine, company, transactionDocumentTypeId));
 }
Exemplo n.º 7
0
        internal static async Task <PostingStatus> GetAccountingDocumentStatus(AccountingSetupDto accountingSetup, IAccountingDocumentQueries accountingQuerie, AccountingDocument accountingDocument, string company, DateTime companyDate, InvoiceInformationDto invoiceInformation = null, CashInformationDto cashInformation = null, RevaluationInformationDto revalInformation = null, CounterpartyInformationDto counterpartyInformation = null)
        {
            accountingDocument.ErrorMessage = string.Empty;

            if (invoiceInformation != null)
            {
                if (!CheckPostingForAuthorized(invoiceInformation))
                {
                    return(PostingStatus.Incomplete);
                }
            }
            else if (cashInformation != null)
            {
                if (!CheckPostingForAuthorized(null, cashInformation))
                {
                    return(PostingStatus.Incomplete);
                }
            }
            else if (revalInformation != null)
            {
                if (!CheckPostingForAuthorized(null, null, revalInformation))
                {
                    return(PostingStatus.Incomplete);
                }
            }
            else if (counterpartyInformation != null)
            {
                if (!CheckPostingForAuthorized(null, null, null, counterpartyInformation))
                {
                    return(PostingStatus.Incomplete);
                }
            }

            if (CheckSanityCheck(accountingDocument))
            {
                if (CheckFxRateConverted(accountingDocument))
                {
                    bool ifInterface = await CheckIfInterface(accountingQuerie, accountingDocument.TransactionDocumentId, company);

                    MappingErrorMessages messages = await CheckMappingError(accountingQuerie, accountingDocument.AccountingDocumentLines, company, accountingDocument.TransactionDocumentTypeId);

                    if (ifInterface)
                    {
                        if (!messages.C2CCode)
                        {
                            accountingDocument.ErrorMessage = "C2C Code Is NULL ;";
                        }

                        if (!messages.CostAlternativeCode)
                        {
                            accountingDocument.ErrorMessage += "Cost Alternative Code Is NULL ;";
                        }

                        if (!messages.TaxInterfaceCode)
                        {
                            accountingDocument.ErrorMessage += "Tax Interface Code Is NULL ;";
                        }

                        if (!messages.NominalAlternativeAccount)
                        {
                            accountingDocument.ErrorMessage += "Nominal Alternative Code Is NULL ;";
                        }

                        if (!messages.DepartmentAlternativeCode)
                        {
                            accountingDocument.ErrorMessage += "Department Alternative Code Is NULL ;";
                        }

                        if (!string.IsNullOrEmpty(accountingDocument.ErrorMessage))
                        {
                            return(PostingStatus.MappingError);
                        }
                    }

                    if (MandatoryFieldValidation(accountingDocument))
                    {
                        accountingDocument.ErrorMessage = "Mandatory Field Missing";

                        return(PostingStatus.Held);
                    }

                    if (CheckFutureDate(accountingDocument, companyDate))
                    {
                        accountingDocument.ErrorMessage = "Future document date";
                        return(PostingStatus.Held);
                    }
                    if (!IsMonthOpenForAccounting(accountingSetup.LastMonthClosed, accountingDocument.AccountingDate, accountingSetup.NumberOfOpenPeriod))
                    {
                        accountingDocument.ErrorMessage = "Period is not open for accounting";
                        return(PostingStatus.Held);
                    }

                    return(PostingStatus.Authorised);
                }
                else
                {
                    accountingDocument.ErrorMessage = "No Fxrate found";
                    return(PostingStatus.Held);
                }
            }
            else
            {
                accountingDocument.ErrorMessage = "Unbalanced document";
                return(PostingStatus.Held);
            }
        }
Exemplo n.º 8
0
        internal static async Task <PostingStatus> ReturnAccountingDocumentStatus(IAccountingDocumentQueries accountingQueries, AccountingDocument accountingDocument, DateTime companyDate, string company, AccountingSetupDto accountingSetup)
        {
            accountingDocument.ErrorMessage = string.Empty;

            // Sanity Check
            bool isLegSumValid = CommonRules.CheckSanityCheck(accountingDocument);
            MappingErrorMessages messages;

            if (isLegSumValid)
            {
                if (CommonRules.CheckFxRateConverted(accountingDocument))
                {
                    bool ifInterface = await CommonRules.CheckIfInterface(accountingQueries, accountingDocument.TransactionDocumentId, company);

                    messages = await CommonRules.CheckMappingError(accountingQueries, accountingDocument.AccountingDocumentLines, company, accountingDocument.TransactionDocumentTypeId);

                    if (ifInterface)
                    {
                        if (!messages.C2CCode)
                        {
                            accountingDocument.ErrorMessage = "C2C Code Is NULL ;";
                        }

                        if (!messages.CostAlternativeCode)
                        {
                            accountingDocument.ErrorMessage += "Cost Alternative Code  Is NULL ;";
                        }

                        if (!messages.TaxInterfaceCode)
                        {
                            accountingDocument.ErrorMessage += "Tax Interface Code Is NULL ;";
                        }

                        if (!messages.DepartmentAlternativeCode)
                        {
                            accountingDocument.ErrorMessage += "Department Alternative Code Is NULL ;";
                        }

                        if (!messages.NominalAlternativeAccount)
                        {
                            accountingDocument.ErrorMessage += "Nominal Alternative Code Is NULL ;";
                        }

                        if (!string.IsNullOrEmpty(accountingDocument.ErrorMessage))
                        {
                            return(PostingStatus.MappingError);
                        }
                    }

                    if (CommonRules.MandatoryFieldValidation(accountingDocument))
                    {
                        accountingDocument.ErrorMessage = "Mandatory Field Missing";

                        return(PostingStatus.Held);
                    }

                    if (accountingDocument.DocumentDate.Date > companyDate.Date)
                    {
                        accountingDocument.ErrorMessage = "Future document date";
                        return(PostingStatus.Held);
                    }

                    if (!IsMonthOpenForAccounting(accountingSetup.LastMonthClosed, accountingDocument.AccountingDate, accountingSetup.NumberOfOpenPeriod))
                    {
                        accountingDocument.ErrorMessage = "Period is not open for accounting";
                        return(PostingStatus.Held);
                    }

                    return(PostingStatus.Authorised);
                }
                else
                {
                    accountingDocument.ErrorMessage = "No Fxrates Found";
                    return(PostingStatus.Held);
                }
            }
            else
            {
                accountingDocument.ErrorMessage = "Unbalanced document";
                return(PostingStatus.Held);
            }
        }