Lieferland UST CH, Reverse Charge

This commit is contained in:
Kevin Adametz 2021-08-03 16:00:01 +02:00
parent 351a8f763c
commit d46824a4ac
19 changed files with 455 additions and 41 deletions

View file

@ -45,6 +45,7 @@ class UserRepository extends BaseRepository {
$data['same_as_billing'] = !isset($data['same_as_billing']) ? 0 : 1;
$account->fill($data)->save();
if(!$this->model->account_id){
@ -78,7 +79,75 @@ class UserRepository extends BaseRepository {
return $this->model;
}
public function reverse_charge_activate($data, $user){
/* 'AT' => 'AT-Oesterreich',
'BE' => 'BE-Belgien',
'BG' => 'BG-Bulgarien',
'CY' => 'CY-Zypern',
'CZ' => 'CZ-Tschechische Republik',
'DE' => 'DE-Deutschland',
'DK' => 'DK-Dänemark',
'EE' => 'EE-Estland',
'EL' => 'EL-Griechenland',
'ES' => 'ES-Spanien',
'FI' => 'FI-Finnland',
'FR' => 'FR-Frankreich ',
'HR' => 'HR-Kroatien ',
'HU' => 'HU-Ungarn',
'IE' => 'IE-Irland',
'IT' => 'IT-Italien',
'LT' => 'LT-Litauen',
'LU' => 'LU-Luxemburg',
'LV' => 'LV-Lettland',
'MT' => 'MT-Malta',
'NL' => 'NL-Niederlande',
'PL' => 'PL-Polen',
'PT' => 'PT-Portugal',
'RO' => 'RO-Rumänien',
'SE' => 'SE-Schweden',
'SI' => 'SI-Slowenien',
'SK' => 'SK-Slowakei',
'XI' => 'XI-Nordirland', */
$countryCode = 'DE';
if($user->account->country_id){
$countryCode = $user->account->country->code;
}
$vatid = str_replace(array(' ', '.', '-', ',', ', '), '', trim($data['tax_identification_number']));
$cc = substr($vatid, 0, 2);
$vatNo = substr($vatid, 2);
$options = [
'cache_wsdl' => WSDL_CACHE_NONE,
'trace' => 1,
'stream_context' => stream_context_create(
[
'ssl' => [
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
]
]
)
];
$client = new \SoapClient("https://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl", $options);
$result = $client->checkVat(['countryCode' => $countryCode, 'vatNumber' => $vatNo]);
if($result->valid == true) {
$user->account->tax_identification_number = $data['tax_identification_number'];
$user->account->reverse_charge = 1;
$user->account->reverse_charge_valid = now();
$user->account->save();
return 'valid';
} else {
return 'error';
}
}
public function deleteUser(User $user)
{
if($user->account){