2015-12-17 13:49:33 -08:00
|
|
|
// #docregion
|
2016-06-08 01:06:25 +02:00
|
|
|
import { Inject, Injectable } from '@angular/core';
|
2016-05-03 14:06:32 +02:00
|
|
|
|
|
|
|
import { TaxRateService } from './tax-rate.service';
|
2015-12-17 13:49:33 -08:00
|
|
|
|
|
|
|
// #docregion class
|
|
|
|
@Injectable()
|
|
|
|
export class SalesTaxService {
|
2016-05-03 14:06:32 +02:00
|
|
|
constructor(private rateService: TaxRateService) { }
|
2016-06-08 01:06:25 +02:00
|
|
|
getVAT(value: string | number) {
|
|
|
|
let amount: number;
|
|
|
|
if (typeof value === 'string') {
|
2015-12-17 13:49:33 -08:00
|
|
|
amount = parseFloat(value);
|
|
|
|
} else {
|
|
|
|
amount = value;
|
|
|
|
}
|
2016-05-03 14:06:32 +02:00
|
|
|
return (amount || 0) * this.rateService.getRate('VAT');
|
2015-12-17 13:49:33 -08:00
|
|
|
}
|
|
|
|
}
|
2016-05-03 14:06:32 +02:00
|
|
|
// #enddocregion class
|