Esempio n. 1
0
        public void MoneyToDecimal()
        {
            var m = new Money()
            {
                CurrencyCode = "EUR", CentAmount = 123456
            };
            decimal expect = 1234.56M;

            Assert.Equal(expect, m.AmountToDecimal());
        }
        public static TaxedPrice GetTaxedPrice(Money totalNet, decimal rate)
        {
            var currencyCode = totalNet.CurrencyCode;
            var totalGross   = Money.FromDecimal(currencyCode, totalNet.AmountToDecimal() * rate);
            var total        = totalNet.AmountToDecimal() + totalGross.AmountToDecimal();
            var totalAmount  = Money.FromDecimal(currencyCode, total);
            var taxedPrice   = new TaxedPrice
            {
                TotalNet    = totalNet,
                TotalGross  = totalGross,
                TaxPortions = new List <TaxPortion>
                {
                    new TaxPortion
                    {
                        Name   = RandomString(),
                        Amount = totalAmount,
                        Rate   = rate
                    }
                }
            };

            return(taxedPrice);
        }