IDEMPIERE-1588 Add country on non business days table
This commit is contained in:
parent
b3345e1e89
commit
b9f272bbc3
|
@ -31,18 +31,26 @@ as
|
||||||
v_Saturday number := TO_CHAR(TO_DATE('2000-01-01', 'YYYY-MM-DD'), 'D');
|
v_Saturday number := TO_CHAR(TO_DATE('2000-01-01', 'YYYY-MM-DD'), 'D');
|
||||||
v_Sunday number := (case when v_Saturday = 7 then 1 else v_Saturday + 1 end);
|
v_Sunday number := (case when v_Saturday = 7 then 1 else v_Saturday + 1 end);
|
||||||
v_isHoliday boolean := true;
|
v_isHoliday boolean := true;
|
||||||
|
v_country c_country.c_country_id%type;
|
||||||
|
|
||||||
cursor nonBusinessDays(pp_Date date) is
|
cursor nonBusinessDays(pp_Date date, pp_country c_country.c_country_id%type) is
|
||||||
select nbd.Date1 from C_NonBusinessDay nbd
|
select nbd.Date1 from C_NonBusinessDay nbd
|
||||||
where AD_Client_ID=p_AD_Client_ID and IsActive ='Y' and Date1>=pp_Date
|
where AD_Client_ID=p_AD_Client_ID and IsActive ='Y' and Date1>=pp_Date
|
||||||
|
AND COALESCE(C_Country_ID,0) IN (0, pp_country)
|
||||||
order by Date1;
|
order by Date1;
|
||||||
begin
|
begin
|
||||||
v_isHoliday := true;
|
v_isHoliday := true;
|
||||||
|
SELECT COALESCE(MAX(co.c_country_id), 100)
|
||||||
|
INTO v_country
|
||||||
|
FROM ad_client cl
|
||||||
|
JOIN ad_language l ON cl.ad_language = l.ad_language
|
||||||
|
JOIN c_country co ON l.countrycode = co.countrycode
|
||||||
|
WHERE cl.ad_client_id = p_ad_client_id;
|
||||||
loop
|
loop
|
||||||
SELECT DECODE(TO_CHAR(v_nextDate,'D'), v_Saturday, 2, v_Sunday, 1, 0) INTO v_offset FROM DUAL;
|
SELECT DECODE(TO_CHAR(v_nextDate,'D'), v_Saturday, 2, v_Sunday, 1, 0) INTO v_offset FROM DUAL;
|
||||||
v_nextDate := TRUNC(v_nextDate + v_offset);
|
v_nextDate := TRUNC(v_nextDate + v_offset);
|
||||||
v_isHoliday := false;
|
v_isHoliday := false;
|
||||||
for nbd in nonBusinessDays(v_nextDate) loop
|
for nbd in nonBusinessDays(v_nextDate, v_country) loop
|
||||||
exit when v_nextDate <> TRUNC(nbd.Date1);
|
exit when v_nextDate <> TRUNC(nbd.Date1);
|
||||||
v_nextDate := v_nextDate + 1;
|
v_nextDate := v_nextDate + 1;
|
||||||
v_isHoliday := true;
|
v_isHoliday := true;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
CREATE FUNCTION nextbusinessday(p_date timestamp with time zone, p_ad_client_id numeric) RETURNS timestamp with time zone
|
CREATE OR REPLACE FUNCTION nextbusinessday(p_date timestamp with time zone, p_ad_client_id numeric) RETURNS timestamp with time zone
|
||||||
AS $$
|
AS $$
|
||||||
/**
|
/**
|
||||||
*This file is part of Adempiere ERP Bazaar
|
*This file is part of Adempiere ERP Bazaar
|
||||||
|
@ -29,6 +29,7 @@ DECLARE
|
||||||
v_Saturday numeric := TO_CHAR(TO_DATE('2000-01-01', 'YYYY-MM-DD'), 'D');
|
v_Saturday numeric := TO_CHAR(TO_DATE('2000-01-01', 'YYYY-MM-DD'), 'D');
|
||||||
v_Sunday numeric := (case when v_Saturday = 7 then 1 else v_Saturday + 1 end);
|
v_Sunday numeric := (case when v_Saturday = 7 then 1 else v_Saturday + 1 end);
|
||||||
v_isHoliday boolean := true;
|
v_isHoliday boolean := true;
|
||||||
|
v_country c_country.c_country_id%type;
|
||||||
nbd C_NonBusinessDay%ROWTYPE;
|
nbd C_NonBusinessDay%ROWTYPE;
|
||||||
begin
|
begin
|
||||||
v_isHoliday := true;
|
v_isHoliday := true;
|
||||||
|
@ -40,9 +41,16 @@ begin
|
||||||
END INTO v_offset;
|
END INTO v_offset;
|
||||||
v_nextDate := v_nextDate + v_offset::integer;
|
v_nextDate := v_nextDate + v_offset::integer;
|
||||||
v_isHoliday := false;
|
v_isHoliday := false;
|
||||||
|
SELECT COALESCE(MAX(co.c_country_id), 100)
|
||||||
|
INTO v_country
|
||||||
|
FROM ad_client cl
|
||||||
|
JOIN ad_language l ON cl.ad_language = l.ad_language
|
||||||
|
JOIN c_country co ON l.countrycode = co.countrycode
|
||||||
|
WHERE cl.ad_client_id = p_ad_client_id;
|
||||||
FOR nbd IN SELECT *
|
FOR nbd IN SELECT *
|
||||||
FROM C_NonBusinessDay
|
FROM C_NonBusinessDay
|
||||||
WHERE AD_Client_ID=p_AD_Client_ID and IsActive ='Y' and Date1 >= v_nextDate
|
WHERE AD_Client_ID=p_AD_Client_ID and IsActive ='Y' and Date1 >= v_nextDate
|
||||||
|
AND COALESCE(C_Country_ID,0) IN (0, v_country)
|
||||||
ORDER BY Date1
|
ORDER BY Date1
|
||||||
LOOP
|
LOOP
|
||||||
exit when v_nextDate <> trunc(nbd.Date1);
|
exit when v_nextDate <> trunc(nbd.Date1);
|
||||||
|
|
|
@ -0,0 +1,162 @@
|
||||||
|
SET SQLBLANKLINES ON
|
||||||
|
SET DEFINE OFF
|
||||||
|
|
||||||
|
-- Dec 6, 2013 10:44:52 AM CET
|
||||||
|
-- IDEMPIERE-1588 Add country on non business days table
|
||||||
|
INSERT INTO AD_Column (AD_Client_ID,AD_Column_ID,AD_Column_UU,AD_Element_ID,AD_Org_ID,AD_Reference_ID,AD_Table_ID,ColumnName,Created,CreatedBy,Description,EntityType,FieldLength,Help,IsActive,IsAllowCopy,IsAllowLogging,IsAlwaysUpdateable,IsAutocomplete,IsEncrypted,IsIdentifier,IsKey,IsMandatory,IsParent,IsSecure,IsSelectionColumn,IsSyncDatabase,IsToolbarButton,IsTranslated,IsUpdateable,Name,SeqNo,SeqNoSelection,Updated,UpdatedBy,Version) VALUES (0,210893,'b69998b5-9865-43c7-8518-2e50e8bb3bf8',192,0,19,163,'C_Country_ID',TO_DATE('2013-12-06 10:44:51','YYYY-MM-DD HH24:MI:SS'),100,'Country ','D',22,'The Country defines a Country. Each Country must be defined before it can be used in any document.','Y','Y','Y','N','N','N','N','N','N','N','N','N','N','N','N','Y','Country',0,0,TO_DATE('2013-12-06 10:44:51','YYYY-MM-DD HH24:MI:SS'),100,0)
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Dec 6, 2013 10:45:01 AM CET
|
||||||
|
UPDATE AD_Column SET FKConstraintName='CCountry_CNonBusinessDay', FKConstraintType='N',Updated=TO_DATE('2013-12-06 10:45:01','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=210893
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Dec 6, 2013 10:45:01 AM CET
|
||||||
|
ALTER TABLE C_NonBusinessDay ADD C_Country_ID NUMBER(10) DEFAULT NULL
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Dec 6, 2013 10:45:02 AM CET
|
||||||
|
ALTER TABLE C_NonBusinessDay ADD CONSTRAINT CCountry_CNonBusinessDay FOREIGN KEY (C_Country_ID) REFERENCES C_COUNTRY(C_COUNTRY_ID) DEFERRABLE INITIALLY DEFERRED
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Dec 6, 2013 10:45:37 AM CET
|
||||||
|
INSERT INTO AD_Field (AD_Client_ID,AD_Column_ID,AD_Field_ID,AD_Field_UU,AD_Org_ID,AD_Tab_ID,ColumnSpan,Created,CreatedBy,DisplayLength,EntityType,IsActive,IsCentrallyMaintained,IsDisplayed,IsDisplayedGrid,IsEncrypted,IsFieldOnly,IsHeading,IsReadOnly,IsSameLine,Name,SeqNo,Updated,UpdatedBy) VALUES (0,60714,202542,'39156bc8-6f18-437d-b2de-2b4af618dc16',0,131,2,TO_DATE('2013-12-06 10:45:36','YYYY-MM-DD HH24:MI:SS'),100,36,'D','Y','Y','N','N','N','N','N','N','N','C_NonBusinessDay_UU',80,TO_DATE('2013-12-06 10:45:36','YYYY-MM-DD HH24:MI:SS'),100)
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Dec 6, 2013 10:45:37 AM CET
|
||||||
|
INSERT INTO AD_Field (AD_Client_ID,AD_Column_ID,AD_Field_ID,AD_Field_UU,AD_Org_ID,AD_Tab_ID,ColumnSpan,Created,CreatedBy,Description,DisplayLength,EntityType,Help,IsActive,IsCentrallyMaintained,IsDisplayed,IsEncrypted,IsFieldOnly,IsHeading,IsReadOnly,IsSameLine,Name,SeqNo,Updated,UpdatedBy) VALUES (0,210893,202543,'142b8efa-23e4-4329-8091-97ee83964d46',0,131,2,TO_DATE('2013-12-06 10:45:37','YYYY-MM-DD HH24:MI:SS'),100,'Country ',22,'D','The Country defines a Country. Each Country must be defined before it can be used in any document.','Y','Y','Y','N','N','N','N','N','Country',90,TO_DATE('2013-12-06 10:45:37','YYYY-MM-DD HH24:MI:SS'),100)
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Dec 6, 2013 10:45:51 AM CET
|
||||||
|
UPDATE AD_Field SET SeqNo=10,Updated=TO_DATE('2013-12-06 10:45:51','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=486
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Dec 6, 2013 10:45:51 AM CET
|
||||||
|
UPDATE AD_Field SET SeqNo=20,Updated=TO_DATE('2013-12-06 10:45:51','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=2013
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Dec 6, 2013 10:45:51 AM CET
|
||||||
|
UPDATE AD_Field SET SeqNo=30,Updated=TO_DATE('2013-12-06 10:45:51','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=490
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Dec 6, 2013 10:45:51 AM CET
|
||||||
|
UPDATE AD_Field SET SeqNo=40,Updated=TO_DATE('2013-12-06 10:45:51','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=488
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Dec 6, 2013 10:45:51 AM CET
|
||||||
|
UPDATE AD_Field SET SeqNo=50,Updated=TO_DATE('2013-12-06 10:45:51','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=489
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Dec 6, 2013 10:45:51 AM CET
|
||||||
|
UPDATE AD_Field SET SeqNo=60,Updated=TO_DATE('2013-12-06 10:45:51','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=1552
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Dec 6, 2013 10:45:51 AM CET
|
||||||
|
UPDATE AD_Field SET SeqNo=70,Updated=TO_DATE('2013-12-06 10:45:51','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=202543
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Dec 6, 2013 10:45:51 AM CET
|
||||||
|
UPDATE AD_Field SET SeqNo=0,Updated=TO_DATE('2013-12-06 10:45:51','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=202542
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Dec 6, 2013 10:45:51 AM CET
|
||||||
|
UPDATE AD_Field SET SeqNo=0,Updated=TO_DATE('2013-12-06 10:45:51','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=485
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Dec 6, 2013 10:46:03 AM CET
|
||||||
|
UPDATE AD_Field SET SeqNoGrid=0,IsDisplayedGrid='N' WHERE AD_Field_ID=485
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Dec 6, 2013 10:46:03 AM CET
|
||||||
|
UPDATE AD_Field SET SeqNoGrid=10,IsDisplayedGrid='Y' WHERE AD_Field_ID=486
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Dec 6, 2013 10:46:03 AM CET
|
||||||
|
UPDATE AD_Field SET SeqNoGrid=20,IsDisplayedGrid='Y' WHERE AD_Field_ID=2013
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Dec 6, 2013 10:46:03 AM CET
|
||||||
|
UPDATE AD_Field SET SeqNoGrid=30,IsDisplayedGrid='Y' WHERE AD_Field_ID=490
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Dec 6, 2013 10:46:03 AM CET
|
||||||
|
UPDATE AD_Field SET SeqNoGrid=40,IsDisplayedGrid='Y' WHERE AD_Field_ID=488
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Dec 6, 2013 10:46:03 AM CET
|
||||||
|
UPDATE AD_Field SET SeqNoGrid=50,IsDisplayedGrid='Y' WHERE AD_Field_ID=489
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Dec 6, 2013 10:46:03 AM CET
|
||||||
|
UPDATE AD_Field SET SeqNoGrid=60,IsDisplayedGrid='Y' WHERE AD_Field_ID=1552
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Dec 6, 2013 10:46:03 AM CET
|
||||||
|
UPDATE AD_Field SET SeqNoGrid=70,IsDisplayedGrid='Y' WHERE AD_Field_ID=202543
|
||||||
|
;
|
||||||
|
|
||||||
|
create or replace
|
||||||
|
function nextBusinessDay
|
||||||
|
(
|
||||||
|
p_Date in date,
|
||||||
|
p_AD_Client_ID in number
|
||||||
|
)
|
||||||
|
return date
|
||||||
|
/**
|
||||||
|
*This file is part of Adempiere ERP Bazaar
|
||||||
|
*http://www.adempiere.org
|
||||||
|
*
|
||||||
|
*Copyright (C) 2007 Teo Sarca
|
||||||
|
*
|
||||||
|
*This program is free software; you can redistribute it and/or
|
||||||
|
*modify it under the terms of the GNU General Public License
|
||||||
|
*as published by the Free Software Foundation; either version 2
|
||||||
|
*of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
*This program is distributed in the hope that it will be useful,
|
||||||
|
*but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
*MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
*GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
*You should have received a copy of the GNU General Public License
|
||||||
|
*along with this program; if not, write to the Free Software
|
||||||
|
*Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.of
|
||||||
|
*/
|
||||||
|
as
|
||||||
|
v_nextDate date := TRUNC(p_Date);
|
||||||
|
v_offset number := 0;
|
||||||
|
v_Saturday number := TO_CHAR(TO_DATE('2000-01-01', 'YYYY-MM-DD'), 'D');
|
||||||
|
v_Sunday number := (case when v_Saturday = 7 then 1 else v_Saturday + 1 end);
|
||||||
|
v_isHoliday boolean := true;
|
||||||
|
v_country c_country.c_country_id%type;
|
||||||
|
|
||||||
|
cursor nonBusinessDays(pp_Date date, pp_country c_country.c_country_id%type) is
|
||||||
|
select nbd.Date1 from C_NonBusinessDay nbd
|
||||||
|
where AD_Client_ID=p_AD_Client_ID and IsActive ='Y' and Date1>=pp_Date
|
||||||
|
AND COALESCE(C_Country_ID,0) IN (0, pp_country)
|
||||||
|
order by Date1;
|
||||||
|
begin
|
||||||
|
v_isHoliday := true;
|
||||||
|
SELECT COALESCE(MAX(co.c_country_id), 100)
|
||||||
|
INTO v_country
|
||||||
|
FROM ad_client cl
|
||||||
|
JOIN ad_language l ON cl.ad_language = l.ad_language
|
||||||
|
JOIN c_country co ON l.countrycode = co.countrycode
|
||||||
|
WHERE cl.ad_client_id = p_ad_client_id;
|
||||||
|
loop
|
||||||
|
SELECT DECODE(TO_CHAR(v_nextDate,'D'), v_Saturday, 2, v_Sunday, 1, 0) INTO v_offset FROM DUAL;
|
||||||
|
v_nextDate := TRUNC(v_nextDate + v_offset);
|
||||||
|
v_isHoliday := false;
|
||||||
|
for nbd in nonBusinessDays(v_nextDate, v_country) loop
|
||||||
|
exit when v_nextDate <> TRUNC(nbd.Date1);
|
||||||
|
v_nextDate := v_nextDate + 1;
|
||||||
|
v_isHoliday := true;
|
||||||
|
end loop;
|
||||||
|
exit when v_isHoliday=false;
|
||||||
|
end loop;
|
||||||
|
--
|
||||||
|
return v_nextDate;
|
||||||
|
end nextBusinessDay;
|
||||||
|
/
|
||||||
|
|
||||||
|
SELECT register_migration_script('201401150958_IDEMPIERE-1588.sql') FROM dual
|
||||||
|
;
|
|
@ -0,0 +1,162 @@
|
||||||
|
-- Dec 6, 2013 10:44:52 AM CET
|
||||||
|
-- IDEMPIERE-1588 Add country on non business days table
|
||||||
|
INSERT INTO AD_Column (AD_Client_ID,AD_Column_ID,AD_Column_UU,AD_Element_ID,AD_Org_ID,AD_Reference_ID,AD_Table_ID,ColumnName,Created,CreatedBy,Description,EntityType,FieldLength,Help,IsActive,IsAllowCopy,IsAllowLogging,IsAlwaysUpdateable,IsAutocomplete,IsEncrypted,IsIdentifier,IsKey,IsMandatory,IsParent,IsSecure,IsSelectionColumn,IsSyncDatabase,IsToolbarButton,IsTranslated,IsUpdateable,Name,SeqNo,SeqNoSelection,Updated,UpdatedBy,Version) VALUES (0,210893,'b69998b5-9865-43c7-8518-2e50e8bb3bf8',192,0,19,163,'C_Country_ID',TO_TIMESTAMP('2013-12-06 10:44:51','YYYY-MM-DD HH24:MI:SS'),100,'Country ','D',22,'The Country defines a Country. Each Country must be defined before it can be used in any document.','Y','Y','Y','N','N','N','N','N','N','N','N','N','N','N','N','Y','Country',0,0,TO_TIMESTAMP('2013-12-06 10:44:51','YYYY-MM-DD HH24:MI:SS'),100,0)
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Dec 6, 2013 10:45:01 AM CET
|
||||||
|
UPDATE AD_Column SET FKConstraintName='CCountry_CNonBusinessDay', FKConstraintType='N',Updated=TO_TIMESTAMP('2013-12-06 10:45:01','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=210893
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Dec 6, 2013 10:45:01 AM CET
|
||||||
|
ALTER TABLE C_NonBusinessDay ADD COLUMN C_Country_ID NUMERIC(10) DEFAULT NULL
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Dec 6, 2013 10:45:02 AM CET
|
||||||
|
ALTER TABLE C_NonBusinessDay ADD CONSTRAINT CCountry_CNonBusinessDay FOREIGN KEY (C_Country_ID) REFERENCES C_COUNTRY(C_COUNTRY_ID) DEFERRABLE INITIALLY DEFERRED
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Dec 6, 2013 10:45:37 AM CET
|
||||||
|
INSERT INTO AD_Field (AD_Client_ID,AD_Column_ID,AD_Field_ID,AD_Field_UU,AD_Org_ID,AD_Tab_ID,ColumnSpan,Created,CreatedBy,DisplayLength,EntityType,IsActive,IsCentrallyMaintained,IsDisplayed,IsDisplayedGrid,IsEncrypted,IsFieldOnly,IsHeading,IsReadOnly,IsSameLine,Name,SeqNo,Updated,UpdatedBy) VALUES (0,60714,202542,'39156bc8-6f18-437d-b2de-2b4af618dc16',0,131,2,TO_TIMESTAMP('2013-12-06 10:45:36','YYYY-MM-DD HH24:MI:SS'),100,36,'D','Y','Y','N','N','N','N','N','N','N','C_NonBusinessDay_UU',80,TO_TIMESTAMP('2013-12-06 10:45:36','YYYY-MM-DD HH24:MI:SS'),100)
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Dec 6, 2013 10:45:37 AM CET
|
||||||
|
INSERT INTO AD_Field (AD_Client_ID,AD_Column_ID,AD_Field_ID,AD_Field_UU,AD_Org_ID,AD_Tab_ID,ColumnSpan,Created,CreatedBy,Description,DisplayLength,EntityType,Help,IsActive,IsCentrallyMaintained,IsDisplayed,IsEncrypted,IsFieldOnly,IsHeading,IsReadOnly,IsSameLine,Name,SeqNo,Updated,UpdatedBy) VALUES (0,210893,202543,'142b8efa-23e4-4329-8091-97ee83964d46',0,131,2,TO_TIMESTAMP('2013-12-06 10:45:37','YYYY-MM-DD HH24:MI:SS'),100,'Country ',22,'D','The Country defines a Country. Each Country must be defined before it can be used in any document.','Y','Y','Y','N','N','N','N','N','Country',90,TO_TIMESTAMP('2013-12-06 10:45:37','YYYY-MM-DD HH24:MI:SS'),100)
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Dec 6, 2013 10:45:51 AM CET
|
||||||
|
UPDATE AD_Field SET SeqNo=10,Updated=TO_TIMESTAMP('2013-12-06 10:45:51','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=486
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Dec 6, 2013 10:45:51 AM CET
|
||||||
|
UPDATE AD_Field SET SeqNo=20,Updated=TO_TIMESTAMP('2013-12-06 10:45:51','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=2013
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Dec 6, 2013 10:45:51 AM CET
|
||||||
|
UPDATE AD_Field SET SeqNo=30,Updated=TO_TIMESTAMP('2013-12-06 10:45:51','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=490
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Dec 6, 2013 10:45:51 AM CET
|
||||||
|
UPDATE AD_Field SET SeqNo=40,Updated=TO_TIMESTAMP('2013-12-06 10:45:51','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=488
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Dec 6, 2013 10:45:51 AM CET
|
||||||
|
UPDATE AD_Field SET SeqNo=50,Updated=TO_TIMESTAMP('2013-12-06 10:45:51','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=489
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Dec 6, 2013 10:45:51 AM CET
|
||||||
|
UPDATE AD_Field SET SeqNo=60,Updated=TO_TIMESTAMP('2013-12-06 10:45:51','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=1552
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Dec 6, 2013 10:45:51 AM CET
|
||||||
|
UPDATE AD_Field SET SeqNo=70,Updated=TO_TIMESTAMP('2013-12-06 10:45:51','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=202543
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Dec 6, 2013 10:45:51 AM CET
|
||||||
|
UPDATE AD_Field SET SeqNo=0,Updated=TO_TIMESTAMP('2013-12-06 10:45:51','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=202542
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Dec 6, 2013 10:45:51 AM CET
|
||||||
|
UPDATE AD_Field SET SeqNo=0,Updated=TO_TIMESTAMP('2013-12-06 10:45:51','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=485
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Dec 6, 2013 10:46:03 AM CET
|
||||||
|
UPDATE AD_Field SET SeqNoGrid=0,IsDisplayedGrid='N' WHERE AD_Field_ID=485
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Dec 6, 2013 10:46:03 AM CET
|
||||||
|
UPDATE AD_Field SET SeqNoGrid=10,IsDisplayedGrid='Y' WHERE AD_Field_ID=486
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Dec 6, 2013 10:46:03 AM CET
|
||||||
|
UPDATE AD_Field SET SeqNoGrid=20,IsDisplayedGrid='Y' WHERE AD_Field_ID=2013
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Dec 6, 2013 10:46:03 AM CET
|
||||||
|
UPDATE AD_Field SET SeqNoGrid=30,IsDisplayedGrid='Y' WHERE AD_Field_ID=490
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Dec 6, 2013 10:46:03 AM CET
|
||||||
|
UPDATE AD_Field SET SeqNoGrid=40,IsDisplayedGrid='Y' WHERE AD_Field_ID=488
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Dec 6, 2013 10:46:03 AM CET
|
||||||
|
UPDATE AD_Field SET SeqNoGrid=50,IsDisplayedGrid='Y' WHERE AD_Field_ID=489
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Dec 6, 2013 10:46:03 AM CET
|
||||||
|
UPDATE AD_Field SET SeqNoGrid=60,IsDisplayedGrid='Y' WHERE AD_Field_ID=1552
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Dec 6, 2013 10:46:03 AM CET
|
||||||
|
UPDATE AD_Field SET SeqNoGrid=70,IsDisplayedGrid='Y' WHERE AD_Field_ID=202543
|
||||||
|
;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION nextbusinessday(p_date timestamp with time zone, p_ad_client_id numeric) RETURNS timestamp with time zone
|
||||||
|
AS $$
|
||||||
|
/**
|
||||||
|
*This file is part of Adempiere ERP Bazaar
|
||||||
|
*http://www.adempiere.org
|
||||||
|
*
|
||||||
|
*Copyright (C) 2007 Teo Sarca
|
||||||
|
*
|
||||||
|
*This program is free software; you can redistribute it and/or
|
||||||
|
*modify it under the terms of the GNU General Public License
|
||||||
|
*as published by the Free Software Foundation; either version 2
|
||||||
|
*of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
*This program is distributed in the hope that it will be useful,
|
||||||
|
*but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
*MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
*GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
*You should have received a copy of the GNU General Public License
|
||||||
|
*along with this program; if not, write to the Free Software
|
||||||
|
*Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.of
|
||||||
|
*
|
||||||
|
* Converted to PostgreSQL by Tony Snook,
|
||||||
|
* tspc@dodo.com.au
|
||||||
|
*/
|
||||||
|
DECLARE
|
||||||
|
v_nextDate date := trunc(p_Date);
|
||||||
|
v_offset numeric := 0;
|
||||||
|
v_Saturday numeric := TO_CHAR(TO_DATE('2000-01-01', 'YYYY-MM-DD'), 'D');
|
||||||
|
v_Sunday numeric := (case when v_Saturday = 7 then 1 else v_Saturday + 1 end);
|
||||||
|
v_isHoliday boolean := true;
|
||||||
|
v_country c_country.c_country_id%type;
|
||||||
|
nbd C_NonBusinessDay%ROWTYPE;
|
||||||
|
begin
|
||||||
|
v_isHoliday := true;
|
||||||
|
loop
|
||||||
|
SELECT CASE TO_CHAR(v_nextDate,'D')::numeric
|
||||||
|
WHEN v_Saturday THEN 2
|
||||||
|
WHEN v_Sunday THEN 1
|
||||||
|
ELSE 0
|
||||||
|
END INTO v_offset;
|
||||||
|
v_nextDate := v_nextDate + v_offset::integer;
|
||||||
|
v_isHoliday := false;
|
||||||
|
SELECT COALESCE(MAX(co.c_country_id), 100)
|
||||||
|
INTO v_country
|
||||||
|
FROM ad_client cl
|
||||||
|
JOIN ad_language l ON cl.ad_language = l.ad_language
|
||||||
|
JOIN c_country co ON l.countrycode = co.countrycode
|
||||||
|
WHERE cl.ad_client_id = p_ad_client_id;
|
||||||
|
FOR nbd IN SELECT *
|
||||||
|
FROM C_NonBusinessDay
|
||||||
|
WHERE AD_Client_ID=p_AD_Client_ID and IsActive ='Y' and Date1 >= v_nextDate
|
||||||
|
AND COALESCE(C_Country_ID,0) IN (0, v_country)
|
||||||
|
ORDER BY Date1
|
||||||
|
LOOP
|
||||||
|
exit when v_nextDate <> trunc(nbd.Date1);
|
||||||
|
v_nextDate := v_nextDate + 1;
|
||||||
|
v_isHoliday := true;
|
||||||
|
end loop;
|
||||||
|
exit when v_isHoliday=false;
|
||||||
|
end loop;
|
||||||
|
--
|
||||||
|
return v_nextDate::timestamp with time zone;
|
||||||
|
end;
|
||||||
|
$$
|
||||||
|
LANGUAGE plpgsql;
|
||||||
|
|
||||||
|
SELECT register_migration_script('201401150958_IDEMPIERE-1588.sql') FROM dual
|
||||||
|
;
|
|
@ -77,6 +77,21 @@ public interface I_C_NonBusinessDay
|
||||||
|
|
||||||
public org.compiere.model.I_C_Calendar getC_Calendar() throws RuntimeException;
|
public org.compiere.model.I_C_Calendar getC_Calendar() throws RuntimeException;
|
||||||
|
|
||||||
|
/** Column name C_Country_ID */
|
||||||
|
public static final String COLUMNNAME_C_Country_ID = "C_Country_ID";
|
||||||
|
|
||||||
|
/** Set Country.
|
||||||
|
* Country
|
||||||
|
*/
|
||||||
|
public void setC_Country_ID (int C_Country_ID);
|
||||||
|
|
||||||
|
/** Get Country.
|
||||||
|
* Country
|
||||||
|
*/
|
||||||
|
public int getC_Country_ID();
|
||||||
|
|
||||||
|
public org.compiere.model.I_C_Country getC_Country() throws RuntimeException;
|
||||||
|
|
||||||
/** Column name C_NonBusinessDay_ID */
|
/** Column name C_NonBusinessDay_ID */
|
||||||
public static final String COLUMNNAME_C_NonBusinessDay_ID = "C_NonBusinessDay_ID";
|
public static final String COLUMNNAME_C_NonBusinessDay_ID = "C_NonBusinessDay_ID";
|
||||||
|
|
||||||
|
|
|
@ -180,7 +180,7 @@ public class ScheduleUtil
|
||||||
// ORA-00932: inconsistent datatypes: expected NUMBER got TIMESTAMP
|
// ORA-00932: inconsistent datatypes: expected NUMBER got TIMESTAMP
|
||||||
sql = MRole.getDefault(m_ctx, false).addAccessSQL (
|
sql = MRole.getDefault(m_ctx, false).addAccessSQL (
|
||||||
"SELECT Name, Date1 FROM C_NonBusinessDay "
|
"SELECT Name, Date1 FROM C_NonBusinessDay "
|
||||||
+ "WHERE TRUNC(Date1) BETWEEN ? AND ?",
|
+ "WHERE TRUNC(Date1) BETWEEN ? AND ? AND COALESCE(C_Country_ID) IN (0, ?)",
|
||||||
"C_NonBusinessDay", false, false); // not qualified - RO
|
"C_NonBusinessDay", false, false); // not qualified - RO
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -190,6 +190,7 @@ public class ScheduleUtil
|
||||||
pstmt = DB.prepareStatement(sql, trxName);
|
pstmt = DB.prepareStatement(sql, trxName);
|
||||||
pstmt.setTimestamp(1, startDay);
|
pstmt.setTimestamp(1, startDay);
|
||||||
pstmt.setTimestamp(2, endDay);
|
pstmt.setTimestamp(2, endDay);
|
||||||
|
pstmt.setInt(3, Env.getContextAsInt(m_ctx, "#C_Country_ID"));
|
||||||
rs = pstmt.executeQuery();
|
rs = pstmt.executeQuery();
|
||||||
while (rs.next())
|
while (rs.next())
|
||||||
{
|
{
|
||||||
|
|
|
@ -31,7 +31,7 @@ public class X_C_NonBusinessDay extends PO implements I_C_NonBusinessDay, I_Pers
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = 20131031L;
|
private static final long serialVersionUID = 20131211L;
|
||||||
|
|
||||||
/** Standard Constructor */
|
/** Standard Constructor */
|
||||||
public X_C_NonBusinessDay (Properties ctx, int C_NonBusinessDay_ID, String trxName)
|
public X_C_NonBusinessDay (Properties ctx, int C_NonBusinessDay_ID, String trxName)
|
||||||
|
@ -101,6 +101,34 @@ public class X_C_NonBusinessDay extends PO implements I_C_NonBusinessDay, I_Pers
|
||||||
return ii.intValue();
|
return ii.intValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public org.compiere.model.I_C_Country getC_Country() throws RuntimeException
|
||||||
|
{
|
||||||
|
return (org.compiere.model.I_C_Country)MTable.get(getCtx(), org.compiere.model.I_C_Country.Table_Name)
|
||||||
|
.getPO(getC_Country_ID(), get_TrxName()); }
|
||||||
|
|
||||||
|
/** Set Country.
|
||||||
|
@param C_Country_ID
|
||||||
|
Country
|
||||||
|
*/
|
||||||
|
public void setC_Country_ID (int C_Country_ID)
|
||||||
|
{
|
||||||
|
if (C_Country_ID < 1)
|
||||||
|
set_Value (COLUMNNAME_C_Country_ID, null);
|
||||||
|
else
|
||||||
|
set_Value (COLUMNNAME_C_Country_ID, Integer.valueOf(C_Country_ID));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get Country.
|
||||||
|
@return Country
|
||||||
|
*/
|
||||||
|
public int getC_Country_ID ()
|
||||||
|
{
|
||||||
|
Integer ii = (Integer)get_Value(COLUMNNAME_C_Country_ID);
|
||||||
|
if (ii == null)
|
||||||
|
return 0;
|
||||||
|
return ii.intValue();
|
||||||
|
}
|
||||||
|
|
||||||
/** Set Non Business Day.
|
/** Set Non Business Day.
|
||||||
@param C_NonBusinessDay_ID
|
@param C_NonBusinessDay_ID
|
||||||
Day on which business is not transacted
|
Day on which business is not transacted
|
||||||
|
|
Loading…
Reference in New Issue