Ejemplo n.º 1
0
 public MonetaryValue dividedBy(decimal dividend)
 {
     if (dividend == 0)
     {
         return(MonetaryValue.of(this.Code, 0));
     }
     return(MonetaryValue.of(this.Code, this.PreciseValue / dividend));
 }
Ejemplo n.º 2
0
 /// <summary>
 /// multiply monetary value by per_unit.
 /// </summary>
 public static MonetaryValue Convert(MonetaryValue money, decimal per_unit, string code)
 {
     if (money is null)
     {
         return(null);
     }
     return(money.multipliedBy(per_unit));
 }
Ejemplo n.º 3
0
        public MonetaryValue subtractValueOf(MonetaryValue other, IDictionary <string, decimal> table = null)
        {
            if ((this.Code != other.Code))
            {
                if (table is null)
                {
                    throw new Exception("Can't subtract MonetaryValue, convertion table is null");
                }
                var other_converted = other.PreciseValue * table[other.Code];
                return(MonetaryValue.of(this.Code, this.PreciseValue - other_converted));
            }

            return(MonetaryValue.of(this.Code, this.PreciseValue - other.PreciseValue));
        }
Ejemplo n.º 4
0
 public MonetaryValue multipliedBy(decimal multiple)
 {
     return(MonetaryValue.of(this.Code, this.PreciseValue * multiple));
 }