VAT , code VATEX must be used only UBL21 no FacturX
This commit is contained in:
parent
6485a6e5df
commit
36232abc2b
4 changed files with 52 additions and 46 deletions
|
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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??"" ) =="")
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue