Copied to clipboard

Flag this post as spam?

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


  • Paul Blair 466 posts 731 karma points
    Feb 29, 2012 @ 23:02
    Paul Blair
    1

    Euro VAT checking

    Hi,

    Not a question this time ;) just sharing some code I'm working on today...

    I have been following the excellent article http://rune.gronkjaer.dk/en-US/2011/04/12/tea-commerce-dynamic-vat/

    I have changed the way the ValidateAndSetVat method works slightly so that we eliminate the need for a seperate table of European Countries. Instead I assign the Euro countries to the VAT group for Sweden and do the checking against that group.

    So the code ends up:

    private void ValidateAndSetVat(Order order)
            {
                if (order.Country.CountryCode.ToLower().Equals("se"))
                {
                    //We are in Sweden
                    order.VATGroupId = euroVATGroupId;
                }
                else
                {
                    if (order.Country.VATGroupId == euroVATGroupId)
                    {
                        //The country is a member of the European Union and we need to check the VAT number
                        OrderProperty vatProperty = order.Properties.SingleOrDefault(p => p.Alias.Equals("companyVATNo"));

                        if (vatProperty != null && CheckVatNumber(vatProperty.Value, order.Country.CountryCode))
                            //We are in Europe and the customer has a valid VAT number - 0% VAT is applicable
                            order.VATGroupId = noVATGroupId;
                        else
                            //We are in Europe and the customer does not have a valid VAT number - 6% VAT is applicable
                            order.VATGroupId = euroVATGroupId;
                    }
                    else
                    {
                        //The country is NOT a member of the European Union - 0% VAT is applicable
                        order.VATGroupId = noVATGroupId;
                    }
                }
                order.Save();
            }

    Cheers

    Paul

  • Anders Burla 2560 posts 8256 karma points
    Feb 29, 2012 @ 23:58
    Anders Burla
    0

    Hi Paul

    THANKS for sharing! A great and simple solution - just the way we love to work with Umbraco and Tea Commerce :)

    Kind regards
    Anders

Please Sign in or register to post replies

Write your reply to:

Draft