Unsupported operand types: array * float
Fossil01 opened this issue · comments
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:
> 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.
vat-calculator/src/VatCalculator.php
Line 756 in 3b31ecd
Fixed in: #156