This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
site-base/spark/resources/assets/js/mixins/vat.js
2017-11-03 16:26:07 +11:00

45 lines
1.2 KiB
JavaScript
Vendored

module.exports = {
methods: {
/**
* Determine if the given country collects European VAT.
*/
collectsVat(country) {
return Spark.collectsEuropeanVat ? _.contains([
'BE', 'BG', 'CZ', 'DK', 'DE',
'EE', 'IE', 'GR', 'ES', 'FR',
'HR', 'IT', 'CY', 'LV', 'LT',
'LU', 'HU', 'MT', 'NL', 'AT',
'PL', 'PT', 'RO', 'SI', 'SK',
'FI', 'SE', 'GB',
], country) : false;
},
/**
* Refresh the tax rate using the given form input.
*/
refreshTaxRate(form) {
axios.post('/tax-rate', JSON.parse(JSON.stringify(form)))
.then(response => {
this.taxRate = response.data.rate;
});
},
/**
* Get the tax amount for the selected plan.
*/
taxAmount(plan) {
return plan.price * (this.taxRate / 100);
},
/**
* Get the total plan price including the applicable tax.
*/
priceWithTax(plan) {
return plan.price + this.taxAmount(plan);
}
}
};