mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-02-19 21:10:49 +01:00
Correzioni per l'API osmservices
This commit is contained in:
parent
5a0ed16733
commit
97fb5cd324
@ -27,18 +27,8 @@ class Connection
|
|||||||
'resource' => $resource,
|
'resource' => $resource,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (!empty($options['multipart'])) {
|
|
||||||
foreach ($json as $key => $value) {
|
|
||||||
$options['multipart'][] = [
|
|
||||||
'name' => $key,
|
|
||||||
'contents' => $value,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$options['form_params'] = $json;
|
|
||||||
}
|
|
||||||
|
|
||||||
$options = array_merge($options, [
|
$options = array_merge($options, [
|
||||||
|
'json' => $json,
|
||||||
'http_errors' => false,
|
'http_errors' => false,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
@ -15,22 +15,22 @@ class Interaction extends Connection
|
|||||||
$fattura = new FatturaElettronica($id_record);
|
$fattura = new FatturaElettronica($id_record);
|
||||||
$file = DOCROOT.'/'.FatturaElettronica::getDirectory().'/'.$fattura->getFilename();
|
$file = DOCROOT.'/'.FatturaElettronica::getDirectory().'/'.$fattura->getFilename();
|
||||||
|
|
||||||
$response = static::request('POST', 'send_xml', [], [
|
$response = static::request('POST', 'invio_fattura_xml', [
|
||||||
'multipart' => [
|
'xml' => file_get_contents($file),
|
||||||
[
|
'filename' => $fattura->getFilename(),
|
||||||
'name' => 'xml',
|
|
||||||
'filename' => $fattura->getFilename(),
|
|
||||||
'contents' => file_get_contents($file),
|
|
||||||
],
|
|
||||||
],
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$body = static::responseBody($response);
|
$body = static::responseBody($response);
|
||||||
|
|
||||||
return $body;
|
return [
|
||||||
|
'code' => $body['status'],
|
||||||
|
'message' => $body['message'],
|
||||||
|
];
|
||||||
} catch (UnexpectedValueException $e) {
|
} catch (UnexpectedValueException $e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return [
|
||||||
|
'code' => 400,
|
||||||
|
'message' => tr('Fattura non generata correttamente'),
|
||||||
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,28 +24,14 @@ class Interaction extends Connection
|
|||||||
|
|
||||||
// Ricerca da remoto
|
// Ricerca da remoto
|
||||||
if (self::isEnabled()) {
|
if (self::isEnabled()) {
|
||||||
$response = static::request('POST', 'get_fatture_da_importare');
|
$response = static::request('POST', 'fatture_da_importare');
|
||||||
$body = static::responseBody($response);
|
$body = static::responseBody($response);
|
||||||
|
|
||||||
$code = $body['code'];
|
if ($body['status'] == '200') {
|
||||||
|
|
||||||
if ($code == '200') {
|
|
||||||
$files = $body['results'];
|
$files = $body['results'];
|
||||||
|
|
||||||
foreach ($files as $file) {
|
foreach ($files as $file) {
|
||||||
/*
|
$list[] = basename($file);
|
||||||
* Verifico che l'XML (fattura di acquisto) non sia già stato importato nel db, controllo p.iva del fornitore e progressivo invio
|
|
||||||
* TODO: caricare contenuto xml e verificare anche la data (e magari numero) della fattura. Potrebbe essere che il fornitore l'anno successivo mi genera FE con stesso progressivo invio.
|
|
||||||
*/
|
|
||||||
if (preg_match("/^([A-Z]{2})(.+?)_([^\.]+)\.xml/i", $file, $m)) {
|
|
||||||
$partita_iva = $m[2];
|
|
||||||
$progressivo_invio = $m[3];
|
|
||||||
$fattura = database()->fetchOne('SELECT co_documenti.id FROM (co_documenti INNER JOIN co_tipidocumento ON co_documenti.idtipodocumento=co_tipidocumento.id) INNER JOIN an_anagrafiche ON co_documenti.idanagrafica=an_anagrafiche.idanagrafica WHERE co_tipidocumento.dir="uscita" AND an_anagrafiche.piva='.prepare($partita_iva).' AND co_documenti.progressivo_invio='.prepare($progressivo_invio));
|
|
||||||
|
|
||||||
if (!$fattura) {
|
|
||||||
$list[] = basename($file);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -59,7 +45,7 @@ class Interaction extends Connection
|
|||||||
$file = $directory.'/'.$name;
|
$file = $directory.'/'.$name;
|
||||||
|
|
||||||
if (!file_exists($file)) {
|
if (!file_exists($file)) {
|
||||||
$response = static::request('POST', 'get_fattura_da_importare', [
|
$response = static::request('POST', 'fattura_da_importare', [
|
||||||
'name' => $name,
|
'name' => $name,
|
||||||
]);
|
]);
|
||||||
$body = static::responseBody($response);
|
$body = static::responseBody($response);
|
||||||
@ -72,14 +58,14 @@ class Interaction extends Connection
|
|||||||
|
|
||||||
public static function processXML($filename)
|
public static function processXML($filename)
|
||||||
{
|
{
|
||||||
$response = static::request('POST', 'process_xml', [
|
$response = static::request('POST', 'fattura_xml_salvata', [
|
||||||
'filename' => $filename,
|
'filename' => $filename,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$body = static::responseBody($response);
|
$body = static::responseBody($response);
|
||||||
|
|
||||||
if ($body['processed'] == '0') {
|
if ($body['status'] != '200') {
|
||||||
$message = $body['code'].' - '.$body['message'];
|
$message = $body['status'].' - '.$body['message'];
|
||||||
} else {
|
} else {
|
||||||
$message = '';
|
$message = '';
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ class Interaction extends Connection
|
|||||||
{
|
{
|
||||||
public static function getReceiptList()
|
public static function getReceiptList()
|
||||||
{
|
{
|
||||||
$response = static::request('POST', 'get_receipt_list');
|
$response = static::request('POST', 'notifiche_da_importare');
|
||||||
$body = static::responseBody($response)['results'];
|
$body = static::responseBody($response)['results'];
|
||||||
|
|
||||||
return $body;
|
return $body;
|
||||||
@ -21,7 +21,7 @@ class Interaction extends Connection
|
|||||||
|
|
||||||
public static function getReceipt($name)
|
public static function getReceipt($name)
|
||||||
{
|
{
|
||||||
$response = static::request('POST', 'get_receipt', [
|
$response = static::request('POST', 'notifica_da_importare', [
|
||||||
'name' => $name,
|
'name' => $name,
|
||||||
]);
|
]);
|
||||||
$body = static::responseBody($response);
|
$body = static::responseBody($response);
|
||||||
|
@ -28,6 +28,10 @@ class API extends \Util\Singleton
|
|||||||
'code' => 404,
|
'code' => 404,
|
||||||
'message' => 'Non trovato',
|
'message' => 'Non trovato',
|
||||||
],
|
],
|
||||||
|
'externalError' => [
|
||||||
|
'code' => 409,
|
||||||
|
'message' => 'Errore in un servizio esterno',
|
||||||
|
],
|
||||||
'serverError' => [
|
'serverError' => [
|
||||||
'code' => 500,
|
'code' => 500,
|
||||||
'message' => 'Errore del server',
|
'message' => 'Errore del server',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user