[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
SF.net SVN: ledger-smb:[4298] branches/1.3/sql/modules/Payment.sql
- Subject: SF.net SVN: ledger-smb:[4298] branches/1.3/sql/modules/Payment.sql
- From: ..hidden..
- Date: Thu, 09 Feb 2012 13:17:35 +0000
Revision: 4298
http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=4298&view=rev
Author: einhverfr
Date: 2012-02-09 13:17:35 +0000 (Thu, 09 Feb 2012)
Log Message:
-----------
Corrected default currency handling in bulk payment and payment reversal workflows
Modified Paths:
--------------
branches/1.3/sql/modules/Payment.sql
Modified: branches/1.3/sql/modules/Payment.sql
===================================================================
--- branches/1.3/sql/modules/Payment.sql 2012-02-09 11:03:52 UTC (rev 4297)
+++ branches/1.3/sql/modules/Payment.sql 2012-02-09 13:17:35 UTC (rev 4298)
@@ -483,7 +483,7 @@
from defaults
where setting_key = 'curr';
- IF (in_currency IS NULL OR in_currency = t_currs[0]) THEN
+ IF (in_currency IS NULL OR in_currency = t_currs[1]) THEN
t_exchangerate := 1;
ELSIF t_exchangerate IS NULL THEN
t_exchangerate := in_exchangerate;
@@ -520,7 +520,7 @@
t_cash_sign := -1;
END IF;
- IF (in_currency IS NULL OR in_currency = t_currs[0]) THEN
+ IF (in_currency IS NULL OR in_currency = t_currs[1]) THEN
UPDATE bulk_payments_in
SET fxrate = 1;
ELSE
@@ -1095,8 +1095,9 @@
from defaults
where setting_key = 'curr';
- IF in_currency IS NULL OR in_currency = t_currs[0] THEN
+ IF in_currency IS NULL OR in_currency = t_currs[1] THEN
t_rev_fx := 1;
+ t_paid_fx := 1;
ELSIF t_rev_fx IS NULL THEN
t_rev_fx := in_exchangerate;
PERFORM payments_set_exchangerate(in_account_class,
@@ -1118,27 +1119,31 @@
FOR pay_row IN
SELECT a.*, c.ar_ap_account_id, arap.curr, arap.fxrate
FROM acc_trans a
- JOIN (select id, curr, entity_credit_account, buy as fxrate
+ JOIN (select id, curr, entity_credit_account,
+ CASE WHEN curr = t_currs[1] THEN 1
+ ELSE buy END as fxrate
FROM ar
- JOIN exchangerate USING (transdate, curr)
+ LEFT JOIN exchangerate USING (transdate, curr)
WHERE in_account_class = 2
UNION
- SELECT id, curr, entity_credit_account, sell as fxrate
+ SELECT id, curr, entity_credit_account,
+ CASE WHEN curr = t_currs[1] THEN 1
+ ELSE sell END as fxrate
FROM ap
- JOIN exchangerate USING (transdate, curr)
+ LEFT JOIN exchangerate USING (transdate, curr)
WHERE in_account_class = 1
) arap ON (a.trans_id = arap.id)
JOIN entity_credit_account c
ON (arap.entity_credit_account = c.id)
- JOIN chart ch ON (a.chart_id = ch.id)
- WHERE coalesce(source, '') = coalesce(in_source, '')
- AND transdate = in_date_paid
- AND in_credit_id = c.id
+ JOIN account ch ON (a.chart_id = ch.id)
+ WHERE a.source IS NOT DISTINCT FROM in_source
+ AND a.transdate = in_date_paid
+ AND in_credit_id = arap.entity_credit_account
AND in_cash_accno = ch.accno
- and in_voucher_id IS DISTINCT FROM voucher_id
+ and in_voucher_id IS NOT DISTINCT FROM voucher_id
LOOP
- IF pay_row.curr = t_currs[0] THEN
- pay_row.fxrage = 1;
+ IF pay_row.curr = t_currs[1] THEN
+ pay_row.fxrate = 1;
END IF;
IF in_batch_id IS NOT NULL
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.