Sklep B2B naliczał VAT 23% klientom z Niemiec i Francji którzy podawali numer VAT UE. Zgodnie z zasadą reverse charge VAT powinien być 0% dla firm z UE posiadających numer VAT. Problem generował skargi klientów i ryzyko podatkowe. Czas naprawy: 8 godzin.
Objawy
- Klienci z UE z numerem VAT płacą pełny VAT 23%
- Faktury wystawiane z nieprawidłową stawką VAT
- Pole „VAT number” w checkout widoczne, ale nie wpływa na cenę
Konfiguracja
# Stores > Configuration > Customers > Customer Configuration # Create Account > Show VAT Number on Storefront: Required # Stores > Configuration > Sales > Tax # Tax Classes > Tax Class for Shipping: Taxable Goods # Calculation Settings: # Tax Calculation Based On: Shipping Address # Tax Calculation Method Based On: Total # Dla B2B reverse charge potrzebujesz Customer Tax Class # Stores > Tax > Customer Tax Classes: dodaj "EU B2B Customer" # Stores > Tax > Tax Rules: # - Customer Tax Class: EU B2B Customer # - Product Tax Class: Taxable Goods # - Tax Rate: 0% EU # - Priority: 0 (wyższy niż standardowy VAT)
<?php
// Observer który zmienia klasę podatkową przy weryfikacji NIP UE
class VatValidationObserver implements \Magento\Framework\Event\ObserverInterface
{
public function execute(\Magento\Framework\Event\Observer $observer): void
{
$customer = $observer->getCustomer();
$vatNumber = $customer->getTaxvat();
if ($this->isValidEuVat($vatNumber)) {
// Przypisz klasę podatkową B2B
$customer->setGroupId($this->getB2bGroupId());
$customer->setTaxClassId($this->getEuB2bTaxClassId());
}
}
private function isValidEuVat(string $vatNumber): bool
{
// Wywołaj VIES API do weryfikacji
$client = new \SoapClient('https://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl');
$countryCode = substr($vatNumber, 0, 2);
$number = substr($vatNumber, 2);
try {
$result = $client->checkVat(['countryCode' => $countryCode, 'vatNumber' => $number]);
return $result->valid;
} catch (\Exception $e) {
return false;
}
}
}
Wnioski
Reverse charge dla UE B2B wymaga walidacji numeru VAT przez VIES API, osobnej klasy podatkowej dla klientów B2B i odpowiedniej reguły podatkowej z 0% VAT. Zawsze konsultuj konfigurację podatkową z księgowym.
