View Issue Details

IDProjectCategoryView StatusLast Update
0000668Noalyss - PLUGINGeneralpublic2012-07-02 09:56
Reporterroland Assigned Todanydb  
PriorityélevéeSeveritymajeurReproducibilitytoujours
Status ferméResolutioncorrigé 
PlatformLinuxOSDebian et Ubuntu 
Summary0000668: Problème de fonctionnement de l'extension TVA
DescriptionDes scripts SQL s'affichent et l’extension ne fonctionne plus.
TagsNo tags attached.
Attached Files
erreur_module.txt (5,183 bytes)   
begin; 
create table tva_belge.version ( 
id serial primary key, 
vdate timestamp default now(), 
vdesc text 
); 

CREATE TABLE tva_belge.parameter_chld 
( 
pi_id bigserial NOT NULL, -- PK 
pcode text, -- FK to parameter 
tva_id bigint, -- FK to public.tva_rate 
pcm_val account_type, -- FK to tmp_pcmn 
CONSTRAINT parameter_chld_pkey PRIMARY KEY (pi_id ), 
CONSTRAINT parameter_chld_tva_id_fkey FOREIGN KEY (tva_id) 
REFERENCES tva_rate (tva_id) MATCH SIMPLE 
ON UPDATE CASCADE ON DELETE CASCADE 
); 

COMMENT ON TABLE tva_belge.parameter_chld IS 'Child table for parameters (TVA Plugin)'; 
COMMENT ON COLUMN tva_belge.parameter_chld.pi_id IS 'PK'; 
COMMENT ON COLUMN tva_belge.parameter_chld.pcode IS 'FK to parameter'; 
COMMENT ON COLUMN tva_belge.parameter_chld.tva_id IS 'FK to public.tva_rate'; 
COMMENT ON COLUMN tva_belge.parameter_chld.pcm_val IS 'FK to tmp_pcmn'; 


CREATE OR REPLACE FUNCTION tva_belge.fill_parameter_chld() 
found a function RETURNS void AS 
$BODY$ 

declare 
a_account text[]; 
a_tva_id text[]; 
i record; 
e record; 
f record; 
n_size_tva int; 
n_size_account int; 

begin 

for i in select pcode,pvalue,paccount from tva_belge.parameter 
loop 
if length(trim(i.pvalue)) = 0 or length(trim(i.paccount)) = 0 then 
continue; 
end if; 

a_account := string_to_array(i.paccount, ','); 
a_tva_id := string_to_array(i.pvalue,','); 

n_size_tva := array_upper(a_tva_id,1); 
n_size_account := array_upper(a_account,1); 


while n_size_tva <> 0 loop 

while n_size_account <> 0 loop 

insert into tva_belge.parameter_chld (pcode,tva_id,pcm_val) 
values (i.pcode,a_tva_id[n_size_tva]::numeric,a_account[n_size_account]::account_type); 

n_size_account := n_size_account -1; 
end loop; 
n_size_account := array_upper(a_account,1); 
n_size_tva := n_size_tva -1; 
end loop; 

end loop; 

return; 

end; 

$BODY$ 
LANGUAGE plpgsql; 

CREATE OR REPLACE FUNCTION tva_belge.fill_parameter_chld_assujetti() 
found a function RETURNS void AS 
$BODY$ 

declare 
a_account text[]; 
a_tva_id text[]; 
i record; 
e record; 
f record; 
n_size_tva int; 
n_size_account int; 

begin 

for i in select distinct pvalue from tva_belge.parameter WHERE pcode in ('GRIL00','GRIL01','GRIL02','GRIL03') 
loop 
if length(trim(i.pvalue)) = 0 then 
continue; 
end if; 

a_tva_id := string_to_array(i.pvalue,','); 

n_size_tva := array_upper(a_tva_id,1); 


while n_size_tva <> 0 loop 

insert into tva_belge.parameter_chld (pcode,tva_id) 
values ('ASSUJETTI',a_tva_id[n_size_tva]::numeric); 
n_size_tva := n_size_tva -1; 
end loop; 

