Jelajahi Sumber

drobne poprawki

Mariusz Muszyński 7 tahun lalu
induk
melakukan
5160b37667
3 mengubah file dengan 12 tambahan dan 9 penghapusan
  1. 11 8
      SE/se-lib/Route/UrlAction/BiAuditGenerate.php
  2. 0 1
      SE/se-lib/Teryt.php
  3. 1 0
      SE/se-lib/VAT.php

+ 11 - 8
SE/se-lib/Route/UrlAction/BiAuditGenerate.php

@@ -1582,7 +1582,7 @@ Router::getRoute("UrlAction_BiAuditGenerate")->' . $function . ';
 				'TERYT_SYM_UL',
 			],
 			'BI_audit_KRS' => [
-				'"Zaimportowanoz KRS na podstawie umowy"',
+				'"Zaimportowano z KRS na podstawie faktury/umowy"',
 				'nazwa',
 				'nip',
 				'regon',
@@ -1597,7 +1597,7 @@ Router::getRoute("UrlAction_BiAuditGenerate")->' . $function . ';
 				'TERYT_SYM_UL',
 			],
 			'BI_audit_CEIDG' => [
-				'"Zaimportowano z CEiDG na podstawie umowy"',
+				'"Zaimportowano z CEiDG na podstawie faktury/umowy"',
 				'firma',
 				'nip',
 				'regon',
@@ -1631,14 +1631,17 @@ Router::getRoute("UrlAction_BiAuditGenerate")->' . $function . ';
 				$query = "delete from `{$refTableFakturyToKontrahenci}` where PRIMARY_KEY = '{$row['ID']}'";
 				DB::getPDO()->query($query);
 			}
-			if (!$nip) continue;
+			if (!$nip) {
+				DB::getPDO()->update('BI_audit_ENERGA_FAKTURY', "ID", $ID, ['A_STATUS' => 'OFF_SOFT']);
+				continue;
+			}
 
 			$K_IDs = [];
 			$query = "select `ID` from `BI_audit_ENERGA_RUM_KONTRAHENCI` where `NIP` = '{$nip}'";
 			if ($result2 = DB::getPDO()->fetchall($query)) {
 				foreach ($result2 as $item) $K_IDs[] = $item['ID'];
 			} else {
-				$query = "select ID from BI_audit_KRS where nip = '{$nip}'";
+				$query = "select ID from BI_audit_KRS where nip = '{$nip}' order by `ID` desc limit 1";
 				if ($result2 = DB::getPDO()->fetchall($query)) {
 					foreach ($result2 as $item) {
 						$query = "insert into `BI_audit_ENERGA_RUM_KONTRAHENCI` (" . implode(', ', $fields['BI_audit_ENERGA_RUM_KONTRAHENCI']) . ")" .
@@ -1646,7 +1649,7 @@ Router::getRoute("UrlAction_BiAuditGenerate")->' . $function . ';
 						if (DB::getPDO()->query($query)) $K_IDs[] = DB::getPDO()->lastInsertId();
 					}
 				} else {
-					$query = "select `ID` from `BI_audit_CEIDG` where `nip` = '{$nip}'";
+					$query = "select `ID` from `BI_audit_CEIDG` where `nip` = '{$nip}' order by `ID` desc limit 1";
 					if ($result2 = DB::getPDO()->fetchall($query)) {
 						foreach ($result2 as $item) {
 							$query = "insert into `BI_audit_ENERGA_RUM_KONTRAHENCI` (" . implode(', ', $fields['BI_audit_ENERGA_RUM_KONTRAHENCI']) . ")" .
@@ -1716,7 +1719,7 @@ SQL;
 						if ($result2 = DB::getPDO()->fetchall($query)) {
 							foreach ($result2 as $item) $K_IDs[] = $item['ID'];
 						} else {
-							$query = "select ID from BI_audit_KRS where nip = '{$nip}' or regon = '{$regon}'";
+							$query = "select ID from BI_audit_KRS where nip = '{$nip}' or regon = '{$regon}' order by `ID` desc limit 1";
 							if ($result2 = DB::getPDO()->fetchall($query)) {
 								foreach ($result2 as $item) {
 									$query = "insert into BI_audit_ENERGA_RUM_KONTRAHENCI (" . implode(', ', $fields['BI_audit_ENERGA_RUM_KONTRAHENCI']) . ")" .
@@ -1724,7 +1727,7 @@ SQL;
 									if (DB::getPDO()->query($query)) $K_IDs[] = DB::getPDO()->lastInsertId();
 								}
 							} else {
-								$query = "select ID from BI_audit_CEIDG where nip = '{$nip}' or regon = '{$regon}'";
+								$query = "select ID from BI_audit_CEIDG where nip = '{$nip}' or regon = '{$regon}' order by `ID` desc limit 1";
 								if ($result2 = DB::getPDO()->fetchall($query)) {
 									foreach ($result2 as $item) {
 										$query = "insert into BI_audit_ENERGA_RUM_KONTRAHENCI (" . implode(', ', $fields['BI_audit_ENERGA_RUM_KONTRAHENCI']) . ")" .
@@ -2205,7 +2208,7 @@ SQL;
 				$values[] = "`{$value}`";
 				$updates[] = "`BI_audit_ALL`.`{$field}` = `{$table}`.`{$value}`";
 			}
-			$queries[] = "update `BI_audit_ALL` join `{$table}` on `BI_audit_ALL`.`REMOTE_ID` = `{$table}`.`ID` set " . implode(", ", $updates) . " {$where}";
+			$queries[] = "update `BI_audit_ALL` join `{$table}` on `BI_audit_ALL`.`REMOTE_TABLE` = '{$table}' and `BI_audit_ALL`.`REMOTE_ID` = `{$table}`.`ID` set " . implode(", ", $updates) . " {$where}";
 			$queries[] = "insert into `BI_audit_ALL` (" . implode(", ", $fields) . ") select " . implode(", ", $values) . " from `{$table}` {$where}";
 			$queries[] = "update `{$table}` set `cached` = 1 {$where}";
 		}

+ 0 - 1
SE/se-lib/Teryt.php

@@ -104,7 +104,6 @@ class Teryt {
 			$where = "and WOJ = '{$return['WOJ']}' and POW = '{$return['POW']}'";
 
 			$query = "select WOJ, POW, GMI from `" . self::TERC_TABLE. "` where NAZWA = " . DB::getPDO()->quote($kodPocztowy['gmina']) . " and GMI is not null {$where} group by WOJ, POW, GMI";
-echo $query . "\n";
 			if (!($result = DB::getPDO()->fetchall($query))) throw new Exception("gmina not found");
 			if (count($result) == 1) {
 				$return['WOJ'] = $result[0]['WOJ'];

+ 1 - 0
SE/se-lib/VAT.php

@@ -116,6 +116,7 @@ Class VAT {
 	private function execute() {
 		$this->headers = [];
 		$result = curl_exec($this->ch);
+		if ($result === false) throw new Exception("Błąd połączenia ze stroną Ministerstwa Finansów");
 		if (curl_getinfo($this->ch)['http_code'] != 200) throw new Exception("Błąd połączenia ze stroną Ministerstwa Finansów");
 		return $result;
 	}