pgsql/investigations/ar-cash.sql
authorEdward <edward@roojs.com>
Wed, 5 Feb 2014 07:00:04 +0000 (15:00 +0800)
committerEdward <edward@roojs.com>
Wed, 5 Feb 2014 07:00:04 +0000 (15:00 +0800)
pgsql/investigations/ar-cash.sql

index 11e52e8..1ffafc0 100644 (file)
@@ -95,7 +95,7 @@ BEGIN
     SELECT
             gltrans_id,
             gltrans_amount,
-            ROUND( _ar.arapply_applied / _citem.cashrcpt_curr_rate, 3 ) - ROUND(gltrans_amount, 3)
+            ROUND( _citem.cashrcptitem_amount / _citem.cashrcpt_curr_rate, 3 ) - ROUND(gltrans_amount, 3)
     INTO
             v_gl_id,
             v_gltrans_amount,
@@ -130,9 +130,9 @@ BEGIN
     -- if currency rate is off...
     IF v_diff != 0.00  THEN
     
-        v_new_rate := _ar.arapply_applied / v_gltrans_amount;
+        v_new_rate := _citem.cashrcptitem_amount / v_gltrans_amount;
         
-        RAISE NOTICE 'arapply_id  % change currency rate from % to %, applied % gl amount %', i_arapply_id, _citem.cashrcpt_curr_rate  ,v_new_rate,_ar.arapply_applied,v_gltrans_amount ;
+        RAISE NOTICE 'arapply_id  % change currency rate from % to %, applied % gl amount %', i_arapply_id, _citem.cashrcpt_curr_rate  ,v_new_rate,_citem.cashrcptitem_amount,v_gltrans_amount ;
     
 --         UPDATE 
 --                 aropen