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;
 }
示例#2
0
 public ManualDocumentMatchingCommandHandler(
     ILogger <ManualDocumentMatchingCommandHandler> logger,
     IIdentityService identityService,
     IMasterDataService masterDataService,
     IUnitOfWork unitOfWork,
     IManualDocumentMatchingRepository manualDocumentMatchingRepository,
     IManualDocumentMatchingQueries manualDocumentMatchingQueries,
     ITransactionDocumentQueries transactionDocumentQueries,
     ITransactionDocumentRepository transactionDocumentRepository,
     ISystemDateTimeService systemDateTimeService,
     IForeignExchangeRateService foreignExchangeRateService,
     IProcessMessageService processMessageService,
     IMapper mapper,
     IAuthorizationService authorizationService)
 {
     _manualDocumentMatchingRepository = manualDocumentMatchingRepository ?? throw new ArgumentNullException(nameof(manualDocumentMatchingRepository));
     _manualDocumentMatchingQueries    = manualDocumentMatchingQueries ?? throw new ArgumentNullException(nameof(manualDocumentMatchingQueries));
     _transactionDocumentQueries       = transactionDocumentQueries ?? throw new ArgumentNullException(nameof(transactionDocumentQueries));
     _transactionDocumentRepository    = transactionDocumentRepository ?? throw new ArgumentNullException(nameof(transactionDocumentRepository));
     _unitOfWork                 = unitOfWork ?? throw new ArgumentNullException(nameof(unitOfWork));
     _logger                     = logger ?? throw new ArgumentNullException(nameof(logger));
     _identityService            = identityService ?? throw new ArgumentNullException(nameof(identityService));
     _mapper                     = mapper ?? throw new ArgumentNullException(nameof(mapper));
     _systemDateTimeService      = systemDateTimeService ?? throw new ArgumentNullException(nameof(systemDateTimeService));
     _masterDataService          = masterDataService;
     _foreignExchangeRateService = foreignExchangeRateService;
     _processMessageService      = processMessageService ?? throw new ArgumentNullException(nameof(processMessageService));
     _authorizationService       = authorizationService ?? throw new ArgumentNullException(nameof(authorizationService));
 }
示例#3
0
 public FxRatesController(IUnitOfWork unitOfWork, IFxRateRepository fxRateRepository, ICurrencyRepository currencyRepository, IForeignExchangeRateService foreignExchangeRateService, ILogger <FxRatesController> logger, IHostingEnvironment hostingEnvironment)
 {
     _unitOfWork                 = unitOfWork;
     _fxRateRepository           = fxRateRepository;
     _currencyRepository         = currencyRepository;
     _foreignExchangeRateService = foreignExchangeRateService;
     _logger             = logger;
     _hostingEnvironment = hostingEnvironment;
 }
示例#4
0
 public GetLatestCryptoCurrencyQuotesHandler(ICryptoRepository cryptoRepository,
                                             ICurrencyRepository currencyRepository, ICoinMarketCapService coinMarketCapService,
                                             IForeignExchangeRateService exchangeRateService)
 {
     _cryptoRepository     = cryptoRepository ?? throw new ArgumentNullException(nameof(cryptoRepository));
     _currencyRepository   = currencyRepository ?? throw new ArgumentNullException(nameof(currencyRepository));
     _coinMarketCapService =
         coinMarketCapService ?? throw new ArgumentNullException(nameof(coinMarketCapService));
     _exchangeRateService = exchangeRateService ?? throw new ArgumentNullException(nameof(exchangeRateService));
 }
示例#5
0
 public UpdateAccountingDocumentCommandHandler(
     ILogger <UpdateAccountingDocumentCommandHandler> logger,
     IUnitOfWork unitOfWork,
     IIdentityService identityService,
     IMapper mapper,
     IAuthorizationService authorizationService,
     IMasterDataService masterDataService,
     IAccountingDocumentRepository accountingDocumentRepository,
     IForeignExchangeRateService foreignExchangeRateService)
 {
     _unitOfWork                   = unitOfWork;
     _logger                       = logger;
     _mapper                       = mapper;
     _identityService              = identityService ?? throw new ArgumentNullException(nameof(identityService));
     _authorizationService         = authorizationService ?? throw new ArgumentNullException(nameof(authorizationService));
     _masterDataService            = masterDataService;
     _accountingDocumentRepository = accountingDocumentRepository;
     _foreignExchangeRateService   = foreignExchangeRateService;
 }
示例#6
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;
 }
