Skip to content
Last update: March 14, 2024

Override Rounding Policy

To customize the rounding behavior in your application:

  1. Implement the interface VirtoCommerce.CoreModule.Core.Currency.IMoneyRoundingPolicy:

    public class CustomMoneyRoundingPolicy : IMoneyRoundingPolicy
        public decimal RoundMoney(decimal amount, Currency currency)
            // Insert your rounding logic here
  2. Register the custom rounding policy with the Dependency Injection (DI) container in the Module.cs file:

    public void Initialize(IServiceCollection serviceCollection)
        // Other initialization code...
        // Money rounding
        serviceCollection.AddTransient<IMoneyRoundingPolicy, CustomMoneyRoundingPolicy>();
  3. Ensure to replace the placeholder with your actual rounding logic in the RoundMoney method.