E-INVOICE : add note top level

This commit is contained in:
sparkyx 2025-12-17 17:53:15 +01:00
parent b3215890d0
commit 8462e4ffe3
3 changed files with 37 additions and 8 deletions

View file

@ -565,7 +565,10 @@ class InvoiceUBL21 extends XMLInvoice {
/**
* add note if any
*/
if ( $this->data['note'] != "")
{
$root->appendChild($this->createElement("cbc:Note",$this->data['note']));
}
$root->appendChild($this->createElement('cbc:DocumentCurrencyCode',$this->data['currency']));
$root->appendChild($this->createElement('cbc:BuyerReference',$this->data['info']['order']));
/**

View file

@ -276,7 +276,7 @@ abstract class XML_Reader
$a = $note->length;
for ($i = 0; $i < $a; $i++)
{
$result['note'][] = $note->item(0)->nodeValue;
$result['note'][] = $note->item($i)->nodeValue;
}
}
/**
@ -391,6 +391,9 @@ abstract class XML_Reader
$result['DocumentCurrencyCode'] = $this->get_node_value('cbc:DocumentCurrencyCode');
$result['BuyerReference'] = $this->get_node_value('cbc:BuyerReference');
$result['ActualDeliveryDate'] = $this->get_node_value('//cac:Delivery[1]/cbc:ActualDeliveryDate[1]');
$result['info']=array();
$result['info']['note']=$this->get_node_value("//cbc:Note");
/*
<cac:Delivery>
<cbc:ActualDeliveryDate>2018-07-01</cbc:ActualDeliveryDate>
@ -409,14 +412,15 @@ abstract class XML_Reader
//$pdf = new PDF($cn);
$pdf = new PDF();
$result = $this->get_info();
$info=$result;
// $pdf->setDossierInfo(_(" id ") . " " . $result['id']);
$pdf->AliasNbPages();
$pdf->setAuthor("Noalyss");
$pdf->AddPage();
// 180 mm large
$pdf->setFont("DejaVu", "B", 12);
$pdf->write_cell(60, 4, _("Information facture"));
$pdf->setFont("DejaVu", "B", 16);
$pdf->write_cell(20, 10, "");
$pdf->write_cell(170, 10, _("INFORMATION"),1,0,'C');
$pdf->line_new(10);
$pdf->setFont("DejaVu", "", 7);
$pdf->write(4, sprintf(_("Document ID %s"), $result['id']));
@ -463,7 +467,21 @@ abstract class XML_Reader
$pdf->write_cell(60, 4, $customer['city']);
$pdf->write_cell(20, 4, $customer['country_code']);
$pdf->line_new(10);
/**
* note invoice
*/
if ( $info['info']['note'] != "")
{
$pdf->setFont("DejaVu", "B", 12);
$pdf->write_cell(60, 4, _("Notes"));
$pdf->line_new(10);
$pdf->setFont("DejaVu", "", 7);
$pdf->write_multi(50, 4,$info['info']['note']);
$pdf->line_new(10);
}
/**
* ITEM
*/
$pdf->setFont("DejaVu", "B", 12);
$pdf->write_cell(60, 4, _("Articles"));
$pdf->line_new(10);
@ -475,7 +493,7 @@ abstract class XML_Reader
$pdf->write_cell(25, 4, _("Quantité"), border: 'B', align: 'R');
$pdf->write_cell(25, 4, _("Montant HT"), border: 'B', align: 'R');
$pdf->line_new();
$nb_inline = count($result);
for ($i = 0; $i < $nb_inline; $i++)
{
@ -602,7 +620,7 @@ abstract class XML_Reader
if ( count($result) > 0)
{
$pdf->setFont("DejaVu", "B", 12);
$pdf->write_cell(50,4,_('Documents'));
$pdf->write_cell(60,4,_('Documents inclus'));
$pdf->line_new();
$pdf->setFont("DejaVu", "", 7);
$nb_result=count($result);

View file

@ -187,6 +187,14 @@ abstract class XMLInvoice extends \DOMDocument
$result['description']=$operation->det->jr_comment;
// note if any
$result['note']= $result['description'];
$a_note = $this->cn->get_array("select n_id,n_text from jrn_note where jr_id=$1",[$operation->det->jr_id]);
$nb_note=count($a_note);
for ($e=0;$e<$nb_note;$e++)
{
$result['note'].= str_replace('&nbsp;','',$a_note[$e]['n_text']);
}
// goods and services
$result['operation']=array();