Closed officialmmt closed 3 years ago
Hi, thanks! :-) Why do you need a fixed tax, what is the case for fixed VAT?
As you know, there are annual sales volume limits for Moss (starting from 10000 €). Those who do not reach this limit must apply the tax amount of their own country without applying Moss tax scheme. In this case, it will be a need for me and such companies.
Can you solve the problem by not setting $businessCountryCode
in VatCalculator
constructor or by passing $company = false
when calling calculate()
? That might help, if I understand the issue correctly.
If I do this 20% tax will be applied to the European Union. 0% to others right?
shouldCollectEuVat
would return false for non-EU countries, so you don't even try to calculate VAT as this package only works with EU VAT (and a few exceptions, if configured manually)
I have previously made the company variable false.
$vatRates = new VatRates();
$vatRate = new VatCalculator($vatRates);
$rates = $vatRate->getTaxRateForLocation($code, null, false);
$oredertaxed = $vatRate->calculate(Cart::subtotal(), $code, null, false);
If I understand it correctly, you want VatRates::getTaxRateForLocation()
to always return 20%, no matter what $countryCode
etc is passed? Probably the easiest way would be to use a custom VatRates
object with a method getTaxRateForLocation
that would always return what you need and then pass the object to new VatCalculator(...)
.
I could add VatRatesInterface
so yo don't need to extend anything. Would that be fine with you?
Thinking about it, it seems the best way is to extend VatRates
and override the method, something like
class FixedVatRate
{
public function getTaxRateForLocation(string $countryCode, ?string $postalCode, ?string $type = self::GENERAL, ?DateTimeInterface $date = null): float
{
return 0.2;
}
}
$vatRates = new FixedVatRate();
$vatRate = new VatCalculator($vatRates);
Does it help?
I did try like this and always return 0.2 vat rate for Eu and non-Eu countries. If non-EU countries can get 0% vat rate we will reach the goal.
use DateTimeInterface;
use Spaze\VatCalculator\VatRates;
class FixedVatRate extends VatRates
{
public function getTaxRateForLocation(string $countryCode, ?string $postalCode, ?string $type = self::GENERAL, ?DateTimeInterface $date = null): float
{
return 0.2;
}
}
Sure, you can return whatever you want, check the VatRates
class, you probably have all you need there :-) shouldCollectEuVat
would help.
shouldCollectEuVat return boolean so I should handle with if.
Indeed. Glad you've found the solution 👍
Hi Michal,
First of all, I would like to thank you. I have been using the package you wrote for two months and I am very satisfied.
I had a need. How can I convert to a fixed 20% tax rate for Europe only in the package?
Thanks in advance for your answer