Calculate included VAT extension snippet

I often need to work out how much VAT is included on a price so made a PHP extension for that years ago. I’ve re-written the code in Javascript for this snippet.

The code will strip £ and comma from a price if included before calculating the VAT (20% in my case).

The resulting figure is fixed to 2 decimal places and put into the clipboard.

# popclip
name: VAT
description: Calculate 20% VAT included on an amount
javascript:
    var clip = popclip.input.text.replace(/[£,]/g, '');
    var vatcalc = clip - (clip / 1.2);
    let vat = vatcalc.toFixed(2);
    popclip.copyText(vat);

Feel free to change for your currency/seperator.

2 Likes