From 17143131bf124ae0a8c0384641cefa706f367d1d Mon Sep 17 00:00:00 2001 From: "Redhuan D. Oon" Date: Wed, 17 Dec 2008 15:54:23 +0000 Subject: [PATCH] REVERTING REVISION of [ FR 2432892 ] Re-org of migration directory --- ...dd_c_acctschema_isallownegativeposting.sql | 145 +++++++ .../316-320/002_fix_I_Product_X12DE355.sql | 5 + .../316-320/003_fix_acct_constraints.sql | 52 +++ migration/316-320/004_fix_bug_1705164.sql | 5 + migration/316-320/005_fix_bug_1705537.sql | 7 + .../316-320/006_add_ProductCategoryParent.sql | 102 +++++ migration/316-320/007_country_changes.sql | 53 +++ migration/316-320/008_2pack_enhancements.sql | 79 ++++ migration/316-320/009_fix_bug_1707995.sql | 23 ++ migration/316-320/010_add_feature_1708139.sql | 18 + migration/316-320/011_cleaner_bug_1707995.sql | 8 + migration/316-320/012_M_PriceList_Create.sql | 389 ++++++++++++++++++ migration/316-320/013_version32.sql | 6 + ...cctschema_isallownegativeposting_pgsql.sql | 148 +++++++ .../002_fix_I_Product_X12DE355_pgsql.sql | 4 + .../003_fix_acct_constraints_pgsql.sql | 52 +++ .../postgresql/004_fix_bug_1705164.sql | 5 + .../postgresql/005_fix_bug_1705537.sql | 7 + .../006_add_ProductCategoryParent.sql | 102 +++++ .../postgresql/007_country_changes.sql | 32 ++ .../postgresql/008_2pack_enhancements.sql | 79 ++++ .../postgresql/009_fix_bug_1707995.sql | 20 + .../postgresql/010_add_feature_1708139.sql | 18 + .../postgresql/011_cleaner_bug_1707995.sql | 8 + .../316-320/postgresql/012_alter_column.sql | 111 +++++ .../316-320/postgresql/013_version32.sql | 6 + 26 files changed, 1484 insertions(+) create mode 100644 migration/316-320/001_add_c_acctschema_isallownegativeposting.sql create mode 100644 migration/316-320/002_fix_I_Product_X12DE355.sql create mode 100644 migration/316-320/003_fix_acct_constraints.sql create mode 100644 migration/316-320/004_fix_bug_1705164.sql create mode 100644 migration/316-320/005_fix_bug_1705537.sql create mode 100644 migration/316-320/006_add_ProductCategoryParent.sql create mode 100644 migration/316-320/007_country_changes.sql create mode 100644 migration/316-320/008_2pack_enhancements.sql create mode 100644 migration/316-320/009_fix_bug_1707995.sql create mode 100644 migration/316-320/010_add_feature_1708139.sql create mode 100644 migration/316-320/011_cleaner_bug_1707995.sql create mode 100644 migration/316-320/012_M_PriceList_Create.sql create mode 100644 migration/316-320/013_version32.sql create mode 100644 migration/316-320/postgresql/001_add_c_acctschema_isallownegativeposting_pgsql.sql create mode 100644 migration/316-320/postgresql/002_fix_I_Product_X12DE355_pgsql.sql create mode 100644 migration/316-320/postgresql/003_fix_acct_constraints_pgsql.sql create mode 100644 migration/316-320/postgresql/004_fix_bug_1705164.sql create mode 100644 migration/316-320/postgresql/005_fix_bug_1705537.sql create mode 100644 migration/316-320/postgresql/006_add_ProductCategoryParent.sql create mode 100644 migration/316-320/postgresql/007_country_changes.sql create mode 100644 migration/316-320/postgresql/008_2pack_enhancements.sql create mode 100644 migration/316-320/postgresql/009_fix_bug_1707995.sql create mode 100644 migration/316-320/postgresql/010_add_feature_1708139.sql create mode 100644 migration/316-320/postgresql/011_cleaner_bug_1707995.sql create mode 100644 migration/316-320/postgresql/012_alter_column.sql create mode 100644 migration/316-320/postgresql/013_version32.sql diff --git a/migration/316-320/001_add_c_acctschema_isallownegativeposting.sql b/migration/316-320/001_add_c_acctschema_isallownegativeposting.sql new file mode 100644 index 0000000000..3d51ca1eff --- /dev/null +++ b/migration/316-320/001_add_c_acctschema_isallownegativeposting.sql @@ -0,0 +1,145 @@ +-- ADD C_AcctSchema.IsAllowNegativePosting + +ALTER TABLE C_ACCTSCHEMA ADD isallownegativeposting CHAR(1) DEFAULT 'Y' CHECK (isallownegativeposting IN ('Y','N')); + +INSERT INTO AD_ELEMENT + (ad_org_id, ad_element_id, columnname, + created, createdby, + description, entitytype, isactive, + NAME, printname, + updated, ad_client_id, updatedby + ) + VALUES (0, 50065, 'IsAllowNegativePosting', + TO_DATE ('2007-04-03 18:17:38', 'YYYY-MM-DD HH24:MI:SS'), 100, + 'Allow to post negative accounting values', 'D', 'Y', + 'Allow Negative Posting', 'Allow Negative Posting', + TO_DATE ('2007-04-03 18:17:38', 'YYYY-MM-DD HH24:MI:SS'), 0, 100 + ); + +INSERT INTO AD_COLUMN + (ad_org_id, ad_element_id, ad_reference_id, ad_table_id, + columnname, + created, createdby, + defaultvalue, description, entitytype, fieldlength, isactive, + isalwaysupdateable, isencrypted, isidentifier, iskey, + ismandatory, isparent, isselectioncolumn, issyncdatabase, + istranslated, isupdateable, NAME, seqno, + updated, updatedby, + VERSION, ad_client_id, ad_column_id + ) + VALUES (0, 50065, 20, 265, + 'IsAllowNegativePosting', + TO_DATE ('2007-04-03 18:20:00', 'YYYY-MM-DD HH24:MI:SS'), 100, + 'Y', 'Allow to post negative accounting values', 'D', 1, 'Y', + 'N', 'N', 'N', 'N', + 'N', 'N', 'N', 'N', + 'N', 'Y', 'Allow Negative Posting', 0, + TO_DATE ('2007-04-03 18:20:00', 'YYYY-MM-DD HH24:MI:SS'), 100, + 0, 0, 50210 + ); + +INSERT INTO AD_FIELD + (ad_column_id, ad_org_id, ad_tab_id, + created, createdby, + description, displaylength, entitytype, isactive, + iscentrallymaintained, isdisplayed, isencrypted, isfieldonly, + isheading, isreadonly, issameline, NAME, + updated, ad_client_id, + updatedby, ad_field_id + ) + VALUES (50210, 0, 199, + TO_DATE ('2007-04-03 18:25:16', 'YYYY-MM-DD HH24:MI:SS'), 100, + 'Allow to post negative accounting values', 1, 'D', 'Y', + 'Y', 'Y', 'N', 'N', + 'N', 'N', 'N', 'Allow Negative Posting', + TO_DATE ('2007-04-03 18:25:16', 'YYYY-MM-DD HH24:MI:SS'), 0, + 100, 50180 + ); + +UPDATE AD_FIELD + SET seqno = 260, + updated = TO_DATE ('2007-04-03 18:26:28', 'YYYY-MM-DD HH24:MI:SS'), + updatedby = 100 + WHERE ad_field_id = 12522; + +UPDATE AD_FIELD + SET issameline = 'Y', + seqno = 250, + updated = TO_DATE ('2007-04-03 18:31:50', 'YYYY-MM-DD HH24:MI:SS'), + updatedby = 100 + WHERE ad_field_id = 50180; + +-- update sequences + +UPDATE AD_SEQUENCE + SET currentnextsys = (SELECT MAX (ad_element_id) + 1 + FROM AD_ELEMENT + WHERE ad_element_id < 1000000) + WHERE NAME = 'AD_Element'; + +UPDATE AD_SEQUENCE + SET currentnextsys = (SELECT MAX (ad_column_id) + 1 + FROM AD_COLUMN + WHERE ad_column_id < 1000000) + WHERE NAME = 'AD_Column'; + +UPDATE AD_SEQUENCE + SET currentnextsys = (SELECT MAX (ad_field_id) + 1 + FROM AD_FIELD + WHERE ad_field_id < 1000000) + WHERE NAME = 'AD_Field'; + +-- insert translation tables +INSERT INTO AD_ELEMENT_TRL + (ad_element_id, AD_LANGUAGE, ad_client_id, ad_org_id, isactive, + created, createdby, updated, updatedby, NAME, printname, + description, HELP, po_name, po_printname, po_description, + po_help, istranslated) + SELECT e.ad_element_id, l.AD_LANGUAGE, e.ad_client_id, e.ad_org_id, + e.isactive, e.created, e.createdby, e.updated, e.updatedby, e.NAME, + e.printname, e.description, e.HELP, e.po_name, e.po_printname, + e.po_description, e.po_help, 'N' istranslated + FROM AD_ELEMENT e, AD_LANGUAGE l + WHERE e.ad_element_id = 50065 + AND l.issystemlanguage = 'Y' + AND l.isbaselanguage = 'N' + AND NOT EXISTS ( + SELECT 1 + FROM AD_ELEMENT_TRL et + WHERE et.ad_element_id = e.ad_element_id + AND et.AD_LANGUAGE = l.AD_LANGUAGE); + +INSERT INTO AD_COLUMN_TRL + (ad_column_id, AD_LANGUAGE, ad_client_id, ad_org_id, isactive, + created, createdby, updated, updatedby, NAME, istranslated) + SELECT c.ad_column_id, l.AD_LANGUAGE, c.ad_client_id, c.ad_org_id, + c.isactive, c.created, c.createdby, c.updated, c.updatedby, c.NAME, + 'N' istranslated + FROM AD_COLUMN c, AD_LANGUAGE l + WHERE c.ad_column_id = 50210 + AND l.issystemlanguage = 'Y' + AND l.isbaselanguage = 'N' + AND NOT EXISTS ( + SELECT 1 + FROM AD_COLUMN_TRL ct + WHERE ct.ad_column_id = c.ad_column_id + AND ct.AD_LANGUAGE = l.AD_LANGUAGE); + +INSERT INTO AD_FIELD_TRL + (ad_field_id, AD_LANGUAGE, ad_client_id, ad_org_id, isactive, + created, createdby, updated, updatedby, NAME, description, HELP, + istranslated) + SELECT f.ad_field_id, l.AD_LANGUAGE, f.ad_client_id, f.ad_org_id, + f.isactive, f.created, f.createdby, f.updated, f.updatedby, f.NAME, + f.description, f.HELP, 'N' istranslated + FROM AD_FIELD f, AD_LANGUAGE l + WHERE f.ad_field_id = 50180 + AND l.issystemlanguage = 'Y' + AND l.isbaselanguage = 'N' + AND NOT EXISTS ( + SELECT 1 + FROM AD_FIELD_TRL ft + WHERE ft.ad_field_id = f.ad_field_id + AND ft.AD_LANGUAGE = l.AD_LANGUAGE); + +COMMIT ; diff --git a/migration/316-320/002_fix_I_Product_X12DE355.sql b/migration/316-320/002_fix_I_Product_X12DE355.sql new file mode 100644 index 0000000000..56fb536299 --- /dev/null +++ b/migration/316-320/002_fix_I_Product_X12DE355.sql @@ -0,0 +1,5 @@ +-- Fix I_Product.X12DE355 FieldLength: +ALTER TABLE I_Product MODIFY X12DE355 NVARCHAR2(4); +UPDATE AD_Column SET FieldLength=4 WHERE AD_Column_ID=7862; +COMMIT; + diff --git a/migration/316-320/003_fix_acct_constraints.sql b/migration/316-320/003_fix_acct_constraints.sql new file mode 100644 index 0000000000..8c4d7b79da --- /dev/null +++ b/migration/316-320/003_fix_acct_constraints.sql @@ -0,0 +1,52 @@ +ALTER TABLE C_CHARGE_ACCT DROP CONSTRAINT CCHRAGE_CCHARGEACCT; +ALTER TABLE C_CHARGE_ACCT ADD CONSTRAINT CCHRAGE_CCHARGEACCT + FOREIGN KEY (C_CHARGE_ID) REFERENCES C_CHARGE(C_CHARGE_ID) + ON DELETE CASCADE + ENABLE NOVALIDATE; + +ALTER TABLE A_ASSET_ACCT DROP CONSTRAINT AASSET_AASSETACCT; +ALTER TABLE A_ASSET_ACCT ADD CONSTRAINT AASSET_AASSETACCT + FOREIGN KEY (A_ASSET_ID) REFERENCES A_ASSET(A_ASSET_ID) + ON DELETE CASCADE + ENABLE NOVALIDATE; + +ALTER TABLE A_ASSET_GROUP_ACCT DROP CONSTRAINT AASSETGROUP_AASSETGROUPACCT; +ALTER TABLE A_ASSET_GROUP_ACCT ADD CONSTRAINT AASSETGROUP_AASSETGROUPACCT + FOREIGN KEY (A_ASSET_GROUP_ID) REFERENCES A_ASSET_GROUP (A_ASSET_GROUP_ID) + ON DELETE CASCADE + ENABLE NOVALIDATE; + +ALTER TABLE C_BANKACCOUNT_ACCT DROP CONSTRAINT CBANKACCOUNT_CBANKACCTACCT; +ALTER TABLE C_BANKACCOUNT_ACCT ADD CONSTRAINT CBANKACCOUNT_CBANKACCTACCT + FOREIGN KEY (C_BANKACCOUNT_ID) REFERENCES C_BANKACCOUNT (C_BANKACCOUNT_ID) + ON DELETE CASCADE + ENABLE NOVALIDATE; + +ALTER TABLE C_BP_GROUP_ACCT DROP CONSTRAINT CBPGROUP_CBPGROUPACCT; +ALTER TABLE C_BP_GROUP_ACCT ADD CONSTRAINT CBPGROUP_CBPGROUPACCT + FOREIGN KEY (C_BP_GROUP_ID) REFERENCES C_BP_GROUP (C_BP_GROUP_ID) + ON DELETE CASCADE + ENABLE NOVALIDATE; + +ALTER TABLE C_INTERORG_ACCT DROP CONSTRAINT ADORG_CINTERORGACCT; +ALTER TABLE C_INTERORG_ACCT ADD CONSTRAINT ADORG_CINTERORGACCT + FOREIGN KEY (AD_ORG_ID) REFERENCES AD_ORG (AD_ORG_ID) + ON DELETE CASCADE + ENABLE NOVALIDATE; +ALTER TABLE C_INTERORG_ACCT DROP CONSTRAINT ADORGTO_CINTERORGACCT; +ALTER TABLE C_INTERORG_ACCT ADD CONSTRAINT ADORGTO_CINTERORGACCT + FOREIGN KEY (AD_ORGTO_ID) REFERENCES AD_ORG (AD_ORG_ID) + ON DELETE CASCADE + ENABLE NOVALIDATE; + +ALTER TABLE C_CURRENCY_ACCT DROP CONSTRAINT CACCTSCHEMA_CCURRENCYACCT; +ALTER TABLE C_CURRENCY_ACCT ADD CONSTRAINT CACCTSCHEMA_CCURRENCYACCT + FOREIGN KEY (C_ACCTSCHEMA_ID) REFERENCES C_ACCTSCHEMA (C_ACCTSCHEMA_ID) + ON DELETE CASCADE + ENABLE NOVALIDATE; + +ALTER TABLE C_CURRENCY_ACCT DROP CONSTRAINT CCURRENCY_CCURRENCYACCT; +ALTER TABLE C_CURRENCY_ACCT ADD CONSTRAINT CCURRENCY_CCURRENCYACCT + FOREIGN KEY (C_CURRENCY_ID) REFERENCES C_CURRENCY (C_CURRENCY_ID) + ON DELETE CASCADE + ENABLE NOVALIDATE; diff --git a/migration/316-320/004_fix_bug_1705164.sql b/migration/316-320/004_fix_bug_1705164.sql new file mode 100644 index 0000000000..cdb77f4b9d --- /dev/null +++ b/migration/316-320/004_fix_bug_1705164.sql @@ -0,0 +1,5 @@ +UPDATE AD_FIELD + SET issameline = 'N' + WHERE ad_field_id = 2204; + +COMMIT; \ No newline at end of file diff --git a/migration/316-320/005_fix_bug_1705537.sql b/migration/316-320/005_fix_bug_1705537.sql new file mode 100644 index 0000000000..4ab6d84176 --- /dev/null +++ b/migration/316-320/005_fix_bug_1705537.sql @@ -0,0 +1,7 @@ +UPDATE AD_COLUMN + SET ad_reference_value_id = 182, + updated = TO_DATE ('2007-04-22 23:11:58', 'YYYY-MM-DD HH24:MI:SS'), + updatedby = 100 + WHERE ad_column_id = 7968; + +COMMIT; diff --git a/migration/316-320/006_add_ProductCategoryParent.sql b/migration/316-320/006_add_ProductCategoryParent.sql new file mode 100644 index 0000000000..abcc46f2a8 --- /dev/null +++ b/migration/316-320/006_add_ProductCategoryParent.sql @@ -0,0 +1,102 @@ +INSERT INTO ad_element + (ad_element_id, ad_client_id, ad_org_id, isactive, + created, createdby, + updated, updatedby, + columnname, entitytype, NAME, + printname + ) + VALUES (50070, 0, 0, 'Y', + TO_DATE ('04/24/2007 12:30:00', 'MM/DD/YYYY HH24:MI:SS'), 100, + TO_DATE ('04/24/2007 12:30:00', 'MM/DD/YYYY HH24:MI:SS'), 100, + 'M_Product_Category_Parent_ID', 'D', 'Parent Product Category', + 'Parent Product Category' + ); + + +INSERT INTO ad_column + (ad_column_id, ad_client_id, ad_org_id, isactive, + created, + updated, createdby, + updatedby, name, description, help, version, + entitytype, columnname, ad_table_id, ad_reference_id, + ad_reference_value_id, + fieldlength, iskey, isparent, ismandatory, isupdateable, + isidentifier, seqno, istranslated, isencrypted, + isselectioncolumn, ad_element_id, callout, issyncdatabase, + isalwaysupdateable + ) + VALUES (50211, 0, 0, 'Y', + TO_DATE ('04/24/2007 12:30:00', 'MM/DD/YYYY HH24:MI:SS'), + TO_DATE ('04/24/2007 12:30:00', 'MM/DD/YYYY HH24:MI:SS'), 100, + 100, 'Parent Product Category', 'Parent Product Category', 'The parent product category is used to build a category tree.', 1, + 'D', 'M_Product_Category_Parent_ID', 209, 18, + 163, + 22, 'N', 'N', 'N', 'Y', + 'N', 0, 'N', 'N', + 'N', 50070, 'org.compiere.model.CalloutProductCategory.testForLoop', 'N', + 'N' + ); + + +INSERT INTO ad_field + (ad_field_id, ad_client_id, ad_org_id, isactive, + created, createdby, + updated, updatedby, + name, description, iscentrallymaintained, seqno, ad_tab_id, + ad_column_id, isdisplayed, displaylength, isreadonly, + issameline, isheading, isfieldonly, isencrypted, entitytype + ) + VALUES (50181, 0, 0, 'Y', + TO_DATE ('04/24/2007 12:30:00', 'MM/DD/YYYY HH24:MI:SS'), 100, + TO_DATE ('04/24/2007 12:30:00', 'MM/DD/YYYY HH24:MI:SS'), 100, + 'Parent Product Category', 'Parent Product Category', 'Y', 60, 189, + 50211, 'Y', 22, 'N', + 'N', 'N', 'N', 'N', 'D' + ); + +INSERT INTO ad_message + (ad_message_id, ad_client_id, ad_org_id, isactive, + created, createdby, + updated, updatedby, + value, msgtext, msgtype + ) + VALUES (50014, 0, 0, 'Y', + TO_DATE ('04/24/2007 12:30:00', 'MM/DD/YYYY HH24:MI:SS'), 100, + TO_DATE ('04/24/2007 12:30:00', 'MM/DD/YYYY HH24:MI:SS'), 100, + 'ProductCategoryLoopDetected', + 'A loop in the product category tree has been detected - the old value will be restored','E' + ); + +COMMIT ; + +UPDATE ad_sequence + SET currentnextsys = (SELECT MAX (ad_element_id) + 1 + FROM ad_element + WHERE ad_element_id < 1000000) + WHERE NAME = 'AD_Element'; + +UPDATE ad_sequence + SET currentnextsys = (SELECT MAX (ad_column_id) + 1 + FROM ad_column + WHERE ad_column_id < 1000000) + WHERE NAME = 'AD_Column'; + +UPDATE ad_sequence + SET currentnextsys = (SELECT MAX (ad_field_id) + 1 + FROM ad_field + WHERE ad_field_id < 1000000) + WHERE NAME = 'AD_Field'; + + UPDATE ad_sequence + SET currentnextsys = (SELECT MAX (ad_message_id) + 1 + FROM ad_message + WHERE ad_message_id < 1000000) + WHERE NAME = 'AD_Message'; + + +ALTER TABLE M_Product_Category ADD M_Product_Category_Parent_ID NUMBER(10,0); +ALTER TABLE M_Product_Category ADD CONSTRAINT MProductCat_ParentCat FOREIGN KEY (M_Product_Category_Parent_ID) + REFERENCES M_Product_Category (M_Product_Category_ID); +UPDATE AD_Column SET IsSelectionColumn='Y' WHERE AD_Column_ID=2012; + +COMMIT ; \ No newline at end of file diff --git a/migration/316-320/007_country_changes.sql b/migration/316-320/007_country_changes.sql new file mode 100644 index 0000000000..2f646566ac --- /dev/null +++ b/migration/316-320/007_country_changes.sql @@ -0,0 +1,53 @@ +-- juddm BugFix:(Country Changes) + +--add Serbian currency +INSERT INTO C_CURRENCY + (c_currency_id, ad_client_id, ad_org_id, isactive, created, + createdby, updated, updatedby, iso_code, cursymbol, + description, stdprecision, costingprecision, iseuro, isemumember + ) + VALUES (347, 0, 0, 'Y', TO_DATE ('2003-08-06', 'YYYY-MM-DD'), + 0, TO_DATE ('2000-01-02', 'YYYY-MM-DD'), 0, 'RSD', 'RSD', + 'Serbian Dinar', 2, 4, 'N', 'N' + ); + +-- add country Serbia +INSERT INTO C_COUNTRY + (c_country_id, ad_client_id, ad_org_id, isactive, created, + createdby, updated, updatedby, NAME, description, + countrycode, hasregion, displaysequence, haspostal_add, + c_currency_id, isaddresslinesreverse, isaddresslineslocalreverse + ) + VALUES (349, 0, 0, 'Y', TO_DATE ('2003-03-09', 'YYYY-MM-DD'), + 0, TO_DATE ('2000-01-02', 'YYYY-MM-DD'), 0, 'Serbia', 'Serbia', + 'RS', 'N', '@C@, @P@', 'N', + 347, 'N', 'N' + ); + +-- add country Montenegro +INSERT INTO C_COUNTRY + (c_country_id, ad_client_id, ad_org_id, isactive, created, + createdby, updated, updatedby, NAME, + description, countrycode, hasregion, displaysequence, + haspostal_add, c_currency_id, isaddresslinesreverse, + isaddresslineslocalreverse + ) + VALUES (350, 0, 0, 'Y', TO_DATE ('2003-03-09', 'YYYY-MM-DD'), + 0, TO_DATE ('2000-01-02', 'YYYY-MM-DD'), 0, 'Montenegro', + 'Montenegro', 'ME', 'N', '@C@, @P@', + 'N', 102, 'N', + 'N' + ); + +-- deactivate Yugoslavia +UPDATE C_COUNTRY + SET isactive = 'N' + WHERE c_country_id = 346; + + +-- deactivate Yugoslavia currency +UPDATE C_CURRENCY + SET isactive = 'N' + WHERE c_currency_id = 314; + +COMMIT ; diff --git a/migration/316-320/008_2pack_enhancements.sql b/migration/316-320/008_2pack_enhancements.sql new file mode 100644 index 0000000000..f5cfce67f6 --- /dev/null +++ b/migration/316-320/008_2pack_enhancements.sql @@ -0,0 +1,79 @@ +ALTER TABLE AD_PACKAGE_EXP_DETAIL ADD ad_val_rule_id NUMBER(10); + +INSERT INTO AD_COLUMN + (ad_column_id, ad_client_id, ad_org_id, isactive, + created, + updated, createdby, + updatedby, NAME, description, + HELP, + VERSION, entitytype, columnname, ad_table_id, ad_reference_id, + fieldlength, iskey, isparent, ismandatory, isupdateable, + isidentifier, seqno, istranslated, isencrypted, + isselectioncolumn, ad_element_id, issyncdatabase, + isalwaysupdateable + ) + VALUES (50212, 0, 0, 'Y', + TO_DATE ('04/26/2007 03:24:26', 'MM/DD/YYYY HH24:MI:SS'), + TO_DATE ('04/26/2007 03:24:26', 'MM/DD/YYYY HH24:MI:SS'), 100, + 100, 'Dynamic Validation', 'Dynamic Validation Rule', + 'These rules define how an entry is determined to valid. You can use variables for dynamic (context sensitive) validation.', + 0, 'D', 'AD_Val_Rule_ID', 50006, 18, + 22, 'N', 'N', 'N', 'Y', + 'N', 0, 'N', 'N', + 'N', 139, 'N', + 'N' + ); + +INSERT INTO AD_FIELD + (ad_field_id, ad_client_id, ad_org_id, isactive, + created, createdby, + updated, updatedby, + NAME, description, + HELP, + iscentrallymaintained, ad_tab_id, ad_column_id, isdisplayed, + displaylogic, displaylength, isreadonly, seqno, issameline, + isheading, isfieldonly, isencrypted, entitytype + ) + VALUES (50182, 0, 0, 'Y', + TO_DATE ('04/26/2007 03:28:08', 'MM/DD/YYYY HH24:MI:SS'), 100, + TO_DATE ('04/26/2007 03:30:25', 'MM/DD/YYYY HH24:MI:SS'), 100, + 'Dynamic Validation', 'Dynamic Validation Rule', + 'These rules define how an entry is determined to valid. You can use variables for dynamic (context sensitive) validation.', + 'Y', 50006, 50212, 'Y', + '@Type@=''V''', 22, 'N', 245, 'N', + 'N', 'N', 'N', 'D' + ); + +INSERT INTO AD_REF_LIST + (ad_ref_list_id, ad_client_id, ad_org_id, isactive, + created, createdby, + updated, updatedby, + VALUE, NAME, ad_reference_id, entitytype + ) + VALUES (50041, 0, 0, 'Y', + TO_DATE ('04/26/2007 03:33:05', 'MM/DD/YYYY HH24:MI:SS'), 100, + TO_DATE ('04/26/2007 03:33:05', 'MM/DD/YYYY HH24:MI:SS'), 100, + 'V', 'Dynamic Validation Rule', 50004, 'D' + ); + +COMMIT ; + +UPDATE AD_SEQUENCE + SET currentnextsys = (SELECT MAX (ad_column_id) + 1 + FROM AD_COLUMN + WHERE ad_column_id < 1000000) + WHERE NAME = 'AD_Column'; + +UPDATE AD_SEQUENCE + SET currentnextsys = (SELECT MAX (ad_field_id) + 1 + FROM AD_FIELD + WHERE ad_field_id < 1000000) + WHERE NAME = 'AD_Field'; + +UPDATE AD_SEQUENCE + SET currentnextsys = (SELECT MAX (ad_ref_list_id) + 1 + FROM AD_REF_LIST + WHERE ad_ref_list_id < 1000000) + WHERE NAME = 'AD_Ref_List'; + +COMMIT ; diff --git a/migration/316-320/009_fix_bug_1707995.sql b/migration/316-320/009_fix_bug_1707995.sql new file mode 100644 index 0000000000..65b0c8e478 --- /dev/null +++ b/migration/316-320/009_fix_bug_1707995.sql @@ -0,0 +1,23 @@ +-- Bug Fix +-- http://sourceforge.net/tracker/index.php?func=detail&aid=1707995&group_id=176962&atid=879332 + +SET DEFINE OFF; +SET SQLBLANKLINES OFF; + +INSERT INTO AD_VAL_RULE (ad_val_rule_id, ad_client_id, ad_org_id, isactive, created, createdby, updated, updatedby, NAME, description, + TYPE, code, entitytype ) + VALUES(271, 0, 0, 'Y', TO_DATE('2007-04-26','YYYY-MM-DD'), 100, TO_DATE('2007-04-26','YYYY-MM-DD'), 100, 'M_PriceList is SO/PO', 'Limits the Sales & Purchase Order window to the correct price lsits', + 'S', '(M_PriceList.IsSOPriceList = ''Y'' AND ''@IsSOTrx@''=''Y'') OR (M_PriceList.IsSOPriceList = ''N'' AND ''@IsSOTrx@''=''N'')', 'D'); + +UPDATE AD_COLUMN SET ad_val_rule_id = 271 WHERE ad_column_id = 2204; + + +COMMIT; + +UPDATE AD_SEQUENCE + SET currentnextsys = (SELECT MAX (ad_val_rule_id) + 1 + FROM AD_VAL_RULE + WHERE ad_val_rule_id < 1000000) + WHERE NAME = 'AD_Val_Rule'; + +COMMIT; diff --git a/migration/316-320/010_add_feature_1708139.sql b/migration/316-320/010_add_feature_1708139.sql new file mode 100644 index 0000000000..ab4d24b5a1 --- /dev/null +++ b/migration/316-320/010_add_feature_1708139.sql @@ -0,0 +1,18 @@ +-- Feature Request - Allow rounding up of price list (schema) to nearest 5 or 9 unit of currency +-- http://sourceforge.net/tracker/index.php?func=detail&aid=1708139&group_id=176962&atid=879335 + +INSERT INTO AD_REF_LIST + (ad_ref_list_id, ad_client_id, ad_org_id, isactive, created, createdby, updated, updatedby, + value, name, description, ad_reference_id, validfrom, validto, entitytype ) + VALUES (50042, 0, 0, 'Y', TO_DATE('2007-04-26','YYYY-MM-DD'),100, TO_DATE('2007-04-26','YYYY-MM-DD'), 100, + 9, 'Ending in 9/5', 'The price ends in either a 5 or 9 whole unit',155,NULL,NULL,'D'); + +COMMIT; + +UPDATE AD_SEQUENCE + SET currentnextsys = (SELECT MAX (ad_ref_list_id) + 1 + FROM AD_REF_LIST + WHERE ad_ref_list_id < 1000000) + WHERE NAME = 'AD_Ref_List'; + +COMMIT; diff --git a/migration/316-320/011_cleaner_bug_1707995.sql b/migration/316-320/011_cleaner_bug_1707995.sql new file mode 100644 index 0000000000..741e22a327 --- /dev/null +++ b/migration/316-320/011_cleaner_bug_1707995.sql @@ -0,0 +1,8 @@ +-- equivalent cleaner code + +UPDATE AD_VAL_RULE + SET code = 'M_PriceList.IsSOPriceList = ''@IsSOTrx@''' + WHERE ad_val_rule_id = 271; + +COMMIT; + \ No newline at end of file diff --git a/migration/316-320/012_M_PriceList_Create.sql b/migration/316-320/012_M_PriceList_Create.sql new file mode 100644 index 0000000000..0ed0817fe2 --- /dev/null +++ b/migration/316-320/012_M_PriceList_Create.sql @@ -0,0 +1,389 @@ +CREATE OR REPLACE +PROCEDURE "M_PRICELIST_CREATE" +( + PInstance_ID IN NUMBER +) +AS +/************************************************************************* + * 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-2003 Jorg Janke, ComPiere, Inc. All Rights Reserved. + ************************************************************************* + * $Id: M_PriceList_Create.sql,v 1.1 2006/04/21 17:51:58 jjanke Exp $ + *** + * Title: Create Pricelist + * Description: + * Create PriceList by copying purchase prices (M_Product_PO) + * and applying product category discounts (M_CategoryDiscount) + * Carlos Ruiz - globalqss - Make T_Selection tables permanent + ************************************************************************/ + -- Logistice + ResultStr VARCHAR2(2000); + Message VARCHAR2(2000) := ''; + NoRate EXCEPTION; + -- Parameter + CURSOR Cur_Parameter (PInstance NUMBER) IS + SELECT i.Record_ID, p.ParameterName, p.P_String, p.P_Number, p.P_Date + FROM AD_PInstance i, AD_PInstance_Para p + WHERE i.AD_PInstance_ID=PInstance + AND i.AD_PInstance_ID=p.AD_PInstance_ID(+) + ORDER BY p.SeqNo; + -- Parameter Variables + p_PriceList_Version_ID NUMBER; + p_DeleteOld CHAR(1) := 'N'; + -- + v_Currency_ID NUMBER; + v_Client_ID NUMBER; + v_Org_ID NUMBER; + v_UpdatedBy NUMBER; + v_StdPrecision NUMBER; + v_DiscountSchema_ID NUMBER; + v_PriceList_Version_Base_ID NUMBER; + -- + v_NextNo NUMBER := 0; + + -- Get PL Parameter + CURSOR Cur_DiscountLine (DiscountSchema_ID NUMBER) IS + SELECT * + FROM M_DiscountSchemaLine + WHERE M_DiscountSchema_ID=DiscountSchema_ID + AND IsActive='Y' + ORDER BY SeqNo; + +BEGIN + -- Update AD_PInstance + DBMS_OUTPUT.PUT_LINE('Updating PInstance - Processing'); + ResultStr := 'PInstanceNotFound'; + UPDATE AD_PInstance + SET Created = SysDate, + IsProcessing = 'Y' + WHERE AD_PInstance_ID=PInstance_ID; + COMMIT; + + -- Get Parameters + ResultStr := 'ReadingParameters'; + FOR p IN Cur_Parameter (PInstance_ID) LOOP + p_PriceList_Version_ID := p.Record_ID; + IF (p.ParameterName = 'DeleteOld') THEN + p_DeleteOld := p.P_String; + DBMS_OUTPUT.PUT_LINE(' DeleteOld=' || p_DeleteOld); + ELSE + DBMS_OUTPUT.PUT_LINE('*** Unknown Parameter=' || p.ParameterName); + END IF; + END LOOP; -- Get Parameter + DBMS_OUTPUT.PUT_LINE(' PriceList_Version_ID=' || p_PriceList_Version_ID); + + -- Checking Prerequisites + -- -- PO Prices must exists + ResultStr := 'CorrectingProductPO'; + DBMS_OUTPUT.PUT_LINE(ResultStr); + UPDATE M_Product_PO + SET PriceList = 0 + WHERE PriceList IS NULL; + UPDATE M_Product_PO + SET PriceLastPO = 0 + WHERE PriceLastPO IS NULL; + UPDATE M_Product_PO + SET PricePO = PriceLastPO + WHERE (PricePO IS NULL OR PricePO = 0) AND PriceLastPO <> 0; + UPDATE M_Product_PO + SET PricePO = 0 + WHERE PricePO IS NULL; + -- Set default current vendor + UPDATE M_Product_PO p + SET IsCurrentVendor = 'Y' + WHERE IsCurrentVendor = 'N' + AND NOT EXISTS + (SELECT pp.M_Product_ID FROM M_Product_PO pp + WHERE pp.M_Product_ID=p.M_Product_ID + GROUP BY pp.M_Product_ID HAVING COUNT(*) > 1); + COMMIT; + + /** + * Make sure that we have only one active product + */ + ResultStr := 'CorrectingDuplicates'; + DBMS_OUTPUT.PUT_LINE(ResultStr); + DECLARE + -- All duplicate products + CURSOR Cur_Duplicates IS + SELECT DISTINCT M_Product_ID + FROM M_Product_PO po + WHERE IsCurrentVendor='Y' AND IsActive='Y' + AND EXISTS ( SELECT M_Product_ID FROM M_Product_PO x + WHERE x.M_Product_ID=po.M_Product_ID + GROUP BY M_Product_ID HAVING COUNT(*) > 1 ) + ORDER BY 1; + -- All vendors of Product - expensive first + CURSOR Cur_Vendors (Product_ID NUMBER) IS + SELECT M_Product_ID, C_BPartner_ID + FROM M_Product_PO + WHERE IsCurrentVendor='Y' AND IsActive='Y' + AND M_Product_ID=Product_ID + ORDER BY PriceList DESC; + -- + Product_ID NUMBER; + BPartner_ID NUMBER; + BEGIN + FOR dupl IN Cur_Duplicates LOOP + OPEN Cur_Vendors (dupl.M_Product_ID); + FETCH Cur_Vendors INTO Product_ID, BPartner_ID; -- Leave First + LOOP + FETCH Cur_Vendors INTO Product_ID, BPartner_ID; -- Get Record ID + EXIT WHEN Cur_Vendors%NOTFOUND; + -- + DBMS_OUTPUT.PUT_LINE(' Record: ' || Product_ID || ' / ' || BPartner_ID); + UPDATE M_Product_PO + SET IsCurrentVendor='N' + WHERE M_Product_ID=Product_ID AND C_BPartner_ID=BPartner_ID; + END LOOP; + CLOSE Cur_Vendors; + END LOOP; + COMMIT; + END; + + /** Delete Old Data */ + ResultStr := 'DeletingOld'; + IF (p_DeleteOld = 'Y') THEN + DELETE M_ProductPrice + WHERE M_PriceList_Version_ID = p_PriceList_Version_ID; + Message := '@Deleted@=' || SQL%ROWCOUNT || ' - '; + DBMS_OUTPUT.PUT_LINE(Message); + END IF; + + -- Get PriceList Info + ResultStr := 'GetPLInfo'; + DBMS_OUTPUT.PUT_LINE(ResultStr); + SELECT p.C_Currency_ID, c.StdPrecision, + v.AD_Client_ID, v.AD_Org_ID, v.UpdatedBy, + v.M_DiscountSchema_ID, M_PriceList_Version_Base_ID + INTO v_Currency_ID, v_StdPrecision, + v_Client_ID, v_Org_ID, v_UpdatedBy, + v_DiscountSchema_ID, v_PriceList_Version_Base_ID + FROM M_PriceList p, M_PriceList_Version v, C_Currency c + WHERE p.M_PriceList_ID=v.M_PriceList_ID + AND p.C_Currency_ID=c.C_Currency_ID + AND v.M_PriceList_Version_ID=p_PriceList_Version_ID; + + /** + * For All Discount Lines in Sequence + */ + FOR dl IN Cur_DiscountLine (v_DiscountSchema_ID) LOOP + ResultStr := 'Parameter Seq=' || dl.SeqNo; + -- DBMS_OUTPUT.PUT_LINE(ResultStr); + + -- Clear Temporary Table + DELETE FROM T_Selection WHERE AD_PInstance_ID = PInstance_ID; + + -- ----------------------------------- + -- Create Selection in temporary table + -- ----------------------------------- + IF (v_PriceList_Version_Base_ID IS NULL) THEN + -- Create Selection from M_Product_PO + INSERT INTO T_Selection (AD_PInstance_ID, T_Selection_ID) + SELECT DISTINCT PInstance_ID, po.M_Product_ID + FROM M_Product p, M_Product_PO po + WHERE p.M_Product_ID=po.M_Product_ID + AND (p.AD_Client_ID=v_Client_ID OR p.AD_Client_ID=0) + AND p.IsActive='Y' AND po.IsActive='Y' AND po.IsCurrentVendor='Y' + -- Optional Restrictions + AND (dl.M_Product_Category_ID IS NULL OR p.M_Product_Category_ID IN ( + SELECT M_Product_Category_ID FROM M_Product_Category + START WITH M_Product_Category_ID=dl.M_Product_Category_ID + CONNECT BY M_Product_Category_Parent_ID = PRIOR M_Product_Category_ID + )) + AND (dl.C_BPartner_ID IS NULL OR po.C_BPartner_ID=dl.C_BPartner_ID) + AND (dl.M_Product_ID IS NULL OR p.M_Product_ID=dl.M_Product_ID); + ELSE + -- Create Selection from existing PriceList + INSERT INTO T_Selection (AD_PInstance_ID, T_Selection_ID) + SELECT DISTINCT PInstance_ID, p.M_Product_ID + FROM M_Product p, M_ProductPrice pp + WHERE p.M_Product_ID=pp.M_Product_ID + AND pp.M_PriceList_Version_ID=v_PriceList_Version_Base_ID + AND p.IsActive='Y' AND pp.IsActive='Y' + -- Optional Restrictions + AND (dl.M_Product_Category_ID IS NULL OR p.M_Product_Category_ID IN ( + SELECT M_Product_Category_ID FROM M_Product_Category + START WITH M_Product_Category_ID=dl.M_Product_Category_ID + CONNECT BY M_Product_Category_Parent_ID = PRIOR M_Product_Category_ID + )) + AND (dl.C_BPartner_ID IS NULL OR EXISTS + (SELECT * FROM M_Product_PO po WHERE po.M_Product_ID=p.M_Product_ID AND po.C_BPartner_ID=dl.C_BPartner_ID)) + AND (dl.M_Product_ID IS NULL OR p.M_Product_ID=dl.M_Product_ID); + END IF; + Message := Message || '@Selected@=' || SQL%ROWCOUNT; + -- DBMS_OUTPUT.PUT_LINE(Message); + + -- Delete Prices in Selection, so that we can insert + IF (v_PriceList_Version_Base_ID IS NULL + OR v_PriceList_Version_Base_ID <> p_PriceList_Version_ID) THEN + ResultStr := ResultStr || ', Delete'; + DELETE M_ProductPrice pp + WHERE pp.M_PriceList_Version_ID = p_PriceList_Version_ID + AND EXISTS (SELECT * FROM T_Selection s WHERE pp.M_Product_ID=s.T_Selection_ID + AND s.AD_PInstance_ID = PInstance_ID); + Message := ', @Deleted@=' || SQL%ROWCOUNT; + END IF; + + -- -------------------- + -- Copy (Insert) Prices + -- -------------------- + IF (v_PriceList_Version_Base_ID = p_PriceList_Version_ID) THEN + -- We have Prices already + NULL; + ELSIF (v_PriceList_Version_Base_ID IS NULL) THEN + -- Copy and Convert from Product_PO + ResultStr := ResultStr || ',Copy_PO'; + INSERT INTO M_ProductPrice + (M_PriceList_Version_ID, M_Product_ID, + AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, + PriceList, PriceStd, PriceLimit) + SELECT + p_PriceList_Version_ID, po.M_Product_ID, + v_Client_ID, v_Org_ID, 'Y', SysDate, v_UpdatedBy, SysDate, v_UpdatedBy, + -- Price List + COALESCE(currencyConvert(po.PriceList, + po.C_Currency_ID, v_Currency_ID, dl.ConversionDate, dl.C_ConversionType_ID, v_Client_ID, v_Org_ID),0), + -- Price Std + COALESCE(currencyConvert(po.PriceList, + po.C_Currency_ID, v_Currency_ID, dl.ConversionDate, dl.C_ConversionType_ID, v_Client_ID, v_Org_ID),0), + -- Price Limit + COALESCE(currencyConvert(po.PricePO, + po.C_Currency_ID, v_Currency_ID, dl.ConversionDate, dl.C_ConversionType_ID, v_Client_ID, v_Org_ID),0) + FROM M_Product_PO po + WHERE EXISTS (SELECT * FROM T_Selection s WHERE po.M_Product_ID=s.T_Selection_ID + AND s.AD_PInstance_ID = PInstance_ID) + AND po.IsCurrentVendor='Y' AND po.IsActive='Y'; + ELSE + -- Copy and Convert from other PriceList_Version + ResultStr := ResultStr || ',Copy_PL'; + INSERT INTO M_ProductPrice + (M_PriceList_Version_ID, M_Product_ID, + AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, + PriceList, PriceStd, PriceLimit) + SELECT + p_PriceList_Version_ID, pp.M_Product_ID, + v_Client_ID, v_Org_ID, 'Y', SysDate, v_UpdatedBy, SysDate, v_UpdatedBy, + -- Price List + COALESCE(currencyConvert(pp.PriceList, + pl.C_Currency_ID, v_Currency_ID, dl.ConversionDate, dl.C_ConversionType_ID, v_Client_ID, v_Org_ID),0), + -- Price Std + COALESCE(currencyConvert(pp.PriceStd, + pl.C_Currency_ID, v_Currency_ID, dl.ConversionDate, dl.C_ConversionType_ID, v_Client_ID, v_Org_ID),0), + -- Price Limit + COALESCE(currencyConvert(pp.PriceLimit, + pl.C_Currency_ID, v_Currency_ID, dl.ConversionDate, dl.C_ConversionType_ID, v_Client_ID, v_Org_ID),0) + FROM M_ProductPrice pp + INNER JOIN M_PriceList_Version plv ON (pp.M_PriceList_Version_ID=plv.M_PriceList_Version_ID) + INNER JOIN M_PriceList pl ON (plv.M_PriceList_ID=pl.M_PriceList_ID) + WHERE pp.M_PriceList_Version_ID=v_PriceList_Version_Base_ID + AND EXISTS (SELECT * FROM T_Selection s WHERE pp.M_Product_ID=s.T_Selection_ID + AND s.AD_PInstance_ID = PInstance_ID) + AND pp.IsActive='Y'; + END IF; + Message := Message || ', @Inserted@=' || SQL%ROWCOUNT; + + -- ----------- + -- Calculation + -- ----------- + ResultStr := ResultStr || ',Calc'; + UPDATE M_ProductPrice p + SET PriceList = (DECODE(dl.List_Base, 'S', PriceStd, 'X', PriceLimit, PriceList) + + dl.List_AddAmt) * (1 - dl.List_Discount/100), + PriceStd = (DECODE(dl.Std_Base, 'L', PriceList, 'X', PriceLimit, PriceStd) + + dl.Std_AddAmt) * (1 - dl.Std_Discount/100), + PriceLimit = (DECODE(dl.Limit_Base, 'L', PriceList, 'S', PriceStd, PriceLimit) + + dl.Limit_AddAmt) * (1 - dl.Limit_Discount/100) + WHERE M_PriceList_Version_ID=p_PriceList_Version_ID + AND EXISTS (SELECT * FROM T_Selection s + WHERE s.T_Selection_ID=p.M_Product_ID + AND s.AD_PInstance_ID = PInstance_ID); + + -- -------- + -- Rounding (AD_Reference_ID=155) + -- -------- + ResultStr := ResultStr || ',Round'; + UPDATE M_ProductPrice p + SET PriceList = DECODE(dl.List_Rounding, + 'N', PriceList, + '0', ROUND(PriceList, 0), -- Even .00 + 'D', ROUND(PriceList, 1), -- Dime .10 + 'T', ROUND(PriceList, -1), -- Ten 10.00 + '5', ROUND(PriceList*20,0)/20, -- Nickle .05 + 'Q', ROUND(PriceList*4,0)/4, -- Quarter .25 + ROUND(PriceList, v_StdPrecision)),-- Currency + PriceStd = DECODE(dl.Std_Rounding, + 'N', PriceStd, + '0', ROUND(PriceStd, 0), -- Even .00 + 'D', ROUND(PriceStd, 1), -- Dime .10 + 'T', ROUND(PriceStd, -1), -- Ten 10.00 + '5', ROUND(PriceStd*20,0)/20, -- Nickle .05 + 'Q', ROUND(PriceStd*4,0)/4, -- Quarter .25 + ROUND(PriceStd, v_StdPrecision)), -- Currency + PriceLimit = DECODE(dl.Limit_Rounding, + 'N', PriceLimit, + '0', ROUND(PriceLimit, 0), -- Even .00 + 'D', ROUND(PriceLimit, 1), -- Dime .10 + 'T', ROUND(PriceLimit, -1), -- Ten 10.00 + '5', ROUND(PriceLimit*20,0)/20, -- Nickle .05 + 'Q', ROUND(PriceLimit*4,0)/4, -- Quarter .25 + ROUND(PriceLimit, v_StdPrecision))-- Currency + WHERE M_PriceList_Version_ID=p_PriceList_Version_ID + AND EXISTS (SELECT * FROM T_Selection s + WHERE s.T_Selection_ID=p.M_Product_ID + AND s.AD_PInstance_ID = PInstance_ID); + Message := Message || ', @Updated@=' || SQL%ROWCOUNT; + + -- Fixed Price overwrite + ResultStr := ResultStr || ',Fix'; + UPDATE M_ProductPrice p + SET PriceList = DECODE(dl.List_Base, 'F', dl.List_Fixed, PriceList), + PriceStd = DECODE(dl.Std_Base, 'F', dl.Std_Fixed, PriceStd), + PriceLimit = DECODE(dl.Limit_Base, 'F', dl.Limit_Fixed, PriceLimit) + WHERE M_PriceList_Version_ID=p_PriceList_Version_ID + AND EXISTS (SELECT * FROM T_Selection s + WHERE s.T_Selection_ID=p.M_Product_ID + AND s.AD_PInstance_ID = PInstance_ID); + + -- Log Info + INSERT INTO AD_PInstance_Log (AD_PInstance_ID, Log_ID, P_ID, P_NUMBER, P_MSG) + VALUES (PInstance_ID, v_NextNo, null, dl.SeqNo, Message); + -- + v_NextNo := v_NextNo + 1; + Message := ''; + END LOOP; -- For all DiscountLines + + -- Delete Temporary Selection + DELETE FROM T_Selection WHERE AD_PInstance_ID = PInstance_ID; + + +<> + -- Update AD_PInstance + DBMS_OUTPUT.PUT_LINE(Message); + DBMS_OUTPUT.PUT_LINE('Updating PInstance - Finished'); + UPDATE AD_PInstance + SET Updated = SysDate, + IsProcessing = 'N', + Result = 1, -- success + ErrorMsg = Message + WHERE AD_PInstance_ID=PInstance_ID; + COMMIT; + RETURN; + +EXCEPTION + WHEN OTHERS THEN + ResultStr := ResultStr || ':' || SQLERRM || ' ' || Message; + DBMS_OUTPUT.PUT_LINE(ResultStr); + UPDATE AD_PInstance + SET Updated = SysDate, + IsProcessing = 'N', + Result = 0, -- failure + ErrorMsg = ResultStr + WHERE AD_PInstance_ID=PInstance_ID; + COMMIT; + RETURN; + +END M_PriceList_Create; diff --git a/migration/316-320/013_version32.sql b/migration/316-320/013_version32.sql new file mode 100644 index 0000000000..067f4f5c5b --- /dev/null +++ b/migration/316-320/013_version32.sql @@ -0,0 +1,6 @@ +UPDATE AD_SYSTEM + SET releaseno = '320', + VERSION = '2007-05-01' + WHERE ad_system_id = 0 AND ad_client_id = 0; + +COMMIT ; diff --git a/migration/316-320/postgresql/001_add_c_acctschema_isallownegativeposting_pgsql.sql b/migration/316-320/postgresql/001_add_c_acctschema_isallownegativeposting_pgsql.sql new file mode 100644 index 0000000000..eb21d780be --- /dev/null +++ b/migration/316-320/postgresql/001_add_c_acctschema_isallownegativeposting_pgsql.sql @@ -0,0 +1,148 @@ +-- ADD C_AcctSchema.IsAllowNegativePosting - postgres script + +ALTER TABLE C_ACCTSCHEMA ADD COLUMN IsAllowNegativePosting CHAR(1) DEFAULT 'Y' CHECK (IsAllowNegativePosting IN ('Y','N')); + +INSERT INTO AD_ELEMENT + (ad_org_id, ad_element_id, columnname, + created, + createdby, description, entitytype, isactive, + NAME, printname, + updated, + ad_client_id, updatedby + ) + VALUES (0, 50065, 'IsAllowNegativePosting', + TO_TIMESTAMP ('2007-04-03 18:17:38', 'YYYY-MM-DD HH24:MI:SS'), + 100, 'Allow to post negative accounting values', 'D', 'Y', + 'Allow Negative Posting', 'Allow Negative Posting', + TO_TIMESTAMP ('2007-04-03 18:17:38', 'YYYY-MM-DD HH24:MI:SS'), + 0, 100 + ); + +INSERT INTO AD_COLUMN + (ad_org_id, ad_element_id, ad_reference_id, ad_table_id, + columnname, + created, + createdby, defaultvalue, description, entitytype, fieldlength, + isactive, isalwaysupdateable, isencrypted, isidentifier, iskey, + ismandatory, isparent, isselectioncolumn, issyncdatabase, + istranslated, isupdateable, NAME, seqno, + updated, + updatedby, VERSION, ad_client_id, ad_column_id + ) + VALUES (0, 50065, 20, 265, + 'IsAllowNegativePosting', + TO_TIMESTAMP ('2007-04-03 18:20:00', 'YYYY-MM-DD HH24:MI:SS'), + 100, 'Y', 'Allow to post negative accounting values', 'D', 1, + 'Y', 'N', 'N', 'N', 'N', + 'N', 'N', 'N', 'N', + 'N', 'Y', 'Allow Negative Posting', 0, + TO_TIMESTAMP ('2007-04-03 18:20:00', 'YYYY-MM-DD HH24:MI:SS'), + 100, 0, 0, 50210 + ); + +INSERT INTO AD_FIELD + (ad_column_id, ad_org_id, ad_tab_id, + created, + createdby, description, displaylength, entitytype, isactive, + iscentrallymaintained, isdisplayed, isencrypted, isfieldonly, + isheading, isreadonly, issameline, NAME, + updated, + ad_client_id, updatedby, ad_field_id + ) + VALUES (50210, 0, 199, + TO_TIMESTAMP ('2007-04-03 18:25:16', 'YYYY-MM-DD HH24:MI:SS'), + 100, 'Allow to post negative accounting values', 1, 'D', 'Y', + 'Y', 'Y', 'N', 'N', + 'N', 'N', 'N', 'Allow Negative Posting', + TO_TIMESTAMP ('2007-04-03 18:25:16', 'YYYY-MM-DD HH24:MI:SS'), + 0, 100, 50180 + ); + +UPDATE AD_FIELD + SET seqno = 260, + updated = TO_TIMESTAMP ('2007-04-03 18:26:28', 'YYYY-MM-DD HH24:MI:SS'), + updatedby = 100 + WHERE ad_field_id = 12522; + +UPDATE AD_FIELD + SET issameline = 'Y', + seqno = 250, + updated = TO_TIMESTAMP ('2007-04-03 18:31:50', 'YYYY-MM-DD HH24:MI:SS'), + updatedby = 100 + WHERE ad_field_id = 50180; + +-- update sequences + +UPDATE AD_SEQUENCE + SET currentnextsys = (SELECT MAX (ad_element_id) + 1 + FROM AD_ELEMENT + WHERE ad_element_id < 1000000) + WHERE NAME = 'AD_Element'; + +UPDATE AD_SEQUENCE + SET currentnextsys = (SELECT MAX (ad_column_id) + 1 + FROM AD_COLUMN + WHERE ad_column_id < 1000000) + WHERE NAME = 'AD_Column'; + +UPDATE AD_SEQUENCE + SET currentnextsys = (SELECT MAX (ad_field_id) + 1 + FROM AD_FIELD + WHERE ad_field_id < 1000000) + WHERE NAME = 'AD_Field'; + +-- insert translation tables + +INSERT INTO AD_ELEMENT_TRL + (ad_element_id, AD_LANGUAGE, ad_client_id, ad_org_id, isactive, + created, createdby, updated, updatedby, NAME, printname, + description, HELP, po_name, po_printname, po_description, + po_help, istranslated) + SELECT e.ad_element_id, l.AD_LANGUAGE, e.ad_client_id, e.ad_org_id, + e.isactive, e.created, e.createdby, e.updated, e.updatedby, e.NAME, + e.printname, e.description, e.HELP, e.po_name, e.po_printname, + e.po_description, e.po_help, 'N' + FROM AD_ELEMENT e, AD_LANGUAGE l + WHERE e.ad_element_id = 50065 + AND l.issystemlanguage = 'Y' + AND l.isbaselanguage = 'N' + AND NOT EXISTS ( + SELECT 1 + FROM AD_ELEMENT_TRL et + WHERE et.ad_element_id = e.ad_element_id + AND et.AD_LANGUAGE = l.AD_LANGUAGE); + +INSERT INTO AD_COLUMN_TRL + (ad_column_id, AD_LANGUAGE, ad_client_id, ad_org_id, isactive, + created, createdby, updated, updatedby, NAME, istranslated) + SELECT c.ad_column_id, l.AD_LANGUAGE, c.ad_client_id, c.ad_org_id, + c.isactive, c.created, c.createdby, c.updated, c.updatedby, c.NAME, + 'N' + FROM AD_COLUMN c, AD_LANGUAGE l + WHERE c.ad_column_id = 50210 + AND l.issystemlanguage = 'Y' + AND l.isbaselanguage = 'N' + AND NOT EXISTS ( + SELECT 1 + FROM AD_COLUMN_TRL ct + WHERE ct.ad_column_id = c.ad_column_id + AND ct.AD_LANGUAGE = l.AD_LANGUAGE); + +INSERT INTO AD_FIELD_TRL + (ad_field_id, AD_LANGUAGE, ad_client_id, ad_org_id, isactive, + created, createdby, updated, updatedby, NAME, description, HELP, + istranslated) + SELECT f.ad_field_id, l.AD_LANGUAGE, f.ad_client_id, f.ad_org_id, + f.isactive, f.created, f.createdby, f.updated, f.updatedby, f.NAME, + f.description, f.HELP, 'N' + FROM AD_FIELD f, AD_LANGUAGE l + WHERE f.ad_field_id = 50180 + AND l.issystemlanguage = 'Y' + AND l.isbaselanguage = 'N' + AND NOT EXISTS ( + SELECT 1 + FROM AD_FIELD_TRL ft + WHERE ft.ad_field_id = f.ad_field_id + AND ft.AD_LANGUAGE = l.AD_LANGUAGE); + +COMMIT ; \ No newline at end of file diff --git a/migration/316-320/postgresql/002_fix_I_Product_X12DE355_pgsql.sql b/migration/316-320/postgresql/002_fix_I_Product_X12DE355_pgsql.sql new file mode 100644 index 0000000000..6262b51c6b --- /dev/null +++ b/migration/316-320/postgresql/002_fix_I_Product_X12DE355_pgsql.sql @@ -0,0 +1,4 @@ +-- Fix I_Product.X12DE355 FieldLength: +ALTER TABLE i_product ALTER x12de355 TYPE character varying(4); +UPDATE AD_Column SET FieldLength=4 WHERE AD_Column_ID=7862; +COMMIT; diff --git a/migration/316-320/postgresql/003_fix_acct_constraints_pgsql.sql b/migration/316-320/postgresql/003_fix_acct_constraints_pgsql.sql new file mode 100644 index 0000000000..d4a611bb22 --- /dev/null +++ b/migration/316-320/postgresql/003_fix_acct_constraints_pgsql.sql @@ -0,0 +1,52 @@ +ALTER TABLE C_CHARGE_ACCT DROP CONSTRAINT CCHRAGE_CCHARGEACCT; +ALTER TABLE C_CHARGE_ACCT ADD CONSTRAINT CCHRAGE_CCHARGEACCT + FOREIGN KEY (C_CHARGE_ID) REFERENCES C_CHARGE(C_CHARGE_ID) + ON DELETE CASCADE + DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE A_ASSET_ACCT DROP CONSTRAINT AASSET_AASSETACCT; +ALTER TABLE A_ASSET_ACCT ADD CONSTRAINT AASSET_AASSETACCT + FOREIGN KEY (A_ASSET_ID) REFERENCES A_ASSET(A_ASSET_ID) + ON DELETE CASCADE + DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE A_ASSET_GROUP_ACCT DROP CONSTRAINT AASSETGROUP_AASSETGROUPACCT; +ALTER TABLE A_ASSET_GROUP_ACCT ADD CONSTRAINT AASSETGROUP_AASSETGROUPACCT + FOREIGN KEY (A_ASSET_GROUP_ID) REFERENCES A_ASSET_GROUP (A_ASSET_GROUP_ID) + ON DELETE CASCADE + DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE C_BANKACCOUNT_ACCT DROP CONSTRAINT CBANKACCOUNT_CBANKACCTACCT; +ALTER TABLE C_BANKACCOUNT_ACCT ADD CONSTRAINT CBANKACCOUNT_CBANKACCTACCT + FOREIGN KEY (C_BANKACCOUNT_ID) REFERENCES C_BANKACCOUNT (C_BANKACCOUNT_ID) + ON DELETE CASCADE + DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE C_BP_GROUP_ACCT DROP CONSTRAINT CBPGROUP_CBPGROUPACCT; +ALTER TABLE C_BP_GROUP_ACCT ADD CONSTRAINT CBPGROUP_CBPGROUPACCT + FOREIGN KEY (C_BP_GROUP_ID) REFERENCES C_BP_GROUP (C_BP_GROUP_ID) + ON DELETE CASCADE + DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE C_INTERORG_ACCT DROP CONSTRAINT ADORG_CINTERORGACCT; +ALTER TABLE C_INTERORG_ACCT ADD CONSTRAINT ADORG_CINTERORGACCT + FOREIGN KEY (AD_ORG_ID) REFERENCES AD_ORG (AD_ORG_ID) + ON DELETE CASCADE + DEFERRABLE INITIALLY DEFERRED; +ALTER TABLE C_INTERORG_ACCT DROP CONSTRAINT ADORGTO_CINTERORGACCT; +ALTER TABLE C_INTERORG_ACCT ADD CONSTRAINT ADORGTO_CINTERORGACCT + FOREIGN KEY (AD_ORGTO_ID) REFERENCES AD_ORG (AD_ORG_ID) + ON DELETE CASCADE + DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE C_CURRENCY_ACCT DROP CONSTRAINT CACCTSCHEMA_CCURRENCYACCT; +ALTER TABLE C_CURRENCY_ACCT ADD CONSTRAINT CACCTSCHEMA_CCURRENCYACCT + FOREIGN KEY (C_ACCTSCHEMA_ID) REFERENCES C_ACCTSCHEMA (C_ACCTSCHEMA_ID) + ON DELETE CASCADE + DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE C_CURRENCY_ACCT DROP CONSTRAINT CCURRENCY_CCURRENCYACCT; +ALTER TABLE C_CURRENCY_ACCT ADD CONSTRAINT CCURRENCY_CCURRENCYACCT + FOREIGN KEY (C_CURRENCY_ID) REFERENCES C_CURRENCY (C_CURRENCY_ID) + ON DELETE CASCADE + DEFERRABLE INITIALLY DEFERRED; diff --git a/migration/316-320/postgresql/004_fix_bug_1705164.sql b/migration/316-320/postgresql/004_fix_bug_1705164.sql new file mode 100644 index 0000000000..cdb77f4b9d --- /dev/null +++ b/migration/316-320/postgresql/004_fix_bug_1705164.sql @@ -0,0 +1,5 @@ +UPDATE AD_FIELD + SET issameline = 'N' + WHERE ad_field_id = 2204; + +COMMIT; \ No newline at end of file diff --git a/migration/316-320/postgresql/005_fix_bug_1705537.sql b/migration/316-320/postgresql/005_fix_bug_1705537.sql new file mode 100644 index 0000000000..35959ee371 --- /dev/null +++ b/migration/316-320/postgresql/005_fix_bug_1705537.sql @@ -0,0 +1,7 @@ +UPDATE AD_COLUMN + SET ad_reference_value_id = 182, + updated = TO_TIMESTAMP ('2007-04-22 23:11:58', 'YYYY-MM-DD HH24:MI:SS'), + updatedby = 100 + WHERE ad_column_id = 7968; + +COMMIT; \ No newline at end of file diff --git a/migration/316-320/postgresql/006_add_ProductCategoryParent.sql b/migration/316-320/postgresql/006_add_ProductCategoryParent.sql new file mode 100644 index 0000000000..5d675ca720 --- /dev/null +++ b/migration/316-320/postgresql/006_add_ProductCategoryParent.sql @@ -0,0 +1,102 @@ +INSERT INTO ad_element + (ad_element_id, ad_client_id, ad_org_id, isactive, + created, createdby, + updated, updatedby, + columnname, entitytype, NAME, + printname + ) + VALUES (50070, 0, 0, 'Y', + TO_DATE ('04/24/2007 12:30:00', 'MM/DD/YYYY HH24:MI:SS'), 100, + TO_DATE ('04/24/2007 12:30:00', 'MM/DD/YYYY HH24:MI:SS'), 100, + 'M_Product_Category_Parent_ID', 'D', 'Parent Product Category', + 'Parent Product Category' + ); + + +INSERT INTO ad_column + (ad_column_id, ad_client_id, ad_org_id, isactive, + created, + updated, createdby, + updatedby, name, description, help, version, + entitytype, columnname, ad_table_id, ad_reference_id, + ad_reference_value_id, + fieldlength, iskey, isparent, ismandatory, isupdateable, + isidentifier, seqno, istranslated, isencrypted, + isselectioncolumn, ad_element_id, callout, issyncdatabase, + isalwaysupdateable + ) + VALUES (50211, 0, 0, 'Y', + TO_DATE ('04/24/2007 12:30:00', 'MM/DD/YYYY HH24:MI:SS'), + TO_DATE ('04/24/2007 12:30:00', 'MM/DD/YYYY HH24:MI:SS'), 100, + 100, 'Parent Product Category', 'Parent Product Category', 'The parent product category is used to build a category tree.', 1, + 'D', 'M_Product_Category_Parent_ID', 209, 18, + 163, + 22, 'N', 'N', 'N', 'Y', + 'N', 0, 'N', 'N', + 'N', 50070, 'org.compiere.model.CalloutProductCategory.testForLoop', 'N', + 'N' + ); + + +INSERT INTO ad_field + (ad_field_id, ad_client_id, ad_org_id, isactive, + created, createdby, + updated, updatedby, + name, description, iscentrallymaintained, seqno, ad_tab_id, + ad_column_id, isdisplayed, displaylength, isreadonly, + issameline, isheading, isfieldonly, isencrypted, entitytype + ) + VALUES (50181, 0, 0, 'Y', + TO_DATE ('04/24/2007 12:30:00', 'MM/DD/YYYY HH24:MI:SS'), 100, + TO_DATE ('04/24/2007 12:30:00', 'MM/DD/YYYY HH24:MI:SS'), 100, + 'Parent Product Category', 'Parent Product Category', 'Y', 60, 189, + 50211, 'Y', 22, 'N', + 'N', 'N', 'N', 'N', 'D' + ); + +INSERT INTO ad_message + (ad_message_id, ad_client_id, ad_org_id, isactive, + created, createdby, + updated, updatedby, + value, msgtext, msgtype + ) + VALUES (50014, 0, 0, 'Y', + TO_DATE ('04/24/2007 12:30:00', 'MM/DD/YYYY HH24:MI:SS'), 100, + TO_DATE ('04/24/2007 12:30:00', 'MM/DD/YYYY HH24:MI:SS'), 100, + 'ProductCategoryLoopDetected', + 'A loop in the product category tree has been detected - the old value will be restored','E' + ); + +COMMIT ; + +UPDATE ad_sequence + SET currentnextsys = (SELECT MAX (ad_element_id) + 1 + FROM ad_element + WHERE ad_element_id < 1000000) + WHERE NAME = 'AD_Element'; + +UPDATE ad_sequence + SET currentnextsys = (SELECT MAX (ad_column_id) + 1 + FROM ad_column + WHERE ad_column_id < 1000000) + WHERE NAME = 'AD_Column'; + +UPDATE ad_sequence + SET currentnextsys = (SELECT MAX (ad_field_id) + 1 + FROM ad_field + WHERE ad_field_id < 1000000) + WHERE NAME = 'AD_Field'; + + UPDATE ad_sequence + SET currentnextsys = (SELECT MAX (ad_message_id) + 1 + FROM ad_message + WHERE ad_message_id < 1000000) + WHERE NAME = 'AD_Message'; + + +ALTER TABLE M_Product_Category ADD M_Product_Category_Parent_ID NUMERIC(10); +ALTER TABLE M_Product_Category ADD CONSTRAINT MProductCat_ParentCat FOREIGN KEY (M_Product_Category_Parent_ID) + REFERENCES M_Product_Category (M_Product_Category_ID); +UPDATE AD_Column SET IsSelectionColumn='Y' WHERE AD_Column_ID=2012; + +COMMIT ; \ No newline at end of file diff --git a/migration/316-320/postgresql/007_country_changes.sql b/migration/316-320/postgresql/007_country_changes.sql new file mode 100644 index 0000000000..6e3ec39ea1 --- /dev/null +++ b/migration/316-320/postgresql/007_country_changes.sql @@ -0,0 +1,32 @@ +-- juddm BugFix:(Country Changes) + +--add Serbian currency +INSERT INTO C_CURRENCY + (C_CURRENCY_ID, AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, CREATED, CREATEDBY, UPDATED, UPDATEDBY, ISO_CODE, + CURSYMBOL, DESCRIPTION, STDPRECISION, COSTINGPRECISION, ISEURO, ISEMUMEMBER) + VALUES(347, 0, 0, 'Y', TO_TIMESTAMP('2003-08-06','YYYY-MM-DD'),0, TO_TIMESTAMP('2000-01-02','YYYY-MM-DD'), 0, 'RSD', + 'RSD', 'Serbian Dinar', 2, 4, 'N', 'N'); + +-- add country Serbia +INSERT INTO C_COUNTRY + (C_COUNTRY_ID, AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, CREATED, CREATEDBY, UPDATED, UPDATEDBY, + NAME, DESCRIPTION, COUNTRYCODE, HASREGION, DISPLAYSEQUENCE, HASPOSTAL_ADD, C_CURRENCY_ID, + ISADDRESSLINESREVERSE, ISADDRESSLINESLOCALREVERSE) + VALUES (349, 0, 0, 'Y', TO_TIMESTAMP('2003-03-09', 'YYYY-MM-DD'), 0, TO_TIMESTAMP('2000-01-02','YYYY-MM-DD'), 0, + 'Serbia', 'Serbia', 'RS', 'N', '@C@, @P@', 'N', 347, 'N', 'N'); + +-- add country Montenegro +INSERT INTO C_COUNTRY + (C_COUNTRY_ID, AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, CREATED, CREATEDBY, UPDATED, UPDATEDBY, + NAME, DESCRIPTION, COUNTRYCODE, HASREGION, DISPLAYSEQUENCE, HASPOSTAL_ADD, C_CURRENCY_ID, + ISADDRESSLINESREVERSE, ISADDRESSLINESLOCALREVERSE) + VALUES (350, 0, 0, 'Y', TO_TIMESTAMP('2003-03-09','YYYY-MM-DD'), 0, TO_TIMESTAMP('2000-01-02','YYYY-MM-DD'), 0, + 'Montenegro', 'Montenegro', 'ME', 'N', '@C@, @P@', 'N', 102, 'N', 'N'); + +-- deactivate Yugoslavia +UPDATE C_COUNTRY SET ISACTIVE = 'N' WHERE C_COUNTRY_ID=346; + +-- deactivate Yugoslavia currency +UPDATE C_CURRENCY SET ISACTIVE = 'N' WHERE C_CURRENCY_ID = 314; + +COMMIT; diff --git a/migration/316-320/postgresql/008_2pack_enhancements.sql b/migration/316-320/postgresql/008_2pack_enhancements.sql new file mode 100644 index 0000000000..736394a7de --- /dev/null +++ b/migration/316-320/postgresql/008_2pack_enhancements.sql @@ -0,0 +1,79 @@ +ALTER TABLE AD_PACKAGE_EXP_DETAIL ADD ad_val_rule_id NUMERIC(10); + +INSERT INTO AD_COLUMN + (ad_column_id, ad_client_id, ad_org_id, isactive, + created, + updated, createdby, + updatedby, NAME, description, + HELP, + VERSION, entitytype, columnname, ad_table_id, ad_reference_id, + fieldlength, iskey, isparent, ismandatory, isupdateable, + isidentifier, seqno, istranslated, isencrypted, + isselectioncolumn, ad_element_id, issyncdatabase, + isalwaysupdateable + ) + VALUES (50212, 0, 0, 'Y', + TO_TIMESTAMP('2007-04-26','YYYY-MM-DD'), + TO_TIMESTAMP('2007-04-26','YYYY-MM-DD'), 100, + 100, 'Dynamic Validation', 'Dynamic Validation Rule', + 'These rules define how an entry is determined to valid. You can use variables for dynamic (context sensitive) validation.', + 0, 'D', 'AD_Val_Rule_ID', 50006, 18, + 22, 'N', 'N', 'N', 'Y', + 'N', 0, 'N', 'N', + 'N', 139, 'N', + 'N' + ); + +INSERT INTO AD_FIELD + (ad_field_id, ad_client_id, ad_org_id, isactive, + created, createdby, + updated, updatedby, + NAME, description, + HELP, + iscentrallymaintained, ad_tab_id, ad_column_id, isdisplayed, + displaylogic, displaylength, isreadonly, seqno, issameline, + isheading, isfieldonly, isencrypted, entitytype + ) + VALUES (50182, 0, 0, 'Y', + TO_TIMESTAMP('2007-04-26','YYYY-MM-DD'), 100, + TO_TIMESTAMP('2007-04-26','YYYY-MM-DD'), 100, + 'Dynamic Validation', 'Dynamic Validation Rule', + 'These rules define how an entry is determined to valid. You can use variables for dynamic (context sensitive) validation.', + 'Y', 50006, 50212, 'Y', + '@Type@=''V''', 22, 'N', 245, 'N', + 'N', 'N', 'N', 'D' + ); + +INSERT INTO AD_REF_LIST + (ad_ref_list_id, ad_client_id, ad_org_id, isactive, + created, createdby, + updated, updatedby, + VALUE, NAME, ad_reference_id, entitytype + ) + VALUES (50041, 0, 0, 'Y', + TO_TIMESTAMP('2007-04-26','YYYY-MM-DD'), 100, + TO_TIMESTAMP('2007-04-26','YYYY-MM-DD'), 100, + 'V', 'Dynamic Validation Rule', 50004, 'D' + ); + +COMMIT ; + +UPDATE AD_SEQUENCE + SET currentnextsys = (SELECT MAX (ad_column_id) + 1 + FROM AD_COLUMN + WHERE ad_column_id < 1000000) + WHERE NAME = 'AD_Column'; + +UPDATE AD_SEQUENCE + SET currentnextsys = (SELECT MAX (ad_field_id) + 1 + FROM AD_FIELD + WHERE ad_field_id < 1000000) + WHERE NAME = 'AD_Field'; + +UPDATE AD_SEQUENCE + SET currentnextsys = (SELECT MAX (ad_ref_list_id) + 1 + FROM AD_REF_LIST + WHERE ad_ref_list_id < 1000000) + WHERE NAME = 'AD_Ref_List'; + +COMMIT ; diff --git a/migration/316-320/postgresql/009_fix_bug_1707995.sql b/migration/316-320/postgresql/009_fix_bug_1707995.sql new file mode 100644 index 0000000000..c024c052bc --- /dev/null +++ b/migration/316-320/postgresql/009_fix_bug_1707995.sql @@ -0,0 +1,20 @@ +-- Bug Fix +-- http://sourceforge.net/tracker/index.php?func=detail&aid=1707995&group_id=176962&atid=879332 + +INSERT INTO AD_VAL_RULE (ad_val_rule_id, ad_client_id, ad_org_id, isactive, created, createdby, updated, updatedby, name, description, + type, code, entitytype ) + VALUES(271, 0, 0, 'Y', TO_TIMESTAMP('2007-04-26','YYYY-MM-DD'), 100, TO_TIMESTAMP('2007-04-26','YYYY-MM-DD'), 100, 'M_PriceList is SO/PO', 'Limits the Sales & Purchase Order window to the correct price lsits', + 'S', '(M_PriceList.IsSOPriceList = ''Y'' AND ''@IsSOTrx@''=''Y'') OR (M_PriceList.IsSOPriceList = ''N'' AND ''@IsSOTrx@''=''N'')', 'D'); + +UPDATE AD_COLUMN set ad_val_rule_id = 271 where ad_column_id = 2204; + + +COMMIT; + +UPDATE AD_SEQUENCE + SET currentnextsys = (SELECT MAX (ad_val_rule_id) + 1 + FROM AD_VAL_RULE + WHERE ad_val_rule_id < 1000000) + WHERE NAME = 'AD_Val_Rule'; + +COMMIT; diff --git a/migration/316-320/postgresql/010_add_feature_1708139.sql b/migration/316-320/postgresql/010_add_feature_1708139.sql new file mode 100644 index 0000000000..f2c2407dd7 --- /dev/null +++ b/migration/316-320/postgresql/010_add_feature_1708139.sql @@ -0,0 +1,18 @@ +-- Feature Request - Allow rounding up of price list (schema) to nearest 5 or 9 unit of currency +-- http://sourceforge.net/tracker/index.php?func=detail&aid=1708139&group_id=176962&atid=879335 + +INSERT INTO AD_REF_LIST + (ad_ref_list_id, ad_client_id, ad_org_id, isactive, created, createdby, updated, updatedby, + value, name, description, ad_reference_id, validfrom, validto, entitytype ) + VALUES (50042, 0, 0, 'Y', TO_TIMESTAMP('2007-04-26','YYYY-MM-DD'),100, TO_TIMESTAMP('2007-04-26','YYYY-MM-DD'), 100, + 9, 'Ending in 9/5', 'The price ends in either a 5 or 9 whole unit',155,NULL,NULL,'D'); + +COMMIT; + +UPDATE AD_SEQUENCE + SET currentnextsys = (SELECT MAX (ad_ref_list_id) + 1 + FROM AD_REF_LIST + WHERE ad_ref_list_id < 1000000) + WHERE NAME = 'AD_Ref_List'; + +COMMIT; diff --git a/migration/316-320/postgresql/011_cleaner_bug_1707995.sql b/migration/316-320/postgresql/011_cleaner_bug_1707995.sql new file mode 100644 index 0000000000..741e22a327 --- /dev/null +++ b/migration/316-320/postgresql/011_cleaner_bug_1707995.sql @@ -0,0 +1,8 @@ +-- equivalent cleaner code + +UPDATE AD_VAL_RULE + SET code = 'M_PriceList.IsSOPriceList = ''@IsSOTrx@''' + WHERE ad_val_rule_id = 271; + +COMMIT; + \ No newline at end of file diff --git a/migration/316-320/postgresql/012_alter_column.sql b/migration/316-320/postgresql/012_alter_column.sql new file mode 100644 index 0000000000..74ba493905 --- /dev/null +++ b/migration/316-320/postgresql/012_alter_column.sql @@ -0,0 +1,111 @@ +create or replace function altercolumn(tablename name, columnname name, datatype name, +nullclause varchar, defaultclause varchar) returns void as $$ +declare + command text; + viewtext text[]; + viewname name[]; + dropviews name[]; + i int; + j int; + v record; + sqltype text; + sqltype_short text; + typename name; +begin + if datatype is not null then + select pg_type.typname, format_type(pg_type.oid, pg_attribute.atttypmod) + into typename, sqltype + from pg_class, pg_attribute, pg_type + where relname = lower(tablename) + and relkind = 'r' + and pg_class.oid = pg_attribute.attrelid + and attname = lower(columnname) + and atttypid = pg_type.oid; + sqltype_short := sqltype; + if typename = 'numeric' then + sqltype_short := replace(sqltype, ',0', ''); + elsif strpos(sqltype,'character varying') = 1 then + sqltype_short := replace(sqltype, 'character varying', 'varchar'); + elsif sqltype = 'timestamp without time zone' then + sqltype_short := 'timestamp'; + end if; + if lower(datatype) <> sqltype and lower(datatype) <> sqltype_short then + i := 0; + for v in select a.relname, a.oid + from pg_class a, pg_depend b, pg_depend c, pg_class d, pg_attribute e + where a.oid = b.refobjid + and b.objid = c.objid + and b.refobjid <> c.refobjid + and b.deptype = 'n' + and c.refobjid = d.oid + and d.relname = lower(tablename) + and d.relkind = 'r' + and d.oid = e.attrelid + and e.attname = lower(columnname) + and c.refobjsubid = e.attnum + and a.relkind = 'v' + loop + i := i + 1; + viewtext[i] := pg_get_viewdef(v.oid); + viewname[i] := v.relname; + end loop; + if i > 0 then + begin + for j in 1 .. i loop + command := 'drop view ' || viewname[j]; + execute command; + dropviews[j] := viewname[j]; + end loop; + exception + when others then + i := array_upper(dropviews, 1); + if i > 0 then + for j in 1 .. i loop + command := 'create or replace view ' || dropviews[j] || ' as ' || viewtext[j]; + execute command; + end loop; + end if; + raise exception 'Failed to recreate dependent view'; + end; + end if; + command := 'alter table ' || lower(tablename) || ' alter column ' || lower(columnname) || ' type ' || lower(datatype); + execute command; + i := array_upper(dropviews, 1); + if i > 0 then + for j in 1 .. i loop + command := 'create or replace view ' || dropviews[j] || ' as ' || viewtext[j]; + execute command; + end loop; + end if; + end if; + end if; + + if defaultclause is not null then + if lower(defaultclause) = 'null' then + command := 'alter table ' || lower(tablename) || ' alter column ' || lower(columnname) || ' drop default '; + else + command := 'alter table ' || lower(tablename) || ' alter column ' || lower(columnname) || ' set default ''' || defaultclause || ''''; + end if; + execute command; + end if; + + if nullclause is not null then + if lower(nullclause) = 'not null' then + command := 'alter table ' || lower(tablename) || ' alter column ' || lower(columnname) || ' set not null'; + execute command; + elsif lower(nullclause) = 'null' then + command := 'alter table ' || lower(tablename) || ' alter column ' || lower(columnname) || ' drop not null'; + execute command; + end if; + end if; +end; +$$ language plpgsql; + +create table t_alter_column +( tablename name, columnname name, datatype name, nullclause varchar(10), defaultclause varchar(200)); + +create rule alter_column_rule as on insert to t_alter_column +do instead select altercolumn(new.tablename, new.columnname, new.datatype, new.nullclause, +new.defaultclause); + + diff --git a/migration/316-320/postgresql/013_version32.sql b/migration/316-320/postgresql/013_version32.sql new file mode 100644 index 0000000000..067f4f5c5b --- /dev/null +++ b/migration/316-320/postgresql/013_version32.sql @@ -0,0 +1,6 @@ +UPDATE AD_SYSTEM + SET releaseno = '320', + VERSION = '2007-05-01' + WHERE ad_system_id = 0 AND ad_client_id = 0; + +COMMIT ;