Closed ghost closed 1 year ago
When using custom tax rules I get this error on the calculate method: Unsupported operand types: array * float
Unsupported operand types: array * float
When using 'TR' or 'NO' for example it does not work, but 'DE' works fine (built-in rate).
Seems to error out at: $this->taxValue = round($this->taxRate * $this->netPrice, 2);
$this->taxValue = round($this->taxRate * $this->netPrice, 2);
It does indeed return an array instead of the direct value:
> VatCalculator::getTaxRateForLocation('DE'); = 0.21 > VatCalculator::getTaxRateForLocation('TR'); = [ "rate" => 0.18, ]
Custom rules are identical in array format as the builtin ones:
return 'rules' => [ 'GB' => [ // United Kingdom 'rate' => 0.20, 'exceptions' => [ // UK RAF Bases in Cyprus are taxed at Cyprus rate 'Akrotiri' => 0.19, 'Dhekelia' => 0.19, ], ], 'TR' => [ // Turkey 'rate' => 0.18, ], 'NO' => [ // Norway 'rate' => 0.25 ] ],
Looks like it gets the whole array key instead of just the rate value if requesting a country that only exists in the external config file.
rate
https://github.com/driesvints/vat-calculator/blob/3b31ecd22b0685321909f32287889bc747a25930/src/VatCalculator.php#L756
Fixed in: https://github.com/driesvints/vat-calculator/pull/156
When using custom tax rules I get this error on the calculate method:
Unsupported operand types: array * float
When using 'TR' or 'NO' for example it does not work, but 'DE' works fine (built-in rate).
Seems to error out at:
$this->taxValue = round($this->taxRate * $this->netPrice, 2);
It does indeed return an array instead of the direct value:
Custom rules are identical in array format as the builtin ones: