/[phpcompta]/phpcompta/html/admin/sql/patch/upgrade7.sql
ViewVC logotype

Diff of /phpcompta/html/admin/sql/patch/upgrade7.sql

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.5 by sparkyx, Tue Oct 18 12:43:42 2005 UTC revision 1.6 by sparkyx, Sun Oct 23 18:53:21 2005 UTC
# Line 4  insert into tva_rate values (5,'0%',0, ' Line 4  insert into tva_rate values (5,'0%',0, '
4    
5  update fiche_def_ref set frd_class_base=2400 where frd_id=7;  update fiche_def_ref set frd_class_base=2400 where frd_id=7;
6    
 update  version set val=8;  
7  -- banque n'a pas de gestion stock  -- banque n'a pas de gestion stock
8  delete from jnt_fic_attr where fd_id=1 and ad_id=19;  delete from jnt_fic_attr where fd_id=1 and ad_id=19;
9  -- client n'a pas de gestion stock  -- client n'a pas de gestion stock
# Line 16  delete from jnt_fic_attr where fd_id=2 a Line 15  delete from jnt_fic_attr where fd_id=2 a
15  update jrnx set j_tech_per = jr_tech_per  from jrn  where j_grpt=jr_grpt_id and j_tech_per is null;  update jrnx set j_tech_per = jr_tech_per  from jrn  where j_grpt=jr_grpt_id and j_tech_per is null;
16  alter table jrnx alter j_tech_per set not null;  alter table jrnx alter j_tech_per set not null;
17  alter table jrn alter jr_tech_per set not null;  alter table jrn alter jr_tech_per set not null;
18    alter table jrn  alter jr_montant type numeric(8,4);
19    alter table jrnx  alter j_montant type numeric(8,4);
20  -- version 8  -- version 8
21    
22    
23    create function check_balance (p_internal text)  returns numeric as $$
24    declare
25            amount_jrnx_debit numeric;
26            amount_jrnx_credit numeric;
27            amount_jrn numeric;
28    begin
29            select sum (j_montant) into amount_jrnx_credit
30            from jrnx join jrn on (j_grpt=jr_grpt_id)
31                    where
32            jr_internal=p_internal
33            and j_debit=false;
34    
35            select sum (j_montant) into amount_jrnx_debit
36            from jrnx join jrn on (j_grpt=jr_grpt_id)
37                    where
38            jr_internal=p_internal
39            and j_debit=true;
40    
41            select jr_montant into amount_jrn
42            from jrn
43            where
44            jr_internal=p_internal;
45    
46            if ( amount_jrnx_debit != amount_jrnx_credit )
47                    then
48                    return abs(amount_jrnx_debit-amount_jrnx_credit);
49                    end if;
50            if ( amount_jrn != amount_jrnx_credit)
51                    then
52                    return -1*abs(amount_jrn - amount_jrnx_credit);
53                    end if;
54            return 0;
55    end;
56    $$ language plpgsql;
57    
58    create function proc_check_balance () returns TRIGGER as $jrn$
59    declare
60            diff numeric;
61            tt text;
62    begin
63            raise notice 'tg_op is %', TG_OP;
64            if TG_OP = 'INSERT' then
65            tt=NEW.jr_internal;
66            diff:=check_balance(tt);
67            if diff != 0 then
68                    raise exception 'Rounded error %',diff ;
69            end if;
70            return NEW;
71            end if;
72    end;
73    $jrn$ language plpgsql;
74    create trigger tr_jrn_check_balance after insert  on jrn for each row execute procedure proc_check_balance();
75    create table user_local_pref (
76            user_id text,
77            parameter_type text,
78            parameter_value text
79    );
80    comment on table user_local_pref is 'The user''s local parameter ';
81    comment on column user_local_pref.user_id is 'user''s login ';
82    comment on column user_local_pref.parameter_type is 'the type of parameter ';
83    comment on column user_local_pref.parameter_value is 'the value of parameter ';
84    
85    alter table user_local_pref add constraint pk_user_local_pref primary key (user_id,parameter_type);
86    
87    insert into user_local_pref  (user_id,parameter_type,parameter_value)
88    select pref_user,'PERIODE',pref_periode from user_pref ;
89    
90  update version set val=8;  update version set val=8;
91    
92    
93  commit;  commit;

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26