Merge branch '250826-e-einvoice' into unstable

* 250826-e-einvoice: (29 commits)
  Update VENDOR : remove useless
  Factur-X norme 3 (May 15th, 2025)
  E-INVOICE : if upload an XML file than the embedded document will be saved separately, if there is no embedded document a standard document with info from XML will be generated
  E-INVOICE , when loading a XML , the file is splitted into a PDF and XML
  XMLInvoiceReader : extract information from XML
  E-INVOICE : corrige PriceAmount
  E-INVOICE : show the XML to download
  Database: upload file function
  E-INVOICE : export XML if exists from ledger_detail_bottom
  E-INVOICE : create standard invoice if not convert
  E-INVOICE: small bugs UBL21
  E-INVOICE: negative amount
  e-invoice : add communication , bank and buyer reference
  e-invoice : display errors if cannot be created
  Typo : space quantity
  PHPUNIT : adapt 12.3
  E-INVOICE: check data before generating E-INVOICE: add missing for Belgium : BuyerReference and Due_Date
  E-INVOICE: add code quantity
  E-INVOICE : add AdditionalDocument
  XMLInvoice adapt currency
  ...
This commit is contained in:
sparkyx 2025-10-06 09:01:38 +02:00
commit 9898434767
169 changed files with 3614 additions and 15659 deletions

View file

