Place an order with VAT excluded

I’ve done some more testing now and from what I can see it works as long as you assume that the discount is on the price including VAT. Then everything adds up.

The code changes I’ve done is to create a IPriceCalculatorDecorator as suggested above:

[ServiceDecorator(typeof(IPriceCalculator))]
public class IPriceCalculatorDecorator : IPriceCalculator
{
    private readonly IPriceCalculator _parent;
    private readonly PersonService _personService;

    public IPriceCalculatorDecorator(
        IPriceCalculator parent,
        PersonService personService)
    {
        _parent = parent;
        _personService = personService;
    }

    public IDictionary<Guid, PriceCalculatorResult> GetListPrices(PriceCalculatorArgs calculatorArgs, params PriceCalculatorItemArgs[] itemArgs)
    {
        var prices = _parent.GetListPrices(calculatorArgs, itemArgs);

        var person = _personService.Get(calculatorArgs.UserSystemId);
        var vatNumber = person?.Fields.GetValue<string>(CustomerFieldNameConstants.VatNumber);
        if (string.IsNullOrWhiteSpace(vatNumber))
        {
            return prices;
        }

        foreach (var price in prices)
        {
            price.Value.VatRate = 0;
            price.Value.PriceIncludingVat = price.Value.PriceExcludingVat;
        }

        return prices;
    }

    public ICollection<ProductPriceList> GetPriceLists(PriceCalculatorArgs calculatorArgs)
    {
        return _parent.GetPriceLists(calculatorArgs);
    }
}

The only thing that is a concern is that on the order rows in the database the VatDetails still says ‘amountIncludingVat’ and an amount like this.
image

@anusha.ganegoda What is the VatDetails used for?

Looking at the order in backoffice everything looks correct.