diff --git a/html/admin/setup.php b/html/admin/setup.php
index 17d06caa4..d108226cd 100644
--- a/html/admin/setup.php
+++ b/html/admin/setup.php
@@ -500,6 +500,10 @@ if ( DEBUG=='false' ) ob_start();
ExecuteScript($db,'sql/patch/upgrade25.sql');
} // version
+ if ( GetVersion($db) == 26 ) {
+ ExecuteScript($db,'sql/patch/upgrade26.sql');
+ } // version
+
if ( DEBUG == 'false') ob_end_clean();
}//for
@@ -612,6 +616,10 @@ if (DEBUG == 'false' ) ob_start();
ExecuteScript($db,'sql/patch/upgrade25.sql');
} // version
+ if ( GetVersion($db) == 26 ) {
+ ExecuteScript($db,'sql/patch/upgrade26.sql');
+ } // version
+
if ( DEBUG == 'false') ob_end_clean();
}
diff --git a/html/admin/sql/patch/upgrade26.sql b/html/admin/sql/patch/upgrade26.sql
new file mode 100644
index 000000000..171fd8096
--- /dev/null
+++ b/html/admin/sql/patch/upgrade26.sql
@@ -0,0 +1,31 @@
+begin;
+CREATE or replace FUNCTION account_compute(p_f_id integer) RETURNS poste_comptable
+ AS $$
+declare
+ class_base poste_comptable;
+ maxcode poste_comptable;
+begin
+ select fd_class_base into class_base
+ from
+ fiche_def join fiche using (fd_id)
+ where
+ f_id=p_f_id;
+ raise notice 'account_compute class base %',class_base;
+ select count (pcm_val) into maxcode from tmp_pcmn where pcm_val_parent = class_base;
+ if maxcode = 0 then
+ maxcode:=class_base;
+ else
+ select max (pcm_val) into maxcode from tmp_pcmn where pcm_val_parent = class_base;
+ end if;
+ if maxcode = class_base then
+ maxcode:=class_base*1000;
+ end if;
+ maxcode:=maxcode+1;
+ raise notice 'account_compute Max code %',maxcode;
+ return maxcode;
+end;
+$$
+ LANGUAGE plpgsql;
+
+update version set val=27;
+commit;