diff --git a/doc/developper/account_repository.html b/doc/developper/account_repository.html
index 1b5be6b6b..f92243626 100644
--- a/doc/developper/account_repository.html
+++ b/doc/developper/account_repository.html
@@ -111,13 +111,13 @@
-
Dumped on 2006-08-01
+
Dumped on 2006-09-05
@@ -405,7 +405,7 @@
- | $1 |
+ ac_users_use_active_check |
CHECK (((use_active = 0) OR (use_active = 1))) |
@@ -416,10 +416,6 @@
Tables referencing this one via Foreign Key Constraints:
-
-
@@ -473,20 +469,12 @@
- ac_users.use_id
-
-
-
|
use_id |
integer |
-
-
-
-
PRIMARY KEY
@@ -983,15 +971,6 @@
-
-
-Returns: void
-Language: C
-
- plpgsql_validator
-
Generated by PostgreSQL Autodoc
diff --git a/doc/developper/dossier1.dia b/doc/developper/dossier1.dia
index 850b246ae..fcb51a775 100644
--- a/doc/developper/dossier1.dia
+++ b/doc/developper/dossier1.dia
@@ -3253,7 +3253,7 @@
- #Table temporaire pour l'importation ... t CSV#
+ ##
@@ -3397,7 +3397,7 @@
# montant#
- #numeric(20,4)#
+ #text#
@@ -3530,6 +3530,29 @@
+
+
+ # status#
+
+
+ #character varying(1)#
+
+
+
+ #'n'::character varying#
+
+
+
+
+
+
+
+
+
+
+
+
+
# bq_account#
@@ -3576,29 +3599,6 @@
-
-
- # status#
-
-
- #character varying(1)#
-
-
-
- #'n'::character varying#
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -3608,7 +3608,7 @@
- #chk_status#
+ #import_tmp_status_check#
@@ -3622,7 +3622,7 @@
- #CHECK ((((((status)::text = 'n ... xt)))#
+ #CHECK ((((((status)::text = 't ... xt)))#
##
@@ -4128,6 +4128,29 @@
+
+
+ # jnt_id#
+
+
+ #bigint#
+
+
+
+ #nextval('s_jnt_id ... lass)#
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -6810,7 +6833,7 @@
- #$1#
+ #parm_periode_check#
diff --git a/doc/developper/dossier1.html b/doc/developper/dossier1.html
index d845bd106..5fbaa9373 100644
--- a/doc/developper/dossier1.html
+++ b/doc/developper/dossier1.html
@@ -111,13 +111,13 @@
-
Dumped on 2006-08-01
+
Dumped on 2006-09-05
- public
- action
- action_gestion
- attr_def
- attr_min
- attr_value
- centralized
- document
- document_modele
- document_state
- document_type
- fiche
- fiche_def
- fiche_def_ref
- form
- format_csv_banque
- formdef
- import_tmp
- invoice
- jnt_fic_att_value
- jnt_fic_attr
- jrn
- jrn_action
- jrn_def
- jrn_rapt
- jrn_type
- jrnx
- parameter
- parm_code
- parm_money
- parm_periode
- quant_sold
- stock_goods
- tmp_pcmn
- tva_rate
- user_local_pref
- user_sec_act
- user_sec_jrn
- version
- vw_client
- vw_fiche_attr
- vw_fiche_def
- vw_fiche_min
- vw_poste_qcode
- vw_supplier
- - account_add( p_id public.poste_comptable, p_name character varying )
- account_auto( p_fd_id integer )
- account_compute( p_f_id integer )
- account_insert( p_f_id integer, p_account public.poste_comptable )
- account_parent( p_account public.poste_comptable )
- account_update( p_f_id integer, p_account public.poste_comptable )
- attribut_insert( p_f_id integer, p_ad_id integer, p_value character varying )
- card_class_base( p_f_id integer )
- check_balance( p_grpt integer )
- fiche_account_parent( p_f_id integer )
- insert_jrnx( p_date character varying, p_montant numeric, p_poste integer, p_grpt integer, p_jrn_def integer, p_debit boolean, p_tech_user text, p_tech_per integer, p_qcode text )
- insert_quant_sold( p_internal text, p_fiche character varying, p_quant integer, p_price numeric, p_vat numeric, p_vat_code integer, p_client character varying )
- insert_quick_code( nf_id integer, tav_text text )
- plpgsql_validator( oid )
- proc_check_balance( )
- t_document_type_insert( )
- t_jrn_def_sequence( )
- trim_cvs_quote( )
- trim_space_format_csv_banque( )
- tva_delete( integer )
- tva_insert( integer, text, numeric, text, text )
- tva_modify( integer, text, numeric, text, text )
- update_quick_code( njft_id integer, tav_text text )
+ - account_add( p_id public.poste_comptable, p_name character varying )
- account_auto( p_fd_id integer )
- account_compute( p_f_id integer )
- account_insert( p_f_id integer, p_account public.poste_comptable )
- account_parent( p_account public.poste_comptable )
- account_update( p_f_id integer, p_account public.poste_comptable )
- attribut_insert( p_f_id integer, p_ad_id integer, p_value character varying )
- card_class_base( p_f_id integer )
- check_balance( p_grpt integer )
- correct_sequence( p_sequence text, p_col text, p_table text )
- fiche_account_parent( p_f_id integer )
- insert_jrnx( p_date character varying, p_montant numeric, p_poste integer, p_grpt integer, p_jrn_def integer, p_debit boolean, p_tech_user text, p_tech_per integer, p_qcode text )
- insert_quant_sold( p_internal text, p_fiche character varying, p_quant integer, p_price numeric, p_vat numeric, p_vat_code integer, p_client character varying )
- insert_quick_code( nf_id integer, tav_text text )
- proc_check_balance( )
- t_document_type_insert( )
- t_jrn_def_sequence( )
- trim_cvs_quote( )
- trim_space_format_csv_banque( )
- tva_delete( integer )
- tva_insert( integer, text, numeric, text, text )
- tva_modify( integer, text, numeric, text, text )
- update_quick_code( njft_id integer, tav_text text )
@@ -2105,8 +2105,6 @@
import_tmp
- Table temporaire pour l'importation des banques en format CSV
-
@@ -2127,7 +2125,7 @@
|
- NOT NULL
+
@@ -2143,7 +2141,7 @@
|
- NOT NULL
+
@@ -2159,7 +2157,7 @@
|
- NOT NULL
+
@@ -2171,11 +2169,11 @@
|
montant |
- numeric(20,4) |
+ text |
- NOT NULL
+
@@ -2266,13 +2264,13 @@
|
|
- bq_account |
- integer |
+ status |
+ character varying(1) |
NOT NULL
-
+ DEFAULT 'n'::character varying
|
@@ -2282,7 +2280,7 @@
|
- jrn |
+ bq_account |
integer |
@@ -2298,15 +2296,15 @@
|
|
- status |
- character varying(1) |
+ jrn |
+ integer |
+ NOT NULL
- DEFAULT 'n'::character varying
-
Status doit être w pour en attente, t pour transfèrer ou d à effacer
+
|
@@ -2327,8 +2325,8 @@
- | chk_status |
- CHECK ((((((status)::text = 'n'::text) OR ((status)::text = 'w'::text)) OR ((status)::text = 'd'::text)) OR ((status)::text = 't'::text))) |
+ import_tmp_status_check |
+ CHECK ((((((status)::text = 't'::text) OR ((status)::text = 'd'::text)) OR ((status)::text = 'w'::text)) OR ((status)::text = 'n'::text))) |
@@ -2622,6 +2620,29 @@
+
+
+ |
+
+
+
+ |
+
+
+
+ |
+ jnt_id |
+ bigint |
+
+
+ PRIMARY KEY
+
+
+
+
+
+
+ DEFAULT nextval('s_jnt_id'::regclass)
|
@@ -4247,19 +4268,11 @@
|
-
-
|
p_start |
date |
-
-
-
- UNIQUE
-
-
NOT NULL
@@ -4349,7 +4362,7 @@
|
- | $1 |
+ parm_periode_check |
CHECK ((p_end >= p_start)) |
@@ -7285,7 +7298,6 @@ end ;
declare
l_auto bool;
begin
-
select fd_create_account into l_auto from fiche_def where fd_id=p_fd_id;
if l_auto is null then
l_auto:=false;
@@ -7306,19 +7318,19 @@ declare
class_base poste_comptable;
maxcode int8;
begin
- -- Get the class base
select fd_class_base into class_base
from
fiche_def join fiche using (fd_id)
where
f_id=p_f_id;
- raise notice 'class base %',class_base;
- select max(pcm_val) into maxcode from tmp_pcmn where pcm_val = class_base;
+ raise notice 'account_compute class base %',class_base;
+ select max(pcm_val) into maxcode from tmp_pcmn where pcm_val_parent = class_base;
if maxcode = class_base then
- maxcode=class_base*1000+1;
+ maxcode:=class_base*1000;
end if;
- raise notice 'Max code %',maxcode;
-return maxcode+1;
+ maxcode:=maxcode+1;
+ raise notice 'account_compute Max code %',maxcode;
+ return maxcode;
end;
@@ -7339,51 +7351,40 @@ nFd_id integer;
nCount integer;
begin
- -- if p_value empty
if length(trim(p_account)) != 0 then
- -- does the account exist ?
+ raise notice 'p_account is not empty';
select * into nCount from tmp_pcmn where pcm_val=p_account;
if nCount !=0 then
- -- retrieve name
+ raise notice 'this account exists in tmp_pcmn ';
select av_text into sName from
attr_value join jnt_fic_att_value using (jft_id)
where
ad_id=1 and f_id=p_f_id;
- -- get parent
nParent:=account_parent(p_account);
- -- account doesn't exist we need to add id
insert into tmp_pcmn(pcm_val,pcm_lib,pcm_val_parent)
values (p_account,sName,nParent);
- -- insert as card's attribute
perform attribut_insert(p_f_id,5,to_char(nNew,'999999999999'));
end if;
else
+ raise notice 'p_account is empty';
select fd_id into nFd_id from fiche where f_id=p_f_id;
bAuto:= account_auto(nFd_id);
-
if bAuto = true then
- -- create automatically the account
- -- compute the next account
+ raise notice 'account generated automatically';
nNew:=account_compute(p_f_id);
-raise debug 'nNew %', nNew;
- -- retrieve name
+ raise notice 'nNew %', nNew;
select av_text into sName from
attr_value join jnt_fic_att_value using (jft_id)
where
ad_id=1 and f_id=p_f_id;
-
- -- get parent
nParent:=account_parent(nNew);
- -- account doesn't exist we need to add id
perform account_add (nNew,sName);
- -- insert as card's attribute
perform attribut_insert(p_f_id,5,to_char(nNew,'999999999999'));
else
perform attribut_insert(p_f_id,5,null);
end if;
-
end if;
return 0;
@@ -7418,9 +7419,8 @@ begin
if length(sParent) <= 0 then
raise exception 'Impossible de trouver le compte parent pour %',p_account;
end if;
-
end loop;
-
+ raise notice 'account_parent : Parent is %',nParent;
return nParent;
end;
@@ -7441,25 +7441,18 @@ sName varchar;
nJft_id attr_value.jft_id%type;
begin
- -- if p_value empty
if length(trim(p_account)) != 0 then
- -- does the account exist ?
select count(*) into nCount from tmp_pcmn where pcm_val=p_account;
if nCount = 0 then
- -- retrieve name
select av_text into sName from
attr_value join jnt_fic_att_value using (jft_id)
where
ad_id=1 and f_id=p_f_id;
- -- get parent
nParent:=fiche_account_parent(p_f_id);
- -- account doesn't exist we need to add id
insert into tmp_pcmn(pcm_val,pcm_lib,pcm_val_parent) values (p_account,sName,nParent);
end if;
end if;
- -- we retrieve jft_id
select jft_id into njft_id from jnt_fic_att_value where f_id=p_f_id and ad_id=5;
- -- we update the account
update attr_value set av_text=p_account where jft_id=njft_id;
return njft_id;
@@ -7492,18 +7485,18 @@ end;
Language: PLPGSQL
-
declare
n_poste fiche_def.fd_class_base%type;
begin
- select fd_class_base into n_poste from fiche_def join fiche using (fd_id)
+ select fd_class_base into n_poste from fiche_def join fiche using
+(fd_id)
where f_id=p_f_id;
if not FOUND then
raise exception 'Invalid fiche card_class_base(%)',p_f_id;
end if;
return n_poste;
-end;
+end;
@@ -7524,18 +7517,15 @@ begin
where
j_grpt=p_grpt
and j_debit=false;
-
select sum (j_montant) into amount_jrnx_debit
from jrnx
where
j_grpt=p_grpt
and j_debit=true;
-
select jr_montant into amount_jrn
from jrn
where
jr_grpt_id=p_grpt;
-
if ( amount_jrnx_debit != amount_jrnx_credit )
then
return abs(amount_jrnx_debit-amount_jrnx_credit);
@@ -7545,6 +7535,43 @@ begin
return -1*abs(amount_jrn - amount_jrnx_credit);
end if;
return 0;
+end;
+
+
+
+
+Returns: integer
+Language: PLPGSQL
+ Often the primary key is a sequence number and sometimes the value of the sequence is not synchronized with the primary key ( p_sequence : sequence name, p_col : col of the pk,p_table : concerned table
+
+declare
+last_sequence int8;
+max_sequence int8;
+n integer;
+begin
+ select count(*) into n from pg_class where relkind='S' and relname=lower(p_sequence);
+ if n = 0 then
+ raise exception ' Unknow sequence % ',p_sequence;
+ end if;
+ select count(*) into n from pg_class where relkind='r' and relname=lower(p_table);
+ if n = 0 then
+ raise exception ' Unknow table % ',p_table;
+ end if;
+
+ execute 'select last_value from '||p_sequence into last_sequence;
+ raise notice 'Last value of the sequence is %', last_sequence;
+
+ execute 'select max('||p_col||') from '||p_table into max_sequence;
+ if max_sequence is null then
+ max_sequence := 0;
+ end if;
+ raise notice 'Max value of the sequence is %', max_sequence;
+ max_sequence:= max_sequence +1;
+ execute 'alter sequence '||p_sequence||' restart with '||max_sequence;
+return 0;
+
end;
@@ -7580,14 +7607,9 @@ declare
nCount_qcode integer;
begin
sCode=trim(p_qcode);
-
- -- if p_qcode is empty try to find one
if length(sCode) = 0 or p_qcode is null then
-
select count(*) into nCount_qcode
from vw_poste_qcode where j_poste=p_poste;
- -- if we find only one q_code for a accountancy account
- -- then retrieve it
if nCount_qcode = 1 then
select j_qcode into sCode
from vw_poste_qcode where j_poste=p_poste;
@@ -7622,7 +7644,6 @@ begin
p_tech_per,
sCode
);
-
return;
end;
@@ -7640,10 +7661,10 @@ declare
fid_good integer;
begin
select f_id into fid_client from
- attr_value join jnt_fic_att_value using (jft_id) where ad_id=23 and av_text=p_client;
+ attr_value join jnt_fic_att_value using (jft_id) where ad_id=23 and av_text=upper(p_client);
select f_id into fid_good from
- attr_value join jnt_fic_att_value using (jft_id) where ad_id=23 and av_text=p_fiche;
+ attr_value join jnt_fic_att_value using (jft_id) where ad_id=23 and av_text=upper(p_fiche);
insert into quant_sold
@@ -7652,7 +7673,7 @@ begin
(p_internal,fid_good,p_quant,p_price,p_vat,p_vat_code,fid_client);
return;
end;
-
+
Function:
@@ -7671,39 +7692,25 @@ end;
tText := replace(tText,' ','');
loop
- -- take the next sequence
select nextval('s_jnt_fic_att_value') into ns;
if length (tText) = 0 or tText is null then
tText := 'FID'||ns;
end if;
- -- av_text already used ?
select count(*) into nExist
from jnt_fic_att_value join attr_value using (jft_id)
where
ad_id=23 and av_text=upper(tText);
-
if nExist = 0 then
exit;
end if;
tText:='FID'||ns;
end loop;
- -- insert into table jnt_fic_att_value
insert into jnt_fic_att_value values (ns,nf_id,23);
- -- insert value into attr_value
insert into attr_value values (ns,upper(tText));
return ns;
end;
-
-
-Returns: void
-Language: C
-
- plpgsql_validator
-
Function:
proc_check_balance( )
@@ -7797,7 +7804,6 @@ begin
if ( length(modified.include_file) = 0 ) then
modified.include_file=null;
end if;
-
return modified;
end;
@@ -7885,7 +7891,6 @@ begin
if length(trim(p_tva_label)) = 0 then
return 3;
end if;
-
if length(trim(p_tva_poste)) != 0 then
if position (',' in p_tva_poste) = 0 then return 4; end if;
debit = split_part(p_tva_poste,',',1);
@@ -7936,7 +7941,7 @@ end;
select count(*) into nExist
from jnt_fic_att_value join attr_value using (jft_id)
where
- ad_id=23 and av_text=upper(tText);
+ ad_id=23 and av_text=tText;
if nExist = 0 then
exit;
@@ -7949,6 +7954,15 @@ end;
end loop;
update attr_value set av_text = tText where jft_id=njft_id;
+
+ -- update also the contact
+ update attr_value set av_text = tText
+ where jft_id in
+ ( select jft_id
+ from jnt_fic_att_value join attr_value using (jft_id)
+ where ad_id=25 and av_text=old_qcode);
+
+
update jrnx set j_qcode=tText where j_qcode = old_qcode;
return ns;
end;
diff --git a/html/admin/sql/patch/upgrade20.sql b/html/admin/sql/patch/upgrade20.sql
index 822d33320..f72291183 100644
--- a/html/admin/sql/patch/upgrade20.sql
+++ b/html/admin/sql/patch/upgrade20.sql
@@ -99,5 +99,24 @@ CREATE or replace FUNCTION update_quick_code(njft_id integer, tav_text text) RET
end;
$body$
LANGUAGE plpgsql;
+alter table parm_periode alter p_end set not null;
+
+create or replace function drop_it (p_constraint varchar)
+returns void as
+$body$
+declare
+-- drop a constraint if it exists
+ nCount integer;
+begin
+ select count(*) into nCount from pg_constraint where conname=p_constraint;
+ if nCount = 1 then
+ execute 'alter table parm_periode drop constraint '||p_constraint ;
+ end if;
+end;
+$body$ language plpgsql;
+
+select drop_it('parm_periode_p_start_key');
+create unique index x_periode on parm_periode (p_start,p_end);
+
update version set val=21;
commit;
diff --git a/html/form.php b/html/form.php
index bfc8a612f..b95ea7522 100644
--- a/html/form.php
+++ b/html/form.php
@@ -53,9 +53,9 @@ if ( $User->CheckAction($cn,FORM)==0){
}
echo ShowMenuAdvanced("form.php");
if ( isset ($_POST["record"] )) {
- echo '';
+ // echo '
';
AddForm($cn,$HTTP_POST_VARS);
- echo "
";
+ //echo "
";
}
if ( isset ($_POST["del_form"]) ) {
echo '';
diff --git a/html/line_update.php b/html/line_update.php
index c959b626c..1a3cbc61f 100644
--- a/html/line_update.php
+++ b/html/line_update.php
@@ -56,6 +56,19 @@ if ( isset ($_POST["update"] ) ) {
$p_lib=FormatString($_POST["p_name"]);
$p_parent=trim($_POST["p_val_parent"]);
$old_line=trim($_POST["p_old"]);
+ // Check if p_parent and p_val are number
+ if ( ! is_numeric($p_val) || ! is_numeric($p_parent) ) {
+ // not number no update
+ echo '';
+ echo "";
+ exit();
+
+ }
echo_debug('line_update.php',__LINE__,"Update old : $old_line News = $p_val $p_lib");
if ( strlen ($p_val) != 0 && strlen ($p_lib) != 0 && strlen($old_line)!=0 ) {
if (strlen ($p_val) == 1 ) {
diff --git a/include/ac_common.php b/include/ac_common.php
index 58d7aa2c2..464764921 100644
--- a/include/ac_common.php
+++ b/include/ac_common.php
@@ -102,10 +102,15 @@ function isDate ( $p_date) {
return null;
} else {
$l_date=explode(".",$p_date);
+
+ if ( sizeof ($p_date) != 3 )
+ return null;
+
if ( $l_date[2] > 2020 ) {
return null;
}
echo_debug('ac_common.php',__LINE__,' date = '.var_export($l_date,true));
+
if ( checkdate ($l_date[1],$l_date[0],$l_date[2]) == false) {
return null;
}
diff --git a/include/balance.php b/include/balance.php
index 48ca444ce..0932de817 100644
--- a/include/balance.php
+++ b/include/balance.php
@@ -115,6 +115,13 @@ if ( isset($_POST['view'] ) ) {
echo "
période du ".$a['p_start']." au ".$b['p_end']."
";
echo '
';
+ echo '| Poste Comptable | ';
+ echo 'Libellé | ';
+ echo 'Débit | ';
+ echo 'Crédit | ';
+ echo 'Solde Débiteur | ';
+ echo 'Solde Créditeur | ';
+
$i=0;
foreach ($row as $r) {
$i++;