Merge branch 'unstable' into pre-stable

* unstable:
  OTP : get options
  XML : improve invoice appearance
  XMLReader : correct VAT order
  Bug 2458: Si on envoie un email depuis Linux ,  le return-path doit être spécifié
This commit is contained in:
sparkyx 2026-04-02 11:33:21 +02:00
commit 5e94c72180
5 changed files with 69 additions and 49 deletions

View file

@ -31,7 +31,6 @@ namespace Noalyss\XMLDocument;
*/ */
abstract class XML_Reader abstract class XML_Reader
{ {
protected \DOMDocument $domDocument; protected \DOMDocument $domDocument;
protected readonly \DOMXPath $xpath; protected readonly \DOMXPath $xpath;
@ -578,12 +577,16 @@ abstract class XML_Reader
$pdf->write_cell(50, 4, _("Total Hors Taxe")); $pdf->write_cell(50, 4, _("Total Hors Taxe"));
$pdf->write_cell(50, 4, nbm($result['TaxExclusiveAmount']),align:'R'); $pdf->write_cell(50, 4, nbm($result['TaxExclusiveAmount']),align:'R');
$pdf->line_new(); $pdf->line_new();
$pdf->write_cell(50, 4, _("Total avec Taxe")); $pdf->setFont("DejaVu", "B", 7);
$pdf->write_cell(50, 4, nbm($result['TaxInclusiveAmount']),align:'R'); $pdf->write_cell(50, 4, _("Total avec Taxe"),border:1);
$pdf->write_cell(50, 4, nbm($result['TaxInclusiveAmount']),border:1,align:'R');
$pdf->line_new(); $pdf->line_new();
$pdf->write_cell(50, 4, _("Total à payer"));
$pdf->write_cell(50, 4, nbm($result['PayableAmount']),align:'R'); $pdf->setFont("DejaVu", "B", 7);
$pdf->write_cell(50, 4, _("Total à payer"),border:1);
$pdf->write_cell(50, 4, nbm($result['PayableAmount']),border:1,align:'R');
$pdf->line_new(); $pdf->line_new();
$pdf->setFont("DejaVu", "", 7);
$pdf->write_cell(50, 4, _("Total réduction")); $pdf->write_cell(50, 4, _("Total réduction"));
$pdf->write_cell(50, 4, nbm($result['AllowanceTotalAmount']),align:'R'); $pdf->write_cell(50, 4, nbm($result['AllowanceTotalAmount']),align:'R');
$pdf->line_new(); $pdf->line_new();
@ -633,20 +636,22 @@ abstract class XML_Reader
$pdf->setFont("DejaVu", "", 7); $pdf->setFont("DejaVu", "", 7);
$result = $this->get_taxes(); $result = $this->get_taxes();
$pdf->write_cell(25, 4, _("% Taxe"), align: 'R', border: 'B'); $pdf->write_cell(25, 4, _("% Taxe"), align: 'R', border: 'B');
$pdf->write_cell(30, 4, _("Code taxe"), border: 'B'); $pdf->write_cell(100, 4, _("Code taxe"), border: 'B');
$pdf->write_cell(50, 4, _("Base"), align: 'R', border: 'B'); $pdf->write_cell(30, 4, _("Base"), align: 'R', border: 'B');
$pdf->write_cell(50, 4, _("Taxe"), align: 'R', border: 'B'); $pdf->write_cell(30, 4, _("Taxe"), align: 'R', border: 'B');
$pdf->line_new(); $pdf->line_new();
$nb_inline = count($result); $nb_inline = count($result);
for ($i = 0; $i < $nb_inline; $i++) for ($i = 0; $i < $nb_inline; $i++)
{ {
$pdf->write_cell(25, 4, $result[$i]['tax_percent'], align: 'R'); $pdf->write_cell(20, 4, $result[$i]['tax_percent'], align: 'R');
$pdf->write_cell(5, 4, $result[$i]['tax_id']); $pdf->write_cell(5, 4, $result[$i]['tax_id']);
$pdf->write_multi(25, 4, $result[$i]['vatex']); $pdf->write_multi(100, 4, $result[$i]['vatex']);
$pdf->write_cell(50, 4, nbm($result[$i]['taxable_amount']), align: 'R'); $pdf->write_cell(30, 4, nbm($result[$i]['taxable_amount']),border:'R',align: 'R');
$pdf->write_cell(50, 4, nbm($result[$i]['tax']), align: 'R'); $pdf->write_cell(30, 4, nbm($result[$i]['tax']), border:'R',align: 'R');
$pdf->line_new(); $pdf->line_new();
$pdf->write_cell(185,0,'',border:'T');
$pdf->line_new();
} }
$pdf->line_new(10); $pdf->line_new(10);

View file

@ -188,28 +188,37 @@ class XMLCreditNote_Reader extends XML_Reader
{ {
$result = []; $result = [];
$node = $this->get_node("//cac:TaxTotal/cac:TaxSubtotal"); $node = $this->get_node("//cac:TaxTotal/cac:TaxSubtotal");
for ($e = 0; $e < $node->length; $e++) for ($e = 0; $e < $node->length; $e++)
{ {
$row = []; $row = [];
$xml = simplexml_import_dom($node->item($e)); $xml = simplexml_import_dom($node->item($e));
// /Invoice/cac:TaxTotal[1]/cac:TaxSubtotal[1]/cbc:TaxableAmount[1]
$this->registerNS($xml); $this->registerNS($xml);
$row ['taxable_amount'] = $xml->xpath("//cbc:TaxableAmount")[$e] . "";
$row ['tax'] = $xml->xpath("//cbc:TaxAmount")[$e] . "";
$row ['tax_id'] = $xml->xpath("//cac:TaxCategory/cbc:ID")[$e] . "";
$row ['tax_percent'] = $xml->xpath("//cac:TaxCategory/cbc:Percent")[$e] . "";
if (isset($xml->xpath("//cac:CreditNoteLine/cac:Item/cbc:Name")[$e]))
$row ['name'] =$xml->xpath("//cac:CreditNoteLine/cac:Item/cbc:Name")[$e]."";
else
$row['name']="";
if ( isset ($xml->xpath("//cbc:TaxExemptionReasonCode")[$e])) $row ['taxable_amount'] = $xml->xpath("cbc:TaxableAmount")[0] . "";
$row ['tax'] = $xml->xpath("cbc:TaxAmount")[0] . "";
$row['tax_currency']=$xml->xpath("cbc:TaxAmount")[0]->attributes()['currencyID']."";
$row ['tax_id'] = $xml->xpath("cac:TaxCategory/cbc:ID")[0]. "";
$row ['tax_percent'] =0;
$r=$xml->xpath("//cac:TaxCategory/cbc:Percent");
if ( isset($r[$e]) )
{ {
$row['vatex']=$xml->xpath("//cbc:TaxExemptionReasonCode")[$e]; $row ['tax_percent'] = $xml->xpath("cac:TaxCategory/cbc:Percent")[0] . "";
}else { }
$row ['name'] ="";
if ( $xml->xpath("cac:TaxCategory/cbc:Name") != null)
{
$row['name']=$xml->xpath("cac:TaxCategory/cbc:Name")[0].'';
}
$row['vatex']=""; $row['vatex']="";
if ( $xml->xpath("cac:TaxCategory/cbc:TaxExemptionReason") != null)
{
$row['vatex']=$xml->xpath("cac:TaxCategory/cbc:TaxExemptionReason")[0].'';
}
if ( $xml->xpath("cac:TaxCategory/cbc:TaxExemptionReason") != null)
{
$row['vatex'].=$xml->xpath("cac:TaxCategory/cbc:TaxExemptionReason")[0].'';
} }
$result[] = $row; $result[] = $row;
} }

View file

@ -153,34 +153,37 @@ class XMLInvoice_Reader extends XML_Reader
{ {
$result = []; $result = [];
$node = $this->get_node("//cac:TaxTotal/cac:TaxSubtotal"); $node = $this->get_node("//cac:TaxTotal/cac:TaxSubtotal");
for ($e = 0; $e < $node->length; $e++) for ($e = 0; $e < $node->length; $e++)
{ {
$row = []; $row = [];
$xml = simplexml_import_dom($node->item($e)); $xml = simplexml_import_dom($node->item($e));
// /Invoice/cac:TaxTotal[1]/cac:TaxSubtotal[1]/cbc:TaxableAmount[1]
$this->registerNS($xml); $this->registerNS($xml);
$row ['taxable_amount'] = $xml->xpath("//cbc:TaxableAmount")[$e] . "";
$row ['tax'] = $xml->xpath("//cbc:TaxAmount")[$e] . ""; $row ['taxable_amount'] = $xml->xpath("cbc:TaxableAmount")[0] . "";
$row ['tax_id'] = $xml->xpath("//cac:TaxCategory/cbc:ID")[$e] . ""; $row ['tax'] = $xml->xpath("cbc:TaxAmount")[0] . "";
$row['tax_currency']=$xml->xpath("cbc:TaxAmount")[0]->attributes()['currencyID']."";
$row ['tax_id'] = $xml->xpath("cac:TaxCategory/cbc:ID")[0]. "";
$row ['tax_percent'] =0; $row ['tax_percent'] =0;
$r=$xml->xpath("//cac:TaxCategory/cbc:Percent"); $r=$xml->xpath("//cac:TaxCategory/cbc:Percent");
if ( isset($r[$e]) ) if ( isset($r[$e]) )
{ {
$row ['tax_percent'] = $xml->xpath("//cac:TaxCategory/cbc:Percent")[$e] . ""; $row ['tax_percent'] = $xml->xpath("cac:TaxCategory/cbc:Percent")[0] . "";
} }
if (isset($xml->xpath("//cac:InvoiceLine/cac:Item/cbc:Name")[$e]))
{
$row ['name'] =$xml->xpath("//cac:InvoiceLine/cac:Item/cbc:Name")[$e]."";
}else {
$row ['name'] =""; $row ['name'] ="";
} if ( $xml->xpath("cac:TaxCategory/cbc:Name") != null)
if ( isset ($xml->xpath("//cbc:TaxExemptionReasonCode")[$e]))
{ {
$row['vatex']=$xml->xpath("//cbc:TaxExemptionReasonCode")[$e]; $row['name']=$xml->xpath("cac:TaxCategory/cbc:Name")[0].'';
}else { }
$row['vatex']=""; $row['vatex']="";
if ( $xml->xpath("cac:TaxCategory/cbc:TaxExemptionReason") != null)
{
$row['vatex']=$xml->xpath("cac:TaxCategory/cbc:TaxExemptionReason")[0].'';
}
if ( $xml->xpath("cac:TaxCategory/cbc:TaxExemptionReason") != null)
{
$row['vatex'].=$xml->xpath("cac:TaxCategory/cbc:TaxExemptionReason")[0].'';
} }
$result[] = $row; $result[] = $row;
} }

View file

@ -99,5 +99,5 @@ define ("DEBUGNOALYSS",0);
// your installation, example with https://demo.noalyss.eu // your installation, example with https://demo.noalyss.eu
// define ("NOALYSS_URL","https://demo.noalyss.eu"); // define ("NOALYSS_URL","https://demo.noalyss.eu");
// For POSTFIX, when sending email from NOALYSS via sendmail an extra parameter is needed // For POSTFIX, when sending email from NOALYSS via sendmail an extra parameter is needed
// for the Return-Path, the FROM will be replaced by the Sendmail_Core->from value // for the Return-Path, the [FROM] will be replaced by the Sendmail_Core->from value
//define("MAIL_EXTRA_PARAM","-f [FROM]") //define("MAIL_EXTRA_PARAM","-f [FROM]")

View file

@ -164,5 +164,8 @@ class Authenticator{
return sprintf('otpauth://%s/%s?%s', $this->mode, rawurlencode($label), $values); return sprintf('otpauth://%s/%s?%s', $this->mode, rawurlencode($label), $values);
} }
function getOptions()
{
return $this->options;
}
} }