IDEMPIERE-4083 currency rate by document or by transaction (#182)
Integrating a contribution from TrekGlobal developed by Heng Sin
This commit is contained in:
parent
e79ef31cd5
commit
0fa717cf0a
|
@ -0,0 +1,36 @@
|
||||||
|
CREATE OR REPLACE FUNCTION currencyConvertInvoice(
|
||||||
|
p_c_invoice_id in number,
|
||||||
|
p_currency_to_id in number,
|
||||||
|
p_amt in number DEFAULT NULL,
|
||||||
|
p_conversiondate in date DEFAULT NULL)
|
||||||
|
RETURNS number
|
||||||
|
AS
|
||||||
|
v_GrandTotal NUMBER;
|
||||||
|
v_ConversionType_ID NUMBER;
|
||||||
|
v_Client_ID NUMBER;
|
||||||
|
v_Org_ID NUMBER;
|
||||||
|
v_Currency_ID NUMBER;
|
||||||
|
v_CurrencyRate NUMBER;
|
||||||
|
v_DateAcct DATE;
|
||||||
|
v_BaseCurrency_ID NUMBER;
|
||||||
|
v_IsOverrideCurrencyRate CHAR(1);
|
||||||
|
BEGIN
|
||||||
|
SELECT AD_Client_ID, AD_Org_ID, DateAcct, C_Currency_ID, C_ConversionType_ID, CurrencyRate, GrandTotal, IsOverrideCurrencyRate
|
||||||
|
INTO v_Client_ID, v_Org_ID, v_DateAcct, v_Currency_ID, v_ConversionType_ID, v_CurrencyRate, v_GrandTotal, v_IsOverrideCurrencyRate
|
||||||
|
FROM C_Invoice
|
||||||
|
WHERE C_Invoice_ID=p_C_Invoice_ID;
|
||||||
|
|
||||||
|
SELECT sc.C_Currency_ID
|
||||||
|
INTO v_BaseCurrency_ID
|
||||||
|
FROM AD_ClientInfo ci
|
||||||
|
JOIN C_AcctSchema sc ON ci.C_AcctSchema1_ID=sc.C_AcctSchema_ID
|
||||||
|
WHERE ci.AD_Client_ID=v_Client_ID;
|
||||||
|
|
||||||
|
IF v_BaseCurrency_ID=p_Currency_To_id AND Coalesce(v_CurrencyRate,0) > 0 AND v_Currency_ID != p_Currency_To_id AND v_IsOverrideCurrencyRate='Y' THEN
|
||||||
|
RETURN currencyRound(Coalesce(p_Amt,v_GrandTotal)*v_CurrencyRate, p_Currency_To_id, null);
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
RETURN currencyConvert(Coalesce(p_Amt,v_GrandTotal), v_Currency_ID, p_Currency_To_id, Coalesce(p_conversionDate,v_DateAcct), v_ConversionType_ID, v_Client_ID, v_Org_ID);
|
||||||
|
END currencyConvertInvoice;
|
||||||
|
/
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
CREATE OR REPLACE FUNCTION currencyConvertPayment
|
||||||
|
(
|
||||||
|
p_C_Payment_ID IN NUMBER,
|
||||||
|
p_CurTo_ID IN NUMBER,
|
||||||
|
p_Amt IN NUMBER DEFAULT NULL,
|
||||||
|
p_conversionDate IN DATE DEFAULT NULL
|
||||||
|
)
|
||||||
|
RETURN NUMBER
|
||||||
|
AS
|
||||||
|
v_Rate NUMBER;
|
||||||
|
v_PayAmt NUMBER;
|
||||||
|
v_ConversionType_ID NUMBER;
|
||||||
|
v_Client_ID NUMBER;
|
||||||
|
v_Org_ID NUMBER;
|
||||||
|
v_Currency_ID NUMBER;
|
||||||
|
v_CurrencyRate NUMBER;
|
||||||
|
v_ConvertedAmt NUMBER;
|
||||||
|
v_DateAcct DATE;
|
||||||
|
v_BaseCurrency_ID NUMBER;
|
||||||
|
v_IsOverrideCurrencyRate Char(1);
|
||||||
|
BEGIN
|
||||||
|
SELECT AD_Client_ID, AD_Org_ID, DateAcct, C_Currency_ID, C_ConversionType_ID, CurrencyRate, ConvertedAmt, PayAmt, IsOverrideCurrencyRate
|
||||||
|
INTO v_Client_ID, v_Org_ID, v_DateAcct, v_Currency_ID, v_ConversionType_ID, v_CurrencyRate, v_ConvertedAmt, v_PayAmt, v_IsOverrideCurrencyRate
|
||||||
|
FROM C_Payment
|
||||||
|
WHERE C_Payment_ID=p_C_Payment_ID;
|
||||||
|
|
||||||
|
SELECT sc.C_Currency_ID
|
||||||
|
INTO v_BaseCurrency_ID
|
||||||
|
FROM AD_ClientInfo ci
|
||||||
|
JOIN C_AcctSchema sc ON ci.C_AcctSchema1_ID=sc.C_AcctSchema_ID
|
||||||
|
WHERE ci.AD_Client_ID=v_Client_ID;
|
||||||
|
|
||||||
|
IF v_BaseCurrency_ID=p_Currency_To_id AND Coalesce(v_CurrencyRate,0) > 0 AND Coalesce(v_ConvertedAmt,0) != 0 AND v_Currency_ID != p_Currency_To_id AND v_IsOverrideCurrencyRate='Y' THEN
|
||||||
|
IF p_Amt IS NULL THEN
|
||||||
|
RETURN v_ConvertedAmt;
|
||||||
|
ELSE
|
||||||
|
RETURN currencyRound(p_Amt*v_CurrencyRate, p_Currency_To_id, null);
|
||||||
|
END IF;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
RETURN currencyConvert(Coalesce(p_Amt,v_PayAmt), v_Currency_ID, p_Currency_To_id, Coalesce(p_conversionDate,v_DateAcct), v_ConversionType_ID, v_Client_ID, v_Org_ID);
|
||||||
|
END currencyConvertPayment;
|
||||||
|
/
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
CREATE OR REPLACE FUNCTION currencyConvertInvoice(
|
||||||
|
p_c_invoice_id numeric,
|
||||||
|
p_currency_to_id numeric,
|
||||||
|
p_amt numeric DEFAULT NULL::numeric,
|
||||||
|
p_conversiondate timestamp with time zone DEFAULT NULL::timestamp with time zone)
|
||||||
|
RETURNS numeric
|
||||||
|
LANGUAGE 'plpgsql'
|
||||||
|
|
||||||
|
COST 100
|
||||||
|
VOLATILE
|
||||||
|
AS $BODY$
|
||||||
|
|
||||||
|
DECLARE
|
||||||
|
v_GrandTotal NUMERIC;
|
||||||
|
v_ConversionType_ID NUMERIC;
|
||||||
|
v_Client_ID NUMERIC;
|
||||||
|
v_Org_ID NUMERIC;
|
||||||
|
v_Currency_ID NUMERIC;
|
||||||
|
v_CurrencyRate NUMERIC;
|
||||||
|
v_DateAcct timestamp with time zone;
|
||||||
|
v_BaseCurrency_ID NUMERIC;
|
||||||
|
v_IsOverrideCurrencyRate character(1);
|
||||||
|
BEGIN
|
||||||
|
SELECT AD_Client_ID, AD_Org_ID, DateAcct, C_Currency_ID, C_ConversionType_ID, CurrencyRate, GrandTotal, IsOverrideCurrencyRate
|
||||||
|
INTO v_Client_ID, v_Org_ID, v_DateAcct, v_Currency_ID, v_ConversionType_ID, v_CurrencyRate, v_GrandTotal, v_IsOverrideCurrencyRate
|
||||||
|
FROM C_Invoice
|
||||||
|
WHERE C_Invoice_ID=p_C_Invoice_ID;
|
||||||
|
|
||||||
|
SELECT sc.C_Currency_ID
|
||||||
|
INTO v_BaseCurrency_ID
|
||||||
|
FROM AD_ClientInfo ci
|
||||||
|
JOIN C_AcctSchema sc ON ci.C_AcctSchema1_ID=sc.C_AcctSchema_ID
|
||||||
|
WHERE ci.AD_Client_ID=v_Client_ID;
|
||||||
|
|
||||||
|
IF v_BaseCurrency_ID=p_Currency_To_id AND Coalesce(v_CurrencyRate,0) > 0 AND v_Currency_ID != p_Currency_To_id AND v_IsOverrideCurrencyRate='Y' THEN
|
||||||
|
RETURN currencyRound(Coalesce(p_Amt,v_GrandTotal)*v_CurrencyRate, p_Currency_To_id, null);
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
RETURN currencyConvert(Coalesce(p_Amt,v_GrandTotal), v_Currency_ID, p_Currency_To_id, Coalesce(p_conversionDate,v_DateAcct), v_ConversionType_ID, v_Client_ID, v_Org_ID);
|
||||||
|
END;
|
||||||
|
|
||||||
|
$BODY$;
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
CREATE OR REPLACE FUNCTION currencyConvertPayment(
|
||||||
|
p_C_Payment_ID numeric,
|
||||||
|
p_Currency_To_id numeric,
|
||||||
|
p_Amt numeric default null,
|
||||||
|
p_conversionDate timestamp with time zone default null)
|
||||||
|
RETURNS numeric
|
||||||
|
LANGUAGE 'plpgsql'
|
||||||
|
AS $BODY$
|
||||||
|
DECLARE
|
||||||
|
v_PayAmt NUMERIC;
|
||||||
|
v_ConversionType_ID NUMERIC;
|
||||||
|
v_Client_ID NUMERIC;
|
||||||
|
v_Org_ID NUMERIC;
|
||||||
|
v_Currency_ID NUMERIC;
|
||||||
|
v_CurrencyRate NUMERIC;
|
||||||
|
v_ConvertedAmt NUMERIC;
|
||||||
|
v_DateAcct timestamp with time zone;
|
||||||
|
v_BaseCurrency_ID NUMERIC;
|
||||||
|
v_IsOverrideCurrencyRate character(1);
|
||||||
|
BEGIN
|
||||||
|
SELECT AD_Client_ID, AD_Org_ID, DateAcct, C_Currency_ID, C_ConversionType_ID, CurrencyRate, ConvertedAmt, PayAmt, IsOverrideCurrencyRate
|
||||||
|
INTO v_Client_ID, v_Org_ID, v_DateAcct, v_Currency_ID, v_ConversionType_ID, v_CurrencyRate, v_ConvertedAmt, v_PayAmt, v_IsOverrideCurrencyRate
|
||||||
|
FROM C_Payment
|
||||||
|
WHERE C_Payment_ID=p_C_Payment_ID;
|
||||||
|
|
||||||
|
SELECT sc.C_Currency_ID
|
||||||
|
INTO v_BaseCurrency_ID
|
||||||
|
FROM AD_ClientInfo ci
|
||||||
|
JOIN C_AcctSchema sc ON ci.C_AcctSchema1_ID=sc.C_AcctSchema_ID
|
||||||
|
WHERE ci.AD_Client_ID=v_Client_ID;
|
||||||
|
|
||||||
|
IF v_BaseCurrency_ID=p_Currency_To_id AND Coalesce(v_CurrencyRate,0) > 0 AND Coalesce(v_ConvertedAmt,0) != 0 AND v_Currency_ID != p_Currency_To_id AND v_IsOverrideCurrencyRate='Y' THEN
|
||||||
|
IF p_Amt IS NULL THEN
|
||||||
|
RETURN v_ConvertedAmt;
|
||||||
|
ELSE
|
||||||
|
RETURN currencyRound(p_Amt*v_CurrencyRate, p_Currency_To_id, null);
|
||||||
|
END IF;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
RETURN currencyConvert(Coalesce(p_Amt,v_PayAmt), v_Currency_ID, p_Currency_To_id, Coalesce(p_conversionDate,v_DateAcct), v_ConversionType_ID, v_Client_ID, v_Org_ID);
|
||||||
|
END;
|
||||||
|
$BODY$;
|
||||||
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
SET SQLBLANKLINES ON
|
||||||
|
SET DEFINE OFF
|
||||||
|
|
||||||
|
-- Jul 25, 2018 6:27:49 PM MYT
|
||||||
|
-- AP2-473 Improve handling of Spot Rate
|
||||||
|
INSERT INTO AD_Column (AD_Column_ID,SeqNoSelection,IsSyncDatabase,Version,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsParent,FieldLength,IsSelectionColumn,IsKey,IsAutocomplete,IsAllowLogging,AD_Column_UU,Updated,IsUpdateable,ColumnName,Description,DefaultValue,Help,Name,IsAllowCopy,IsActive,CreatedBy,UpdatedBy,IsAlwaysUpdateable,AD_Client_ID,Created,IsSecure,EntityType,IsEncrypted,AD_Element_ID,AD_Table_ID,AD_Reference_ID,IsToolbarButton,AD_Org_ID,IsHtml) VALUES (213623,0,'N',0,'N','N','N',0,'N',22,'N','N','N','Y','2c7aa027-bb65-45f3-b584-7471b4db2589',TO_DATE('2018-07-25 18:27:43','YYYY-MM-DD HH24:MI:SS'),'Y','CurrencyRate','Currency Conversion Rate',NULL,'The Currency Conversion Rate indicates the rate to use when converting the source currency to the accounting currency','Rate','Y','Y',100,100,'N',0,TO_DATE('2018-07-25 18:27:43','YYYY-MM-DD HH24:MI:SS'),'N','D','N',253,335,22,'N',0,'N')
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jul 25, 2018 6:27:58 PM MYT
|
||||||
|
ALTER TABLE C_Payment ADD CurrencyRate NUMBER DEFAULT NULL
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jul 25, 2018 6:28:37 PM MYT
|
||||||
|
INSERT INTO AD_Column (AD_Column_ID,SeqNoSelection,IsSyncDatabase,Version,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsParent,FieldLength,IsSelectionColumn,IsKey,IsAutocomplete,IsAllowLogging,AD_Column_UU,Updated,IsUpdateable,ColumnName,Description,Help,Name,IsAllowCopy,IsActive,CreatedBy,UpdatedBy,IsAlwaysUpdateable,AD_Client_ID,Created,IsSecure,EntityType,IsEncrypted,AD_Element_ID,AD_Table_ID,AD_Reference_ID,IsToolbarButton,AD_Org_ID,IsHtml) VALUES (213624,0,'N',0,'N','N','N',0,'N',22,'N','N','N','Y','d1ef932b-5a7d-4d3a-b6c9-d92b02c440f9',TO_DATE('2018-07-25 18:28:37','YYYY-MM-DD HH24:MI:SS'),'Y','ConvertedAmt','Converted Amount','The Converted Amount is the result of multiplying the Source Amount by the Conversion Rate for this target currency.','Converted Amount','Y','Y',100,100,'N',0,TO_DATE('2018-07-25 18:28:37','YYYY-MM-DD HH24:MI:SS'),'N','D','N',1555,335,12,'N',0,'N')
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jul 25, 2018 6:28:44 PM MYT
|
||||||
|
ALTER TABLE C_Payment ADD ConvertedAmt NUMBER DEFAULT NULL
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jul 25, 2018 6:35:47 PM MYT
|
||||||
|
INSERT INTO AD_Field (SortNo,AD_Field_ID,IsEncrypted,DisplayLength,IsSameLine,IsHeading,SeqNo,IsCentrallyMaintained,IsReadOnly,Help,DisplayLogic,Updated,Description,Name,AD_Field_UU,IsDisplayed,IsFieldOnly,CreatedBy,UpdatedBy,IsActive,IsDisplayedGrid,SeqNoGrid,XPosition,IsQuickEntry,AD_Client_ID,Created,ColumnSpan,NumLines,IsAdvancedField,IsDefaultFocus,AD_Column_ID,EntityType,AD_Tab_ID,AD_Org_ID) VALUES (0,205669,'N',0,'N','N',231,'Y','N','The Currency Conversion Rate indicates the rate to use when converting the source currency to the accounting currency','@C_Currency_ID@!@$C_Currency_ID@ & @C_ConversionType_ID@=114',TO_DATE('2018-07-25 18:35:41','YYYY-MM-DD HH24:MI:SS'),'Currency Conversion Rate','Rate','085538d5-fa30-454f-9efa-46d7f03ec2bf','Y','N',100,100,'Y','Y',221,4,'N',0,TO_DATE('2018-07-25 18:35:41','YYYY-MM-DD HH24:MI:SS'),2,1,'N','N',213623,'D',330,0)
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jul 25, 2018 6:36:28 PM MYT
|
||||||
|
INSERT INTO AD_Field (SortNo,AD_Field_ID,IsEncrypted,DisplayLength,IsSameLine,IsHeading,SeqNo,IsCentrallyMaintained,IsReadOnly,Help,DisplayLogic,Updated,Description,Name,AD_Field_UU,IsDisplayed,IsFieldOnly,CreatedBy,UpdatedBy,IsActive,IsDisplayedGrid,SeqNoGrid,XPosition,IsQuickEntry,AD_Client_ID,Created,ColumnSpan,NumLines,IsAdvancedField,IsDefaultFocus,AD_Column_ID,EntityType,AD_Tab_ID,AD_Org_ID) VALUES (0,205670,'N',0,'N','N',232,'Y','N','The Converted Amount is the result of multiplying the Source Amount by the Conversion Rate for this target currency.','@C_Currency_ID@!@$C_Currency_ID@ & @C_ConversionType_ID@=114',TO_DATE('2018-07-25 18:36:22','YYYY-MM-DD HH24:MI:SS'),'Converted Amount','Converted Amount','a7312ba2-8cd8-4c8c-ac60-24559140372a','Y','N',100,100,'Y','Y',222,1,'N',0,TO_DATE('2018-07-25 18:36:22','YYYY-MM-DD HH24:MI:SS'),2,1,'N','N',213624,'D',330,0)
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jul 26, 2018 5:47:16 PM MYT
|
||||||
|
-- AP2-473 Improve handling of Spot Rate
|
||||||
|
UPDATE AD_Column SET Callout='org.compiere.model.CalloutPayment.amounts',Updated=TO_DATE('2018-07-26 17:47:16','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=213623
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jul 26, 2018 5:47:50 PM MYT
|
||||||
|
UPDATE AD_Column SET Callout='org.compiere.model.CalloutPayment.amounts',Updated=TO_DATE('2018-07-26 17:47:50','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=213624
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jul 26, 2018 8:42:12 PM MYT
|
||||||
|
-- AP2-473 Improve handling of Spot Rate
|
||||||
|
UPDATE AD_Column SET Callout='org.compiere.model.CalloutPayment.amounts',Updated=TO_DATE('2018-07-26 20:42:12','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=12128
|
||||||
|
;
|
||||||
|
|
||||||
|
SELECT register_migration_script('202007211800_IDEMPIERE-4083.sql') FROM dual
|
||||||
|
;
|
||||||
|
|
|
@ -0,0 +1,106 @@
|
||||||
|
SET SQLBLANKLINES ON
|
||||||
|
SET DEFINE OFF
|
||||||
|
|
||||||
|
-- Aug 6, 2018 12:04:56 PM MYT
|
||||||
|
-- AP2-473 Improve handling of Spot Rate
|
||||||
|
INSERT INTO AD_Element (AD_Element_ID,ColumnName,Updated,Name,Description,PrintName,AD_Element_UU,IsActive,Created,CreatedBy,UpdatedBy,AD_Client_ID,EntityType,AD_Org_ID) VALUES (203258,'IsOverrideCurrencyRate',TO_DATE('2018-08-06 12:04:54','YYYY-MM-DD HH24:MI:SS'),'Override Currency Conversion Rate','Override Currency Conversion Rate','Override Currency Conversion Rate','fa5158e6-cd76-4b51-a423-0e61f1174402','Y',TO_DATE('2018-08-06 12:04:54','YYYY-MM-DD HH24:MI:SS'),100,100,0,'D',0)
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Aug 6, 2018 12:06:46 PM MYT
|
||||||
|
INSERT INTO AD_Column (AD_Column_ID,SeqNoSelection,IsSyncDatabase,Version,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsParent,FieldLength,IsSelectionColumn,IsKey,IsAutocomplete,IsAllowLogging,AD_Column_UU,Updated,IsUpdateable,ColumnName,Description,DefaultValue,Name,IsAllowCopy,IsActive,CreatedBy,UpdatedBy,IsAlwaysUpdateable,AD_Client_ID,Created,IsSecure,EntityType,IsEncrypted,FKConstraintType,AD_Element_ID,AD_Table_ID,AD_Reference_ID,IsToolbarButton,AD_Org_ID,IsHtml) VALUES (213664,0,'N',0,'Y','N','N',0,'N',1,'N','N','N','Y','694d7baf-3218-4940-a32e-439a8a8c0fdf',TO_DATE('2018-08-06 12:06:45','YYYY-MM-DD HH24:MI:SS'),'Y','IsOverrideCurrencyRate','Override Currency Conversion Rate','N','Override Currency Conversion Rate','Y','Y',100,100,'N',0,TO_DATE('2018-08-06 12:06:45','YYYY-MM-DD HH24:MI:SS'),'N','D','N','N',203258,335,20,'N',0,'N')
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Aug 6, 2018 12:07:00 PM MYT
|
||||||
|
UPDATE AD_Column SET IsAllowCopy='N',Updated=TO_DATE('2018-08-06 12:07:00','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=213664
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Aug 6, 2018 12:07:06 PM MYT
|
||||||
|
ALTER TABLE C_Payment ADD IsOverrideCurrencyRate CHAR(1) DEFAULT 'N' CHECK (IsOverrideCurrencyRate IN ('Y','N')) NOT NULL
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Aug 6, 2018 12:11:52 PM MYT
|
||||||
|
UPDATE AD_Field SET SeqNo=233, DisplayLogic='@C_Currency_ID@!@$C_Currency_ID@ & @IsOverrideCurrencyRateO@=Y', AD_Val_Rule_ID=NULL, SeqNoGrid=223, XPosition=4, AD_Reference_Value_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2018-08-06 12:11:52','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=205670
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Aug 6, 2018 12:12:40 PM MYT
|
||||||
|
UPDATE AD_Field SET SeqNo=232, DisplayLogic='@C_Currency_ID@!@$C_Currency_ID@ & @IsOverrideCurrencyRate@=Y', AD_Val_Rule_ID=NULL, SeqNoGrid=222, XPosition=1, AD_Reference_Value_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2018-08-06 12:12:40','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=205669
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Aug 6, 2018 12:13:30 PM MYT
|
||||||
|
INSERT INTO AD_Field (SortNo,AD_Field_ID,IsEncrypted,DisplayLength,IsSameLine,IsHeading,SeqNo,IsCentrallyMaintained,IsReadOnly,DisplayLogic,Updated,Description,Name,AD_Field_UU,IsDisplayed,IsFieldOnly,CreatedBy,UpdatedBy,IsActive,IsDisplayedGrid,SeqNoGrid,XPosition,IsQuickEntry,AD_Client_ID,Created,ColumnSpan,NumLines,IsAdvancedField,IsDefaultFocus,AD_Column_ID,EntityType,AD_Tab_ID,AD_Org_ID) VALUES (0,205706,'N',0,'N','N',231,'Y','N','@C_Currency_ID@!@$C_Currency_ID@',TO_DATE('2018-08-06 12:13:30','YYYY-MM-DD HH24:MI:SS'),'Override Currency Conversion Rate','Override Currency Conversion Rate','29fffeb3-e9dc-4a9d-813f-e54782b9dc19','Y','N',100,100,'Y','Y',221,1,'N',0,TO_DATE('2018-08-06 12:13:30','YYYY-MM-DD HH24:MI:SS'),2,1,'N','N',213664,'D',330,0)
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Aug 6, 2018 12:14:06 PM MYT
|
||||||
|
UPDATE AD_Field SET DisplayLogic='@C_Currency_ID@!@$C_Currency_ID@ & @IsOverrideCurrencyRate@=N', AD_Val_Rule_ID=NULL, AD_Reference_Value_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2018-08-06 12:14:06','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=8651
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Aug 6, 2018 12:14:39 PM MYT
|
||||||
|
UPDATE AD_Field SET AD_Val_Rule_ID=NULL, XPosition=2, AD_Reference_Value_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2018-08-06 12:14:39','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=205706
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Aug 6, 2018 3:36:31 PM MYT
|
||||||
|
-- AP2-473 Improve handling of Spot Rate
|
||||||
|
UPDATE AD_Field SET DisplayLogic='@C_Currency_ID@!@$C_Currency_ID@', AD_Val_Rule_ID=NULL, AD_Reference_Value_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2018-08-06 15:36:31','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=8651
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Aug 6, 2018 4:34:56 PM MYT
|
||||||
|
-- AP2-473 Improve handling of Spot Rate
|
||||||
|
UPDATE AD_Column SET Callout=NULL,Updated=TO_DATE('2018-08-06 16:34:56','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=12128
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Aug 6, 2018 4:35:17 PM MYT
|
||||||
|
UPDATE AD_Column SET Callout='org.compiere.model.CalloutPayment.amounts',Updated=TO_DATE('2018-08-06 16:35:17','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=213664
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Aug 6, 2018 6:16:52 PM MYT
|
||||||
|
-- AP2-473 Improve handling of Spot Rate
|
||||||
|
UPDATE AD_Field SET DisplayLogic='@C_Currency_ID@!@$C_Currency_ID@ & @IsOverrideCurrencyRate@=Y', AD_Val_Rule_ID=NULL, AD_Reference_Value_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2018-08-06 18:16:52','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=205670
|
||||||
|
;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION currencyConvertPayment
|
||||||
|
(
|
||||||
|
p_C_Payment_ID IN NUMBER,
|
||||||
|
p_CurTo_ID IN NUMBER,
|
||||||
|
p_Amt IN NUMBER DEFAULT NULL,
|
||||||
|
p_conversionDate IN DATE DEFAULT NULL
|
||||||
|
)
|
||||||
|
RETURN NUMBER
|
||||||
|
AS
|
||||||
|
v_Rate NUMBER;
|
||||||
|
v_PayAmt NUMBER;
|
||||||
|
v_ConversionType_ID NUMBER;
|
||||||
|
v_Client_ID NUMBER;
|
||||||
|
v_Org_ID NUMBER;
|
||||||
|
v_Currency_ID NUMBER;
|
||||||
|
v_CurrencyRate NUMBER;
|
||||||
|
v_ConvertedAmt NUMBER;
|
||||||
|
v_DateAcct DATE;
|
||||||
|
v_BaseCurrency_ID NUMBER;
|
||||||
|
v_IsOverrideCurrencyRate Char(1);
|
||||||
|
BEGIN
|
||||||
|
SELECT AD_Client_ID, AD_Org_ID, DateAcct, C_Currency_ID, C_ConversionType_ID, CurrencyRate, ConvertedAmt, PayAmt, IsOverrideCurrencyRate
|
||||||
|
INTO v_Client_ID, v_Org_ID, v_DateAcct, v_Currency_ID, v_ConversionType_ID, v_CurrencyRate, v_ConvertedAmt, v_PayAmt, v_IsOverrideCurrencyRate
|
||||||
|
FROM C_Payment
|
||||||
|
WHERE C_Payment_ID=p_C_Payment_ID;
|
||||||
|
|
||||||
|
SELECT sc.C_Currency_ID
|
||||||
|
INTO v_BaseCurrency_ID
|
||||||
|
FROM AD_ClientInfo ci
|
||||||
|
JOIN C_AcctSchema sc ON ci.C_AcctSchema1_ID=sc.C_AcctSchema_ID
|
||||||
|
WHERE ci.AD_Client_ID=v_Client_ID;
|
||||||
|
|
||||||
|
IF v_BaseCurrency_ID=p_Currency_To_id AND Coalesce(v_CurrencyRate,0) > 0 AND Coalesce(v_ConvertedAmt,0) != 0 AND v_Currency_ID != p_Currency_To_id AND v_IsOverrideCurrencyRate='Y' THEN
|
||||||
|
IF p_Amt IS NULL THEN
|
||||||
|
RETURN v_ConvertedAmt;
|
||||||
|
ELSE
|
||||||
|
RETURN currencyRound(p_Amt*v_CurrencyRate, p_Currency_To_id, null);
|
||||||
|
END IF;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
RETURN currencyConvert(Coalesce(p_Amt,v_PayAmt), v_Currency_ID, p_Currency_To_id, Coalesce(p_conversionDate,v_DateAcct), v_ConversionType_ID, v_Client_ID, v_Org_ID);
|
||||||
|
END currencyConvertPayment;
|
||||||
|
/
|
||||||
|
|
||||||
|
SELECT register_migration_script('202007211900_IDEMPIERE-4083.sql') FROM dual
|
||||||
|
;
|
||||||
|
|
|
@ -0,0 +1,95 @@
|
||||||
|
SET SQLBLANKLINES ON
|
||||||
|
SET DEFINE OFF
|
||||||
|
|
||||||
|
-- Aug 7, 2018 12:11:37 PM MYT
|
||||||
|
-- AP2-473 Improve handling of Spot Rate
|
||||||
|
INSERT INTO AD_Column (AD_Column_ID,SeqNoSelection,IsSyncDatabase,Version,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsParent,FieldLength,IsSelectionColumn,IsKey,IsAutocomplete,IsAllowLogging,AD_Column_UU,Updated,IsUpdateable,ColumnName,Description,DefaultValue,Name,IsAllowCopy,IsActive,CreatedBy,UpdatedBy,IsAlwaysUpdateable,AD_Client_ID,Created,IsSecure,EntityType,IsEncrypted,FKConstraintType,AD_Element_ID,AD_Table_ID,AD_Reference_ID,IsToolbarButton,AD_Org_ID,IsHtml) VALUES (213667,0,'N',0,'Y','N','N',0,'N',1,'N','N','N','Y','49dfde99-b3e4-48df-b2dc-d178a7ba8391',TO_DATE('2018-08-07 12:11:31','YYYY-MM-DD HH24:MI:SS'),'Y','IsOverrideCurrencyRate','Override Currency Conversion Rate','N','Override Currency Conversion Rate','Y','Y',100,100,'N',0,TO_DATE('2018-08-07 12:11:31','YYYY-MM-DD HH24:MI:SS'),'N','D','N','N',203258,318,20,'N',0,'N')
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Aug 7, 2018 12:11:44 PM MYT
|
||||||
|
ALTER TABLE C_Invoice ADD IsOverrideCurrencyRate CHAR(1) DEFAULT 'N' CHECK (IsOverrideCurrencyRate IN ('Y','N')) NOT NULL
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Aug 7, 2018 12:12:34 PM MYT
|
||||||
|
INSERT INTO AD_Column (AD_Column_ID,SeqNoSelection,IsSyncDatabase,Version,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsParent,FieldLength,IsSelectionColumn,IsKey,IsAutocomplete,IsAllowLogging,AD_Column_UU,Updated,IsUpdateable,ColumnName,Description,Help,Name,IsAllowCopy,IsActive,CreatedBy,UpdatedBy,IsAlwaysUpdateable,AD_Client_ID,Created,IsSecure,EntityType,IsEncrypted,AD_Element_ID,AD_Table_ID,AD_Reference_ID,IsToolbarButton,AD_Org_ID,IsHtml) VALUES (213668,0,'N',0,'N','N','N',0,'N',22,'N','N','N','Y','a73b45e7-f38f-4447-8657-1eb475e6e153',TO_DATE('2018-08-07 12:12:28','YYYY-MM-DD HH24:MI:SS'),'Y','CurrencyRate','Currency Conversion Rate','The Currency Conversion Rate indicates the rate to use when converting the source currency to the accounting currency','Rate','Y','Y',100,100,'N',0,TO_DATE('2018-08-07 12:12:28','YYYY-MM-DD HH24:MI:SS'),'N','D','N',253,318,22,'N',0,'N')
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Aug 7, 2018 12:12:40 PM MYT
|
||||||
|
ALTER TABLE C_Invoice ADD CurrencyRate NUMBER DEFAULT NULL
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Aug 7, 2018 12:50:00 PM MYT
|
||||||
|
-- AP2-473 Improve handling of Spot Rate
|
||||||
|
INSERT INTO AD_Field (SortNo,AD_Field_ID,IsEncrypted,DisplayLength,IsSameLine,IsHeading,SeqNo,IsCentrallyMaintained,IsReadOnly,DisplayLogic,Updated,Description,Name,AD_Field_UU,IsDisplayed,IsFieldOnly,CreatedBy,UpdatedBy,IsActive,IsDisplayedGrid,SeqNoGrid,XPosition,IsQuickEntry,AD_Client_ID,Created,ColumnSpan,NumLines,IsAdvancedField,IsDefaultFocus,AD_Column_ID,EntityType,AD_Tab_ID,AD_Org_ID) VALUES (0,205806,'N',0,'N','N',171,'Y','N','@C_Currency_ID@!@$C_Currency_ID@',TO_DATE('2018-08-07 12:49:55','YYYY-MM-DD HH24:MI:SS'),'Override Currency Conversion Rate','Override Currency Conversion Rate','a28728cb-1b43-493f-bf29-481604eb1dcb','Y','N',100,100,'Y','Y',171,2,'N',0,TO_DATE('2018-08-07 12:49:55','YYYY-MM-DD HH24:MI:SS'),2,1,'N','N',213667,'D',263,0)
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Aug 7, 2018 12:51:28 PM MYT
|
||||||
|
INSERT INTO AD_Field (SortNo,AD_Field_ID,IsEncrypted,DisplayLength,IsSameLine,IsHeading,SeqNo,IsCentrallyMaintained,IsReadOnly,Help,DisplayLogic,Updated,Description,Name,AD_Field_UU,IsDisplayed,IsFieldOnly,CreatedBy,UpdatedBy,IsActive,IsDisplayedGrid,SeqNoGrid,XPosition,IsQuickEntry,AD_Client_ID,Created,ColumnSpan,NumLines,IsAdvancedField,IsDefaultFocus,AD_Column_ID,EntityType,AD_Tab_ID,AD_Org_ID) VALUES (0,205807,'N',0,'N','N',172,'Y','N','The Currency Conversion Rate indicates the rate to use when converting the source currency to the accounting currency','@C_Currency_ID@!@$C_Currency_ID@ & @IsOverrideCurrencyRate@=Y',TO_DATE('2018-08-07 12:51:22','YYYY-MM-DD HH24:MI:SS'),'Currency Conversion Rate','Rate','c8f3055c-77ff-4fa8-bf79-fa1e60f8693f','Y','N',100,100,'Y','Y',172,4,'N',0,TO_DATE('2018-08-07 12:51:22','YYYY-MM-DD HH24:MI:SS'),2,1,'N','N',213668,'D',263,0)
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Aug 7, 2018 12:53:55 PM MYT
|
||||||
|
INSERT INTO AD_Field (SortNo,AD_Field_ID,IsEncrypted,DisplayLength,IsSameLine,IsHeading,SeqNo,IsCentrallyMaintained,IsReadOnly,DisplayLogic,Updated,Description,Name,AD_Field_UU,IsDisplayed,IsFieldOnly,CreatedBy,UpdatedBy,IsActive,IsDisplayedGrid,SeqNoGrid,XPosition,IsQuickEntry,AD_Client_ID,Created,ColumnSpan,NumLines,IsAdvancedField,IsDefaultFocus,AD_Column_ID,EntityType,AD_Tab_ID,AD_Org_ID) VALUES (0,205808,'N',0,'N','N',171,'Y','N','@C_Currency_ID@!@$C_Currency_ID@',TO_DATE('2018-08-07 12:53:50','YYYY-MM-DD HH24:MI:SS'),'Override Currency Conversion Rate','Override Currency Conversion Rate','8adaa192-2b66-477c-a442-4902fcc8a377','Y','N',100,100,'Y','Y',171,2,'N',0,TO_DATE('2018-08-07 12:53:50','YYYY-MM-DD HH24:MI:SS'),2,1,'N','N',213667,'D',290,0)
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Aug 7, 2018 12:55:15 PM MYT
|
||||||
|
INSERT INTO AD_Field (SortNo,AD_Field_ID,IsEncrypted,DisplayLength,IsSameLine,IsHeading,SeqNo,IsCentrallyMaintained,IsReadOnly,Help,DisplayLogic,Updated,Description,Name,AD_Field_UU,IsDisplayed,IsFieldOnly,CreatedBy,UpdatedBy,IsActive,IsDisplayedGrid,SeqNoGrid,XPosition,IsQuickEntry,AD_Client_ID,Created,ColumnSpan,NumLines,IsAdvancedField,IsDefaultFocus,AD_Column_ID,EntityType,AD_Tab_ID,AD_Org_ID) VALUES (0,205809,'N',0,'N','N',172,'Y','N','The Currency Conversion Rate indicates the rate to use when converting the source currency to the accounting currency','@C_Currency_ID@!@$C_Currency_ID@ & @IsOverrideCurrencyRate@=Y',TO_DATE('2018-08-07 12:55:09','YYYY-MM-DD HH24:MI:SS'),'Currency Conversion Rate','Rate','654aef87-77d6-4640-9366-4e2d16de610c','Y','N',100,100,'Y','Y',1,4,'N',0,TO_DATE('2018-08-07 12:55:09','YYYY-MM-DD HH24:MI:SS'),2,1,'N','N',213668,'D',290,0)
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Aug 7, 2018 5:24:49 PM MYT
|
||||||
|
-- AP2-473 Improve handling of Spot Rate
|
||||||
|
UPDATE AD_StatusLine SET SQLStatement='SELECT COUNT(DISTINCT C_InvoiceLine_ID) AS Lines,o.TotalLines,o.GrandTotal,c.ISO_Code, currencyConvertInvoice(o.C_Invoice_ID,@$C_Currency_ID@,o.GrandTotal,o.DateAcct) AS ConvAmt, o.GrandTotal-o.TotalLines AS TaxAmt
|
||||||
|
FROM C_Invoice o
|
||||||
|
INNER JOIN C_Currency c ON (o.C_Currency_ID=c.C_Currency_ID)
|
||||||
|
LEFT JOIN C_InvoiceLine l ON (o.C_Invoice_ID=l.C_Invoice_ID)
|
||||||
|
WHERE o.C_Invoice_ID=@C_Invoice_ID@
|
||||||
|
GROUP BY o.C_Currency_ID, c.ISO_Code, o.TotalLines, o.GrandTotal, o.DateAcct, o.AD_Client_ID, o.AD_Org_ID',Updated=TO_DATE('2018-08-07 17:24:49','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_StatusLine_ID=200002
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Aug 7, 2018 5:26:55 PM MYT
|
||||||
|
UPDATE AD_StatusLine SET SQLStatement='SELECT COUNT(DISTINCT C_InvoiceLine_ID) AS Lines,o.TotalLines,o.GrandTotal,c.ISO_Code, currencyConvertInvoice(o.C_Invoice_ID,@$C_Currency_ID@,o.GrandTotal,o.DateAcct) AS ConvAmt, o.GrandTotal-o.TotalLines AS TaxAmt
|
||||||
|
FROM C_Invoice o
|
||||||
|
INNER JOIN C_Currency c ON (o.C_Currency_ID=c.C_Currency_ID)
|
||||||
|
LEFT JOIN C_InvoiceLine l ON (o.C_Invoice_ID=l.C_Invoice_ID)
|
||||||
|
WHERE o.C_Invoice_ID=@C_Invoice_ID@
|
||||||
|
GROUP BY o.C_Invoice_ID, c.ISO_Code, o.TotalLines, o.GrandTotal, o.DateAcct, o.AD_Client_ID, o.AD_Org_ID',Updated=TO_DATE('2018-08-07 17:26:55','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_StatusLine_ID=200002
|
||||||
|
;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION currencyConvertInvoice(
|
||||||
|
p_c_invoice_id in number,
|
||||||
|
p_currency_to_id in number,
|
||||||
|
p_amt in number DEFAULT NULL,
|
||||||
|
p_conversiondate in date DEFAULT NULL)
|
||||||
|
RETURNS number
|
||||||
|
AS
|
||||||
|
v_GrandTotal NUMBER;
|
||||||
|
v_ConversionType_ID NUMBER;
|
||||||
|
v_Client_ID NUMBER;
|
||||||
|
v_Org_ID NUMBER;
|
||||||
|
v_Currency_ID NUMBER;
|
||||||
|
v_CurrencyRate NUMBER;
|
||||||
|
v_DateAcct DATE;
|
||||||
|
v_BaseCurrency_ID NUMBER;
|
||||||
|
v_IsOverrideCurrencyRate CHAR(1);
|
||||||
|
BEGIN
|
||||||
|
SELECT AD_Client_ID, AD_Org_ID, DateAcct, C_Currency_ID, C_ConversionType_ID, CurrencyRate, GrandTotal, IsOverrideCurrencyRate
|
||||||
|
INTO v_Client_ID, v_Org_ID, v_DateAcct, v_Currency_ID, v_ConversionType_ID, v_CurrencyRate, v_GrandTotal, v_IsOverrideCurrencyRate
|
||||||
|
FROM C_Invoice
|
||||||
|
WHERE C_Invoice_ID=p_C_Invoice_ID;
|
||||||
|
|
||||||
|
SELECT sc.C_Currency_ID
|
||||||
|
INTO v_BaseCurrency_ID
|
||||||
|
FROM AD_ClientInfo ci
|
||||||
|
JOIN C_AcctSchema sc ON ci.C_AcctSchema1_ID=sc.C_AcctSchema_ID
|
||||||
|
WHERE ci.AD_Client_ID=v_Client_ID;
|
||||||
|
|
||||||
|
IF v_BaseCurrency_ID=p_Currency_To_id AND Coalesce(v_CurrencyRate,0) > 0 AND v_Currency_ID != p_Currency_To_id AND v_IsOverrideCurrencyRate='Y' THEN
|
||||||
|
RETURN currencyRound(Coalesce(p_Amt,v_GrandTotal)*v_CurrencyRate, p_Currency_To_id, null);
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
RETURN currencyConvert(Coalesce(p_Amt,v_GrandTotal), v_Currency_ID, p_Currency_To_id, Coalesce(p_conversionDate,v_DateAcct), v_ConversionType_ID, v_Client_ID, v_Org_ID);
|
||||||
|
END currencyConvertInvoice;
|
||||||
|
/
|
||||||
|
|
||||||
|
SELECT register_migration_script('202007212000_IDEMPIERE-4083.sql') FROM dual
|
||||||
|
;
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
-- Jul 25, 2018 6:27:49 PM MYT
|
||||||
|
-- AP2-473 Improve handling of Spot Rate
|
||||||
|
INSERT INTO AD_Column (AD_Column_ID,SeqNoSelection,IsSyncDatabase,Version,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsParent,FieldLength,IsSelectionColumn,IsKey,IsAutocomplete,IsAllowLogging,AD_Column_UU,Updated,IsUpdateable,ColumnName,Description,DefaultValue,Help,Name,IsAllowCopy,IsActive,CreatedBy,UpdatedBy,IsAlwaysUpdateable,AD_Client_ID,Created,IsSecure,EntityType,IsEncrypted,AD_Element_ID,AD_Table_ID,AD_Reference_ID,IsToolbarButton,AD_Org_ID,IsHtml) VALUES (213623,0,'N',0,'N','N','N',0,'N',22,'N','N','N','Y','2c7aa027-bb65-45f3-b584-7471b4db2589',TO_TIMESTAMP('2018-07-25 18:27:43','YYYY-MM-DD HH24:MI:SS'),'Y','CurrencyRate','Currency Conversion Rate',NULL,'The Currency Conversion Rate indicates the rate to use when converting the source currency to the accounting currency','Rate','Y','Y',100,100,'N',0,TO_TIMESTAMP('2018-07-25 18:27:43','YYYY-MM-DD HH24:MI:SS'),'N','D','N',253,335,22,'N',0,'N')
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jul 25, 2018 6:27:58 PM MYT
|
||||||
|
ALTER TABLE C_Payment ADD COLUMN CurrencyRate NUMERIC DEFAULT NULL
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jul 25, 2018 6:28:37 PM MYT
|
||||||
|
INSERT INTO AD_Column (AD_Column_ID,SeqNoSelection,IsSyncDatabase,Version,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsParent,FieldLength,IsSelectionColumn,IsKey,IsAutocomplete,IsAllowLogging,AD_Column_UU,Updated,IsUpdateable,ColumnName,Description,Help,Name,IsAllowCopy,IsActive,CreatedBy,UpdatedBy,IsAlwaysUpdateable,AD_Client_ID,Created,IsSecure,EntityType,IsEncrypted,AD_Element_ID,AD_Table_ID,AD_Reference_ID,IsToolbarButton,AD_Org_ID,IsHtml) VALUES (213624,0,'N',0,'N','N','N',0,'N',22,'N','N','N','Y','d1ef932b-5a7d-4d3a-b6c9-d92b02c440f9',TO_TIMESTAMP('2018-07-25 18:28:37','YYYY-MM-DD HH24:MI:SS'),'Y','ConvertedAmt','Converted Amount','The Converted Amount is the result of multiplying the Source Amount by the Conversion Rate for this target currency.','Converted Amount','Y','Y',100,100,'N',0,TO_TIMESTAMP('2018-07-25 18:28:37','YYYY-MM-DD HH24:MI:SS'),'N','D','N',1555,335,12,'N',0,'N')
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jul 25, 2018 6:28:44 PM MYT
|
||||||
|
ALTER TABLE C_Payment ADD COLUMN ConvertedAmt NUMERIC DEFAULT NULL
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jul 25, 2018 6:35:47 PM MYT
|
||||||
|
INSERT INTO AD_Field (SortNo,AD_Field_ID,IsEncrypted,DisplayLength,IsSameLine,IsHeading,SeqNo,IsCentrallyMaintained,IsReadOnly,Help,DisplayLogic,Updated,Description,Name,AD_Field_UU,IsDisplayed,IsFieldOnly,CreatedBy,UpdatedBy,IsActive,IsDisplayedGrid,SeqNoGrid,XPosition,IsQuickEntry,AD_Client_ID,Created,ColumnSpan,NumLines,IsAdvancedField,IsDefaultFocus,AD_Column_ID,EntityType,AD_Tab_ID,AD_Org_ID) VALUES (0,205669,'N',0,'N','N',231,'Y','N','The Currency Conversion Rate indicates the rate to use when converting the source currency to the accounting currency','@C_Currency_ID@!@$C_Currency_ID@ & @C_ConversionType_ID@=114',TO_TIMESTAMP('2018-07-25 18:35:41','YYYY-MM-DD HH24:MI:SS'),'Currency Conversion Rate','Rate','085538d5-fa30-454f-9efa-46d7f03ec2bf','Y','N',100,100,'Y','Y',221,4,'N',0,TO_TIMESTAMP('2018-07-25 18:35:41','YYYY-MM-DD HH24:MI:SS'),2,1,'N','N',213623,'D',330,0)
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jul 25, 2018 6:36:28 PM MYT
|
||||||
|
INSERT INTO AD_Field (SortNo,AD_Field_ID,IsEncrypted,DisplayLength,IsSameLine,IsHeading,SeqNo,IsCentrallyMaintained,IsReadOnly,Help,DisplayLogic,Updated,Description,Name,AD_Field_UU,IsDisplayed,IsFieldOnly,CreatedBy,UpdatedBy,IsActive,IsDisplayedGrid,SeqNoGrid,XPosition,IsQuickEntry,AD_Client_ID,Created,ColumnSpan,NumLines,IsAdvancedField,IsDefaultFocus,AD_Column_ID,EntityType,AD_Tab_ID,AD_Org_ID) VALUES (0,205670,'N',0,'N','N',232,'Y','N','The Converted Amount is the result of multiplying the Source Amount by the Conversion Rate for this target currency.','@C_Currency_ID@!@$C_Currency_ID@ & @C_ConversionType_ID@=114',TO_TIMESTAMP('2018-07-25 18:36:22','YYYY-MM-DD HH24:MI:SS'),'Converted Amount','Converted Amount','a7312ba2-8cd8-4c8c-ac60-24559140372a','Y','N',100,100,'Y','Y',222,1,'N',0,TO_TIMESTAMP('2018-07-25 18:36:22','YYYY-MM-DD HH24:MI:SS'),2,1,'N','N',213624,'D',330,0)
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jul 26, 2018 5:47:16 PM MYT
|
||||||
|
-- AP2-473 Improve handling of Spot Rate
|
||||||
|
UPDATE AD_Column SET Callout='org.compiere.model.CalloutPayment.amounts',Updated=TO_TIMESTAMP('2018-07-26 17:47:16','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=213623
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jul 26, 2018 5:47:50 PM MYT
|
||||||
|
UPDATE AD_Column SET Callout='org.compiere.model.CalloutPayment.amounts',Updated=TO_TIMESTAMP('2018-07-26 17:47:50','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=213624
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jul 26, 2018 8:42:12 PM MYT
|
||||||
|
-- AP2-473 Improve handling of Spot Rate
|
||||||
|
UPDATE AD_Column SET Callout='org.compiere.model.CalloutPayment.amounts',Updated=TO_TIMESTAMP('2018-07-26 20:42:12','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=12128
|
||||||
|
;
|
||||||
|
|
||||||
|
SELECT register_migration_script('202007211800_IDEMPIERE-4083.sql') FROM dual
|
||||||
|
;
|
||||||
|
|
|
@ -0,0 +1,102 @@
|
||||||
|
-- Aug 6, 2018 12:04:56 PM MYT
|
||||||
|
-- AP2-473 Improve handling of Spot Rate
|
||||||
|
INSERT INTO AD_Element (AD_Element_ID,ColumnName,Updated,Name,Description,PrintName,AD_Element_UU,IsActive,Created,CreatedBy,UpdatedBy,AD_Client_ID,EntityType,AD_Org_ID) VALUES (203258,'IsOverrideCurrencyRate',TO_TIMESTAMP('2018-08-06 12:04:54','YYYY-MM-DD HH24:MI:SS'),'Override Currency Conversion Rate','Override Currency Conversion Rate','Override Currency Conversion Rate','fa5158e6-cd76-4b51-a423-0e61f1174402','Y',TO_TIMESTAMP('2018-08-06 12:04:54','YYYY-MM-DD HH24:MI:SS'),100,100,0,'D',0)
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Aug 6, 2018 12:06:46 PM MYT
|
||||||
|
INSERT INTO AD_Column (AD_Column_ID,SeqNoSelection,IsSyncDatabase,Version,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsParent,FieldLength,IsSelectionColumn,IsKey,IsAutocomplete,IsAllowLogging,AD_Column_UU,Updated,IsUpdateable,ColumnName,Description,DefaultValue,Name,IsAllowCopy,IsActive,CreatedBy,UpdatedBy,IsAlwaysUpdateable,AD_Client_ID,Created,IsSecure,EntityType,IsEncrypted,FKConstraintType,AD_Element_ID,AD_Table_ID,AD_Reference_ID,IsToolbarButton,AD_Org_ID,IsHtml) VALUES (213664,0,'N',0,'Y','N','N',0,'N',1,'N','N','N','Y','694d7baf-3218-4940-a32e-439a8a8c0fdf',TO_TIMESTAMP('2018-08-06 12:06:45','YYYY-MM-DD HH24:MI:SS'),'Y','IsOverrideCurrencyRate','Override Currency Conversion Rate','N','Override Currency Conversion Rate','Y','Y',100,100,'N',0,TO_TIMESTAMP('2018-08-06 12:06:45','YYYY-MM-DD HH24:MI:SS'),'N','D','N','N',203258,335,20,'N',0,'N')
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Aug 6, 2018 12:07:00 PM MYT
|
||||||
|
UPDATE AD_Column SET IsAllowCopy='N',Updated=TO_TIMESTAMP('2018-08-06 12:07:00','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=213664
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Aug 6, 2018 12:07:06 PM MYT
|
||||||
|
ALTER TABLE C_Payment ADD COLUMN IsOverrideCurrencyRate CHAR(1) DEFAULT 'N' CHECK (IsOverrideCurrencyRate IN ('Y','N')) NOT NULL
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Aug 6, 2018 12:11:52 PM MYT
|
||||||
|
UPDATE AD_Field SET SeqNo=233, DisplayLogic='@C_Currency_ID@!@$C_Currency_ID@ & @IsOverrideCurrencyRateO@=Y', AD_Val_Rule_ID=NULL, SeqNoGrid=223, XPosition=4, AD_Reference_Value_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2018-08-06 12:11:52','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=205670
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Aug 6, 2018 12:12:40 PM MYT
|
||||||
|
UPDATE AD_Field SET SeqNo=232, DisplayLogic='@C_Currency_ID@!@$C_Currency_ID@ & @IsOverrideCurrencyRate@=Y', AD_Val_Rule_ID=NULL, SeqNoGrid=222, XPosition=1, AD_Reference_Value_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2018-08-06 12:12:40','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=205669
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Aug 6, 2018 12:13:30 PM MYT
|
||||||
|
INSERT INTO AD_Field (SortNo,AD_Field_ID,IsEncrypted,DisplayLength,IsSameLine,IsHeading,SeqNo,IsCentrallyMaintained,IsReadOnly,DisplayLogic,Updated,Description,Name,AD_Field_UU,IsDisplayed,IsFieldOnly,CreatedBy,UpdatedBy,IsActive,IsDisplayedGrid,SeqNoGrid,XPosition,IsQuickEntry,AD_Client_ID,Created,ColumnSpan,NumLines,IsAdvancedField,IsDefaultFocus,AD_Column_ID,EntityType,AD_Tab_ID,AD_Org_ID) VALUES (0,205706,'N',0,'N','N',231,'Y','N','@C_Currency_ID@!@$C_Currency_ID@',TO_TIMESTAMP('2018-08-06 12:13:30','YYYY-MM-DD HH24:MI:SS'),'Override Currency Conversion Rate','Override Currency Conversion Rate','29fffeb3-e9dc-4a9d-813f-e54782b9dc19','Y','N',100,100,'Y','Y',221,1,'N',0,TO_TIMESTAMP('2018-08-06 12:13:30','YYYY-MM-DD HH24:MI:SS'),2,1,'N','N',213664,'D',330,0)
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Aug 6, 2018 12:14:06 PM MYT
|
||||||
|
UPDATE AD_Field SET DisplayLogic='@C_Currency_ID@!@$C_Currency_ID@ & @IsOverrideCurrencyRate@=N', AD_Val_Rule_ID=NULL, AD_Reference_Value_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2018-08-06 12:14:06','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=8651
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Aug 6, 2018 12:14:39 PM MYT
|
||||||
|
UPDATE AD_Field SET AD_Val_Rule_ID=NULL, XPosition=2, AD_Reference_Value_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2018-08-06 12:14:39','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=205706
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Aug 6, 2018 3:36:31 PM MYT
|
||||||
|
-- AP2-473 Improve handling of Spot Rate
|
||||||
|
UPDATE AD_Field SET DisplayLogic='@C_Currency_ID@!@$C_Currency_ID@', AD_Val_Rule_ID=NULL, AD_Reference_Value_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2018-08-06 15:36:31','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=8651
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Aug 6, 2018 4:34:56 PM MYT
|
||||||
|
-- AP2-473 Improve handling of Spot Rate
|
||||||
|
UPDATE AD_Column SET Callout=NULL,Updated=TO_TIMESTAMP('2018-08-06 16:34:56','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=12128
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Aug 6, 2018 4:35:17 PM MYT
|
||||||
|
UPDATE AD_Column SET Callout='org.compiere.model.CalloutPayment.amounts',Updated=TO_TIMESTAMP('2018-08-06 16:35:17','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=213664
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Aug 6, 2018 6:16:52 PM MYT
|
||||||
|
-- AP2-473 Improve handling of Spot Rate
|
||||||
|
UPDATE AD_Field SET DisplayLogic='@C_Currency_ID@!@$C_Currency_ID@ & @IsOverrideCurrencyRate@=Y', AD_Val_Rule_ID=NULL, AD_Reference_Value_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2018-08-06 18:16:52','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=205670
|
||||||
|
;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION currencyConvertPayment(
|
||||||
|
p_C_Payment_ID numeric,
|
||||||
|
p_Currency_To_id numeric,
|
||||||
|
p_Amt numeric default null,
|
||||||
|
p_conversionDate timestamp with time zone default null)
|
||||||
|
RETURNS numeric
|
||||||
|
LANGUAGE 'plpgsql'
|
||||||
|
AS $BODY$
|
||||||
|
DECLARE
|
||||||
|
v_PayAmt NUMERIC;
|
||||||
|
v_ConversionType_ID NUMERIC;
|
||||||
|
v_Client_ID NUMERIC;
|
||||||
|
v_Org_ID NUMERIC;
|
||||||
|
v_Currency_ID NUMERIC;
|
||||||
|
v_CurrencyRate NUMERIC;
|
||||||
|
v_ConvertedAmt NUMERIC;
|
||||||
|
v_DateAcct timestamp with time zone;
|
||||||
|
v_BaseCurrency_ID NUMERIC;
|
||||||
|
v_IsOverrideCurrencyRate character(1);
|
||||||
|
BEGIN
|
||||||
|
SELECT AD_Client_ID, AD_Org_ID, DateAcct, C_Currency_ID, C_ConversionType_ID, CurrencyRate, ConvertedAmt, PayAmt, IsOverrideCurrencyRate
|
||||||
|
INTO v_Client_ID, v_Org_ID, v_DateAcct, v_Currency_ID, v_ConversionType_ID, v_CurrencyRate, v_ConvertedAmt, v_PayAmt, v_IsOverrideCurrencyRate
|
||||||
|
FROM C_Payment
|
||||||
|
WHERE C_Payment_ID=p_C_Payment_ID;
|
||||||
|
|
||||||
|
SELECT sc.C_Currency_ID
|
||||||
|
INTO v_BaseCurrency_ID
|
||||||
|
FROM AD_ClientInfo ci
|
||||||
|
JOIN C_AcctSchema sc ON ci.C_AcctSchema1_ID=sc.C_AcctSchema_ID
|
||||||
|
WHERE ci.AD_Client_ID=v_Client_ID;
|
||||||
|
|
||||||
|
IF v_BaseCurrency_ID=p_Currency_To_id AND Coalesce(v_CurrencyRate,0) > 0 AND Coalesce(v_ConvertedAmt,0) != 0 AND v_Currency_ID != p_Currency_To_id AND v_IsOverrideCurrencyRate='Y' THEN
|
||||||
|
IF p_Amt IS NULL THEN
|
||||||
|
RETURN v_ConvertedAmt;
|
||||||
|
ELSE
|
||||||
|
RETURN currencyRound(p_Amt*v_CurrencyRate, p_Currency_To_id, null);
|
||||||
|
END IF;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
RETURN currencyConvert(Coalesce(p_Amt,v_PayAmt), v_Currency_ID, p_Currency_To_id, Coalesce(p_conversionDate,v_DateAcct), v_ConversionType_ID, v_Client_ID, v_Org_ID);
|
||||||
|
END;
|
||||||
|
$BODY$;
|
||||||
|
|
||||||
|
SELECT register_migration_script('202007211900_IDEMPIERE-4083.sql') FROM dual
|
||||||
|
;
|
||||||
|
|
|
@ -0,0 +1,99 @@
|
||||||
|
-- Aug 7, 2018 12:11:37 PM MYT
|
||||||
|
-- AP2-473 Improve handling of Spot Rate
|
||||||
|
INSERT INTO AD_Column (AD_Column_ID,SeqNoSelection,IsSyncDatabase,Version,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsParent,FieldLength,IsSelectionColumn,IsKey,IsAutocomplete,IsAllowLogging,AD_Column_UU,Updated,IsUpdateable,ColumnName,Description,DefaultValue,Name,IsAllowCopy,IsActive,CreatedBy,UpdatedBy,IsAlwaysUpdateable,AD_Client_ID,Created,IsSecure,EntityType,IsEncrypted,FKConstraintType,AD_Element_ID,AD_Table_ID,AD_Reference_ID,IsToolbarButton,AD_Org_ID,IsHtml) VALUES (213667,0,'N',0,'Y','N','N',0,'N',1,'N','N','N','Y','49dfde99-b3e4-48df-b2dc-d178a7ba8391',TO_TIMESTAMP('2018-08-07 12:11:31','YYYY-MM-DD HH24:MI:SS'),'Y','IsOverrideCurrencyRate','Override Currency Conversion Rate','N','Override Currency Conversion Rate','Y','Y',100,100,'N',0,TO_TIMESTAMP('2018-08-07 12:11:31','YYYY-MM-DD HH24:MI:SS'),'N','D','N','N',203258,318,20,'N',0,'N')
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Aug 7, 2018 12:11:44 PM MYT
|
||||||
|
ALTER TABLE C_Invoice ADD COLUMN IsOverrideCurrencyRate CHAR(1) DEFAULT 'N' CHECK (IsOverrideCurrencyRate IN ('Y','N')) NOT NULL
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Aug 7, 2018 12:12:34 PM MYT
|
||||||
|
INSERT INTO AD_Column (AD_Column_ID,SeqNoSelection,IsSyncDatabase,Version,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsParent,FieldLength,IsSelectionColumn,IsKey,IsAutocomplete,IsAllowLogging,AD_Column_UU,Updated,IsUpdateable,ColumnName,Description,Help,Name,IsAllowCopy,IsActive,CreatedBy,UpdatedBy,IsAlwaysUpdateable,AD_Client_ID,Created,IsSecure,EntityType,IsEncrypted,AD_Element_ID,AD_Table_ID,AD_Reference_ID,IsToolbarButton,AD_Org_ID,IsHtml) VALUES (213668,0,'N',0,'N','N','N',0,'N',22,'N','N','N','Y','a73b45e7-f38f-4447-8657-1eb475e6e153',TO_TIMESTAMP('2018-08-07 12:12:28','YYYY-MM-DD HH24:MI:SS'),'Y','CurrencyRate','Currency Conversion Rate','The Currency Conversion Rate indicates the rate to use when converting the source currency to the accounting currency','Rate','Y','Y',100,100,'N',0,TO_TIMESTAMP('2018-08-07 12:12:28','YYYY-MM-DD HH24:MI:SS'),'N','D','N',253,318,22,'N',0,'N')
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Aug 7, 2018 12:12:40 PM MYT
|
||||||
|
ALTER TABLE C_Invoice ADD COLUMN CurrencyRate NUMERIC DEFAULT NULL
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Aug 7, 2018 12:50:01 PM MYT
|
||||||
|
-- AP2-473 Improve handling of Spot Rate
|
||||||
|
INSERT INTO AD_Field (SortNo,AD_Field_ID,IsEncrypted,DisplayLength,IsSameLine,IsHeading,SeqNo,IsCentrallyMaintained,IsReadOnly,DisplayLogic,Updated,Description,Name,AD_Field_UU,IsDisplayed,IsFieldOnly,CreatedBy,UpdatedBy,IsActive,IsDisplayedGrid,SeqNoGrid,XPosition,IsQuickEntry,AD_Client_ID,Created,ColumnSpan,NumLines,IsAdvancedField,IsDefaultFocus,AD_Column_ID,EntityType,AD_Tab_ID,AD_Org_ID) VALUES (0,205806,'N',0,'N','N',171,'Y','N','@C_Currency_ID@!@$C_Currency_ID@',TO_TIMESTAMP('2018-08-07 12:49:55','YYYY-MM-DD HH24:MI:SS'),'Override Currency Conversion Rate','Override Currency Conversion Rate','a28728cb-1b43-493f-bf29-481604eb1dcb','Y','N',100,100,'Y','Y',171,2,'N',0,TO_TIMESTAMP('2018-08-07 12:49:55','YYYY-MM-DD HH24:MI:SS'),2,1,'N','N',213667,'D',263,0)
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Aug 7, 2018 12:51:28 PM MYT
|
||||||
|
INSERT INTO AD_Field (SortNo,AD_Field_ID,IsEncrypted,DisplayLength,IsSameLine,IsHeading,SeqNo,IsCentrallyMaintained,IsReadOnly,Help,DisplayLogic,Updated,Description,Name,AD_Field_UU,IsDisplayed,IsFieldOnly,CreatedBy,UpdatedBy,IsActive,IsDisplayedGrid,SeqNoGrid,XPosition,IsQuickEntry,AD_Client_ID,Created,ColumnSpan,NumLines,IsAdvancedField,IsDefaultFocus,AD_Column_ID,EntityType,AD_Tab_ID,AD_Org_ID) VALUES (0,205807,'N',0,'N','N',172,'Y','N','The Currency Conversion Rate indicates the rate to use when converting the source currency to the accounting currency','@C_Currency_ID@!@$C_Currency_ID@ & @IsOverrideCurrencyRate@=Y',TO_TIMESTAMP('2018-08-07 12:51:22','YYYY-MM-DD HH24:MI:SS'),'Currency Conversion Rate','Rate','c8f3055c-77ff-4fa8-bf79-fa1e60f8693f','Y','N',100,100,'Y','Y',172,4,'N',0,TO_TIMESTAMP('2018-08-07 12:51:22','YYYY-MM-DD HH24:MI:SS'),2,1,'N','N',213668,'D',263,0)
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Aug 7, 2018 12:53:55 PM MYT
|
||||||
|
INSERT INTO AD_Field (SortNo,AD_Field_ID,IsEncrypted,DisplayLength,IsSameLine,IsHeading,SeqNo,IsCentrallyMaintained,IsReadOnly,DisplayLogic,Updated,Description,Name,AD_Field_UU,IsDisplayed,IsFieldOnly,CreatedBy,UpdatedBy,IsActive,IsDisplayedGrid,SeqNoGrid,XPosition,IsQuickEntry,AD_Client_ID,Created,ColumnSpan,NumLines,IsAdvancedField,IsDefaultFocus,AD_Column_ID,EntityType,AD_Tab_ID,AD_Org_ID) VALUES (0,205808,'N',0,'N','N',171,'Y','N','@C_Currency_ID@!@$C_Currency_ID@',TO_TIMESTAMP('2018-08-07 12:53:50','YYYY-MM-DD HH24:MI:SS'),'Override Currency Conversion Rate','Override Currency Conversion Rate','8adaa192-2b66-477c-a442-4902fcc8a377','Y','N',100,100,'Y','Y',171,2,'N',0,TO_TIMESTAMP('2018-08-07 12:53:50','YYYY-MM-DD HH24:MI:SS'),2,1,'N','N',213667,'D',290,0)
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Aug 7, 2018 12:55:15 PM MYT
|
||||||
|
INSERT INTO AD_Field (SortNo,AD_Field_ID,IsEncrypted,DisplayLength,IsSameLine,IsHeading,SeqNo,IsCentrallyMaintained,IsReadOnly,Help,DisplayLogic,Updated,Description,Name,AD_Field_UU,IsDisplayed,IsFieldOnly,CreatedBy,UpdatedBy,IsActive,IsDisplayedGrid,SeqNoGrid,XPosition,IsQuickEntry,AD_Client_ID,Created,ColumnSpan,NumLines,IsAdvancedField,IsDefaultFocus,AD_Column_ID,EntityType,AD_Tab_ID,AD_Org_ID) VALUES (0,205809,'N',0,'N','N',172,'Y','N','The Currency Conversion Rate indicates the rate to use when converting the source currency to the accounting currency','@C_Currency_ID@!@$C_Currency_ID@ & @IsOverrideCurrencyRate@=Y',TO_TIMESTAMP('2018-08-07 12:55:09','YYYY-MM-DD HH24:MI:SS'),'Currency Conversion Rate','Rate','654aef87-77d6-4640-9366-4e2d16de610c','Y','N',100,100,'Y','Y',1,4,'N',0,TO_TIMESTAMP('2018-08-07 12:55:09','YYYY-MM-DD HH24:MI:SS'),2,1,'N','N',213668,'D',290,0)
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Aug 7, 2018 5:24:49 PM MYT
|
||||||
|
-- AP2-473 Improve handling of Spot Rate
|
||||||
|
UPDATE AD_StatusLine SET SQLStatement='SELECT COUNT(DISTINCT C_InvoiceLine_ID) AS Lines,o.TotalLines,o.GrandTotal,c.ISO_Code, currencyConvertInvoice(o.C_Invoice_ID,@$C_Currency_ID@,o.GrandTotal,o.DateAcct) AS ConvAmt, o.GrandTotal-o.TotalLines AS TaxAmt
|
||||||
|
FROM C_Invoice o
|
||||||
|
INNER JOIN C_Currency c ON (o.C_Currency_ID=c.C_Currency_ID)
|
||||||
|
LEFT JOIN C_InvoiceLine l ON (o.C_Invoice_ID=l.C_Invoice_ID)
|
||||||
|
WHERE o.C_Invoice_ID=@C_Invoice_ID@
|
||||||
|
GROUP BY o.C_Currency_ID, c.ISO_Code, o.TotalLines, o.GrandTotal, o.DateAcct, o.AD_Client_ID, o.AD_Org_ID',Updated=TO_TIMESTAMP('2018-08-07 17:24:49','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_StatusLine_ID=200002
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Aug 7, 2018 5:26:55 PM MYT
|
||||||
|
UPDATE AD_StatusLine SET SQLStatement='SELECT COUNT(DISTINCT C_InvoiceLine_ID) AS Lines,o.TotalLines,o.GrandTotal,c.ISO_Code, currencyConvertInvoice(o.C_Invoice_ID,@$C_Currency_ID@,o.GrandTotal,o.DateAcct) AS ConvAmt, o.GrandTotal-o.TotalLines AS TaxAmt
|
||||||
|
FROM C_Invoice o
|
||||||
|
INNER JOIN C_Currency c ON (o.C_Currency_ID=c.C_Currency_ID)
|
||||||
|
LEFT JOIN C_InvoiceLine l ON (o.C_Invoice_ID=l.C_Invoice_ID)
|
||||||
|
WHERE o.C_Invoice_ID=@C_Invoice_ID@
|
||||||
|
GROUP BY o.C_Invoice_ID, c.ISO_Code, o.TotalLines, o.GrandTotal, o.DateAcct, o.AD_Client_ID, o.AD_Org_ID',Updated=TO_TIMESTAMP('2018-08-07 17:26:55','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_StatusLine_ID=200002
|
||||||
|
;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION currencyConvertInvoice(
|
||||||
|
p_c_invoice_id numeric,
|
||||||
|
p_currency_to_id numeric,
|
||||||
|
p_amt numeric DEFAULT NULL::numeric,
|
||||||
|
p_conversiondate timestamp with time zone DEFAULT NULL::timestamp with time zone)
|
||||||
|
RETURNS numeric
|
||||||
|
LANGUAGE 'plpgsql'
|
||||||
|
|
||||||
|
COST 100
|
||||||
|
VOLATILE
|
||||||
|
AS $BODY$
|
||||||
|
|
||||||
|
DECLARE
|
||||||
|
v_GrandTotal NUMERIC;
|
||||||
|
v_ConversionType_ID NUMERIC;
|
||||||
|
v_Client_ID NUMERIC;
|
||||||
|
v_Org_ID NUMERIC;
|
||||||
|
v_Currency_ID NUMERIC;
|
||||||
|
v_CurrencyRate NUMERIC;
|
||||||
|
v_DateAcct timestamp with time zone;
|
||||||
|
v_BaseCurrency_ID NUMERIC;
|
||||||
|
v_IsOverrideCurrencyRate character(1);
|
||||||
|
BEGIN
|
||||||
|
SELECT AD_Client_ID, AD_Org_ID, DateAcct, C_Currency_ID, C_ConversionType_ID, CurrencyRate, GrandTotal, IsOverrideCurrencyRate
|
||||||
|
INTO v_Client_ID, v_Org_ID, v_DateAcct, v_Currency_ID, v_ConversionType_ID, v_CurrencyRate, v_GrandTotal, v_IsOverrideCurrencyRate
|
||||||
|
FROM C_Invoice
|
||||||
|
WHERE C_Invoice_ID=p_C_Invoice_ID;
|
||||||
|
|
||||||
|
SELECT sc.C_Currency_ID
|
||||||
|
INTO v_BaseCurrency_ID
|
||||||
|
FROM AD_ClientInfo ci
|
||||||
|
JOIN C_AcctSchema sc ON ci.C_AcctSchema1_ID=sc.C_AcctSchema_ID
|
||||||
|
WHERE ci.AD_Client_ID=v_Client_ID;
|
||||||
|
|
||||||
|
IF v_BaseCurrency_ID=p_Currency_To_id AND Coalesce(v_CurrencyRate,0) > 0 AND v_Currency_ID != p_Currency_To_id AND v_IsOverrideCurrencyRate='Y' THEN
|
||||||
|
RETURN currencyRound(Coalesce(p_Amt,v_GrandTotal)*v_CurrencyRate, p_Currency_To_id, null);
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
RETURN currencyConvert(Coalesce(p_Amt,v_GrandTotal), v_Currency_ID, p_Currency_To_id, Coalesce(p_conversionDate,v_DateAcct), v_ConversionType_ID, v_Client_ID, v_Org_ID);
|
||||||
|
END;
|
||||||
|
|
||||||
|
$BODY$;
|
||||||
|
|
||||||
|
SELECT register_migration_script('202007212000_IDEMPIERE-4083.sql') FROM dual
|
||||||
|
;
|
||||||
|
|
|
@ -105,9 +105,8 @@ public class CalloutPaySelection extends CalloutEngine
|
||||||
BigDecimal DiscountAmt = Env.ZERO;
|
BigDecimal DiscountAmt = Env.ZERO;
|
||||||
Boolean IsSOTrx = Boolean.FALSE;
|
Boolean IsSOTrx = Boolean.FALSE;
|
||||||
String sql = "SELECT"
|
String sql = "SELECT"
|
||||||
+ " currencyConvert("
|
+ " currencyConvertInvoice("
|
||||||
+ "invoiceOpen(i.C_Invoice_ID, 0)"
|
+ "i.C_Invoice_ID, ba.C_Currency_ID, invoiceOpen(i.C_Invoice_ID, 0), i.DateInvoiced),"
|
||||||
+ ", i.C_Currency_ID,ba.C_Currency_ID, i.DateInvoiced, i.C_ConversionType_ID, i.AD_Client_ID, i.AD_Org_ID),"
|
|
||||||
+ " currencyConvert("
|
+ " currencyConvert("
|
||||||
+ "paymentTermDiscount(i.GrandTotal,i.C_Currency_ID,i.C_PaymentTerm_ID,i.DateInvoiced, ?)"
|
+ "paymentTermDiscount(i.GrandTotal,i.C_Currency_ID,i.C_PaymentTerm_ID,i.DateInvoiced, ?)"
|
||||||
+ ", i.C_Currency_ID, ba.C_Currency_ID, i.DateInvoiced, i.C_ConversionType_ID, i.AD_Client_ID, i.AD_Org_ID)"
|
+ ", i.C_Currency_ID, ba.C_Currency_ID, i.DateInvoiced, i.C_ConversionType_ID, i.AD_Client_ID, i.AD_Org_ID)"
|
||||||
|
|
|
@ -27,6 +27,7 @@ import java.util.logging.Level;
|
||||||
|
|
||||||
import org.compiere.util.DB;
|
import org.compiere.util.DB;
|
||||||
import org.compiere.util.Env;
|
import org.compiere.util.Env;
|
||||||
|
import org.compiere.util.Msg;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Payment Callouts. org.compiere.model.CalloutPayment.*
|
* Payment Callouts. org.compiere.model.CalloutPayment.*
|
||||||
|
@ -124,6 +125,7 @@ public class CalloutPayment extends CalloutEngine
|
||||||
{
|
{
|
||||||
DB.close (rs, pstmt);
|
DB.close (rs, pstmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
return docType (ctx, WindowNo, mTab, mField, value);
|
return docType (ctx, WindowNo, mTab, mField, value);
|
||||||
} // invoice
|
} // invoice
|
||||||
|
|
||||||
|
@ -317,6 +319,81 @@ public class CalloutPayment extends CalloutEngine
|
||||||
{
|
{
|
||||||
C_InvoicePaySchedule_ID = Env.getContextAsInt (ctx, WindowNo, Env.TAB_INFO, "C_InvoicePaySchedule_ID");
|
C_InvoicePaySchedule_ID = Env.getContextAsInt (ctx, WindowNo, Env.TAB_INFO, "C_InvoicePaySchedule_ID");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get Currency Info
|
||||||
|
Integer curr_int = (Integer) mTab.getValue ("C_Currency_ID");
|
||||||
|
if (curr_int == null)
|
||||||
|
curr_int = Integer.valueOf(0);
|
||||||
|
int C_Currency_ID = curr_int.intValue ();
|
||||||
|
MCurrency currency = MCurrency.get (ctx, C_Currency_ID);
|
||||||
|
int C_ConversionType_ID = 0;
|
||||||
|
Integer ii = (Integer)mTab.getValue ("C_ConversionType_ID");
|
||||||
|
if (ii != null)
|
||||||
|
C_ConversionType_ID = ii.intValue ();
|
||||||
|
int AD_Client_ID = Env.getContextAsInt (ctx, WindowNo, "AD_Client_ID");
|
||||||
|
int AD_Org_ID = Env.getContextAsInt (ctx, WindowNo, "AD_Org_ID");
|
||||||
|
|
||||||
|
if (colName.equals(I_C_Payment.COLUMNNAME_CurrencyRate))
|
||||||
|
{
|
||||||
|
if (value != null)
|
||||||
|
{
|
||||||
|
BigDecimal baseCurrencyRate = (BigDecimal) value;
|
||||||
|
if (baseCurrencyRate.signum() < 0)
|
||||||
|
{
|
||||||
|
mTab.setValue(colName, oldValue);
|
||||||
|
mTab.fireDataStatusEEvent("Invalid", Msg.getElement(ctx, colName), true);
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
else if (baseCurrencyRate.signum() == 0)
|
||||||
|
{
|
||||||
|
int baseCurrencyId = Env.getContextAsInt(ctx, "$C_Currency_ID");
|
||||||
|
Timestamp dateAcct = (Timestamp) mTab.getValue(I_C_Payment.COLUMNNAME_DateAcct);
|
||||||
|
baseCurrencyRate = MConversionRate.getRate(C_Currency_ID, baseCurrencyId, dateAcct, C_ConversionType_ID, AD_Client_ID, AD_Org_ID);
|
||||||
|
if (baseCurrencyRate == null)
|
||||||
|
return "";
|
||||||
|
mTab.setValue(I_C_Payment.COLUMNNAME_CurrencyRate, baseCurrencyRate);
|
||||||
|
}
|
||||||
|
BigDecimal payAmt = (BigDecimal) mTab.getValue(I_C_Payment.COLUMNNAME_PayAmt);
|
||||||
|
if (payAmt != null)
|
||||||
|
{
|
||||||
|
BigDecimal convertedAmt = payAmt.multiply(baseCurrencyRate);
|
||||||
|
mTab.setValue(I_C_Payment.COLUMNNAME_ConvertedAmt, convertedAmt);
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mTab.setValue(colName, oldValue);
|
||||||
|
mTab.fireDataStatusEEvent("Invalid", Msg.getElement(ctx, colName), true);
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (colName.equals(I_C_Payment.COLUMNNAME_ConvertedAmt))
|
||||||
|
{
|
||||||
|
if (value != null)
|
||||||
|
{
|
||||||
|
BigDecimal convertedAmt = (BigDecimal) value;
|
||||||
|
if (convertedAmt.signum() == 0)
|
||||||
|
{
|
||||||
|
mTab.setValue(colName, oldValue);
|
||||||
|
mTab.fireDataStatusEEvent("Invalid", Msg.getElement(ctx, colName), true);
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
BigDecimal payAmt = (BigDecimal) mTab.getValue(I_C_Payment.COLUMNNAME_PayAmt);
|
||||||
|
if (payAmt != null)
|
||||||
|
{
|
||||||
|
BigDecimal baseCurrencyRate = convertedAmt.divide(payAmt, 6, RoundingMode.HALF_UP);
|
||||||
|
mTab.setValue(I_C_Payment.COLUMNNAME_CurrencyRate, baseCurrencyRate);
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mTab.setValue(colName, oldValue);
|
||||||
|
mTab.fireDataStatusEEvent("Invalid", Msg.getElement(ctx, colName), true);
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
// Get Open Amount & Invoice Currency
|
// Get Open Amount & Invoice Currency
|
||||||
BigDecimal InvoiceOpenAmt = Env.ZERO;
|
BigDecimal InvoiceOpenAmt = Env.ZERO;
|
||||||
int C_Currency_Invoice_ID = 0;
|
int C_Currency_Invoice_ID = 0;
|
||||||
|
@ -377,19 +454,8 @@ public class CalloutPayment extends CalloutEngine
|
||||||
OverUnderAmt = Env.ZERO;
|
OverUnderAmt = Env.ZERO;
|
||||||
if (log.isLoggable(Level.FINE)) log.fine ("Pay=" + PayAmt + ", Discount=" + DiscountAmt + ", WriteOff="
|
if (log.isLoggable(Level.FINE)) log.fine ("Pay=" + PayAmt + ", Discount=" + DiscountAmt + ", WriteOff="
|
||||||
+ WriteOffAmt + ", OverUnderAmt=" + OverUnderAmt);
|
+ WriteOffAmt + ", OverUnderAmt=" + OverUnderAmt);
|
||||||
// Get Currency Info
|
|
||||||
Integer curr_int = (Integer) mTab.getValue ("C_Currency_ID");
|
Timestamp ConvDate = (Timestamp)mTab.getValue ("DateTrx");
|
||||||
if (curr_int == null)
|
|
||||||
curr_int = Integer.valueOf(0);
|
|
||||||
int C_Currency_ID = curr_int.intValue ();
|
|
||||||
MCurrency currency = MCurrency.get (ctx, C_Currency_ID);
|
|
||||||
Timestamp ConvDate = (Timestamp)mTab.getValue ("DateTrx");
|
|
||||||
int C_ConversionType_ID = 0;
|
|
||||||
Integer ii = (Integer)mTab.getValue ("C_ConversionType_ID");
|
|
||||||
if (ii != null)
|
|
||||||
C_ConversionType_ID = ii.intValue ();
|
|
||||||
int AD_Client_ID = Env.getContextAsInt (ctx, WindowNo, "AD_Client_ID");
|
|
||||||
int AD_Org_ID = Env.getContextAsInt (ctx, WindowNo, "AD_Org_ID");
|
|
||||||
// Get Currency Rate
|
// Get Currency Rate
|
||||||
BigDecimal CurrencyRate = Env.ONE;
|
BigDecimal CurrencyRate = Env.ONE;
|
||||||
if ((C_Currency_ID > 0 && C_Currency_Invoice_ID > 0 && C_Currency_ID != C_Currency_Invoice_ID)
|
if ((C_Currency_ID > 0 && C_Currency_Invoice_ID > 0 && C_Currency_ID != C_Currency_Invoice_ID)
|
||||||
|
@ -417,21 +483,46 @@ public class CalloutPayment extends CalloutEngine
|
||||||
+ InvoiceOpenAmt);
|
+ InvoiceOpenAmt);
|
||||||
}
|
}
|
||||||
// Currency Changed - convert all
|
// Currency Changed - convert all
|
||||||
if (colName.equals ("C_Currency_ID")
|
if (colName.equals ("C_Currency_ID"))
|
||||||
|| colName.equals ("C_ConversionType_ID"))
|
|
||||||
{
|
{
|
||||||
PayAmt = PayAmt.multiply (CurrencyRate).setScale (
|
if (oldValue != null && oldValue instanceof Integer)
|
||||||
currency.getStdPrecision (), RoundingMode.HALF_UP);
|
{
|
||||||
mTab.setValue ("PayAmt", PayAmt);
|
BigDecimal conversionRate = null;
|
||||||
DiscountAmt = DiscountAmt.multiply (CurrencyRate).setScale (
|
int oldId = (int) oldValue;
|
||||||
currency.getStdPrecision (), RoundingMode.HALF_UP);
|
if (oldId > 0 && oldId == C_Currency_Invoice_ID)
|
||||||
mTab.setValue ("DiscountAmt", DiscountAmt);
|
{
|
||||||
WriteOffAmt = WriteOffAmt.multiply (CurrencyRate).setScale (
|
conversionRate = CurrencyRate;
|
||||||
currency.getStdPrecision (), RoundingMode.HALF_UP);
|
}
|
||||||
mTab.setValue ("WriteOffAmt", WriteOffAmt);
|
else if (oldId > 0)
|
||||||
OverUnderAmt = OverUnderAmt.multiply (CurrencyRate).setScale (
|
{
|
||||||
currency.getStdPrecision (), RoundingMode.HALF_UP);
|
conversionRate = MConversionRate.getRate (oldId,
|
||||||
mTab.setValue ("OverUnderAmt", OverUnderAmt);
|
C_Currency_ID, ConvDate, C_ConversionType_ID, AD_Client_ID,
|
||||||
|
AD_Org_ID);
|
||||||
|
if (conversionRate == null)
|
||||||
|
{
|
||||||
|
conversionRate = MConversionRate.getRate (C_Currency_ID,
|
||||||
|
oldId, ConvDate, C_ConversionType_ID, AD_Client_ID,
|
||||||
|
AD_Org_ID);
|
||||||
|
if (conversionRate != null)
|
||||||
|
conversionRate = new BigDecimal("1").divide(conversionRate, 12, RoundingMode.HALF_UP);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (conversionRate != null)
|
||||||
|
{
|
||||||
|
PayAmt = PayAmt.multiply (conversionRate).setScale (
|
||||||
|
currency.getStdPrecision (), RoundingMode.HALF_UP);
|
||||||
|
mTab.setValue ("PayAmt", PayAmt);
|
||||||
|
DiscountAmt = DiscountAmt.multiply (conversionRate).setScale (
|
||||||
|
currency.getStdPrecision (), RoundingMode.HALF_UP);
|
||||||
|
mTab.setValue ("DiscountAmt", DiscountAmt);
|
||||||
|
WriteOffAmt = WriteOffAmt.multiply (conversionRate).setScale (
|
||||||
|
currency.getStdPrecision (), RoundingMode.HALF_UP);
|
||||||
|
mTab.setValue ("WriteOffAmt", WriteOffAmt);
|
||||||
|
OverUnderAmt = OverUnderAmt.multiply (conversionRate).setScale (
|
||||||
|
currency.getStdPrecision (), RoundingMode.HALF_UP);
|
||||||
|
mTab.setValue ("OverUnderAmt", OverUnderAmt);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// No Invoice - Set Discount, Writeoff, Under/Over to 0
|
// No Invoice - Set Discount, Writeoff, Under/Over to 0
|
||||||
else if (C_Invoice_ID == 0)
|
else if (C_Invoice_ID == 0)
|
||||||
|
@ -495,6 +586,38 @@ public class CalloutPayment extends CalloutEngine
|
||||||
mTab.setValue ("PayAmt", PayAmt);
|
mTab.setValue ("PayAmt", PayAmt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (colName.equals(I_C_Payment.COLUMNNAME_C_Currency_ID) || colName.equals(I_C_Payment.COLUMNNAME_PayAmt)
|
||||||
|
|| colName.equals(I_C_Payment.COLUMNNAME_IsOverrideCurrencyRate) ) {
|
||||||
|
Boolean override = (Boolean)(colName.equals(I_C_Payment.COLUMNNAME_IsOverrideCurrencyRate) ? value : mTab.getValue(I_C_Payment.COLUMNNAME_IsOverrideCurrencyRate));
|
||||||
|
int baseCurrencyId = Env.getContextAsInt(ctx, "$C_Currency_ID");
|
||||||
|
if (baseCurrencyId == C_Currency_ID) {
|
||||||
|
mTab.setValue(I_C_Payment.COLUMNNAME_IsOverrideCurrencyRate, false);
|
||||||
|
mTab.setValue(I_C_Payment.COLUMNNAME_CurrencyRate, null);
|
||||||
|
mTab.setValue(I_C_Payment.COLUMNNAME_ConvertedAmt, null);
|
||||||
|
}
|
||||||
|
else if (!override) {
|
||||||
|
mTab.setValue(I_C_Payment.COLUMNNAME_CurrencyRate, null);
|
||||||
|
mTab.setValue(I_C_Payment.COLUMNNAME_ConvertedAmt, null);
|
||||||
|
} else {
|
||||||
|
BigDecimal payAmt = colName.equals(I_C_Payment.COLUMNNAME_PayAmt) ? (BigDecimal) value : (BigDecimal)mTab.getValue ("PayAmt");
|
||||||
|
if (payAmt == null)
|
||||||
|
return "";
|
||||||
|
if (colName.equals(I_C_Payment.COLUMNNAME_PayAmt) && oldValue != null) {
|
||||||
|
BigDecimal oldPayAmt = (BigDecimal) oldValue;
|
||||||
|
BigDecimal baseConversionRate = (BigDecimal) mTab.getValue(I_C_Payment.COLUMNNAME_CurrencyRate);
|
||||||
|
BigDecimal converted = (BigDecimal) mTab.getValue(I_C_Payment.COLUMNNAME_ConvertedAmt);
|
||||||
|
if (baseConversionRate != null && converted != null && oldPayAmt.multiply(baseConversionRate).compareTo(converted)==0) {
|
||||||
|
converted = payAmt.multiply(baseConversionRate);
|
||||||
|
int stdPrecision = MCurrency.getStdPrecision(ctx, baseCurrencyId);
|
||||||
|
if (converted.scale() > stdPrecision)
|
||||||
|
converted = converted.setScale(stdPrecision, RoundingMode.HALF_UP);
|
||||||
|
mTab.setValue(I_C_Payment.COLUMNNAME_ConvertedAmt, converted);
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return "";
|
return "";
|
||||||
} // amounts
|
} // amounts
|
||||||
} // CalloutPayment
|
} // CalloutPayment
|
||||||
|
|
|
@ -124,17 +124,19 @@ public class Aging extends SvrProcess
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
String s = ",oi.C_Currency_ID," + p_ConvertCurrencyTo_ID + ",oi.DateAcct,oi.C_ConversionType_ID,oi.AD_Client_ID,oi.AD_Org_ID)";
|
String s = "," + p_ConvertCurrencyTo_ID;
|
||||||
sql.append("currencyConvert(oi.GrandTotal").append(s); // 11
|
sql.append("currencyConvertInvoice(oi.C_Invoice_ID").append(s).append(")"); // 11
|
||||||
if (!p_DateAcct)
|
if (!p_DateAcct)
|
||||||
{
|
{
|
||||||
sql.append(", currencyConvert(oi.PaidAmt").append(s) // 12
|
sql.append(", currencyConvertInvoice(oi.C_Invoice_ID").append(s) // 12
|
||||||
.append(", currencyConvert(oi.OpenAmt").append(s); // 13
|
.append(",oi.PaidAmt), currencyConvertInvoice(oi.C_Invoice_ID").append(s).append(",oi.OpenAmt)"); // 13
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sql.append(", currencyConvert(invoicePaidToDate(oi.C_Invoice_ID, oi.C_Currency_ID, 1,"+dateacct+")").append(s) // 12
|
sql.append(", currencyConvertInvoice(oi.C_Invoice_ID").append(s) // 12
|
||||||
.append(", currencyConvert(invoiceOpenToDate(oi.C_Invoice_ID,oi.C_InvoicePaySchedule_ID,"+dateacct+")").append(s); // 13
|
.append(",invoicePaidToDate(oi.C_Invoice_ID, oi.C_Currency_ID, 1,"+dateacct+")), "
|
||||||
|
+ "currencyConvertInvoice(oi.C_Invoice_ID").append(s)
|
||||||
|
.append(",invoiceOpenToDate(oi.C_Invoice_ID,oi.C_InvoicePaySchedule_ID,"+dateacct+"))"); // 13
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sql.append(",oi.C_Activity_ID,oi.C_Campaign_ID,oi.C_Project_ID,oi.AD_Org_ID "); // 14..17
|
sql.append(",oi.C_Activity_ID,oi.C_Campaign_ID,oi.C_Project_ID,oi.AD_Org_ID "); // 14..17
|
||||||
|
|
|
@ -125,11 +125,11 @@ public class PaySelectionCreateFrom extends SvrProcess
|
||||||
|
|
||||||
StringBuilder sql = new StringBuilder("SELECT C_Invoice_ID,") // 1
|
StringBuilder sql = new StringBuilder("SELECT C_Invoice_ID,") // 1
|
||||||
// Open
|
// Open
|
||||||
.append(" currencyConvert(invoiceOpen(i.C_Invoice_ID, i.C_InvoicePaySchedule_ID)")
|
.append(" currencyConvertInvoice(i.C_Invoice_ID")
|
||||||
.append(",i.C_Currency_ID, ?,?, i.C_ConversionType_ID,i.AD_Client_ID,i.AD_Org_ID) AS PayAmt,") // 2 ##p1/p2 Currency_To,PayDate
|
.append(",?,invoiceOpen(i.C_Invoice_ID, i.C_InvoicePaySchedule_ID), ?) AS PayAmt,") // ##1/2 Currency_To,PayDate
|
||||||
// Discount
|
// Discount
|
||||||
.append(" currencyConvert(invoiceDiscount(i.C_Invoice_ID,?,i.C_InvoicePaySchedule_ID)") // ##p3 PayDate
|
.append(" currencyConvertInvoice(i.C_Invoice_ID")
|
||||||
.append(",i.C_Currency_ID, ?,?,i.C_ConversionType_ID,i.AD_Client_ID,i.AD_Org_ID) AS DiscountAmt,") // 3 ##p4/p5 Currency_To,PayDate
|
.append(",?,invoiceDiscount(i.C_Invoice_ID,?,i.C_InvoicePaySchedule_ID),?) AS DiscountAmt,") // ##3/4/5 Currency_To,PayDate,PayDate
|
||||||
.append(" PaymentRule, IsSOTrx, ") // 4..5
|
.append(" PaymentRule, IsSOTrx, ") // 4..5
|
||||||
.append(" currencyConvert(invoiceWriteOff(i.C_Invoice_ID) ")
|
.append(" currencyConvert(invoiceWriteOff(i.C_Invoice_ID) ")
|
||||||
.append(",i.C_Currency_ID, ?,?,i.C_ConversionType_ID,i.AD_Client_ID,i.AD_Org_ID) AS WriteOffAmt ") // 6 ##p6/p7 Currency_To,PayDate
|
.append(",i.C_Currency_ID, ?,?,i.C_ConversionType_ID,i.AD_Client_ID,i.AD_Org_ID) AS WriteOffAmt ") // 6 ##p6/p7 Currency_To,PayDate
|
||||||
|
@ -233,9 +233,9 @@ public class PaySelectionCreateFrom extends SvrProcess
|
||||||
pstmt.setInt (index++, C_CurrencyTo_ID);
|
pstmt.setInt (index++, C_CurrencyTo_ID);
|
||||||
pstmt.setTimestamp(index++, psel.getPayDate());
|
pstmt.setTimestamp(index++, psel.getPayDate());
|
||||||
//
|
//
|
||||||
pstmt.setTimestamp(index++, psel.getPayDate());
|
|
||||||
pstmt.setInt (index++, C_CurrencyTo_ID);
|
pstmt.setInt (index++, C_CurrencyTo_ID);
|
||||||
pstmt.setTimestamp(index++, psel.getPayDate());
|
pstmt.setTimestamp(index++, psel.getPayDate());
|
||||||
|
pstmt.setTimestamp(index++, psel.getPayDate());
|
||||||
pstmt.setInt (index++, C_CurrencyTo_ID);
|
pstmt.setInt (index++, C_CurrencyTo_ID);
|
||||||
pstmt.setTimestamp(index++, psel.getPayDate());
|
pstmt.setTimestamp(index++, psel.getPayDate());
|
||||||
//
|
//
|
||||||
|
|
|
@ -1102,7 +1102,7 @@ public abstract class Doc
|
||||||
m_period = MPeriod.get(getCtx(), ii.intValue());
|
m_period = MPeriod.get(getCtx(), ii.intValue());
|
||||||
}
|
}
|
||||||
if (m_period == null)
|
if (m_period == null)
|
||||||
m_period = MPeriod.get(getCtx(), getDateAcct(), getAD_Org_ID(), m_trxName);
|
m_period = MPeriod.get(getCtx(), getDateAcct(), getAD_Org_ID(), (String)null);
|
||||||
// Is Period Open?
|
// Is Period Open?
|
||||||
if (m_period != null
|
if (m_period != null
|
||||||
&& m_period.isOpen(getDocumentType(), getDateAcct()))
|
&& m_period.isOpen(getDocumentType(), getDateAcct()))
|
||||||
|
@ -1690,6 +1690,11 @@ public abstract class Doc
|
||||||
return 0;
|
return 0;
|
||||||
} // getC_ConversionType_ID
|
} // getC_ConversionType_ID
|
||||||
|
|
||||||
|
public BigDecimal getCurrencyRate()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get GL_Category_ID
|
* Get GL_Category_ID
|
||||||
* @return category
|
* @return category
|
||||||
|
@ -1707,8 +1712,8 @@ public abstract class Doc
|
||||||
} // getGL_Category_ID
|
} // getGL_Category_ID
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get GL_Category_ID
|
* Get getGL_Budget_ID
|
||||||
* @return category
|
* @return budget
|
||||||
*/
|
*/
|
||||||
public int getGL_Budget_ID()
|
public int getGL_Budget_ID()
|
||||||
{
|
{
|
||||||
|
@ -2319,6 +2324,13 @@ public abstract class Doc
|
||||||
return m_fact;
|
return m_fact;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return MAcctSchema
|
||||||
|
*/
|
||||||
|
protected MAcctSchema getAcctSchema() {
|
||||||
|
return m_as;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return document whether need to defer posting or not
|
* Return document whether need to defer posting or not
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -115,6 +115,7 @@ public class DocLine
|
||||||
private int m_C_ConversionType_ID = -1;
|
private int m_C_ConversionType_ID = -1;
|
||||||
/** Period */
|
/** Period */
|
||||||
private int m_C_Period_ID = -1;
|
private int m_C_Period_ID = -1;
|
||||||
|
private BigDecimal m_currencyRate = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Currency
|
* Get Currency
|
||||||
|
@ -167,6 +168,16 @@ public class DocLine
|
||||||
m_C_ConversionType_ID = C_ConversionType_ID;
|
m_C_ConversionType_ID = C_ConversionType_ID;
|
||||||
} // setC_ConversionType_ID
|
} // setC_ConversionType_ID
|
||||||
|
|
||||||
|
public BigDecimal getCurrencyRate()
|
||||||
|
{
|
||||||
|
return m_currencyRate;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setCurrencyRate(BigDecimal currencyRate)
|
||||||
|
{
|
||||||
|
m_currencyRate = currencyRate;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Amount (DR)
|
* Set Amount (DR)
|
||||||
* @param sourceAmt source amt
|
* @param sourceAmt source amt
|
||||||
|
|
|
@ -105,6 +105,16 @@ public class Doc_AllocationHdr extends Doc
|
||||||
{
|
{
|
||||||
MAllocationLine line = lines[i];
|
MAllocationLine line = lines[i];
|
||||||
DocLine_Allocation docLine = new DocLine_Allocation(line, this);
|
DocLine_Allocation docLine = new DocLine_Allocation(line, this);
|
||||||
|
|
||||||
|
// Get Payment Conversion Rate
|
||||||
|
if (line.getC_Payment_ID() != 0)
|
||||||
|
{
|
||||||
|
MPayment payment = new MPayment (getCtx(), line.getC_Payment_ID(), getTrxName());
|
||||||
|
int C_ConversionType_ID = payment.getC_ConversionType_ID();
|
||||||
|
docLine.setC_ConversionType_ID(C_ConversionType_ID);
|
||||||
|
if (payment.isOverrideCurrencyRate())
|
||||||
|
docLine.setCurrencyRate(payment.getCurrencyRate());
|
||||||
|
}
|
||||||
//
|
//
|
||||||
if (log.isLoggable(Level.FINE)) log.fine(docLine.toString());
|
if (log.isLoggable(Level.FINE)) log.fine(docLine.toString());
|
||||||
list.add (docLine);
|
list.add (docLine);
|
||||||
|
|
|
@ -1140,7 +1140,7 @@ public class Doc_Invoice extends Doc
|
||||||
"UPDATE M_Product_PO po ")
|
"UPDATE M_Product_PO po ")
|
||||||
.append("SET PriceLastInv = ")
|
.append("SET PriceLastInv = ")
|
||||||
// select
|
// select
|
||||||
.append("(SELECT currencyConvert(il.PriceActual,i.C_Currency_ID,po.C_Currency_ID,i.DateInvoiced,i.C_ConversionType_ID,i.AD_Client_ID,i.AD_Org_ID) ")
|
.append("(SELECT currencyConvertInvoice(i.C_Invoice_ID,po.C_Currency_ID,il.PriceActual,i.DateInvoiced) ")
|
||||||
.append("FROM C_Invoice i, C_InvoiceLine il ")
|
.append("FROM C_Invoice i, C_InvoiceLine il ")
|
||||||
.append("WHERE i.C_Invoice_ID=il.C_Invoice_ID")
|
.append("WHERE i.C_Invoice_ID=il.C_Invoice_ID")
|
||||||
.append(" AND po.M_Product_ID=il.M_Product_ID AND po.C_BPartner_ID=i.C_BPartner_ID");
|
.append(" AND po.M_Product_ID=il.M_Product_ID AND po.C_BPartner_ID=i.C_BPartner_ID");
|
||||||
|
@ -1167,5 +1167,35 @@ public class Doc_Invoice extends Doc
|
||||||
int no = DB.executeUpdate(sql.toString(), getTrxName());
|
int no = DB.executeUpdate(sql.toString(), getTrxName());
|
||||||
if (log.isLoggable(Level.FINE)) log.fine("Updated=" + no);
|
if (log.isLoggable(Level.FINE)) log.fine("Updated=" + no);
|
||||||
} // updateProductPO
|
} // updateProductPO
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BigDecimal getCurrencyRate() {
|
||||||
|
if (getC_Currency_ID() == getAcctSchema().getC_Currency_ID())
|
||||||
|
return null;
|
||||||
|
|
||||||
|
MInvoice inv = (MInvoice)getPO();
|
||||||
|
int baseCurrencyId = MClientInfo.get(getCtx(), inv.getAD_Client_ID()).getC_Currency_ID();
|
||||||
|
if (baseCurrencyId != getAcctSchema().getC_Currency_ID())
|
||||||
|
return null;
|
||||||
|
|
||||||
|
if (inv.isOverrideCurrencyRate()) {
|
||||||
|
return inv.getCurrencyRate();
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isConvertible (MAcctSchema acctSchema) {
|
||||||
|
MInvoice inv = (MInvoice)getPO();
|
||||||
|
if (inv.getC_Currency_ID() != acctSchema.getC_Currency_ID()) {
|
||||||
|
int baseCurrencyId = MClientInfo.get(getCtx(), inv.getAD_Client_ID()).getC_Currency_ID();
|
||||||
|
if (baseCurrencyId == acctSchema.getC_Currency_ID() && inv.isOverrideCurrencyRate()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.isConvertible(acctSchema);
|
||||||
|
}
|
||||||
|
|
||||||
} // Doc_Invoice
|
} // Doc_Invoice
|
||||||
|
|
|
@ -25,6 +25,7 @@ import org.compiere.model.MAccount;
|
||||||
import org.compiere.model.MAcctSchema;
|
import org.compiere.model.MAcctSchema;
|
||||||
import org.compiere.model.MBankAccount;
|
import org.compiere.model.MBankAccount;
|
||||||
import org.compiere.model.MCharge;
|
import org.compiere.model.MCharge;
|
||||||
|
import org.compiere.model.MClientInfo;
|
||||||
import org.compiere.model.MPayment;
|
import org.compiere.model.MPayment;
|
||||||
import org.compiere.model.MSysConfig;
|
import org.compiere.model.MSysConfig;
|
||||||
import org.compiere.util.Env;
|
import org.compiere.util.Env;
|
||||||
|
@ -185,4 +186,34 @@ public class Doc_Payment extends Doc
|
||||||
return ba.getAD_Org_ID();
|
return ba.getAD_Org_ID();
|
||||||
} // getBank_Org_ID
|
} // getBank_Org_ID
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BigDecimal getCurrencyRate() {
|
||||||
|
if (getC_Currency_ID() == getAcctSchema().getC_Currency_ID())
|
||||||
|
return null;
|
||||||
|
|
||||||
|
MPayment pay = (MPayment)getPO();
|
||||||
|
int baseCurrencyId = MClientInfo.get(getCtx(), pay.getAD_Client_ID()).getC_Currency_ID();
|
||||||
|
if (baseCurrencyId != getAcctSchema().getC_Currency_ID())
|
||||||
|
return null;
|
||||||
|
|
||||||
|
if (pay.isOverrideCurrencyRate()) {
|
||||||
|
return pay.getCurrencyRate();
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isConvertible (MAcctSchema acctSchema) {
|
||||||
|
MPayment pay = (MPayment)getPO();
|
||||||
|
if (pay.getC_Currency_ID() != acctSchema.getC_Currency_ID()) {
|
||||||
|
int baseCurrencyId = MClientInfo.get(getCtx(), pay.getAD_Client_ID()).getC_Currency_ID();
|
||||||
|
if (baseCurrencyId == acctSchema.getC_Currency_ID() && pay.isOverrideCurrencyRate()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.isConvertible(acctSchema);
|
||||||
|
}
|
||||||
} // Doc_Payment
|
} // Doc_Payment
|
||||||
|
|
|
@ -62,7 +62,7 @@ public final class FactLine extends X_Fact_Acct
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = 6141312459030795891L;
|
private static final long serialVersionUID = -533308106857819424L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
|
@ -726,21 +726,45 @@ public final class FactLine extends X_Fact_Acct
|
||||||
if (AD_Org_ID == 0)
|
if (AD_Org_ID == 0)
|
||||||
AD_Org_ID = m_doc.getAD_Org_ID();
|
AD_Org_ID = m_doc.getAD_Org_ID();
|
||||||
}
|
}
|
||||||
|
|
||||||
Timestamp convDate = getDateAcct();
|
Timestamp convDate = getDateAcct();
|
||||||
|
|
||||||
if (m_docLine != null && m_doc instanceof Doc_BankStatement)
|
if (( m_doc instanceof Doc_BankStatement || m_doc instanceof Doc_AllocationHdr ) && m_docLine != null)
|
||||||
convDate = m_docLine.getDateConv();
|
convDate = m_docLine.getDateConv();
|
||||||
|
|
||||||
|
BigDecimal currencyRate = null;
|
||||||
setAmtAcctDr (MConversionRate.convert (getCtx(),
|
if (m_docLine != null && m_docLine.getCurrencyRate() != null && m_docLine.getCurrencyRate().signum() > 0)
|
||||||
getAmtSourceDr(), getC_Currency_ID(), m_acctSchema.getC_Currency_ID(),
|
{
|
||||||
convDate, C_ConversionType_ID, m_doc.getAD_Client_ID(), AD_Org_ID));
|
currencyRate = m_docLine.getCurrencyRate();
|
||||||
if (getAmtAcctDr() == null)
|
}
|
||||||
return false;
|
if (currencyRate == null && m_doc != null && m_doc.getCurrencyRate() != null && m_doc.getCurrencyRate().signum() > 0)
|
||||||
setAmtAcctCr (MConversionRate.convert (getCtx(),
|
{
|
||||||
getAmtSourceCr(), getC_Currency_ID(), m_acctSchema.getC_Currency_ID(),
|
currencyRate = m_doc.getCurrencyRate();
|
||||||
convDate, C_ConversionType_ID, m_doc.getAD_Client_ID(), AD_Org_ID));
|
}
|
||||||
|
|
||||||
|
if (currencyRate != null && currencyRate.signum() > 0)
|
||||||
|
{
|
||||||
|
BigDecimal amtAcctDr = getAmtSourceDr().multiply(currencyRate);
|
||||||
|
int stdPrecision = MCurrency.getStdPrecision(getCtx(), m_acctSchema.getC_Currency_ID());
|
||||||
|
if (amtAcctDr.scale() > stdPrecision)
|
||||||
|
amtAcctDr = amtAcctDr.setScale(stdPrecision, RoundingMode.HALF_UP);
|
||||||
|
setAmtAcctDr(amtAcctDr);
|
||||||
|
BigDecimal amtAcctCr = getAmtSourceCr().multiply(currencyRate);
|
||||||
|
if (amtAcctCr.scale() > stdPrecision)
|
||||||
|
amtAcctCr = amtAcctCr.setScale(stdPrecision, RoundingMode.HALF_UP);
|
||||||
|
setAmtAcctCr(amtAcctCr);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setAmtAcctDr (MConversionRate.convert (getCtx(),
|
||||||
|
getAmtSourceDr(), getC_Currency_ID(), m_acctSchema.getC_Currency_ID(),
|
||||||
|
convDate, C_ConversionType_ID, m_doc.getAD_Client_ID(), AD_Org_ID));
|
||||||
|
if (getAmtAcctDr() == null)
|
||||||
|
return false;
|
||||||
|
setAmtAcctCr (MConversionRate.convert (getCtx(),
|
||||||
|
getAmtSourceCr(), getC_Currency_ID(), m_acctSchema.getC_Currency_ID(),
|
||||||
|
convDate, C_ConversionType_ID, m_doc.getAD_Client_ID(), AD_Org_ID));
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
} // convert
|
} // convert
|
||||||
|
|
||||||
|
|
|
@ -399,6 +399,19 @@ public interface I_C_Invoice
|
||||||
*/
|
*/
|
||||||
public String getCreateFrom();
|
public String getCreateFrom();
|
||||||
|
|
||||||
|
/** Column name CurrencyRate */
|
||||||
|
public static final String COLUMNNAME_CurrencyRate = "CurrencyRate";
|
||||||
|
|
||||||
|
/** Set Rate.
|
||||||
|
* Currency Conversion Rate
|
||||||
|
*/
|
||||||
|
public void setCurrencyRate (BigDecimal CurrencyRate);
|
||||||
|
|
||||||
|
/** Get Rate.
|
||||||
|
* Currency Conversion Rate
|
||||||
|
*/
|
||||||
|
public BigDecimal getCurrencyRate();
|
||||||
|
|
||||||
/** Column name DateAcct */
|
/** Column name DateAcct */
|
||||||
public static final String COLUMNNAME_DateAcct = "DateAcct";
|
public static final String COLUMNNAME_DateAcct = "DateAcct";
|
||||||
|
|
||||||
|
@ -612,6 +625,19 @@ public interface I_C_Invoice
|
||||||
*/
|
*/
|
||||||
public boolean isInDispute();
|
public boolean isInDispute();
|
||||||
|
|
||||||
|
/** Column name IsOverrideCurrencyRate */
|
||||||
|
public static final String COLUMNNAME_IsOverrideCurrencyRate = "IsOverrideCurrencyRate";
|
||||||
|
|
||||||
|
/** Set Override Currency Conversion Rate.
|
||||||
|
* Override Currency Conversion Rate
|
||||||
|
*/
|
||||||
|
public void setIsOverrideCurrencyRate (boolean IsOverrideCurrencyRate);
|
||||||
|
|
||||||
|
/** Get Override Currency Conversion Rate.
|
||||||
|
* Override Currency Conversion Rate
|
||||||
|
*/
|
||||||
|
public boolean isOverrideCurrencyRate();
|
||||||
|
|
||||||
/** Column name IsPaid */
|
/** Column name IsPaid */
|
||||||
public static final String COLUMNNAME_IsPaid = "IsPaid";
|
public static final String COLUMNNAME_IsPaid = "IsPaid";
|
||||||
|
|
||||||
|
|
|
@ -407,6 +407,19 @@ public interface I_C_Payment
|
||||||
|
|
||||||
public org.compiere.model.I_C_Invoice getC_Invoice() throws RuntimeException;
|
public org.compiere.model.I_C_Invoice getC_Invoice() throws RuntimeException;
|
||||||
|
|
||||||
|
/** Column name ConvertedAmt */
|
||||||
|
public static final String COLUMNNAME_ConvertedAmt = "ConvertedAmt";
|
||||||
|
|
||||||
|
/** Set Converted Amount.
|
||||||
|
* Converted Amount
|
||||||
|
*/
|
||||||
|
public void setConvertedAmt (BigDecimal ConvertedAmt);
|
||||||
|
|
||||||
|
/** Get Converted Amount.
|
||||||
|
* Converted Amount
|
||||||
|
*/
|
||||||
|
public BigDecimal getConvertedAmt();
|
||||||
|
|
||||||
/** Column name C_Order_ID */
|
/** Column name C_Order_ID */
|
||||||
public static final String COLUMNNAME_C_Order_ID = "C_Order_ID";
|
public static final String COLUMNNAME_C_Order_ID = "C_Order_ID";
|
||||||
|
|
||||||
|
@ -581,6 +594,19 @@ public interface I_C_Payment
|
||||||
*/
|
*/
|
||||||
public String getCreditCardVV();
|
public String getCreditCardVV();
|
||||||
|
|
||||||
|
/** Column name CurrencyRate */
|
||||||
|
public static final String COLUMNNAME_CurrencyRate = "CurrencyRate";
|
||||||
|
|
||||||
|
/** Set Rate.
|
||||||
|
* Currency Conversion Rate
|
||||||
|
*/
|
||||||
|
public void setCurrencyRate (BigDecimal CurrencyRate);
|
||||||
|
|
||||||
|
/** Get Rate.
|
||||||
|
* Currency Conversion Rate
|
||||||
|
*/
|
||||||
|
public BigDecimal getCurrencyRate();
|
||||||
|
|
||||||
/** Column name CustomerAddressID */
|
/** Column name CustomerAddressID */
|
||||||
public static final String COLUMNNAME_CustomerAddressID = "CustomerAddressID";
|
public static final String COLUMNNAME_CustomerAddressID = "CustomerAddressID";
|
||||||
|
|
||||||
|
@ -777,6 +803,19 @@ public interface I_C_Payment
|
||||||
*/
|
*/
|
||||||
public boolean isOnline();
|
public boolean isOnline();
|
||||||
|
|
||||||
|
/** Column name IsOverrideCurrencyRate */
|
||||||
|
public static final String COLUMNNAME_IsOverrideCurrencyRate = "IsOverrideCurrencyRate";
|
||||||
|
|
||||||
|
/** Set Override Currency Conversion Rate.
|
||||||
|
* Override Currency Conversion Rate
|
||||||
|
*/
|
||||||
|
public void setIsOverrideCurrencyRate (boolean IsOverrideCurrencyRate);
|
||||||
|
|
||||||
|
/** Get Override Currency Conversion Rate.
|
||||||
|
* Override Currency Conversion Rate
|
||||||
|
*/
|
||||||
|
public boolean isOverrideCurrencyRate();
|
||||||
|
|
||||||
/** Column name IsOverUnderPayment */
|
/** Column name IsOverUnderPayment */
|
||||||
public static final String COLUMNNAME_IsOverUnderPayment = "IsOverUnderPayment";
|
public static final String COLUMNNAME_IsOverUnderPayment = "IsOverUnderPayment";
|
||||||
|
|
||||||
|
|
|
@ -464,7 +464,7 @@ public class MCost extends X_M_Cost
|
||||||
int M_ASI_ID, int AD_Org_ID, int C_Currency_ID)
|
int M_ASI_ID, int AD_Org_ID, int C_Currency_ID)
|
||||||
{
|
{
|
||||||
BigDecimal retValue = null;
|
BigDecimal retValue = null;
|
||||||
StringBuilder sql = new StringBuilder("SELECT currencyConvert(il.PriceActual, i.C_Currency_ID, ?, i.DateAcct, i.C_ConversionType_ID, il.AD_Client_ID, il.AD_Org_ID) ")
|
StringBuilder sql = new StringBuilder("SELECT currencyConvertInvoice(i.C_Invoice_ID, ?, il.PriceActual, i.DateAcct) ")
|
||||||
// ,il.PriceActual, il.QtyInvoiced, i.DateInvoiced, il.Line
|
// ,il.PriceActual, il.QtyInvoiced, i.DateInvoiced, il.Line
|
||||||
.append("FROM C_InvoiceLine il ")
|
.append("FROM C_InvoiceLine il ")
|
||||||
.append(" INNER JOIN C_Invoice i ON (il.C_Invoice_ID=i.C_Invoice_ID) ")
|
.append(" INNER JOIN C_Invoice i ON (il.C_Invoice_ID=i.C_Invoice_ID) ")
|
||||||
|
|
|
@ -18,6 +18,7 @@ package org.compiere.model;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.math.RoundingMode;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
@ -1055,6 +1056,31 @@ public class MInvoice extends X_C_Invoice implements DocAction
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isProcessed())
|
||||||
|
{
|
||||||
|
MClientInfo info = MClientInfo.get(getCtx(), getAD_Client_ID(), get_TrxName());
|
||||||
|
MAcctSchema as = MAcctSchema.get (getCtx(), info.getC_AcctSchema1_ID(), get_TrxName());
|
||||||
|
if (as.getC_Currency_ID() != getC_Currency_ID())
|
||||||
|
{
|
||||||
|
if (isOverrideCurrencyRate())
|
||||||
|
{
|
||||||
|
if(getCurrencyRate() == null || getCurrencyRate().signum() == 0)
|
||||||
|
{
|
||||||
|
log.saveError("FillMandatory", Msg.getElement(getCtx(), COLUMNNAME_CurrencyRate));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setCurrencyRate(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setCurrencyRate(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} // beforeSave
|
} // beforeSave
|
||||||
|
|
||||||
|
@ -1949,8 +1975,20 @@ public class MInvoice extends X_C_Invoice implements DocAction
|
||||||
MBPartner bp = new MBPartner (getCtx(), getC_BPartner_ID(), get_TrxName());
|
MBPartner bp = new MBPartner (getCtx(), getC_BPartner_ID(), get_TrxName());
|
||||||
DB.getDatabase().forUpdate(bp, 0);
|
DB.getDatabase().forUpdate(bp, 0);
|
||||||
// Update total revenue and balance / credit limit (reversed on AllocationLine.processIt)
|
// Update total revenue and balance / credit limit (reversed on AllocationLine.processIt)
|
||||||
BigDecimal invAmt = MConversionRate.convertBase(getCtx(), getGrandTotal(true), // CM adjusted
|
BigDecimal invAmt = null;
|
||||||
getC_Currency_ID(), getDateAcct(), getC_ConversionType_ID(), getAD_Client_ID(), getAD_Org_ID());
|
int baseCurrencyId = Env.getContextAsInt(getCtx(), "$C_Currency_ID");
|
||||||
|
if (getC_Currency_ID() != baseCurrencyId && isOverrideCurrencyRate())
|
||||||
|
{
|
||||||
|
invAmt = getGrandTotal(true).multiply(getCurrencyRate());
|
||||||
|
int stdPrecision = MCurrency.getStdPrecision(getCtx(), baseCurrencyId);
|
||||||
|
if (invAmt.scale() > stdPrecision)
|
||||||
|
invAmt = invAmt.setScale(stdPrecision, RoundingMode.HALF_UP);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
invAmt = MConversionRate.convertBase(getCtx(), getGrandTotal(true), // CM adjusted
|
||||||
|
getC_Currency_ID(), getDateAcct(), getC_ConversionType_ID(), getAD_Client_ID(), getAD_Org_ID());
|
||||||
|
}
|
||||||
if (invAmt == null)
|
if (invAmt == null)
|
||||||
{
|
{
|
||||||
m_processMsg = MConversionRateUtil.getErrorMessage(getCtx(), "ErrorConvertingCurrencyToBaseCurrency",
|
m_processMsg = MConversionRateUtil.getErrorMessage(getCtx(), "ErrorConvertingCurrencyToBaseCurrency",
|
||||||
|
|
|
@ -822,7 +822,39 @@ public class MPayment extends X_C_Payment
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isProcessed())
|
||||||
|
{
|
||||||
|
MClientInfo info = MClientInfo.get(getCtx(), getAD_Client_ID(), get_TrxName());
|
||||||
|
MAcctSchema as = MAcctSchema.get (getCtx(), info.getC_AcctSchema1_ID(), get_TrxName());
|
||||||
|
if (as.getC_Currency_ID() != getC_Currency_ID())
|
||||||
|
{
|
||||||
|
if (isOverrideCurrencyRate())
|
||||||
|
{
|
||||||
|
if(getCurrencyRate() == null || getCurrencyRate().signum() == 0)
|
||||||
|
{
|
||||||
|
log.saveError("FillMandatory", Msg.getElement(getCtx(), COLUMNNAME_CurrencyRate));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (getConvertedAmt() == null || getConvertedAmt().signum() == 0)
|
||||||
|
{
|
||||||
|
log.saveError("FillMandatory", Msg.getElement(getCtx(), COLUMNNAME_ConvertedAmt));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setCurrencyRate(null);
|
||||||
|
setConvertedAmt(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setCurrencyRate(null);
|
||||||
|
setConvertedAmt(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} // beforeSave
|
} // beforeSave
|
||||||
|
|
||||||
|
@ -2014,14 +2046,23 @@ public class MPayment extends X_C_Payment
|
||||||
{
|
{
|
||||||
MBPartner bp = new MBPartner (getCtx(), getC_BPartner_ID(), get_TrxName());
|
MBPartner bp = new MBPartner (getCtx(), getC_BPartner_ID(), get_TrxName());
|
||||||
DB.getDatabase().forUpdate(bp, 0);
|
DB.getDatabase().forUpdate(bp, 0);
|
||||||
// Update total balance to include this payment
|
// Update total balance to include this payment
|
||||||
BigDecimal payAmt = MConversionRate.convertBase(getCtx(), getPayAmt(),
|
BigDecimal payAmt = null;
|
||||||
getC_Currency_ID(), getDateAcct(), getC_ConversionType_ID(), getAD_Client_ID(), getAD_Org_ID());
|
int baseCurrencyId = Env.getContextAsInt(getCtx(), "$C_Currency_ID");
|
||||||
if (payAmt == null)
|
if (getC_Currency_ID() != baseCurrencyId && isOverrideCurrencyRate())
|
||||||
{
|
{
|
||||||
m_processMsg = MConversionRateUtil.getErrorMessage(getCtx(), "ErrorConvertingCurrencyToBaseCurrency",
|
payAmt = getConvertedAmt();
|
||||||
getC_Currency_ID(), MClient.get(getCtx()).getC_Currency_ID(), getC_ConversionType_ID(), getDateAcct(), get_TrxName());
|
}
|
||||||
return DocAction.STATUS_Invalid;
|
else
|
||||||
|
{
|
||||||
|
payAmt = MConversionRate.convertBase(getCtx(), getPayAmt(),
|
||||||
|
getC_Currency_ID(), getDateAcct(), getC_ConversionType_ID(), getAD_Client_ID(), getAD_Org_ID());
|
||||||
|
if (payAmt == null)
|
||||||
|
{
|
||||||
|
m_processMsg = MConversionRateUtil.getErrorMessage(getCtx(), "ErrorConvertingCurrencyToBaseCurrency",
|
||||||
|
getC_Currency_ID(), MClient.get(getCtx()).getC_Currency_ID(), getC_ConversionType_ID(), getDateAcct(), get_TrxName());
|
||||||
|
return DocAction.STATUS_Invalid;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Total Balance
|
// Total Balance
|
||||||
BigDecimal newBalance = bp.getTotalOpenBalance();
|
BigDecimal newBalance = bp.getTotalOpenBalance();
|
||||||
|
|
|
@ -33,7 +33,7 @@ public class X_C_Invoice extends PO implements I_C_Invoice, I_Persistent
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = 20200413L;
|
private static final long serialVersionUID = 20200721L;
|
||||||
|
|
||||||
/** Standard Constructor */
|
/** Standard Constructor */
|
||||||
public X_C_Invoice (Properties ctx, int C_Invoice_ID, String trxName)
|
public X_C_Invoice (Properties ctx, int C_Invoice_ID, String trxName)
|
||||||
|
@ -64,6 +64,8 @@ public class X_C_Invoice extends PO implements I_C_Invoice, I_Persistent
|
||||||
// @IsApproved@
|
// @IsApproved@
|
||||||
setIsDiscountPrinted (false);
|
setIsDiscountPrinted (false);
|
||||||
setIsInDispute (false);
|
setIsInDispute (false);
|
||||||
|
// N
|
||||||
|
setIsOverrideCurrencyRate (false);
|
||||||
// N
|
// N
|
||||||
setIsPaid (false);
|
setIsPaid (false);
|
||||||
setIsPayScheduleValid (false);
|
setIsPayScheduleValid (false);
|
||||||
|
@ -696,6 +698,26 @@ public class X_C_Invoice extends PO implements I_C_Invoice, I_Persistent
|
||||||
return (String)get_Value(COLUMNNAME_CreateFrom);
|
return (String)get_Value(COLUMNNAME_CreateFrom);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Set Rate.
|
||||||
|
@param CurrencyRate
|
||||||
|
Currency Conversion Rate
|
||||||
|
*/
|
||||||
|
public void setCurrencyRate (BigDecimal CurrencyRate)
|
||||||
|
{
|
||||||
|
set_Value (COLUMNNAME_CurrencyRate, CurrencyRate);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get Rate.
|
||||||
|
@return Currency Conversion Rate
|
||||||
|
*/
|
||||||
|
public BigDecimal getCurrencyRate ()
|
||||||
|
{
|
||||||
|
BigDecimal bd = (BigDecimal)get_Value(COLUMNNAME_CurrencyRate);
|
||||||
|
if (bd == null)
|
||||||
|
return Env.ZERO;
|
||||||
|
return bd;
|
||||||
|
}
|
||||||
|
|
||||||
/** Set Account Date.
|
/** Set Account Date.
|
||||||
@param DateAcct
|
@param DateAcct
|
||||||
Accounting Date
|
Accounting Date
|
||||||
|
@ -1070,6 +1092,30 @@ public class X_C_Invoice extends PO implements I_C_Invoice, I_Persistent
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Set Override Currency Conversion Rate.
|
||||||
|
@param IsOverrideCurrencyRate
|
||||||
|
Override Currency Conversion Rate
|
||||||
|
*/
|
||||||
|
public void setIsOverrideCurrencyRate (boolean IsOverrideCurrencyRate)
|
||||||
|
{
|
||||||
|
set_Value (COLUMNNAME_IsOverrideCurrencyRate, Boolean.valueOf(IsOverrideCurrencyRate));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get Override Currency Conversion Rate.
|
||||||
|
@return Override Currency Conversion Rate
|
||||||
|
*/
|
||||||
|
public boolean isOverrideCurrencyRate ()
|
||||||
|
{
|
||||||
|
Object oo = get_Value(COLUMNNAME_IsOverrideCurrencyRate);
|
||||||
|
if (oo != null)
|
||||||
|
{
|
||||||
|
if (oo instanceof Boolean)
|
||||||
|
return ((Boolean)oo).booleanValue();
|
||||||
|
return "Y".equals(oo);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/** Set Paid.
|
/** Set Paid.
|
||||||
@param IsPaid
|
@param IsPaid
|
||||||
The document is paid
|
The document is paid
|
||||||
|
|
|
@ -33,7 +33,7 @@ public class X_C_Payment extends PO implements I_C_Payment, I_Persistent
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = 20200413L;
|
private static final long serialVersionUID = 20200721L;
|
||||||
|
|
||||||
/** Standard Constructor */
|
/** Standard Constructor */
|
||||||
public X_C_Payment (Properties ctx, int C_Payment_ID, String trxName)
|
public X_C_Payment (Properties ctx, int C_Payment_ID, String trxName)
|
||||||
|
@ -59,6 +59,8 @@ public class X_C_Payment extends PO implements I_C_Payment, I_Persistent
|
||||||
// N
|
// N
|
||||||
setIsDelayedCapture (false);
|
setIsDelayedCapture (false);
|
||||||
setIsOnline (false);
|
setIsOnline (false);
|
||||||
|
setIsOverrideCurrencyRate (false);
|
||||||
|
// N
|
||||||
setIsOverUnderPayment (true);
|
setIsOverUnderPayment (true);
|
||||||
// Y
|
// Y
|
||||||
setIsPrepayment (false);
|
setIsPrepayment (false);
|
||||||
|
@ -670,6 +672,26 @@ public class X_C_Payment extends PO implements I_C_Payment, I_Persistent
|
||||||
return ii.intValue();
|
return ii.intValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Set Converted Amount.
|
||||||
|
@param ConvertedAmt
|
||||||
|
Converted Amount
|
||||||
|
*/
|
||||||
|
public void setConvertedAmt (BigDecimal ConvertedAmt)
|
||||||
|
{
|
||||||
|
set_Value (COLUMNNAME_ConvertedAmt, ConvertedAmt);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get Converted Amount.
|
||||||
|
@return Converted Amount
|
||||||
|
*/
|
||||||
|
public BigDecimal getConvertedAmt ()
|
||||||
|
{
|
||||||
|
BigDecimal bd = (BigDecimal)get_Value(COLUMNNAME_ConvertedAmt);
|
||||||
|
if (bd == null)
|
||||||
|
return Env.ZERO;
|
||||||
|
return bd;
|
||||||
|
}
|
||||||
|
|
||||||
public org.compiere.model.I_C_Order getC_Order() throws RuntimeException
|
public org.compiere.model.I_C_Order getC_Order() throws RuntimeException
|
||||||
{
|
{
|
||||||
return (org.compiere.model.I_C_Order)MTable.get(getCtx(), org.compiere.model.I_C_Order.Table_Name)
|
return (org.compiere.model.I_C_Order)MTable.get(getCtx(), org.compiere.model.I_C_Order.Table_Name)
|
||||||
|
@ -952,6 +974,26 @@ public class X_C_Payment extends PO implements I_C_Payment, I_Persistent
|
||||||
return (String)get_Value(COLUMNNAME_CreditCardVV);
|
return (String)get_Value(COLUMNNAME_CreditCardVV);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Set Rate.
|
||||||
|
@param CurrencyRate
|
||||||
|
Currency Conversion Rate
|
||||||
|
*/
|
||||||
|
public void setCurrencyRate (BigDecimal CurrencyRate)
|
||||||
|
{
|
||||||
|
set_Value (COLUMNNAME_CurrencyRate, CurrencyRate);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get Rate.
|
||||||
|
@return Currency Conversion Rate
|
||||||
|
*/
|
||||||
|
public BigDecimal getCurrencyRate ()
|
||||||
|
{
|
||||||
|
BigDecimal bd = (BigDecimal)get_Value(COLUMNNAME_CurrencyRate);
|
||||||
|
if (bd == null)
|
||||||
|
return Env.ZERO;
|
||||||
|
return bd;
|
||||||
|
}
|
||||||
|
|
||||||
/** Set Customer Address ID.
|
/** Set Customer Address ID.
|
||||||
@param CustomerAddressID Customer Address ID */
|
@param CustomerAddressID Customer Address ID */
|
||||||
public void setCustomerAddressID (String CustomerAddressID)
|
public void setCustomerAddressID (String CustomerAddressID)
|
||||||
|
@ -1295,6 +1337,30 @@ public class X_C_Payment extends PO implements I_C_Payment, I_Persistent
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Set Override Currency Conversion Rate.
|
||||||
|
@param IsOverrideCurrencyRate
|
||||||
|
Override Currency Conversion Rate
|
||||||
|
*/
|
||||||
|
public void setIsOverrideCurrencyRate (boolean IsOverrideCurrencyRate)
|
||||||
|
{
|
||||||
|
set_Value (COLUMNNAME_IsOverrideCurrencyRate, Boolean.valueOf(IsOverrideCurrencyRate));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get Override Currency Conversion Rate.
|
||||||
|
@return Override Currency Conversion Rate
|
||||||
|
*/
|
||||||
|
public boolean isOverrideCurrencyRate ()
|
||||||
|
{
|
||||||
|
Object oo = get_Value(COLUMNNAME_IsOverrideCurrencyRate);
|
||||||
|
if (oo != null)
|
||||||
|
{
|
||||||
|
if (oo instanceof Boolean)
|
||||||
|
return ((Boolean)oo).booleanValue();
|
||||||
|
return "Y".equals(oo);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/** Set Over/Under Payment.
|
/** Set Over/Under Payment.
|
||||||
@param IsOverUnderPayment
|
@param IsOverUnderPayment
|
||||||
Over-Payment (unallocated) or Under-Payment (partial payment)
|
Over-Payment (unallocated) or Under-Payment (partial payment)
|
||||||
|
|
|
@ -126,8 +126,8 @@ public class Allocation
|
||||||
Vector<Vector<Object>> data = new Vector<Vector<Object>>();
|
Vector<Vector<Object>> data = new Vector<Vector<Object>>();
|
||||||
StringBuilder sql = new StringBuilder("SELECT p.DateTrx,p.DocumentNo,p.C_Payment_ID," // 1..3
|
StringBuilder sql = new StringBuilder("SELECT p.DateTrx,p.DocumentNo,p.C_Payment_ID," // 1..3
|
||||||
+ "c.ISO_Code,p.PayAmt," // 4..5
|
+ "c.ISO_Code,p.PayAmt," // 4..5
|
||||||
+ "currencyConvert(p.PayAmt,p.C_Currency_ID,?,?,p.C_ConversionType_ID,p.AD_Client_ID,p.AD_Org_ID),"// 6 #1, #2
|
+ "currencyConvertPayment(p.C_Payment_ID,?,null,?),"// 6 #1, #2
|
||||||
+ "currencyConvert(paymentAvailable(C_Payment_ID),p.C_Currency_ID,?,?,p.C_ConversionType_ID,p.AD_Client_ID,p.AD_Org_ID)," // 7 #3, #4
|
+ "currencyConvertPayment(p.C_Payment_ID,?,paymentAvailable(p.C_Payment_ID),?)," // 7 #3, #4
|
||||||
+ "p.MultiplierAP "
|
+ "p.MultiplierAP "
|
||||||
+ "FROM C_Payment_v p" // Corrected for AP/AR
|
+ "FROM C_Payment_v p" // Corrected for AP/AR
|
||||||
+ " INNER JOIN C_Currency c ON (p.C_Currency_ID=c.C_Currency_ID) "
|
+ " INNER JOIN C_Currency c ON (p.C_Currency_ID=c.C_Currency_ID) "
|
||||||
|
@ -257,10 +257,10 @@ public class Allocation
|
||||||
Vector<Vector<Object>> data = new Vector<Vector<Object>>();
|
Vector<Vector<Object>> data = new Vector<Vector<Object>>();
|
||||||
StringBuilder sql = new StringBuilder("SELECT i.DateInvoiced,i.DocumentNo,i.C_Invoice_ID," // 1..3
|
StringBuilder sql = new StringBuilder("SELECT i.DateInvoiced,i.DocumentNo,i.C_Invoice_ID," // 1..3
|
||||||
+ "c.ISO_Code,i.GrandTotal*i.MultiplierAP, " // 4..5 Orig Currency
|
+ "c.ISO_Code,i.GrandTotal*i.MultiplierAP, " // 4..5 Orig Currency
|
||||||
+ "currencyConvert(i.GrandTotal*i.MultiplierAP,i.C_Currency_ID,?,?,i.C_ConversionType_ID,i.AD_Client_ID,i.AD_Org_ID), " // 6 #1 Converted, #2 Date
|
+ "currencyConvertInvoice(i.C_Invoice_ID,?,i.GrandTotal*i.MultiplierAP,?), " // 6 #1 Converted, #2 Date
|
||||||
+ "currencyConvert(invoiceOpen(C_Invoice_ID,C_InvoicePaySchedule_ID),i.C_Currency_ID,?,?,i.C_ConversionType_ID,i.AD_Client_ID,i.AD_Org_ID)*i.MultiplierAP, " // 7 #3, #4 Converted Open
|
+ "currencyConvertInvoice(i.C_Invoice_ID,?,invoiceOpen(C_Invoice_ID,C_InvoicePaySchedule_ID),?)*i.MultiplierAP, " // 7 #3, #4 Converted Open
|
||||||
+ "currencyConvert(invoiceDiscount" // 8 AllowedDiscount
|
+ "currencyConvertInvoice(i.C_Invoice_ID" // 8 AllowedDiscount
|
||||||
+ "(i.C_Invoice_ID,?,C_InvoicePaySchedule_ID),i.C_Currency_ID,?,i.DateInvoiced,i.C_ConversionType_ID,i.AD_Client_ID,i.AD_Org_ID)*i.Multiplier*i.MultiplierAP," // #5, #6
|
+ ",?,invoiceDiscount(i.C_Invoice_ID,?,C_InvoicePaySchedule_ID),i.DateInvoiced)*i.Multiplier*i.MultiplierAP," // #5, #6
|
||||||
+ "i.MultiplierAP "
|
+ "i.MultiplierAP "
|
||||||
+ "FROM C_Invoice_v i" // corrected for CM/Split
|
+ "FROM C_Invoice_v i" // corrected for CM/Split
|
||||||
+ " INNER JOIN C_Currency c ON (i.C_Currency_ID=c.C_Currency_ID) "
|
+ " INNER JOIN C_Currency c ON (i.C_Currency_ID=c.C_Currency_ID) "
|
||||||
|
@ -285,8 +285,8 @@ public class Allocation
|
||||||
pstmt.setTimestamp(2, (Timestamp)date);
|
pstmt.setTimestamp(2, (Timestamp)date);
|
||||||
pstmt.setInt(3, m_C_Currency_ID);
|
pstmt.setInt(3, m_C_Currency_ID);
|
||||||
pstmt.setTimestamp(4, (Timestamp)date);
|
pstmt.setTimestamp(4, (Timestamp)date);
|
||||||
pstmt.setTimestamp(5, (Timestamp)date);
|
pstmt.setInt(5, m_C_Currency_ID);
|
||||||
pstmt.setInt(6, m_C_Currency_ID);
|
pstmt.setTimestamp(6, (Timestamp)date);
|
||||||
pstmt.setInt(7, m_C_BPartner_ID);
|
pstmt.setInt(7, m_C_BPartner_ID);
|
||||||
if (!isMultiCurrency)
|
if (!isMultiCurrency)
|
||||||
pstmt.setInt(8, m_C_Currency_ID);
|
pstmt.setInt(8, m_C_Currency_ID);
|
||||||
|
|
|
@ -233,8 +233,8 @@ public class PaySelect
|
||||||
new ColumnInfo(Msg.translate(ctx, "DiscountAmt"), "currencyConvert(invoiceDiscount(i.C_Invoice_ID,?,i.C_InvoicePaySchedule_ID),i.C_Currency_ID, ?,?,i.C_ConversionType_ID, i.AD_Client_ID,i.AD_Org_ID)", BigDecimal.class),
|
new ColumnInfo(Msg.translate(ctx, "DiscountAmt"), "currencyConvert(invoiceDiscount(i.C_Invoice_ID,?,i.C_InvoicePaySchedule_ID),i.C_Currency_ID, ?,?,i.C_ConversionType_ID, i.AD_Client_ID,i.AD_Org_ID)", BigDecimal.class),
|
||||||
new ColumnInfo(Msg.translate(ctx, "WriteOffAmt"), "currencyConvert(invoiceWriteOff(i.C_Invoice_ID),i.C_Currency_ID, ?,?,i.C_ConversionType_ID, i.AD_Client_ID,i.AD_Org_ID)", BigDecimal.class),
|
new ColumnInfo(Msg.translate(ctx, "WriteOffAmt"), "currencyConvert(invoiceWriteOff(i.C_Invoice_ID),i.C_Currency_ID, ?,?,i.C_ConversionType_ID, i.AD_Client_ID,i.AD_Org_ID)", BigDecimal.class),
|
||||||
new ColumnInfo(Msg.getMsg(ctx, "DiscountDate"), "COALESCE((SELECT discountdate from C_InvoicePaySchedule ips WHERE ips.C_InvoicePaySchedule_ID=i.C_InvoicePaySchedule_ID),i.DateInvoiced+p.DiscountDays+p.GraceDays) AS DiscountDate", Timestamp.class),
|
new ColumnInfo(Msg.getMsg(ctx, "DiscountDate"), "COALESCE((SELECT discountdate from C_InvoicePaySchedule ips WHERE ips.C_InvoicePaySchedule_ID=i.C_InvoicePaySchedule_ID),i.DateInvoiced+p.DiscountDays+p.GraceDays) AS DiscountDate", Timestamp.class),
|
||||||
new ColumnInfo(Msg.getMsg(ctx, "AmountDue"), "currencyConvert(invoiceOpen(i.C_Invoice_ID,i.C_InvoicePaySchedule_ID),i.C_Currency_ID, ?,?,i.C_ConversionType_ID, i.AD_Client_ID,i.AD_Org_ID) AS AmountDue", BigDecimal.class),
|
new ColumnInfo(Msg.getMsg(ctx, "AmountDue"), "currencyConvertInvoice(i.C_Invoice_ID,?,invoiceOpen(i.C_Invoice_ID,i.C_InvoicePaySchedule_ID),?) AS AmountDue", BigDecimal.class),
|
||||||
new ColumnInfo(Msg.getMsg(ctx, "AmountPay"), "currencyConvert(invoiceOpen(i.C_Invoice_ID,i.C_InvoicePaySchedule_ID)-invoiceDiscount(i.C_Invoice_ID,?,i.C_InvoicePaySchedule_ID)-invoiceWriteOff(i.C_Invoice_ID),i.C_Currency_ID, ?,?,i.C_ConversionType_ID, i.AD_Client_ID,i.AD_Org_ID) AS AmountPay", BigDecimal.class)
|
new ColumnInfo(Msg.getMsg(ctx, "AmountPay"), "currencyConvertInvoice(i.C_Invoice_ID,?,invoiceOpen(i.C_Invoice_ID,i.C_InvoicePaySchedule_ID)-invoiceDiscount(i.C_Invoice_ID,?,i.C_InvoicePaySchedule_ID),?) AS AmountPay", BigDecimal.class)
|
||||||
},
|
},
|
||||||
// FROM
|
// FROM
|
||||||
"C_Invoice_v i"
|
"C_Invoice_v i"
|
||||||
|
@ -370,8 +370,8 @@ public class PaySelect
|
||||||
pstmt.setTimestamp(index++, payDate);
|
pstmt.setTimestamp(index++, payDate);
|
||||||
pstmt.setInt(index++, bi.C_Currency_ID); // DueAmt
|
pstmt.setInt(index++, bi.C_Currency_ID); // DueAmt
|
||||||
pstmt.setTimestamp(index++, payDate);
|
pstmt.setTimestamp(index++, payDate);
|
||||||
pstmt.setTimestamp(index++, payDate); // PayAmt
|
|
||||||
pstmt.setInt(index++, bi.C_Currency_ID);
|
pstmt.setInt(index++, bi.C_Currency_ID);
|
||||||
|
pstmt.setTimestamp(index++, payDate); // PayAmt
|
||||||
pstmt.setTimestamp(index++, payDate);
|
pstmt.setTimestamp(index++, payDate);
|
||||||
pstmt.setString(index++, isSOTrx); // IsSOTrx
|
pstmt.setString(index++, isSOTrx); // IsSOTrx
|
||||||
pstmt.setInt(index++, m_AD_Client_ID); // Client
|
pstmt.setInt(index++, m_AD_Client_ID); // Client
|
||||||
|
|
|
@ -176,7 +176,7 @@ public abstract class StatementCreateFromBatch extends CreateFromForm
|
||||||
Vector<Vector<Object>> data = new Vector<Vector<Object>>();
|
Vector<Vector<Object>> data = new Vector<Vector<Object>>();
|
||||||
StringBuilder sql = new StringBuilder();
|
StringBuilder sql = new StringBuilder();
|
||||||
sql.append("SELECT py.C_DepositBatch_ID, db.DocumentNo, db.DateDeposit, db.C_BankAccount_ID, ba.AccountNo,");
|
sql.append("SELECT py.C_DepositBatch_ID, db.DocumentNo, db.DateDeposit, db.C_BankAccount_ID, ba.AccountNo,");
|
||||||
sql.append("SUM(currencyConvert(p.PayAmt,p.C_Currency_ID,ba.C_Currency_ID,p.DateAcct,p.C_ConversionType_ID,p.AD_Client_ID,p.AD_Org_ID)) AS amount,");
|
sql.append("SUM(currencyConvertPayment(p.C_Payment_ID,ba.C_Currency_ID)) AS amount,");
|
||||||
sql.append("SUM(p.PayAmt) AS amountoriginal");
|
sql.append("SUM(p.PayAmt) AS amountoriginal");
|
||||||
sql.append(" FROM C_BankAccount ba");
|
sql.append(" FROM C_BankAccount ba");
|
||||||
sql.append(" INNER JOIN C_Payment_v p ON (p.C_BankAccount_ID=ba.C_BankAccount_ID)");
|
sql.append(" INNER JOIN C_Payment_v p ON (p.C_BankAccount_ID=ba.C_BankAccount_ID)");
|
||||||
|
@ -245,7 +245,7 @@ public abstract class StatementCreateFromBatch extends CreateFromForm
|
||||||
|
|
||||||
StringBuilder sql = new StringBuilder();
|
StringBuilder sql = new StringBuilder();
|
||||||
sql.append("SELECT p.DateTrx,p.C_Payment_ID,p.DocumentNo, p.C_Currency_ID,c.ISO_Code, p.PayAmt,");
|
sql.append("SELECT p.DateTrx,p.C_Payment_ID,p.DocumentNo, p.C_Currency_ID,c.ISO_Code, p.PayAmt,");
|
||||||
sql.append("currencyConvert(p.PayAmt,p.C_Currency_ID,ba.C_Currency_ID,p.DateAcct,p.C_ConversionType_ID,p.AD_Client_ID,p.AD_Org_ID), bp.Name ");
|
sql.append("currencyConvertPayment(p.C_Payment_ID,ba.C_Currency_ID), bp.Name ");
|
||||||
sql.append(" FROM C_BankAccount ba");
|
sql.append(" FROM C_BankAccount ba");
|
||||||
sql.append(" INNER JOIN C_Payment_v p ON (p.C_BankAccount_ID=ba.C_BankAccount_ID)");
|
sql.append(" INNER JOIN C_Payment_v p ON (p.C_BankAccount_ID=ba.C_BankAccount_ID)");
|
||||||
sql.append(" INNER JOIN C_Currency c ON (p.C_Currency_ID=c.C_Currency_ID)");
|
sql.append(" INNER JOIN C_Currency c ON (p.C_Currency_ID=c.C_Currency_ID)");
|
||||||
|
|
|
@ -59,7 +59,7 @@ public abstract class CreateFromDepositBatch extends CreateFromBatch
|
||||||
|
|
||||||
StringBuilder sql = new StringBuilder();
|
StringBuilder sql = new StringBuilder();
|
||||||
sql.append("SELECT p.DateTrx,p.C_Payment_ID,p.DocumentNo, p.C_Currency_ID,c.ISO_Code, p.PayAmt,");
|
sql.append("SELECT p.DateTrx,p.C_Payment_ID,p.DocumentNo, p.C_Currency_ID,c.ISO_Code, p.PayAmt,");
|
||||||
sql.append("currencyConvert(p.PayAmt,p.C_Currency_ID,ba.C_Currency_ID,p.DateAcct,p.C_ConversionType_ID,p.AD_Client_ID,p.AD_Org_ID), bp.Name ");
|
sql.append("currencyConvertPayment(p.C_Payment_ID,ba.C_Currency_ID), bp.Name ");
|
||||||
sql.append("FROM C_BankAccount ba");
|
sql.append("FROM C_BankAccount ba");
|
||||||
sql.append(" INNER JOIN C_Payment_v p ON (p.C_BankAccount_ID=ba.C_BankAccount_ID)");
|
sql.append(" INNER JOIN C_Payment_v p ON (p.C_BankAccount_ID=ba.C_BankAccount_ID)");
|
||||||
sql.append(" INNER JOIN C_Currency c ON (p.C_Currency_ID=c.C_Currency_ID)");
|
sql.append(" INNER JOIN C_Currency c ON (p.C_Currency_ID=c.C_Currency_ID)");
|
||||||
|
|
|
@ -59,7 +59,7 @@ public abstract class CreateFromStatement extends CreateFromBatch
|
||||||
|
|
||||||
StringBuilder sql = new StringBuilder();
|
StringBuilder sql = new StringBuilder();
|
||||||
sql.append("SELECT p.DateTrx,p.C_Payment_ID,p.DocumentNo, p.C_Currency_ID,c.ISO_Code, p.PayAmt,");
|
sql.append("SELECT p.DateTrx,p.C_Payment_ID,p.DocumentNo, p.C_Currency_ID,c.ISO_Code, p.PayAmt,");
|
||||||
sql.append("currencyConvert(p.PayAmt,p.C_Currency_ID,ba.C_Currency_ID,p.DateAcct,p.C_ConversionType_ID,p.AD_Client_ID,p.AD_Org_ID), bp.Name ");
|
sql.append("currencyConvertPayment(p.C_Payment_ID,ba.C_Currency_ID), bp.Name ");
|
||||||
sql.append("FROM C_BankAccount ba");
|
sql.append("FROM C_BankAccount ba");
|
||||||
sql.append(" INNER JOIN C_Payment_v p ON (p.C_BankAccount_ID=ba.C_BankAccount_ID)");
|
sql.append(" INNER JOIN C_Payment_v p ON (p.C_BankAccount_ID=ba.C_BankAccount_ID)");
|
||||||
sql.append(" INNER JOIN C_Currency c ON (p.C_Currency_ID=c.C_Currency_ID)");
|
sql.append(" INNER JOIN C_Currency c ON (p.C_Currency_ID=c.C_Currency_ID)");
|
||||||
|
|
Loading…
Reference in New Issue