|
|
@@ -70,6 +70,20 @@ Class VAT {
|
|
|
private $cookies = "php://memory";
|
|
|
private $message = [];
|
|
|
private $initialized = false;
|
|
|
+ private $messages = [
|
|
|
+ "Podmiot o podanym identyfikatorze podatkowym NIP jest zarejestrowany jako podatnik VAT czynny" => [
|
|
|
+ "active" => true,
|
|
|
+ "shortMessage" => "Czynny",
|
|
|
+ ],
|
|
|
+ "Podmiot o podanym identyfikatorze podatkowym NIP nie jest zarejestrowany jako podatnik VAT" => [
|
|
|
+ "active" => false,
|
|
|
+ "shortMessage" => "Niezarejestrowany",
|
|
|
+ ],
|
|
|
+ "Podmiot o podanym identyfikatorze podatkowym NIP jest zarejestrowany jako podatnik VAT zwolniony" => [
|
|
|
+ "active" => true,
|
|
|
+ "shortMessage" => "Zwolniony"
|
|
|
+ ],
|
|
|
+ ];
|
|
|
|
|
|
private function getHeaders($ch, $header) {
|
|
|
$len = strlen($header);
|
|
|
@@ -152,11 +166,8 @@ Class VAT {
|
|
|
$this->dom->loadHTML(mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8'));
|
|
|
$this->message = array_map("trim", array_values(array_diff(explode("|", $this->dom->getElementById("caption2_b-3")->textContent), [''])));
|
|
|
if (!$this->message) throw new Exception("Błąd danych ze strony Ministerstwa Finansów");
|
|
|
- switch ($this->message[0]) {
|
|
|
- case "Podmiot o podanym identyfikatorze podatkowym NIP jest zarejestrowany jako podatnik VAT czynny" : return true;
|
|
|
- case "Podmiot o podanym identyfikatorze podatkowym NIP nie jest zarejestrowany jako podatnik VAT" : return false;
|
|
|
- default: throw new Exception("Nieznany rezultat");
|
|
|
- }
|
|
|
+ if (isset($this->messages[$this->message[0]])) return $this->messages[$this->message[0]]['active'];
|
|
|
+ else throw new Exception("Nieznany rezultat");
|
|
|
}
|
|
|
|
|
|
public function getMessage($whole = false) {
|
|
|
@@ -165,6 +176,12 @@ Class VAT {
|
|
|
else return $this->message[0];
|
|
|
}
|
|
|
|
|
|
+ public function getShortMessage() {
|
|
|
+ if (!$this->message) return "Brak wyniku";
|
|
|
+ if (!isset($this->messages[$this->message[0]])) return "Nieznany rezultat";
|
|
|
+ return $this->messages[$this->message[0]]['shortMessage'];
|
|
|
+ }
|
|
|
+
|
|
|
public function isActiveVatPayer($nip) {
|
|
|
$this->message = [];
|
|
|
$nip = str_replace("-", "", trim($nip));
|