[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpcompta-dev] r4813 - phpcompta/tags/rel601/sql
From: |
phpcompta-dev |
Subject: |
[Phpcompta-dev] r4813 - phpcompta/tags/rel601/sql |
Date: |
Tue, 24 Apr 2012 20:58:20 +0200 (CEST) |
Author: danydb
Date: 2012-04-24 20:58:20 +0200 (Tue, 24 Apr 2012)
New Revision: 4813
Added:
phpcompta/tags/rel601/sql/upgrade.sql
Log:
change SQL
Added: phpcompta/tags/rel601/sql/upgrade.sql
===================================================================
--- phpcompta/tags/rel601/sql/upgrade.sql (rev 0)
+++ phpcompta/tags/rel601/sql/upgrade.sql 2012-04-24 18:58:20 UTC (rev
4813)
@@ -0,0 +1,38 @@
+CREATE OR REPLACE FUNCTION comptaproc.check_balance(p_grpt integer)
+ RETURNS numeric AS
+$BODY$
+declare
+ amount_jrnx_debit numeric;
+ amount_jrnx_credit numeric;
+ amount_jrn numeric;
+begin
+ select coalesce(sum (j_montant),0) into amount_jrnx_credit
+ from jrnx
+ where
+ j_grpt=p_grpt
+ and j_debit=false;
+
+ select coalesce(sum (j_montant),0) into amount_jrnx_debit
+ from jrnx
+ where
+ j_grpt=p_grpt
+ and j_debit=true;
+
+ select coalesce(jr_montant,0) 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);
+ end if;
+ if ( amount_jrn != amount_jrnx_credit)
+ then
+ return -1*abs(amount_jrn - amount_jrnx_credit);
+ end if;
+ return 0;
+end;
+$BODY$
+ LANGUAGE plpgsql;
+
---
PhpCompta est un logiciel de comptabilité libre en ligne (full web)
Projet opensource http://www.phpcompta.eu
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpcompta-dev] r4813 - phpcompta/tags/rel601/sql,
phpcompta-dev <=