diff --git a/db/ddlutils/oracle/functions/C_BPartner_RemitLocation.SQL b/db/ddlutils/oracle/functions/C_BPartner_RemitLocation.SQL index 62aec19390..3dfd28870d 100644 --- a/db/ddlutils/oracle/functions/C_BPartner_RemitLocation.SQL +++ b/db/ddlutils/oracle/functions/C_BPartner_RemitLocation.SQL @@ -21,7 +21,7 @@ AS CURSOR CUR_BPLoc IS SELECT IsRemitTo, C_Location_ID FROM C_BPartner_Location - WHERE C_BPartner_ID=p_C_BPartner_ID + WHERE C_BPartner_ID=p_C_BPartner_ID AND IsActive='Y' ORDER BY IsRemitTo DESC; BEGIN FOR l IN CUR_BPLoc LOOP @@ -31,4 +31,4 @@ BEGIN END LOOP; RETURN v_C_Location_ID; END bpartnerRemitLocation; -/ \ No newline at end of file +/ diff --git a/db/ddlutils/postgresql/functions/C_BPartner_RemitLocation.sql b/db/ddlutils/postgresql/functions/C_BPartner_RemitLocation.sql index e138861ec5..28d270811f 100644 --- a/db/ddlutils/postgresql/functions/C_BPartner_RemitLocation.sql +++ b/db/ddlutils/postgresql/functions/C_BPartner_RemitLocation.sql @@ -9,7 +9,7 @@ BEGIN FOR l IN SELECT IsRemitTo, C_Location_ID FROM C_BPartner_Location - WHERE C_BPartner_ID=p_C_BPartner_ID + WHERE C_BPartner_ID=p_C_BPartner_ID AND IsActive='Y' ORDER BY IsRemitTo DESC LOOP IF (v_C_Location_ID IS NULL) THEN diff --git a/migration/i2.0/oracle/201312110939_IDEMPIERE-1625.sql b/migration/i2.0/oracle/201312110939_IDEMPIERE-1625.sql new file mode 100644 index 0000000000..f8eb1e283e --- /dev/null +++ b/migration/i2.0/oracle/201312110939_IDEMPIERE-1625.sql @@ -0,0 +1,38 @@ +CREATE OR REPLACE FUNCTION bpartnerRemitLocation +( + p_C_BPartner_ID C_BPartner.C_BPartner_ID%TYPE +) +RETURN NUMBER +/************************************************************************* + * The contents of this file are subject to the Compiere License. You may + * obtain a copy of the License at http://www.compiere.org/license.html + * Software is on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either + * express or implied. See the License for details. Code: Compiere ERP+CRM + * Copyright (C) 1999-2002 Jorg Janke, ComPiere, Inc. All Rights Reserved. + ************************************************************************* + * $Id: C_BPartner_RemitLocation.SQL,v 1.1 2006/04/21 17:51:58 jjanke Exp $ + *** + * Title: Return the first RemitTo C_Location_ID of a Business Partner + * Description: + * + ************************************************************************/ +AS + v_C_Location_ID NUMBER := NULL; + CURSOR CUR_BPLoc IS + SELECT IsRemitTo, C_Location_ID + FROM C_BPartner_Location + WHERE C_BPartner_ID=p_C_BPartner_ID AND IsActive='Y' + ORDER BY IsRemitTo DESC; +BEGIN + FOR l IN CUR_BPLoc LOOP + IF (v_C_Location_ID IS NULL) THEN + v_C_Location_ID := l.C_Location_ID; + END IF; + END LOOP; + RETURN v_C_Location_ID; +END bpartnerRemitLocation; +/ + +SELECT register_migration_script('201312110939_IDEMPIERE-1625.sql') FROM dual +; + diff --git a/migration/i2.0/postgresql/201312110939_IDEMPIERE-1625.sql b/migration/i2.0/postgresql/201312110939_IDEMPIERE-1625.sql new file mode 100644 index 0000000000..44638adc45 --- /dev/null +++ b/migration/i2.0/postgresql/201312110939_IDEMPIERE-1625.sql @@ -0,0 +1,27 @@ +CREATE OR REPLACE FUNCTION bpartnerRemitLocation(p_C_BPartner_ID C_BPartner.C_BPartner_ID%TYPE) +RETURNS numeric AS $body$ + +DECLARE + v_C_Location_ID NUMERIC := NULL; + l RECORD; + +BEGIN + FOR l IN + SELECT IsRemitTo, C_Location_ID + FROM C_BPartner_Location + WHERE C_BPartner_ID=p_C_BPartner_ID AND IsActive='Y' + ORDER BY IsRemitTo DESC + LOOP + IF (v_C_Location_ID IS NULL) THEN + v_C_Location_ID := l.C_Location_ID; + END IF; + END LOOP; + RETURN v_C_Location_ID; + +END; + +$body$ LANGUAGE plpgsql; + +SELECT register_migration_script('201312110939_IDEMPIERE-1625.sql') FROM dual +; +