openhab-addons/bundles/org.openhab.transform.vat
openhab-bot 577c73af0e
New Crowdin updates (#16967)
* New translations volumio.properties (French)
* New translations astro.properties (Finnish)
* New translations chromecast.properties (Finnish)
* New translations icloud.properties (Finnish)
* New translations tradfri.properties (Finnish)
* New translations icalendar.properties (Finnish)
* New translations dali.properties (Finnish)
* New translations fmiweather.properties (Finnish)
* New translations modbus.properties (Finnish)
* New translations mybmw.properties (Finnish)
* New translations netatmo.properties (Finnish)
* New translations rollershutter.properties (Finnish)
* New translations vat.properties (Finnish)
* New translations avmfritz.properties (Italian)
* New translations enigma2.properties (Italian)
* New translations astro.properties (Dutch)
* New translations openweathermap.properties (Dutch)
* New translations dsmr.properties (Dutch)
* New translations systeminfo.properties (Dutch)
* New translations unifi.properties (Dutch)
* New translations jsscripting.properties (Dutch)
* New translations inmemory.properties (Dutch)
* New translations mapdb.properties (Dutch)
* New translations rrd4j.properties (Dutch)
* New translations smhi.properties (Swedish)
* New translations plex.properties (Italian)
* New translations openwebnet.properties (Italian)
* New translations solarforecast.properties (Finnish)
* New translations nikohomecontrol.properties (Dutch)
* New translations emotiva.properties (Italian)
* New translations volumio.properties (Italian)
* New translations siemenshvac.properties (Italian)
2024-07-01 17:32:59 +02:00
..
src/main New Crowdin updates (#16967) 2024-07-01 17:32:59 +02:00
NOTICE Initial contribution (#14529) 2023-03-17 22:06:06 +01:00
pom.xml Apply spotless after release (#16097) 2023-12-22 23:30:38 +01:00
README.md Add JRuby examples in READMEs (#16948) 2024-06-28 22:10:03 +02:00

VAT Transformation Service

The VAT Transformation Service adds VAT (Value-Added Tax) to a given input amount. The input string must be either an ISO 3166 alpha-2 country code or a percentage, i.e. numerical format.

Examples

Display

Number CurrentSpotPrice "Current Spot Price incl. VAT [VAT(12.5):%s]" <price>

In a Rule

Add Danish VAT to price:

:::: tabs

::: tab DSL

var Number price = 499
logInfo("Price", "Price incl. VAT: " + transform("VAT", "DK", price.toString))

:::

::: tab JavaScript

var price = 499;
console.log("Price incl. VAT: " + actions.Transformation.transform("VAT", "DK", price.toString()));

:::

::: tab JRuby

price = 499
# The currency name can be either a Symbol or a String
# The input value doesn't need to be converted to string, however, the return value is a String
price_incl_vat = transform(:vat, :DK, price)
logger.info "Price incl. VAT: #{price_incl_vat}"

:::

::::

Usage as a Profile

The functionality of this TransformationService can also be used in a Profile on an ItemChannelLink. This is the most powerful usage since VAT will be added without providing any explicit country code, percentage or configuration. To use this, an .items file can be configured as follows:

Number CurrentSpotPrice "Current Spot Price" <price> { channel="<channelUID>" [profile="transform:VAT"] }

To override VAT percentage for configured system country:

Number CurrentSpotPrice "Current Spot Price" <price> { channel="<channelUID>" [profile="transform:VAT", percentage="12.5"] }

If VAT is not known for the configured country or the provided percentage is invalid, the default is 0%, so the input value will be put into the transformation without any changes.

Please note: This profile is a one-way transformation, i.e. only values from a device towards the item are changed, the other direction is left untouched.