public static Money operator+(Money m1, Money m2) { Money m = new Money(m1.currency, m1.value); if (m1.currency_ == m2.currency_) { m.value_ += m2.value_; } else if (Money.conversionType == Money.ConversionType.BaseCurrencyConversion) { Money.convertToBase(ref m); Money tmp = m2; Money.convertToBase(ref tmp); m += tmp; } else if (Money.conversionType == Money.ConversionType.AutomatedConversion) { Money tmp = m2; Money.convertTo(ref tmp, m.currency_); m += tmp; } else { Utils.QL_FAIL("currency mismatch and no conversion specified"); } return(m); }
public static bool close(Money m1, Money m2, int n) { if (m1.currency == m2.currency) { return(close(m1.value, m2.value, n)); } else if (Money.conversionType == Money.ConversionType.BaseCurrencyConversion) { Money tmp1 = m1; Money.convertToBase(ref tmp1); Money tmp2 = m2; Money.convertToBase(ref tmp2); return(close(tmp1, tmp2, n)); } else if (Money.conversionType == Money.ConversionType.AutomatedConversion) { Money tmp = m2; Money.convertTo(ref tmp, m1.currency); return(close(m1, tmp, n)); } else { throw new Exception("currency mismatch and no conversion specified"); } }