diff --git a/include/XMLDocument/facturx.class.php b/include/XMLDocument/facturx.class.php index 9e7f515ea..e47fd3756 100644 --- a/include/XMLDocument/facturx.class.php +++ b/include/XMLDocument/facturx.class.php @@ -111,7 +111,7 @@ class FacturX extends XMLInvoice $this->data = $this->build_data($jr_id); $company = $this->load_noalyss_parameter(); // var_dump($this->data); - $documentBuilder = ZugferdDocumentBuilder::createNew(ZugferdProfiles::PROFILE_XRECHNUNG_2_3); + $documentBuilder = ZugferdDocumentBuilder::createNew(ZugferdProfiles::PROFILE_EN16931); $documentBuilder->setDocumentInformation( $this->data['id'] ,"380" @@ -260,6 +260,9 @@ class FacturX extends XMLInvoice return $a_error; } - + function check_VAT() + { + return array(); + } } \ No newline at end of file diff --git a/include/XMLDocument/invoiceubl21.class.php b/include/XMLDocument/invoiceubl21.class.php index 40f5bb12e..2c62a938d 100644 --- a/include/XMLDocument/invoiceubl21.class.php +++ b/include/XMLDocument/invoiceubl21.class.php @@ -70,7 +70,49 @@ class InvoiceUBL21 extends XMLInvoice { include NOALYSS_TEMPLATE."/xmlinvoice-display_error.php"; } - + + /** + * @brief check that the VAT is using a PEPPOL Code + */ + function check_VAT() + { + $a_error=array(); + $nb_operation=count($this->data['operation']); + for ($i=0;$i <$nb_operation;$i++) + { + if ( $this->data['operation'][$i]['vat_code'] == "" ) { + $card=new \Fiche( + $this->cn + ,$this->data['operation'][$i]['card_id'] + ); + $tva= \Acc_Tva::build($this->cn, $this->data['operation'][$i]['vat_id']); + $a_error[]=sprintf(_("%s : %s code TVA pour PEPPOL non configuré code TVA [ %s %s ]") + , $i + , $card->get_quick_code() + ,$tva->tva_id + ,$tva->tva_code + ); + } + elseif (! in_array($this->data['operation'][$i]['vat_code'],array("S","Z"))) + { + $card=new \Fiche( + $this->cn + ,$this->data['operation'][$i]['card_id'] + ); + $tva= \Acc_Tva::build($this->cn, $this->data['operation'][$i]['vat_id']); + if ( $tva->vx_code == "") + { + $a_error[]=sprintf(_("%s : %s code Exemption pour PEPPOL non configuré code TVA [ %s %s ]") + , $i + , $card->get_quick_code() + ,$tva->tva_id + ,$tva->tva_code + ); + } + } + } + return $a_error; + } /** * @brief check that mandatory info are saved in the DB for company (seller) * @param $a_error (array) array of errors, empty if nothing found diff --git a/include/XMLDocument/xmlinvoice.class.php b/include/XMLDocument/xmlinvoice.class.php index 5077f9e1c..41de86bf9 100644 --- a/include/XMLDocument/xmlinvoice.class.php +++ b/include/XMLDocument/xmlinvoice.class.php @@ -350,49 +350,10 @@ abstract class XMLInvoice extends \DOMDocument include NOALYSS_TEMPLATE."/xmlinvoice-display_error.php"; } - /** * @brief check that the VAT is using a PEPPOL Code */ - function check_VAT() - { - $a_error=array(); - $nb_operation=count($this->data['operation']); - for ($i=0;$i <$nb_operation;$i++) - { - if ( $this->data['operation'][$i]['vat_code'] == "" ) { - $card=new \Fiche( - $this->cn - ,$this->data['operation'][$i]['card_id'] - ); - $tva= \Acc_Tva::build($this->cn, $this->data['operation'][$i]['vat_id']); - $a_error[]=sprintf(_("%s : %s code TVA pour PEPPOL non configuré code TVA [ %s %s ]") - , $i - , $card->get_quick_code() - ,$tva->tva_id - ,$tva->tva_code - ); - } - elseif (! in_array($this->data['operation'][$i]['vat_code'],array("S","Z"))) - { - $card=new \Fiche( - $this->cn - ,$this->data['operation'][$i]['card_id'] - ); - $tva= \Acc_Tva::build($this->cn, $this->data['operation'][$i]['vat_id']); - if ( $tva->vx_code == "") - { - $a_error[]=sprintf(_("%s : %s code Exemption pour PEPPOL non configuré code TVA [ %s %s ]") - , $i - , $card->get_quick_code() - ,$tva->tva_id - ,$tva->tva_code - ); - } - } - } - return $a_error; - } + abstract function check_VAT(); /** * @brief thanks MY_INVOICE_FORMAT , create the corresponding object diff --git a/include/class/tva_rate_mtable.class.php b/include/class/tva_rate_mtable.class.php index 3c0ba45f8..01fdc2d4f 100644 --- a/include/class/tva_rate_mtable.class.php +++ b/include/class/tva_rate_mtable.class.php @@ -453,17 +453,17 @@ class Tva_Rate_MTable extends Manage_Table_SQL } // if vatex is set then code invoice must be different from S and Z - if ( $g_parameter->MY_INVOICE_FORMAT != 'BASIC' && trim($this->table->vx_code??"") != "" && in_array($this->table->tva_peppol_code,['S','Z'] )) + if ( $g_parameter->MY_INVOICE_FORMAT == 'UBL21BE' && trim($this->table->vx_code??"") != "" && in_array($this->table->tva_peppol_code,['S','Z'] )) { $this->set_error("vx_code",_("Le code d'exemption TVA ne peut être utilisé avec ce code Facture électronique UBL ")); } // if vatex is set then code invoice must be different from S and Z - if ( $g_parameter->MY_INVOICE_FORMAT != 'BASIC' && trim($this->table->vx_code??"") != "" && $this->table->tva_peppol_code=="") + if ( $g_parameter->MY_INVOICE_FORMAT == 'UBL21BE' && trim($this->table->vx_code??"") != "" && $this->table->tva_peppol_code=="") { $this->set_error("vx_code",_("Le code d'exemption TVA n' pas de sens sans code Facture électronique")); } // if tva_peppol_code is not S or Z then a VATEX code must be supplied - if ( $g_parameter->MY_INVOICE_FORMAT != 'BASIC' + if ( $g_parameter->MY_INVOICE_FORMAT == 'UBL21BE' && ! in_array($this->table->tva_peppol_code??"",["Z","S"]) && trim($this->table->vx_code??"" ) =="") {