E-INVOICE : create standard invoice if not convert

This commit is contained in:
sparkyx 2025-09-29 18:13:12 +02:00
parent 8a3c718186
commit 497a544433
8 changed files with 634 additions and 100 deletions

View file

@ -202,6 +202,7 @@ class Acc_Document extends Document {
/**
* @brief export the file to the file system and complet $this->d_mimetype, d_filename and
* @param $destination_file (string) full path to document
* @return bool false for failure and string (the full path_name) for success
*/
function export_file($destination_file) {

View file

@ -29,9 +29,86 @@ require_once NOALYSS_INCLUDE.'/lib/ac_common.php';
/*!
* \class Acc_Ledger_Purchase
* \brief Handle the ledger of purchase,
*
*
** @brief : input, confirm and save new operations in edger of purchase
the $_POST data is an array with these keys
@code
Array
(
// =====================
// ANALYTIC PART
// =====================
[pa_id] => Array
(
[0] => 1
)
[op] => Array
(
[0] => 0
)
[amount_t0] => 10
[hplan] => Array
(
[0] => Array
(
[0] => -1
)
)
[val] => Array
(
[0] => Array
(
[0] => 10
)
)
// =====================
// SALES DATA
// =====================
[e_client] => QuickCode supplier
[nb_item] => number of items (lines of invoice)
[p_jrn] => JRN_DEF.JRN_DEF_ID id of the ledger
[jrn_note_input] => Note JRN_NOTE.N_TEXT
[mt] => 1759130008.8134
[p_currency_rate] => Currency Rate
[p_currency_code] => Currency Code
[e_comm] => Description of invoice
[e_date] => date invoice
[e_ech] => limit date
[e_pj] => Receipt number
[e_pj_suggest] => suggested receipt number
[e_mp] => payment means (
[jrn_type] => Type of ledger (always ACH)
//---------------------------------------------
// For each invoice line
//---------------------------------------------
[e_march0] => QuickCode of the item
[e_march0_label] => label
[e_march0_price] => unit price
[e_march0_tva_id] => VAT ID
[e_march0_tva_amount] => amount of VAT
[e_quant0] => quantity of item
//========================
// MISC
//========================
[repo] => 1 (repository)
[gen_invoice] => on (it is asked to generate an invoice
[gen_doc] => Document template id
[bon_comm] => JRN_INFO.
[other_info] = JRN_INFO.>
[opd_name] => Name of operation template
[od_description] => Description of operation template
[reverse_date] => if reverse is asked
[ext_label] => Label for revese operation
[jr_optype] => Type of operation NOR:Normal,, EXT; reverse, ..
)
@endcode
*/
class Acc_Ledger_Purchase extends Acc_Ledger
{

View file

@ -28,9 +28,87 @@ require_once NOALYSS_INCLUDE.'/lib/user_common.php';
require_once NOALYSS_INCLUDE.'/lib/ac_common.php';
/*!
* \brief Handle the ledger of sold,
*
* @exception throw an exception is something is wrong
* @class Acc_Ledger_Sale
* @brief : input, confirm and save new operations in edger of sales
the $_POST data is an array with these keys
@code
Array
(
// =====================
// ANALYTIC PART
// =====================
[pa_id] => Array
(
[0] => 1
)
[op] => Array
(
[0] => 0
)
[amount_t0] => 10
[hplan] => Array
(
[0] => Array
(
[0] => -1
)
)
[val] => Array
(
[0] => Array
(
[0] => 10
)
)
// =====================
// SALES DATA
// =====================
[e_client] => QuickCode customer
[nb_item] => number of items (lines of invoice)
[p_jrn] => JRN_DEF.JRN_DEF_ID id of the ledger
[jrn_note_input] => Note JRN_NOTE.N_TEXT
[mt] => 1759130008.8134
[p_currency_rate] => Currency Rate
[p_currency_code] => Currency Code
[e_comm] => Description of invoice
[e_date] => date invoice
[e_ech] => limit date
[e_pj] => Receipt number
[e_pj_suggest] => suggested receipt number
[e_mp] => payment means (
[jrn_type] => Type of ledger (always VEN)
//---------------------------------------------
// For each invoice line
//---------------------------------------------
[e_march0] => QuickCode of the item
[e_march0_label] => label
[e_march0_price] => unit price
[e_march0_tva_id] => VAT ID
[e_march0_tva_amount] => amount of VAT
[e_quant0] => quantity of item
//========================
// MISC
//========================
[repo] => 1 (repository)
[gen_invoice] => on (it is asked to generate an invoice
[gen_doc] => Document template id
[bon_comm] => JRN_INFO.
[other_info] = JRN_INFO.>
[opd_name] => Name of operation template
[od_description] => Description of operation template
[reverse_date] => if reverse is asked
[ext_label] => Label for revese operation
[jr_optype] => Type of operation NOR:Normal,, EXT; reverse, ..
)
@endcode
*/
class Acc_Ledger_Sale extends Acc_Ledger {
@ -1302,21 +1380,25 @@ EOF;
$file->table = 0;
$file->setAlertOnSize(true);
$r.='<p class="decale">';
// add a receipt
$r.=_("Ajoutez une pièce justificative ");
$r.=$file->input("pj", "");
if ($this->db->count_sql("select md_id,md_name from document_modele where md_affect='VEN' ") > 0) {
$r.=_('ou générer une facture') . ' <input type="checkbox" name="gen_invoice" CHECKED>';
// We propose to generate the invoice and some template
$doc_gen = new ISelect();
$doc_gen->name = "gen_doc";
$doc_gen->value = $this->db->make_array(
"select md_id,md_name " .
" from document_modele where md_affect='VEN' order by 2");
$r.=$doc_gen->input() . '<br>';
}
//------------------------------------------------
// Propose to generate an invoice
//------------------------------------------------
$r.=_('ou générer une facture') . ' <input type="checkbox" name="gen_invoice" CHECKED>';
// We propose to generate the invoice and some template
$doc_gen = new ISelect();
$doc_gen->name = "gen_doc";
$doc_gen->value = $this->db->make_array(
"select md_id,md_name " .
" from document_modele where md_affect='VEN' ".
" union select -2,'"._("0 - Facture PDF Standard")."' ".
" order by 2");
$r.=$doc_gen->input() . '<br>';
$r.='<br>';
$obj = new IText();
$r.=_('Numero de bon de commande') . $obj->input('bon_comm') . '<br>';

View file

@ -109,16 +109,20 @@ class Document
/*!
* \brief Generate the document, Call $this-\>replace to replace
* tag by value
* @param p_array contains the data normally it is the $_POST
* @param $p_filename contains the new filename
* @param p_array contains the data normally it is the $_POST (see Acc_Ledger_Sale or
* Acc_Ledger_Purchase)
* @see Acc_Ledger_Sale
* @see Acc_Ledger_Purchase
* @param $p_filename contains the new filename, if not given the filename will be generated
* \return an string : the url where the generated doc can be found, the name
* of the file and his mimetype
*/
function generate($p_array, $p_filename="")
{
try {
// create a temp directory in /tmp to unpack file and to parse it
///@var $dirname (string) temp directory in /tmp to unpack file and to parse it
$dirname=tempnam($_ENV['TMP'], 'doc_');
if ($dirname == false) {
throw new Exception ('DC117 cannot create tmp file',5000);
@ -128,6 +132,31 @@ class Document
if ( mkdir($dirname) == false ) {
throw new Exception ("DC121 cannot create $dirname directory",5000);
}
/**
* md_id == -2 is the standard PDF invoice, you don't parse or compute
* it
*/
if ( $this->md_id == -2)
{
$file_to_parse=str_replace(
array('/', '*', '<', '>', ';', ',', '\\', '.', ':', '(', ')', ' ', '[', ']')
, "-"
, "inv-std-".$p_array['e_pj'].".pdf");
$this->d_number=$this->db->get_next_seq("seq_doc_type_stdinv");
$this->d_filename=$file_to_parse;
$this->d_mimetype="application/pdf";
$this->d_name=$file_to_parse;
$standard_invoice=new \Noalyss\Invoice_PDF($this->db,$dirname,$file_to_parse);
$standard_invoice->set_data($p_array);
$standard_invoice->export();
$this->saveGenerated($dirname.DIRECTORY_SEPARATOR.$file_to_parse);
// Invoice
$href=http_build_query(array('gDossier'=>Dossier::id(), "d_id"=>$this->d_id, 'act'=>'RAW:document'));
$ret='<A class="mtitle" HREF="export.php?'.$href.'">'._('Document').'</A>';
return $ret;
}
// Retrieve the lob and save it into $dirname
$this->db->start();
$dm_info="select md_name,md_type,md_lob,md_filename,md_mimetype
@ -149,7 +178,8 @@ class Document
record_log(sprintf('DOCUMENT.GENERATE.D1 , export failed %s %s',$dirname, $filename));
throw new Exception(sprintf(_("Export a échoué pour %s"), $filename));
}
// $type (letter) type of document : OOo for openoffice otherwise n , with OOo the file
// is a ZIP XML
$type="n";
// if the doc is a OOo, we need to unzip it first
// and the name of the file to change is always content.xml
@ -336,10 +366,9 @@ class Document
}
/*!
* \brief Save the generated Document
* \brief insert the generated Document into the database, update the $this->d_id
* that is the PK of document. and load the PDF into the database.
* \param $p_file is the generated file
*
*
* \return 0 if no error otherwise 1
*/

View file

@ -0,0 +1,332 @@
<?php
namespace Noalyss;
/*
* This file is part of NOALYSS.
*
* NOALYSS is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* NOALYSS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with NOALYSS; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// Copyright Author Dany De Bontridder danydb@aevalys.eu 22/10/23
/**
* @file
* @brief create a standard invoice
*/
/**
* @class Invoice PDF
* @brief create a standard invoice
*/
class Invoice_PDF extends \PDF
{
private $data; //!< $data (array) see Acc_Ledger_Purchases
function __construct(
\Database $cn
, private $dirname //!< folder where to save file
, private $filename //!< filename to use
)
{
parent::__construct($cn);
}
public function get_dirname()
{
return $this->dirname;
}
public function get_filename()
{
return $this->filename;
}
public function set_dirname($dirname)
{
$this->dirname = $dirname;
return $this;
}
public function set_filename($filename)
{
$this->filename = $filename;
return $this;
}
function set_data($array)
{
$this->data = $array;
return $this;
}
function get_data()
{
return $this->data;
}
function footer()
{
//Position at 1 cm from bottom
$this->SetY(-10);
//Arial italic 8
$this->SetFont('Arial', '', 8);
//Page number
parent::Cell(0, 8, " Page " . $this->PageNo() . '/{nb}', 0, 0, 'C');
parent::Ln(3);
}
function header()
{
global $g_parameter;
$this->setY(15);
$this->SetFont('DejaVu', '', 6);
$colsize = 90;
$this->write_multi($colsize, 3, $g_parameter->MY_NAME);
$this->write_multi($colsize, 3, $this->data['e_date'], border: '', align: 'R');
$this->line_new();
$this->write_multi($colsize, 3,
sprintf("%s %s "
, $g_parameter->MY_STREET
, $g_parameter->MY_NUMBER));
$this->line_new();
$this->write_multi($colsize, 3, $g_parameter->MY_POSTCODE
. " " . $g_parameter->MY_CITY
. " " . $g_parameter->MY_COUNTRY
);
$this->line_new();
$this->write_multi($colsize, 3, $g_parameter->MY_TVA);
$this->line_new();
$email_company = $this->cn->get_value("select pe_value from parameter_extra where pe_code=$1",
['INVOICE_EMAIL_COMPANY']);
$site = $this->cn->get_value("select pe_value from parameter_extra where pe_code=$1",
['WEB_COMPANY']);
// for FRANCE , the SIREN and SIRET must be given
$siren = $this->cn->get_value("select pe_value from parameter_extra where pe_code=$1",
['SIREN']);
$siret = $this->cn->get_value("select pe_value from parameter_extra where pe_code=$1",
['SIRET']);
$iban = $this->cn->get_value("select pe_value from parameter_extra where pe_code=$1",
['COMPANY_BANK_IBAN']);
$bic = $this->cn->get_value("select pe_value from parameter_extra where pe_code=$1",
['COMPANY_BANK_BIC']);
if ($siret != "")
{
$this->write_multi($colsize, 3, "SIRET $siret");
$this->line_new();
}
if ($siren != "")
{
$this->write_multi($colsize, 3, "SIREN $siren");
$this->line_new();
}
if ($iban != "")
{
$this->write_multi($colsize, 3, "IBAN $iban BIC $bic");
$this->line_new();
}
if ($g_parameter->MY_PHONE != "")
{
$this->write_multi($colsize, 3, sprintf(_("Tel %s "),
$g_parameter->MY_PHONE
));
$this->line_new();
}
if ($email_company != "")
{
$this->write_multi($colsize, 3, sprintf(_("email %s "),
$email_company));
$this->line_new();
}
if ($site != "")
{
$this->write_multi($colsize, 3, sprintf(_("site %s"),
$site
));
$this->line_new();
}
$this->setFont("DejaVu", 'B', 14);
$this->write_multi(40, 10, "");
$this->write_multi(100, 10, _("Facture") . " " . $this->data['e_pj'], border: 1, align: 'C');
$this->write_multi(40, 10, "");
$this->line_new(10);
$this->ln(5);
}
//!
//@brief make the invoice
function export()
{
$this->SetAuthor('NOALYSS');
$this->AliasNbPages();
$this->AddPage();
$this->SetAutoPageBreak(true, $this->bMargin*1);
$this->setTitle($this->filename, true);
// $customer (Fiche) retrieve card of the customer
$customer = new \Fiche($this->cn);
$customer->get_by_qcode(trim($this->data['e_client']));
$this->setFont("DejaVu", '', 7);
$this->write_cell(50, 4, "");
$this->write_cell(60, 4, sprintf(_("Echéance %s"), $this->data['e_ech']));
$this->line_new();
$this->write_cell(50, 4, "");
$this->write_cell(100, 4, _("Client"), 'B', 'R');
$this->line_new();
$this->write_cell(50, 4, "");
$this->write_cell(110, 4, $customer->get_attribute(ATTR_DEF_NAME)
. " " . $customer->get_attribute(ATTR_DEF_FIRST_NAME, 0));
$this->line_new();
$this->write_cell(50, 4, "");
$this->write_cell(110, 4, $customer->get_attribute(ATTR_DEF_ADRESS, 0));
$this->line_new();
$this->write_cell(50, 4, "");
$this->write_cell(110, 4, $customer->get_attribute(ATTR_DEF_POSTCODE, 0)
. " " . $customer->get_attribute(ATTR_DEF_CITY, 0)
);
$this->line_new();
$this->write_cell(50, 4, "");
$this->write_cell(110, 4, $customer->get_attribute(ATTR_DEF_COUNTRY, 0));
$this->line_new();
$this->write_cell(50, 4, "");
$this->write_cell(110, 4, $customer->get_attribute(ATTR_DEF_NUMTVA, 0));
$this->line_new();
$a_tva_amount = [];
$a_tva_code = [];
$col = array(
"quick_code" => 30,
"label" => 80,
"quantity" => 25,
"price" => 25,
"vat_code" => 20
);
$this->SetFont("DejaVu", "B", 12);
$this->write_multi(50, 20, "");
$this->write_multi(50, 20, _("Détails"));
$this->line_new();
$this->SetFont("DejaVuCond", "", 7);
$currency = new \Acc_Currency($this->cn, $this->data['p_currency_code']);
$this->write_multi(60, 4, sprintf(_("Les montants sont en %s taux %s")
, $currency->get_code()
, $this->data['p_currency_rate']));
$this->line_new(4);
if ($this->data["bon_comm"] != "")
{
$this->write_multi(120, 4, sprintf(_("Bon de commande / référence %s")
, $this->data["bon_comm"]));
$this->line_new(4);
}
$this->line_new(4);
$this->SetFont("DejaVu", "", 7);
$this->write_multi($col['quick_code'], 4, _("Article"), 1);
$this->write_multi($col['label'], 4, _("Description"), 1);
$this->write_multi($col['quantity'], 4, _("Quantité"), 1);
$this->write_multi($col['price'], 4, _("Prix"), 1);
$this->write_multi($col['vat_code'], 4, _("TVA"), 1);
$this->line_new();
///@var $tot_amount (float) total amount without VAT
///@var $tot_vat (float) total VAT
///@var $line (int) line printed
$tot_amount = $tot_vat = $line =0;
for ($i = 0; $i < $this->data['nb_item']; $i++)
{
$item = new \Fiche($this->cn);
if (!isset($this->data['e_march' . $i]) || $this->data['e_march' . $i] == "")
{
continue;
}
$line++;
$item->get_by_qcode(trim($this->data['e_march' . $i]));
$fill = $this->is_fill($line);
$this->write_multi($col['quick_code'], 4, $item->get_attribute(ATTR_DEF_QUICKCODE),'','',$fill);
$this->write_multi($col['label'], 4, $this->data['e_march' . $i . '_label'],fill:$fill);
$this->write_multi($col['quantity'], 4, nbm($this->data['e_quant' . $i]), '', 'R',fill:$fill);
$this->write_multi($col['price'], 4, nbm($this->data['e_march' . $i . '_price']), '', 'R',fill:$fill);
$this->write_multi($col['vat_code'], 4, $this->data['e_march' . $i . '_tva_id'], '', 'C',fill:$fill);
$x = $this->data['e_march' . $i . '_tva_id'];
if (!isset($a_tva_amount[$x]))
{
$a_tva_amount[$x] = 0;
}
$a_tva_amount[$x] = bcadd($a_tva_amount[$x], $this->data["e_march" . $i . "_tva_amount"], 2);
$tot_amount = bcadd($tot_amount
, bcmul($this->data['e_march' . $i . '_price']
, $this->data['e_quant' . $i]
, 2
)
, 2);
$tot_vat = bcadd($tot_vat
, $this->data['e_march' . $i . '_tva_amount']
, 2);
$this->line_new(4);
if ($this->GetY()>250) {
$this->AddPage();
}
}
$this->line_new(10);
$this->SetFont("DejaVu", "B", 9);
$this->write_multi(30, 4, _("TVA"));
$this->line_new(5);
$this->SetFont("DejaVu", "", 7);
foreach ($a_tva_amount as $tva_id => $tva_amount)
{
$tva = \Acc_Tva::build($this->cn, $tva_id);
$this->write_multi(20, 4, "");
$this->write_multi(80, 4, $tva->tva_id
. " / " . $tva->tva_code
. " / " . $tva->tva_label
. " / " . $tva->tva_rate * 100
);
$this->write_multi(50, 4, $tva_amount);
$this->line_new();
}
$this->ln(20);
$this->SetFont("DejaVu", "B", 9);
$this->write_multi(30, 4, _("TOTAUX"));
$this->line_new();
$this->SetFont("DejaVu", "", 7);
$this->write_multi(60, 4, _("Total Hors TVA "));
$this->write_multi(60, 4, nbm($tot_amount), '', 'R');
$this->line_new();
$this->write_multi(60, 4, _("Total TVA "));
$this->write_multi(60, 4, nbm($tot_vat), '', 'R');
$this->line_new();
$this->write_multi(60, 4, _("Total "));
$this->write_multi(60, 4, nbm(bcadd($tot_amount, $tot_vat, 2),2), '', 'R');
$this->line_new();
$iban = $this->cn->get_value("select pe_value from parameter_extra where pe_code=$1",
['COMPANY_BANK_IBAN']);
if ($this->data['e_ech'] != "" && $iban != "")
{
$info = ($this->data["other_info"] == "") ? $this->data["e_pj"] : $this->data["other_info"];
$bic = $this->cn->get_value("select pe_value from parameter_extra where pe_code=$1",
['COMPANY_BANK_IBAN']);
$this->write_multi(150, 4,
sprintf(_("Paiement avant le %s sur le compte %s (BIC %s) avec comme message %s"),
$this->data['e_ech']
, $iban
, $bic
, $this->data["other_info"]
)
);
$this->line_new();
}
$this->Output($this->dirname . DIRECTORY_SEPARATOR . $this->filename, "F");
}
}

View file

@ -79,10 +79,10 @@ if ( isset ($_POST['view_invoice'] ) )
echo '<form class="print" enctype="multipart/form-data" method="post">';
echo dossier::hidden();
echo $Ledger->confirm($_POST );
//----------------------------------------------------------------------------
// Check that INVOICE can be generated
// for e-invoice only
//----------------------------------------------------------------------------
//----------------------------------------------------
// Check that INVOICE can be generated
// for e-invoice only
//----------------------------------------------------
if ($g_parameter->MY_INVOICE_FORMAT != 'BASIC')
{
$xmldocument= \Noalyss\XMLDocument\XMLInvoice::build_xmlinvoice($cn);
@ -152,84 +152,92 @@ if ( isset($_POST['record']) )
// is no invoice
$receipt='';
//-------------------------------------------------------
// Generate a XLM invoice
// if a document has been created create the XML file
//-------------------------------------------------------
///@var $flag_invoice (int) error for invoice generating.
/// 0 = nothing no invoice created
/// 1 = cannot create e-invoice
/// 2 = create e-invoice requested
$flag_invoice=0;
/* Save the attachment or generate doc */
if (isset($_FILES['pj'])) {
if (noalyss_strlentrim($_FILES['pj']['name']) != 0)
{
$cn->save_receipt($seq);
}
else
if (isset($_FILES['pj']) && noalyss_strlentrim($_FILES['pj']['name']) != 0)
{
$cn->save_receipt($seq);
}
else
/* Generate an invoice and save it into the database */
if (isset($_POST['gen_invoice']))
if (isset($_POST['gen_invoice']))
{
//@var $invoice_template (int) get the invoice number DOCUMENT_MODELE.MD_ID
$invoice_template=$http->post("gen_doc","number");
// generate an invoice
$file = $Ledger->create_document($internal, $_POST);
$receipt= HtmlInput::show_receipt_document($Ledger->jr_id
,h($file));
$acc_document=new Acc_Document($cn,$Ledger->jr_id);
/**
* @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 ))
{
// generate an invoice
$file = $Ledger->create_document($internal, $_POST);
$receipt= HtmlInput::show_receipt_document($Ledger->jr_id
,h($file));
$acc_document=new Acc_Document($cn,$Ledger->jr_id);
//-------------------------------------------------------
// Generate a XLM invoice
// if a document has been created create the XML file
//-------------------------------------------------------
///@var $flag_invoice (int) error for invoice generating.
/// 0 = nothing
/// 1 = cannot create e-invoice
/// 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;
$xmldocument= \Noalyss\XMLDocument\XMLInvoice::build_xmlinvoice($cn);
$xmldocument->build_data($Ledger->jr_id);
$code_error = $xmldocument->verify() ;
// check that all the sub arrays are empty
if ( ! empty( array_filter($code_error,function($a){ if (!empty($a)) return true; })))
{
$flag_invoice=2;
$xmldocument= \Noalyss\XMLDocument\XMLInvoice::build_xmlinvoice($cn);
$xmldocument->build_data($Ledger->jr_id);
$code_error = $xmldocument->verify() ;
// check that all the sub arrays are empty
if ( ! empty( array_filter($code_error,function($a){ if (!empty($a)) return true; })))
{
$xmldocument->display_error();
$flag_invoice=1;
}
$xmldocument->display_error();
$flag_invoice=1;
}
//------------------------------------------------
// flag_invoice == 2 , generate an e-invoice
//------------------------------------------------
if ( $flag_invoice == 2 )
{
}
//------------------------------------------------
// flag_invoice == 2 , generate an e-invoice
//------------------------------------------------
if ( $flag_invoice == 2 )
{
$pdf_filename=$acc_document->d_filename;
if ( $acc_document->d_mimetype != 'application/pdf')
{
$pdf_filename=$acc_document->transform2pdf();
// save PDF In db
$acc_document->update($pdf_filename);
// make the PDF
$xmldocument->set_pdf_filename($pdf_filename);
// make the XML + PDF
$xml=$xmldocument->make_xml($Ledger->jr_id);
if (DEBUGNOALYSS > 1) {
$mt=date ('ymd-Hi').'+'.$Ledger->jr_id;
$uniq= $_ENV['TMP']. DIRECTORY_SEPARATOR."$mt-e-invoice.xml";
file_put_contents($uniq, $xml);
chmod ($uniq,774);
echo \Noalyss\Dbg::echo_file("file save $uniq");
}
// save XML string into the DB
$oid=$cn->lo_write($xml);
echo \Noalyss\Dbg::echo_var(1, "oid is $oid");
if ($oid == false) {
throw new Exception ('CV177 : cannot import e-invoice');
}
$acc_document->update_document_xml($oid);
$receipt= HtmlInput::show_receipt_document($Ledger->jr_id,$acc_document->d_filename);
}else{
$pdf_filename=$_ENV['TMP']."/".$pdf_filename;
$acc_document->export_file($pdf_filename);
}
// make the PDF
$xmldocument->set_pdf_filename($pdf_filename);
// make the XML + PDF
$xml=$xmldocument->make_xml($Ledger->jr_id);
if (DEBUGNOALYSS > 1) {
$mt=date ('ymd-Hi').'+'.$Ledger->jr_id;
$uniq= $_ENV['TMP']. DIRECTORY_SEPARATOR."$mt-e-invoice.xml";
file_put_contents($uniq, $xml);
chmod ($uniq,774);
echo \Noalyss\Dbg::echo_file("file save $uniq");
}
// save XML string into the DB
$oid=$cn->lo_write($xml);
echo \Noalyss\Dbg::echo_var(1, "oid is $oid");
if ($oid == false) {
throw new Exception ('CV177 : cannot import e-invoice');
}
$acc_document->update_document_xml($oid);
$receipt= HtmlInput::show_receipt_document($Ledger->jr_id,$acc_document->d_filename);
}
}
}
catch (\Exception $e) {

View file

@ -224,8 +224,8 @@ define("ATTR_DEF_BQ_NO", 3);
define("ATTR_DEF_BQ_NAME", 4);
define("ATTR_DEF_PRIX_ACHAT", 7);
define("ATTR_DEF_PRIX_VENTE", 6);
define("ATTR_DEF_TVA", 2);
define("ATTR_DEF_NUMTVA", 13);
define("ATTR_DEF_TVA", 2); // usable VAT for goods and services
define("ATTR_DEF_NUMTVA", 13); // number of VAT
define("ATTR_DEF_ADRESS", 14);
define("ATTR_DEF_POSTCODE", 15);
define("ATTR_DEF_COUNTRY", 16);
@ -431,7 +431,8 @@ function noalyss_class_autoloader($class)
'noalyss\xmldocument\xmlinvoice'=>'XMLDocument/XMLInvoice.php',
'noalyss\xmldocument\facturx'=>'XMLDocument/FacturX.php',
'noalyss\xmldocument\invoiceubl21'=>'XMLDocument/InvoiceUBL21.php',
'noalyss\xmldocument\error_message'=>'XMLDocument/Error_Message.php'
'noalyss\xmldocument\error_message'=>'XMLDocument/Error_Message.php',
"noalyss\invoice_pdf"=>"class/invoice_pdf.class.php"
);
if (isset ($aClass[$class])) {
require_once NOALYSS_INCLUDE . "/" . $aClass[$class];

View file

@ -295,4 +295,8 @@ insert into "parameter" values ('MY_INVOICE_FORMAT','BASIC');
alter table jrn add jr_document_xml oid;
comment on column jrn.jr_document_xml is 'OID of the XML files (e-invoice)';
comment on column jrn.jr_document_xml is 'OID of the XML files (e-invoice)';
create sequence seq_doc_type_stdinv;
comment on sequence seq_doc_type_stdinv is 'Sequence for standard invoice';