Skip to content

Commit

Permalink
V.2.1.8
Browse files Browse the repository at this point in the history
- Fix recupero/creazione VAT RATES non associate
  • Loading branch information
websuvius committed Aug 22, 2023
1 parent bdb3ca8 commit 9394e50
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
2 changes: 1 addition & 1 deletion fattureincloud/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<module>
<name>fattureincloud</name>
<displayName><![CDATA[FattureInCloud]]></displayName>
<version><![CDATA[2.1.7]]></version>
<version><![CDATA[2.1.8]]></version>
<description><![CDATA[Collega il tuo negozio Prestashop al tuo account FattureInCloud! Sincronizza gli ordini, le anagrafiche ed emetti fatture!]]></description>
<author><![CDATA[FattureInCloud]]></author>
<tab><![CDATA[billing_invoicing]]></tab>
Expand Down
23 changes: 20 additions & 3 deletions fattureincloud/fattureincloud.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function __construct()
{
$this->name = 'fattureincloud';
$this->tab = 'billing_invoicing';
$this->version = '2.1.7';
$this->version = '2.1.8';
$this->author = 'FattureInCloud';
$this->need_instance = 1;

Expand Down Expand Up @@ -652,7 +652,7 @@ public function hookActionTaxFormBuilderModifier($params)

$vat_list_request = $fic_client->getVatTypes();

if (isset($vat_list_request['error'])) {
if (!$vat_list_request || isset($vat_list_request['error'])) {
$this->writeLog("ERROR - Lista IVA non recuperata: " . json_encode($vat_list_request));
} else {
$choices = array();
Expand Down Expand Up @@ -891,12 +891,29 @@ public function getDefaultVatID($vat_rate, $id_tax)
} elseif ($id_tax!= null) {
$fic_client = $this->initFattureInCloudClient();


$vat_list_request = $fic_client->getVatTypes();

if (isset($vat_list_request['error'])) {
$this->writeLog("ERROR - Lista IVA non recuperata: " . json_encode($vat_list_request));
} else {

foreach ($vat_list_request['data'] as $vat) {

if ($vat['value'] == $vat_rate) {
$this->writeLog("INFO - Vat type recuperato: " . json_encode($vat));
$this->writeExtraTaxValues($id_tax, $vat['id']);
return $vat['id'];
}
}
}

$vat_to_create = array("data" => array("value" => $vat_rate));

$new_vat_request = $fic_client->createVatType($vat_to_create);

if (isset($new_vat_request['error'])) {
$this->writeLog("ERROR - Vat type non creato: " . json_encode($new_vat_request));
$this->writeLog("ERROR - Vat type non creato ( " . json_encode($vat_to_create). " ): " . json_encode($new_vat_request));
return null;
} else {
$this->writeLog("INFO - Vat type creato: " . json_encode($new_vat_request));
Expand Down

0 comments on commit 9394e50

Please sign in to comment.