Improve #0002196: Comptes Alphanumériques calculés trop longs
This commit is contained in:
parent
50180e68ad
commit
f1d3862e17
8 changed files with 95 additions and 19 deletions
|
|
@ -115,7 +115,7 @@ if (!defined("NOALYSS_PACKAGE_REPOSITORY")) {
|
|||
if (!defined("SYSINFO_DISPLAY")) {
|
||||
define("SYSINFO_DISPLAY", TRUE);
|
||||
}
|
||||
define("DBVERSION", 179);
|
||||
define("DBVERSION", 180);
|
||||
define("MONO_DATABASE", 25);
|
||||
define("DBVERSIONREPO", 20);
|
||||
define('NOTFOUND', '--not found--');
|
||||
|
|
|
|||
77
include/sql/patch/upgrade179.sql
Normal file
77
include/sql/patch/upgrade179.sql
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
begin;
|
||||
CREATE OR REPLACE FUNCTION comptaproc.account_compute_alpha(p_class text, p_name text)
|
||||
RETURNS account_type
|
||||
AS $function$
|
||||
declare
|
||||
sResult account_type;
|
||||
sAccount account_type;
|
||||
sFormatedAccount account_type;
|
||||
nCount int;
|
||||
idx int :=0;
|
||||
begin
|
||||
sFormatedAccount := comptaproc.format_account(p_name);
|
||||
|
||||
sAccount := p_class||substring(sFormatedAccount for 5);
|
||||
nCount := 0;
|
||||
loop
|
||||
select count(*) into nCount from tmp_pcmn where pcm_val = comptaproc.format_account(sAccount);
|
||||
|
||||
exit when nCount = 0;
|
||||
idx := idx + 1;
|
||||
sAccount := p_class || substring(sFormatedAccount for 5)||idx::text;
|
||||
end loop;
|
||||
sResult := comptaproc.format_account(sAccount);
|
||||
return sResult;
|
||||
end;
|
||||
$function$
|
||||
LANGUAGE plpgsql;
|
||||
|
||||
|
||||
|
||||
CREATE OR REPLACE FUNCTION comptaproc.account_compute(p_f_id integer)
|
||||
RETURNS account_type
|
||||
AS $function$
|
||||
declare
|
||||
class_base fiche_def.fd_class_base%type;
|
||||
maxcode numeric;
|
||||
sResult account_type;
|
||||
bAlphanum bool;
|
||||
sName text;
|
||||
begin
|
||||
select fd_class_base into class_base
|
||||
from
|
||||
fiche_def join fiche using (fd_id)
|
||||
where
|
||||
f_id=p_f_id;
|
||||
|
||||
bAlphanum := account_alphanum();
|
||||
if bAlphanum = false then
|
||||
select count (pcm_val) into maxcode from tmp_pcmn where pcm_val_parent = class_base;
|
||||
if maxcode = 0 then
|
||||
maxcode:=class_base::numeric;
|
||||
else
|
||||
select max (pcm_val) into maxcode from tmp_pcmn where pcm_val_parent = class_base;
|
||||
maxcode:=maxcode::numeric;
|
||||
end if;
|
||||
if maxcode::text = class_base then
|
||||
maxcode:=class_base::numeric*1000;
|
||||
end if;
|
||||
maxcode:=maxcode+1;
|
||||
|
||||
sResult:=maxcode::account_type;
|
||||
else
|
||||
-- if alphanum, use name
|
||||
select ad_value into sName from fiche_detail where f_id=p_f_id and ad_id=1;
|
||||
if sName is null then
|
||||
raise exception 'Cannot compute an accounting without the name of the card for %',p_f_id;
|
||||
end if;
|
||||
sResult := account_compute_alpha(class_base,sName);
|
||||
end if;
|
||||
return sResult;
|
||||
end;
|
||||
$function$
|
||||
LANGUAGE plpgsql
|
||||
;
|
||||
|
||||
insert into version (val,v_description) values (180,'Shorten Aphanumeric account');
|
||||
commit;
|
||||
|
|
@ -1 +0,0 @@
|
|||
|
||||
|
|
@ -851,7 +851,7 @@ class Acc_LedgerTest extends TestCase
|
|||
\Noalyss\Facility::save_file(__DIR__."/file", "acc_ledger-input_new.html", $result);
|
||||
$size=filesize(__DIR__."/file/acc_ledger-input_new.html");
|
||||
|
||||
$this->assertEquals(16325,$size," output input_new is not what it is expected");
|
||||
$this->assertEquals(15649,$size," output input_new is not what it is expected");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -180,7 +180,7 @@ class ContactTest extends TestCase
|
|||
$filename="contact-summary-1.html";
|
||||
\Noalyss\Facility::save_file($path,$filename,$r);
|
||||
print "File saved into $path/$filename";
|
||||
$this->assertEquals(4983, filesize ($path."/".$filename)," File not valide (1)");
|
||||
$this->assertEquals(4988, filesize ($path."/".$filename)," File not valide (1)");
|
||||
$this->assertEquals(5 , preg_match_all('/<tr class="/',$r)," 1. Missing card");
|
||||
$contact->filter_company(' fourni ');
|
||||
ob_start();
|
||||
|
|
@ -191,7 +191,7 @@ class ContactTest extends TestCase
|
|||
\Noalyss\Facility::save_file($path,$filename,$r);
|
||||
|
||||
print "File saved into $path/$filename";
|
||||
$this->assertEquals(3457,filesize ($path."/".$filename)," File not valide (2)");
|
||||
$this->assertEquals(3460,filesize ($path."/".$filename)," File not valide (2)");
|
||||
$this->assertEquals(3 , preg_match_all('/<tr class="/',$r), 'not found all the contacts from FOURNI');
|
||||
|
||||
|
||||
|
|
@ -202,7 +202,7 @@ class ContactTest extends TestCase
|
|||
$filename="contact-summary-3.html";
|
||||
\Noalyss\Facility::save_file($path,$filename,$r);
|
||||
print "File saved into $path/$filename";
|
||||
$this->assertEquals(2018,filesize ($path."/".$filename)," File not valide (3)");
|
||||
$this->assertEquals(2019,filesize ($path."/".$filename)," File not valide (3)");
|
||||
$this->assertEquals(1, preg_match_all('/<tr class="/',$r), 'Search does not filter');
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -629,14 +629,16 @@ where
|
|||
$fiche->setAttribut(ATTR_DEF_ACCOUNT, "");
|
||||
Card_Property::update($fiche);
|
||||
$fiche->load();
|
||||
$this->assertEquals('600CARDFORPHPUNIT',$fiche->strAttribut(ATTR_DEF_ACCOUNT),'Account not properly created');
|
||||
$this->assertEquals('600CARDF1',$fiche->strAttribut(ATTR_DEF_ACCOUNT),'Account not properly created');
|
||||
|
||||
for ( $i=600002; $i < 600999;$i++) {
|
||||
for ( $i=600002; $i < 600099;$i++) {
|
||||
$fiche->setAttribut(ATTR_DEF_NAME,'Card for testing '.$i);
|
||||
$fiche->setAttribut(ATTR_DEF_ACCOUNT, "");
|
||||
Card_Property::update($fiche);
|
||||
$fiche->load();
|
||||
$this->assertEquals("600CARDFORTESTING".$i,$fiche->strAttribut(ATTR_DEF_ACCOUNT),'Account not properly created');
|
||||
|
||||
$idx=$i-600000;
|
||||
$this->assertEquals("600CARDF".$idx,$fiche->strAttribut(ATTR_DEF_ACCOUNT),'Account not properly created');
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -655,15 +657,13 @@ where
|
|||
$fiche_def->save_class_base('600');
|
||||
$first=true;
|
||||
|
||||
for ( $i=1; $i < 1000;$i++) {
|
||||
for ( $i=1; $i < 100;$i++) {
|
||||
$fiche=new Fiche($this->g_connection);
|
||||
$fiche->insert(2,['av_text1'=>substr($i.' PHPUNIT '.__FUNCTION__,0,35)],);
|
||||
if ( $first ) {
|
||||
$first=false;
|
||||
$start=$fiche->id;
|
||||
}
|
||||
|
||||
$fiche->load();
|
||||
$this->assertEquals(substr("600".$i."PHPUNITTESTAUTOMATICACCOUNTINGIN",0,36),$fiche->strAttribut(ATTR_DEF_ACCOUNT),'Account not properly created');
|
||||
$expected="600".substr($i."PHPU",0,5);
|
||||
$this->assertEquals($expected,$fiche->strAttribut(ATTR_DEF_ACCOUNT),'Account not properly created');
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ class Follow_Up_DetailTest extends TestCase
|
|||
*/
|
||||
public static function setUpBeforeClass():void
|
||||
{
|
||||
|
||||
require DIRTEST.'/global.php';
|
||||
global $g_connection;
|
||||
$g_connection->exec_sql('delete from action_detail');
|
||||
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ fi
|
|||
|
||||
if [ ! -z "$FOLDERTEST" -a -d "$FOLDERTEST" ] ; then
|
||||
|
||||
$PHPINI $PHPUNIT --globals-backup --bootstrap bootstrap.php $COVERAGE --testdox --color $FOLDERTEST
|
||||
$PHPINI $PHPUNIT --bootstrap bootstrap.php $COVERAGE --testdox --color $FOLDERTEST
|
||||
exit $?
|
||||
fi
|
||||
|
||||
|
|
@ -65,12 +65,12 @@ fi
|
|||
|
||||
if [ ! -z "$FUNCTION" ] ; then
|
||||
echo "testing $FILETOTEST $FUNCTION"
|
||||
$PHPINI $PHPUNIT --bootstrap $CUR_DIR/bootstrap.php --globals-backup --verbose --color --filter $FUNCTION $FILETOTEST
|
||||
$PHPINI $PHPUNIT --bootstrap $CUR_DIR/bootstrap.php --verbose --color --filter $FUNCTION $FILETOTEST
|
||||
else
|
||||
|
||||
# $PHPUNIT --bootstrap bootstrap.php --whitelist $FILETOTEST --coverage-text=${FILETOTEST%.php}.txt --color $FILETOTEST
|
||||
# $PHPUNIT --bootstrap $CUR_DIR/bootstrap.php --whitelist=$CUR_DIR/../include/class --coverage-html=coverage --color $FILETOTEST
|
||||
$PHPINI $PHPUNIT --bootstrap bootstrap.php $COVERAGE $FILETOTEST --testdox --color $FILETOTEST
|
||||
#$PHPUNIT --bootstrap bootstrap.php --whitelist=../include --globals-backup --coverage-html=coverage $FILETOTEST --testdox-html ${FILETOTEST%.php}-testdox.html --color $FILETOTEST
|
||||
#$PHPUNIT --bootstrap bootstrap.php --whitelist=../include --coverage-html=coverage $FILETOTEST --testdox-html ${FILETOTEST%.php}-testdox.html --color $FILETOTEST
|
||||
fi
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue