Popravek api klica za preverjanje ddv - vracamo ddv - true/false in pri preverjanju pocistimo crke iz davcne stevilke

This commit is contained in:
pero1203 2020-12-02 10:49:04 +01:00
parent 16b6bf280d
commit 285dbe4861
2 changed files with 7 additions and 1 deletions

View File

@ -295,10 +295,12 @@ class ApiNarocilaController{
// Mora placati ddv - cena ostane ista // Mora placati ddv - cena ostane ista
if(UserNarocila::checkPayDDV($podjetje_davcna, $podjetje_drzava)){ if(UserNarocila::checkPayDDV($podjetje_davcna, $podjetje_drzava)){
$this->response['cena'] = $cena; $this->response['cena'] = $cena;
$this->response['ddv'] = true;
} }
// Ne placa ddv - placa samo osnovo // Ne placa ddv - placa samo osnovo
else{ else{
$this->response['cena'] = number_format(floatval($cena) / 1.22, 2, '.', ''); $this->response['cena'] = number_format(floatval($cena) / 1.22, 2, '.', '');
$this->response['ddv'] = false;
} }
$this->response['success'] = true; $this->response['success'] = true;

View File

@ -1267,7 +1267,11 @@ class UserNarocila{
if(!isset($countries_eu[$drzava])) if(!isset($countries_eu[$drzava]))
return false; return false;
// Drugace gre za tujca iz EU - preverimo ce je zavezanec // Drugace gre za tujca iz EU
// Pocistimo davcno stevilko - ohranimo samo stevilke ce je vnesel v obliki "DE12345678" -> "12345678"
$davcna_stevilka = preg_replace('[\D]', '', $davcna_stevilka);
// Preverimo, ce je zavezanec
$client = new SoapClient("http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl"); $client = new SoapClient("http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl");
try{ try{
$response = $client->checkVat( array('countryCode' => $countries_eu[$drzava], 'vatNumber' => $davcna_stevilka) ); $response = $client->checkVat( array('countryCode' => $countries_eu[$drzava], 'vatNumber' => $davcna_stevilka) );