Functii API > Adaugarea NIR-ului

Adaugarea NIR-ului

Metoda de adaugare a documentelor se apeleaza la adresa: https://appv1.facturis-online.ro/facturis/api/add_nir.php

Iata mai jos modul de apelare al acestei metode

Se face un POST pe pagina cu urmatorii parametrii:

xml_string – textul xml ce contine datele de logare si NIR-ul cu produse

In cazul in care datele sunt furnizate corect, se introduce documentul in sistem si se intoarce PDF-ul pentru listare ori salvare

In cazul in care apare o eroare aceasta va fi listata ca in exemplele urmatoare:

Eroare: 4 – Autentificare client esuata

Eroare: 12 – Data emiterii nu este valida


$xml_string='<?xml version="1.0" encoding="ISO-8859-1"?>
<addDoc>
  <login>
       <pass>!parola_primita_de_la_facturis_online!</pass>
  </login>  
  <nir>
      <office></office>
      <administration></administration>      
      <number>3</number>
      <issueDate>2014-06-11</issueDate>
      <supplier>furnizor</supplier>
	  <autoNr>nr. auto</autoNr>
      <docType>tip document</docType>
	  <docNr>nr. document</docNr>
      <observations>...</observations>
      <products>
          <product>
              <productId>1</productId>
              <productName>produs1</productName>
              <unit>buc</unit>
              <amount_in>2</amount_in>
              <unitPrice_in>6</unitPrice_in>
              <value_in>12</value_in>
			  <VATrate_in>24%</VATrate_in>
              <VAT_in>2.88</VAT_in>			  
              <amount>2</amount>
              <unitPrice>6</unitPrice>
              <value>12</value>
			  <VATrate>24%</VATrate>
              <VAT>2.88</VAT>
          </product>
          <product>
              <productId>2</productId>
              <productName>produs2</productName>
              <unit>buc</unit>
              <amount_in>3</amount_in>
              <unitPrice_in>6</unitPrice_in>
              <value_in>12</value_in>
			  <VATrate_in>24%</VATrate_in>
              <VAT_in>2.88</VAT_in>			  
              <amount>3</amount>
              <unitPrice>12</unitPrice>
              <value>24</value>
			  <VATrate>9%</VATrate>
              <VAT>2.16</VAT>
          </product>		  
      </products>
  </nir>
</addDoc>';
 
 $curl_options = array(
  CURLOPT_URL => "https://appv1.facturis-online.ro/facturis/api/add_nir.php",
  CURLOPT_POST => true,
  CURLOPT_POSTFIELDS => array(
				xml_string => $xml_string
			),
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_HEADER => false,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_CONNECTTIMEOUT => 5
);
 
$curl = curl_init();
curl_setopt_array( $curl, $curl_options );
$result = curl_exec( $curl );

 //daca raspunsul este o eroare
if (strrpos($result, "Eroare") !== false){
  echo $result;
  die;
}
 
  header('Cache-Control: public');
  header('Content-type: application/pdf');
  //daca se doreste salvata
  //header('Content-Disposition: attachment; filename="invoice.pdf"');
  //daca se doreste vizualizata
  header('Content-Disposition: inline; filename="invoice.pdf"');
  header('Content-Length: '.strlen($result));
  echo $result;
  die;


si descrierea tag-urilor XML:


<?xml version="1.0" encoding="ISO-8859-1"?>
<addDoc>
  <login>
       <pass>!parola_primita_de_la_facturis_online!</pass>
	   <!-- cod unic firma generat din facturis-online.ro - obligatoriu -->
  </login>  
  <nir>
      <office></office>
	  <!-- denumire punct de lucru din facturis-online.ro - optional -->
      <administration></administration>
	  <!-- denumire gestiune din facturis-online.ro - optional -->
      <number>3</number>
	  <!-- numar NIR - optional -->
      <issueDate>2014-06-11</issueDate>
	  <!-- Data emiterii - obligatoriu -->
      <supplier>furnizor</supplier>
	  <!-- Furnizor - obligatoriu -->
	  <autoNr>nr. auto</autoNr>
	  <!-- Nr. auto - optional -->
      <docType>tip document</docType>
	  <!-- Tipul documentului pe baza caruia se inregistreaza NIR-ul - obligatoriu -->
	  <docNr>nr. document</docNr>
	  <!-- Numarul documentului pe baza caruia se inregistreaza NIR-ul - obligatoriu -->	  
      <observations>...</observations>
	  <!-- Observatii - optional -->
      <products>
          <product>
              <productId>1</productId>
			  <!-- cod produs - optional -->
              <productName>produs1</productName>
			  <!-- nume produs - obligatoriu -->
              <unit>buc</unit>
			  <!-- unitate de masura - obligatoriu -->
              <amount_in>2</amount_in>
			  <!-- cantitate conform document- obligatoriu -->
              <unitPrice_in>6</unitPrice_in>
			  <!-- pret unitar fara TVA achizitie- obligatoriu -->
              <value_in>12</value_in>
			  <!-- valoare totala fara TVA achizitie- obligatoriu -->
			  <VATrate_in>24%</VATrate_in>
			  <!-- Cota TVA achizitie - obligatoriu -->
              <VAT_in>2.88</VAT_in>
			  <!-- valoare TVA achizitie- obligatoriu -->	
              <amount>2</amount>
			  <!-- cantitate receptionata- obligatoriu -->
              <unitPrice>6</unitPrice>
			  <!-- pret unitar fara TVA vanzare- obligatoriu -->
              <value>12</value>
			  <!-- valoare totala fara TVA vanzare- obligatoriu -->
			  <VATrate>24%</VATrate>
			  <!-- Cota TVA vanzare - obligatoriu -->
              <VAT>2.88</VAT>
			  <!-- valoare TVA vanzare- obligatoriu -->	
          </product>
          <product>
              <productId>2</productId>
			  <!-- cod produs - optional -->
              <productName>produs3</productName>
			  <!-- nume produs - obligatoriu -->
              <unit>buc</unit>
			  <!-- unitate de masura - obligatoriu -->
              <amount_in>3</amount_in>
			  <!-- cantitate conform document- obligatoriu -->
              <unitPrice_in>6</unitPrice_in>
			  <!-- pret unitar fara TVA achizitie- obligatoriu -->
              <value_in>18</value_in>
			  <!-- valoare totala fara TVA achizitie- obligatoriu -->
			  <VATrate_in>24%</VATrate_in>
			  <!-- Cota TVA achizitie - obligatoriu -->
              <VAT_in>4.32</VAT_in>
			  <!-- valoare TVA achizitie- obligatoriu -->	
              <amount>3</amount>
			  <!-- cantitate receptionata- obligatoriu -->
              <unitPrice>8</unitPrice>
			  <!-- pret unitar fara TVA vanzare- obligatoriu -->
              <value>24</value>
			  <!-- valoare totala fara TVA vanzare- obligatoriu -->
			  <VATrate>9%</VATrate>
			  <!-- Cota TVA vanzare - obligatoriu -->
              <VAT>2.16</VAT>
			  <!-- valoare TVA vanzare- obligatoriu -->	
          </product>		  
      </products>
  </nir>
</addDoc>


0