Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


These support forums are now closed for new topics and comments.
Please head on over to http://eureka.ucommerce.net/ for support.

  • Dan Diplo 1554 posts 6205 karma points MVP 6x c-trib
    Mar 01, 2012 @ 16:28
    Dan Diplo
    0

    Getting Price + VAT for Product using Razor (C#)

    Am I right in assuming if you are using the raw entities you need to calculate the total price + VAT yourself? There isn't any helper I'm missing?

    Currently this seems to work:

        var priceGroup = PriceGroup.Get(7);
        var price = product.GetPrice(priceGroup);
        var total = price.Price.Value + (price.Price.Value * priceGroup.VATRate);
        <h1>@priceGroup.Currency.ISOCode @total.ToCurrencyAmount()</h1>

    Is that right or is there a better way?

  • Søren Spelling Lund 1797 posts 2786 karma points
    Mar 05, 2012 @ 10:24
    Søren Spelling Lund
    0

    Hi Dan,

    You'll want to use IPricingService and ITaxService to get what you want. They encapsulate the logic for calculating price and tax and gives you the opportunity to override them later on if you need it:

    var pricingService = ObjectFactory.Instance.Resolve<IPricingService>();
    var taxService = ObjectFactory.Instance.Resolve<ITaxService>();
    var product = Product.All().First();
    PriceGroupPrice unitPriceExTax = pricingService.GetProductPrice(product, myCatalog);
    Money unitTax = taxService.CalculateTax(product, unitPriceExTax.PriceGroup, unitPriceExTax);
  • Dan Diplo 1554 posts 6205 karma points MVP 6x c-trib
    Mar 05, 2012 @ 20:11
    Dan Diplo
    0

    Ahh, OK, that seems a lot more encapsualted. I thought there must be a way! Thanks again.

Please Sign in or register to post replies

Write your reply to:

Draft