end loop; 

return; 

end; 

$BODY$ 
LANGUAGE plpgsql; 

select tva_belge.fill_parameter_chld(); 
select tva_belge.fill_parameter_chld_assujetti(); 
select tva_belge.fill_parameter_chld_assujetti() SQL ERROR select tva_belge.fill_parameter_chld_assujetti() ERREUR: une instruction insert ou update sur la table « parameter_chld » viole la contrainte de clé étrangère « parameter_chld_tva_id_fkey » D?TAIL : La clé (tva_id)=(6) n'est pas présente dans la table « tva_rate ». CONTEXTE : instruction SQL « insert into tva_belge.parameter_chld (pcode,tva_id) values ('ASSUJETTI', $1 [ $2 ]::numeric) » PL/pgSQL function "fill_parameter_chld_assujetti" line 26 at instruction SQLArray#0 /var/www/phpcompta/include/class_database.php(303): Database->exec_sql('select tva_belg...') #1 /var/www/phpcompta/include/ext/tva/index.php(97): Database->execute_script('/var/www/phpcom...') #2 /var/www/phpcompta/include/extension_get.inc.php(38): require_once('/var/www/phpcom...') #3 /var/www/phpcompta/include/ac_common.php(944): require('/var/www/phpcom...') #4 /var/www/phpcompta/html/do.php(140): show_menu(Array, 1) #5 {main}ERREUR: une instruction insert ou update sur la table « parameter_chld » viole la contrainte de clé étrangère « parameter_chld_tva_id_fkey » D?TAIL : La clé (tva_id)=(6) n'est pas présente dans la table « tva_rate ». CONTEXTE : instruction SQL « insert into tva_belge.parameter_chld (pcode,tva_id) values ('ASSUJETTI', $1 [ $2 ]::numeric) » PL/pgSQL function "fill_parameter_chld_assujetti" line 26 at instruction SQL
Fatal error: Uncaught exception 'Exception' with message ' SQL ERROR select tva_belge.fill_parameter_chld_assujetti() ERREUR: une instruction insert ou update sur la table « parameter_chld » viole la contrainte de clé étrangère « parameter_chld_tva_id_fkey » D?TAIL : La clé (tva_id)=(6) n'est pas présente dans la table « tva_rate ». CONTEXTE : instruction SQL « insert into tva_belge.parameter_chld (pcode,tva_id) values ('ASSUJETTI', $1 [ $2 ]::numeric) » PL/pgSQL function "fill_parameter_chld_assujetti" line 26 at instruction SQL' in /var/www/phpcompta/include/class_database.php:151 Stack trace: #0 /var/www/phpcompta/include/class_database.php(303): Database->exec_sql('select tva_belg...') #1 /var/www/phpcompta/include/ext/tva/index.php(97): Database->execute_script('/var/www/phpcom...') #2 /var/www/phpcompta/include/extension_get.inc.php(38): require_once('/var/www/phpcom...') #3 /var/www/phpcompta/include/ac_common.php(944): require('/var/www/phpcom...') #4 /var/www/phpcompta/html/do.php(140): show_menu( in /var/www/phpcompta/include/class_database.php on line 151
erreur_module.txt (5,183 bytes)   
Extension Noalyss

Activities

danydb

2012-07-02 09:55

administrator   ~0001321

Le problème venait d'un code TVA inexistant, cela se produisait lors d'un upgrade. Changement du script SQL, vérification si le code TVA existe

Issue History

Date Modified Username Field Change
2012-07-01 22:41 roland New Issue
2012-07-02 09:54 danydb File Added: erreur_module.txt
2012-07-02 09:55 danydb Project NOALYSS => Noalyss - PLUGIN
2012-07-02 09:55 danydb Category Impact Plugin => General
2012-07-02 09:55 danydb Note Added: 0001321
2012-07-02 09:55 danydb Status new => resolved
2012-07-02 09:55 danydb Resolution open => fixed
2012-07-02 09:55 danydb Assigned To => danydb
2012-07-02 09:56 danydb Status resolved => closed