MTva : Petit ajout

This commit is contained in:
Michael RICOIS 2017-01-19 12:39:10 +01:00
parent e9a011cecf
commit fbf5602231

View File

@ -85,10 +85,10 @@ class Metier_Partenaires_MTva
$dateRef->sub(new DateInterval('P6M')); $dateRef->sub(new DateInterval('P6M'));
$dateMaj = DateTime::createFromFormat('Ymd', $tab['DateMAJ']); $dateMaj = DateTime::createFromFormat('Ymd', $tab['DateMAJ']);
$this->vatNumber = "FR".$this->cle.$this->siren; $this->vatNumber = "FR".$this->cle.$this->siren;
if ($cle !== null) { if ($cle !== null | $cle != 0) {
$this->vatDefined = true; $this->vatDefined = true;
return true; return true;
} elseif ($cle === null && $dateMaj >= $dateRef) { } elseif (($cle === null || $cle == 0) && $dateMaj >= $dateRef) {
$this->vatDefined = false; $this->vatDefined = false;
return true; return true;
} }
@ -146,8 +146,8 @@ class Metier_Partenaires_MTva
'traderStreet' => "", 'traderStreet' => "",
'traderPostalCode' => "", 'traderPostalCode' => "",
'traderCity' => "", 'traderCity' => "",
'requesterMemberStateCode' => "", 'requesterMemberStateCode' => "FR",
'requesterNumber' => "", 'requesterNumber' => $this->cle.$this->siren,
'action' => "check", 'action' => "check",
'check' => "Vérifier", 'check' => "Vérifier",
], ],
@ -160,11 +160,11 @@ class Metier_Partenaires_MTva
if (preg_match('/Yes, valid VAT number/i', $body) if (preg_match('/Yes, valid VAT number/i', $body)
|| preg_match('/Oui, numéro de TVA valide/i', $body)) { || preg_match('/Oui, numéro de TVA valide/i', $body)) {
if ($exist) { if ($exist) {
$this->conn->update('sdv1.siren_tva', array('cle' => $this->cle, $this->conn->update('sdv1.siren_tva', array('cle' => intval($this->cle),
'duree' => $time), array('siren' => $this->siren)); 'duree' => $time), array('siren' => $this->siren));
} else { } else {
$this->conn->insert('sdv1.siren_tva', array('siren' => $this->siren, $this->conn->insert('sdv1.siren_tva', array('siren' => $this->siren,
'cle' => $this->cle, 'duree' => $time)); 'cle' => intval($this->cle), 'duree' => $time));
} }
$this->vatNumber = "FR".$this->cle.$this->siren; $this->vatNumber = "FR".$this->cle.$this->siren;
$this->vatDefined = true; $this->vatDefined = true;