This depends where you are doing the VAT calculation and the structure of your site but in theory for global properties...
You could create a property on the very top node of you Umbraco Content tree - usually your homepage document type (perhaps on a Site Settings tab) - if you called the property 'VATRate'; you could then read this value in a template View using:
@Model.Content.GetPropertyValue("VATRate",true)
(where true, means recurse up the content tree until you find a property called 'VATRate')
or
@Umbraco.Field("VATRate", recursive: true)
will do the same.
If your calculations are in a Macro you can create a parameter on the macro called VATRateParam and pass this in from the doc type property when you render your macro like so:
@Umbraco.RenderMacro("AliasOfMacro", new {VATRateParam = "[$VATRate]"})
the $ syntax here means recurse up the tree until you find the VATRate property, you would then access this value in your macro via:
var vatRate = Model.MacroParameters.GetValue("VATRateParam")
if that helps ?
You might want to Cache the retrieved value for a period of time to prevent the work associated in accessing it from happening on each calculation; and also consider storing the rate at which VAT was calculated against each order - ie so historical orders or orders in progress don't have their VAT changed after the purchaser has committed to buy when the rate is changed globally...
To continue on the global theme I'd also go with keeping historical vat rates global.. A global key value pair list of datetime and vat rate (then look up against invoice date for historical).. You might also have different types of products attracting different vat rates just to complicate things ☺
Create a global property that can be updated by the content editor
The product prices on my website are shown excluding VAT.
I want the content editor to be able to set and update the VAT rate across the site.
What is the best way to achieve this?
Your help would be much appreciated.
Thanking you in anticipation.
Roger
Hi Roger
This depends where you are doing the VAT calculation and the structure of your site but in theory for global properties...
You could create a property on the very top node of you Umbraco Content tree - usually your homepage document type (perhaps on a Site Settings tab) - if you called the property 'VATRate'; you could then read this value in a template View using:
(where true, means recurse up the content tree until you find a property called 'VATRate')
or
will do the same.
If your calculations are in a Macro you can create a parameter on the macro called VATRateParam and pass this in from the doc type property when you render your macro like so:
the $ syntax here means recurse up the tree until you find the VATRate property, you would then access this value in your macro via:
if that helps ?
You might want to Cache the retrieved value for a period of time to prevent the work associated in accessing it from happening on each calculation; and also consider storing the rate at which VAT was calculated against each order - ie so historical orders or orders in progress don't have their VAT changed after the purchaser has committed to buy when the rate is changed globally...
To continue on the global theme I'd also go with keeping historical vat rates global.. A global key value pair list of datetime and vat rate (then look up against invoice date for historical).. You might also have different types of products attracting different vat rates just to complicate things ☺
is working on a reply...