Ejemplo n.º 1
0
 private PurchaseInfo(MoneyAmount grossAmount, MoneyAmount netAmount, MoneyAmount vatAmount, VatRate vatRate)
 {
     GrossAmount = grossAmount;
     NetAmount   = netAmount;
     VatAmount   = vatAmount;
     VatRate     = vatRate;
 }
Ejemplo n.º 2
0
 private static void ThrowIfInputNull(VatRate vatRate, MoneyAmount amount)
 {
     if (vatRate == null)
     {
         throw new ArgumentException(nameof(vatRate));
     }
     if (amount == null)
     {
         throw new ArgumentException(nameof(amount));
     }
 }
Ejemplo n.º 3
0
        public static PurchaseInfo CreateWithVatAmount(VatRate vatRate, MoneyAmount vatAmount)
        {
            ThrowIfInputNull(vatRate, vatAmount);
            decimal netAmount   = vatAmount.Value / vatRate.Value;
            decimal grossAmount = netAmount + vatAmount.Value;

            var netAmountResult   = MoneyAmount.Create(netAmount);
            var grossAmountResult = MoneyAmount.Create(grossAmount);

            if (netAmountResult.IsFailure || grossAmountResult.IsFailure)
            {
                throw new ArgumentException();
            }

            return(new PurchaseInfo(grossAmountResult.Value, netAmountResult.Value, vatAmount, vatRate));
        }