public MonetaryValue dividedBy(decimal dividend) { if (dividend == 0) { return(MonetaryValue.of(this.Code, 0)); } return(MonetaryValue.of(this.Code, this.PreciseValue / dividend)); }
/// <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)); }
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)); }
public MonetaryValue multipliedBy(decimal multiple) { return(MonetaryValue.of(this.Code, this.PreciseValue * multiple)); }