Exemple #1
0
 public virtual Amount Subtract(Amount other) =>
 other == null ? throw new ArgumentNullException(nameof(other))
     : other.Currency != this.Currency ? throw new ArgumentException("Mismatched currency.")
     : other.Value > this.Value ? throw new ArgumentException("Insufficient funds.")
     : new Amount(this.Currency, this.Value - other.Value);
Exemple #2
0
 public Money PayableAt(Money money, Amount expense, Timestamp time) =>
 money is GiftCard gift && gift.ValidBefore.CompareTo(time) < 0 ? Amount.Zero(expense.Currency)
Exemple #3
0
 public virtual Amount Add(Amount other) =>
 other == null ? throw new ArgumentNullException(nameof(other))
     : other.Currency != this.Currency ? throw new ArgumentException("Mismatched currency.")
     : new Amount(this.Currency, this.Value + other.Value);