Exemple #1
0
 private PurchaseInfo(MoneyAmount grossAmount, MoneyAmount netAmount, MoneyAmount vatAmount, VatRate vatRate)
 {
     GrossAmount = grossAmount;
     NetAmount   = netAmount;
     VatAmount   = vatAmount;
     VatRate     = vatRate;
 }
Exemple #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));
     }
 }
Exemple #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));
        }