e-invoice : add communication , bank and buyer reference

This commit is contained in:
sparkyx 2025-09-20 17:08:11 +02:00
parent 244249132f
commit 817dc6f345
5 changed files with 35 additions and 18 deletions

View file

@ -296,16 +296,16 @@ class InvoiceUBL21 extends XMLInvoice {
*/
function build_paymentInfo()
{
$company = $this->load_noalyss_parameter();
$payment=$this->createElement("cac:PaymentMeans");
$payment->appendChild($this->createElement('cbc:PaymentMeansCode',30));
///@note cbc:PaymentID est la communication lors du paiement
$payment->appendChild($this->createElement('cbc:PaymentID',$this->data["id"]));
$payment->appendChild($this->createElement('cbc:PaymentID',$this->data["info"]['communication']));
$f=$this->createElement ('cac:PayeeFinancialAccount');
///@todo customer = IBAN doit être dans les paramètres (voir upgrade.sql)
$f->appendChild($this->createElement("cbc:ID", "ERROR:IBAN"));
$f->appendChild($this->createElement("cbc:ID",$company['COMPANY_BANK_IBAN']));
$g=$this->createElement("cac:FinancialInstitutionBranch");
///@todo customer = BIC doit être dans les paramètres (voir upgrade.sql)
$g->appendChild($this->createElement("cbc:ID", "ERROR:BIC"));
$g->appendChild($this->createElement("cbc:ID", $company['COMPANY_BANK_BIC']));
$f->appendChild($g);
$payment->appendChild($f);
@ -596,7 +596,7 @@ class InvoiceUBL21 extends XMLInvoice {
$root->appendChild($this->createElement('cbc:DueDate',$this->data['due_date']));
$root->appendChild($this->createElement('cbc:InvoiceTypeCode',380));
$root->appendChild($this->createElement('cbc:DocumentCurrencyCode',$this->data['currency']));
$root->appendChild($this->createElement('cbc:BuyerReference',"NOALYSS"));
$root->appendChild($this->createElement('cbc:BuyerReference',$this->data['info']['order']));
/**
* insert PDF in the XML
*/

View file

@ -59,7 +59,7 @@ namespace Noalyss\XMLDocument;
[currency] => 0
[info] => Array
[order] = order reference
[comment] = comment added to the invoice
[communication] = communication added to the invoice
[operation] => Array
(
[0] => Array
@ -218,17 +218,20 @@ abstract class XMLInvoice extends \DOMDocument
,[$jr_id]);
$nb_row = count($a_row);
$result['info']=[];
$result['info']['order']='NA';
$result['info']['communication']='';
for($i=0;$i<$nb_row;$i++) {
switch ($a_row[$i]['id_type']) {
case 'BON_COMMANDE':
$result['info']['order']=$a_row[$i]['ji_value'];
break;
case 'OTHER':
$result['info']['comment']=$a_row[$i]['ji_value'];
$result['info']['communication']=$a_row[$i]['ji_value'];
break;
}
}
$result['info']['communication']=($result['info']['communication']=="")?$result['id']:"";
return $result;
}

View file

@ -1286,7 +1286,8 @@ EOF;
return $r;
}
/*!\brief the function extra info allows to
/*!
* \brief the function extra info allows to
* - add a attachment
* - generate an invoice
* - insert extra info
@ -1294,7 +1295,7 @@ EOF;
*/
public function extra_info() {
$r = '<div id="facturation_div_id" style="height:185px;height:10rem">';
$r = '<div id="facturation_div_id" style="display:flex;height:185px;height:10rem">';
// check for upload piece
$file = new IFile();
$file->table = 0;
@ -1317,8 +1318,8 @@ EOF;
}
$r.='<br>';
$obj = new IText();
$r.=_('Numero de bon de commande : ') . $obj->input('bon_comm') . '<br>';
$r.=_('Communication ou autre information : ') . $obj->input('other_info') . '<br>';
$r.=_('Numero de bon de commande') . $obj->input('bon_comm') . '<br>';
$r.=_('Communication') . $obj->input('other_info') . '<br>';
$r.='</p>';
$r.='</div>';
return $r;

View file

@ -1917,16 +1917,14 @@ class Document
}
/**
* @brief transform the current Document to a PDF, returns the full path of the PDF from the TMP folder
* if the file IS a pdf , then export it and return the path to the file.
*
* @todo replace use of unoconv with a PHP lib to convert into PDF
* @return string full path to the PDF file
*/
function transform2pdf()
{
if (GENERATE_PDF == 'NO' ) {
\record_log(__FILE__."D1857 PDF not available");
throw new \Exception("Cannot not transform to PDF",5000);
}
// Extract from public.document
// Extract from public.document
$dirname=tempnam($_ENV['TMP'],"document");
if ( $dirname == false ) {
@ -1937,6 +1935,16 @@ class Document
if ( mkdir($dirname) == false ) {
throw new Exception("D1868.cannot create tmp directory",5000);
}
if ( $this->d_mimetype == "application/pdf") {
$destination_file=$dirname."/".$this->d_filename;
$this->export_file($destination_file);
return $dirname."/".$destination_file;
return;
}
if (GENERATE_PDF == 'NO' ) {
\record_log(__FILE__."D1857 PDF not available");
throw new \Exception("Cannot not transform to PDF",5000);
}
$destination_file=$dirname."/".$this->d_filename;
$this->export_file($destination_file);

View file

@ -158,12 +158,14 @@ if ( isset($_POST['record']) )
/* Save the attachment or generate doc */
if (isset($_FILES['pj'])) {
if (noalyss_strlentrim($_FILES['pj']['name']) != 0)
{ $cn->save_receipt($seq);
{
$cn->save_receipt($seq);
}
else
/* Generate an invoice and save it into the database */
if (isset($_POST['gen_invoice']))
{
// generate an invoice
$file = $Ledger->create_document($internal, $_POST);
$receipt= HtmlInput::show_receipt_document($Ledger->jr_id
,h($file));
@ -178,6 +180,9 @@ if ( isset($_POST['record']) )
/// 2 = create e-invoice requested
$flag_invoice=0;
/**
* @todo si Client non belge ou pas de de tva alors pas de e-facture
*/
if ($g_parameter->MY_INVOICE_FORMAT != 'BASIC' && ! empty($acc_document->d_filename ))
{
$flag_invoice=2;
@ -189,7 +194,7 @@ if ( isset($_POST['record']) )
$flag_invoice=1;
}
}
//----------------------7--------------------------
//------------------------------------------------
// flag_invoice == 2 , generate an e-invoice
//------------------------------------------------
if ( $flag_invoice == 2 )