2namespace Noalyss\XMLDocument;
118 parent::__construct(
"1.0",
"UTF-8");
185 $result[
'currency']=$this->
cn->get_value(
"select cr_code_iso from currency where id=$1"
194 $a_note = $this->
cn->get_array(
"select n_id,n_text from jrn_note where jr_id=$1",[
$operation->det->jr_id]);
195 $nb_note=count($a_note);
196 for (
$e=0;
$e<$nb_note;
$e++)
199 $result[
'note'].= html_entity_decode($a_note[
$e][
'n_text']??
"");
215 $result[
'operation'][
$i][
'code_quantity']=(
$x===
false||
$x==
"")?
"EA":
$x;
224 $result[
'operation'][
$i][
'price_unit']=bcdiv(
233 $x=$this->
cn->get_row(
"select tva_peppol_code,tva_rate from tva_rate where tva_id=$1"
235 $result[
'operation'][
$i][
'vat_code']=(
$x[
'tva_peppol_code']==
"")?
"S":
$x[
'tva_peppol_code'];
236 $result[
'operation'][
$i][
'vat_rate']=
$x[
'tva_rate'];
243 $a_row=$this->
cn->get_array(
"select id_type,ji_value from jrn_info where jr_id=$1"
248 $result[
'info'][
'communication']=
'';
269 $result[
'LineExtensionAmount']=0;
270 $result[
'TaxExclusiveAmount']=0;
271 $result[
'TaxInclusiveAmount']=0;
279 $VAT_SubTotal=array();
283 $VAT_SubTotal=array();
285 $acc_tva=\Acc_TVA::build($this->
cn,
$result[
'operation'][
$i][
'vat_id'] );
286 $percent = bcmul($acc_tva->tva_rate,100,2);
292 $VAT_SubTotal[$idx_subtotal]=array();
293 $VAT_SubTotal[$idx_subtotal][
'idx']=
$idx;
294 $VAT_SubTotal[$idx_subtotal][
'vat_code']=
$result[
'operation'][
$i][
'vat_code'] ;
295 $VAT_SubTotal[$idx_subtotal][
'percent']=
$percent;
296 $VAT_SubTotal[$idx_subtotal][
'vatex']=$acc_tva->vx_code;
297 $VAT_SubTotal[$idx_subtotal][
'amount']=$VAT_SubTotal[$idx_subtotal][
'vat']=0;
304 $VAT_SubTotal[
$n][
'amount']=bcadd($VAT_SubTotal[
$n][
'amount'],
$result[
'operation'][
$i][
'price']);
305 $VAT_SubTotal[
$n][
'vat']=bcadd($VAT_SubTotal[
$n][
'vat'],
$result[
'operation'][
$i][
'vat']);
306 $VAT_SubTotal[
$n][
'vat']=bcsub($VAT_SubTotal[
$n][
'vat'],
$result[
'operation'][
$i][
'vat_reversed']);
312 $result[
'subTotalVAT']=$VAT_SubTotal;
330 $r=$this->
cn->get_array(
'
331 select pe_code, pe_value from parameter_extra
333 select pr_id,pr_value
336 return array_column(
$r,
"pe_value",
"pe_code");
364 $a_error=$this->verify();
365 include NOALYSS_TEMPLATE.
"/xmlinvoice-display_error.php";
382 return new \Noalyss\XMLDocument\InvoiceUBL21($conx);
385 return new \Noalyss\XMLDocument\FacturX($conx);
395 public function verify()
400 $a_error[
'general'] = [];
401 $a_error[
'operation']=[];
404 $a_error[
'company'] = $this->check_company_data();
405 $a_error[
'customer'] = $this->check_customer_data();
441 $result[
'customer_vat_id']=str_replace([
" ",
".",
"-",
"/"],
"" ,$customer->get_attribute(
ATTR_DEF_NUMTVA,0));
472 $result[
'name']=$a_parameter[
'MY_NAME'];
473 $result[
'street']=$a_parameter[
'MY_STREET'];
474 $result[
'postalzone']=$a_parameter[
'MY_POSTCODE'];
475 $result[
'city']=$a_parameter[
'MY_CITY'];
476 $result[
'country']=$a_parameter[
'MY_COUNTRY'];
478 $result[
'registration_name']=$a_parameter[
'MY_NAME'];
480 $result[
'supplier_vat_id']=str_replace([
" ",
".",
"-",
"/"],
"" ,$a_parameter[
'MY_TVA']);
485 $result[
'COUNTRY_CODE']=$a_parameter[
'MY_COUNTRY_CODE']?? substr(
$result[
'supplier_vat_id'], 0, 2);
486 $result[
'COMPANY_LEGAL_REGISTRATION']=$a_parameter[
'COMPANY_LEGAL_REGISTRATION']??
"";
487 $result[
'COMPANY_LEGAL_ENTITY']=$a_parameter[
'COMPANY_LEGAL_ENTITY']??
"";
488 $result[
'INVOICE_CONTACT_NAME']=$a_parameter[
'INVOICE_CONTACT_NAME']??
"";
489 $result[
'INVOICE_EMAIL_COMPANY']=$a_parameter[
'INVOICE_EMAIL_COMPANY']??
"";
490 $result[
'COMPANY_PEPPOL_ID']=$a_parameter[
'COMPANY_PEPPOL_ID']??
"";
511 $http=new \HttpInput();
512 $http->set_array($a_array);
514 $nb_item=
$http->get_value(
"nb_item");
515 for (
$i=0;
$i<$nb_item;
$i++)
517 if (
$http->get_value(
"e_march{$i}_tva_id") ==
"")
546 if ( !file_exists($pdf_filename)) {
547 throw new \Exception(
"AD65 $pdf_filename doesn't not exist");
549 $this->pdf_filename = $pdf_filename;
560 $a_document=$this->
cn->get_array(
"select js_id,js_filename,js_description,js_lob from jrn_sup_document where js_mimetype='application/pdf' AND jr_id=$1",
562 if ($a_document ==
null)
return array();
564 foreach ($a_document as $document)
566 $result[]=array(
"filename"=>$document[
'js_filename']
567 ,
"description"=>$document[
'js_description']
568 ,
'oid'=>$document[
'js_lob']
569 ,
'id'=>$document[
'js_id']
find_idx($array, $key, $value)
retrieve the index for the key percent, returns -1 if nothing found
catch(Exception $exc) if(! $g_user->can_write_action($ag_id)) $r
static build($db, $p_code)
retrieve TVA rate thanks the code that could be the tva_id or tva_code.
contains the class for connecting to Noalyss
static from_qcode(Database $cn, string $p_qcode)
create a card from a qcode and returns a card
Mother class for e-invoice.
$cn
Database conx , current folder.
$jr_id
$data (Array) data retrieve from DB
load_noalyss_parameter()
make an array of parameter_extra where pe_code as key and pe_value as value
display_error()
display_error display a warning with all error
check_VAT()
check that the VAT is using a PEPPOL Code
fill_document($jr_id)
retrieve additionnal documents but only PDF , not other files
get_db_conx()
get Database Connexion
check_company_data()
check that mandatory info are saved in the DB for company (seller)
set_db_conx(\Database $cn)
set Database Connexion
fill_operation_from_array($a_array)
build operation from array key :
static build_xmlinvoice(\Database $conx)
thanks MY_INVOICE_FORMAT , create the corresponding object
__construct(\Database $conx)
$jr_id (int) is JRN.JR_ID
check_customer_data()
check that mandatory info are saved in the DB for customer
fill_customer($card_id)
retrieve data from customer and return it into an array
build_data($jr_id)
transform an operation ($jr_id) into an array, which contains needed information for making an e-invo...
set_pdf_filename($pdf_filename)
set the PDF
set_data($data)
returns data
create_invoice($operation_id)
create the invoice in the right format, with PDF if any
make_xml($jr_id)
create an XML invoice based on JRN.JR_ID operation.
fill_supplier()
complete $this->data from $g_parameter (global variable) for Noalyss_Folder_Parameter
const ATTR_DEF_COUNTRY_CODE
const ATTR_DEF_QUANTITY_TYPE