Beispiel #1
0
        public void Multiply__Produces_Correct_Result(string a, string b, string c)
        {
            var(left, right) = Parse(a, b);

            Money18
            .Multiply(left, right)
            .Should()
            .Be(c);
        }
Beispiel #2
0
        public async Task <AmountConvertBySpendRuleResponse> GetAmountBySpendRuleAsync(Guid spendRuleId, Guid customerId, string from, string to, Money18 amount)
        {
            var conversionRate = await GetCurrencyRateBySpendRuleIdAsync(spendRuleId, customerId, from, to);

            return(new AmountConvertBySpendRuleResponse()
            {
                Amount = Money18.Multiply(amount, conversionRate.UsedRate),
                CurrencyCode = to,
                UsedRate = conversionRate.UsedRate,
                ConversionSource = ConversionSource.BurnRule,
                SpendRuleId = spendRuleId,
                CustomerId = customerId
            });
        }
Beispiel #3
0
        public async Task <OptimalAmountConvertResponse> ConvertOptimalByPartnerAsync(Guid partnerId, Guid customerId, string from, string to, Money18 amount)
        {
            var conversionRate = await GetOptimalCurrencyRateByPartnerAsync(partnerId, customerId, from, to);

            return(new OptimalAmountConvertResponse
            {
                Amount = Money18.Multiply(amount, conversionRate.UsedRate),
                ConversionSource = conversionRate.ConversionSource,
                CurrencyCode = to,
                UsedRate = conversionRate.UsedRate,
                SpendRuleId = conversionRate.SpendRuleId,
                CustomerId = customerId
            });
        }
Beispiel #4
0
        public async Task <AmountByConditionResponse> GetAmountConditionAsync(Guid conditionId, Guid customerId, string fromCurrency, string toCurrency,
                                                                              Money18 amount)
        {
            var conversionRate = await GetCurrencyRateByConditionIdAsync(conditionId, customerId, fromCurrency, toCurrency);

            return(new AmountByConditionResponse()
            {
                Amount = Money18.Multiply(amount, conversionRate.UsedRate),
                CurrencyCode = toCurrency,
                UsedRate = conversionRate.UsedRate,
                ConversionSource = ConversionSource.Condition,
                ConditionId = conditionId,
                CustomerId = customerId
            });
        }