示例#7
0
        internal static async Task <AccountingDocumentLine> CalculateFunctionalAndStatutoryCurrency(IForeignExchangeRateService foreignExchangeRateService, AccountingDocumentLine accountingDocumentLine, decimal?amountInUSD, FxRateInformation fxRates, Company company, string baseCurrency, int decimals)
        {
            if (amountInUSD != null)
            {
                amountInUSD = Math.Round((decimal)amountInUSD, decimals);

                accountingDocumentLine.StatutoryCurrency = amountInUSD;
                if (company.StatutoryCurrencyCode != null && amountInUSD != null && company.StatutoryCurrencyCode.ToUpperInvariant() != baseCurrency)
                {
                    accountingDocumentLine.StatutoryCurrency = (await foreignExchangeRateService.Convert(baseCurrency, fxRates.FxRateStatutoryCurrency.FxCurrency, (decimal)amountInUSD, fxRates.FxRateStatutoryCurrency.FxDate)).ConvertedValue;
                }

                accountingDocumentLine.FunctionalCurrency = amountInUSD;
                if (company.FunctionalCurrencyCode != null && amountInUSD != null && company.FunctionalCurrencyCode.ToUpperInvariant() != baseCurrency)
                {
                    accountingDocumentLine.FunctionalCurrency = (await foreignExchangeRateService.Convert(baseCurrency, fxRates.FxRateFunctionalCurrency.FxCurrency, (decimal)amountInUSD, fxRates.FxRateFunctionalCurrency.FxDate)).ConvertedValue;
                }

                if (accountingDocumentLine.StatutoryCurrency != null)
                {
                    accountingDocumentLine.StatutoryCurrency = Math.Round((decimal)accountingDocumentLine.StatutoryCurrency, decimals, MidpointRounding.AwayFromZero); // the default rounding option for .NET is MidPointRounding.ToEven, but that this option does not produce the desired result for some of values: -1119.965 was getting rounded to -1119.96 instead of -1119.97
                }

                if (accountingDocumentLine.FunctionalCurrency != null)
                {
                    accountingDocumentLine.FunctionalCurrency = Math.Round((decimal)accountingDocumentLine.FunctionalCurrency, decimals, MidpointRounding.AwayFromZero); // the default rounding option for .NET is MidPointRounding.ToEven, but that this option does not produce the desired result for some of values: -1119.965 was getting rounded to -1119.96 instead of -1119.97
                }
            }
            else
            {
                accountingDocumentLine.StatutoryCurrency  = null;
                accountingDocumentLine.FunctionalCurrency = null;
            }

            return(accountingDocumentLine);
        }
示例#8
0
        internal static async Task <AccountingDocument> CalculateFunctionalAndStatutoryCurrencyAccountingLine(IForeignExchangeRateService foreignExchangeRateService, AccountingDocument document)
        {
            AccountingDocument accountingDocumentStatus = new AccountingDocument();

            accountingDocumentStatus.AccountingId = document.AccountingId;

            foreach (AccountingDocumentLine documentLine in document.AccountingDocumentLines)
            {
                documentLine.Amount = Math.Round(documentLine.Amount, CommonRules.RoundDecimals);

                decimal?amountInUSD = documentLine.Amount;

                if (document.CurrencyCode != null && document.CurrencyCode.ToUpperInvariant() != CommonRules.BaseCurrency)
                {
                    var result = await foreignExchangeRateService.Convert(document.CurrencyCode, CommonRules.BaseCurrency, documentLine.Amount, (DateTime)document.GLDate);

                    amountInUSD  = result.ConvertedValue;
                    document.Roe = result.Rate;
                }

                if (amountInUSD != null)
                {
                    documentLine.StatutoryCurrency = amountInUSD;

                    if (document.StatutoryCurrencyCode != null && document.StatutoryCurrencyCode.ToUpperInvariant() != CommonRules.BaseCurrency)
                    {
                        var result = await foreignExchangeRateService.Convert(CommonRules.BaseCurrency, document.StatutoryCurrencyCode, (decimal)amountInUSD, (DateTime)document.GLDate);

                        documentLine.StatutoryCurrency = result.ConvertedValue;
                    }

                    documentLine.FunctionalCurrency = amountInUSD;
                    if (document.FunctionalCurrencyCode != null && document.FunctionalCurrencyCode.ToUpperInvariant() != CommonRules.BaseCurrency)
                    {
                        var result = await foreignExchangeRateService.Convert(CommonRules.BaseCurrency, document.FunctionalCurrencyCode, (decimal)amountInUSD, (DateTime)document.GLDate);

                        documentLine.FunctionalCurrency = result.ConvertedValue;
                    }

                    if (documentLine.StatutoryCurrency != null)
                    {
                        documentLine.StatutoryCurrency = Math.Round((decimal)documentLine.StatutoryCurrency, CommonRules.RoundDecimals, MidpointRounding.AwayFromZero); // the default rounding option for .NET is MidPointRounding.ToEven, but that this option does not produce the desired result for some of values: -1119.965 was getting rounded to -1119.96 instead of -1119.97
                    }

                    if (documentLine.FunctionalCurrency != null)
                    {
                        documentLine.FunctionalCurrency = Math.Round((decimal)documentLine.FunctionalCurrency, CommonRules.RoundDecimals, MidpointRounding.AwayFromZero); // the default rounding option for .NET is MidPointRounding.ToEven, but that this option does not produce the desired result for some of values: -1119.965 was getting rounded to -1119.96 instead of -1119.97
                    }
                }
                else
                {
                    documentLine.FunctionalCurrency = null;
                    documentLine.StatutoryCurrency  = null;
                }
            }

            return(document);
        }