Exemplo n.º 1
0
 public Money RoundToPayableAmount()
 {
     if (_currencySymbol.Equals(Organisation.EnterpriseCurrency))
     {
         return(new Money(MoneyRounder.RoundToPayableAmount(_amount, 0.05m), _currencySymbol,
                          _currencySymbolDisplay, _currencyDecimalDigits));
     }
     else
     {
         return(this);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Rule implementation.
        /// </summary>
        /// <param name="context">Rule context.</param>
        protected override void Execute(RuleContext context)
        {
            object value = context.InputPropertyValues[PrimaryProperty];

            if (value != null)
            {
                Money valueAsMoney = Money.TryConvert(value);
                if (valueAsMoney != null && valueAsMoney.Amount >= 0m &&
                    valueAsMoney.CurrencySymbol.Equals(Organisation.EnterpriseCurrency))
                {
                    if (MoneyRounder.RoundToPayableAmount(valueAsMoney.Amount, 0.05m) != valueAsMoney.Amount)
                    {
                        string message = string.Format(Localization.MoneyRules.MoneyNotPayable,
                                                       PrimaryProperty.FriendlyName);
                        context.Results.Add(new RuleResult(RuleName, PrimaryProperty, message)
                        {
                            Severity = Severity
                        });
                    }
                }
            }
        }