|
|
@@ -8,6 +8,11 @@ class Route_UrlAction_JPK extends RouteBase {
|
|
|
private $REFERER, $LAST_REFERER;
|
|
|
private $JPK, $BO;
|
|
|
private $NIPerrors = array();
|
|
|
+ private $JPK_VAT_Wariant = null;
|
|
|
+ const tns = [
|
|
|
+ 2 => "http://jpk.mf.gov.pl/wzor/2016/10/26/10261/",
|
|
|
+ 3 => "http://jpk.mf.gov.pl/wzor/2017/11/13/1113/",
|
|
|
+ ];
|
|
|
|
|
|
public function handleAuth() {
|
|
|
if (!User::logged()) {
|
|
|
@@ -23,6 +28,12 @@ class Route_UrlAction_JPK extends RouteBase {
|
|
|
else throw new Exception("Dostęp zabroniony");
|
|
|
if ($result = DB::getPDO()->fetchall("select * from BILLING_OWNER where ID='{$this->JPK['ID_BILLING_OWNER']}'")) $this->BO = $result[0];
|
|
|
else throw new Exception("Błąd spójności danych");
|
|
|
+ if ($this->JPK['A_STATUS'] != 'WAITING') {
|
|
|
+ if (!$this->JPK['MONTH']) throw new Exception("Błąd daty w rekordzie JPK_VAT");
|
|
|
+ $year = date("Y", strtotime($this->JPK['MONTH']));
|
|
|
+ if ($year < 2018) $this->JPK_VAT_Wariant = 2;
|
|
|
+ else $this->JPK_VAT_Wariant = 3;
|
|
|
+ }
|
|
|
} catch (Exception $e) {
|
|
|
SE_Layout::gora();
|
|
|
SE_Layout::menu();
|
|
|
@@ -180,34 +191,46 @@ format: 'YYYY-MM'
|
|
|
"PodatekNaliczony" => "Podatek naliczony"
|
|
|
);
|
|
|
|
|
|
- private function showJPK_VAT($xml) {
|
|
|
+ private static function getNamespaces($xml) {
|
|
|
$ns = $xml->getNamespaces(true);
|
|
|
+ if (!isset($ns['tns'])) {
|
|
|
+ if (isset($ns[''])) {
|
|
|
+ $ns['tns'] = $ns[''];
|
|
|
+ unset($ns['']);
|
|
|
+ } else throw new Exception('Błędna struktura namespace');
|
|
|
+ }
|
|
|
+ foreach ($ns as $k => $v) $xml->registerXPathNamespace($k, $v);
|
|
|
+ return $ns;
|
|
|
+ }
|
|
|
+
|
|
|
+ private function showJPK_VAT($xml) {
|
|
|
+ $ns = self::getNamespaces($xml);
|
|
|
$summaryJPK_VAT = $this->getSummaryJPK_VAT($xml);
|
|
|
|
|
|
- $result['KodFormularza'] = $xml->Naglowek->KodFormularza;
|
|
|
- $result['WariantFormularza'] = $xml->Naglowek->WariantFormularza;
|
|
|
- $result['CelZlozenia'] = $xml->Naglowek->CelZlozenia;
|
|
|
- $result['DataWytworzeniaJPK'] = date("Y-m-d H:i:s", strtotime($xml->Naglowek->DataWytworzeniaJPK));
|
|
|
- $result['DataOd'] = $xml->Naglowek->DataOd;
|
|
|
- $result['DataDo'] = $xml->Naglowek->DataDo;
|
|
|
- $result['DomyslnyKodWaluty'] = $xml->Naglowek->DomyslnyKodWaluty;
|
|
|
- $result['KodUrzedu'] = $xml->Naglowek->KodUrzedu;
|
|
|
- $result['NIP'] = $xml->Podmiot1->IdentyfikatorPodmiotu->children($ns['etd'])->NIP;
|
|
|
- $result['PelnaNazwa'] = $xml->Podmiot1->IdentyfikatorPodmiotu->children($ns['etd'])->PelnaNazwa;
|
|
|
- $result['REGON'] = $xml->Podmiot1->IdentyfikatorPodmiotu->children($ns['etd'])->REGON;
|
|
|
- $result['KodKraju'] = $xml->Podmiot1->AdresPodmiotu->KodKraju;
|
|
|
- $result['Wojewodztwo'] = $xml->Podmiot1->AdresPodmiotu->Wojewodztwo;
|
|
|
- $result['Powiat'] = $xml->Podmiot1->AdresPodmiotu->Powiat;
|
|
|
- $result['Gmina'] = $xml->Podmiot1->AdresPodmiotu->Gmina;
|
|
|
- $result['Ulica'] = $xml->Podmiot1->AdresPodmiotu->Ulica;
|
|
|
- $result['NrDomu'] = $xml->Podmiot1->AdresPodmiotu->NrDomu;
|
|
|
- $result['NrLokalu'] = $xml->Podmiot1->AdresPodmiotu->NrLokalu;
|
|
|
- $result['Miejscowosc'] = $xml->Podmiot1->AdresPodmiotu->Miejscowosc;
|
|
|
- $result['KodPocztowy'] = $xml->Podmiot1->AdresPodmiotu->KodPocztowy;
|
|
|
- $result['Poczta'] = $xml->Podmiot1->AdresPodmiotu->Poczta;
|
|
|
- $result['LiczbaWierszySprzedazy'] = $summaryJPK_VAT['LiczbaWierszySprzedazy'] ? $summaryJPK_VAT['LiczbaWierszySprzedazy'] : "";
|
|
|
+ $result['KodFormularza'] = $xml->xpath('/tns:JPK/tns:Naglowek/tns:KodFormularza')[0];
|
|
|
+ $result['WariantFormularza'] = $xml->xpath('/tns:JPK/tns:Naglowek/tns:WariantFormularza')[0];
|
|
|
+ $result['CelZlozenia'] = $xml->xpath('/tns:JPK/tns:Naglowek/tns:CelZlozenia')[0];
|
|
|
+ $result['DataWytworzeniaJPK'] = $xml->xpath('/tns:JPK/tns:Naglowek/tns:DataWytworzeniaJPK')[0];
|
|
|
+ $result['DataOd'] = $xml->xpath('/tns:JPK/tns:Naglowek/tns:DataOd')[0];
|
|
|
+ $result['DataDo'] = $xml->xpath('/tns:JPK/tns:Naglowek/tns:DataDo')[0];
|
|
|
+ $result['DomyslnyKodWaluty'] = $xml->xpath('/tns:JPK/tns:Naglowek/tns:DomyslnyKodWaluty')[0];
|
|
|
+ $result['KodUrzedu'] = $xml->xpath('/tns:JPK/tns:Naglowek/tns:KodUrzedu')[0];
|
|
|
+ $result['NIP'] = $xml->xpath('/tns:JPK/tns:Podmiot1/tns:IdentyfikatorPodmiotu/etd:NIP')[0];
|
|
|
+ $result['PelnaNazwa'] = $xml->xpath('/tns:JPK/tns:Podmiot1/tns:IdentyfikatorPodmiotu/etd:PelnaNazwa')[0];
|
|
|
+ $result['REGON'] = $xml->xpath('/tns:JPK/tns:Podmiot1/tns:IdentyfikatorPodmiotu/etd:REGON')[0];
|
|
|
+ $result['KodKraju'] = $xml->xpath('/tns:JPK/tns:Podmiot1/tns:AdresPodmiotu/tns:KodKraju')[0];
|
|
|
+ $result['Wojewodztwo'] = $xml->xpath('/tns:JPK/tns:Podmiot1/tns:AdresPodmiotu/tns:Wojewodztwo')[0];
|
|
|
+ $result['Powiat'] = $xml->xpath('/tns:JPK/tns:Podmiot1/tns:AdresPodmiotu/tns:Powiat')[0];
|
|
|
+ $result['Gmina'] = $xml->xpath('/tns:JPK/tns:Podmiot1/tns:AdresPodmiotu/tns:Gmina')[0];
|
|
|
+ $result['Ulica'] = $xml->xpath('/tns:JPK/tns:Podmiot1/tns:AdresPodmiotu/tns:Ulica')[0];
|
|
|
+ $result['NrDomu'] = $xml->xpath('/tns:JPK/tns:Podmiot1/tns:AdresPodmiotu/tns:NrDomu')[0];
|
|
|
+ $result['NrLokalu'] = $xml->xpath('/tns:JPK/tns:Podmiot1/tns:AdresPodmiotu/tns:NrLokalu')[0];
|
|
|
+ $result['Miejscowosc'] = $xml->xpath('/tns:JPK/tns:Podmiot1/tns:AdresPodmiotu/tns:Miejscowosc')[0];
|
|
|
+ $result['KodPocztowy'] = $xml->xpath('/tns:JPK/tns:Podmiot1/tns:AdresPodmiotu/tns:KodPocztowy')[0];
|
|
|
+ $result['Poczta'] = $xml->xpath('/tns:JPK/tns:Podmiot1/tns:AdresPodmiotu/tns:Poczta')[0];
|
|
|
+ $result['LiczbaWierszySprzedazy'] = $summaryJPK_VAT['LiczbaWierszySprzedazy'] ?: "";
|
|
|
$result['PodatekNalezny'] = $summaryJPK_VAT['LiczbaWierszySprzedazy'] ? number_format($summaryJPK_VAT['PodatekNalezny'], 2, ',', '.'): "";
|
|
|
- $result['LiczbaWierszyZakupow'] = $summaryJPK_VAT['LiczbaWierszyZakupow'] ? $summaryJPK_VAT['LiczbaWierszyZakupow'] : "";
|
|
|
+ $result['LiczbaWierszyZakupow'] = $summaryJPK_VAT['LiczbaWierszyZakupow'] ?: "";
|
|
|
$result['PodatekNaliczony'] = $summaryJPK_VAT['LiczbaWierszyZakupow'] ? number_format($summaryJPK_VAT['PodatekNaliczony'], 2, ',', '.'): "";
|
|
|
|
|
|
return $result;
|
|
|
@@ -425,6 +448,10 @@ format: 'YYYY-MM'
|
|
|
}
|
|
|
|
|
|
private function getSummaryJPK_VAT($xml) {
|
|
|
+ $ns = $xml->getNamespaces(true);
|
|
|
+ $tns = self::tns[$this->JPK_VAT_Wariant];
|
|
|
+ if (array_search($tns, $ns) === false) throw new Exception("Błąd struktury pliku XML - błędny namespace");
|
|
|
+
|
|
|
$PodatekNaleznyFields = array("K_16" => "1", "K_18" => "1", "K_20" => "1", "K_24" => "1", "K_26" => "1", "K_28" => "1",
|
|
|
"K_30" => "1", "K_33" => "1", "K_35" => "1", "K_36" => "1", "K_37" => "1", "K_38" => "-1", "K_39" => "-1");
|
|
|
$PodatekNaliczonyFields = array("K_44" => 1, "K_46" => 1, "K_47" => 1, "K_48" => 1, "K_49" => 1, "K_50" => 1);
|
|
|
@@ -435,19 +462,19 @@ format: 'YYYY-MM'
|
|
|
"LiczbaWierszyZakupow" => 0,
|
|
|
"PodatekNaliczony" => 0);
|
|
|
|
|
|
- foreach ($xml->SprzedazWiersz as $SprzedazWiersz) {
|
|
|
+ foreach ($xml->children($tns)->SprzedazWiersz as $SprzedazWiersz) {
|
|
|
foreach ($PodatekNaleznyFields as $PodatekNaleznyField => $sign) {
|
|
|
- if (isset($SprzedazWiersz->$PodatekNaleznyField)) {
|
|
|
- $result["PodatekNalezny"] += round((float) $SprzedazWiersz->$PodatekNaleznyField * $sign, 2);
|
|
|
+ if (isset($SprzedazWiersz->children($tns)->$PodatekNaleznyField)) {
|
|
|
+ $result["PodatekNalezny"] += round((float) $SprzedazWiersz->children($tns)->$PodatekNaleznyField * $sign, 2);
|
|
|
}
|
|
|
}
|
|
|
$result["LiczbaWierszySprzedazy"]++;
|
|
|
}
|
|
|
|
|
|
- foreach ($xml->ZakupWiersz as $ZakupWiersz) {
|
|
|
+ foreach ($xml->children($tns)->ZakupWiersz as $ZakupWiersz) {
|
|
|
foreach ($PodatekNaliczonyFields as $PodatekNaliczonyField => $sign) {
|
|
|
- if (isset($ZakupWiersz->$PodatekNaliczonyField)) {
|
|
|
- $result["PodatekNaliczony"] += round((float) $ZakupWiersz->$PodatekNaliczonyField * $sign, 2);
|
|
|
+ if (isset($ZakupWiersz->children($tns)->$PodatekNaliczonyField)) {
|
|
|
+ $result["PodatekNaliczony"] += round((float) $ZakupWiersz->children($tns)->$PodatekNaliczonyField * $sign, 2);
|
|
|
}
|
|
|
}
|
|
|
$result["LiczbaWierszyZakupow"]++;
|
|
|
@@ -459,30 +486,30 @@ format: 'YYYY-MM'
|
|
|
}
|
|
|
|
|
|
private function validateJPK_VAT(&$xml) {
|
|
|
- $ns = $xml->getNamespaces(true);
|
|
|
- if ($xml->Naglowek->KodFormularza != "JPK_VAT") throw new Exception("Błędny typ deklaracji JPK");
|
|
|
- if ($xml->Naglowek->WariantFormularza != "2") throw new Exception("Błędna wersja deklaracji JPK");
|
|
|
- if ($xml->Naglowek->CelZlozenia != $this->JPK['PURPOSE']) throw new Exception("Niezgodny cel złożenia deklaracji JPK");
|
|
|
- if ($xml->Naglowek->DataOd != ($this->JPK['MONTH'] . "-01")) throw new Exception("Błędna data 'od' deklaracji JPK");
|
|
|
- if ($xml->Naglowek->DataDo != date("Y-m-d", strtotime($xml->Naglowek->DataOd . "+ 1 month - 1 day"))) throw new Exception("Błędna data 'do' deklaracji JPK");
|
|
|
- if ($xml->Naglowek->DomyslnyKodWaluty != "PLN") throw new Exception("Błędna waluta deklaracji JPK");
|
|
|
- if (trim(str_replace('-', '', $xml->Podmiot1->IdentyfikatorPodmiotu->children($ns['etd'])->NIP)) != trim(str_replace('-', '', $this->BO['nip']))) throw new Exception("Niezgodny NIP podmiotu w deklaracji JPK");
|
|
|
+ $ns = self::getNamespaces($xml);
|
|
|
+
|
|
|
+ if ($xml->xpath('/tns:JPK/tns:Naglowek/tns:KodFormularza')[0] != "JPK_VAT") throw new Exception("Błędny typ deklaracji JPK");
|
|
|
+ if ($xml->xpath('/tns:JPK/tns:Naglowek/tns:WariantFormularza')[0] != $this->JPK_VAT_Wariant) throw new Exception("Błędna wersja deklaracji JPK");
|
|
|
+ if ($xml->xpath('/tns:JPK/tns:Naglowek/tns:CelZlozenia')[0] != $this->JPK['PURPOSE']) throw new Exception("Niezgodny cel złożenia deklaracji JPK");
|
|
|
+ if ($xml->xpath('/tns:JPK/tns:Naglowek/tns:DataOd')[0] != ($this->JPK['MONTH'] . "-01")) throw new Exception("Błędna data 'od' deklaracji JPK");
|
|
|
+ if ($xml->xpath('/tns:JPK/tns:Naglowek/tns:DataDo')[0] != date("Y-m-d", strtotime($xml->xpath('/tns:JPK/tns:Naglowek/tns:DataOd')[0] . " + 1 month - 1 day"))) throw new Exception("Błędna data 'do' deklaracji JPK");
|
|
|
+ if ($xml->xpath('/tns:JPK/tns:Naglowek/tns:DomyslnyKodWaluty')[0] != "PLN") throw new Exception("Błędna waluta deklaracji JPK");
|
|
|
+ if (trim(str_replace('-', '', $xml->xpath('/tns:JPK/tns:Podmiot1/tns:IdentyfikatorPodmiotu/etd:NIP')[0])) != trim(str_replace('-', '', $this->BO['nip']))) throw new Exception("Niezgodny NIP podmiotu w deklaracji JPK");
|
|
|
$summaryJPK_VAT = $this->getSummaryJPK_VAT($xml);
|
|
|
if ($summaryJPK_VAT["LiczbaWierszySprzedazy"]) {
|
|
|
- if ($xml->SprzedazCtrl->LiczbaWierszySprzedazy != $summaryJPK_VAT["LiczbaWierszySprzedazy"]) throw new Exception("Brak spójności liczby wierszy sprzedaży w deklaracji JPK");
|
|
|
- if (((float) $xml->SprzedazCtrl->PodatekNalezny) != $summaryJPK_VAT["PodatekNalezny"]) throw new Exception("Brak spójności wartości podatku należnego w deklaracji JPK");
|
|
|
+ if ($xml->xpath('/tns:JPK/tns:SprzedazCtrl/tns:LiczbaWierszySprzedazy')[0] != $summaryJPK_VAT["LiczbaWierszySprzedazy"]) throw new Exception("Brak spójności liczby wierszy sprzedaży w deklaracji JPK");
|
|
|
+ if (((float) $xml->xpath('/tns:JPK/tns:SprzedazCtrl/tns:PodatekNalezny')[0]) != $summaryJPK_VAT["PodatekNalezny"]) throw new Exception("Brak spójności wartości podatku należnego w deklaracji JPK");
|
|
|
}
|
|
|
if ($summaryJPK_VAT["LiczbaWierszyZakupow"]) {
|
|
|
- if ($xml->ZakupCtrl->LiczbaWierszyZakupow != $summaryJPK_VAT["LiczbaWierszyZakupow"]) throw new Exception("Brak spójności liczby wierszy zakupów w deklaracji JPK");
|
|
|
- if (((float) $xml->ZakupCtrl->PodatekNaliczony) != $summaryJPK_VAT["PodatekNaliczony"]) throw new Exception("Brak spójności wartości podatku naliczonego w deklaracji JPK");
|
|
|
+ if ($xml->xpath('/tns:JPK/tns:ZakupCtrl/tns:LiczbaWierszyZakupow')[0] != $summaryJPK_VAT["LiczbaWierszyZakupow"]) throw new Exception("Brak spójności liczby wierszy zakupów w deklaracji JPK");
|
|
|
+ if (((float) $xml->xpath('/tns:JPK/tns:ZakupCtrl/tns:PodatekNaliczony')[0]) != $summaryJPK_VAT["PodatekNaliczony"]) throw new Exception("Brak spójności wartości podatku naliczonego w deklaracji JPK");
|
|
|
}
|
|
|
|
|
|
- function HandleXmlError($errno, $errstr, $errfile, $errline) {
|
|
|
+ set_error_handler(function ($errno, $errstr, $errfile, $errline) {
|
|
|
if ($errno==E_WARNING && (substr_count($errstr,"DOMDocument::loadXML()")>0)) throw new DOMException($errstr);
|
|
|
else return false;
|
|
|
- }
|
|
|
+ });
|
|
|
|
|
|
- set_error_handler('HandleXmlError');
|
|
|
try {
|
|
|
$dom = new DOMDocument();
|
|
|
$dom->preserveWhiteSpace = false;
|
|
|
@@ -491,10 +518,16 @@ format: 'YYYY-MM'
|
|
|
} catch (Exception $e) {
|
|
|
throw new Exception("Błąd parsowania pliku JPK");
|
|
|
}
|
|
|
+
|
|
|
restore_error_handler();
|
|
|
|
|
|
+ $xsd = [
|
|
|
+ 2 => 'Schemat_JPK_VAT(2)_v1-0.xsd',
|
|
|
+ 3 => 'Schemat_JPK_VAT(3)_v1-1.xsd',
|
|
|
+ ];
|
|
|
+
|
|
|
libxml_use_internal_errors(true);
|
|
|
- if (!$dom->schemaValidate(APP_PATH_SCHEMA . "/jpk/Schemat_JPK_VAT(2)_v1-0.xsd")) {
|
|
|
+ if (!$dom->schemaValidate(APP_PATH_SCHEMA . "/jpk/" . $xsd[$this->JPK_VAT_Wariant])) {
|
|
|
$errors = '';
|
|
|
foreach (libxml_get_errors() as $libxml_error) $errors .= "<br/>{$libxml_error->message}";
|
|
|
throw new Exception("Plik JPK niezgodny ze schematem XSD{$errors}<pre>" . htmlentities($dom->saveXML()) . "</pre>");
|
|
|
@@ -508,6 +541,7 @@ format: 'YYYY-MM'
|
|
|
if ($_FILES['IN_INSERT']['type'] != "text/xml") throw new Exception("Błędny plik JPK");
|
|
|
$xml = simplexml_load_file($_FILES['IN_INSERT']['tmp_name']);
|
|
|
$this->validateJPK_VAT($xml);
|
|
|
+
|
|
|
if ($this->JPK['IN_L1']) $info = "Zaimportowano dane z Insert i L1";
|
|
|
else $info = "Zaimportowano dane z Insert";
|
|
|
|
|
|
@@ -764,11 +798,11 @@ EOT;
|
|
|
|
|
|
ksort($data);
|
|
|
|
|
|
- function addCdata(&$node, $value) {
|
|
|
+ $addCdata = function(&$node, $value) {
|
|
|
$dom_node = dom_import_simplexml($node);
|
|
|
$dom_owner = $dom_node->ownerDocument;
|
|
|
$dom_node->appendChild($dom_owner->createCDATASection($value));
|
|
|
- }
|
|
|
+ };
|
|
|
|
|
|
$i = 0;
|
|
|
foreach ($data as $pos) {
|
|
|
@@ -779,7 +813,7 @@ EOT;
|
|
|
ksort($pos[1]);
|
|
|
foreach ($pos as $subpos) foreach ($subpos as $key => $value) {
|
|
|
$x->addChild($key, $value);
|
|
|
- if (!strlen($x->$key)) addCdata($x->$key, $value);
|
|
|
+ if (!strlen($x->$key)) $addCdata($x->$key, $value);
|
|
|
}
|
|
|
}
|
|
|
if ($this->NIPerrors) throw new Exception("Błędne numery NIP:<br/>" . implode("<br/>", $this->NIPerrors));
|
|
|
@@ -843,6 +877,19 @@ EOT;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private static function removeTnsNamespace(&$xml) {
|
|
|
+ $ns = $xml->getNamespaces(true);
|
|
|
+ if (isset($ns[''])) return;
|
|
|
+ if ((!isset($ns['tns']) || isset($ns['xsi']))) throw new Exception("Błędna struktura pliku XML - błędne namespace");
|
|
|
+
|
|
|
+ $dom = dom_import_simplexml($xml);
|
|
|
+ $ns_uri = $dom->lookupNamespaceURI('tns');
|
|
|
+ $dom->removeAttributeNS($ns_uri, 'tns');
|
|
|
+ $xml->addAttribute('xmlns', $ns['tns']);
|
|
|
+ $xml->addAttribute('xmlns:xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
|
|
|
+ $xml = simplexml_load_string($xml->asXML());
|
|
|
+ }
|
|
|
+
|
|
|
private function generate_merged_jpk() {
|
|
|
|
|
|
$xmlSchema = <<<EOT
|
|
|
@@ -850,28 +897,29 @@ EOT;
|
|
|
<JPK xmlns="http://jpk.mf.gov.pl/wzor/2016/10/26/10261/" xmlns:etd="http://crd.gov.pl/xml/schematy/dziedzinowe/mf/2016/01/25/eD/DefinicjeTypy/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
|
|
</JPK>
|
|
|
EOT;
|
|
|
-
|
|
|
- function xml_append(SimpleXMLElement $to, SimpleXMLElement $from) {
|
|
|
+ $xml_append = function(SimpleXMLElement $to, SimpleXMLElement $from) {
|
|
|
$toDom = dom_import_simplexml($to);
|
|
|
$fromDom = dom_import_simplexml($from);
|
|
|
$toDom->appendChild($toDom->ownerDocument->importNode($fromDom, true));
|
|
|
- }
|
|
|
+ };
|
|
|
|
|
|
try {
|
|
|
if (!($this->JPK['IN_INSERT'] && $this->JPK['IN_L1'])) throw new Exception("Błąd danych");
|
|
|
|
|
|
$xmlInsert = simplexml_load_string($this->JPK['IN_INSERT']);
|
|
|
+ self::removeTnsNamespace($xmlInsert);
|
|
|
$xmlL1 = simplexml_load_string($this->JPK['IN_L1']);
|
|
|
$xml = simplexml_load_string($xmlSchema);
|
|
|
+ $tns = self::tns[$this->JPK_VAT_Wariant];
|
|
|
|
|
|
switch (V::get('SRC_PODMIOT','',$_POST)) {
|
|
|
case "Insert":
|
|
|
- xml_append($xml, $xmlInsert->Naglowek);
|
|
|
- xml_append($xml, $xmlInsert->Podmiot1);
|
|
|
+ $xml_append($xml, $xmlInsert->children($tns)->Naglowek);
|
|
|
+ $xml_append($xml, $xmlInsert->children($tns)->Podmiot1);
|
|
|
break;
|
|
|
case "L1":
|
|
|
- xml_append($xml, $xmlL1->Naglowek);
|
|
|
- xml_append($xml, $xmlL1->Podmiot1);
|
|
|
+ $xml_append($xml, $xmlL1->children($tns)->Naglowek);
|
|
|
+ $xml_append($xml, $xmlL1->children($tns)->Podmiot1);
|
|
|
break;
|
|
|
default:
|
|
|
throw new Exception("Błąd formularza");
|
|
|
@@ -883,12 +931,12 @@ EOT;
|
|
|
foreach ($xmlInsert->SprzedazWiersz as $sprzedazWiersz) {
|
|
|
$this->validateNIP($sprzedazWiersz->NrKontrahenta, $sprzedazWiersz->NazwaKontrahenta, "Sprzedaż Insert");
|
|
|
$sprzedazWiersz->LpSprzedazy = ++$i;
|
|
|
- xml_append($xml, $sprzedazWiersz);
|
|
|
+ $xml_append($xml, $sprzedazWiersz);
|
|
|
}
|
|
|
foreach ($xmlL1->SprzedazWiersz as $sprzedazWiersz) {
|
|
|
$this->validateNIP($sprzedazWiersz->NrKontrahenta, $sprzedazWiersz->NazwaKontrahenta, "Sprzedaż L1");
|
|
|
$sprzedazWiersz->LpSprzedazy = ++$i;
|
|
|
- xml_append($xml, $sprzedazWiersz);
|
|
|
+ $xml_append($xml, $sprzedazWiersz);
|
|
|
}
|
|
|
$xml->addChild("SprzedazCtrl");
|
|
|
|
|
|
@@ -896,12 +944,12 @@ EOT;
|
|
|
foreach ($xmlInsert->ZakupWiersz as $zakupWiersz) {
|
|
|
$this->validateNIP($zakupWiersz->NrDostawcy, $zakupWiersz->NazwaDostawcy, "Zakup Insert");
|
|
|
$zakupWiersz->LpZakupu = ++$i;
|
|
|
- xml_append($xml, $zakupWiersz);
|
|
|
+ $xml_append($xml, $zakupWiersz);
|
|
|
}
|
|
|
foreach ($xmlL1->ZakupWiersz as $zakupWiersz) {
|
|
|
$this->validateNIP($zakupWiersz->NrDostawcy, $zakupWiersz->NazwaDostawcy, "Zakup L1");
|
|
|
$zakupWiersz->LpZakupu = ++$i;
|
|
|
- xml_append($xml, $zakupWiersz);
|
|
|
+ $xml_append($xml, $zakupWiersz);
|
|
|
}
|
|
|
$xml->addChild("ZakupCtrl");
|
|
|
|