@ -1,6 +1,7 @@
<?php
use PHPUnit\Framework\TestCase;
use PHPUnit\Framework\Attributes\DataProvider;
class Ac_CommonTest extends TestCase
{
@ -207,7 +208,7 @@ class Ac_CommonTest extends TestCase
/**
* provides data to testIsDate
*/
function dataIsDate()
static function dataIsDate():array
{
return array(
['01.01.1992',1],
@ -221,12 +222,13 @@ class Ac_CommonTest extends TestCase
* @testdox isDate
* @dataProvider dataIsDate
*/
function testIsDate($p_date,$expected)
#[DataProvider('dataIsDate')]
function testIsDate(string $p_date,int $expected)
{
$return=($expected==1)?$p_date:null;
$this->assertEquals(isDate($p_date),$return,"Test $p_date");
}
function dataCompareDate ()
static function dataCompareDate ():array
{
return array(
['01.01.1992','05.02.2001',-1],
@ -238,6 +240,7 @@ class Ac_CommonTest extends TestCase
* @testDox test cmpDate
* @dataProvider dataCompareDate
*/
#[DataProvider('dataCompareDate')]
function testCompareDate($p_date,$p_date_2,$p_result)
{
$cmp=cmpDate($p_date,$p_date_2);
@ -266,7 +269,7 @@ class Ac_CommonTest extends TestCase
$this->assertEquals("&lt;&amp;",h("<&"));
$this->assertEquals(0,h("0"));
}
function dataFormat_Date()
static function dataFormat_Date()
{
return array(
["01.05.2000","DD.MM.YYYY","DD.MM.YY",'01.05.00'],
@ -287,6 +290,7 @@ class Ac_CommonTest extends TestCase
* @throws Exception
* @dataProvider dataFormat_date
*/
#[DataProvider('dataFormat_date')]
function testFormatDate($p_date,$p_from,$p_to,$p_result)
{
$this->assertEquals($p_result,format_date($p_date,$p_from,$p_to));
@ -305,7 +309,7 @@ class Ac_CommonTest extends TestCase
$this->assertEquals("l''éléphant",Database::escape_string("l'éléphant"));
$this->assertEquals("l\''éléphant",Database::escape_string("l\'éléphant"));
}
function dataNoalyss_trim()
static function dataNoalyss_trim()
{
return array(["0","0"],
[" 0 1 1 1 ","0 1 1 1"],
@ -320,11 +324,12 @@ class Ac_CommonTest extends TestCase
* @return void
* @dataProvider dataNoalyss_trim
*/
#[DataProvider('dataNoalyss_trim')]
function testNoalyss_trim($param,$result)
{
$this->assertEquals($result,noalyss_trim($param));
}
function dataNoalyss_replace() {
static function dataNoalyss_replace() {
return array(["0","/","0A0A","/A/A"],
["A","*","0A0A","0*0*"],
["0","/",null,""],
@ -336,11 +341,12 @@ class Ac_CommonTest extends TestCase
* @brief Comptability PHP 8.1 , null is not consider as an empty string
* @dataProvider dataNoalyss_replace
*/
#[DataProvider('dataNoalyss_replace')]
function testNoalyss_replace($search,$replace,$string,$expected)
{
$this->assertEquals($expected,noalyss_str_replace($search,$replace,$string));
}
function dataNoalyss_bcsub() {
static function dataNoalyss_bcsub() {
return array(
[1,2,-1],
[0,2,-2],
@ -353,11 +359,12 @@ class Ac_CommonTest extends TestCase
* @brief Comptability PHP 8.1 , null is not consider as an empty string
* @dataProvider dataNoalyss_bcsub
*/
#[DataProvider('dataNoalyss_bcsub')]
function testNoalyss_bcsub($numbera,$numberb,$expected)
{
$this->assertEquals($expected,noalyss_bcsub($numbera,$numberb));
}
function dataNoalyss_strip_tags() {
static function dataNoalyss_strip_tags() {
return array(
[null,""],
["",""],
@ -370,6 +377,7 @@ class Ac_CommonTest extends TestCase
* @brief Comptability PHP 8.1 , null is not consider as an empty string
* @dataProvider dataNoalyss_strip_tags
*/
#[DataProvider('dataNoalyss_strip_tags')]
function testNoalyss_strip_tags($string,$expected)
{
$this->assertEquals($expected,noalyss_strip_tags($string));
@ -429,7 +437,7 @@ EOF;
* supply data for user password
* @return array[$password, $weakness] 0 means strong password
*/
public function dataCheck_password_strength()
public static function dataCheck_password_strength()
{
return array(
["AAAAAAA",5]
@ -446,6 +454,7 @@ EOF;
* @testDoc test the check_password_strength function
* @dataProvider dataCheck_password_strength()
*/
#[DataProvider('dataCheck_password_strength')]
public function testCheck_password_strength($p_password,$p_cnt)
{

View file

@ -123,6 +123,94 @@ class DatabaseCoreTest extends TestCase
$this->assertStringContainsString("Documentation", $p_content,"$filename invalid content");
}
/**
* @brief read / write large object
* @testDox read and write - unlink large object
*
*/
public function testWrite_Read_large_object()
{
$md5="965765540c1531370e5856ff81696107";
$file=__DIR__."/file/developpement-widget.pdf";
// step 1 : we create the large object
$binary_data= file_get_contents($file);
$this->assertEquals($md5,md5($binary_data)," error when reading $file ");
$oid = $this->object->lo_write($binary_data);
$this->assertTrue ($oid != false , "writing in DB fails");
// step 2 = read object
$retrieve = $this->object->lo_read($oid);
$this->assertEquals($md5,md5($retrieve)," error when retrieving file from db");
$target=$file."retrieve.pdf";
if ( file_exists($target) ) { unlink($target);}
file_put_contents($target, $retrieve);
$this->assertTrue(file_exists($target));
if ( file_exists($target) ) { unlink($target);}
$this->assertTrue( $this->object->lo_unlink($oid)," cannot unlink it");
}
/**
* @brief import export large objects
* @testDox import and export large object
*
*/
public function testImport_export_large_object()
{
$md5="965765540c1531370e5856ff81696107";
$file=__DIR__."/file/developpement-widget.pdf";
$this->object->start();
$oid = $this->object->lo_import($file);
$this->object->commit();
$this->assertTrue( $oid != false , "import of the file fails");
$target=$file."-tmp";
if ( file_exists($target) ) { unlink($target);}
$this->object->start();
$this->object->lo_export($oid , $file."-tmp");
$this->object->commit();
$this->assertTrue(file_exists($file."-tmp")," file not exported");
if ( file_exists($target) ) { unlink($target);}
$this->assertTrue( $this->object->lo_unlink($oid)," cannot unlink it");
}
public function testReplace() {
$string=<<<EOF
Lorem ipsum dolor sit amet consectetur adipiscing elit. Quisque faucibus ex sapien vitae pellentesque sem placerat. In id cursus mi pretium tellus duis convallis. Tempus leo eu aenean sed diam urna tempor. Pulvinar vivamus fringilla lacus nec metus bibendum egestas. Iaculis massa nisl malesuada lacinia integer nunc posuere. Ut hendrerit semper vel class aptent taciti sociosqu. Ad litora torquent per conubia nostra inceptos himenaeos.
Lorem ipsum dolor sit amet consectetur adipiscing elit. Quisque faucibus ex sapien vitae pellentesque sem placerat. In id cursus mi pretium tellus duis convallis. Tempus leo eu aenean sed diam urna tempor. Pulvinar vivamus fringilla lacus nec metus bibendum egestas. Iaculis massa nisl malesuada lacinia integer nunc posuere. Ut hendrerit semper vel class aptent taciti sociosqu. Ad litora torquent per conubia nostra inceptos himenaeos.
Lorem ipsum dolor sit amet consectetur adipiscing elit. Quisque faucibus ex sapien vitae pellentesque sem placerat. In id cursus mi pretium tellus duis convallis. Tempus leo eu aenean sed diam urna tempor. Pulvinar vivamus fringilla lacus nec metus bibendum egestas. Iaculis massa nisl malesuada lacinia integer nunc posuere. Ut hendrerit semper vel class aptent taciti sociosqu. Ad litora torquent per conubia nostra inceptos himenaeos.
Lorem ipsum dolor sit amet consectetur adipiscing elit. Quisque faucibus ex sapien vitae pellentesque sem placerat. In id cursus mi pretium tellus duis convallis. Tempus leo eu aenean sed diam urna tempor. Pulvinar vivamus fringilla lacus nec metus bibendum egestas. Iaculis massa nisl malesuada lacinia integer nunc posuere. Ut hendrerit semper vel class aptent taciti sociosqu. Ad litora torquent per conubia nostra inceptos himenaeos.
Lorem ipsum dolor sit amet consectetur adipiscing elit. Quisque faucibus ex sapien vitae pellentesque sem placerat. In id cursus mi pretium tellus duis convallis. Tempus leo eu aenean sed diam urna tempor. Pulvinar vivamus fringilla lacus nec metus bibendum egestas. Iaculis massa nisl malesuada lacinia integer nunc posuere. Ut hendrerit semper vel class aptent taciti sociosqu. Ad litora torquent per conubia nostra inceptos himenaeos.
EOF;
$md5=md5($string);
$this->object->start();
$oid=$this->object->lo_write($string);
$this->object->commit();
$this->object->start();
$stringDB = $this->object->lo_read($oid);
$this->object->commit();
$this->assertEquals(md5($string),md5($stringDB)," error string from DB corrupted");
$string = "second";
$this->object->start();
$this->object->lo_replace($string,$oid);
$this->object->commit();
$this->object->start();
$stringDB = $this->object->lo_read($oid);
var_dump($stringDB);
$this->object->commit();
$this->assertEquals(md5($string),md5($stringDB)," after lo_replace(), string from DB corrupted");
}
}