📄 c_payment_available.sql
字号:
CREATE OR REPLACE FUNCTION C_Payment_Available
(
p_C_Payment_ID IN NUMBER
)
RETURN NUMBER
/*************************************************************************
* The contents of this file are subject to the Compiere License. You may
* obtain a copy of the License at http://www.compiere.org/license.html
* Software is on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
* express or implied. See the License for details. Code: Compiere ERP+CRM
* Copyright (C) 1999-2001 Jorg Janke, ComPiere, Inc. All Rights Reserved.
*************************************************************************
* $Id: C_Payment_Available.sql,v 1.3 2003/03/17 20:32:25 jjanke Exp $
***
* Title: Calculate Available Payment Amount in Payment Currency
* Description:
* similar to C_Invoice_Open
************************************************************************/
AS
v_Currency_ID NUMBER(10);
v_AvailableAmt NUMBER := 0;
CURSOR Cur_Alloc IS
SELECT AD_Client_ID, AD_Org_ID, Amount, C_Currency_ID, DateTrx
FROM C_Allocation
WHERE C_Payment_ID = p_C_Payment_ID
AND C_Invoice_ID IS NOT NULL;
BEGIN
-- Get Currency
SELECT C_Currency_ID, PayAmt
INTO v_Currency_ID, v_AvailableAmt
FROM C_Payment
WHERE C_Payment_ID = p_C_Payment_ID;
-- Calculate Allocated Amount
FOR a IN Cur_Alloc LOOP
v_AvailableAmt := v_AvailableAmt
- C_Currency_Convert(a.Amount, a.C_Currency_ID, v_Currency_ID, a.DateTrx, null, a.AD_Client_ID, a.AD_Org_ID);
END LOOP;
-- Ignore Rounding
IF (v_AvailableAmt BETWEEN -0.00999 AND 0.00999) THEN
v_AvailableAmt := 0;
END IF;
-- Round to penny
v_AvailableAmt := ROUND(NVL(v_AvailableAmt,0), 2);
RETURN v_AvailableAmt;
END C_Payment_Available;
/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -